mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
1 line
157 KiB
JavaScript
1 line
157 KiB
JavaScript
!function(p){"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<arguments.length;e++)n[e]=arguments[e];return t(r.apply(null,n))}},A=function(n){return 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<arguments.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 function(){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&&String.prototype.isPrototypeOf(n)?"string":e}(n)===e}},b=m("string"),g=m("object"),y=m("array"),w=m("boolean"),x=m("function"),T=m("number"),O=Object.prototype.hasOwnProperty,k=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 merge zero objects");for(var t={},r=0;r<n.length;r++){var o=n[r];for(var i in o)O.call(o,i)&&(t[i]=u(t[i],o[i]))}return t}},C=k(function(n,e){return g(n)&&g(e)?C(n,e):e}),E=k(function(n,e){return e}),D=f,M=d,B=function(){return R},R=(r={fold:function(n,e){return n()},is:D,isSome:D,isNone:M,getOr:t=function(n){return n},getOrThunk:e=function(n){return n()},getOrDie:function(n){throw new Error(n||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:t,orThunk:e,map:B,ap:B,each:function(){},bind:B,flatten:B,exists:D,forall:M,filter:B,equals:n=function(n){return n.isNone()},equals_:n,toArray:function(){return[]},toString:A("none()")},Object.freeze&&Object.freeze(r),r),F=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){return t===n},isSome:M,isNone:D,getOr:n,getOrThunk:n,getOrDie:n,getOrNull:n,getOrUndefined:n,or:e,orThunk:e,map:function(n){return F(n(t))},ap:function(n){return n.fold(B,function(n){return F(n(t))})},each:function(n){n(t)},bind:r,flatten:n,exists:r,forall:r,filter:function(n){return n(t)?o:R},equals:function(n){return n.is(t)},equals_:function(n,e){return n.fold(D,function(n){return e(t,n)})},toArray:function(){return[t]},toString:function(){return"some("+t+")"}};return o},V={some:F,none:B,from:function(n){return null===n||n===undefined?R:F(n)}},N=Object.keys,H=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)}},z=function(n,r){return j(n,function(n,e,t){return{k:e,v:r(n,e,t)}})},j=function(r,o){var i={};return H(r,function(n,e){var t=o(n,e,r);i[t.k]=t.v}),i},L=function(n,t){var r=[];return H(n,function(n,e){r.push(t(n,e))}),r},U=A("touchstart"),P=A("touchmove"),$=A("touchend"),W=A("mousedown"),G=A("mousemove"),_=A("mouseup"),q=A("mouseover"),Y=A("keydown"),K=A("input"),X=A("change"),J=A("click"),Q=A("transitionend"),Z=A("selectstart"),nn=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}},en=function(n,e){var t=function(n,e){for(var t=0;t<n.length;t++){var r=n[t];if(r.test(e))return r}return undefined}(n,e);if(!t)return{major:0,minor:0};var r=function(n){return Number(e.replace(t,"$"+n))};return rn(r(1),r(2))},tn=function(){return rn(0,0)},rn=function(n,e){return{major:n,minor:e}},on={nu:rn,detect:function(n,e){var t=String(e).toLowerCase();return 0===n.length?tn():en(n,t)},unknown:tn},un="Firefox",an=function(n,e){return function(){return e===n}},cn=function(n){var e=n.current;return{current:e,version:n.version,isEdge:an("Edge",e),isChrome:an("Chrome",e),isIE:an("IE",e),isOpera:an("Opera",e),isFirefox:an(un,e),isSafari:an("Safari",e)}},sn={unknown:function(){return cn({current:undefined,version:on.unknown()})},nu:cn,edge:A("Edge"),chrome:A("Chrome"),ie:A("IE"),opera:A("Opera"),firefox:A(un),safari:A("Safari")},fn="Windows",ln="Android",dn="Solaris",mn="FreeBSD",gn=function(n,e){return function(){return e===n}},vn=function(n){var e=n.current;return{current:e,version:n.version,isWindows:gn(fn,e),isiOS:gn("iOS",e),isAndroid:gn(ln,e),isOSX:gn("OSX",e),isLinux:gn("Linux",e),isSolaris:gn(dn,e),isFreeBSD:gn(mn,e)}},pn={unknown:function(){return vn({current:undefined,version:on.unknown()})},nu:vn,windows:A(fn),ios:A("iOS"),android:A(ln),linux:A("Linux"),osx:A("OSX"),solaris:A(dn),freebsd:A(mn)},hn=(o=Array.prototype.indexOf)===undefined?function(n,e){return Cn(n,e)}:function(n,e){return o.call(n,e)},bn=function(n,e){return-1<hn(n,e)},yn=function(n,e){for(var t=n.length,r=new Array(t),o=0;o<t;o++){var i=n[o];r[o]=e(i,o,n)}return r},wn=function(n,e){for(var t=0,r=n.length;t<r;t++)e(n[t],t,n)},xn=function(n,e){for(var t=[],r=0,o=n.length;r<o;r++){var i=n[r];e(i,r,n)&&t.push(i)}return t},Sn=function(n,e,t){return 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},Tn=function(n,e,t){return wn(n,function(n){t=e(t,n)}),t},On=function(n,e){for(var t=0,r=n.length;t<r;t++){var o=n[t];if(e(o,t,n))return V.some(o)}return V.none()},kn=function(n,e){for(var t=0,r=n.length;t<r;t++)if(e(n[t],t,n))return V.some(t);return V.none()},Cn=function(n,e){for(var t=0,r=n.length;t<r;++t)if(n[t]===e)return t;return-1},En=Array.prototype.push,Dn=function(n){for(var e=[],t=0,r=n.length;t<r;++t){if(!Array.prototype.isPrototypeOf(n[t]))throw new Error("Arr.flatten item "+t+" was not an array, input: "+n);En.apply(e,n[t])}return e},In=function(n,e){var t=yn(n,e);return Dn(t)},An=function(n,e){for(var t=0,r=n.length;t<r;++t)if(!0!==e(n[t],t,n))return!1;return!0},Mn=Array.prototype.slice,Bn=function(n){var e=Mn.call(n,0);return e.reverse(),e},Rn=function(n){return[n]},Fn=(x(Array.from)&&Array.from,function(n,e){var t=String(e).toLowerCase();return On(n,function(n){return n.search(t)})}),Vn=function(n,t){return Fn(n,t).map(function(n){var e=on.detect(n.versionRegexes,t);return{current:n.name,version:e}})},Nn=function(n,t){return Fn(n,t).map(function(n){var e=on.detect(n.versionRegexes,t);return{current:n.name,version:e}})},Hn=function(n,e){return-1!==n.indexOf(e)},zn=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,jn=function(e){return function(n){return Hn(n,e)}},Ln=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(n){return Hn(n,"edge/")&&Hn(n,"chrome")&&Hn(n,"safari")&&Hn(n,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,zn],search:function(n){return Hn(n,"chrome")&&!Hn(n,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(n){return Hn(n,"msie")||Hn(n,"trident")}},{name:"Opera",versionRegexes:[zn,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:jn("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:jn("firefox")},{name:"Safari",versionRegexes:[zn,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(n){return(Hn(n,"safari")||Hn(n,"mobile/"))&&Hn(n,"applewebkit")}}],Un=[{name:"Windows",search:jn("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(n){return Hn(n,"iphone")||Hn(n,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:jn("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:jn("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:jn("linux"),versionRegexes:[]},{name:"Solaris",search:jn("sunos"),versionRegexes:[]},{name:"FreeBSD",search:jn("freebsd"),versionRegexes:[]}],Pn={browsers:A(Ln),oses:A(Un)},$n=function(n){var e,t,r,o,i,u,a,c,s,f,l,d=Pn.browsers(),m=Pn.oses(),g=Vn(d,n).fold(sn.unknown,sn.nu),v=Nn(m,n).fold(pn.unknown,pn.nu);return{browser:g,os:v,deviceType:(t=g,r=n,o=(e=v).isiOS()&&!0===/ipad/i.test(r),i=e.isiOS()&&!o,u=e.isAndroid()&&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),isTouch:A(s),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:A(l)})}},Wn={detect:nn(function(){var n=p.navigator.userAgent;return $n(n)})},Gn={tap:A("alloy.tap")},_n=A("alloy.focus"),qn=A("alloy.blur.post"),Yn=A("alloy.receive"),Kn=A("alloy.execute"),Xn=A("alloy.focus.item"),Jn=Gn.tap,Qn=Wn.detect().deviceType.isTouch()?Gn.tap:J,Zn=A("alloy.longpress"),ne=A("alloy.system.init"),ee=A("alloy.system.scroll"),te=A("alloy.system.attached"),re=A("alloy.system.detached"),oe=function(n,e){ce(n,n.element(),e,{})},ie=function(n,e,t){ce(n,n.element(),e,t)},ue=function(n){oe(n,Kn())},ae=function(n,e,t){ce(n,e,t,{})},ce=function(n,e,t,r){var o=C({target:e},r);n.getSystem().triggerEvent(t,e,z(o,A))},se=function(n){if(null===n||n===undefined)throw new Error("Node cannot be null or undefined");return{dom:A(n)}},fe={fromHtml:function(n,e){var t=(e||p.document).createElement("div");if(t.innerHTML=n,!t.hasChildNodes()||1<t.childNodes.length)throw p.console.error("HTML does not have a single root node",n),new Error("HTML must have a single root node");return se(t.childNodes[0])},fromTag:function(n,e){var t=(e||p.document).createElement(n);return se(t)},fromText:function(n,e){var t=(e||p.document).createTextNode(n);return se(t)},fromDom:se,fromPoint:function(n,e,t){var r=n.dom();return V.from(r.elementFromPoint(e,t)).map(se)}},le=(p.Node.ATTRIBUTE_NODE,p.Node.CDATA_SECTION_NODE,p.Node.COMMENT_NODE,p.Node.DOCUMENT_NODE),de=(p.Node.DOCUMENT_TYPE_NODE,p.Node.DOCUMENT_FRAGMENT_NODE,p.Node.ELEMENT_NODE),me=p.Node.TEXT_NODE,ge=(p.Node.PROCESSING_INSTRUCTION_NODE,p.Node.ENTITY_REFERENCE_NODE,p.Node.ENTITY_NODE,p.Node.NOTATION_NODE,function(n){return n.dom().nodeName.toLowerCase()}),ve=function(e){return function(n){return n.dom().nodeType===e}},pe=ve(de),he=ve(me),be=function(n){var e=he(n)?n.dom().parentNode:n.dom();return e!==undefined&&null!==e&&e.ownerDocument.body.contains(e)},ye=nn(function(){return we(fe.fromDom(p.document))}),we=function(n){var e=n.dom().body;if(null===e||e===undefined)throw new Error("Body is not available yet");return fe.fromDom(e)},xe=function(){for(var e=[],n=0;n<arguments.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 number of arguments to struct. Expected "['+e.length+']", got '+t.length+" arguments");var r={};return wn(e,function(n,e){r[n]=A(t[e])}),r}},Se=function(n){return n.slice(0).sort()},Te=function(n,e){throw new Error("All required keys ("+Se(n).join(", ")+") were not specified. Specified keys were: "+Se(e).join(", ")+".")},Oe=function(n){throw new Error("Unsupported keys for object: "+Se(n).join(", "))},ke=function(e,n){if(!y(n))throw new Error("The "+e+" fields must be an array. Was: "+n+".");wn(n,function(n){if(!b(n))throw new Error("The value "+n+" in the "+e+" fields was not a string.")})},Ce=function(n){var t=Se(n);On(t,function(n,e){return e<t.length-1&&n===t[e+1]}).each(function(n){throw new Error("The field: "+n+" occurs more than once in the combined fields: ["+t.join(", ")+"].")})},Ee=function(o,i){var u=o.concat(i);if(0===u.length)throw new Error("You must specify at least one required or optional field.");return ke("required",o),ke("optional",i),Ce(u),function(e){var t=N(e);An(o,function(n){return bn(t,n)})||Te(o,t);var n=xn(t,function(n){return!bn(u,n)});0<n.length&&Oe(n);var r={};return wn(o,function(n){r[n]=A(e[n])}),wn(i,function(n){r[n]=A(Object.prototype.hasOwnProperty.call(e,n)?V.some(e[n]):V.none())}),r}},De="undefined"!=typeof p.window?p.window:Function("return this;")(),Ie=function(n,e){return function(n,e){for(var t=e!==undefined&&null!==e?e:De,r=0;r<n.length&&t!==undefined&&null!==t;++r)t=t[n[r]];return t}(n.split("."),e)},Ae={getOrDie:function(n,e){var t=Ie(n,e);if(t===undefined||null===t)throw n+" not available on this browser";return t}},Me=de,Be=le,Re=function(n,e){var t=n.dom();if(t.nodeType!==Me)return!1;if(t.matches!==undefined)return t.matches(e);if(t.msMatchesSelector!==undefined)return t.msMatchesSelector(e);if(t.webkitMatchesSelector!==undefined)return t.webkitMatchesSelector(e);if(t.mozMatchesSelector!==undefined)return t.mozMatchesSelector(e);throw new Error("Browser lacks native selectors")},Fe=function(n){return n.nodeType!==Me&&n.nodeType!==Be||0===n.childElementCount},Ve=function(n,e){var t=e===undefined?p.document:e.dom();return Fe(t)?[]:yn(t.querySelectorAll(n),fe.fromDom)},Ne=function(n,e){var t=e===undefined?p.document:e.dom();return Fe(t)?V.none():V.from(t.querySelector(n)).map(fe.fromDom)},He=function(n,e){return n.dom()===e.dom()},ze=(Wn.detect().browser.isIE(),function(n){return fe.fromDom(n.dom().ownerDocument)}),je=function(n){var e=n.dom();return V.from(e.parentNode).map(fe.fromDom)},Le=function(n){var e=n.dom();return yn(e.childNodes,fe.fromDom)},Ue=function(n){return e=0,t=n.dom().childNodes,V.from(t[e]).map(fe.fromDom);var e,t},Pe=(xe("element","offset"),function(e,t){Ue(e).fold(function(){$e(e,t)},function(n){e.dom().insertBefore(t.dom(),n.dom())})}),$e=function(n,e){n.dom().appendChild(e.dom())},We=function(e,n){wn(n,function(n){$e(e,n)})},Ge=function(n){n.dom().textContent="",wn(Le(n),function(n){_e(n)})},_e=function(n){var e=n.dom();null!==e.parentNode&&e.parentNode.removeChild(e)},qe=function(n){oe(n,re());var e=n.components();wn(e,qe)},Ye=function(n){var e=n.components();wn(e,Ye),oe(n,te())},Ke=function(n,e){Xe(n,e,$e)},Xe=function(n,e,t){n.getSystem().addToWorld(e),t(n.element(),e.element()),be(n.element())&&Ye(e),n.syncComponents()},Je=function(n){qe(n),_e(n.element()),n.getSystem().removeFromWorld(n)},Qe=function(e){var n=je(e.element()).bind(function(n){return e.getSystem().getByDom(n).fold(V.none,V.some)});Je(e),n.each(function(n){n.syncComponents()})},Ze=function(t){return{is:function(n){return t===n},isValue:d,isError:f,getOr:A(t),getOrThunk:A(t),getOrDie:A(t),or:function(n){return Ze(t)},orThunk:function(n){return Ze(t)},fold:function(n,e){return e(t)},map:function(n){return Ze(n(t))},mapError:function(n){return Ze(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:function(){return V.some(t)}}},nt=function(t){return{is:f,isValue:f,isError:d,getOr:h,getOrThunk:function(n){return n()},getOrDie: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 nt(t)},mapError:function(n){return nt(n(t))},each:I,bind:function(n){return nt(t)},exists:f,forall:d,toOption:V.none}},et={value:Ze,error:nt},tt=function(u){if(!y(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(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 named cata (sorry)");if(!y(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:function(){if(arguments.length!==u.length)throw new Error("Wrong number of arguments to 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("Wrong number of arguments to match. Expected: "+a.join(",")+"\nActual: "+e.join(","));if(!An(a,function(n){return bn(e,n)}))throw new Error("Not all branches were specified when using match. Specified: "+e.join(", ")+"\nRequired: "+a.join(", "));return n[o].apply(null,t)},log:function(n){p.console.log(n,{constructors:a,constructor:o,params:t})}}}}),t},rt=tt([{strict:[]},{defaultedThunk:["fallbackThunk"]},{asOption:[]},{asDefaultedOptionThunk:["fallbackThunk"]},{mergeWithThunk:["baseThunk"]}]),ot=function(n){return rt.defaultedThunk(A(n))},it=rt.strict,ut=rt.asOption,at=rt.defaultedThunk,ct=rt.mergeWithThunk,st=(tt([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]),function(n){var e=[],t=[];return wn(n,function(n){n.fold(function(n){e.push(n)},function(n){t.push(n)})}),{errors:e,values:t}}),ft=function(n){return v(et.error,Dn)(n)},lt=function(n,e){var t,r,o=st(n);return 0<o.errors.length?ft(o.errors):(t=o.values,r=e,et.value(C.apply(undefined,[r].concat(t))))},dt=function(n){var e=st(n);return 0<e.errors.length?ft(e.errors):et.value(e.values)},mt=function(e){return function(n){return n.hasOwnProperty(e)?V.from(n[e]):V.none()}},gt=function(n,e){return mt(e)(n)},vt=function(n,e){var t={};return t[n]=e,t},pt=function(n,e){return t=n,r={},wn(e,function(n){t[n]!==undefined&&t.hasOwnProperty(n)&&(r[n]=t[n])}),r;var t,r},ht=function(n,e){return t=e,r={},H(n,function(n,e){bn(t,e)||(r[e]=n)}),r;var t,r},bt=function(n){return mt(n)},yt=function(n,e){return t=n,r=e,function(n){return mt(t)(n).getOr(r)};var t,r},wt=function(n,e){return gt(n,e)},xt=function(n,e){return vt(n,e)},St=function(n){return e={},wn(n,function(n){e[n.key]=n.value}),e;var e},Tt=function(n,e){return lt(n,e)},Ot=function(n,e){return r=e,(t=n).hasOwnProperty(r)&&t[r]!==undefined&&null!==t[r];var t,r},kt=tt([{setOf:["validator","valueType"]},{arrOf:["valueType"]},{objOf:["fields"]},{itemOf:["validator"]},{choiceOf:["key","branches"]},{thunk:["description"]},{func:["args","outputSchema"]}]),Ct=tt([{field:["name","presence","type"]},{state:["name"]}]),Et=function(){return Ae.getOrDie("JSON")},Dt=function(n,e,t){return Et().stringify(n,e,t)},It=function(n){return g(n)&&100<N(n).length?" removed due to size":Dt(n,null,2)},At=function(n,e){return et.error([{path:n,getErrorInfo:e}])},Mt=tt([{field:["key","okey","presence","prop"]},{state:["okey","instantiator"]}]),Bt=function(t,r,o){return gt(r,o).fold(function(){return n=o,e=r,At(t,function(){return'Could not find valid *strict* value for "'+n+'" in '+It(e)});var n,e},et.value)},Rt=function(n,e,t){var r=gt(n,e).fold(function(){return t(n)},h);return et.value(r)},Ft=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).map(function(n){return vt(e,c(n))})},u=function(n){return n.fold(function(){var n=vt(e,c(V.none()));return et.value(n)},function(n){return t.extract(o.concat([i]),c,n).map(function(n){return vt(e,c(V.some(n)))})})};return n.fold(function(){return Bt(o,a,i).bind(r)},function(n){return Rt(a,i,n).bind(r)},function(){return(n=a,e=i,et.value(gt(n,e))).bind(u);var n,e},function(n){return(e=a,t=i,r=n,o=gt(e,t).map(function(n){return!0===n?r(e):n}),et.value(o)).bind(u);var e,t,r,o},function(n){var e=n(a);return Rt(a,i,A({})).map(function(n){return C(e,n)}).bind(r)})},function(n,e){var t=e(a);return et.value(vt(n,c(t)))})},Vt=function(r){return{extract:function(t,n,e){return r(e,n).fold(function(n){return e=n,At(t,function(){return e});var e},et.value)},toString:function(){return"val"},toDsl:function(){return kt.itemOf(r)}}},Nt=function(n){var c=Ht(n),s=Sn(n,function(e,n){return n.fold(function(n){return C(e,xt(n,!0))},A(e))},{});return{extract:function(n,e,t){var r,o,i,u=w(t)?[]:(o=N(r=t),xn(o,function(n){return Ot(r,n)})),a=xn(u,function(n){return!Ot(s,n)});return 0===a.length?c.extract(n,e,t):(i=a,At(n,function(){return"There are unsupported fields: ["+i.join(", ")+"] specified"}))},toString:c.toString,toDsl:c.toDsl}},Ht=function(a){return{extract:function(n,e,t){return r=n,o=t,i=e,u=yn(a,function(n){return Ft(r,o,n,i)}),lt(u,{});var r,o,i,u},toString:function(){return"obj{\n"+yn(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 kt.objOf(yn(a,function(n){return n.fold(function(n,e,t,r){return Ct.field(n,t,r)},function(n,e){return Ct.state(n)})}))}}},zt=function(t,i){var e=function(n,e){return(o=Vt(t),{extract:function(t,r,n){var e=yn(n,function(n,e){return o.extract(t.concat(["["+e+"]"]),r,n)});return dt(e)},toString:function(){return"array("+o.toString()+")"},toDsl:function(){return kt.arrOf(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=yn(n,function(n){return Mt.field(n,n,it(),i)});return Ht(e).extract(t,r,o)})},toString:function(){return"setOf("+i.toString()+")"},toDsl:function(){return kt.setOf(t,i)}}},jt=A(Vt(et.value)),Lt=Mt.state,Ut=Mt.field,Pt=function(t,e,r,o,i){return wt(o,i).fold(function(){return n=o,e=i,At(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+It(n)});var n,e},function(n){return Ht(n).extract(t.concat(["branch: "+i]),e,r)})},$t=function(o,i){return{extract:function(e,t,r){return wt(r,o).fold(function(){return n=o,At(e,function(){return'Choice schema did not contain choice key: "'+n+'"'});var n},function(n){return Pt(e,t,r,i,n)})},toString:function(){return"chooseOn("+o+"). Possible values: "+N(i)},toDsl:function(){return kt.choiceOf(o,i)}}},Wt=Vt(et.value),Gt=function(n,e,t,r){return e.extract([n],t,r).fold(function(n){return et.error({input:r,errors:n})},et.value)},_t=function(n,e,t){return Gt(n,e,A,t)},qt=function(n){return n.fold(function(n){throw new Error(Xt(n))},h)},Yt=function(n,e,t){return qt(Gt(n,e,h,t))},Kt=function(n,e,t){return qt(_t(n,e,t))},Xt=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,yn(t,function(n){return"Failed path: ("+n.path.join(" > ")+")\n"+n.getErrorInfo()}))+"\n\nInput object: "+It(n.input);var e,t},Jt=function(n,e){return $t(n,e)},Qt=A(Wt),Zt=(i=x,u="function",Vt(function(n){var e=typeof n;return i(n)?et.value(n):et.error("Expected type: "+u+" but got: "+e)})),nr=function(n){return Ut(n,n,it(),jt())},er=function(n,e){return Ut(n,n,it(),e)},tr=function(n){return er(n,Zt)},rr=function(n,e){return Ut(n,n,it(),Ht(e))},or=function(n){return Ut(n,n,ut(),jt())},ir=function(n,e){return Ut(n,n,ut(),Ht(e))},ur=function(n,e){return Ut(n,n,ut(),Nt(e))},ar=function(n,e){return Ut(n,n,ot(e),jt())},cr=function(n,e,t){return Ut(n,n,ot(e),t)},sr=function(n,e){return Lt(n,e)},fr=function(n){if(!Ot(n,"can")&&!Ot(n,"abort")&&!Ot(n,"run"))throw new Error("EventHandler defined by: "+Dt(n,null,2)+" does not have can, abort, or run!");return Yt("Extracting event.handler",Nt([ar("can",A(!0)),ar("abort",A(!1)),ar("run",I)]),n)},lr=function(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 Tn(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 Tn(o,function(n,e){return n||i(e).apply(undefined,t)},!1)});return fr({can:n,abort:u,run:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];wn(t,function(n){n.run.apply(undefined,e)})}})},dr=function(n){return St(n)},mr=function(n,e){return{key:n,value:fr({abort:e})}},gr=function(n,e){return{key:n,value:fr({run:e})}},vr=function(n,e,t){return{key:n,value:fr({run:function(n){e.apply(undefined,[n].concat(t))}})}},pr=function(n){return function(r){return{key:n,value:fr({run:function(n,e){var t;t=e,He(n.element(),t.event().target())&&r(n,e)}})}}},hr=function(n,e,t){var u,r,o=e.partUids()[t];return r=o,gr(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())})})},br=function(n){return gr(n,function(n,e){e.cut()})},yr=pr(te()),wr=pr(re()),xr=pr(ne()),Sr=(a=Kn(),function(n){return gr(a,n)}),Tr=function(n){return yn(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.length-"/*".length);var e,t,r,o})},Or=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.toFunctionAnnotation=function(){return{name:e,parameters:Tr(i)}},n},kr=Ee(["tag"],["classes","attributes","styles","value","innerHtml","domChildren","defChildren"]),Cr=function(n){return{tag:n.tag(),classes:n.classes().getOr([]),attributes:n.attributes().getOr({}),styles:n.styles().getOr({}),value:n.value().getOr("<none>"),innerHtml:n.innerHtml().getOr("<none>"),defChildren:n.defChildren().fold(function(){return"<none>"},function(n){return Dt(n,null,2)}),domChildren:n.domChildren().fold(function(){return"<none>"},function(n){return 0===n.length?"0 children, but still specified":String(n.length)})}},Er=Ee([],["classes","attributes","styles","value","innerHtml","defChildren","domChildren"]),Dr=function(e,n,t){return n.fold(function(){return t.fold(function(){return{}},function(n){return xt(e,n)})},function(n){return t.fold(function(){return xt(e,n)},function(n){return xt(e,n)})})},Ir=function(t,r,o){return xr(function(n,e){o(n,t,r)})},Ar=function(n,e,t,r,o,i){var u,a,c=n,s=ir(e,[(u="config",a=n,Ut(u,u,ut(),a))]);return Rr(c,s,e,t,r,o,i)},Mr=function(o,i,u){var n,e,t,r,a,c;return n=function(t){for(var n=[],e=1;e<arguments.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 configuration 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.toFunctionAnnotation=function(){return{name:e,parameters:Tr(c.slice(0,1).concat(c.slice(3)))}},n},Br=function(n){return{key:n,value:undefined}},Rr=function(t,n,r,o,e,i,u){var a=function(n){return Ot(n,r)?n[r]():V.none()},c=z(e,function(n,e){return Mr(r,n,e)}),s=z(i,function(n,e){return Or(n,e)}),f=C(s,c,{revoke:l(Br,r),config:function(n){var e=Kt(r+"-config",t,n);return{key:r,value:{config:e,me:f,configAsRaw:nn(function(){return Yt(r+"-config",t,n)}),initialConfig:n,state:u}}},schema:function(){return n},exhibit:function(n,t){return a(n).bind(function(e){return wt(o,"exhibit").map(function(n){return n(t,e.config,e.state)})}).getOr(Er({}))},name:function(){return r},handlers:function(n){return a(n).bind(function(e){return wt(o,"events").map(function(n){return n(e.config,e.state)})}).getOr({})}});return f},Fr=function(n,e){return Vr(n,e,{validate:x,label:"function"})},Vr=function(r,o,i){if(0===o.length)throw new Error("You must specify at least one required field.");return ke("required",o),Ce(o),function(e){var t=N(e);An(o,function(n){return bn(t,n)})||Te(o,t),r(o,t);var n=xn(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 ("+Se(n).join(", ")+") were not.")}(n,i.label),e}},Nr=function(e,n){var t=xn(n,function(n){return!bn(e,n)});0<t.length&&Oe(t)},Hr=I,zr=function(n){return Fr(Nr,n)},jr={init:function(){return Lr({readState:function(){return"No State required"}})}},Lr=function(n){return Fr(Hr,["readState"])(n),n},Ur=function(n){return St(n)},Pr=Nt([nr("fields"),nr("name"),ar("active",{}),ar("apis",{}),ar("state",jr),ar("extra",{})]),$r=function(n){var e,t,r,o,i,u,a,c,s=Yt("Creating behaviour: "+n.name,Pr,n);return e=s.fields,t=s.name,r=s.active,o=s.apis,i=s.extra,u=s.state,a=Nt(e),c=ir(t,[ur("config",e)]),Rr(a,c,t,r,o,i,u)},Wr=Nt([nr("branchKey"),nr("branches"),nr("name"),ar("active",{}),ar("apis",{}),ar("state",jr),ar("extra",{})]),Gr=A(undefined),_r=function(n,e,t){if(!(b(t)||w(t)||T(t)))throw p.console.error("Invalid call to Attr.set. Key ",e,":: Value ",t,":: Element ",n),new Error("Attribute value was not simple");n.setAttribute(e,t+"")},qr=function(n,e,t){_r(n.dom(),e,t)},Yr=function(n,e){var t=n.dom();H(e,function(n,e){_r(t,e,n)})},Kr=function(n,e){var t=n.dom().getAttribute(e);return null===t?undefined:t},Xr=function(n,e){var t=n.dom();return!(!t||!t.hasAttribute)&&t.hasAttribute(e)},Jr=function(n,e){n.dom().removeAttribute(e)},Qr=function(n,e){var t=Kr(n,e);return t===undefined||""===t?[]:t.split(" ")},Zr=function(n){return n.dom().classList!==undefined},no=function(n){return Qr(n,"class")},eo=function(n,e){return o=e,i=Qr(t=n,r="class").concat([o]),qr(t,r,i.join(" ")),!0;var t,r,o,i},to=function(n,e){return o=e,0<(i=xn(Qr(t=n,r="class"),function(n){return n!==o})).length?qr(t,r,i.join(" ")):Jr(t,r),!1;var t,r,o,i},ro=function(n,e){Zr(n)?n.dom().classList.add(e):eo(n,e)},oo=function(n,e){var t;Zr(n)?n.dom().classList.remove(e):to(n,e),0===(Zr(t=n)?t.dom().classList:no(t)).length&&Jr(t,"class")},io=function(n,e){return Zr(n)?n.dom().classList.toggle(e):(r=e,bn(no(t=n),r)?to(t,r):eo(t,r));var t,r},uo=function(n,e){return Zr(n)&&n.dom().classList.contains(e)},ao=function(n,e,t){oo(n,t),ro(n,e)},co=Object.freeze({toAlpha:function(n,e,t){ao(n.element(),e.alpha(),e.omega())},toOmega:function(n,e,t){ao(n.element(),e.omega(),e.alpha())},isAlpha:function(n,e,t){return uo(n.element(),e.alpha())},isOmega:function(n,e,t){return uo(n.element(),e.omega())},clear:function(n,e,t){oo(n.element(),e.alpha()),oo(n.element(),e.omega())}}),so=[nr("alpha"),nr("omega")],fo=$r({fields:so,name:"swapping",apis:co}),lo=function(n){var e=n,t=function(){return e};return{get:t,set:function(n){e=n},clone:function(){return lo(t())}}};function mo(n,e,t,r,o){return n(t,r)?V.some(t):x(o)&&o(t)?V.none():e(t,r,o)}var go=function(n,e,t){for(var r=n.dom(),o=x(t)?t:A(!1);r.parentNode;){r=r.parentNode;var i=fe.fromDom(r);if(e(i))return V.some(i);if(o(i))break}return V.none()},vo=function(n,e,t){return mo(function(n){return e(n)},go,n,e,t)},po=function(n,r){var o=function(n){for(var e=0;e<n.childNodes.length;e++){if(r(fe.fromDom(n.childNodes[e])))return V.some(fe.fromDom(n.childNodes[e]));var t=o(n.childNodes[e]);if(t.isSome())return t}return V.none()};return o(n.dom())},ho=function(n){n.dom().focus()},bo=function(n){n.dom().blur()},yo=function(n){var e=n!==undefined?n.dom():p.document;return V.from(e.activeElement).map(fe.fromDom)},wo=function(e){return yo(ze(e)).filter(function(n){return e.dom().contains(n.dom())})},xo=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),So=tinymce.util.Tools.resolve("tinymce.ThemeManager"),To=function(n){var e=p.document.createElement("a");e.target="_blank",e.href=n.href,e.rel="noreferrer noopener";var t=p.document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,p.window,0,0,0,0,0,!1,!1,!1,!1,0,null),p.document.body.appendChild(e),e.dispatchEvent(t),p.document.body.removeChild(e)},Oo={formatChanged:A("formatChanged"),orientationChanged:A("orientationChanged"),dropupDismissed:A("dropupDismissed")},ko=function(n){return n.dom().innerHTML},Co=function(n,e){var t,r,o=ze(n).dom(),i=fe.fromDom(o.createDocumentFragment()),u=(t=e,(r=(o||p.document).createElement("div")).innerHTML=t,Le(fe.fromDom(r)));We(i,u),Ge(n),$e(n,i)},Eo=function(n){return e=n,t=!1,fe.fromDom(e.dom().cloneNode(t));var e,t},Do=function(n){var e,t,r,o=Eo(n);return e=o,t=fe.fromTag("div"),r=fe.fromDom(e.dom().cloneNode(!0)),$e(t,r),ko(t)},Io=function(n){return Do(n)},Ao=Object.freeze({events:function(a){return dr([gr(Yn(),function(o,i){var n,e,u=a.channels(),t=N(u),r=(n=t,(e=i).universal()?n:xn(n,function(n){return bn(e.channels(),n)}));wn(r,function(n){var e=u[n](),t=e.schema(),r=Kt("channel["+n+"] data\nReceiver: "+Io(o.element()),t,i.data());e.onReceive()(o,r)})})])}}),Mo=function(n){for(var e=[],t=function(n){e.push(n)},r=0;r<n.length;r++)n[r].each(t);return e},Bo=function(n,e){for(var t=0;t<n.length;t++){var r=e(n[t],t);if(r.isSome())return r}return V.none()},Ro="unknown",Fo=[],Vo=["alloy/data/Fields","alloy/debugging/Debugging"],No=function(){var n=new Error;if(n.stack!==undefined){var e=n.stack.split("\n");return On(e,function(e){return 0<e.indexOf("alloy")&&!kn(Vo,function(n){return-1<e.indexOf(n)}).isSome()}).getOr(Ro)}return Ro},Ho={logEventCut:I,logEventStopped:I,logNoParent:I,logEventNoHandlers:I,logEventResponse:I,write:I},zo=function(n,e,t){var r,o="*"===Fo||bn(Fo,n)?(r=[],{logEventCut:function(n,e,t){r.push({outcome:"cut",target:e,purpose:t})},logEventStopped:function(n,e,t){r.push({outcome:"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({outcome:"no-handlers-left",target:e})},logEventResponse:function(n,e,t){r.push({outcome:"response",purpose:t,target:e})},write:function(){bn(["mousemove","mouseover","mouseout",ne()],n)||p.console.log(n,{event:n,target:e.dom(),sequence:yn(r,function(n){return bn(["cut","stopped","response"],n.outcome)?"{"+n.purpose+"} "+n.outcome+" at ("+Io(n.target)+")":n.outcome})})}}):Ho,i=t(o);return o.write(),i},jo=A([nr("menu"),nr("selectedMenu")]),Lo=A([nr("item"),nr("selectedItem")]),Uo=(A(Nt(Lo().concat(jo()))),A(Nt(Lo()))),Po=rr("initSize",[nr("numColumns"),nr("numRows")]),$o=function(n,e,t){var r;return No(),Ut(e,e,t,(r=function(t){return et.value(function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t.apply(undefined,n)})},Vt(function(n){return r(n)})))},Wo=function(n){return $o(0,n,ot(I))},Go=function(n){return $o(0,n,ot(V.none))},_o=function(n){return $o(0,n,it())},qo=function(n){return $o(0,n,it())},Yo=function(n,e){return sr(n,A(e))},Ko=function(n){return sr(n,h)},Xo=A(Po),Jo=[er("channels",zt(et.value,Nt([_o("onReceive"),ar("schema",Qt())])))],Qo=$r({fields:Jo,name:"receiving",active:Ao}),Zo=function(n,e){var t=ri(n,e),r=e.aria();r.update()(n,r,t)},ni=function(n,e,t){io(n.element(),e.toggleClass()),Zo(n,e)},ei=function(n,e,t){ro(n.element(),e.toggleClass()),Zo(n,e)},ti=function(n,e,t){oo(n.element(),e.toggleClass()),Zo(n,e)},ri=function(n,e){return uo(n.element(),e.toggleClass())},oi=function(n,e,t){(e.selected()?ei:ti)(n,e,t)},ii=Object.freeze({onLoad:oi,toggle:ni,isOn:ri,on:ei,off:ti}),ui=Object.freeze({exhibit:function(n,e,t){return Er({})},events:function(n,e){var t,r,o,i=(t=n,r=e,o=ni,Sr(function(n){o(n,t,r)})),u=Ir(n,e,oi);return dr(Dn([n.toggleOnExecute()?[i]:[],[u]]))}}),ai=function(n,e,t){qr(n.element(),"aria-expanded",t)},ci=[ar("selected",!1),nr("toggleClass"),ar("toggleOnExecute",!0),cr("aria",{mode:"none"},Jt("mode",{pressed:[ar("syncWithExpanded",!1),Yo("update",function(n,e,t){qr(n.element(),"aria-pressed",t),e.syncWithExpanded()&&ai(n,e,t)})],checked:[Yo("update",function(n,e,t){qr(n.element(),"aria-checked",t)})],expanded:[Yo("update",ai)],selected:[Yo("update",function(n,e,t){qr(n.element(),"aria-selected",t)})],none:[Yo("update",I)]}))],si=$r({fields:ci,name:"toggling",active:ui,apis:ii}),fi=function(t,r){return Qo.config({channels:xt(Oo.formatChanged(),{onReceive:function(n,e){e.command===t&&r(n,e.state)}})})},li=function(n){return Qo.config({channels:xt(Oo.orientationChanged(),{onReceive:n})})},di=function(n,e){return{key:n,value:{onReceive:e}}},mi="tinymce-mobile",gi={resolve:function(n){return mi+"-"+n},prefix:A(mi)},vi=function(n,e){e.ignore()||(ho(n.element()),e.onFocus()(n))},pi=Object.freeze({focus:vi,blur:function(n,e){e.ignore()||bo(n.element())},isFocused:function(n){return e=n.element(),t=ze(e).dom(),e.dom()===t.activeElement;var e,t}}),hi=Object.freeze({exhibit:function(n,e){return e.ignore()?Er({}):Er({attributes:{tabindex:"-1"}})},events:function(t){return dr([gr(_n(),function(n,e){vi(n,t),e.stop()})])}}),bi=[Wo("onFocus"),ar("ignore",!1)],yi=$r({fields:bi,name:"focusing",active:hi,apis:pi}),wi=function(n){return n.style!==undefined},xi=function(n,e,t){if(!b(t))throw p.console.error("Invalid call to CSS.set. Property ",e,":: Value ",t,":: Element ",n),new Error("CSS value must be a string: "+t);wi(n)&&n.style.setProperty(e,t)},Si=function(n,e,t){var r=n.dom();xi(r,e,t)},Ti=function(n,e){var t=n.dom();H(e,function(n,e){xi(t,e,n)})},Oi=function(n,e){var t=n.dom(),r=p.window.getComputedStyle(t).getPropertyValue(e),o=""!==r||be(n)?r:ki(t,e);return null===o?undefined:o},ki=function(n,e){return wi(n)?n.style.getPropertyValue(e):""},Ci=function(n,e){var t=n.dom(),r=ki(t,e);return V.from(r).filter(function(n){return 0<n.length})},Ei=function(n,e){var t,r,o=n.dom();r=e,wi(t=o)&&t.style.removeProperty(r),Xr(n,"style")&&""===Kr(n,"style").replace(/^\s+|\s+$/g,"")&&Jr(n,"style")},Di=function(n){return n.dom().offsetWidth};function Ii(r,o){var n=function(n){var e=o(n);if(e<=0||null===e){var t=Oi(n,r);return parseFloat(t)||0}return e},i=function(o,n){return Tn(n,function(n,e){var t=Oi(o,e),r=t===undefined?0:parseInt(t,10);return isNaN(r)?n:n+r},0)};return{set:function(n,e){if(!T(e)&&!e.match(/^[0-9]+$/))throw new Error(r+".set accepts only positive integer values. Value was "+e);var t=n.dom();wi(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 Ai,Mi,Bi=Ii("height",function(n){var e=n.dom();return be(n)?e.getBoundingClientRect().height:e.offsetHeight}),Ri=function(n){return Bi.get(n)},Fi=function(n,e,t){return xn(function(n,e){for(var t=x(e)?e:A(!1),r=n.dom(),o=[];null!==r.parentNode&&r.parentNode!==undefined;){var i=r.parentNode,u=fe.fromDom(i);if(o.push(u),!0===t(u))break;r=i}return o}(n,t),e)},Vi=function(n,e){return xn(je(t=n).map(Le).map(function(n){return xn(n,function(n){return!He(t,n)})}).getOr([]),e);var t},Ni=function(n,e){return Ve(e,n)},Hi=function(n){return Ne(n)},zi=function(n,e,t){return go(n,function(n){return Re(n,e)},t)},ji=function(n,e){return Ne(e,n)},Li=function(n,e,t){return mo(Re,zi,n,e,t)},Ui=function(n,e,t){var r=Bn(n.slice(0,e)),o=Bn(n.slice(e+1));return On(r.concat(o),t)},Pi=function(n,e,t){var r=Bn(n.slice(0,e));return On(r,t)},$i=function(n,e,t){var r=n.slice(0,e),o=n.slice(e+1);return On(o.concat(r),t)},Wi=function(n,e,t){var r=n.slice(e+1);return On(r,t)},Gi=function(t){return function(n){var e=n.raw();return bn(t,e.which)}},_i=function(n){return function(e){return An(n,function(n){return n(e)})}},qi=function(n){return!0===n.raw().shiftKey},Yi=function(n){return!0===n.raw().ctrlKey},Ki=S(qi),Xi=function(n,e){return{matches:n,classification:e}},Ji=function(n,e,t,r){var o=n+e;return r<o?t:o<t?r:o},Qi=function(n,e,t){return n<=e?e:t<=n?t:n},Zi=function(e,t,n){var r=Ni(e.element(),"."+t.highlightClass());wn(r,function(n){oo(n,t.highlightClass()),e.getSystem().getByDom(n).each(function(n){t.onDehighlight()(e,n)})})},nu=function(n,e,t,r){var o=eu(n,e,t,r);Zi(n,e),ro(r.element(),e.highlightClass()),o||e.onHighlight()(n,r)},eu=function(n,e,t,r){return uo(r.element(),e.highlightClass())},tu=function(n,e,t,r){var o=Ni(n.element(),"."+e.itemClass());return V.from(o[r]).fold(function(){return et.error("No element found with index "+r)},n.getSystem().getByDom)},ru=function(e,n,t){return ji(e.element(),"."+n.itemClass()).bind(function(n){return e.getSystem().getByDom(n).toOption()})},ou=function(e,n,t){var r=Ni(e.element(),"."+n.itemClass());return(0<r.length?V.some(r[r.length-1]):V.none()).bind(function(n){return e.getSystem().getByDom(n).toOption()})},iu=function(t,e,n,r){var o=Ni(t.element(),"."+e.itemClass());return kn(o,function(n){return uo(n,e.highlightClass())}).bind(function(n){var e=Ji(n,r,0,o.length-1);return t.getSystem().getByDom(o[e]).toOption()})},uu=Object.freeze({dehighlightAll:Zi,dehighlight:function(n,e,t,r){var o=eu(n,e,t,r);oo(r.element(),e.highlightClass()),o&&e.onDehighlight()(n,r)},highlight:nu,highlightFirst:function(e,t,r){ru(e,t,r).each(function(n){nu(e,t,r,n)})},highlightLast:function(e,t,r){ou(e,t,r).each(function(n){nu(e,t,r,n)})},highlightAt:function(e,t,r,n){tu(e,t,r,n).fold(function(n){throw new Error(n)},function(n){nu(e,t,r,n)})},highlightBy:function(e,t,r,n){var o=Ni(e.element(),"."+t.itemClass()),i=Mo(yn(o,function(n){return e.getSystem().getByDom(n).toOption()}));On(i,n).each(function(n){nu(e,t,r,n)})},isHighlighted:eu,getHighlighted:function(e,n,t){return ji(e.element(),"."+n.highlightClass()).bind(function(n){return e.getSystem().getByDom(n).toOption()})},getFirst:ru,getLast:ou,getPrevious:function(n,e,t){return iu(n,e,0,-1)},getNext:function(n,e,t){return iu(n,e,0,1)}}),au=[nr("highlightClass"),nr("itemClass"),Wo("onHighlight"),Wo("onDehighlight")],cu=$r({fields:au,name:"highlighting",apis:uu}),su=function(){return{get:function(n){return wo(n.element())},set:function(n,e){n.getSystem().triggerFocus(e,n.element())}}},fu=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(),On(n,function(n){return n.matches(i)}).map(function(n){return n.classification})).bind(function(n){return n(e,t,r,o)})},o={schema:function(){return n.concat([ar("focusManager",su()),Yo("handler",o),Yo("state",e)])},processKey:u,toEvents:function(r,o){var n=t(r,o),e=dr(i.map(function(t){return gr(_n(),function(n,e){t(n,r,o,e),e.stop()})}).toArray().concat([gr(Y(),function(n,e){u(n,e,r,o).each(function(n){e.stop()})})]));return C(n,e)},toApis:r};return o},lu=function(n){var e=[or("onEscape"),or("onEnter"),ar("selector",'[data-alloy-tabstop="true"]'),ar("firstTabstop",0),ar("useTabstopAt",A(!0)),or("visibilitySelector")].concat([n]),u=function(n,e){var t=n.visibilitySelector().bind(function(n){return Li(e,n)}).getOr(e);return 0<Ri(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()?V.some(!0):V.none()},function(n){return r.focusManager().set(e,n),V.some(!0)})},i=function(e,n,t,r){var o,i,u=Ni(e.element(),t.selector());return(o=e,i=t,i.focusManager().get(o).bind(function(n){return Li(n,i.selector())})).bind(function(n){return kn(u,l(He,n)).bind(function(n){return a(e,u,n,t,r)})})},t=A([Xi(_i([qi,Gi([9])]),function(n,e,t,r){var o=t.cyclic()?Ui:Pi;return i(n,0,t,o)}),Xi(Gi([9]),function(n,e,t,r){var o=t.cyclic()?$i:Wi;return i(n,0,t,o)}),Xi(Gi([27]),function(e,t,n,r){return n.onEscape().bind(function(n){return n(e,t)})}),Xi(_i([Ki,Gi([13])]),function(e,t,n,r){return n.onEnter().bind(function(n){return n(e,t)})})]),r=A({}),o=A({});return fu(e,jr.init,t,r,o,V.some(function(e,t){var n,r,o,i;(n=e,r=t,o=Ni(n.element(),r.selector()),i=xn(o,function(n){return u(r,n)}),V.from(i[r.firstTabstop()])).each(function(n){t.focusManager().set(e,n)})}))},du=lu(sr("cyclic",A(!1))),mu=lu(sr("cyclic",A(!0))),gu=function(n){return"input"===ge(n)&&"radio"!==Kr(n,"type")||"textarea"===ge(n)},vu=function(n,e,t){return gu(t)&&Gi([32])(e.event())?V.none():(ae(n,t,Kn()),V.some(!0))},pu=[ar("execute",vu),ar("useSpace",!1),ar("useEnter",!0),ar("useControlEnter",!1),ar("useDown",!1)],hu=function(n,e,t){return t.execute()(n,e,n.element())},bu=A({}),yu=A({}),wu=fu(pu,jr.init,function(n,e,t,r){var o=t.useSpace()&&!gu(n.element())?[32]:[],i=t.useEnter()?[13]:[],u=t.useDown()?[40]:[],a=o.concat(i).concat(u);return[Xi(Gi(a),hu)].concat(t.useControlEnter()?[Xi(_i([Yi,Gi([13])]),hu)]:[])},bu,yu,V.none()),xu=function(n){var t=lo(V.none());return Lr({readState:A({}),setGridSize:function(n,e){t.set(V.some({numRows:A(n),numColumns:A(e)}))},getNumRows:function(){return t.get().map(function(n){return n.numRows()})},getNumColumns:function(){return t.get().map(function(n){return n.numColumns()})}})},Su=Object.freeze({flatgrid:xu,init:function(n){return n.state()(n)}}),Tu=function(e,t){return function(n){return"rtl"===Ou(n)?t:e}},Ou=function(n){return"rtl"===Oi(n,"direction")?"rtl":"ltr"},ku=function(i){return function(n,e,t,r){var o=i(n.element());return Iu(o,n,e,t,r)}},Cu=function(n,e){var t=Tu(n,e);return ku(t)},Eu=function(n,e){var t=Tu(e,n);return ku(t)},Du=function(o){return function(n,e,t,r){return Iu(o,n,e,t,r)}},Iu=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})},Au=Du,Mu=Du,Bu=Du,Ru=function(n){var e,t=n.dom();return!((e=t).offsetWidth<=0&&e.offsetHeight<=0)},Fu=Ee(["index","candidates"],[]),Vu=function(n,e,t){return Nu(n,e,t,Ru)},Nu=function(n,e,t,r){var o,i=l(He,e),u=Ni(n,t),a=xn(u,Ru);return kn(o=a,i).map(function(n){return Fu({index:n,candidates:o})})},Hu=function(n,e){return kn(n,function(n){return He(e,n)})},zu=function(t,n,r,e){return e(Math.floor(n/r),n%r).bind(function(n){var e=n.row()*r+n.column();return 0<=e&&e<t.length?V.some(t[e]):V.none()})},ju=function(o,n,i,u,a){return zu(o,n,u,function(n,e){var t=n===i-1?o.length-n*u:u,r=Ji(e,a,0,t-1);return V.some({row:A(n),column:A(r)})})},Lu=function(i,n,u,a,c){return zu(i,n,a,function(n,e){var t=Ji(n,c,0,u-1),r=t===u-1?i.length-t*a:a,o=Qi(e,0,r-1);return V.some({row:A(t),column:A(o)})})},Uu=[nr("selector"),ar("execute",vu),Go("onEscape"),ar("captureTab",!1),Xo()],Pu=function(o){return function(n,e,t,r){return Vu(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()))})}},$u=function(n,e,t,r){return t.captureTab()?V.some(!0):V.none()},Wu=Pu(function(n,e,t,r){return ju(n,e,t,r,-1)}),Gu=Pu(function(n,e,t,r){return ju(n,e,t,r,1)}),_u=Pu(function(n,e,t,r){return Lu(n,e,t,r,-1)}),qu=Pu(function(n,e,t,r){return Lu(n,e,t,r,1)}),Yu=A([Xi(Gi([37]),Cu(Wu,Gu)),Xi(Gi([39]),Eu(Wu,Gu)),Xi(Gi([38]),Au(_u)),Xi(Gi([40]),Mu(qu)),Xi(_i([qi,Gi([9])]),$u),Xi(_i([Ki,Gi([9])]),$u),Xi(Gi([27]),function(n,e,t,r){return t.onEscape()(n,e)}),Xi(Gi([32].concat([13])),function(e,t,r,n){return(o=e,i=r,i.focusManager().get(o).bind(function(n){return Li(n,i.selector())})).bind(function(n){return r.execute()(e,t,n)});var o,i})]),Ku=A({}),Xu=fu(Uu,xu,Yu,Ku,{},V.some(function(e,t,n){ji(e.element(),t.selector()).each(function(n){t.focusManager().set(e,n)})})),Ju=function(n,e,t,o){return Vu(n,t,e).bind(function(n){var e=n.index(),t=n.candidates(),r=Ji(e,o,0,t.length-1);return V.from(t[r])})},Qu=[nr("selector"),ar("getInitial",V.none),ar("execute",vu),ar("executeOnMove",!1),ar("allowVertical",!0)],Zu=function(e,t,r){return(n=e,o=r,o.focusManager().get(n).bind(function(n){return Li(n,o.selector())})).bind(function(n){return r.execute()(e,t,n)});var n,o},na=function(n,e,t){return Ju(n,t.selector(),e,-1)},ea=function(n,e,t){return Ju(n,t.selector(),e,1)},ta=function(r){return function(n,e,t){return r(n,e,t).bind(function(){return t.executeOnMove()?Zu(n,e,t):V.some(!0)})}},ra=A({}),oa=A({}),ia=fu(Qu,jr.init,function(n,e,t,r){var o=[37].concat(t.allowVertical()?[38]:[]),i=[39].concat(t.allowVertical()?[40]:[]);return[Xi(Gi(o),ta(Cu(na,ea))),Xi(Gi(i),ta(Eu(na,ea))),Xi(Gi([13]),Zu),Xi(Gi([32]),Zu)]},ra,oa,V.some(function(e,t){t.getInitial()(e).or(ji(e.element(),t.selector())).each(function(n){t.focusManager().set(e,n)})})),ua=Ee(["rowIndex","columnIndex","cell"],[]),aa=function(n,e,t){return V.from(n[e]).bind(function(n){return V.from(n[t]).map(function(n){return ua({rowIndex:e,columnIndex:t,cell:n})})})},ca=function(n,e,t,r){var o=n[e].length,i=Ji(t,r,0,o-1);return aa(n,e,i)},sa=function(n,e,t,r){var o=Ji(t,r,0,n.length-1),i=n[o].length,u=Qi(e,0,i-1);return aa(n,o,u)},fa=function(n,e,t,r){var o=n[e].length,i=Qi(t+r,0,o-1);return aa(n,e,i)},la=function(n,e,t,r){var o=Qi(t+r,0,n.length-1),i=n[o].length,u=Qi(e,0,i-1);return aa(n,o,u)},da=[rr("selectors",[nr("row"),nr("cell")]),ar("cycles",!0),ar("previousSelector",V.none),ar("execute",vu)],ma=function(n,e){return function(t,r,i){var u=i.cycles()?n:e;return Li(r,i.selectors().row()).bind(function(n){var e=Ni(n,i.selectors().cell());return Hu(e,r).bind(function(r){var o=Ni(t,i.selectors().row());return Hu(o,n).bind(function(n){var e,t=(e=i,yn(o,function(n){return Ni(n,e.selectors().cell())}));return u(t,n,r).map(function(n){return n.cell()})})})})}},ga=ma(function(n,e,t){return ca(n,e,t,-1)},function(n,e,t){return fa(n,e,t,-1)}),va=ma(function(n,e,t){return ca(n,e,t,1)},function(n,e,t){return fa(n,e,t,1)}),pa=ma(function(n,e,t){return sa(n,t,e,-1)},function(n,e,t){return la(n,t,e,-1)}),ha=ma(function(n,e,t){return sa(n,t,e,1)},function(n,e,t){return la(n,t,e,1)}),ba=A([Xi(Gi([37]),Cu(ga,va)),Xi(Gi([39]),Eu(ga,va)),Xi(Gi([38]),Au(pa)),Xi(Gi([40]),Mu(ha)),Xi(Gi([32].concat([13])),function(e,t,r){return wo(e.element()).bind(function(n){return r.execute()(e,t,n)})})]),ya=A({}),wa=A({}),xa=fu(da,jr.init,ba,ya,wa,V.some(function(e,t){t.previousSelector()(e).orThunk(function(){var n=t.selectors();return ji(e.element(),n.cell())}).each(function(n){t.focusManager().set(e,n)})})),Sa=[nr("selector"),ar("execute",vu),ar("moveOnTab",!1)],Ta=function(e,t,r){return r.focusManager().get(e).bind(function(n){return r.execute()(e,t,n)})},Oa=function(n,e,t){return Ju(n,t.selector(),e,-1)},ka=function(n,e,t){return Ju(n,t.selector(),e,1)},Ca=A([Xi(Gi([38]),Bu(Oa)),Xi(Gi([40]),Bu(ka)),Xi(_i([qi,Gi([9])]),function(n,e,t){return t.moveOnTab()?Bu(Oa)(n,e,t):V.none()}),Xi(_i([Ki,Gi([9])]),function(n,e,t){return t.moveOnTab()?Bu(ka)(n,e,t):V.none()}),Xi(Gi([13]),Ta),Xi(Gi([32]),Ta)]),Ea=A({}),Da=A({}),Ia=fu(Sa,jr.init,Ca,Ea,Da,V.some(function(e,t){ji(e.element(),t.selector()).each(function(n){t.focusManager().set(e,n)})})),Aa=[Go("onSpace"),Go("onEnter"),Go("onShiftEnter"),Go("onLeft"),Go("onRight"),Go("onTab"),Go("onShiftTab"),Go("onUp"),Go("onDown"),Go("onEscape"),or("focusIn")],Ma=fu(Aa,jr.init,function(n,e,t){return[Xi(Gi([32]),t.onSpace()),Xi(_i([Ki,Gi([13])]),t.onEnter()),Xi(_i([qi,Gi([13])]),t.onShiftEnter()),Xi(_i([qi,Gi([9])]),t.onShiftTab()),Xi(_i([Ki,Gi([9])]),t.onTab()),Xi(Gi([38]),t.onUp()),Xi(Gi([40]),t.onDown()),Xi(Gi([37]),t.onLeft()),Xi(Gi([39]),t.onRight()),Xi(Gi([32]),t.onSpace()),Xi(Gi([27]),t.onEscape())]},function(){return{}},function(){return{}},V.some(function(e,t){return t.focusIn().bind(function(n){return n(e,t)})})),Ba=du.schema(),Ra=mu.schema(),Fa=ia.schema(),Va=Xu.schema(),Na=xa.schema(),Ha=wu.schema(),za=Ia.schema(),ja=Ma.schema(),La=(Mi=Yt("Creating behaviour: "+(Ai={branchKey:"mode",branches:Object.freeze({acyclic:Ba,cyclic:Ra,flow:Fa,flatgrid:Va,matrix:Na,execution:Ha,menu:za,special:ja}),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,r,o){Ot(t,"setGridSize")?t.setGridSize(r,o):p.console.error("Layout does not support setGridSize")}},state:Su}).name,Wr,Ai),Ar(Jt(Mi.branchKey,Mi.branches),Mi.name,Mi.active,Mi.apis,Mi.extra,Mi.state)),Ua=function(r,n){return e=r,t={},o=yn(n,function(n){return e=n.name(),t="Cannot configure "+n.name()+" for "+r,Ut(e,e,ut(),Vt(function(n){return et.error("The field: "+e+" is forbidden. "+t)}));var e,t}).concat([sr("dump",h)]),Ut(e,e,ot(t),Ht(o));var e,t,o},Pa=function(n){return n.dump()},$a="placeholder",Wa=tt([{single:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),Ga=function(n,e,t,r){return t.uiType===$a?(i=t,u=r,(o=n).exists(function(n){return n!==i.owner})?Wa.single(!0,A(i)):wt(u,i.name).fold(function(){throw new Error("Unknown placeholder component: "+i.name+"\nKnown: ["+N(u)+"]\nNamespace: "+o.getOr("none")+"\nSpec: "+Dt(i,null,2))},function(n){return n.replace()})):Wa.single(!1,A(t));var o,i,u},_a=function(i,u,a,c){return Ga(i,0,a,c).fold(function(n,e){var t=e(u,a.config,a.validated),r=wt(t,"components").getOr([]),o=In(r,function(n){return _a(i,u,n,c)});return[C(t,{components:o})]},function(n,e){return e(u,a.config,a.validated)})},qa=function(e,t,n,r){var o,i,u,a=z(r,function(n,e){return r=n,o=!1,{name: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 Error("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,In(n,function(n){return _a(o,i,n,u)}));return H(a,function(n){if(!1===n.used()&&n.required())throw new Error("Placeholder: "+n.name()+" was not found in components list\nNamespace: "+e.getOr("none")+"\nComponents: "+Dt(t.components(),null,2))}),c},Ya=Wa.single,Ka=Wa.multiple,Xa=A($a),Ja=0,Qa=function(n){var e=(new Date).getTime();return n+"_"+Math.floor(1e9*Math.random())+ ++Ja+String(e)},Za=tt([{required:["data"]},{external:["data"]},{optional:["data"]},{group:["data"]}]),nc=ar("factory",{sketch:h}),ec=ar("schema",[]),tc=nr("name"),rc=Ut("pname","pname",at(function(n){return"<alloy."+Qa(n.name)+">"}),Qt()),oc=ar("defaults",A({})),ic=ar("overrides",A({})),uc=Ht([nc,ec,tc,rc,oc,ic]),ac=Ht([nc,ec,tc,rc,oc,ic]),cc=Ht([nc,ec,tc,nr("unit"),rc,oc,ic]),sc=function(n){var e=function(n){return n.name()};return n.fold(e,e,e,e)},fc=function(t,r){return function(n){var e=Kt("Converting part type",r,n);return t(e)}},lc=fc(Za.required,uc),dc=fc(Za.optional,ac),mc=fc(Za.group,cc),gc=A("entirety"),vc=function(n,e,t,r){var o=t;return C(e.defaults()(n,t,r),t,{uid:n.partUids()[e.name()]},e.overrides()(n,t,r),{"debug.sketcher":xt("part-"+e.name(),o)})},pc=function(o,n){var i={};return wn(n,function(n){var e;(e=n,e.fold(V.some,V.none,V.some,V.some)).each(function(t){var r=hc(o,t.pname());i[t.name()]=function(n){var e=Yt("Part: "+t.name()+" in "+o,Ht(t.schema()),n);return C(r,{config:n,validated:e})}})}),i},hc=function(n,e){return{uiType:Xa(),owner:n,name:e}},bc=function(n,e,t){return r=e,i={},o={},wn(t,function(n){n.fold(function(r){i[r.pname()]=Ya(!0,function(n,e,t){return r.factory().sketch(vc(n,r,e,t))})},function(n){var e=r.parts()[n.name()]();o[n.name()]=A(vc(r,n,e[gc()]()))},function(r){i[r.pname()]=Ya(!1,function(n,e,t){return r.factory().sketch(vc(n,r,e,t))})},function(o){i[o.pname()]=Ka(!0,function(e,n,t){var r=e[o.name()]();return yn(r,function(n){return o.factory().sketch(C(o.defaults()(e,n),n,o.overrides()(e,n)))})})})}),{internals:A(i),externals:A(o)};var r,i,o},yc=function(n,e,t){return qa(V.some(n),e,e.components(),t)},wc=function(n,e,t){var r=e.partUids()[t];return n.getSystem().getByUid(r).toOption()},xc=function(n,e,t){return wc(n,e,t).getOrDie("Could not find part: "+t)},Sc=function(e,n){var t=yn(n,sc);return St(yn(t,function(n){return{key:n,value:e+"-"+n}}))},Tc=function(e){return Ut("partUids","partUids",ct(function(n){return Sc(n.uid,e)}),Qt())},Oc=Qa("alloy-premade"),kc=Qa("api"),Cc=function(n){return xt(Oc,n)},Ec=function(o){return n=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var r=n.config(kc);return o.apply(undefined,[r].concat([n].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:Tr(i.slice(1))}},n;var n,e,t,r,i},Dc=A(kc),Ic=A("alloy-id-"),Ac=A("data-alloy-id"),Mc=Ic(),Bc=Ac(),Rc=function(n){var e=pe(n)?Kr(n,Bc):null;return V.from(e)},Fc=function(n){return Qa(n)},Vc=function(n,e,t,r,o){var i,u,a=(u=o,(0<(i=r).length?[rr("parts",i)]:[]).concat([nr("uid"),ar("dom",{}),ar("components",[]),Ko("originalSpec"),ar("debug.sketcher",{})]).concat(u));return Kt(n+" [SpecSchema]",Nt(a.concat(e)),t)},Nc=function(n,e,t,r,o){var i=Hc(o),u=In(t,function(n){return n.fold(V.none,V.some,V.none,V.none).map(function(n){return rr(n.name(),n.schema().concat([Ko(gc())]))}).toArray()}),a=Tc(t),c=Vc(n,e,i,u,[a]),s=bc(0,c,t),f=yc(n,c,s.internals());return C(r(c,f,i,s.externals()),{"debug.sketcher":xt(n,o)})},Hc=function(n){return C({uid:Fc("uid")},n)},zc=Nt([nr("name"),nr("factory"),nr("configFields"),ar("apis",{}),ar("extraApis",{})]),jc=Nt([nr("name"),nr("factory"),nr("configFields"),nr("partFields"),ar("apis",{}),ar("extraApis",{})]),Lc=function(n){var a=Yt("Sketcher for "+n.name,zc,n),e=z(a.apis,Ec),t=z(a.extraApis,function(n,e){return Or(n,e)});return C({name:A(a.name),partFields:A([]),configFields:A(a.configFields),sketch:function(n){return e=a.name,t=a.configFields,r=a.factory,i=Hc(o=n),u=Vc(e,t,i,[],[]),C(r(u,i),{"debug.sketcher":xt(e,o)});var e,t,r,o,i,u}},e,t)},Uc=function(n){var e=Yt("Sketcher for "+n.name,jc,n),t=pc(e.name,e.partFields),r=z(e.apis,Ec),o=z(e.extraApis,function(n,e){return Or(n,e)});return C({name:A(e.name),partFields:A(e.partFields),configFields:A(e.configFields),sketch:function(n){return Nc(e.name,e.configFields,e.partFields,e.factory,n)},parts:A(t)},r,o)},Pc=Lc({name:"Button",factory:function(n){var e,t,r,o=(e=n.action(),t=function(n,e){e.stop(),ue(n)},r=Wn.detect().deviceType.isTouch()?[gr(Jn(),t)]:[gr(J(),t),gr(W(),function(n,e){e.cut()})],dr(Dn([e.map(function(t){return gr(Kn(),function(n,e){t(n),e.stop()})}).toArray(),r]))),i=wt(n.dom(),"attributes").bind(bt("type")),u=wt(n.dom(),"tag");return{uid:n.uid(),dom:n.dom(),components:n.components(),events:o,behaviours:C(Ur([yi.config({}),La.config({mode:"execution",useSpace:!0,useEnter:!0})]),Pa(n.buttonBehaviours())),domModification:{attributes:C(i.fold(function(){return u.is("button")?{type:"button"}:{}},function(n){return{}}),{role:n.role().getOr("button")})},eventOrder:n.eventOrder()}},configFields:[ar("uid",undefined),nr("dom"),ar("components",[]),Ua("buttonBehaviours",[yi,La]),or("action"),or("role"),ar("eventOrder",{})]}),$c=$r({fields:[],name:"unselecting",active:Object.freeze({events:function(n){return dr([mr(Z(),A(!0))])},exhibit:function(n,e){return Er({styles:{"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none","-moz-user-select":"-moz-none"},attributes:{unselectable:"on"}})}})}),Wc=function(n){var e,t,r,o=fe.fromHtml(n),i=Le(o),u=(t=(e=o).dom().attributes!==undefined?e.dom().attributes:[],Tn(t,function(n,e){return"class"===e.name?n:C(n,xt(e.name,e.value))},{})),a=(r=o,Array.prototype.slice.call(r.dom().classList,0)),c=0===i.length?{}:{innerHtml:ko(o)};return C({tag:ge(o),classes:a,attributes:u},c)},Gc=function(n){var e,o,t=(e=n,o={prefix:gi.prefix()},e.replace(/\$\{([^{}]*)\}/g,function(n,e){var t,r=o[e];return"string"==(t=typeof r)||"number"===t?r.toString():n}));return Wc(t)},_c=function(n){return{dom:Gc(n)}},qc=function(n){return Ur([si.config({toggleClass:gi.resolve("toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),fi(n,function(n,e){(e?si.on:si.off)(n)})])},Yc=function(n,e,t){return Pc.sketch({dom:Gc('<span class="${prefix}-toolbar-button ${prefix}-icon-'+n+' ${prefix}-icon"></span>'),action:e,buttonBehaviours:C(Ur([$c.config({})]),t)})},Kc={forToolbar:Yc,forToolbarCommand:function(n,e){return Yc(e,function(){n.execCommand(e)},{})},forToolbarStateAction:function(n,e,t,r){var o=qc(t);return Yc(e,r,o)},forToolbarStateCommand:function(n,e){var t=qc(e);return Yc(e,function(){n.execCommand(e)},t)}},Xc=function(t,r){return{left:A(t),top:A(r),translate:function(n,e){return Xc(t+n,r+e)}}},Jc=Xc,Qc=function(n,e,t){return Math.max(e,Math.min(t,n))},Zc=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=Qc(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 Qc(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},ns="slider.change.value",es=Wn.detect().deviceType.isTouch(),ts=function(n){return function(n){var e=n.event().raw();if(es){var t=e;return t.touches!==undefined&&1===t.touches.length?V.some(t.touches[0]).map(function(n){return Jc(n.clientX,n.clientY)}):V.none()}var r=e;return r.clientX!==undefined?V.some(r).map(function(n){return Jc(n.clientX,n.clientY)}):V.none()}(n).map(function(n){return n.left()})},rs=function(n,e){ie(n,ns,{value:e})},os=function(i,u,a,n){return ts(n).map(function(n){var e,t,r,o;return e=i,r=n,o=Zc(a,(t=u).min(),t.max(),r,t.stepSize(),t.snapToGrid(),t.snapStart()),rs(e,o),n})},is=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:Math.max(r,t-i));rs(n,u)},us=function(n,e){var t,r,o,i,u=(t=e.value().get(),r=e.min(),o=e.max(),i=e.stepSize(),o<t?t:t<r?r:t===o?o+1:Math.min(o,t+i));rs(n,u)},as=Wn.detect().deviceType.isTouch(),cs=function(n,r){return dc({name:n+"-edge",overrides:function(n){var e=dr([vr(U(),r,[n])]),t=dr([vr(W(),r,[n]),vr(G(),function(n,e){e.mouseIsDown().get()&&r(n,e)},[n])]);return{events:as?e:t}}})},ss=[cs("left",function(n,e){rs(n,e.min()-1)}),cs("right",function(n,e){rs(n,e.max()+1)}),lc({name:"thumb",defaults:A({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:dr([hr(U(),n,"spectrum"),hr(P(),n,"spectrum"),hr($(),n,"spectrum")])}}}),lc({schema:[sr("mouseIsDown",function(){return lo(!1)})],name:"spectrum",overrides:function(r){var t=function(n,e){var t=n.element().dom().getBoundingClientRect();os(n,r,t,e)},n=dr([gr(U(),t),gr(P(),t)]),e=dr([gr(W(),t),gr(G(),function(n,e){r.mouseIsDown().get()&&t(n,e)})]);return{behaviours:Ur(as?[]:[La.config({mode:"special",onLeft:function(n){return is(n,r),V.some(!0)},onRight:function(n){return us(n,r),V.some(!0)}}),yi.config({})]),events:as?n:e}}})],fs=function(n,e,t){e.store().manager().onLoad(n,e,t)},ls=function(n,e,t){e.store().manager().onUnload(n,e,t)},ds=Object.freeze({onLoad:fs,onUnload:ls,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)}}),ms=Object.freeze({events:function(t,r){var n=t.resetOnDom()?[yr(function(n,e){fs(n,t,r)}),wr(function(n,e){ls(n,t,r)})]:[Ir(t,r,fs)];return dr(n)}}),gs=function(){var n=lo(null);return Lr({set:n.set,get:n.get,isNotSet:function(){return null===n.get()},clear:function(){n.set(null)},readState:function(){return{mode:"memory",value:n.get()}}})},vs=function(){var n=lo({});return Lr({readState:function(){return{mode:"dataset",dataset:n.get()}},set:n.set,get:n.get})},ps=Object.freeze({memory:gs,dataset:vs,manual:function(){return Lr({readState:function(){}})},init:function(n){return n.store().manager().state(n)}}),hs=function(n,e,t,r){e.store().getDataKey(),t.set({}),e.store().setData()(n,r),e.onSetValue()(n,r)},bs=[or("initialValue"),nr("getFallbackEntry"),nr("getDataKey"),nr("setData"),Yo("manager",{setValue:hs,getValue:function(n,e,t){var r=e.store().getDataKey()(n),o=t.get();return wt(o,r).fold(function(){return e.store().getFallbackEntry()(r)},function(n){return n})},onLoad:function(e,t,r){t.store().initialValue().each(function(n){hs(e,t,r,n)})},onUnload:function(n,e,t){t.set({})},state:vs})],ys=[nr("getValue"),ar("setValue",I),or("initialValue"),Yo("manager",{setValue:function(n,e,t,r){e.store().setValue()(n,r),e.onSetValue()(n,r)},getValue:function(n,e,t){return e.store().getValue()(n)},onLoad:function(e,t,n){t.store().initialValue().each(function(n){t.store().setValue()(e,n)})},onUnload:I,state:jr.init})],ws=[or("initialValue"),Yo("manager",{setValue:function(n,e,t,r){t.set(r),e.onSetValue()(n,r)},getValue:function(n,e,t){return t.get()},onLoad:function(n,e,t){e.store().initialValue().each(function(n){t.isNotSet()&&t.set(n)})},onUnload:function(n,e,t){t.clear()},state:gs})],xs=[cr("store",{mode:"memory"},Jt("mode",{memory:ws,manual:ys,dataset:bs})),Wo("onSetValue"),ar("resetOnDom",!1)],Ss=$r({fields:xs,name:"representing",active:ms,apis:ds,extra:{setValueFrom:function(n,e){var t=Ss.getValue(e);Ss.setValue(n,t)}},state:ps}),Ts=Wn.detect().deviceType.isTouch(),Os=[nr("min"),nr("max"),ar("stepSize",1),ar("onChange",I),ar("onInit",I),ar("onDragStart",I),ar("onDragEnd",I),ar("snapToGrid",!1),or("snapStart"),nr("getInitialValue"),Ua("sliderBehaviours",[La,Ss]),sr("value",function(n){return lo(n.min)})].concat(Ts?[]:[sr("mouseIsDown",function(){return lo(!1)})]),ks=Ii("width",function(n){return n.dom().offsetWidth}),Cs=function(n,e){ks.set(n,e)},Es=function(n){return ks.get(n)},Ds=Wn.detect().deviceType.isTouch(),Is=Uc({name:"Slider",configFields:Os,partFields:ss,factory: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},o=function(n){return xc(n,c,"thumb")},i=function(n){var e,t,r,o,i=xc(n,c,"spectrum").element().dom().getBoundingClientRect(),u=n.element().dom().getBoundingClientRect(),a=(e=n,t=i,(o=(r=c).value().get())<r.min()?wc(e,r,"left-edge").fold(function(){return 0},function(n){return f(n)-t.left}):o>r.max()?wc(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.left+a},u=function(n){var e=i(n),t=o(n),r=Es(t.element())/2;Si(t.element(),"left",e-r+"px")},r=function(n,e){var t=c.value().get(),r=o(n);return t!==e||Ci(r.element(),"left").isNone()?(c.value().set(e),u(n),c.onChange()(n,r,e),V.some(!0)):V.none()},a=Ds?[gr(U(),function(n,e){c.onDragStart()(n,o(n))}),gr($(),function(n,e){c.onDragEnd()(n,o(n))})]:[gr(W(),function(n,e){e.stop(),c.onDragStart()(n,o(n)),c.mouseIsDown().set(!0)}),gr(_(),function(n,e){c.onDragEnd()(n,o(n)),c.mouseIsDown().set(!1)})];return{uid:c.uid(),dom:c.dom(),components:n,behaviours:C(Ur(Dn([Ds?[]:[La.config({mode:"special",focusIn:function(n){return wc(n,c,"spectrum").map(La.focusIn).map(A(!0))}})],[Ss.config({store:{mode:"manual",getValue:function(n){return c.value().get()}}})]])),Pa(c.sliderBehaviours())),events:dr([gr(ns,function(n,e){r(n,e.event().value())}),yr(function(n,e){c.value().set(c.getInitialValue()());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())},refresh: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)}}}),As=function(e,t,r){return Kc.forToolbar(t,function(){var n=r();e.setContextToolbar([{label:t+" group",items:n}])},{})},Ms=function(n){return[(o=n,i=function(n){return n<0?"black":360<n?"white":"hsl("+n+", 100%, 50%)"},Is.sketch({dom:Gc('<div class="${prefix}-slider ${prefix}-hue-slider-container"></div>'),components:[Is.parts()["left-edge"](_c('<div class="${prefix}-hue-slider-black"></div>')),Is.parts().spectrum({dom:Gc('<div class="${prefix}-slider-gradient-container"></div>'),components:[_c('<div class="${prefix}-slider-gradient"></div>')],behaviours:Ur([si.config({toggleClass:gi.resolve("thumb-active")})])}),Is.parts()["right-edge"](_c('<div class="${prefix}-hue-slider-white"></div>')),Is.parts().thumb({dom:Gc('<div class="${prefix}-slider-thumb"></div>'),behaviours:Ur([si.config({toggleClass:gi.resolve("thumb-active")})])})],onChange:function(n,e,t){var r=i(t);Si(e.element(),"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){si.on(e)},onDragEnd:function(n,e){si.off(e)},onInit:function(n,e,t){var r=i(t);Si(e.element(),"background-color",r)},stepSize:10,min:0,max:360,getInitialValue:o.getInitialValue,sliderBehaviours:Ur([li(Is.refresh)])}))];var o,i},Bs=function(n,r){var e={onChange:function(n,e,t){r.undoManager.transact(function(){r.formatter.apply("forecolor",{value:t}),r.nodeChanged()})},getInitialValue:function(){return-1}};return As(n,"color",function(){return Ms(e)})},Rs=Nt([nr("getInitialValue"),nr("onChange"),nr("category"),nr("sizes")]),Fs=function(n){var o=Yt("SizeSlider",Rs,n);return Is.sketch({dom:{tag:"div",classes:[gi.resolve("slider-"+o.category+"-size-container"),gi.resolve("slider"),gi.resolve("slider-size-container")]},onChange:function(n,e,t){var r;0<=(r=t)&&r<o.sizes.length&&o.onChange(t)},onDragStart:function(n,e){si.on(e)},onDragEnd:function(n,e){si.off(e)},min:0,max:o.sizes.length-1,stepSize:1,getInitialValue:o.getInitialValue,snapToGrid:!0,sliderBehaviours:Ur([li(Is.refresh)]),components:[Is.parts().spectrum({dom:Gc('<div class="${prefix}-slider-size-container"></div>'),components:[_c('<div class="${prefix}-slider-size-line"></div>')]}),Is.parts().thumb({dom:Gc('<div class="${prefix}-slider-thumb"></div>'),behaviours:Ur([si.config({toggleClass:gi.resolve("thumb-active")})])})]})},Vs=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],Ns=function(n){var e,t,r=n.selection.getStart(),o=fe.fromDom(r),i=fe.fromDom(n.getBody()),u=(e=function(n){return He(i,n)},(pe(t=o)?V.some(t):je(t)).map(function(n){return vo(n,function(n){return Ci(n,"font-size").isSome()},e).bind(function(n){return Ci(n,"font-size")}).getOrThunk(function(){return Oi(n,"font-size")})}).getOr(""));return On(Vs,function(n){return u===n}).getOr("medium")},Hs={candidates:A(Vs),get:function(n){var e,t=Ns(n);return(e=t,kn(Vs,function(n){return n===e})).getOr(2)},apply:function(r,n){var e;(e=n,V.from(Vs[e])).each(function(n){var e,t;t=n,Ns(e=r)!==t&&e.execCommand("fontSize",!1,t)})}},zs=Hs.candidates(),js=function(n){return[_c('<span class="${prefix}-toolbar-button ${prefix}-icon-small-font ${prefix}-icon"></span>'),(e=n,Fs({onChange:e.onChange,sizes:zs,category:"font",getInitialValue:e.getInitialValue})),_c('<span class="${prefix}-toolbar-button ${prefix}-icon-large-font ${prefix}-icon"></span>')];var e},Ls=function(n){var e=n.uid!==undefined&&Ot(n,"uid")?n.uid:Fc("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).fold(V.none,V.some)},asSpec:function(){return C(n,{uid:e})}}};function Us(n,e){return $s(p.document.createElement("canvas"),n,e)}function Ps(n){return n.getContext("2d")}function $s(n,e,t){return n.width=e,n.height=t,n}var Ws={create:Us,clone:function(n){var e;return Ps(e=Us(n.width,n.height)).drawImage(n,0,0),e},resize:$s,get2dContext:Ps,get3dContext:function(n){var e=null;try{e=n.getContext("webgl")||n.getContext("experimental-webgl")}catch(t){}return e||(e=null),e}},Gs={getWidth:function(n){return n.naturalWidth||n.width},getHeight:function(n){return n.naturalHeight||n.height}},_s=window.Promise?window.Promise:function(){var n=function(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof n)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],s(n,r(o,this),r(u,this))},e=n.immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(n){p.setTimeout(n,1)};function r(n,e){return function(){n.apply(e,arguments)}}var t=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)};function i(r){var o=this;null!==this._state?e(function(){var n=o._state?r.onFulfilled:r.onRejected;if(null!==n){var e;try{e=n(o._value)}catch(t){return void r.reject(t)}r.resolve(e)}else(o._state?r.resolve:r.reject)(o._value)}):this._deferreds.push(r)}function o(n){try{if(n===this)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var e=n.then;if("function"==typeof e)return void s(r(e,n),r(o,this),r(u,this))}this._state=!0,this._value=n,a.call(this)}catch(t){u.call(this,t)}}function u(n){this._state=!1,this._value=n,a.call(this)}function a(){for(var n=0,e=this._deferreds.length;n<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"==typeof e?e:null,this.resolve=t,this.reject=r}function s(n,e,t){var r=!1;try{n(function(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.prototype.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.length)return o([]);var u=c.length;function a(e,n){try{if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if("function"==typeof t)return void t.call(n,function(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.constructor===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 qs(){return new(Ae.getOrDie("FileReader"))}var Ys={atob:function(n){return Ae.getOrDie("atob")(n)},requestAnimationFrame:function(n){Ae.getOrDie("requestAnimationFrame")(n)}};function Ks(a){return new _s(function(n,e){var t=p.URL.createObjectURL(a),r=new p.Image,o=function(){r.removeEventListener("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.addEventListener("load",i),r.addEventListener("error",u),r.src=t,r.complete&&i()})}function Xs(r){return new _s(function(n,t){var e=new p.XMLHttpRequest;e.open("GET",r,!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 to download image")).code=18,n.name="SecurityError",n):new Error("Error "+e.status+" downloading image"))},e.send()})}function Js(n){var e=n.split(","),t=/data:([^;]+)/.exec(e[0]);if(!t)return V.none();for(var r,o,i,u=t[1],a=e[1],c=Ys.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),v=new Array(g-m),p=m,h=0;p<g;++h,++p)v[h]=c[p].charCodeAt(0);l[d]=(r=v,new(Ae.getOrDie("Uint8Array"))(r))}return V.some((o=l,i={type:u},new(Ae.getOrDie("Blob"))(o,i)))}function Qs(t){return new _s(function(n,e){Js(t).fold(function(){e("uri is not base64: "+t)},n)})}function Zs(t){return new _s(function(n){var e=qs();e.onloadend=function(){n(e.result)},e.readAsDataURL(t)})}var nf,ef,tf,rf,of,uf,af,cf,sf={blobToImage:Ks,imageToBlob:function(n){var e=n.src;return 0===e.indexOf("data:")?Qs(e):Xs(e)},blobToArrayBuffer:function(t){return new _s(function(n){var e=qs();e.onloadend=function(){n(e.result)},e.readAsArrayBuffer(t)})},blobToDataUri:Zs,blobToBase64:function(n){return Zs(n).then(function(n){return n.split(",")[1]})},dataUriToBlobSync:Js,canvasToBlob:function(n,t,r){return t=t||"image/png",p.HTMLCanvasElement.prototype.toBlob?new _s(function(e){n.toBlob(function(n){e(n)},t,r)}):Qs(n.toDataURL(t,r))},canvasToDataURL:function(n,e,t){return e=e||"image/png",n.then(function(n){return n.toDataURL(e,t)})},blobToCanvas:function(n){return Ks(n).then(function(n){var e,t;return e=n,p.URL.revokeObjectURL(e.src),t=Ws.create(Gs.getWidth(n),Gs.getHeight(n)),Ws.get2dContext(t).drawImage(n,0,0),t})},uriToBlob:function(n){return 0===n.indexOf("blob:")?Xs(n):0===n.indexOf("data:")?Qs(n):null}},ff=function(n){return sf.blobToBase64(n)},lf=function(u){var e=Ls({dom:{tag:"input",attributes:{accept:"image/*",type:"file",title:""},styles:{visibility:"hidden",position:"absolute"}},events:dr([br(J()),gr(X(),function(n,e){var t,r,o;(t=e,r=t.event(),o=r.raw().target.files||r.raw().dataTransfer.files,V.from(o[0])).each(function(n){var o,i;o=u,ff(i=n).then(function(r){o.undoManager.transact(function(){var n=o.editorUpload.blobCache,e=n.create(Qa("mceu"),i,r);n.add(e);var t=o.dom.createHTML("img",{src:e.blobUri()});o.insertContent(t)})})})})])});return Pc.sketch({dom:Gc('<span class="${prefix}-toolbar-button ${prefix}-icon-image ${prefix}-icon"></span>'),components:[e.asSpec()],action:function(n){e.get(n).element().dom().click()}})},df=function(n){return n.dom().textContent},mf=function(n){return 0<n.length},gf=function(n){return n===undefined||null===n?"":n},vf=function(e,t,n){return n.text.filter(mf).fold(function(){return Kr(n=e,"href")===df(n)?V.some(t):V.none();var n},V.some)},pf=function(n){var e=fe.fromDom(n.selection.getStart());return Li(e,"a")},hf={getInfo:function(n){return pf(n).fold(function(){return{url:"",text:n.selection.getContent({format:"text"}),title:"",target:"",link:V.none()}},function(n){return t=df(e=n),r=Kr(e,"href"),o=Kr(e,"title"),i=Kr(e,"target"),{url:gf(r),text:t!==r?gf(t):"",title:gf(o),target:gf(i),link:V.some(e)};var e,t,r,o,i})},applyInfo:function(o,i){i.url.filter(mf).fold(function(){var e;e=o,i.link.bind(h).each(function(n){e.execCommand("unlink")})},function(e){var n,t,r=(n=i,(t={}).href=e,n.title.filter(mf).each(function(n){t.title=n}),n.target.filter(mf).each(function(n){t.target=n}),t);i.link.bind(h).fold(function(){var n=i.text.filter(mf).getOr(e);o.insertContent(o.dom.createHTML("a",r,o.dom.encode(n)))},function(t){var n=vf(t,e,i);Yr(t,r),n.each(function(n){var e;e=n,t.dom().textContent=e})})})},query:pf},bf=Wn.detect(),yf=function(n,e){var t=e.selection.getRng();n(),e.selection.setRng(t)},wf=function(n,e){(bf.os.isAndroid()?yf:s)(e,n)},xf=function(n,e){var t,r;return{key:n,value:{config:{},me:(t=n,r=dr(e),$r({fields:[nr("enabled")],name:t,active:{events:A(r)}})),configAsRaw:A({}),initialConfig:{},state:jr}}},Sf=Object.freeze({getCurrent:function(n,e,t){return e.find()(n)}}),Tf=[nr("find")],Of=$r({fields:Tf,name:"composing",apis:Sf}),kf=Lc({name:"Container",factory:function(n){return{uid:n.uid(),dom:C({tag:"div",attributes:{role:"presentation"}},n.dom()),components:n.components(),behaviours:Pa(n.containerBehaviours()),events:n.events(),domModification:n.domModification(),eventOrder:n.eventOrder()}},configFields:[ar("components",[]),Ua("containerBehaviours",[]),ar("events",{}),ar("domModification",{}),ar("eventOrder",{})]}),Cf=Lc({name:"DataField",factory:function(t){return{uid:t.uid(),dom:t.dom(),behaviours:C(Ur([Ss.config({store:{mode:"memory",initialValue:t.getInitialValue()()}}),Of.config({find:V.some})]),Pa(t.dataBehaviours())),events:dr([yr(function(n,e){Ss.setValue(n,t.getInitialValue()())})])}},configFields:[nr("uid"),nr("dom"),nr("getInitialValue"),Ua("dataBehaviours",[Ss,Of])]}),Ef=function(n){return n.dom().value},Df=function(n,e){if(e===undefined)throw new Error("Value.set was undefined");n.dom().value=e},If=A([or("data"),ar("inputAttributes",{}),ar("inputStyles",{}),ar("type","input"),ar("tag","input"),ar("inputClasses",[]),Wo("onSetValue"),ar("styles",{}),or("placeholder"),ar("eventOrder",{}),Ua("inputBehaviours",[Ss,yi]),ar("selectOnFocus",!0)]),Af=function(n){return C(Ur([Ss.config({store:{mode:"manual",initialValue:n.data().getOr(undefined),getValue:function(n){return Ef(n.element())},setValue:function(n,e){Ef(n.element())!==e&&Df(n.element(),e)}},onSetValue:n.onSetValue()})]),(e=n,Ur([yi.config({onFocus:!1===e.selectOnFocus()?I:function(n){var e=n.element(),t=Ef(e);e.dom().setSelectionRange(0,t.length)}})])),Pa(n.inputBehaviours()));var e},Mf=Lc({name:"Input",configFields:If(),factory:function(n,e){return{uid:n.uid(),dom:(t=n,{tag:t.tag(),attributes:C(St([{key:"type",value:t.type()}].concat(t.placeholder().map(function(n){return{key:"placeholder",value:n}}).toArray())),t.inputAttributes()),styles:t.inputStyles(),classes:t.inputClasses()}),components:[],behaviours:Af(n),eventOrder:n.eventOrder()};var t}}),Bf=Object.freeze({exhibit:function(n,e){return Er({attributes:St([{key:e.tabAttr(),value:"true"}])})}}),Rf=[ar("tabAttr","data-alloy-tabstop")],Ff=$r({fields:Rf,name:"tabstopping",active:Bf}),Vf=function(n,e){var t=Ls(Mf.sketch({placeholder:e,onSetValue:function(n,e){oe(n,K())},inputBehaviours:Ur([Of.config({find:V.some}),Ff.config({}),La.config({mode:"execution"})]),selectOnFocus:!1})),r=Ls(Pc.sketch({dom:Gc('<button class="${prefix}-input-container-x ${prefix}-icon-cancel-circle ${prefix}-icon"></button>'),action:function(n){var e=t.get(n);Ss.setValue(e,"")}}));return{name:n,spec:kf.sketch({dom:Gc('<div class="${prefix}-input-container"></div>'),components:[t.asSpec(),r.asSpec()],containerBehaviours:Ur([si.config({toggleClass:gi.resolve("input-container-empty")}),Of.config({find:function(n){return V.some(t.get(n))}}),xf("input-clearing",[gr(K(),function(n){var e=t.get(n);(0<Ss.getValue(e).length?si.off:si.on)(n)})])])})}},Nf=["input","button","textarea"],Hf=function(n,e,t){e.disabled()&&$f(n,e,t)},zf=function(n){return bn(Nf,ge(n.element()))},jf=function(n){qr(n.element(),"disabled","disabled")},Lf=function(n){Jr(n.element(),"disabled")},Uf=function(n){qr(n.element(),"aria-disabled","true")},Pf=function(n){qr(n.element(),"aria-disabled","false")},$f=function(e,n,t){n.disableClass().each(function(n){ro(e.element(),n)}),(zf(e)?jf:Uf)(e)},Wf=function(n){return zf(n)?Xr(n.element(),"disabled"):"true"===Kr(n.element(),"aria-disabled")},Gf=Object.freeze({enable:function(e,n,t){n.disableClass().each(function(n){oo(e.element(),n)}),(zf(e)?Lf:Pf)(e)},disable:$f,isDisabled:Wf,onLoad:Hf}),_f=Object.freeze({exhibit:function(n,e,t){return Er({classes:e.disabled()?e.disableClass().map(Rn).getOr([]):[]})},events:function(n,e){return dr([mr(Kn(),function(n,e){return Wf(n)}),Ir(n,e,Hf)])}}),qf=[ar("disabled",!1),or("disableClass")],Yf=$r({fields:qf,name:"disabling",active:_f,apis:Gf}),Kf=[Ua("formBehaviours",[Ss])],Xf=function(n){return"<alloy.field."+n+">"},Jf=function(o,n,e){return C({"debug.sketcher":{Form:e},uid:o.uid(),dom:o.dom(),components:n,behaviours:C(Ur([Ss.config({store:{mode:"manual",getValue:function(n){var e,t,r=(e=o,t=n.getSystem(),z(e.partUids(),function(n,e){return A(t.getByUid(n))}));return z(r,function(n,e){return n().bind(Of.getCurrent).map(Ss.getValue)})},setValue:function(t,n){H(n,function(e,n){wc(t,o,n).each(function(n){Of.getCurrent(n).each(function(n){Ss.setValue(n,e)})})})}}})]),Pa(o.formBehaviours())),apis:{getField:function(n,e){return wc(n,o,e).bind(Of.getCurrent)}}})},Qf=(Ec(function(n,e,t){return n.getField(e,t)}),function(n){var i,e=(i=[],{field:function(n,e){return i.push(n),t="form",r=Xf(n),o=e,{uiType:Xa(),owner:t,name:r,config:o,validated:{}};var t,r,o},record:function(){return i}}),t=n(e),r=e.record(),o=yn(r,function(n){return lc({name:n,pname:Xf(n)})});return Nc("form",Kf,o,Jf,t)}),Zf=function(){var e=lo(V.none()),t=function(){e.get().each(function(n){n.destroy()})};return{clear:function(){t(),e.set(V.none())},isSet:function(){return e.get().isSome()},set:function(n){t(),e.set(V.some(n))},run:function(n){e.get().each(n)}}},nl=function(){var e=lo(V.none());return{clear:function(){e.set(V.none())},set:function(n){e.set(V.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}},el=function(n){return{xValue:n,points:[]}},tl=function(n,e){if(e===n.xValue)return n;var t=0<e-n.xValue?1:-1,r={direction:t,xValue: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])}},rl=function(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},ol=function(n){var r="navigateEvent",e=Ht([nr("fields"),ar("maxFieldIndex",n.fields.length-1),nr("onExecute"),nr("getInitialValue"),sr("state",function(){return{dialogSwipeState:nl(),currentScreen:lo(0)}})]),u=Yt("SerialisedDialog",e,n),o=function(e,n,t){return Pc.sketch({dom:Gc('<span class="${prefix}-icon-'+n+' ${prefix}-icon"></span>'),action:function(n){ie(n,r,{direction:e})},buttonBehaviours:Ur([Yf.config({disableClass:gi.resolve("toolbar-navigation-disabled"),disabled:!t})])})},i=function(n,o){var i=Ni(n.element(),"."+gi.resolve("serialised-dialog-screen"));ji(n.element(),"."+gi.resolve("serialised-dialog-chain")).each(function(r){0<=u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o<i.length&&(Ci(r,"left").each(function(n){var e=parseInt(n,10),t=Es(i[0]);Si(r,"left",e-o*t+"px")}),u.state.currentScreen.set(u.state.currentScreen.get()+o))})},a=function(r){var n=Ni(r.element(),"input");V.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.getSystem().triggerFocus(t,e.element())})});var e=s.get(r);cu.highlightAt(e,u.state.currentScreen.get())},c=Ls(Qf(function(t){return{dom:Gc('<div class="${prefix}-serialised-dialog"></div>'),components:[kf.sketch({dom:Gc('<div class="${prefix}-serialised-dialog-chain" style="left: 0px; position: absolute;"></div>'),components:yn(u.fields,function(n,e){return e<=u.maxFieldIndex?kf.sketch({dom:Gc('<div class="${prefix}-serialised-dialog-screen"></div>'),components:Dn([[o(-1,"previous",0<e)],[t.field(n.name,n.spec)],[o(1,"next",e<u.maxFieldIndex)]])}):t.field(n.name,n.spec)})})],formBehaviours:Ur([li(function(n,e){var t;t=e,ji(n.element(),"."+gi.resolve("serialised-dialog-chain")).each(function(n){Si(n,"left",-u.state.currentScreen.get()*t.width+"px")})}),La.config({mode:"special",focusIn:function(n){a(n)},onTab:function(n){return i(n,1),V.some(!0)},onShiftTab:function(n){return i(n,-1),V.some(!0)}}),xf("form-events",[yr(function(e,n){u.state.currentScreen.set(0),u.state.dialogSwipeState.clear();var t=s.get(e);cu.highlightFirst(t),u.getInitialValue(e).each(function(n){Ss.setValue(e,n)})}),Sr(u.onExecute),gr(Q(),function(n,e){"left"===e.event().raw().propertyName&&a(n)}),gr(r,function(n,e){var t=e.event().direction();i(n,t)})])])}})),s=Ls({dom:Gc('<div class="${prefix}-dot-container"></div>'),behaviours:Ur([cu.config({highlightClass:gi.resolve("dot-active"),itemClass:gi.resolve("dot-item")})]),components:In(u.fields,function(n,e){return e<=u.maxFieldIndex?[_c('<div class="${prefix}-dot-item ${prefix}-icon-full-dot ${prefix}-icon"></div>')]:[]})});return{dom:Gc('<div class="${prefix}-serializer-wrapper"></div>'),components:[c.asSpec(),s.asSpec()],behaviours:Ur([La.config({mode:"special",focusIn:function(n){var e=c.get(n);La.focusIn(e)}}),xf("serializer-wrapper-events",[gr(U(),function(n,e){var t=e.event();u.state.dialogSwipeState.set(el(t.touches[0].clientX))}),gr(P(),function(n,e){var t=e.event();u.state.dialogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeState.set(tl(n,t.raw().touches[0].clientX))})}),gr($(),function(r){u.state.dialogSwipeState.on(function(n){var e=c.get(r),t=-1*rl(n);i(e,t)})})])])}},il=nn(function(t,r){return[{label:"the link group",items:[ol({fields:[Vf("url","Type or paste URL"),Vf("text","Link text"),Vf("title","Link title"),Vf("target","Link target"),(n="link",{name:n,spec:Cf.sketch({dom:{tag:"span",styles:{display:"none"}},getInitialValue:function(){return V.none()}})})],maxFieldIndex:["url","text","title","target"].length-1,getInitialValue:function(){return V.some(hf.getInfo(r))},onExecute:function(n){var e=Ss.getValue(n);hf.applyInfo(r,e),t.restoreToolbar(),r.focus()}})]}];var n}),ul=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}],al=dr([(nf=_n(),ef=function(n,e){var t,r,o=e.event().originator(),i=e.event().target();return r=i,!(He(t=o,n.element())&&!He(t,r)&&(p.console.warn(_n()+" did not get interpreted by the desired target. \nOriginator: "+Io(o)+"\nTarget: "+Io(i)+"\nCheck the "+_n()+" event handlers"),1))},{key:nf,value:fr({can:ef})})]),cl=Object.freeze({events:al}),sl=h,fl=zr(["debugInfo","triggerFocus","triggerEvent","triggerEscape","addToWorld","removeFromWorld","addToGui","removeFromGui","build","getByUid","getByDom","broadcast","broadcastOn","isConnected"]),ll=function(e){var n=function(n){return function(){throw new Error("The component must be in a context to send: "+n+"\n"+Io(e().element())+" is not in context.")}};return fl({debugInfo:A("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerFocus"),triggerEscape:n("triggerEscape"),build:n("build"),addToWorld:n("addToWorld"),removeFromWorld:n("removeFromWorld"),addToGui:n("addToGui"),removeFromGui:n("removeFromGui"),getByUid:n("getByUid"),getByDom:n("getByDom"),broadcast:n("broadcast"),broadcastOn:n("broadcastOn"),isConnected:A(!1)})},dl=function(n,o){var i={};return H(n,function(n,r){H(n,function(n,e){var t=yt(e,[])(i);i[e]=t.concat([o(r,n)])})}),i},ml=function(n,e){return 1<n.length?et.error('Multiple behaviours have tried to change DOM "'+e+'". The guilty behaviours are: '+Dt(yn(n,function(n){return n.name()}))+". At this stage, this is not supported. Future releases might provide strategies for resolving this."):0===n.length?et.value({}):et.value(n[0].modification().fold(function(){return{}},function(n){return xt(e,n)}))},gl=function(u,a){return Tn(u,function(n,e){var t=e.modification().getOr({});return n.bind(function(i){var n=L(t,function(n,e){return i[e]!==undefined?(t=a,r=e,o=u,et.error("Mulitple behaviours have tried to change the _"+r+'_ "'+t+'". The guilty behaviours are: '+Dt(In(o,function(n){return n.modification().getOr({})[r]!==undefined?[n.name()]:[]}),null,2)+". This is not currently supported.")):et.value(xt(e,n));var t,r,o});return Tt(n,i)})},et.value({})).map(function(n){return xt(a,n)})},vl={classes:function(n,e){var t=In(n,function(n){return n.modification().getOr([])});return et.value(xt(e,t))},attributes:gl,styles:gl,domChildren:ml,defChildren:ml,innerHtml:ml,value:ml},pl=function(n,e){return t=l.apply(undefined,[n.handler].concat(e)),r=n.purpose(),{cHandler:t,purpose:A(r)};var t,r},hl=function(n){return n.cHandler},bl=function(n,e){return{name:A(n),handler:A(e)}},yl=function(n,e,t){var r,o,i=C(t,(r=n,o={},wn(e,function(n){o[n.name()]=n.handlers(r)}),o));return dl(i,bl)},wl=function(n){var e,i=x(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]=arguments[r];var o=[n,e].concat(t);i.abort.apply(undefined,o)?e.stop():i.can.apply(undefined,o)&&i.run.apply(undefined,o)}},xl=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 for "+u+" does not have an entry for "+t+".\nOrder specified: "+Dt(c,null,2));if(-1===i)throw new Error("The ordering for "+u+" does not have an entry for "+r+".\nOrder specified: "+Dt(c,null,2));return o<i?-1:i<o?1:0});return et.value(t)}catch(r){return et.error([r])}}("Event: "+t,"name",n,i).map(function(n){var e=yn(n,function(n){return n.handler()});return lr(e)}):(r=t,o=n,et.error(["The event ("+r+') has more than one behaviour that 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 can trigger it are: '+Dt(yn(o,function(n){return n.name()}),null,2)]))},Sl=function(n,i){var e=L(n,function(r,o){return(1===r.length?et.value(r[0].handler()):xl(r,i,o)).map(function(n){var e=wl(n),t=1<r.length?xn(i,function(e){return bn(r,function(n){return n.name()===e})}).join(" > "):r[0].name();return xt(o,{handler:e,purpose:A(t)})})});return Tt(e,{})},Tl=function(n){return _t("custom.definition",Nt([Ut("dom","dom",it(),Nt([nr("tag"),ar("styles",{}),ar("classes",[]),ar("attributes",{}),or("value"),or("innerHtml")])),nr("components"),nr("uid"),ar("events",{}),ar("apis",A({})),Ut("eventOrder","eventOrder",(e={"alloy.execute":["disabling","alloy.base.behaviour","toggling"],"alloy.focus":["alloy.base.behaviour","focusing","keying"],"alloy.system.init":["alloy.base.behaviour","disabling","toggling","representing"],input:["alloy.base.behaviour","representing","streaming","invalidating"],"alloy.system.detached":["alloy.base.behaviour","representing"]},rt.mergeWithThunk(A(e))),Qt()),or("domModification"),Ko("originalSpec"),ar("debug.sketcher","unknown")]),n);var e},Ol=function(n){var e,t={tag:n.dom().tag(),classes:n.dom().classes(),attributes:C((e=n,xt(Ac(),e.uid())),n.dom().attributes()),styles:n.dom().styles(),domChildren:yn(n.components(),function(n){return n.element()})};return kr(C(t,n.dom().innerHtml().map(function(n){return xt("innerHtml",n)}).getOr({}),n.dom().value().map(function(n){return xt("value",n)}).getOr({})))},kl=function(e,n){wn(n,function(n){ro(e,n)})},Cl=function(e,n){wn(n,function(n){oo(e,n)})},El=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=Cr(e),Dt(n,null,2)));return e.domChildren().fold(function(){var n=e.defChildren().getOr([]);return yn(n,Il)},function(n){return n});var n},Dl=function(n){var e=fe.fromTag(n.tag());Yr(e,n.attributes().getOr({})),kl(e,n.classes().getOr([])),Ti(e,n.styles().getOr({})),Co(e,n.innerHtml().getOr(""));var t=El(n);return We(e,t),n.value().each(function(n){Df(e,n)}),e},Il=function(n){var e=kr(n);return Dl(e)},Al=function(n,e){return t=n,o=yn(r=e,function(n){return ir(n.name(),[nr("config"),ar("state",jr)])}),i=_t("component.behaviours",Ht(o),t.behaviours).fold(function(n){throw new Error(Xt(n)+"\nComplete spec:\n"+Dt(t,null,2))},function(n){return n}),{list:r,data:z(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},Ml=function(n){var e,t,r=(e=wt(n,"behaviours").getOr({}),t=xn(N(e),function(n){return e[n]!==undefined}),yn(t,function(n){return e[n].me}));return Al(n,r)},Bl=zr(["getSystem","config","hasConfigured","spec","connect","disconnect","element","syncComponents","readState","components","events"]),Rl=function(n,e,t){var r,o,i,u,a=Ol(n),c=function(e,n,t,r){var o=C({},n);wn(t,function(n){o[n.name()]=n.exhibit(e,r)});var i=dl(o,function(n,e){return{name:function(){return n},modification:e}}),u=z(i,function(n,e){return In(n,function(e){return e.modification().fold(function(){return[]},function(n){return[e]})})}),a=L(u,function(e,t){return wt(vl,t).fold(function(){return et.error("Unknown field type: "+t)},function(n){return n(e,t)})});return Tt(a,{}).map(Er)}(t,{"alloy.base.modification":(r=n,r.domModification().fold(function(){return Er({})},Er))},e,a).getOrDie();return i=c,u=C({tag:(o=a).tag(),classes:i.classes().getOr([]).concat(o.classes().getOr([])),attributes:E(o.attributes().getOr({}),i.attributes().getOr({})),styles:E(o.styles().getOr({}),i.styles().getOr({}))},i.innerHtml().or(o.innerHtml()).map(function(n){return xt("innerHtml",n)}).getOr({}),Dr("domChildren",i.domChildren(),o.domChildren()),Dr("defChildren",i.defChildren(),o.defChildren()),i.value().or(o.value()).map(function(n){return xt("value",n)}).getOr({})),kr(u)},Fl=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=yl(o,u,a),Sl(c,i)).getOrDie()},Vl=function(n){var e,t,r,o,i,u,a,c,s,f,l,d,m,g,v=sl(n),p=(e=v,t=yt("components",[])(e),yn(t,zl)),h=C(cl,v,xt("components",p));return et.value((r=h,i=lo(ll(o=function(){return g})),u=qt(Tl(C(r,{behaviours:undefined}))),a=Ml(r),c=a.list,s=a.data,f=Rl(u,c,s),l=Dl(f),d=Fl(u,c,s),m=lo(u.components()),g=Bl({getSystem:i.get,config:function(n){if(n===Dc())return u.apis();if(b(n))throw new Error("Invalid input: only API constant is allowed");var e=s;return(x(e[n.name()])?e[n.name()]:function(){throw new Error("Could not find "+n.name()+" in "+Dt(r,null,2))})()},hasConfigured:function(n){return x(s[n.name()])},spec:A(r),readState:function(n){return s[n]().map(function(n){return n.state.readState()}).getOr("not enabled")},connect:function(n){i.set(n)},disconnect:function(){i.set(ll(o))},element:A(l),syncComponents:function(){var n=Le(l),e=In(n,function(n){return i.get().getByDom(n).fold(function(){return[]},function(n){return[n]})});m.set(e)},components:m.get,events:A(d)})))},Nl=function(n){var e=fe.fromText(n);return Hl({element:e})},Hl=function(n){var t=Kt("external.component",Nt([nr("element"),or("uid")]),n),e=lo(ll());t.uid().each(function(n){var e;e=t.element(),qr(e,Bc,n)});var r=Bl({getSystem:e.get,config:V.none,hasConfigured:A(!1),connect:function(n){e.set(n)},disconnect:function(){e.set(ll(function(){return r}))},element:A(t.element()),spec:A(n),readState:A("No state"),syncComponents:I,components:A([]),events:A({})});return Cc(r)},zl=function(e){return(n=e,wt(n,Oc)).fold(function(){var n=C({uid:Fc("")},e);return Vl(n).getOrDie()},function(n){return n});var n},jl=Cc,Ll="alloy.item-hover",Ul="alloy.item-focus",Pl=function(n){(wo(n.element()).isNone()||yi.isFocused(n))&&(yi.isFocused(n)||yi.focus(n),ie(n,Ll,{item:n}))},$l=function(n){ie(n,Ul,{item:n})},Wl=A(Ll),Gl=A(Ul),_l=[nr("data"),nr("components"),nr("dom"),or("toggling"),ar("itemBehaviours",{}),ar("ignoreFocus",!1),ar("domModification",{}),Yo("builder",function(n){return{dom:C(n.dom(),{attributes:{role:n.toggling().isSome()?"menuitemcheckbox":"menuitem"}}),behaviours:C(Ur([n.toggling().fold(si.revoke,function(n){return si.config(C({aria:{mode:"checked"}},n))}),yi.config({ignore:n.ignoreFocus(),onFocus:function(n){$l(n)}}),La.config({mode:"execution"}),Ss.config({store:{mode:"memory",initialValue:n.data()}})]),n.itemBehaviours()),events:dr([(e=Qn(),r=ue,gr(e,function(e,t){var n=t.event();e.getSystem().getByDom(n.target()).each(function(n){r(e,n,t)})})),br(W()),gr(q(),Pl),gr(Xn(),yi.focus)]),components:n.components(),domModification:n.domModification(),eventOrder:n.eventOrder()};var e,r}),ar("eventOrder",{})],ql=[nr("dom"),nr("components"),Yo("builder",function(n){return{dom:n.dom(),components:n.components(),events:dr([(e=Xn(),gr(e,function(n,e){e.stop()}))])};var e})],Yl=A([lc({name:"widget",overrides:function(e){return{behaviours:Ur([Ss.config({store:{mode:"manual",getValue:function(n){return e.data()},setValue:function(){}}})])}}})]),Kl=[nr("uid"),nr("data"),nr("components"),nr("dom"),ar("autofocus",!1),ar("domModification",{}),Tc(Yl()),Yo("builder",function(t){var n=bc(0,t,Yl()),e=yc("item-widget",t,n.internals()),r=function(n){return wc(n,t,"widget").map(function(n){return La.focusIn(n),n})},o=function(n,e){return gu(e.event().target())||t.autofocus()&&e.setSource(n.element()),V.none()};return C({dom:t.dom(),components:e,domModification:t.domModification(),events:dr([Sr(function(n,e){r(n).each(function(n){e.stop()})}),gr(q(),Pl),gr(Xn(),function(n,e){t.autofocus()?r(n):yi.focus(n)})]),behaviours:Ur([Ss.config({store:{mode:"memory",initialValue:t.data()}}),yi.config({onFocus:function(n){$l(n)}}),La.config({mode:"special",focusIn:t.autofocus()?function(n){r(n)}:Gr(),onLeft:o,onRight:o,onEscape:function(n,e){return yi.isFocused(n)||t.autofocus()?(t.autofocus()&&e.setSource(n.element()),V.none()):(yi.focus(n),V.some(!0))}})])})})],Xl=Jt("type",{widget:Kl,item:_l,separator:ql}),Jl=A([mc({factory:{sketch:function(n){var e=Kt("menu.spec item",Xl,n);return e.builder()(e)}},name:"items",unit:"item",defaults:function(n,e){var t=Fc("");return C({uid:t},e)},overrides:function(n,e){return{type:e.type,ignoreFocus:n.fakeFocus(),domModification:{classes:[n.markers().item()]}}}})]),Ql=A([nr("value"),nr("items"),nr("dom"),nr("components"),ar("eventOrder",{}),Ua("menuBehaviours",[cu,Ss,Of,La]),cr("movement",{mode:"menu",moveOnTab:!0},Jt("mode",{grid:[Xo(),Yo("config",function(n,e){return{mode:"flatgrid",selector:"."+n.markers().item(),initSize:{numColumns:e.initSize().numColumns(),numRows:e.initSize().numRows()},focusManager:n.focusManager()}})],menu:[ar("moveOnTab",!0),Yo("config",function(n,e){return{mode:"menu",selector:"."+n.markers().item(),moveOnTab:e.moveOnTab(),focusManager:n.focusManager()}})]})),er("markers",Uo()),ar("fakeFocus",!1),ar("focusManager",su()),Wo("onHighlight")]),Zl=A("alloy.menu-focus"),nd=Uc({name:"Menu",configFields:Ql(),partFields:Jl(),factory:function(n,e,t,r){return C({dom:C(n.dom(),{attributes:{role:"menu"}}),uid:n.uid(),behaviours:C(Ur([cu.config({highlightClass:n.markers().selectedItem(),itemClass:n.markers().item(),onHighlight:n.onHighlight()}),Ss.config({store:{mode:"memory",initialValue:n.value()}}),Of.config({find:V.some}),La.config(n.movement().config()(n,n.movement()))]),Pa(n.menuBehaviours())),events:dr([gr(Gl(),function(e,t){var n=t.event();e.getSystem().getByDom(n.target()).each(function(n){cu.highlight(e,n),t.stop(),ie(e,Zl(),{menu:e,item:n})})}),gr(Wl(),function(n,e){var t=e.event().item();cu.highlight(n,t)})]),components:e,eventOrder:n.eventOrder()})}}),ed=function(n,e,t,r){var o=n.getSystem().build(r);Xe(n,o,t)},td=function(n,e){return n.components()},rd=$r({fields:[],name:"replacing",apis:Object.freeze({append:function(n,e,t,r){ed(n,0,$e,r)},prepend:function(n,e,t,r){ed(n,0,Pe,r)},remove:function(n,e,t,r){var o=td(n,e);On(o,function(n){return He(r.element(),n.element())}).each(Qe)},set:function(e,n,t,r){var o,i,u,a,c,s;i=(o=e).components(),wn(i,Je),Ge(o.element()),o.syncComponents(),u=function(){var n=yn(r,e.getSystem().build);wn(n,function(n){Ke(e,n)})},a=e.element(),c=ze(a),s=yo(c).bind(function(e){var n=function(n){return He(e,n)};return n(a)?V.some(a):po(a,n)}),u(a),s.each(function(e){yo(c).filter(function(n){return He(n,e)}).fold(function(){ho(e)},I)})},contents:td})}),od=function(t,r,o,n){return wt(o,n).bind(function(n){return wt(t,n).bind(function(n){var e=od(t,r,o,n);return V.some([n].concat(e))})}).getOr([])},id=function(n,e){var t={};H(n,function(n,e){wn(n,function(n){t[n]=e})});var r=e,o=j(e,function(n,e){return{k:n,v:e}}),i=z(o,function(n,e){return[e].concat(od(t,r,o,e))});return z(t,function(n){return wt(i,n).getOr([n])})},ud=function(){var i=lo({}),u=lo({}),a=lo({}),c=lo(V.none()),s=lo({}),n=function(n){return wt(u.get(),n)};return{setContents:function(n,e,t,r){c.set(V.some(n)),i.set(t),u.set(e),s.set(r);var o=id(r,t);a.set(o)},expand:function(t){return wt(i.get(),t).map(function(n){var e=wt(a.get(),t).getOr([]);return[n].concat(e)})},refresh:function(n){return wt(a.get(),n)},collapse:function(n){return wt(a.get(),n).bind(function(n){return 1<n.length?V.some(n.slice(1)):V.none()})},lookupMenu:n,otherMenus:function(n){var e,t,r=s.get();return e=N(r),t=n,xn(e,function(n){return!bn(t,n)})},getPrimary:function(){return c.get().bind(n)},getMenus:function(){return u.get()},clear:function(){i.set({}),u.set({}),a.set({}),c.set(V.none())},isClear:function(){return c.get().isNone()}}},ad=A("collapse-item"),cd=Lc({name:"TieredMenu",configFields:[qo("onExecute"),qo("onEscape"),_o("onOpenMenu"),_o("onOpenSubmenu"),Wo("onCollapseMenu"),ar("openImmediately",!0),rr("data",[nr("primary"),nr("menus"),nr("expansions")]),ar("fakeFocus",!1),Wo("onHighlight"),Wo("onHover"),rr("markers",[nr("backgroundMenu")].concat(jo()).concat(Lo())),nr("dom"),ar("navigateOnHover",!0),ar("stayInDom",!1),Ua("tmenuBehaviours",[La,cu,Of,rd]),ar("eventOrder",{})],apis:{collapseMenu:function(n,e){n.collapseMenu(e)}},factory:function(u,o){var i=function(r,n){return z(n,function(n,e){var t=nd.sketch(C(n,{value:e,items:n.items,markers:pt(o.markers,["item","selectedItem"]),fakeFocus:u.fakeFocus(),onHighlight:u.onHighlight(),focusManager:u.fakeFocus()?{get:function(n){return cu.getHighlighted(n).map(function(n){return n.element()})},set:function(e,n){e.getSystem().getByDom(n).fold(I,function(n){cu.highlight(e,n)})}}:su()}));return r.getSystem().build(t)})},a=ud(),c=function(n){return Ss.getValue(n).value},s=function(n){return z(u.data().menus(),function(n,e){return In(n.items,function(n){return"separator"===n.type?[]:[n.data.value]})})},f=function(e,n){cu.highlight(e,n),cu.getHighlighted(n).orThunk(function(){return cu.getFirst(n)}).each(function(n){ae(e,n.element(),Xn())})},l=function(n,e){return Mo(yn(e,n.lookupMenu))},d=function(r,o,i){return V.from(i[0]).bind(o.lookupMenu).map(function(n){var e=l(o,i.slice(1));wn(e,function(n){ro(n.element(),u.markers().backgroundMenu())}),be(n.element())||rd.append(r,jl(n)),Cl(n.element(),[u.markers().backgroundMenu()]),f(r,n);var t=l(o,o.otherMenus(i));return wn(t,function(n){Cl(n.element(),[u.markers().backgroundMenu()]),u.stayInDom()||rd.remove(r,n)}),n})},m=function(e,t){var n=c(t);return a.expand(n).bind(function(n){return V.from(n[0]).bind(a.lookupMenu).each(function(n){be(n.element())||rd.append(e,jl(n)),u.onOpenSubmenu()(e,t,n),cu.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 Li(n.getSource(),"."+u.markers().item()).bind(function(n){return e.getSystem().getByDom(n).toOption().bind(function(n){return t(e,n).map(function(){return!0})})})}},e=dr([gr(Zl(),function(n,e){var t=e.event().menu();cu.highlight(n,t)}),Sr(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).fold(function(){u.onExecute()(e,n)},function(){})})}),yr(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().expansions(),o),a.getPrimary()).each(function(n){rd.append(e,jl(n)),u.openImmediately()&&(f(e,n),u.onOpenMenu()(e,n))})})].concat(u.navigateOnHover()?[gr(Wl(),function(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:C(Ur([La.config({mode:"special",onRight:n(function(n,e){return gu(e.element())?V.none():m(n,e)}),onLeft:n(function(n,e){return gu(e.element())?V.none():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){ae(e,n.element(),Xn())})}}),cu.config({highlightClass:u.markers().selectedMenu(),itemClass:u.markers().menu()}),Of.config({find:function(n){return cu.getHighlighted(n)}}),rd.config({})]),Pa(u.tmenuBehaviours())),eventOrder:u.eventOrder(),apis:{collapseMenu:function(e){cu.getHighlighted(e).each(function(n){cu.getHighlighted(n).each(function(n){r(e,n)})})}},events:e}},extraApis:{tieredData:function(n,e,t){return{primary:n,menus:e,expansions:t}},singleData:function(n,e){return{primary:n,menus:xt(n,e),expansions:{}}},collapseItem:function(n){return{value:Qa(ad()),text:n}}}}),sd=function(n,e,t,r){return wt(e.routes(),r.start()).map(s).bind(function(n){return wt(n,r.destination()).map(s)})},fd=function(n,e,t,r){return sd(0,e,0,r).bind(function(e){return e.transition().map(function(n){return{transition:A(n),route:A(e)}})})},ld=function(t,r,n){var e,o,i;(e=t,o=r,i=n,dd(e,o,i).bind(function(n){return fd(e,o,i,n)})).each(function(n){var e=n.transition();oo(t.element(),e.transitionClass()),Jr(t.element(),r.destinationAttr())})},dd=function(n,e,t){var r=n.element();return Xr(r,e.destinationAttr())?V.some({start:A(Kr(n.element(),e.stateAttr())),destination:A(Kr(n.element(),e.destinationAttr()))}):V.none()},md=function(n,e,t,r){ld(n,e,t),Xr(n.element(),e.stateAttr())&&Kr(n.element(),e.stateAttr())!==r&&e.onFinish()(n,r),qr(n.element(),e.stateAttr(),r)},gd=Object.freeze({findRoute:sd,disableTransition:ld,getCurrentRoute:dd,jumpTo:md,progressTo:function(t,r,o,i){var n,e;e=r,Xr((n=t).element(),e.destinationAttr())&&(qr(n.element(),e.stateAttr(),Kr(n.element(),e.destinationAttr())),Jr(n.element(),e.destinationAttr()));var u,a,c=(u=r,a=i,{start:A(Kr(t.element(),u.stateAttr())),destination:A(a)});fd(t,r,o,c).fold(function(){md(t,r,o,i)},function(n){ld(t,r,o);var e=n.transition();ro(t.element(),e.transitionClass()),qr(t.element(),r.destinationAttr(),i)})},getState:function(n,e,t){var r=n.element();return Xr(r,e.stateAttr())?V.some(Kr(r,e.stateAttr())):V.none()}}),vd=Object.freeze({events:function(o,i){return dr([gr(Q(),function(t,n){var r=n.event().raw();dd(t,o,i).each(function(e){sd(0,o,0,e).each(function(n){n.transition().each(function(n){r.propertyName===n.property()&&(md(t,o,i,e.destination()),o.onTransition()(t,e))})})})}),yr(function(n,e){md(n,o,i,o.initialState())})])}}),pd=[ar("destinationAttr","data-transitioning-destination"),ar("stateAttr","data-transitioning-state"),nr("initialState"),Wo("onTransition"),Wo("onFinish"),er("routes",zt(et.value,zt(et.value,Nt([ur("transition",[nr("property"),nr("transitionClass")])]))))],hd=$r({fields:pd,name:"transitioning",active:vd,apis:gd,extra:{createRoutes:function(n){var r={};return H(n,function(n,e){var t=e.split("<->");r[t[0]]=xt(t[1],n),r[t[1]]=xt(t[0],n)}),r},createBistate:function(n,e,t){return St([{key:n,value:xt(e,t)},{key:e,value:xt(n,t)}])},createTristate:function(n,e,t,r){return St([{key:n,value:St([{key:e,value:r},{key:t,value:r}])},{key:e,value:St([{key:n,value:r},{key:t,value:r}])},{key:t,value:St([{key:n,value:r},{key:e,value:r}])}])}}}),bd=gi.resolve("scrollable"),yd={register:function(n){ro(n,bd)},deregister:function(n){oo(n,bd)},scrollable:A(bd)},wd=function(n){return wt(n,"format").getOr(n.title)},xd=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[gi.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:gi.resolve("format-matches"),selected:t},itemBehaviours:Ur(o?[]:[fi(n,function(n,e){(e?si.on:si.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},Sd=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[Pc.sketch({dom:{tag:"div",classes:[gi.resolve("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[gi.resolve("styles-collapse-icon")]}},Nl(n)]:[Nl(n)],action:function(n){if(r){var e=t().get(n);cd.collapseMenu(e)}}}),{dom:{tag:"div",classes:[gi.resolve("styles-menu-items-container")]},components:[nd.parts().items({})],behaviours:Ur([xf("adhoc-scrollable-menu",[yr(function(n,e){Si(n.element(),"overflow-y","auto"),Si(n.element(),"-webkit-overflow-scrolling","touch"),yd.register(n.element())}),wr(function(n){Ei(n.element(),"overflow-y"),Ei(n.element(),"-webkit-overflow-scrolling"),yd.deregister(n.element())})])])}],items:e,menuBehaviours:Ur([hd.config({initialState:"after",routes:hd.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},Td=function(r){var o,i,n,e,t,u=(o=r.formats,i=function(){return a},n=Sd("Styles",[].concat(yn(o.items,function(n){return xd(wd(n),n.title,n.isSelected(),n.getPreview(),Ot(o.expansions,wd(n)))})),i,!1),e=z(o.menus,function(n,e){var t=yn(n,function(n){return xd(wd(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",Ot(o.expansions,wd(n)))});return Sd(e,t,i,!0)}),t=C(e,xt("styles",n)),{tmenu:cd.tieredData("styles",t,o.expansions)}),a=Ls(cd.sketch({dom:{tag:"div",classes:[gi.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=Ss.getValue(e);return r.handle(e,t.value),V.none()},onEscape:function(){return V.none()},onOpenMenu:function(n,e){var t=Es(n.element());Cs(e.element(),t),hd.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=Es(n.element()),o=zi(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();Cs(t.element(),r),hd.progressTo(i,"before"),hd.jumpTo(t,"after"),hd.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=zi(e.element(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();hd.progressTo(o,"after"),hd.progressTo(t,"current")},navigateOnHover:!1,openImmediately:!0,data:u.tmenu,markers:{backgroundMenu:gi.resolve("styles-background-menu"),menu:gi.resolve("styles-menu"),selectedMenu:gi.resolve("styles-selected-menu"),item:gi.resolve("styles-item"),selectedItem:gi.resolve("styles-selected-item")}}));return a.asSpec()},Od=function(n){return Ot(n,"items")?(t=C(ht(e=n,["items"]),{menu:!0}),r=kd(e.items),{item:t,menus:C(r.menus,xt(e.title,r.items)),expansions:C(r.expansions,xt(e.title,e.title))}):{item:n,menus:{},expansions:{}};var e,t,r},kd=function(n){return Sn(n,function(n,e){var t=Od(e);return{menus:C(n.menus,t.menus),items:[t.item].concat(n.items),expansions:C(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},Cd={expand:kd},Ed=function(u,n){var a=function(n){return function(){return u.formatter.match(n)}},c=function(n){return function(){return u.formatter.getCssText(n)}},e=wt(n,"style_formats").getOr(ul),s=function(n){return yn(n,function(n){if(Ot(n,"items")){var e=s(n.items);return C(C(n,{isSelected:A(!1),getPreview:A("")}),{items:e})}return Ot(n,"format")?C(i=n,{isSelected:a(i.format),getPreview:c(i.format)}):(r=Qa((t=n).title),o=C(t,{format:r,isSelected:a(r),getPreview:c(r)}),u.formatter.register(r,o),o);var t,r,o,i})};return s(e)},Dd=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return In(n,function(n){return n.items!==undefined?0<o(n.items).length?[n]:[]:!Ot(n,"format")||e.formatter.canApply(n.format)?[n]:[]})})(n),Cd.expand(i));return Td({formats:u,handle:function(n,e){t.undoManager.transact(function(){si.isOn(n)?t.formatter.remove(e):t.formatter.apply(e)}),r()}})},Id=["undo","bold","italic","link","image","bullist","styleselect"],Ad=function(n){var e=n.replace(/\|/g," ").trim();return 0<e.length?e.split(/\s+/):[]},Md=function(n){return In(n,function(n){return y(n)?Md(n):Ad(n)})},Bd=function(n){var e=n.toolbar!==undefined?n.toolbar:Id;return y(e)?Md(e):Ad(e)},Rd=function(r,o){var n=function(n){return function(){return Kc.forToolbarCommand(o,n)}},e=function(n){return function(){return Kc.forToolbarStateCommand(o,n)}},t=function(n,e,t){return function(){return Kc.forToolbarStateAction(o,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(){o.execCommand("unlink",null,!1)}),d=t("unordered-list","ul",function(){o.execCommand("InsertUnorderedList",null,!1)}),m=t("ordered-list","ol",function(){o.execCommand("InsertOrderedList",null,!1)}),g=Ed(o,o.settings),v=function(){return Dd(o,g,function(){o.fire("scrollIntoView")})},p=function(n,e){return{isSupported:function(){return n.forall(function(n){return Ot(o.buttons,n)})},sketch:e}};return{undo:p(V.none(),i),redo:p(V.none(),u),bold:p(V.none(),a),italic:p(V.none(),c),underline:p(V.none(),s),removeformat:p(V.none(),f),link:p(V.none(),function(){return e=r,t=o,Kc.forToolbarStateAction(t,"link","link",function(){var n=il(e,t);e.setContextToolbar(n),wf(t,function(){e.focusToolbar()}),hf.query(t).each(function(n){t.selection.select(n.dom())})});var e,t}),unlink:p(V.none(),l),image:p(V.none(),function(){return lf(o)}),bullist:p(V.some("bullist"),d),numlist:p(V.some("numlist"),m),fontsizeselect:p(V.none(),function(){return e=o,n={onChange:function(n){Hs.apply(e,n)},getInitialValue:function(){return Hs.get(e)}},As(r,"font-size",function(){return js(n)});var e,n}),forecolor:p(V.none(),function(){return Bs(r,o)}),styleselect:p(V.none(),function(){return Kc.forToolbar("style-formats",function(n){o.fire("toReading"),r.dropup().appear(v,si.on,n)},Ur([si.config({toggleClass:gi.resolve("toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),Qo.config({channels:St([di(Oo.orientationChanged(),si.off),di(Oo.dropupDismissed(),si.off)])})]))})}},Fd=function(n,t){var e=Bd(n),r={};return In(e,function(n){var e=!Ot(r,n)&&Ot(t,n)&&t[n].isSupported()?[t[n].sketch()]:[];return r[n]=!0,e})},Vd=function(m,g){return function(n){if(m(n)){var e,t,r,o,i,u,a,c=fe.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,prevent:i,kill:u,raw:A(a)});g(d)}}},Nd=function(n,e,t,r,o){var i=Vd(t,r);return n.dom().addEventListener(e,i,o),{unbind:l(Hd,n,e,i,o)}},Hd=function(n,e,t,r){n.dom().removeEventListener(e,t,r)},zd=A(!0),jd=function(n,e,t){return Nd(n,e,zd,t,!1)},Ld=function(n,e,t){return Nd(n,e,zd,t,!0)},Ud=function(n){var e=n.matchMedia("(orientation: portrait)").matches;return{isPortrait:A(e)}},Pd=Ud,$d=function(r,e){var n=fe.fromDom(r),o=null,t=jd(n,"orientationchange",function(){clearInterval(o);var n=Ud(r);e.onChange(n),i(function(){e.onReady(n)})}),i=function(n){clearInterval(o);var e=r.innerHeight,t=0;o=setInterval(function(){e!==r.innerHeight?(clearInterval(o),n(V.some(r.innerHeight))):20<t&&(clearInterval(o),n(V.none())),t++},50)};return{onAdjustment:i,destroy:function(){t.unbind()}}},Wd=function(n){var e=Wn.detect().os.isiOS(),t=Ud(n).isPortrait();return e&&!t?n.screen.height:n.screen.width},Gd=function(n){var e=n.raw();return e.touches===undefined||1!==e.touches.length?V.none():V.some(e.touches[0])},_d=function(t){var r,o,i,u=lo(V.none()),a=(r=function(n){u.set(V.none()),t.triggerEvent(Zn(),n)},o=400,i=null,{cancel:function(){null!==i&&(p.clearTimeout(i),i=null)},schedule:function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];i=p.setTimeout(function(){r.apply(null,n),i=null},o)}}),c=St([{key:U(),value:function(t){return Gd(t).each(function(n){a.cancel();var e={x:A(n.clientX),y:A(n.clientY),target:t.target};a.schedule(t),u.set(V.some(e))}),V.none()}},{key:P(),value:function(n){return a.cancel(),Gd(n).each(function(i){u.get().each(function(n){var e,t,r,o;e=i,t=n,r=Math.abs(e.clientX-t.x()),o=Math.abs(e.clientY-t.y()),(5<r||5<o)&&u.set(V.none())})}),V.none()}},{key:$(),value:function(e){return a.cancel(),u.get().filter(function(n){return He(n.target(),e.target())}).map(function(n){return t.triggerEvent(Jn(),e)})}}]);return{fireIfReady:function(e,n){return wt(c,n).bind(function(n){return n(e)})}}},qd=function(t){var e=_d({triggerEvent:function(n,e){t.onTapContent(e)}});return{fireTouchstart:function(n){e.fireIfReady(n,"touchstart")},onTouchend:function(){return jd(t.body(),"touchend",function(n){e.fireIfReady(n,"touchend")})},onTouchmove:function(){return jd(t.body(),"touchmove",function(n){e.fireIfReady(n,"touchmove")})}}},Yd=6<=Wn.detect().os.version.major,Kd=function(r,e,t){var o=qd(r),i=ze(e),u=function(n){return!He(n.start(),n.finish())||n.soffset()!==n.foffset()},n=function(){var n=r.doc().dom().hasFocus()&&r.getSelection().exists(u);t.getByDom(e).each(!0===(n||yo(i).filter(function(n){return"input"===ge(n)}).exists(function(n){return n.dom().selectionStart!==n.dom().selectionEnd}))?si.on:si.off)},a=[jd(r.body(),"touchstart",function(n){r.onTouchContent(),o.fireTouchstart(n)}),o.onTouchmove(),o.onTouchend(),jd(e,"touchstart",function(n){r.onTouchToolstrip()}),r.onToReading(function(){bo(r.body())}),r.onToEditing(I),r.onScrollToCursor(function(n){n.preventDefault(),r.getCursorBox().each(function(n){var e=r.win(),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===Yd?[]:[jd(fe.fromDom(r.win()),"blur",function(){t.getByDom(e).each(si.off)}),jd(i,"select",n),jd(r.doc(),"selectionchange",n)]);return{destroy:function(){wn(a,function(n){n.unbind()})}}},Xd=function(n,e){var t=parseInt(Kr(n,e),10);return isNaN(t)?0:t},Jd=(tf=he,rf="text",of=function(n){return tf(n)?V.from(n.dom().nodeValue):V.none()},uf=Wn.detect().browser,{get:function(n){if(!tf(n))throw new Error("Can only get "+rf+" value of a "+rf+" node");return af(n).getOr("")},getOption:af=uf.isIE()&&10===uf.version.major?function(n){try{return of(n)}catch(e){return V.none()}}:of,set:function(n,e){if(!tf(n))throw new Error("Can only set raw "+rf+" value of a "+rf+" node");n.dom().nodeValue=e}}),Qd=function(n){return Jd.getOption(n)},Zd=tt([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),nm={before:Zd.before,on:Zd.on,after:Zd.after,cata:function(n,e,t,r){return n.fold(e,t,r)},getStart:function(n){return n.fold(h,h,h)}},em=tt([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),tm=xe("start","soffset","finish","foffset"),rm=em.relative,om=em.exact,im=function(n,e,t,r){var o,i,u,a,c,s=(i=e,u=t,a=r,(c=ze(o=n).dom().createRange()).setStart(o.dom(),i),c.setEnd(u.dom(),a),c),f=He(n,t)&&e===r;return s.collapsed&&!f},um=function(n,e,t){var r,o,i=n.document.createRange();return r=i,e.fold(function(n){r.setStartBefore(n.dom())},function(n,e){r.setStart(n.dom(),e)},function(n){r.setStartAfter(n.dom())}),o=i,t.fold(function(n){o.setEndBefore(n.dom())},function(n,e){o.setEnd(n.dom(),e)},function(n){o.setEndAfter(n.dom())}),i},am=function(n,e,t,r,o){var i=n.document.createRange();return i.setStart(e.dom(),t),i.setEnd(r.dom(),o),i},cm=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)}},sm=tt([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),fm=function(n,e,t){return e(fe.fromDom(t.startContainer),t.startOffset,fe.fromDom(t.endContainer),t.endOffset)},lm=function(n,e){var o,t,r,i=(o=n,e.match({domRange:function(n){return{ltr:A(n),rtl:V.none}},relative:function(n,e){return{ltr:nn(function(){return um(o,n,e)}),rtl:nn(function(){return V.some(um(o,e,n))})}},exact:function(n,e,t,r){return{ltr:nn(function(){return am(o,n,e,t,r)}),rtl:nn(function(){return V.some(am(o,t,r,n,e))})}}}));return(r=(t=i).ltr()).collapsed?t.rtl().filter(function(n){return!1===n.collapsed}).map(function(n){return sm.rtl(fe.fromDom(n.endContainer),n.endOffset,fe.fromDom(n.startContainer),n.startOffset)}).getOrThunk(function(){return fm(0,sm.ltr,r)}):fm(0,sm.ltr,r)},dm=(document.caretPositionFromPoint||document.caretRangeFromPoint,function(n,e){var t=ge(n);return"input"===t?nm.after(n):bn(["br","img"],t)?0===e?nm.before(n):nm.after(n):nm.on(n,e)}),mm=function(n,e,t,r,o){var i,u,a=am(n,e,t,r,o);i=n,u=a,V.from(i.getSelection()).each(function(n){n.removeAllRanges(),n.addRange(u)})},gm=function(n,e,t,r,o){var i,u,a,c,l,s=(i=r,u=o,a=dm(e,t),c=dm(i,u),rm(a,c));lm(l=n,s).match({ltr:function(n,e,t,r){mm(l,n,e,t,r)},rtl:function(n,e,t,r){var o,i,u,a,c,s=l.getSelection();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){mm(l,t,r,n,e)}else mm(l,t,r,n,e)}})},vm=function(n){var e=fe.fromDom(n.anchorNode),t=fe.fromDom(n.focusNode);return im(e,n.anchorOffset,t,n.focusOffset)?V.some(tm(e,n.anchorOffset,t,n.focusOffset)):function(n){if(0<n.rangeCount){var e=n.getRangeAt(0),t=n.getRangeAt(n.rangeCount-1);return V.some(tm(fe.fromDom(e.startContainer),e.startOffset,fe.fromDom(t.endContainer),t.endOffset))}return V.none()}(n)},pm=function(n){return V.from(n.getSelection()).filter(function(n){return 0<n.rangeCount}).bind(vm)},hm=function(n,e){var i,t,r,o,u=lm(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.dom(),e),o}});return r=(t=u).getClientRects(),0<(o=0<r.length?r[0]:t.getBoundingClientRect()).width||0<o.height?V.some(o).map(cm):V.none()},bm=function(n){return{left:n.left,top:n.top,right:n.right,bottom:n.bottom,width:A(2),height:n.height}},ym=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)}},wm=function(r){if(r.collapsed){var o=fe.fromDom(r.startContainer);return je(o).bind(function(n){var e,t=om(o,r.startOffset,n,"img"===ge(e=n)?1:Qd(e).fold(function(){return Le(e).length},function(n){return n.length}));return hm(r.startContainer.ownerDocument.defaultView,t).map(bm).map(Rn)}).getOr([])}return yn(r.getClientRects(),ym)},xm=function(n){var e=n.getSelection();return e!==undefined&&0<e.rangeCount?wm(e.getRangeAt(0)):[]},Sm=function(n){n.focus();var e=fe.fromDom(n.document.body);(yo().exists(function(n){return bn(["input","textarea"],ge(n))})?function(n){setTimeout(function(){n()},0)}:s)(function(){yo().each(bo),ho(e)})},Tm="data-"+gi.resolve("last-outer-height"),Om=function(n,e){qr(n,Tm,e)},km=function(n){return{top:A(n.top()),bottom:A(n.top()+n.height())}},Cm=function(n,e){var t=Xd(e,Tm),r=n.innerHeight;return r<t?V.some(t-r):V.none()},Em=function(n,u){var e=fe.fromDom(u.document.body),t=jd(fe.fromDom(n),"resize",function(){Cm(n,e).each(function(i){var n,e;(n=u,e=xm(n),0<e.length?V.some(e[0]).map(km):V.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.innerHeight+50):0);0!==o&&u.scrollTo(u.pageXOffset,u.pageYOffset+o)})}),Om(e,n.innerHeight)});return Om(e,n.innerHeight),{toEditing:function(){Sm(u)},destroy:function(){t.unbind()}}},Dm=function(n){return V.some(fe.fromDom(n.dom().contentWindow.document.body))},Im=function(n){return V.some(fe.fromDom(n.dom().contentWindow.document))},Am=function(n){return V.from(n.dom().contentWindow)},Mm=function(n){return Am(n).bind(pm)},Bm=function(n){return n.getFrame()},Rm=function(n,t){return function(e){return e[n].getOrThunk(function(){var n=Bm(e);return function(){return t(n)}})()}},Fm=function(n,e,t,r){return n[t].getOrThunk(function(){return function(n){return jd(e,r,n)}})},Vm=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)}},Nm={getBody:Rm("getBody",Dm),getDoc:Rm("getDoc",Im),getWin:Rm("getWin",Am),getSelection:Rm("getSelection",Mm),getFrame:Bm,getActiveApi:function(a){var c=Bm(a);return Dm(c).bind(function(u){return Im(c).bind(function(i){return Am(c).map(function(o){var n=fe.fromDom(i.dom().documentElement),e=a.getCursorBox.getOrThunk(function(){return function(){return(n=o,pm(n).map(function(n){return om(n.start(),n.soffset(),n.finish(),n.foffset())})).bind(function(n){return hm(o,n).orThunk(function(){return pm(o).filter(function(n){return He(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0<e.width||0<e.height?V.some(e).map(Vm):V.none()})})});var n}}),t=a.setSelection.getOrThunk(function(){return function(n,e,t,r){gm(o,n,e,t,r)}}),r=a.clearSelection.getOrThunk(function(){return function(){o.getSelection().removeAllRanges()}});return{body:A(u),doc:A(i),win:A(o),html:A(n),getSelection:l(Mm,c),setSelection:t,clearSelection:r,frame:A(c),onKeyup:Fm(a,i,"onKeyup","keyup"),onNodeChanged:Fm(a,i,"onNodeChanged","selectionchange"),onDomChanged:a.onDomChanged,onScrollToCursor:a.onScrollToCursor,onScrollToElement:a.onScrollToElement,onToReading:a.onToReading,onToEditing:a.onToEditing,onToolbarScrollStart:a.onToolbarScrollStart,onTouchContent:a.onTouchContent,onTapContent:a.onTapContent,onTouchToolstrip:a.onTouchToolstrip,getCursorBox:e}})})})}},Hm="data-ephox-mobile-fullscreen-style",zm="position:absolute!important;",jm="top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;",Lm=Wn.detect().os.isAndroid(),Um=function(n,e){var t,r,o,i=function(r){return function(n){var e=Kr(n,"style"),t=e===undefined?"no-styles":e.trim();t!==r&&(qr(n,Hm,t),qr(n,"style",r))}},u=(t="*",Fi(n,function(n){return Re(n,t)},r)),a=In(u,function(n){var e;return e="*",Vi(n,function(n){return Re(n,e)})}),c=(o=Oi(e,"background-color"))!==undefined&&""!==o?"background-color:"+o+"!important":"background-color:rgb(255,255,255)!important;";wn(a,i("display:none!important;")),wn(u,i(zm+jm+c)),i((!0===Lm?"":zm)+jm+c)(n)},Pm=function(){var n=Ve("["+Hm+"]");wn(n,function(n){var e=Kr(n,Hm);"no-styles"!==e?qr(n,"style",e):Jr(n,"style"),Jr(n,Hm)})},$m=function(){var e=Hi("head").getOrDie(),n=Hi('meta[name="viewport"]').getOrThunk(function(){var n=fe.fromTag("meta");return qr(n,"name","viewport"),$e(e,n),n}),t=Kr(n,"content");return{maximize:function(){qr(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?qr(n,"content",t):qr(n,"content","user-scalable=yes")}}},Wm=function(e,n){var t=$m(),r=Zf(),o=Zf();return{enter:function(){n.hide(),ro(e.container,gi.resolve("fullscreen-maximized")),ro(e.container,gi.resolve("android-maximized")),t.maximize(),ro(e.body,gi.resolve("android-scroll-reload")),r.set(Em(e.win,Nm.getWin(e.editor).getOrDie("no"))),Nm.getActiveApi(e.editor).each(function(n){Um(e.container,n.body()),o.set(Kd(n,e.toolstrip,e.alloy))})},exit:function(){t.restore(),n.show(),oo(e.container,gi.resolve("fullscreen-maximized")),oo(e.container,gi.resolve("android-maximized")),Pm(),oo(e.body,gi.resolve("android-scroll-reload")),o.clear(),r.clear()}}},Gm=function(t,r){var o=null;return{cancel:function(){null!==o&&(p.clearTimeout(o),o=null)},throttle:function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];null!==o&&p.clearTimeout(o),o=p.setTimeout(function(){t.apply(null,n),o=null},r)}}},_m=function(n,e){var t,r,o,i=Ls(kf.sketch({dom:Gc('<div aria-hidden="true" class="${prefix}-mask-tap-icon"></div>'),containerBehaviours:Ur([si.config({toggleClass:gi.resolve("mask-tap-icon-selected"),toggleOnExecute:!1})])})),u=(t=n,r=200,o=null,{cancel:function(){null!==o&&(p.clearTimeout(o),o=null)},throttle:function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];null===o&&(o=p.setTimeout(function(){t.apply(null,n),o=null},r))}});return kf.sketch({dom:Gc('<div class="${prefix}-disabled-mask"></div>'),components:[kf.sketch({dom:Gc('<div class="${prefix}-content-container"></div>'),components:[Pc.sketch({dom:Gc('<div class="${prefix}-content-tap-section"></div>'),components:[i.asSpec()],action:function(n){u.throttle()},buttonBehaviours:Ur([si.config({toggleClass:gi.resolve("mask-tap-icon-selected")})])})]})]})},qm=Ht([rr("editor",[nr("getFrame"),or("getBody"),or("getDoc"),or("getWin"),or("getSelection"),or("setSelection"),or("clearSelection"),or("cursorSaver"),or("onKeyup"),or("onNodeChanged"),or("getCursorBox"),nr("onDomChanged"),ar("onTouchContent",I),ar("onTapContent",I),ar("onTouchToolstrip",I),ar("onScrollToCursor",A({unbind:I})),ar("onScrollToElement",A({unbind:I})),ar("onToEditing",A({unbind:I})),ar("onToReading",A({unbind:I})),ar("onToolbarScrollStart",h)]),nr("socket"),nr("toolstrip"),nr("dropup"),nr("toolbar"),nr("container"),nr("alloy"),sr("win",function(n){return ze(n.socket).dom().defaultView}),sr("body",function(n){return fe.fromDom(n.socket.dom().ownerDocument.body)}),ar("translate",h),ar("setReadOnly",I),ar("readOnlyOnInit",A(!0))]),Ym=function(n){var e=Yt("Getting AndroidWebapp schema",qm,n);Si(e.toolstrip,"width","100%");var t=zl(_m(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)}};$e(e.container,t.element());var o=Wm(e,r);return{setReadOnly:e.setReadOnly,refreshStructure:I,enter:o.enter,exit:o.exit,destroy:I}},Km=A([ar("shell",!0),Ua("toolbarBehaviours",[rd])]),Xm=A([dc({name:"groups",overrides:function(n){return{behaviours:Ur([rd.config({})])}}})]),Jm=Uc({name:"Toolbar",configFields:Km(),partFields:Xm(),factory:function(e,n,t,r){var o=function(n){return e.shell()?V.some(n):wc(n,e,"groups")},i=e.shell()?{behaviours:[rd.config({})],components:[]}:{behaviours:[],components:n};return{uid:e.uid(),dom:e.dom(),components:i.components,behaviours:C(Ur(i.behaviours),Pa(e.toolbarBehaviours())),apis:{setGroups:function(n,e){o(n).fold(function(){throw p.console.error("Toolbar was defined to not be a shell, but no groups container was specified in components"),new Error("Toolbar was defined to not be a shell, but no groups container was specified in components")},function(n){rd.set(n,e)})}},domModification:{attributes:{role:"group"}}}},apis:{setGroups:function(n,e,t){n.setGroups(e,t)}}}),Qm=A([nr("items"),(cf=["itemClass"],rr("markers",yn(cf,nr))),Ua("tgroupBehaviours",[La])]),Zm=A([mc({name:"items",unit:"item",overrides:function(n){return{domModification:{classes:[n.markers().itemClass()]}}}})]),ng=Uc({name:"ToolbarGroup",configFields:Qm(),partFields:Zm(),factory:function(n,e,t,r){return C({dom:{attributes:{role:"toolbar"}}},{uid:n.uid(),dom:n.dom(),components:e,behaviours:C(Ur([La.config({mode:"flow",selector:"."+n.markers().itemClass()})]),Pa(n.tgroupBehaviours())),"debug.sketcher":t["debug.sketcher"]})}}),eg="data-"+gi.resolve("horizontal-scroll"),tg=function(n){return"true"===Kr(n,eg)?0<(t=n).dom().scrollLeft||function(n){n.dom().scrollLeft=1;var e=0!==n.dom().scrollLeft;return n.dom().scrollLeft=0,e}(t):0<(e=n).dom().scrollTop||function(n){n.dom().scrollTop=1;var e=0!==n.dom().scrollTop;return n.dom().scrollTop=0,e}(e);var e,t},rg={exclusive:function(n,e){return jd(n,"touchmove",function(n){Li(n.target(),e).filter(tg).fold(function(){n.raw().preventDefault()},I)})},markAsHorizontal:function(n){qr(n,eg,"true")}};function og(){var e=function(n){var e=!0===n.scrollable?"${prefix}-toolbar-scrollable-group":"";return{dom:Gc('<div aria-label="'+n.label+'" class="${prefix}-toolbar-group '+e+'"></div>'),tgroupBehaviours:Ur([xf("adhoc-scrollable-toolbar",!0===n.scrollable?[xr(function(n,e){Si(n.element(),"overflow-x","auto"),rg.markAsHorizontal(n.element()),yd.register(n.element())})]:[])]),components:[kf.sketch({components:[ng.parts().items({})]})],markers:{itemClass:gi.resolve("toolbar-group-item")},items:n.items}},t=zl(Jm.sketch({dom:Gc('<div class="${prefix}-toolbar"></div>'),components:[Jm.parts().groups({})],toolbarBehaviours:Ur([si.config({toggleClass:gi.resolve("context-toolbar"),toggleOnExecute:!1,aria:{mode:"none"}}),La.config({mode:"cyclic"})]),shell:!0})),n=zl(kf.sketch({dom:{classes:[gi.resolve("toolstrip")]},components:[jl(t)],containerBehaviours:Ur([si.config({toggleClass:gi.resolve("android-selection-context-toolbar"),toggleOnExecute:!1})])})),r=function(){Jm.setGroups(t,o.get()),si.off(t)},o=lo([]);return{wrapper:A(n),toolbar:A(t),createGroups:function(n){return yn(n,v(ng.sketch,e))},setGroups:function(n){o.set(n),r()},setContextToolbar:function(n){si.on(t),Jm.setGroups(t,n)},restoreToolbar:function(){si.isOn(t)&&r()},refresh:function(){},focus:function(){La.focusIn(t)}}}var ig=function(n,e){rd.append(n,jl(e))},ug=function(n,e){rd.remove(n,e)},ag=function(n){return zl(Pc.sketch({dom:Gc('<div class="${prefix}-mask-edit-icon ${prefix}-icon"></div>'),action:function(){n.run(function(n){n.setReadOnly(!1)})}}))},cg=function(){return zl(kf.sketch({dom:Gc('<div class="${prefix}-editor-socket"></div>'),components:[],containerBehaviours:Ur([rd.config({})])}))},sg=function(n,e,t,r){(!0===t?fo.toAlpha:fo.toOmega)(r),(t?ig:ug)(n,e)},fg=function(e,n){return n.getAnimationRoot().fold(function(){return e.element()},function(n){return n(e)})},lg=function(n){return n.dimension().property()},dg=function(n,e){return n.dimension().getDimension()(e)},mg=function(n,e){var t=fg(n,e);Cl(t,[e.shrinkingClass(),e.growingClass()])},gg=function(n,e){oo(n.element(),e.openClass()),ro(n.element(),e.closedClass()),Si(n.element(),lg(e),"0px"),Di(n.element())},vg=function(n,e){oo(n.element(),e.closedClass()),ro(n.element(),e.openClass()),Ei(n.element(),lg(e))},pg=function(n,e,t){t.setCollapsed(),Si(n.element(),lg(e),dg(e,n.element())),Di(n.element());var r=fg(n,e);ro(r,e.shrinkingClass()),gg(n,e),e.onStartShrink()(n)},hg=function(n,e,t){var r=function(n,e){vg(n,e);var t=dg(e,n.element());return gg(n,e),t}(n,e),o=fg(n,e);ro(o,e.growingClass()),vg(n,e),Si(n.element(),lg(e),r),t.setExpanded(),e.onStartGrow()(n)},bg=function(n,e,t){var r=fg(n,e);return!0===uo(r,e.growingClass())},yg=function(n,e,t){var r=fg(n,e);return!0===uo(r,e.shrinkingClass())},wg=Object.freeze({grow:function(n,e,t){t.isExpanded()||hg(n,e,t)},shrink:function(n,e,t){t.isExpanded()&&pg(n,e,t)},immediateShrink:function(n,e,t){var r,o;t.isExpanded()&&(r=n,o=e,t.setCollapsed(),Si(r.element(),lg(o),dg(o,r.element())),Di(r.element()),mg(r,o),gg(r,o),o.onStartShrink()(r),o.onShrunk()(r))},hasGrown:function(n,e,t){return t.isExpanded()},hasShrunk:function(n,e,t){return t.isCollapsed()},isGrowing:bg,isShrinking:yg,isTransitioning:function(n,e,t){return!0===bg(n,e)||!0===yg(n,e)},toggleGrow:function(n,e,t){(t.isExpanded()?pg:hg)(n,e,t)},disableTransitions:mg}),xg=Object.freeze({exhibit:function(n,e){var t=e.expanded();return Er(t?{classes:[e.openClass()],styles:{}}:{classes:[e.closedClass()],styles:xt(e.dimension().property(),"0px")})},events:function(t,r){return dr([gr(Q(),function(n,e){e.event().raw().propertyName===t.dimension().property()&&(mg(n,t),r.isExpanded()&&Ei(n.element(),t.dimension().property()),(r.isExpanded()?t.onGrown():t.onShrunk())(n))})])}}),Sg=[nr("closedClass"),nr("openClass"),nr("shrinkingClass"),nr("growingClass"),or("getAnimationRoot"),Wo("onShrunk"),Wo("onStartShrink"),Wo("onGrown"),Wo("onStartGrow"),ar("expanded",!1),er("dimension",Jt("property",{width:[Yo("property","width"),Yo("getDimension",function(n){return Es(n)+"px"})],height:[Yo("property","height"),Yo("getDimension",function(n){return Ri(n)+"px"})]}))],Tg=$r({fields:Sg,name:"sliding",active:xg,apis:wg,state:Object.freeze({init:function(n){var e=lo(n.expanded());return Lr({isExpanded:function(){return!0===e.get()},isCollapsed:function(){return!1===e.get()},setCollapsed:l(e.set,!1),setExpanded:l(e.set,!0),readState:function(){return"expanded: "+e.get()}})}})}),Og=function(e,t){var r=zl(kf.sketch({dom:{tag:"div",classes:[gi.resolve("dropup")]},components:[],containerBehaviours:Ur([rd.config({}),Tg.config({closedClass:gi.resolve("dropup-closed"),openClass:gi.resolve("dropup-open"),shrinkingClass:gi.resolve("dropup-shrinking"),growingClass:gi.resolve("dropup-growing"),dimension:{property:"height"},onShrunk:function(n){e(),t(),rd.set(n,[])},onGrown:function(n){e(),t()}}),li(function(n,e){o(I)})])})),o=function(n){p.window.requestAnimationFrame(function(){n(),Tg.shrink(r)})};return{appear:function(n,e,t){!0===Tg.hasShrunk(r)&&!1===Tg.isTransitioning(r)&&p.window.requestAnimationFrame(function(){e(t),rd.set(r,[n()]),Tg.grow(r)})},disappear:o,component:A(r),element:r.element}},kg=Wn.detect().browser.isFirefox(),Cg=Nt([tr("triggerEvent"),tr("broadcastEvent"),ar("stopBackspace",!0)]),Eg=function(e,n){var t,r,o,i,u,a=Yt("Getting GUI events settings",Cg,n),c=Wn.detect().deviceType.isTouch()?["touchstart","touchmove","touchend","gesturestart"]:["mousedown","mouseup","mouseover","mousemove","mouseout","click"],s=_d(a),f=yn(c.concat(["selectstart","input","contextmenu","change","transitionend","drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]),function(n){return jd(e,n,function(e){s.fireIfReady(e,n).each(function(n){n&&e.kill()}),a.triggerEvent(n,e)&&e.kill()})}),l=jd(e,"keydown",function(n){var e;a.triggerEvent("keydown",n)?n.kill():!0!==a.stopBackspace||8!==(e=n).raw().which||bn(["input","textarea"],ge(e.target()))||n.prevent()}),d=(t=e,r=function(n){a.triggerEvent("focusin",n)&&n.kill()},kg?Ld(t,"focus",r):jd(t,"focusin",r)),m=(o=e,i=function(n){a.triggerEvent("focusout",n)&&n.kill(),p.setTimeout(function(){a.triggerEvent(qn(),n)},0)},kg?Ld(o,"blur",i):jd(o,"focusout",i)),g=(u=e.dom().ownerDocument.defaultView,fe.fromDom(u)),v=jd(g,"scroll",function(n){a.broadcastEvent(ee(),n)&&n.kill()});return{unbind:function(){wn(f,function(n){n.unbind()}),l.unbind(),d.unbind(),m.unbind(),v.unbind()}}},Dg=function(n,e){var t=wt(n,"target").map(function(n){return n()}).getOr(e);return lo(t)},Ig=tt([{stopped:[]},{resume:["element"]},{complete:[]}]),Ag=function(n,r,e,t,o,i){var u,a,c,s,f=n(r,t),l=(u=e,a=o,c=lo(!1),s=lo(!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),Ig.complete()},function(e){var t=e.descHandler();return hl(t)(l),l.isStopped()?(i.logEventStopped(r,e.element(),t.purpose()),Ig.stopped()):l.isCut()?(i.logEventCut(r,e.element(),t.purpose()),Ig.complete()):je(e.element()).fold(function(){return i.logNoParent(r,e.element(),t.purpose()),Ig.complete()},function(n){return i.logEventResponse(r,e.element(),t.purpose()),Ig.resume(n)})})},Mg=function(e,t,r,n,o,i){return Ag(e,t,r,n,o,i).fold(function(){return!0},function(n){return Mg(e,t,r,n,o,i)},function(){return!1})},Bg=function(n,e,t){var r,o,i=(r=e,o=lo(!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 wn(n,function(n){var e=n.descHandler();hl(e)(i)}),i.isStopped()},Rg=function(n,e,t,r,o){var i=Dg(t,r);return Mg(n,e,t,r,i,o)},Fg=function(n,e,t){return vo(n,function(n){return e(n).isSome()},t).bind(e)},Vg=xe("element","descHandler"),Ng=function(n,e){return{id:A(n),descHandler:A(e)}};function Hg(){var i={};return{registerId:function(r,o,n){H(n,function(n,e){var t=i[e]!==undefined?i[e]:{};t[o]=pl(n,r),i[e]=t})},unregisterId:function(t){H(i,function(n,e){n.hasOwnProperty(t)&&delete n[t]})},filterByType:function(n){return wt(i,n).map(function(n){return L(n,function(n,e){return Ng(e,n)})}).getOr([])},find:function(n,e,t){var o=bt(e)(i);return Fg(t,function(n){return t=o,Rc(r=n).fold(function(){return V.none()},function(n){var e=bt(n);return t.bind(e).map(function(n){return Vg(r,n)})});var t,r},n)}}}function zg(){var r=Hg(),o={},i=function(r){var n=r.element();return Rc(n).fold(function(){return n="uid-",e=r.element(),t=Qa(Mc+n),qr(e,Bc,t),t;var n,e,t},function(n){return n})},u=function(n){Rc(n.element()).each(function(n){o[n]=undefined,r.unregisterId(n)})};return{find:function(n,e,t){return r.find(n,e,t)},filter:function(n){return r.filterByType(n)},register:function(n){var e=i(n);Ot(o,e)&&function(n,e){var t=o[e];if(t!==n)throw new Error('The tagId "'+e+'" is already used by: '+Io(t.element())+"\nCannot use it for: "+Io(n.element())+"\nThe conflicting element is"+(be(t.element())?" ":" not ")+"already in the DOM");u(n)}(n,e);var t=[n];r.registerId(t,e,n.events()),o[e]=n},unregister:u,getById:function(n){return bt(n)(o)}}}var jg=function(t){var r=function(e){return je(t.element()).fold(function(){return!0},function(n){return He(e,n)})},o=zg(),s=function(n,e){return o.find(r,n,e)},n=Eg(t.element(),{triggerEvent:function(u,a){return zo(u,a.target(),function(n){return e=s,t=u,o=n,i=(r=a).target(),Rg(e,t,r,i,o);var e,t,r,o,i})},broadcastEvent:function(n,e){var t=o.filter(n);return Bg(t,e)}}),i=fl({debugInfo:A("real"),triggerEvent:function(e,t,r){zo(e,t,function(n){Rg(s,e,r,t,n)})},triggerFocus:function(a,c){Rc(a).fold(function(){ho(a)},function(n){zo(_n(),a,function(n){var e,t,r,o,i,u;e=s,t=_n(),r={originator:A(c),kill:I,prevent:I,target:A(a)},i=n,u=Dg(r,o=a),Ag(e,t,r,o,u,i)})})},triggerEscape:function(n,e){i.triggerEvent("keydown",n.element(),e.event())},getByUid:function(n){return m(n)},getByDom:function(n){return g(n)},build:zl,addToGui:function(n){a(n)},removeFromGui:function(n){c(n)},addToWorld:function(n){e(n)},removeFromWorld:function(n){u(n)},broadcast:function(n){l(n)},broadcastOn:function(n,e){d(n,e)},isConnected:A(!0)}),e=function(n){n.connect(i),he(n.element())||(o.register(n),wn(n.components(),e),i.triggerEvent(ne(),n.element(),{target:A(n.element())}))},u=function(n){he(n.element())||(wn(n.components(),u),o.unregister(n)),n.disconnect()},a=function(n){Ke(t,n)},c=function(n){Qe(n)},f=function(t){var n=o.filter(Yn());wn(n,function(n){var e=n.descHandler();hl(e)(t)})},l=function(n){f({universal:A(!0),data:A(n)})},d=function(n,e){f({universal:A(!1),channels:A(n),data:A(e)})},m=function(n){return o.getById(n).fold(function(){return et.error(new Error('Could not find component with uid: "'+n+'" in system.'))},et.value)},g=function(n){var e=Rc(n).getOr("not found");return m(e)};return e(t),{root:A(t),element:t.element,destroy:function(){n.unbind(),_e(t.element())},add:a,remove:c,getByUid:m,getByDom:g,addToWorld:e,removeFromWorld:u,broadcast:l,broadcastOn:d}},Lg=A(gi.resolve("readonly-mode")),Ug=A(gi.resolve("edit-mode"));function Pg(n){var e=zl(kf.sketch({dom:{classes:[gi.resolve("outer-container")].concat(n.classes)},containerBehaviours:Ur([fo.config({alpha:Lg(),omega:Ug()})])}));return jg(e)}var $g=function(n,e){var t=fe.fromTag("input");Ti(t,{opacity:"0",position:"absolute",top:"-1000px",left:"-1000px"}),$e(n,t),ho(t),e(t),_e(t)},Wg=function(n){var e=n.getSelection();if(0<e.rangeCount){var t=e.getRangeAt(0),r=n.document.createRange();r.setStart(t.startContainer,t.startOffset),r.setEnd(t.endContainer,t.endOffset),e.removeAllRanges(),e.addRange(r)}},Gg=function(n,e){yo().each(function(n){He(n,e)||bo(n)}),n.focus(),ho(fe.fromDom(n.document.body)),Wg(n)},_g={stubborn:function(n,e,t,r){var o=function(){Gg(e,r)},i=jd(t,"keydown",function(n){bn(["input","textarea"],ge(n.target()))||o()});return{toReading:function(){$g(n,bo)},toEditing:o,onToolbarTouch:function(){},destroy:function(){i.unbind()}}},timid:function(n,e,t,r){var o=function(){bo(r)};return{toReading:function(){o()},toEditing:function(){Gg(e,r)},onToolbarTouch:function(){o()},destroy:I}}},qg=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=function(){r.run(function(n){n.clearSelection()})},c=function(){t.getCursorBox().each(function(n){e(n.top(),n.height())}),r.run(function(n){n.syncHeight()})},s=qd(t),f=Gm(c,300),l=[t.onKeyup(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(r,i)}),t.onToEditing(function(){r.run(function(n){n.toEditing()})}),t.onToReading(function(){r.run(function(n){n.toReading()})}),jd(t.doc(),"touchend",function(n){He(t.html(),n.target())||He(t.body(),n.target())}),jd(o,"transitionend",function(n){var e;"height"===n.raw().propertyName&&(e=Ri(o),r.run(function(n){n.setViewportOffset(e)}),u(),c())}),Ld(o,"touchstart",function(n){var e;r.run(function(n){n.highlightSelection()}),e=n,r.run(function(n){n.onToolbarTouch(e)}),t.onTouchToolstrip()}),jd(t.body(),"touchstart",function(n){a(),t.onTouchContent(),s.fireTouchstart(n)}),s.onTouchmove(),s.onTouchend(),jd(t.body(),"click",function(n){n.kill()}),jd(o,"touchmove",function(){t.onToolbarScrollStart()})];return{destroy:function(){wn(l,function(n){n.unbind()})}}},Yg=function(n){var t=V.none(),e=[],r=function(n){o()?u(n):e.push(n)},o=function(){return t.isSome()},i=function(n){wn(n,u)},u=function(e){t.each(function(n){p.setTimeout(function(){e(n)},0)})};return n(function(n){t=V.some(n),i(e),e=[]}),{get:r,map:function(t){return Yg(function(e){r(function(n){e(t(n))})})},isReady:o}},Kg={nu:Yg,pure:function(e){return Yg(function(n){n(e)})}},Xg=function(e){var n=function(n){var r;e((r=n,function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=this;p.setTimeout(function(){r.apply(t,n)},0)}))},t=function(){return Kg.nu(n)};return{map:function(r){return Xg(function(t){n(function(n){var e=r(n);t(e)})})},bind:function(t){return Xg(function(e){n(function(n){t(n).get(e)})})},anonBind:function(t){return Xg(function(e){n(function(n){t.get(e)})})},toLazy:t,toCached:function(){var e=null;return Xg(function(n){null===e&&(e=t()),e.get(n)})},get:n}},Jg={nu:Xg,pure:function(e){return Xg(function(n){n(e)})}},Qg=function(n,e,t){return Math.abs(n-e)<=t?V.none():n<e?V.some(n+t):V.some(n-t)},Zg=function(){var s=null;return{animate:function(r,o,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=r();Qg(t,o,n).fold(function(){clearInterval(s),a(o)},function(n){if(i(n,c),!u){var e=r();(e!==n||Math.abs(e-o)>Math.abs(t-o))&&(clearInterval(s),a(o))}})},t)}}},nv=function(e,t){return Bo([{width:320,height:480,keyboard:{portrait:300,landscape:240}},{width:320,height:568,keyboard:{portrait:300,landscape:240}},{width:375,height:667,keyboard:{portrait:305,landscape:240}},{width:414,height:736,keyboard:{portrait:320,landscape:240}},{width:768,height:1024,keyboard:{portrait:320,landscape:400}},{width:1024,height:1366,keyboard:{portrait:380,landscape:460}}],function(n){return e<=n.width&&t<=n.height?V.some(n.keyboard):V.none()}).getOr({portrait:t/5,landscape:e/4})},ev=function(n){var e,t=Pd(n).isPortrait(),r=nv((e=n).screen.width,e.screen.height),o=t?r.portrait:r.landscape;return(t?n.screen.height:n.screen.width)-n.innerHeight>o?0:o},tv=function(n,e){var t=ze(n).dom().defaultView;return Ri(n)+Ri(e)-ev(t)},rv=tv,ov=function(n,e,t){var r=tv(e,t),o=Ri(e)+Ri(t)-r;Si(n,"padding-bottom",o+"px")},iv=tt([{fixed:["element","property","offsetY"]},{scroller:["element","offsetY"]}]),uv="data-"+gi.resolve("position-y-fixed"),av="data-"+gi.resolve("y-property"),cv="data-"+gi.resolve("scrolling"),sv="data-"+gi.resolve("last-window-height"),fv=function(n){return Xd(n,uv)},lv=function(n,e){var t=Kr(n,av);return iv.fixed(n,t,e)},dv=function(n,e){return iv.scroller(n,e)},mv=function(n){var e=fv(n);return("true"===Kr(n,cv)?dv:lv)(n,e)},gv=function(n,e,t){var r=ze(n).dom().defaultView.innerHeight;return qr(n,sv,r+"px"),r-e-t},vv=function(n){var e=Ni(n,"["+uv+"]");return yn(e,mv)},pv=function(r,o,i,u){var n,e,t,a,c,s,f,l,d=ze(r).dom().defaultView,m=(l=Kr(f=i,"style"),Ti(f,{position:"absolute",top:"0px"}),qr(f,uv,"0px"),qr(f,av,"top"),{restore:function(){qr(f,"style",l||""),Jr(f,uv),Jr(f,av)}}),g=Ri(i),v=Ri(u),p=gv(r,g,v),h=(t=g,a=p,s=Kr(c=r,"style"),yd.register(c),Ti(c,{position:"absolute",height:a+"px",width:"100%",top:t+"px"}),qr(c,uv,t+"px"),qr(c,cv,"true"),qr(c,av,"top"),{restore:function(){yd.deregister(c),qr(c,"style",s||""),Jr(c,uv),Jr(c,cv),Jr(c,av)}}),b=(e=Kr(n=u,"style"),Ti(n,{position:"absolute",bottom:"0px"}),qr(n,uv,"0px"),qr(n,av,"bottom"),{restore:function(){qr(n,"style",e||""),Jr(n,uv),Jr(n,av)}}),y=!0,w=function(){var n=d.innerHeight;return Xd(r,sv)<n},x=function(){if(y){var n=Ri(i),e=Ri(u),t=gv(r,n,e);qr(r,uv,n+"px"),Si(r,"height",t+"px"),Si(u,"bottom",-(n+t+e)+"px"),ov(o,r,u)}};return ov(o,r,u),{setViewportOffset:function(n){qr(r,uv,n+"px"),x()},isExpanding:w,isShrinking:S(w),refresh:x,restore:function(){y=!1,m.restore(),h.restore(),b.restore()}}},hv=fv,bv=Zg(),yv="data-"+gi.resolve("last-scroll-top"),wv=function(n){var e=Ci(n,"top").getOr("0");return parseInt(e,10)},xv=function(n){return parseInt(n.dom().scrollTop,10)},Sv=function(n,e){var t=e+hv(n)+"px";Si(n,"top",t)},Tv=function(t,r,o){return Jg.nu(function(n){var e=l(xv,t);bv.animate(e,r,15,function(n){t.dom().scrollTop=n,Si(t,"top",wv(t)+15+"px")},function(){t.dom().scrollTop=r,Si(t,"top",o+"px"),n(r)},10)})},Ov=function(o,i){return Jg.nu(function(n){var e=l(xv,o);qr(o,yv,e());var t=Math.abs(i-e()),r=Math.ceil(t/10);bv.animate(e,i,r,function(n,e){Xd(o,yv)!==o.dom().scrollTop?e(o.dom().scrollTop):(o.dom().scrollTop=n,qr(o,yv,n))},function(){o.dom().scrollTop=i,qr(o,yv,i),n(i)},10)})},kv=function(i,u){return Jg.nu(function(n){var e=l(wv,i),t=function(n){Si(i,"top",n+"px")},r=Math.abs(u-e()),o=Math.ceil(r/10);bv.animate(e,u,o,t,function(){t(u),n(u)},10)})},Cv=function(e,t,r){var o=ze(e).dom().defaultView;return Jg.nu(function(n){Sv(e,r),Sv(t,r),o.scrollTo(0,r),n(r)})},Ev=function(n,e,t,r,o){var i=rv(e,t),u=l(Wg,n);i<r||i<o?Ov(e,e.dom().scrollTop-i+o).get(u):r<0&&Ov(e,e.dom().scrollTop+r).get(u)},Dv=function(u,n){return n(function(r){var o=[],i=0;0===u.length?r([]):wn(u,function(n,e){var t;n.get((t=e,function(n){o[t]=n,++i>=u.length&&r(o)}))})})},Iv=function(n,c){return n.fold(function(n,e,t){return Si(n,e,c+(r=t)+"px"),Jg.pure(r);var r},function(n,e){return o=c+(r=e),i=Ci(t=n,"top").getOr(r),u=o-parseInt(i,10),a=t.dom().scrollTop+u,Tv(t,a,o);var t,r,o,i,u,a})},Av=function(n,e){var t=vv(n),r=yn(t,function(n){return Iv(n,e)});return Dv(r,Jg.nu)},Mv=function(e,t,n,r,o,i){var u,a,c=(u=function(n){return Cv(e,t,n)},a=lo(Kg.pure({})),{start:function(e){var n=Kg.nu(function(n){return u(e).get(n)});a.set(n)},idle:function(n){a.get().get(function(){n()})}}),s=Gm(function(){c.idle(function(){Av(n,r.pageYOffset).get(function(){var n;(n=xm(i),V.from(n[0]).bind(function(n){var e=n.top()-t.dom().scrollTop;return e>r.innerHeight+5||e<-5?V.some({top:A(e),bottom:A(e+n.height())}):V.none()})).each(function(n){t.dom().scrollTop=t.dom().scrollTop+n.top()}),c.start(0),o.refresh()})})},1e3),f=jd(fe.fromDom(r),"scroll",function(){r.pageYOffset<0||s.throttle()});return Av(n,r.pageYOffset).get(h),{unbind:f.unbind}},Bv=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=pv(r,e,o,s),l=a(n.outerBody(),t,ye(),u,o,i),d=$d(c,{onChange:I,onReady:f.refresh});d.onAdjustment(function(){f.refresh()});var m=jd(fe.fromDom(c),"resize",function(){f.isExpanding()&&f.refresh()}),g=Mv(o,r,n.outerBody(),c,f,t),v=function(t,e){var n=t.document,r=fe.fromTag("div");ro(r,gi.resolve("unfocused-selections")),$e(fe.fromDom(n.documentElement),r);var o=jd(r,"touchstart",function(n){n.prevent(),Gg(t,e),u()}),i=function(n){var e=fe.fromTag("span");return kl(e,[gi.resolve("layer-editor"),gi.resolve("unfocused-selection")]),Ti(e,{left:n.left()+"px",top:n.top()+"px",width:n.width()+"px",height:n.height()+"px"}),e},u=function(){Ge(r)};return{update:function(){u();var n=xm(t),e=yn(n,i);We(r,e)},isActive:function(){return 0<Le(r).length},destroy:function(){o.unbind(),_e(r)},clear:u}}(t,u),p=function(){v.clear()};return{toEditing:function(){l.toEditing(),p()},toReading:function(){l.toReading()},onToolbarTouch:function(n){l.onToolbarTouch(n)},refreshSelection:function(){v.isActive()&&v.update()},clearSelection:p,highlightSelection:function(){v.update()},scrollIntoView:function(n,e){Ev(t,r,s,n,e)},updateToolbarPadding:I,setViewportOffset:function(n){f.setViewportOffset(n),kv(r,n).get(h)},syncHeight:function(){Si(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(),$g(ye(),bo)}}},Rv=function(r,n){var o=$m(),i=nl(),u=nl(),a=Zf(),c=Zf();return{enter:function(){n.hide();var t=fe.fromDom(p.document);Nm.getActiveApi(r.editor).each(function(n){i.set({socketHeight:Ci(r.socket,"height"),iframeHeight:Ci(n.frame(),"height"),outerScroll:p.document.body.scrollTop}),u.set({exclusives:rg.exclusive(t,"."+yd.scrollable())}),ro(r.container,gi.resolve("fullscreen-maximized")),Um(r.container,n.body()),o.maximize(),Si(r.socket,"overflow","scroll"),Si(r.socket,"-webkit-overflow-scrolling","touch"),ho(n.body());var e=Ee(["cWin","ceBody","socket","toolstrip","toolbar","dropup","contentElement","cursor","keyboardType","isScrolling","outerWindow","outerBody"],[]);a.set(Bv(e({cWin:n.win(),ceBody:n.body(),socket:r.socket,toolstrip:r.toolstrip,toolbar:r.toolbar,dropup:r.dropup.element(),contentElement:n.frame(),cursor:I,outerBody:r.body,outerWindow:r.win,keyboardType:_g.stubborn,isScrolling:function(){return u.get().exists(function(n){return n.socket.isScrolling()})}}))),a.run(function(n){n.syncHeight()}),c.set(qg(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){Si(r.socket,"height",n)}),n.iframeHeight.each(function(n){Si(r.editor.getFrame(),"height",n)}),p.document.body.scrollTop=n.scrollTop}),i.clear(),u.on(function(n){n.exclusives.unbind()}),u.clear(),oo(r.container,gi.resolve("fullscreen-maximized")),Pm(),yd.deregister(r.toolbar),Ei(r.socket,"overflow"),Ei(r.socket,"-webkit-overflow-scrolling"),bo(r.editor.getFrame()),Nm.getActiveApi(r.editor).each(function(n){n.clearSelection()})}}},Fv=function(n){var e=Yt("Getting IosWebapp schema",qm,n);Si(e.toolstrip,"width","100%"),Si(e.container,"position","relative");var t=zl(_m(function(){e.setReadOnly(e.readOnlyOnInit()),r.enter()},e.translate));e.alloy.add(t);var r=Rv(e,{show:function(){e.alloy.add(t)},hide:function(){e.alloy.remove(t)}});return{setReadOnly:e.setReadOnly,refreshStructure:r.refreshStructure,enter:r.enter,exit:r.exit,destroy:I}},Vv=tinymce.util.Tools.resolve("tinymce.EditorManager"),Nv=function(n){var e=wt(n.settings,"skin_url").fold(function(){return Vv.baseURL+"/skins/lightgray"},function(n){return n});return{content:e+"/content.mobile.min.css",ui:e+"/skin.mobile.min.css"}},Hv=function(n,e,t){n.system().broadcastOn([Oo.formatChanged()],{command:e,state:t})},zv=function(r,n){var e=N(n.formatter.get());wn(e,function(e){n.formatter.formatChanged(e,function(n){Hv(r,e,n)})}),wn(["ul","ol"],function(t){n.selection.selectorChanged(t,function(n,e){Hv(r,t,n)})})},jv=(A(["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)}}),Lv=A("toReading"),Uv=A("toEditing");So.add("mobile",function(D){return{getNotificationManagerImpl:function(){return{open:A({progressBar:{value:I},close:I}),close:I,reposition:I,getArgs:h}},renderUI:function(n){var e=Nv(D);0==(!1===D.settings.skin)?(D.contentCSS.push(e.content),xo.DOM.styleSheetLoader.load(e.ui,jv(D))):jv(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=fe.fromTag("div"),x=Wn.detect().os.isAndroid()?(s=y,f=Pg({classes:[gi.resolve("android-container")]}),l=og(),d=Zf(),m=ag(d),g=cg(),v=Og(I,s),f.add(l.wrapper()),f.add(g),f.add(v.component()),{system:A(f),element:f.element,init:function(n){d.set(Ym(n))},exit:function(){d.run(function(n){n.exit(),rd.remove(g,m)})},setToolbarGroups:function(n){var e=l.createGroups(n);l.setGroups(e)},setContextToolbar:function(n){var e=l.createGroups(n);l.setContextToolbar(e)},focusToolbar:function(){l.focus()},restoreToolbar:function(){l.restoreToolbar()},updateMode:function(n){sg(g,m,n,f.root())},socket:A(g),dropup:A(v)}):(t=y,r=Pg({classes:[gi.resolve("ios-container")]}),o=og(),i=Zf(),u=ag(i),a=cg(),c=Og(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:function(n){i.set(Fv(n))},exit:function(){i.run(function(n){rd.remove(a,u),n.exit()})},setToolbarGroups:function(n){var e=o.createGroups(n);o.setGroups(e)},setContextToolbar:function(n){var e=o.createGroups(n);o.setContextToolbar(e)},focusToolbar:function(){o.focus()},restoreToolbar:function(){o.restoreToolbar()},updateMode:function(n){sg(a,u,n,r.root())},socket:A(a),dropup:A(c)}),S=fe.fromDom(n.targetNode);xe("element","offset"),h=w,(b=(p=S).dom(),V.from(b.nextSibling).map(fe.fromDom)).fold(function(){je(p).each(function(n){$e(n,h)})},function(n){var e,t;t=h,je(e=n).each(function(n){n.dom().insertBefore(t.dom(),e.dom())})}),function(n,e){$e(n,e.element());var t=Le(e.element());wn(t,function(n){e.getByDom(n).each(Ye)})}(w,x.system());var T=n.targetNode.ownerDocument.defaultView,O=$d(T,{onChange:function(){x.system().broadcastOn([Oo.orientationChanged()],{width:Wd(T)})},onReady:I}),k=function(n,e,t,r){!1===r&&D.selection.collapse();var o=C(n,e,t);x.setToolbarGroups(!0===r?o.readOnly:o.main),D.setMode(!0===r?"readonly":"design"),D.fire(!0===r?Lv():Uv()),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=function(n,e){return D.on(n,e),{unbind:function(){D.off(n)}}};return D.on("init",function(){x.init({editor:{getFrame:function(){return fe.fromDom(D.contentAreaContainer.querySelector("iframe"))},onDomChanged:function(){return{unbind:I}},onToReading:function(n){return E(Lv(),n)},onToEditing:function(n){return E(Uv(),n)},onScrollToCursor:function(e){return D.on("scrollIntoView",function(n){e(n)}),{unbind:function(){D.off("scrollIntoView"),O.destroy()}}},onTouchToolstrip:function(){t()},onTouchContent:function(){var n,e=fe.fromDom(D.editorContainer.querySelector("."+gi.resolve("toolbar")));(n=e,wo(n).bind(function(n){return x.system().getByDom(n).toOption()})).each(ue),x.restoreToolbar(),t()},onTapContent:function(n){var e=n.target();"img"===ge(e)?(D.selection.select(e.dom()),n.kill()):"a"===ge(e)&&x.system().getByDom(fe.fromDom(D.editorContainer)).each(function(n){fo.isAlpha(n)&&To(e.dom())})}},container:fe.fromDom(D.editorContainer),socket:fe.fromDom(D.contentAreaContainer),toolstrip:fe.fromDom(D.editorContainer.querySelector("."+gi.resolve("toolstrip"))),toolbar:fe.fromDom(D.editorContainer.querySelector("."+gi.resolve("toolbar"))),dropup:x.dropup(),alloy:x.system(),translate:I,setReadOnly:function(n){k(c,a,u,n)},readOnlyOnInit:function(){return!1}});var t=function(){x.dropup().disappear(function(){x.system().broadcastOn([Oo.dropupDismissed()],{})})},n={label:"The first group",scrollable:!1,items:[Kc.forToolbar("back",function(){D.selection.collapse(),x.exit()},{})]},e={label:"Back to read only",scrollable:!1,items:[Kc.forToolbar("readonly-back",function(){k(c,a,u,!0)},{})]},r=Rd(x,D),o=Fd(D.settings,r),i={label:"The extra group",scrollable:!1,items:[]},u=lo([{label:"the action group",scrollable:!0,items:o},i]),a=lo([{label:"The read only mode group",scrollable:!0,items:[]},i]),c=lo({backToMask:[n],backToReadOnly:[e]});zv(x,D)}),D.on("remove",function(){x.exit()}),D.on("detach",function(){var e,n;e=x.system(),n=Le(e.element()),wn(n,function(n){e.getByDom(n).each(qe)}),_e(e.element()),x.system().destroy(),_e(w)}),{iframeContainer:x.socket().element().dom(),editorContainer:x.element().dom()}}}})}(window); |