Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/assets/js/lib/content-tools/content-tools.min.js

7 lines
177 KiB
JavaScript
Raw Normal View History

2018-10-16 16:28:42 +00:00
/*! ContentTools v1.6.9 by Anthony Blackshaw <ant@getme.co.uk> (https://github.com/anthonyjb) */
(function(){var a;a={},a.Machine=function(){function a(a){this.context=a,this._stateTransitions={},this._stateTransitionsAny={},this._defaultTransition=null,this._initialState=null,this._currentState=null}return a.prototype.addTransition=function(a,b,c,d){return c||(c=b),this._stateTransitions[[a,b]]=[c,d]},a.prototype.addTransitions=function(a,b,c,d){var e,f,g,h;for(c||(c=b),h=[],f=0,g=a.length;f<g;f++)e=a[f],h.push(this.addTransition(e,b,c,d));return h},a.prototype.addTransitionAny=function(a,b,c){return b||(b=a),this._stateTransitionsAny[a]=[b,c]},a.prototype.setDefaultTransition=function(a,b){return this._defaultTransition=[a,b]},a.prototype.getTransition=function(a,b){if(this._stateTransitions[[a,b]])return this._stateTransitions[[a,b]];if(this._stateTransitionsAny[b])return this._stateTransitionsAny[b];if(this._defaultTransition)return this._defaultTransition;throw new Error("Transition is undefined: ("+a+", "+b+")")},a.prototype.getCurrentState=function(){return this._currentState},a.prototype.setInitialState=function(a){if(this._initialState=a,!this._currentState)return this.reset()},a.prototype.reset=function(){return this._currentState=this._initialState},a.prototype.process=function(a){var b;return b=this.getTransition(a,this._currentState),b[1]&&b[1].call(this.context||(this.context=this),a),this._currentState=b[0]},a}(),"undefined"!=typeof window&&(window.FSM=a),"undefined"!=typeof module&&module.exports&&(module.exports=a)}).call(this),function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A=[].slice,B=[].indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1};r={},"undefined"!=typeof window&&(window.HTMLString=r),"undefined"!=typeof module&&module.exports&&(module.exports=r),r.String=function(){function a(a,b){null==b&&(b=!1),this._preserveWhitespace=b,a?(null===r.String._parser&&(r.String._parser=new z),this.characters=r.String._parser.parse(a,this._preserveWhitespace).characters):this.characters=[]}return a._parser=null,a.prototype.isWhitespace=function(){var a,b,c,d;for(d=this.characters,b=0,c=d.length;b<c;b++)if(a=d[b],!a.isWhitespace())return!1;return!0},a.prototype.length=function(){return this.characters.length},a.prototype.preserveWhitespace=function(){return this._preserveWhitespace},a.prototype.capitalize=function(){var a,b;return b=this.copy(),b.length()&&(a=b.characters[0]._c.toUpperCase(),b.characters[0]._c=a),b},a.prototype.charAt=function(a){return this.characters[a].copy()},a.prototype.concat=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;for(g=2<=arguments.length?A.call(arguments,0,i=arguments.length-1):(i=0,[]),c=arguments[i++],void 0!==c&&"boolean"!=typeof c&&(g.push(c),c=!0),e=this.copy(),j=0,m=g.length;j<m;j++)if(f=g[j],0!==f.length){if(h=f,"string"==typeof f&&(h=new r.String(f,this._preserveWhitespace)),c&&e.length())for(b=e.charAt(e.length()-1),d=b.tags(),b.isTag()&&d.shift(),"string"!=typeof f&&(h=h.copy()),p=h.characters,k=0,n=p.length;k<n;k++)a=p[k],a.addTags.apply(a,d);for(q=h.characters,l=0,o=q.length;l<o;l++)a=q[l],e.characters.push(a)}return e},a.prototype.contains=function(a){var b,c,d,e,f,g,h;if("string"==typeof a)return this.text().indexOf(a)>-1;for(d=0;d<=this.length()-a.length();){for(c=!0,h=a.characters,e=f=0,g=h.length;f<g;e=++f)if(b=h[e],!b.eq(this.characters[e+d])){c=!1;break}if(c)return!0;d++}return!1},a.prototype.endsWith=function(a){var b,c,d,e,f,g;if("string"==typeof a)return""===a||this.text().slice(-a.length)===a;for(c=this.characters.slice().reverse(),g=a.characters.slice().reverse(),d=e=0,f=g.length;e<f;d=++e)if(b=g[d],!b.eq(c[d]))return!1;return!0},a.prototype.format=function(){var a,b,c,d,e,f,g;for(b=arguments[0],f=arguments[1],e=3<=arguments.length?A.call(arguments,2):[],f<0&&(f=this.length()+f+1),b<0&&(b=this.length()+b),d=this.copy(),c=g=b;b<=f?g<f:g>f;c=b<=f?++g:--g)a=d.characters[c],a.addTags.apply(a,e);return d},a.prototype.hasTags=function(){var a,b,c,d,e,f,g,h;for(d=2<=arguments.length?A.call(arguments,0,e=arguments.length-1):(e=0,[]),c=arguments[e++],void 0!==c&&"boolean"!=typeof c&&(d.push(
c.prototype.hasCSSClass=function(a){var b,c;return!!(this.attr("class")&&(c=function(){var a,c,d,e;for(d=this.attr("class").split(" "),e=[],a=0,c=d.length;a<c;a++)b=d[a],e.push(b);return e}.call(this),c.indexOf(a)>-1))},c.prototype.merge=function(a){return!(!this.can("merge")||!this.can("remove"))&&(this.constructor.mergers[a.type()]?this.constructor.mergers[a.type()](a,this):a.constructor.mergers[this.type()]?a.constructor.mergers[this.type()](a,this):void 0)},c.prototype.mount=function(){var b;return this._domElement||(this._domElement=document.createElement(this.tagName())),b=this.nextSibling(),b?this.parent().domElement().insertBefore(this._domElement,b.domElement()):this.isFixed()?(this.parent().domElement().parentNode.replaceChild(this._domElement,this.parent().domElement()),this.parent()._domElement=this._domElement):this.parent().domElement().appendChild(this._domElement),this._addDOMEventListeners(),this._addCSSClass("ce-element"),this._addCSSClass("ce-element--type-"+this.cssTypeName()),this.isFocused()&&this._addCSSClass("ce-element--focused"),a.Root.get().trigger("mount",this)},c.prototype.removeAttr=function(a){if(a=a.toLowerCase(),this._attributes[a])return delete this._attributes[a],this.isMounted()&&"class"!==a.toLowerCase()&&this._domElement.removeAttribute(a),this.taint()},c.prototype.removeCSSClass=function(a){var b,c,d;if(this.hasCSSClass(a))return d=function(){var a,c,d,e;for(d=this.attr("class").split(" "),e=[],a=0,c=d.length;a<c;a++)b=d[a],e.push(b);return e}.call(this),c=d.indexOf(a),c>-1&&d.splice(c,1),d.length?this.attr("class",d.join(" ")):this.removeAttr("class"),this._removeCSSClass(a),this.taint()},c.prototype.tagName=function(a){return void 0===a?this._tagName:(this._tagName=a.toLowerCase(),this.isMounted()&&(this.unmount(),this.mount()),this.taint())},c.prototype.unmount=function(){return this._removeDOMEventListeners(),this.isFixed()?(this._removeCSSClass("ce-element"),this._removeCSSClass("ce-element--type-"+this.cssTypeName()),void this._removeCSSClass("ce-element--focused")):(this._domElement.parentNode&&this._domElement.parentNode.removeChild(this._domElement),this._domElement=null,a.Root.get().trigger("unmount",this))},c.prototype._addDOMEventListeners=function(){var a,b,c,d;this._domEventHandlers={dragstart:function(a){return function(a){return a.preventDefault()}}(),focus:function(a){return function(a){return a.preventDefault()}}(),keydown:function(a){return function(b){return a._onKeyDown(b)}}(this),keyup:function(a){return function(b){return a._onKeyUp(b)}}(this),mousedown:function(a){return function(b){if(0===b.button)return a._onMouseDown(b)}}(this),mousemove:function(a){return function(b){return a._onMouseMove(b)}}(this),mouseover:function(a){return function(b){return a._onMouseOver(b)}}(this),mouseout:function(a){return function(b){return a._onMouseOut(b)}}(this),mouseup:function(a){return function(b){if(0===b.button)return a._onMouseUp(b)}}(this),dragover:function(a){return function(a){return a.preventDefault()}}(),drop:function(a){return function(b){return a._onNativeDrop(b)}}(this),paste:function(a){return function(b){return a._onPaste(b)}}(this)},c=this._domEventHandlers,d=[];for(b in c)a=c[b],d.push(this._domElement.addEventListener(b,a));return d},c.prototype._onKeyDown=function(a){},c.prototype._onKeyUp=function(a){},c.prototype._onMouseDown=function(a){if(this.focus)return this.focus(!0)},c.prototype._onMouseMove=function(a){return this._onOver(a)},c.prototype._onMouseOver=function(a){return this._onOver(a)},c.prototype._onMouseOut=function(b){var c;if(this._removeCSSClass("ce-element--over"),c=a.Root.get(),c.dragging())return this._removeCSSClass("ce-element--drop"),this._removeCSSClass("ce-element--drop-above"),this._removeCSSClass("ce-element--drop-below"),this._removeCSSClass("ce-element--drop-center"),this._removeCSSClass("ce-element--drop-left"),this._removeCSSClass("ce-element--drop-right"),c._dropTarget=null},c.prototype._onMouseUp=function(a){return this._ieMouseDownEchoed=!1},c.prototype._onNativeDrop=function(b){return b.preventDefault(),b.stopPropagation(
for(b=this.getDOMElementAttributes(a),f=function(){var b,c,e,f;for(e=a.childNodes,f=[],b=0,c=e.length;b<c;b++)d=e[b],f.push(d);return f}(),i=0,j=f.length;i<j;i++)if(e=f[i],1===e.nodeType&&"img"===e.tagName.toLowerCase()){a=e;break}"a"===a.tagName.toLowerCase()&&(a=document.createElement("img"))}return c=this.getDOMElementAttributes(a),h=c.width,g=c.height,void 0===c.width&&(h=void 0===c.height?a.naturalWidth:a.clientWidth),void 0===c.height&&(g=void 0===c.width?a.naturalHeight:a.clientHeight),c.width=h,c.height=g,new this(c,b)},c}(a.ResizableElement),a.TagNames.get().register(a.Image,"img"),a.ImageFixture=function(b){function c(a,b,d){c.__super__.constructor.call(this,a,b),this._src=d}return h(c,b),c.prototype.cssTypeName=function(){return"image-fixture"},c.prototype.type=function(){return"ImageFixture"},c.prototype.typeName=function(){return"ImageFixture"},c.prototype.html=function(b){var c,d,e,f;return null==b&&(b=""),f=a.LINE_ENDINGS,d=this._attributesToString(),c="",void 0!==this._attributes.alt&&(c='alt="'+this._attributes.alt+'"'),e=b+'<img src="'+this.src()+'"'+c+">",b+"<"+this.tagName()+" "+d+">"+f+a.INDENT+e+f+b+"</"+this.tagName()+">"},c.prototype.mount=function(){var a,b,d,e,f,g;this._domElement=document.createElement(this.tagName()),g=this._attributes;for(b in g)f=g[b],"alt"!==b&&"style"!==b&&this._domElement.setAttribute(b,f);return a="",this.a&&this.a.class&&(a+=" "+this.a.class),this._attributes.class&&(a+=" "+this._attributes.class),this._domElement.setAttribute("class",a),d=this._attributes.style?this._attributes.style:"",e=document.createElement("div"),e.setAttribute("style",d.trim()),e.style.backgroundImage=null,d=e.getAttribute("style"),d=[d.trim(),"background-image:url('"+this.src()+"');"].join(" "),this._domElement.setAttribute("style",d.trim()),c.__super__.mount.call(this)},c.prototype.src=function(a){return void 0===a?this._src:(this._src=a,this.isMounted()&&(this.unmount(),this.mount()),this.taint())},c.prototype.unmount=function(){var a,b;return this.isFixed()?(b=document.createElement("div"),b.innerHTML=this.html(),a=b.firstElementChild,this._domElement.parentNode.replaceChild(a,this._domElement),this._domElement=a,this.parent()._domElement=this._domElement):c.__super__.unmount.call(this)},c.prototype._attributesToString=function(){var b,c,d,e,f,g;this._attributes.style?(d=this._attributes.style?this._attributes.style:"",e=document.createElement("div"),e.setAttribute("style",d.trim()),e.style.backgroundImage=null,d=e.getAttribute("style"),d=[d.trim(),"background-image:url('"+this.src()+"');"].join(" "),this._attributes.style=d.trim()):this._attributes.style="background-image:url('"+this.src()+"');",b={},g=this._attributes;for(c in g)f=g[c],"alt"!==c&&(b[c]=f);return" "+a.attributesToString(b)},c.droppers={ImageFixture:a.Element._dropVert,Image:a.Element._dropVert,PreText:a.Element._dropVert,Text:a.Element._dropVert},c.fromDOMElement=function(a){var b,c,d,e,f,g,h,i;for(a.tagName,c=this.getDOMElementAttributes(a),g="",b="",f=function(){var b,c,e,f;for(e=a.childNodes,f=[],b=0,c=e.length;b<c;b++)d=e[b],f.push(d);return f}(),h=0,i=f.length;h<i;h++)if(e=f[h],1===e.nodeType&&"img"===e.tagName.toLowerCase()){g=e.getAttribute("src")||"",b=e.getAttribute("alt")||"";break}return c=this.getDOMElementAttributes(a),c.alt=b,new this(a.tagName,c,g)},c}(a.Element),a.TagNames.get().register(a.ImageFixture,"img-fixture"),a.Video=function(b){function c(a,b,d){var e;null==d&&(d=[]),c.__super__.constructor.call(this,a,b),this.sources=d,e=this.size(),this._aspectRatio=e[1]/e[0]}return h(c,b),c.prototype.cssTypeName=function(){return"video"},c.prototype.type=function(){return"Video"},c.prototype.typeName=function(){return"Video"},c.prototype._title=function(){var a;return a="",this.attr("src")?a=this.attr("src"):this.sources.length&&(a=this.sources[0].src),a||(a="No video source set"),a.length>80&&(a=a.substr(0,80)+"..."),a},c.prototype.createDraggingDOMElement=function(){var a;if(this.isMounted())return a=c.__super__.createDraggingDOMElement.call(this),a.innerHTML=this._title(),a},c.prototype.html=function(b){var c,
"busy"===this._state?this.addCSSClass("ct-ignition--busy"):"editing"===this._state?this.addCSSClass("ct-ignition--editing"):"ready"===this._state?this.addCSSClass("ct-ignition--ready"):void 0},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domEdit=null,this._domConfirm=null,this._domCancel=null},b.prototype._addDOMEventListeners=function(){return this._domEdit.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.edit()}}(this)),this._domConfirm.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.confirm()}}(this)),this._domCancel.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.cancel()}}(this))},b}(b.WidgetUI),b.InspectorUI=function(a){function c(){c.__super__.constructor.call(this),this._tagUIs=[]}return g(c,a),c.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-widget","ct-inspector"]),this.parent().domElement().appendChild(this._domElement),this._domTags=this.constructor.createDiv(["ct-inspector__tags","ct-tags"]),this._domElement.appendChild(this._domTags),this._domCounter=this.constructor.createDiv(["ct-inspector__counter"]),this._domElement.appendChild(this._domCounter),this.updateCounter(),this._addDOMEventListeners(),this._handleFocusChange=function(a){return function(){return a.updateTags()}}(this),ContentEdit.Root.get().bind("blur",this._handleFocusChange),ContentEdit.Root.get().bind("focus",this._handleFocusChange),ContentEdit.Root.get().bind("mount",this._handleFocusChange)},c.prototype.unmount=function(){return c.__super__.unmount.call(this),this._domTags=null,ContentEdit.Root.get().unbind("blur",this._handleFocusChange),ContentEdit.Root.get().unbind("focus",this._handleFocusChange),ContentEdit.Root.get().unbind("mount",this._handleFocusChange)},c.prototype.updateCounter=function(){var a,c,d,e,f,g,h,i,j,k,l;if(this.isMounted()){for(c="",l=b.EditorApp.get().orderedRegions(),j=0,k=l.length;j<k;j++)(g=l[j])&&(c+=g.domElement().textContent);return c=c.trim(),(c=c.replace(/<\/?[a-z][^>]*>/gi,""),c=c.replace(/[\u200B]+/,""),c=c.replace(/['";:,.?¿\-!¡]+/g,""),i=(c.match(/\S+/g)||[]).length,i=i.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),(d=ContentEdit.Root.get().focused())&&"PreText"===d.type()&&d.selection().isCollapsed())?(e=0,a=1,h=d.content.substring(0,d.selection().get()[0]),f=h.text().split("\n"),e=f.length,a=f[f.length-1].length+1,e=e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),a=a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),this._domCounter.textContent=i+" / "+e+":"+a):void(this._domCounter.textContent=i)}},c.prototype.updateTags=function(){var a,c,d,e,f,g,h,i,j;for(a=ContentEdit.Root.get().focused(),i=this._tagUIs,e=0,g=i.length;e<g;e++)d=i[e],d.unmount();if(this._tagUIs=[],a){for(c=a.parents(),c.reverse(),c.push(a),j=[],f=0,h=c.length;f<h;f++)a=c[f],-1===b.INSPECTOR_IGNORED_ELEMENTS.indexOf(a.type())&&(d=new b.TagUI(a),this._tagUIs.push(d),j.push(d.mount(this._domTags)));return j}},c.prototype._addDOMEventListeners=function(){return this._updateCounterInterval=setInterval(function(a){return function(){return a.updateCounter()}}(this),250)},c.prototype._removeDOMEventListeners=function(){return clearInterval(this._updateCounterInterval)},c}(b.WidgetUI),b.TagUI=function(a){function c(a){this.element=a,this._onMouseDown=h(this._onMouseDown,this),c.__super__.constructor.call(this)}return g(c,a),c.prototype.mount=function(a,b){return null==b&&(b=null),this._domElement=this.constructor.createDiv(["ct-tag"]),this._domElement.textContent=this.element.tagName(),c.__super__.mount.call(this,a,b)},c.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("mousedown",this._onMouseDown)},c.prototype._onMouseDown=function(a){var c,d,e;return a.preventDefault(),this.element.storeState&&this.element.storeState(),c=b.EditorApp.get(),e=new b.ModalUI,d=new b.PropertiesDialog(this.element),d.addEventListener("cancel",function(a){return function(){if(e.hide(),d.hide(),a.element.restoreState)return a.element.restoreState()}}(thi
g=this.constructor.createDiv(["ct-control-group","ct-control-group--left"]),this._domControls.appendChild(g),this._domStylesTab=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--styles"]),this._domStylesTab.setAttribute("data-ct-tooltip",ContentEdit._("Styles")),g.appendChild(this._domStylesTab),this._domAttributesTab=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--attributes"]),this._domAttributesTab.setAttribute("data-ct-tooltip",ContentEdit._("Attributes")),g.appendChild(this._domAttributesTab),this._domCodeTab=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--code"]),this._domCodeTab.setAttribute("data-ct-tooltip",ContentEdit._("Code")),g.appendChild(this._domCodeTab),this._supportsCoding||ContentEdit.addCSSClass(this._domCodeTab,"ct-control--muted"),this._domRemoveAttribute=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--remove","ct-control--muted"]),this._domRemoveAttribute.setAttribute("data-ct-tooltip",ContentEdit._("Remove")),g.appendChild(this._domRemoveAttribute),f=this.constructor.createDiv(["ct-control-group","ct-control-group--right"]),this._domControls.appendChild(f),this._domApply=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--apply"]),this._domApply.textContent=ContentEdit._("Apply"),f.appendChild(this._domApply),h=window.localStorage.getItem("ct-properties-dialog-tab"),"attributes"===h?(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--attributes"),ContentEdit.addCSSClass(this._domAttributesTab,"ct-control--active")):"code"===h&&this._supportsCoding?(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--code"),ContentEdit.addCSSClass(this._domCodeTab,"ct-control--active")):(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--styles"),ContentEdit.addCSSClass(this._domStylesTab,"ct-control--active")),this._addDOMEventListeners()},e.prototype.save=function(){var a,b;return b=null,this._supportsCoding&&(b=this._domInnerHTML.value),a={changedAttributes:this.changedAttributes(),changedStyles:this.changedStyles(),innerHTML:b},this.dispatchEvent(this.createEvent("save",a))},e.prototype._addAttributeUI=function(c,d){var e,f;return f=this,e=new a(c,d),this._attributeUIs.push(e),e.addEventListener("blur",function(a){var b,c,d;if(f._focusedAttributeUI=null,ContentEdit.addCSSClass(f._domRemoveAttribute,"ct-control--muted"),b=f._attributeUIs.indexOf(this),d=f._attributeUIs.length,""===this.name()&&b<d-1&&(this.unmount(),f._attributeUIs.splice(b,1)),(c=f._attributeUIs[d-1])&&c.name()&&c.value())return f._addAttributeUI("","")}),e.addEventListener("focus",function(a){return f._focusedAttributeUI=this,ContentEdit.removeCSSClass(f._domRemoveAttribute,"ct-control--muted")}),e.addEventListener("namechange",function(a){var d,e,g,h,i,j,k;for(d=f.element,c=this.name().toLowerCase(),g=b.getRestrictedAtributes(d.tagName()),h=!0,g&&-1!==g.indexOf(c)&&(h=!1),k=f._attributeUIs,i=0,j=k.length;i<j;i++)e=k[i],""!==c&&e!==this&&e.name().toLowerCase()===c&&(h=!1);return this.valid(h),h?ContentEdit.removeCSSClass(f._domApply,"ct-control--muted"):ContentEdit.addCSSClass(f._domApply,"ct-control--muted")}),e.mount(this._domAttributes),e},e.prototype._addDOMEventListeners=function(){var a,b;return e.__super__._addDOMEventListeners.call(this),a=function(a){return function(b){var c,d,e,f,g,h;for(f=["attributes","code","styles"],g=0,h=f.length;g<h;g++)(d=f[g])!==b&&(e=d.charAt(0).toUpperCase()+d.slice(1),ContentEdit.removeCSSClass(a._domElement,"ct-properties-dialog--"+d),ContentEdit.removeCSSClass(a["_dom"+e+"Tab"],"ct-control--active"));return c=b.charAt(0).toUpperCase()+b.slice(1),ContentEdit.addCSSClass(a._domElement,"ct-properties-dialog--"+b),ContentEdit.addCSSClass(a["_dom"+c+"Tab"],"ct-control--active"),window.localStorage.setItem("ct-properties-dialog-tab",b)}}(this),this._domStylesTab.addEventListener("mousedown",function(b){return function(){return a("styles")}}()),this._domAttributesTab.addEventListener("mousedown",function(b){return function(){return a("attributes")}}()),thi
a||(this._regionsLastModified[g]=this._regions[g].lastModified()));this._domRegions=c,k=this._regions,l=[];for(g in k)k[g],d[g]||(delete this._regions[g],delete this._regionsLastModified[g],f=this._orderedRegions.indexOf(g),f>-1?l.push(this._orderedRegions.splice(f,1)):l.push(void 0));return l},c}(b.ComponentUI),b.EditorApp=function(){function a(){}var c;return c=null,a.get=function(){var a;return a=b.EditorApp.getCls(),null!=c?c:c=new a},a.getCls=function(){return e},a}(),b.History=function(){function a(a){this._lastSnapshotTaken=null,this._regions={},this.replaceRegions(a),this._snapshotIndex=-1,this._snapshots=[],this._store()}return a.prototype.canRedo=function(){return this._snapshotIndex<this._snapshots.length-1},a.prototype.canUndo=function(){return this._snapshotIndex>0},a.prototype.index=function(){return this._snapshotIndex},a.prototype.length=function(){return this._snapshots.length},a.prototype.snapshot=function(){return this._snapshots[this._snapshotIndex]},a.prototype.goTo=function(a){return this._snapshotIndex=Math.min(this._snapshots.length-1,Math.max(0,a)),this.snapshot()},a.prototype.redo=function(){return this.goTo(this._snapshotIndex+1)},a.prototype.replaceRegions=function(a){var b,c,d;this._regions={},d=[];for(b in a)c=a[b],d.push(this._regions[b]=c);return d},a.prototype.restoreSelection=function(a){var b,c;if(a.selected)return c=this._regions[a.selected.region],b=c.descendants()[a.selected.element],b.focus(),b.selection&&a.selected.selection?b.selection(a.selected.selection):void 0},a.prototype.stopWatching=function(){if(this._watchInterval&&clearInterval(this._watchInterval),this._delayedStoreTimeout)return clearTimeout(this._delayedStoreTimeout)},a.prototype.undo=function(){return this.goTo(this._snapshotIndex-1)},a.prototype.watch=function(){var a;return this._lastSnapshotTaken=Date.now(),a=function(a){return function(){var b,c;if(null!==(c=ContentEdit.Root.get().lastModified())&&c>a._lastSnapshotTaken){if(a._delayedStoreRequested===c)return;return a._delayedStoreTimeout&&clearTimeout(a._delayedStoreTimeout),b=function(){return a._lastSnapshotTaken=c,a._store()},a._delayedStoreRequested=c,a._delayedStoreTimeout=setTimeout(b,500)}}}(this),this._watchInterval=setInterval(a,50)},a.prototype._store=function(){var a,b,c,d,e,f,g;e={regions:{},regionModifieds:{},rootModified:ContentEdit.Root.get().lastModified(),selected:null},f=this._regions;for(b in f)d=f[b],e.regions[b]=d.html(),e.regionModifieds[b]=d.lastModified();if(a=ContentEdit.Root.get().focused()){if(e.selected={},!(d=a.closest(function(a){return"Region"===a.type()||"Fixture"===a.type()})))return;g=this._regions;for(b in g)if(c=g[b],d===c){e.selected.region=b;break}e.selected.element=d.descendants().indexOf(a),a.selection&&(e.selected.selection=a.selection())}return this._snapshotIndex<this._snapshots.length-1&&(this._snapshots=this._snapshots.slice(0,this._snapshotIndex+1)),this._snapshotIndex++,this._snapshots.splice(this._snapshotIndex,0,e)},a}(),b.StylePalette=function(){function a(){}return a._styles=[],a.add=function(a){return this._styles=this._styles.concat(a)},a.styles=function(a){var b;return void 0===a?this._styles.slice():(b=a.tagName(),this._styles.filter(function(a){return!a._applicableTo||-1!==a._applicableTo.indexOf(b)}))},a}(),b.Style=function(){function a(a,b,c){this._name=a,this._cssClass=b,this._applicableTo=c||null}return a.prototype.applicableTo=function(){return this._applicableTo},a.prototype.cssClass=function(){return this._cssClass},a.prototype.name=function(){return this._name},a}(),b.ToolShelf=function(){function a(){}return a._tools={},a.stow=function(a,b){return this._tools[b]=a},a.fetch=function(a){if(!this._tools[a])throw new Error("`"+a+"` has not been stowed on the tool shelf");return this._tools[a]},a}(),b.Tool=function(){function a(){}return a.label="Tool",a.icon="tool",a.requiresElement=!0,a.canApply=function(a,b){return!1},a.isApplied=function(a,b){return!1},a.apply=function(a,b,c){throw new Error("Not implemented")},a.editor=function(){return b.EditorApp.get()},a.dispatchEditorEvent=function(a,b){return