forked from nytimes/ice
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ice-master.min.js
7 lines (6 loc) · 103 KB
/
ice-master.min.js
1
2
3
4
5
6
7
//
// @concordnow/ice - Master
// The MIT License
// Copyright (c) 2012 The New York Times, CMS Group, Matthew DeLambo <delambo@gmail.com>
//
window.rangy=function(){var i="object",n="undefined",a=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer","START_TO_START","START_TO_END","END_TO_START","END_TO_END"],c=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],t=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],r=["collapse","compareEndPoints","duplicate","getBookmark","moveToBookmark","moveToElementText","parentElement","pasteHTML","select","setEndPoint","getBoundingClientRect"];function l(e,t){var n=typeof e[t];return"function"==n||!(n!=i||!e[t])||"unknown"==n}function d(e,t){return!(typeof e[t]!=i||!e[t])}function e(e,t){return typeof e[t]!=n}function o(i){return function(e,t){for(var n=t.length;n--;)if(!i(e,t[n]))return!1;return!0}}var h=o(l),s=o(d),u=o(e);function f(e){return e&&h(e,r)&&u(e,t)}var g={version:"1.2.3",initialized:!1,supported:!0,util:{isHostMethod:l,isHostObject:d,isHostProperty:e,areHostMethods:h,areHostObjects:s,areHostProperties:u,isTextRange:f},features:{},modules:{},config:{alertOnWarn:!1,preferTextRange:!1}};function m(e){window.alert("Rangy not supported in your browser. Reason: "+e),g.initialized=!0,g.supported=!1}g.fail=m,g.warn=function(e){e="Rangy warning: "+e,g.config.alertOnWarn?window.alert(e):typeof window.console!=n&&typeof window.console.log!=n&&window.console.log(e)},!{}.hasOwnProperty?m("hasOwnProperty not supported"):g.util.extend=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};var p=[],C=[];function N(){if(!g.initialized){var e,t=!1,n=!1;l(document,"createRange")&&(e=document.createRange(),h(e,c)&&u(e,a)&&(t=!0),e.detach());var i=d(document,"body")?document.body:document.getElementsByTagName("body")[0];i&&l(i,"createTextRange")&&f(e=i.createTextRange())&&(n=!0),t||n||m("Neither Range nor TextRange are implemented"),g.initialized=!0,g.features={implementsDomRange:t,implementsTextRange:n};for(var r=C.concat(p),o=0,s=r.length;o<s;++o)try{r[o](g)}catch(e){d(window,"console")&&l(window.console,"log")&&window.console.log("Init listener threw an exception. Continuing.",e)}}}g.init=N,g.addInitListener=function(e){g.initialized?e(g):p.push(e)};var v=[];function E(e){this.name=e,this.initialized=!1,this.supported=!1}g.addCreateMissingNativeApiListener=function(e){v.push(e)},g.createMissingNativeApi=function(e){e=e||window,N();for(var t=0,n=v.length;t<n;++t)v[t](e)},E.prototype.fail=function(e){throw this.initialized=!0,this.supported=!1,new Error("Module '"+this.name+"' failed to load: "+e)},E.prototype.warn=function(e){g.warn("Module "+this.name+": "+e)},E.prototype.createError=function(e){return new Error("Error in Rangy "+this.name+" module: "+e)},g.createModule=function(e,t){var n=new E(e);g.modules[e]=n,C.push(function(e){t(e,n),n.initialized=!0,n.supported=!0})};var y=!(g.requireModules=function(e){for(var t,n,i=0,r=e.length;i<r;++i){if(n=e[i],!((t=g.modules[n])&&t instanceof E))throw new Error("Module '"+n+"' not found");if(!t.supported)throw new Error("Module '"+n+"' not supported")}}),s=function(e){y||(y=!0,g.initialized||N())};if(typeof window!=n){if(typeof document!=n)return l(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",s,!1),l(window,"addEventListener")?window.addEventListener("load",s,!1):l(window,"attachEvent")?window.attachEvent("onload",s):m("Window does not have required addEventListener or attachEvent method"),g;m("No document found")}else m("No window found")}(),rangy.createModule("DomUtil",function(e,t){var n="undefined",i=e.util;i.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||t.fail("document missing a Node creation method"),i.isHostMethod(document,"getElementsByTagName")||t.fail("document missing getElementsByTagName method");var r=document.createElement("div");i.areHostMethods(r,["insertBefore","appendChild","cloneNode"])||t.fail("Incomplete Element implementation"),i.isHostProperty(r,"innerHTML")||t.fail("Element is missing innerHTML property");r=document.createTextNode("test");i.areHostMethods(r,["splitText","deleteData","insertData","appendData","cloneNode"])||t.fail("Incomplete Text Node implementation");function o(e,t){for(var n=e.length;n--;)if(e[n]===t)return!0;return!1}function c(e){for(var t=0;e=e.previousSibling;)t++;return t}function l(e,t){for(var n=[],i=e;i;i=i.parentNode)n.push(i);for(i=t;i;i=i.parentNode)if(o(n,i))return i;return null}function d(e,t,n){for(var i,r=n?e:e.parentNode;r;){if((i=r.parentNode)===t)return r;r=i}return null}function s(e){e=e.nodeType;return 3==e||4==e||8==e}function a(e,t){var n=t.nextSibling,t=t.parentNode;return n?t.insertBefore(e,n):t.appendChild(e),e}function h(e){if(9==e.nodeType)return e;if(typeof e.ownerDocument!=n)return e.ownerDocument;if(typeof e.document!=n)return e.document;if(e.parentNode)return h(e.parentNode);throw new Error("getDocument: no document found for node")}function u(e){if(!e)return"[No node]";if(s(e))return'"'+e.data+'"';if(1!=e.nodeType)return e.nodeName;var t=e.id?' id="'+e.id+'"':"";return"<"+e.nodeName+t+">["+e.childNodes.length+"]"}function f(e){this.root=e,this._next=e}function g(e,t){this.node=e,this.offset=t}function m(e){this.code=this[e],this.codeName=e,this.message="DOMException: "+this.codeName}f.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var e,t,n=this._current=this._next;if(this._current)if(e=n.firstChild)this._next=e;else{for(t=null;n!==this.root&&!(t=n.nextSibling);)n=n.parentNode;this._next=t}return this._current},detach:function(){this._current=this._next=this.root=null}},g.prototype={equals:function(e){return this.node===e.node&this.offset==e.offset},inspect:function(){return"[DomPosition("+u(this.node)+":"+this.offset+")]"}},(m.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11}).toString=function(){return this.message},e.dom={arrayContains:o,isHtmlNamespace:function(e){var t;return typeof e.namespaceURI==n||null===(t=e.namespaceURI)||"http://www.w3.org/1999/xhtml"==t},parentElement:function(e){return 1==(e=e.parentNode).nodeType?e:null},getNodeIndex:c,getNodeLength:function(e){return s(e)?e.length:(e=e.childNodes)?e.length:0},getCommonAncestor:l,isAncestorOf:function(e,t,n){for(var i=n?t:t.parentNode;i;){if(i===e)return!0;i=i.parentNode}return!1},getClosestAncestorIn:d,isCharacterDataNode:s,insertAfter:a,splitDataNode:function(e,t){var n=e.cloneNode(!1);return n.deleteData(0,t),e.deleteData(t,e.length-t),a(n,e),n},getDocument:h,getWindow:function(e){if(typeof(e=h(e)).defaultView!=n)return e.defaultView;if(typeof e.parentWindow!=n)return e.parentWindow;throw new Error("Cannot get a window object for node")},getIframeWindow:function(e){if(typeof e.contentWindow!=n)return e.contentWindow;if(typeof e.contentDocument!=n)return e.contentDocument.defaultView;throw new Error("getIframeWindow: No Window object found for iframe element")},getIframeDocument:function(e){if(typeof e.contentDocument!=n)return e.contentDocument;if(typeof e.contentWindow!=n)return e.contentWindow.document;throw new Error("getIframeWindow: No Document object found for iframe element")},getBody:function(e){return i.isHostObject(e,"body")?e.body:e.getElementsByTagName("body")[0]},getRootContainer:function(e){for(var t;t=e.parentNode;)e=t;return e},comparePoints:function(e,t,n,i){var r,o,s,a;if(e==n)return t===i?0:t<i?-1:1;if(r=d(n,e,!0))return t<=c(r)?-1:1;if(r=d(e,n,!0))return c(r)<i?-1:1;if((o=e===(i=l(e,n))?i:d(e,i,!0))===(s=n===i?i:d(n,i,!0)))throw new Error("comparePoints got to case 4 and childA and childB are the same!");for(a=i.firstChild;a;){if(a===o)return-1;if(a===s)return 1;a=a.nextSibling}throw new Error("Should not be here!")},inspectNode:u,fragmentFromNodeChildren:function(e){for(var t,n=h(e).createDocumentFragment();t=e.firstChild;)n.appendChild(t);return n},createIterator:function(e){return new f(e)},DomPosition:g},e.DOMException=m}),rangy.createModule("DomRange",function(o,e){o.requireModules(["DomUtil"]);var l=o.dom,t=l.DomPosition,s=o.DOMException;function a(e,t){return 3!=e.nodeType&&(l.isAncestorOf(e,t.startContainer,!0)||l.isAncestorOf(e,t.endContainer,!0))}function c(e){return l.getDocument(e.startContainer)}function d(e,t,n){var i=e._listeners[t];if(i)for(var r=0,o=i.length;r<o;++r)i[r].call(e,{target:e,args:n})}function h(e){return new t(e.parentNode,l.getNodeIndex(e))}function u(e){return new t(e.parentNode,l.getNodeIndex(e)+1)}function n(e,t,n){var i=11==e.nodeType?e.firstChild:e;return l.isCharacterDataNode(t)?n==t.length?l.insertAfter(e,t):t.parentNode.insertBefore(e,0==n?t:l.splitDataNode(t,n)):n>=t.childNodes.length?t.appendChild(e):t.insertBefore(e,t.childNodes[n]),i}function f(e,t,n){var i,r,o,s;for(n=n||{stop:!1};o=e.next();)if(e.isPartiallySelectedSubtree()){if(!1===t(o))return void(n.stop=!0);if(f(s=e.getSubtreeIterator(),t,n),s.detach(!0),n.stop)return}else for(i=l.createIterator(o);r=i.next();)if(!1===t(r))return void(n.stop=!0)}function g(e){for(var t;e.next();)e.isPartiallySelectedSubtree()?(g(t=e.getSubtreeIterator()),t.detach(!0)):e.remove()}function m(e){for(var t,n,i=c(e.range).createDocumentFragment();t=e.next();){if(e.isPartiallySelectedSubtree()?(t=t.cloneNode(!1),n=e.getSubtreeIterator(),t.appendChild(m(n)),n.detach(!0)):e.remove(),10==t.nodeType)throw new s("HIERARCHY_REQUEST_ERR");i.appendChild(t)}return i}function i(e,t,n){var i,r=!(!t||!t.length),o=!!n;r&&(i=new RegExp("^("+t.join("|")+")$"));var s=[];return f(new p(e,!1),function(e){r&&!i.test(e.nodeType)||o&&!n(e)||s.push(e)}),s}function r(e){return"["+(void 0===e.getName?"Range":e.getName())+"("+l.inspectNode(e.startContainer)+":"+e.startOffset+", "+l.inspectNode(e.endContainer)+":"+e.endOffset+")]"}function p(e,t){this.range=e,this.clonePartiallySelectedTextNodes=t,e.collapsed||(this.sc=e.startContainer,this.so=e.startOffset,this.ec=e.endContainer,this.eo=e.endOffset,e=e.commonAncestorContainer,this.sc===this.ec&&l.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==e||l.isCharacterDataNode(this.sc)?l.getClosestAncestorIn(this.sc,e,!0):this.sc.childNodes[this.so],this._last=this.ec!==e||l.isCharacterDataNode(this.ec)?l.getClosestAncestorIn(this.ec,e,!0):this.ec.childNodes[this.eo-1]))}function C(e){this.code=this[e],this.codeName=e,this.message="RangeException: "+this.codeName}function N(e,t,n){this.nodes=i(e,t,n),this._next=this.nodes[0],this._position=0}p.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=null,this._next=this._first},hasNext:function(){return!!this._next},next:function(){var e=this._current=this._next;return e&&(this._next=e!==this._last?e.nextSibling:null,l.isCharacterDataNode(e)&&this.clonePartiallySelectedTextNodes&&(e===this.ec&&(e=e.cloneNode(!0)).deleteData(this.eo,e.length-this.eo),this._current===this.sc&&(e=e.cloneNode(!0)).deleteData(0,this.so))),e},remove:function(){var e,t,n=this._current;!l.isCharacterDataNode(n)||n!==this.sc&&n!==this.ec?n.parentNode&&n.parentNode.removeChild(n):(e=n===this.sc?this.so:0)!=(t=n===this.ec?this.eo:n.length)&&n.deleteData(e,t-e)},isPartiallySelectedSubtree:function(){return a(this._current,this.range)},getSubtreeIterator:function(){var e,t,n,i,r,o;return this.isSingleCharacterDataNode?(e=this.range.cloneRange()).collapse():(e=new ie(c(this.range)),t=this._current,i=0,o=l.getNodeLength(r=n=t),l.isAncestorOf(t,this.sc,!0)&&(n=this.sc,i=this.so),l.isAncestorOf(t,this.ec,!0)&&(r=this.ec,o=this.eo),ne(e,n,i,r,o)),new p(e,this.clonePartiallySelectedTextNodes)},detach:function(e){e&&this.range.detach(),this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}},(C.prototype={BAD_BOUNDARYPOINTS_ERR:1,INVALID_NODE_TYPE_ERR:2}).toString=function(){return this.message},N.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){return this._current=this._next,this._next=this.nodes[++this._position],this._current},detach:function(){this._current=this._next=this.nodes=null}};var v=[1,3,4,5,7,8,10],E=[2,9,11],y=[1,3,4,5,7,8,10,11],T=[1,3,4,5,7,8];function _(r){return function(e,t){for(var n,i=t?e:e.parentNode;i;){if(n=i.nodeType,l.arrayContains(r,n))return i;i=i.parentNode}return null}}var S=l.getRootContainer,b=_([9,11]),R=_([5,6,10,12]),w=_([6,10,12]);function O(e,t){if(w(e,t))throw new C("INVALID_NODE_TYPE_ERR")}function x(e){if(!e.startContainer)throw new s("INVALID_STATE_ERR")}function D(e,t){if(!l.arrayContains(t,e.nodeType))throw new C("INVALID_NODE_TYPE_ERR")}function k(e,t){if(t<0||t>(l.isCharacterDataNode(e)?e:e.childNodes).length)throw new s("INDEX_SIZE_ERR")}function A(e,t){if(b(e,!0)!==b(t,!0))throw new s("WRONG_DOCUMENT_ERR")}function P(e){if(R(e,!0))throw new s("NO_MODIFICATION_ALLOWED_ERR")}function I(e,t){if(!e)throw new s(t)}function B(e){return!l.arrayContains(E,e.nodeType)&&!b(e,!0)}function M(e,t){return t<=(l.isCharacterDataNode(e)?e:e.childNodes).length}function L(e){return!!e.startContainer&&!!e.endContainer&&!B(e.startContainer)&&!B(e.endContainer)&&M(e.startContainer,e.startOffset)&&M(e.endContainer,e.endOffset)}function H(e){if(x(e),!L(e))throw new Error("Range error: Range is no longer valid after DOM mutation ("+e.inspect()+")")}var U=document.createElement("style"),j=!1;try{U.innerHTML="<b>x</b>",j=3==U.firstChild.nodeType}catch(e){}var j=(o.features.htmlParsingConforms=j)?function(e){var t=this.startContainer,n=l.getDocument(t);if(!t)throw new s("INVALID_STATE_ERR");var i=null;return 1==t.nodeType?i=t:l.isCharacterDataNode(t)&&(i=l.parentElement(t)),(i=null===i||"HTML"==i.nodeName&&l.isHtmlNamespace(l.getDocument(i).documentElement)&&l.isHtmlNamespace(i)?n.createElement("body"):i.cloneNode(!1)).innerHTML=e,l.fragmentFromNodeChildren(i)}:function(e){x(this);var t=c(this).createElement("body");return t.innerHTML=e,l.fragmentFromNodeChildren(t)},W=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],F=0,Q=1,K=2,V=3,X=0,z=1,Y=2,q=3;function G(){}function $(e){e.START_TO_START=F,e.START_TO_END=Q,e.END_TO_END=K,e.END_TO_START=V,e.NODE_BEFORE=X,e.NODE_AFTER=z,e.NODE_BEFORE_AND_AFTER=Y,e.NODE_INSIDE=q}function Z(e){$(e),$(e.prototype)}function J(o,s){return function(){H(this);var e=this.startContainer,t=this.startOffset,n=this.commonAncestorContainer,i=new p(this,!0);e!==n&&(e=(r=u(l.getClosestAncestorIn(e,n,!0))).node,t=r.offset),f(i,P),i.reset();var r=o(i);return i.detach(),s(this,e,t,e,t),r}}function ee(e,c,t){function n(t,n){return function(e){x(this),D(e,v),D(S(e),E);e=(t?h:u)(e);(n?i:r)(this,e.node,e.offset)}}function i(e,t,n){var i=e.endContainer,r=e.endOffset;t===e.startContainer&&n===e.startOffset||(S(t)==S(i)&&1!=l.comparePoints(t,n,i,r)||(i=t,r=n),c(e,t,n,i,r))}function r(e,t,n){var i=e.startContainer,r=e.startOffset;t===e.endContainer&&n===e.endOffset||(S(t)==S(i)&&-1!=l.comparePoints(t,n,i,r)||(i=t,r=n),c(e,i,r,t,n))}e.prototype=new G,o.util.extend(e.prototype,{setStart:function(e,t){x(this),O(e,!0),k(e,t),i(this,e,t)},setEnd:function(e,t){x(this),O(e,!0),k(e,t),r(this,e,t)},setStartBefore:n(!0,!0),setStartAfter:n(!1,!0),setEndBefore:n(!0,!1),setEndAfter:n(!1,!1),collapse:function(e){H(this),e?c(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):c(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(e){x(this),O(e,!0),c(this,e,0,e,l.getNodeLength(e))},selectNode:function(e){x(this),O(e,!1),D(e,v);var t=h(e),e=u(e);c(this,t.node,t.offset,e.node,e.offset)},extractContents:J(m,c),deleteContents:J(g,c),canSurroundContents:function(){H(this),P(this.startContainer),P(this.endContainer);var e=new p(this,!0),t=e._first&&a(e._first,this)||e._last&&a(e._last,this);return e.detach(),!t},detach:function(){t(this)},splitBoundaries:function(){H(this);var e=this.startContainer,t=this.startOffset,n=this.endContainer,i=this.endOffset,r=e===n;l.isCharacterDataNode(n)&&0<i&&i<n.length&&l.splitDataNode(n,i),l.isCharacterDataNode(e)&&0<t&&t<e.length&&(e=l.splitDataNode(e,t),r?(i-=t,n=e):n==e.parentNode&&i>=l.getNodeIndex(e)&&i++,t=0),c(this,e,t,n,i)},normalizeBoundaries:function(){H(this);function e(e){var t=e.nextSibling;t&&t.nodeType==e.nodeType&&(s=(o=e).length,e.appendData(t.data),t.parentNode.removeChild(t))}function t(e){var t,n=e.previousSibling;n&&n.nodeType==e.nodeType&&(t=(i=e).length,r=n.length,e.insertData(0,n.data),n.parentNode.removeChild(n),i==o?(s+=r,o=i):o==e.parentNode&&(n=l.getNodeIndex(e),s==n?(o=e,s=t):n<s&&s--))}var n,i=this.startContainer,r=this.startOffset,o=this.endContainer,s=this.endOffset,a=!0;l.isCharacterDataNode(o)?o.length==s&&e(o):(0<s&&((n=o.childNodes[s-1])&&l.isCharacterDataNode(n)&&e(n)),a=!this.collapsed),a?l.isCharacterDataNode(i)?0==r&&t(i):r<i.childNodes.length&&((a=i.childNodes[r])&&l.isCharacterDataNode(a)&&t(a)):(i=o,r=s),c(this,i,r,o,s)},collapseToPoint:function(e,t){var n;x(this),O(e,!0),k(e,t),n=t,(t=e)===(e=this).startContainer&&n===e.startOffset&&t===e.endContainer&&n===e.endOffset||c(e,t,n,t,n)}}),Z(e)}function te(e){e.collapsed=e.startContainer===e.endContainer&&e.startOffset===e.endOffset,e.commonAncestorContainer=e.collapsed?e.startContainer:l.getCommonAncestor(e.startContainer,e.endContainer)}function ne(e,t,n,i,r){var o=e.startContainer!==t||e.startOffset!==n,s=e.endContainer!==i||e.endOffset!==r;e.startContainer=t,e.startOffset=n,e.endContainer=i,e.endOffset=r,te(e),d(e,"boundarychange",{startMoved:o,endMoved:s})}function ie(e){this.startContainer=e,this.startOffset=0,this.endContainer=e,this.endOffset=0,this._listeners={boundarychange:[],detach:[]},te(this)}G.prototype={attachListener:function(e,t){this._listeners[e].push(t)},compareBoundaryPoints:function(e,t){H(this),A(this.startContainer,t.startContainer);var n=e==V||e==F?"start":"end",i=e==Q||e==F?"start":"end",r=this[n+"Container"],e=this[n+"Offset"],n=t[i+"Container"],i=t[i+"Offset"];return l.comparePoints(r,e,n,i)},insertNode:function(e){if(H(this),D(e,y),P(this.startContainer),l.isAncestorOf(e,this.startContainer,!0))throw new s("HIERARCHY_REQUEST_ERR");e=n(e,this.startContainer,this.startOffset);this.setStartBefore(e)},cloneContents:function(){if(H(this),this.collapsed)return c(this).createDocumentFragment();if(this.startContainer===this.endContainer&&l.isCharacterDataNode(this.startContainer))return(t=this.startContainer.cloneNode(!0)).data=t.data.slice(this.startOffset,this.endOffset),(e=c(this).createDocumentFragment()).appendChild(t),e;var e=new p(this,!0),t=function e(t){for(var n,i,r=c(t.range).createDocumentFragment();n=t.next();){if(i=t.isPartiallySelectedSubtree(),n=n.cloneNode(!i),i&&(i=t.getSubtreeIterator(),n.appendChild(e(i)),i.detach(!0)),10==n.nodeType)throw new s("HIERARCHY_REQUEST_ERR");r.appendChild(n)}return r}(e);return e.detach(),t},canSurroundContents:function(){H(this),P(this.startContainer),P(this.endContainer);var e=new p(this,!0),t=e._first&&a(e._first,this)||e._last&&a(e._last,this);return e.detach(),!t},surroundContents:function(e){if(D(e,T),!this.canSurroundContents())throw new C("BAD_BOUNDARYPOINTS_ERR");var t=this.extractContents();if(e.hasChildNodes())for(;e.lastChild;)e.removeChild(e.lastChild);n(e,this.startContainer,this.startOffset),e.appendChild(t),this.selectNode(e)},cloneRange:function(){H(this);for(var e,t=new ie(c(this)),n=W.length;n--;)t[e=W[n]]=this[e];return t},toString:function(){H(this);var e=this.startContainer;if(e===this.endContainer&&l.isCharacterDataNode(e))return 3==e.nodeType||4==e.nodeType?e.data.slice(this.startOffset,this.endOffset):"";var t=[],e=new p(this,!0);return f(e,function(e){3!=e.nodeType&&4!=e.nodeType||t.push(e.data)}),e.detach(),t.join("")},compareNode:function(e){H(this);var t=e.parentNode,n=l.getNodeIndex(e);if(!t)throw new s("NOT_FOUND_ERR");e=this.comparePoint(t,n),n=this.comparePoint(t,n+1);return e<0?0<n?Y:X:0<n?z:q},comparePoint:function(e,t){return H(this),I(e,"HIERARCHY_REQUEST_ERR"),A(e,this.startContainer),l.comparePoints(e,t,this.startContainer,this.startOffset)<0?-1:0<l.comparePoints(e,t,this.endContainer,this.endOffset)?1:0},createContextualFragment:j,toHtml:function(){H(this);var e=c(this).createElement("div");return e.appendChild(this.cloneContents()),e.innerHTML},intersectsNode:function(e,t){if(H(this),I(e,"NOT_FOUND_ERR"),l.getDocument(e)!==c(this))return!1;var n=e.parentNode,i=l.getNodeIndex(e);I(n,"NOT_FOUND_ERR");e=l.comparePoints(n,i,this.endContainer,this.endOffset),i=l.comparePoints(n,i+1,this.startContainer,this.startOffset);return t?e<=0&&0<=i:e<0&&0<i},isPointInRange:function(e,t){return H(this),I(e,"HIERARCHY_REQUEST_ERR"),A(e,this.startContainer),0<=l.comparePoints(e,t,this.startContainer,this.startOffset)&&l.comparePoints(e,t,this.endContainer,this.endOffset)<=0},intersectsRange:function(e,t){if(H(this),c(e)!=c(this))throw new s("WRONG_DOCUMENT_ERR");var n=l.comparePoints(this.startContainer,this.startOffset,e.endContainer,e.endOffset),e=l.comparePoints(this.endContainer,this.endOffset,e.startContainer,e.startOffset);return t?n<=0&&0<=e:n<0&&0<e},intersection:function(e){if(this.intersectsRange(e)){var t=l.comparePoints(this.startContainer,this.startOffset,e.startContainer,e.startOffset),n=l.comparePoints(this.endContainer,this.endOffset,e.endContainer,e.endOffset),i=this.cloneRange();return-1==t&&i.setStart(e.startContainer,e.startOffset),1==n&&i.setEnd(e.endContainer,e.endOffset),i}return null},union:function(e){if(this.intersectsRange(e,!0)){var t=this.cloneRange();return-1==l.comparePoints(e.startContainer,e.startOffset,this.startContainer,this.startOffset)&&t.setStart(e.startContainer,e.startOffset),1==l.comparePoints(e.endContainer,e.endOffset,this.endContainer,this.endOffset)&&t.setEnd(e.endContainer,e.endOffset),t}throw new C("Ranges do not intersect")},containsNode:function(e,t){return t?this.intersectsNode(e,!1):this.compareNode(e)==q},containsNodeContents:function(e){return 0<=this.comparePoint(e,0)&&this.comparePoint(e,l.getNodeLength(e))<=0},containsRange:function(e){return this.intersection(e).equals(e)},containsNodeText:function(e){var t=this.cloneRange();t.selectNode(e);var n=t.getNodes([3]);if(0<n.length){t.setStart(n[0],0);n=n.pop();t.setEnd(n,n.length);n=this.containsRange(t);return t.detach(),n}return this.containsNodeContents(e)},createNodeIterator:function(e,t){return H(this),new N(this,e,t)},getNodes:function(e,t){return H(this),i(this,e,t)},getDocument:function(){return c(this)},collapseBefore:function(e){x(this),this.setEndBefore(e),this.collapse(!1)},collapseAfter:function(e){x(this),this.setStartAfter(e),this.collapse(!0)},getName:function(){return"DomRange"},equals:function(e){return ie.rangesEqual(this,e)},isValid:function(){return L(this)},inspect:function(){return r(this)}},ee(ie,ne,function(e){x(e),e.startContainer=e.startOffset=e.endContainer=e.endOffset=null,e.collapsed=e.commonAncestorContainer=null,d(e,"detach",null),e._listeners=null}),o.rangePrototype=G.prototype,ie.rangeProperties=W,ie.RangeIterator=p,ie.copyComparisonConstants=Z,ie.createPrototypeRange=ee,ie.inspect=r,ie.getRangeDocument=c,ie.rangesEqual=function(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset},o.DomRange=ie,o.RangeException=C}),rangy.createModule("WrappedRange",function(s,e){var a;s.requireModules(["DomUtil","DomRange"]);var t,u=s.dom,f=u.DomPosition,c=s.DomRange;function i(e,t,n,i){var r=e.duplicate();r.collapse(n);var o=r.parentElement();if(!(o=!u.isAncestorOf(t,o,!0)?t:o).canHaveHTML)return new f(o.parentNode,u.getNodeIndex(o));for(var s,a=u.getDocument(o).createElement("span"),c=n?"StartToStart":"StartToEnd";o.insertBefore(a,a.previousSibling),r.moveToElementText(a),0<(s=r.compareEndPoints(c,e))&&a.previousSibling;);if(t=a.nextSibling,-1==s&&t&&u.isCharacterDataNode(t)){if(r.setEndPoint(n?"EndToStart":"EndToEnd",e),/[\r\n]/.test(t.data))for(var l=r.duplicate(),d=l.text.replace(/\r\n/g,"\r").length,h=l.moveStart("character",d);-1==(s=l.compareEndPoints("StartToEnd",l));)h++,l.moveStart("character",1);else h=r.text.length;d=new f(t,h)}else t=(i||!n)&&a.previousSibling,d=(n=(i||n)&&a.nextSibling)&&u.isCharacterDataNode(n)?new f(n,0):t&&u.isCharacterDataNode(t)?new f(t,t.length):new f(o,u.getNodeIndex(a));return a.parentNode.removeChild(a),d}function r(e,t){var n,i,r=e.offset,o=u.getDocument(e.node),s=o.body.createTextRange(),a=u.isCharacterDataNode(e.node),e=a?(n=e.node).parentNode:(n=r<(i=e.node.childNodes).length?i[r]:null,e.node),o=o.createElement("span");return o.innerHTML="&#feff;",n?e.insertBefore(o,n):e.appendChild(o),s.moveToElementText(o),s.collapse(!t),e.removeChild(o),a&&s[t?"moveStart":"moveEnd"]("character",r),s}!s.features.implementsDomRange||s.features.implementsTextRange&&s.config.preferTextRange?s.features.implementsTextRange&&((a=function(e){this.textRange=e,this.refresh()}).prototype=new c(document),a.prototype.refresh=function(){var e,t,n=function(e){var t=e.parentElement(),n=e.duplicate();n.collapse(!0);var i=n.parentElement();return(n=e.duplicate()).collapse(!1),n=n.parentElement(),(n=i==n?i:u.getCommonAncestor(i,n))==t?n:u.getCommonAncestor(t,n)}(this.textRange),n=0==(t=this.textRange).compareEndPoints("StartToEnd",t)?e=i(this.textRange,n,!0,!0):(e=i(this.textRange,n,!0,!1),i(this.textRange,n,!1,!1));this.setStart(e.node,e.offset),this.setEnd(n.node,n.offset)},c.copyComparisonConstants(a),void 0===(t=function(){return this}()).Range&&(t.Range=a),s.createNativeRange=function(e){return(e=e||document).body.createTextRange()}):(function(){var t,i=c.rangeProperties;function r(e){for(var t,n=i.length;n--;)e[t=i[n]]=e.nativeRange[t]}a=function(e){if(!e)throw new Error("Range must be specified");this.nativeRange=e,r(this)},c.createPrototypeRange(a,function(e,t,n,i,r){var o=e.startContainer!==t||e.startOffset!=n,s=e.endContainer!==i||e.endOffset!=r;(o||s)&&(e.setEnd(i,r),e.setStart(t,n))},function(e){e.nativeRange.detach(),e.detached=!0;for(var t=i.length;t--;)e[i[t]]=null}),(t=a.prototype).selectNode=function(e){this.nativeRange.selectNode(e),r(this)},t.deleteContents=function(){this.nativeRange.deleteContents(),r(this)},t.extractContents=function(){var e=this.nativeRange.extractContents();return r(this),e},t.cloneContents=function(){return this.nativeRange.cloneContents()},t.surroundContents=function(e){this.nativeRange.surroundContents(e),r(this)},t.collapse=function(e){this.nativeRange.collapse(e),r(this)},t.cloneRange=function(){return new a(this.nativeRange.cloneRange())},t.refresh=function(){r(this)},t.toString=function(){return this.nativeRange.toString()};var e=document.createTextNode("test");u.getBody(document).appendChild(e);var n=document.createRange();n.setStart(e,0),n.setEnd(e,0);try{n.setStart(e,1),t.setStart=function(e,t){this.nativeRange.setStart(e,t),r(this)},t.setEnd=function(e,t){this.nativeRange.setEnd(e,t),r(this)},o=function(t){return function(e){this.nativeRange[t](e),r(this)}}}catch(e){t.setStart=function(t,n){try{this.nativeRange.setStart(t,n)}catch(e){this.nativeRange.setEnd(t,n),this.nativeRange.setStart(t,n)}r(this)},t.setEnd=function(t,n){try{this.nativeRange.setEnd(t,n)}catch(e){this.nativeRange.setStart(t,n),this.nativeRange.setEnd(t,n)}r(this)},o=function(n,i){return function(t){try{this.nativeRange[n](t)}catch(e){this.nativeRange[i](t),this.nativeRange[n](t)}r(this)}}}t.setStartBefore=o("setStartBefore","setEndBefore"),t.setStartAfter=o("setStartAfter","setEndAfter"),t.setEndBefore=o("setEndBefore","setStartBefore"),t.setEndAfter=o("setEndAfter","setStartAfter"),n.selectNodeContents(e),n.startContainer==e&&n.endContainer==e&&0==n.startOffset&&n.endOffset==e.length?t.selectNodeContents=function(e){this.nativeRange.selectNodeContents(e),r(this)}:t.selectNodeContents=function(e){this.setStart(e,0),this.setEnd(e,c.getEndOffset(e))},n.selectNodeContents(e),n.setEnd(e,3);var o=document.createRange();o.selectNodeContents(e),o.setEnd(e,4),o.setStart(e,2),-1==n.compareBoundaryPoints(n.START_TO_END,o)&1==n.compareBoundaryPoints(n.END_TO_START,o)?t.compareBoundaryPoints=function(e,t){return e==(t=t.nativeRange||t).START_TO_END?e=t.END_TO_START:e==t.END_TO_START&&(e=t.START_TO_END),this.nativeRange.compareBoundaryPoints(e,t)}:t.compareBoundaryPoints=function(e,t){return this.nativeRange.compareBoundaryPoints(e,t.nativeRange||t)},s.util.isHostMethod(n,"createContextualFragment")&&(t.createContextualFragment=function(e){return this.nativeRange.createContextualFragment(e)}),u.getBody(document).removeChild(e),n.detach(),o.detach()}(),s.createNativeRange=function(e){return(e=e||document).createRange()}),s.features.implementsTextRange&&(a.rangeToTextRange=function(e){if(e.collapsed)return r(new f(e.startContainer,e.startOffset),!0);var t=r(new f(e.startContainer,e.startOffset),!0),n=r(new f(e.endContainer,e.endOffset),!1),e=u.getDocument(e.startContainer).body.createTextRange();return e.setEndPoint("StartToStart",t),e.setEndPoint("EndToEnd",n),e}),a.prototype.getName=function(){return"WrappedRange"},s.WrappedRange=a,s.createRange=function(e){return e=e||document,new a(s.createNativeRange(e))},s.createRangyRange=function(e){return e=e||document,new c(e)},s.createIframeRange=function(e){return s.createRange(u.getIframeDocument(e))},s.createIframeRangyRange=function(e){return s.createRangyRange(u.getIframeDocument(e))},s.addCreateMissingNativeApiListener(function(e){e=e.document;void 0===e.createRange&&(e.createRange=function(){return s.createRange(this)})})}),rangy.createModule("WrappedSelection",function(o,e){o.requireModules(["DomUtil","DomRange","WrappedRange"]),o.config.checkSelectionRanges=!0;var r,i,t="boolean",s="_rangySelection",c=o.dom,n=o.util,a=o.DomRange,l=o.WrappedRange,d=o.DOMException,h=c.DomPosition,u="Control";function f(e){return(e||window).document.selection}var g=o.util.isHostMethod(window,"getSelection"),m=o.util.isHostObject(document,"selection"),p=m&&(!g||o.config.preferTextRange);p?(r=f,o.isSelectionValid=function(e){var t=(e||window).document,e=t.selection;return"None"!=e.type||c.getDocument(e.createRange().parentElement())==t}):g?(r=function(e){return(e||window).getSelection()},o.isSelectionValid=function(){return!0}):e.fail("Neither document.selection or window.getSelection() detected.");var C=(o.getNativeSelection=r)(),N=o.createNativeRange(document),v=c.getBody(document),E=n.areHostObjects(C,n.areHostProperties(C,["anchorOffset","focusOffset"]));o.features.selectionHasAnchorAndFocus=E;var y=n.isHostMethod(C,"extend");o.features.selectionHasExtend=y;g="number"==typeof C.rangeCount;o.features.selectionHasRangeCount=g;var T=!1,_=!0;n.areHostMethods(C,["addRange","getRangeAt","removeAllRanges"])&&"number"==typeof C.rangeCount&&o.features.implementsDomRange&&function(){var e=document.createElement("iframe");e.frameBorder=0,e.style.position="absolute",e.style.left="-10000px",v.appendChild(e);var t=c.getIframeDocument(e);t.open(),t.write("<html><head></head><body>12</body></html>"),t.close();var n=c.getIframeWindow(e).getSelection(),i=t.documentElement.lastChild.firstChild,r=t.createRange();r.setStart(i,1),r.collapse(!0),n.addRange(r),_=1==n.rangeCount,n.removeAllRanges();t=r.cloneRange();r.setStart(i,0),t.setEnd(i,2),n.addRange(r),n.addRange(t),T=2==n.rangeCount,r.detach(),t.detach(),v.removeChild(e)}(),o.features.selectionSupportsMultipleRanges=T,o.features.collapsedNonEditableSelectionsSupported=_;var S,b=!1;function R(e,t,n){var i=n?"end":"start",n=n?"start":"end";e.anchorNode=t[i+"Container"],e.anchorOffset=t[i+"Offset"],e.focusNode=t[n+"Container"],e.focusOffset=t[n+"Offset"]}function w(e){e.anchorNode=e.focusNode=null,e.anchorOffset=e.focusOffset=0,e.rangeCount=0,e.isCollapsed=!0,e._ranges.length=0}function O(e){var t;return e instanceof a?(t=e._selectionNativeRange)||((t=o.createNativeRange(c.getDocument(e.startContainer))).setEnd(e.endContainer,e.endOffset),t.setStart(e.startContainer,e.startOffset),e._selectionNativeRange=t,e.attachListener("detach",function(){this._selectionNativeRange=null})):e instanceof l?t=e.nativeRange:o.features.implementsDomRange&&e instanceof c.getWindow(e.startContainer).Range&&(t=e),t}function x(e){var t=e.getNodes();if(!function(e){if(e.length&&1==e[0].nodeType){for(var t=1,n=e.length;t<n;++t)if(!c.isAncestorOf(e[0],e[t]))return;return 1}}(t))throw new Error("getSingleElementFromRange: range "+e.inspect()+" did not consist of a single element");return t[0]}function D(e){return e&&void 0!==e.text}function k(e,t){t=new l(t);e._ranges=[t],R(e,t,!1),e.rangeCount=1,e.isCollapsed=t.collapsed}function A(e){if(e._ranges.length=0,"None"==e.docSelection.type)w(e);else{var t=e.docSelection.createRange();if(D(t))k(e,t);else{e.rangeCount=t.length;for(var n,i=c.getDocument(t.item(0)),r=0;r<e.rangeCount;++r)(n=o.createRange(i)).selectNode(t.item(r)),e._ranges.push(n);e.isCollapsed=1==e.rangeCount&&e._ranges[0].collapsed,R(e,e._ranges[e.rangeCount-1],!1)}}}function P(e,t){for(var n=e.docSelection.createRange(),i=x(t),t=c.getDocument(n.item(0)),r=c.getBody(t).createControlRange(),o=0,s=n.length;o<s;++o)r.add(n.item(o));try{r.add(i)}catch(e){throw new Error("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}r.select(),A(e)}function I(e,t,n){this.nativeSelection=e,this.docSelection=t,this._ranges=[],this.win=n,this.refresh()}v&&n.isHostMethod(v,"createControlRange")&&(M=v.createControlRange(),n.areHostProperties(M,["item","add"])&&(b=!0)),o.features.implementsControlRange=b,i=E?function(e){return e.anchorNode===e.focusNode&&e.anchorOffset===e.focusOffset}:function(e){return!!e.rangeCount&&e.getRangeAt(e.rangeCount-1).collapsed},n.isHostMethod(C,"getRangeAt")?S=function(e,t){try{return e.getRangeAt(t)}catch(e){return null}}:E&&(S=function(e){var t=c.getDocument(e.anchorNode),t=o.createRange(t);return t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.collapsed!==this.isCollapsed&&(t.setStart(e.focusNode,e.focusOffset),t.setEnd(e.anchorNode,e.anchorOffset)),t}),o.getSelection=function(e){var t=(e=e||window)[s],n=r(e),i=m?f(e):null;return t?(t.nativeSelection=n,t.docSelection=i,t.refresh(e)):(t=new I(n,i,e),e[s]=t),t},o.getIframeSelection=function(e){return o.getSelection(c.getIframeWindow(e))};var B,M=I.prototype;function L(e,t){for(var n,i=c.getDocument(t[0].startContainer),r=c.getBody(i).createControlRange(),o=0;o<rangeCount;++o){n=x(t[o]);try{r.add(n)}catch(e){throw new Error("setRanges(): Element within the one of the specified Ranges could not be added to control selection (does it have layout?)")}}r.select(),A(e)}if(!p&&E&&n.areHostMethods(C,["removeAllRanges","addRange"])){M.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),w(this)};function H(e,t){var n=a.getRangeDocument(t),n=o.createRange(n);n.collapseToPoint(t.endContainer,t.endOffset),e.nativeSelection.addRange(O(n)),e.nativeSelection.extend(t.startContainer,t.startOffset),e.refresh()}M.addRange=g?function(e,t){b&&m&&this.docSelection.type==u?P(this,e):t&&y?H(this,e):(t=T?this.rangeCount:(this.removeAllRanges(),0),this.nativeSelection.addRange(O(e)),this.rangeCount=this.nativeSelection.rangeCount,this.rangeCount==t+1?(!o.config.checkSelectionRanges||(t=S(this.nativeSelection,this.rangeCount-1))&&!a.rangesEqual(t,e)&&(e=new l(t)),this._ranges[this.rangeCount-1]=e,R(this,e,j(this.nativeSelection)),this.isCollapsed=i(this)):this.refresh())}:function(e,t){t&&y?H(this,e):(this.nativeSelection.addRange(O(e)),this.refresh())},M.setRanges=function(e){if(b&&1<e.length)L(this,e);else{this.removeAllRanges();for(var t=0,n=e.length;t<n;++t)this.addRange(e[t])}}}else{if(!(n.isHostMethod(C,"empty")&&n.isHostMethod(N,"select")&&b&&p))return e.fail("No means of selecting a Range or TextRange was found"),!1;M.removeAllRanges=function(){try{var e,t;this.docSelection.empty(),"None"!=this.docSelection.type&&(this.anchorNode?e=c.getDocument(this.anchorNode):this.docSelection.type!=u||(t=this.docSelection.createRange()).length&&(e=c.getDocument(t.item(0)).body.createTextRange()),e&&(e.body.createTextRange().select(),this.docSelection.empty()))}catch(e){}w(this)},M.addRange=function(e){this.docSelection.type==u?P(this,e):(l.rangeToTextRange(e).select(),this._ranges[0]=e,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,R(this,e,!1))},M.setRanges=function(e){this.removeAllRanges();var t=e.length;1<t?L(this,e):t&&this.addRange(e[0])}}if(M.getRangeAt=function(e){if(e<0||e>=this.rangeCount)throw new d("INDEX_SIZE_ERR");return this._ranges[e]},p)B=function(e){var t;o.isSelectionValid(e.win)?t=e.docSelection.createRange():(t=c.getBody(e.win.document).createTextRange()).collapse(!0),e.docSelection.type==u?A(e):D(t)?k(e,t):w(e)};else if(n.isHostMethod(C,"getRangeAt")&&"number"==typeof C.rangeCount)B=function(e){if(b&&m&&e.docSelection.type==u)A(e);else if(e._ranges.length=e.rangeCount=e.nativeSelection.rangeCount,e.rangeCount){for(var t=0,n=e.rangeCount;t<n;++t)e._ranges[t]=new o.WrappedRange(e.nativeSelection.getRangeAt(t));R(e,e._ranges[e.rangeCount-1],j(e.nativeSelection)),e.isCollapsed=i(e)}else w(e)};else{if(!E||typeof C.isCollapsed!=t||typeof N.collapsed!=t||!o.features.implementsDomRange)return e.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;B=function(e){var t,n=e.nativeSelection;n.anchorNode?(t=S(n,0),e._ranges=[t],e.rangeCount=1,t=(n=e).nativeSelection,n.anchorNode=t.anchorNode,n.anchorOffset=t.anchorOffset,n.focusNode=t.focusNode,n.focusOffset=t.focusOffset,e.isCollapsed=i(e)):w(e)}}M.refresh=function(e){var t=e?this._ranges.slice(0):null;if(B(this),e){var n=t.length;if(n!=this._ranges.length)return!1;for(;n--;)if(!a.rangesEqual(t[n],this._ranges[n]))return!1;return!0}};function U(e,t){var n=e.getAllRanges(),i=!1;e.removeAllRanges();for(var r=0,o=n.length;r<o;++r)i||t!==n[r]?e.addRange(n[r]):i=!0;e.rangeCount||w(e)}var j;function W(e,t){if(e.anchorNode&&c.getDocument(e.anchorNode)!==c.getDocument(t))throw new d("WRONG_DOCUMENT_ERR")}function F(e){var t=[],n=new h(e.anchorNode,e.anchorOffset),i=new h(e.focusNode,e.focusOffset),r="function"==typeof e.getName?e.getName():"Selection";if(void 0!==e.rangeCount)for(var o=0,s=e.rangeCount;o<s;++o)t[o]=a.inspect(e.getRangeAt(o));return"["+r+"(Ranges: "+t.join(", ")+")(anchor: "+n.inspect()+", focus: "+i.inspect()+"]"}M.removeRange=b?function(e){if(this.docSelection.type==u){for(var t=this.docSelection.createRange(),n=x(e),i=c.getDocument(t.item(0)),r=c.getBody(i).createControlRange(),o=!1,s=0,a=t.length;s<a;++s)t.item(s)!==n||o?r.add(t.item(s)):o=!0;r.select(),A(this)}else U(this,e)}:function(e){U(this,e)},!p&&E&&o.features.implementsDomRange?(j=function(e){var t=!1;return t=e.anchorNode?1==c.comparePoints(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset):t},M.isBackwards=function(){return j(this)}):j=M.isBackwards=function(){return!1},M.toString=function(){for(var e=[],t=0,n=this.rangeCount;t<n;++t)e[t]=""+this._ranges[t];return e.join("")},M.collapse=function(e,t){W(this,e);var n=o.createRange(c.getDocument(e));n.collapseToPoint(e,t),this.removeAllRanges(),this.addRange(n),this.isCollapsed=!0},M.collapseToStart=function(){if(!this.rangeCount)throw new d("INVALID_STATE_ERR");var e=this._ranges[0];this.collapse(e.startContainer,e.startOffset)},M.collapseToEnd=function(){if(!this.rangeCount)throw new d("INVALID_STATE_ERR");var e=this._ranges[this.rangeCount-1];this.collapse(e.endContainer,e.endOffset)},M.selectAllChildren=function(e){W(this,e);var t=o.createRange(c.getDocument(e));t.selectNodeContents(e),this.removeAllRanges(),this.addRange(t)},M.deleteFromDocument=function(){if(b&&m&&this.docSelection.type==u){for(var e,t=this.docSelection.createRange();t.length;)e=t.item(0),t.remove(e),e.parentNode.removeChild(e);this.refresh()}else if(this.rangeCount){var n=this.getAllRanges();this.removeAllRanges();for(var i=0,r=n.length;i<r;++i)n[i].deleteContents();this.addRange(n[r-1])}},M.getAllRanges=function(){return this._ranges.slice(0)},M.setSingleRange=function(e){this.setRanges([e])},M.containsNode=function(e,t){for(var n=0,i=this._ranges.length;n<i;++n)if(this._ranges[n].containsNode(e,t))return!0;return!1},M.toHtml=function(){var e="";if(this.rangeCount){for(var t=a.getRangeDocument(this._ranges[0]).createElement("div"),n=0,i=this._ranges.length;n<i;++n)t.appendChild(this._ranges[n].cloneContents());e=t.innerHTML}return e},M.getName=function(){return"WrappedSelection"},M.inspect=function(){return F(this)},M.detach=function(){this.win[s]=null,this.win=this.anchorNode=this.focusNode=null},I.inspect=F,o.Selection=I,o.selectionPrototype=M,o.addCreateMissingNativeApiListener(function(e){void 0===e.getSelection&&(e.getSelection=function(){return o.getSelection(this)})})}),"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),"indexOf"in Array.prototype||(Array.prototype.indexOf=function(e,t){(t=void 0===t?0:t)<0&&(t+=this.length),t<0&&(t=0);for(var n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1}),"lastIndexOf"in Array.prototype||(Array.prototype.lastIndexOf=function(e,t){for((t=void 0===t?this.length-1:t)<0&&(t+=this.length),t>this.length-1&&(t=this.length-1),t++;0<t--;)if(t in this&&this[t]===e)return t;return-1}),"map"in Array.prototype||(Array.prototype.map=function(e,t){for(var n=new Array(this.length),i=0,r=this.length;i<r;i++)i in this&&(n[i]=e.call(t,this[i],i,this));return n}),"filter"in Array.prototype||(Array.prototype.filter=function(e,t){for(var n,i=[],r=0,o=this.length;r<o;r++)r in this&&e.call(t,n=this[r],r,this)&&i.push(n);return i}),function(){var t={changeIdAttribute:"data-cid",userIdAttribute:"data-userid",userNameAttribute:"data-username",timeAttribute:"data-time",attrValuePrefix:"",blockEl:"p",blockEls:["p","ol","ul","li","h1","h2","h3","h4","h5","h6","blockquote"],blockParentsNodeName:["P","UL","OL","TABLE"],stylePrefix:"cts",currentUser:{id:null,name:null},changeTypes:{insertType:{tag:"span",alias:"ins",action:"Inserted"},deleteType:{tag:"span",alias:"del",action:"Deleted"}},styleColorsNumber:0,handleEvents:!1,contentEditable:!0,isTracking:!0,noTrack:".ice-no-track",classNotTracked:"",avoid:".ice-avoid",mergeBlocks:!0},e=function(e){if(this._changes={},this._userStyles={},!(e=e||{}).element)throw Error("`options.element` must be defined for ice construction.");if(!e.styleColorsNumber)throw Error("`options.styleColorsNumber` must be set to > 0 for ice construction.");ice.dom.extend(!0,this,t,e),this.pluginsManager=new ice.IcePluginManager(this),e.plugins&&this.pluginsManager.usePlugins("ice-init",e.plugins)};e.prototype={_userStyles:{},_trackedUsersId:[],_browserType:null,_batchChangeid:null,_delBookmark:"tempdel",isPlaceHoldingDeletes:!1,startTracking:function(){var t;return this.handleEvents&&(t=this,ice.dom.bind(t.element,"keyup.ice keydown.ice keypress.ice mousedown.ice mouseup.ice",function(e){return t.handleEvent(e)})),this.initializeEnvironment(),this.initializeEditor(),this.findTrackTags(),this.pluginsManager.fireEnabled(this.element),this},stopTracking:function(){return this.handleEvents&&ice.dom.unbind(this.element,"keyup.ice keydown.ice keypress.ice mousedown.ice mouseup.ice"),this.pluginsManager.fireDisabled(this.element),this},initializeEnvironment:function(){this.env||(this.env={}),this.env.element=this.element,this.env.document=this.element.ownerDocument,this.env.window=this.env.document.defaultView||this.env.document.parentWindow||window,this.env.frame=this.env.window.frameElement,this.env.selection=this.selection=new ice.Selection(this.env),this.env.document.createElement(this.changeTypes.insertType.tag),this.env.document.createElement(this.changeTypes.deleteType.tag)},initializeEditor:function(){var e=this.env.document.createElement("div");this.element.childNodes.length?(e.innerHTML=this.element.innerHTML,ice.dom.removeWhitespace(e),""===e.innerHTML&&e.appendChild(ice.dom.create("<"+this.blockEl+" ><br/></"+this.blockEl+">"))):e.appendChild(ice.dom.create("<"+this.blockEl+" ><br/></"+this.blockEl+">")),this.element.innerHTML!=e.innerHTML&&(this.element.innerHTML=e.innerHTML)},findTrackTags:function(){var e,c=1,l=this,d=[],h=this.element.querySelectorAll("[data-cid]");for(e in h.length&&(l._trackedUsersId=this.getTrackedUserIds(h)),this.changeTypes)d.push(this._getIceNodeClass(e));ice.dom.each(ice.dom.find(this.element,"."+d.join(", .")),function(e,t){for(var n="",i=t.className.split(" "),r=0;r<i.length;r++){var o=new RegExp("("+d.join("|")+")").exec(i[r]);o&&(n=l._getChangeTypeFromAlias(o[1]))}var s=l._retrieveOrGenerateUserId(t);h.length&&(c=l._retrieveOrGenerateStyleIndex(t,s)),l.setUserStyle(s,Number(c));var a=ice.dom.attr(t,l.changeIdAttribute);l._changes[a]={type:n,userid:s,username:ice.dom.attr(t,l.userNameAttribute),time:ice.dom.attr(t,l.timeAttribute)}})},getTrackedUserIds:function(e){return Array.prototype.map.call(e,function(e){var t=e.attributes[this.userIdAttribute];return t?parseInt(t.nodeValue,10):this._hashNameToUserId(e)}.bind(this)).filter(function(e,t,n){return n.indexOf(e)===t})},_retrieveOrGenerateStyleIndex:function(e,t){if(this._trackedUsersId.indexOf(t)){e=e.className.match(/\d+/);if(e)return e[0]}return this._trackedUsersId.length%this.styleColorsNumber+1},_retrieveOrGenerateUserId:function(e){var t=ice.dom.attr(e,this.userIdAttribute);return t||this._hashNameToUserId(e)},_hashNameToUserId:function(e){var t=ice.dom.attr(e,this.userNameAttribute),n=0;if(0===t.length)return n;for(var i=0;i<t.length;i++){n=(n<<5)-n+t.charCodeAt(i);n|=0}return-1*n},refreshTrackChangesStyle:function(){var e=this.element.querySelectorAll("[data-cid]");if(e.length){this._trackedUsersId=[],this._userStyles={};for(var t=0;t<e.length;t++){var n=e[t],i=this._retrieveOrGenerateUserId(n),r=n.className.match(/\d+/);r&&(o=this.stylePrefix+"-"+r[0],ice.dom.hasClass(n,o)&&ice.dom.removeClass(n,o));var o=this.getUserStyle(i);ice.dom.addClass(n,o),-1===this._trackedUsersId.indexOf(i)&&this._trackedUsersId.push(i)}}},enableChangeTracking:function(){this.isTracking=!0,this.pluginsManager.fireEnabled(this.element)},disableChangeTracking:function(){this.isTracking=!1,this.pluginsManager.fireDisabled(this.element)},setCurrentUser:function(e){this.currentUser=e},handleEvent:function(e){var t;if(this.isTracking)if("mouseup"==e.type){var n=this;setTimeout(function(){n.mouseUp(e)},200)}else{if("mousedown"==e.type)return this.mouseDown(e);if("keypress"==e.type)return(t=this.keyPress(e))||e.preventDefault(),t;{if("keydown"==e.type)return(t=this.keyDown(e))||e.preventDefault(),t;"keyup"==e.type&&this.pluginsManager.fireCaretUpdated()}}},visible:function(e){e=(e=e.nodeType===ice.dom.TEXT_NODE?e.parentNode:e).getBoundingClientRect();return 0<e.top&&0<e.left},createIceNode:function(e,t){var n=this.env.document.createElement(this.changeTypes[e].tag);return ice.dom.addClass(n,this._getIceNodeClass(e)),n.appendChild(t||this.env.document.createTextNode("")),this.addChange(this.changeTypes[e].alias,[n]),this.pluginsManager.fireNodeCreated(n,{action:this.changeTypes[e].action}),n},insert:function(e,t){var n=!e;e=e||"\ufeff",t?this.selection.addRange(t):t=this.getCurrentRange(),t=t.cloneRange(),this.selection._selection.removeAllRanges(),"string"==typeof e&&(e=document.createTextNode(e)),t.collapsed||(this.deleteContents(null,t),(t=this.getCurrentRange()).startContainer===t.endContainer&&this.element===t.startContainer&&(ice.dom.empty(this.element),i=t.getLastSelectableChild(this.element),t.setStartAfter(i),t.collapse(!0))),this._moveRangeToValidTrackingPos(t);var i=this.startBatchChange();return this._insertNode(e,t,n),this.pluginsManager.fireNodeInserted(e,t),this.endBatchChange(i),n},placeholdDeletes:function(){var n=this;this.isPlaceholdingDeletes&&this.revertDeletePlaceholders(),this.isPlaceholdingDeletes=!0,this._deletes=[];var e="."+this._getIceNodeClass("deleteType");return ice.dom.each(ice.dom.find(this.element,e),function(e,t){n._deletes.push(ice.dom.cloneNode(t)),ice.dom.replaceWith(t,"<"+n._delBookmark+' data-allocation="'+(n._deletes.length-1)+'"/>')}),!0},revertDeletePlaceholders:function(){var n=this;return!!this.isPlaceholdingDeletes&&(ice.dom.each(this._deletes,function(e,t){ice.dom.find(n.element,n._delBookmark+"[data-allocation="+e+"]").replaceWith(t)}),!(this.isPlaceholdingDeletes=!1))},deleteContents:function(e,t){var n=!0,i=ice.dom.browser();t?this.selection.addRange(t):t=this.getCurrentRange();var r=this.startBatchChange(this.changeTypes.deleteType.alias);if(!1===t.collapsed)this._currentUserIceNode(t.startContainer.parentNode)?this._deleteSelection(t):(this._deleteSelection(t),"mozilla"===i.type?(t.startContainer.parentNode.nextSibling?t.setEnd(t.startContainer.parentNode.nextSibling,0):t.setEndAfter(t.startContainer.parentNode),t.collapse(!1)):this.visible(t.endContainer)||(t.setEnd(t.endContainer,t.endOffset-1),t.collapse(!1)));else if(e)if("mozilla"===i.type)n=this._deleteRight(t),this.visible(t.endContainer)||(t.endContainer.parentNode.nextSibling?t.setEndBefore(t.endContainer.parentNode.nextSibling):t.setEndAfter(t.endContainer),t.collapse(!1));else{if(t.endOffset===ice.dom.getNodeCharacterLength(t.endContainer)){var o=t.startContainer.nextSibling;if(ice.dom.is(o,"."+this._getIceNodeClass("deleteType")))for(;o;){if(!ice.dom.is(o,"."+this._getIceNodeClass("deleteType"))){t.setStart(o,0),t.collapse(!0);break}o=o.nextSibling}}n=this._deleteRight(t),this.visible(t.endContainer)||ice.dom.is(t.endContainer.parentNode,"."+this._getIceNodeClass("insertType")+", ."+this._getIceNodeClass("deleteType"))&&(t.setStartAfter(t.endContainer.parentNode),t.collapse(!0))}else if("mozilla"===i.type)n=this._deleteLeft(t),this.visible(t.startContainer)||(t.startContainer.parentNode.previousSibling?t.setEnd(t.startContainer.parentNode.previousSibling,0):t.setEnd(t.startContainer.parentNode,0),t.moveEnd(ice.dom.CHARACTER_UNIT,ice.dom.getNodeCharacterLength(t.endContainer)),t.collapse(!1));else{if(!this.visible(t.startContainer)&&t.endOffset===ice.dom.getNodeCharacterLength(t.endContainer)){var s=t.startContainer.previousSibling;if(ice.dom.is(s,"."+this._getIceNodeClass("deleteType")))for(;s;){if(!ice.dom.is(s,"."+this._getIceNodeClass("deleteType"))){t.setEndBefore(s.nextSibling,0),t.collapse(!1);break}s=s.prevSibling}}n=this._deleteLeft(t)}return this.selection.addRange(t),this.endBatchChange(r),n},getChanges:function(){return this._changes},getChangeUserids:function(){var e,t=[],n=Object.keys(this._changes);for(e in n)t.push(this._changes[n[e]].userid);return t.sort().filter(function(e,t,n){return t==n.indexOf(e)?1:0})},getElementContent:function(){return this.element.innerHTML},getCleanContent:function(e,t,n){var i="",r=this;ice.dom.each(this.changeTypes,function(e,t){"deleteType"!=e&&(0<t&&(i+=","),i+="."+r._getIceNodeClass(e))}),e=e?"string"==typeof e?ice.dom.create("<div>"+e+"</div>"):ice.dom.cloneNode(e,!1)[0]:ice.dom.cloneNode(this.element,!1)[0],e=n?n.call(this,e):e;n=ice.dom.find(e,i);ice.dom.each(n,function(e,t){ice.dom.replaceWith(this,ice.dom.contents(this))});n=ice.dom.find(e,"."+this._getIceNodeClass("deleteType"));return ice.dom.remove(n),(e=t?t.call(this,e):e).innerHTML},acceptAll:function(){this.element.innerHTML=this.getCleanContent()},rejectAll:function(){var e="."+this._getIceNodeClass("insertType"),t="."+this._getIceNodeClass("deleteType");ice.dom.remove(ice.dom.find(this.element,e)),ice.dom.each(ice.dom.find(this.element,t),function(e,t){ice.dom.replaceWith(t,ice.dom.contents(t))})},acceptChange:function(e){this.acceptRejectChange(e,!0)},rejectChange:function(e){this.acceptRejectChange(e,!1)},acceptRejectChange:function(e,t){var n,i,r,o,s=ice.dom,a=(e.parentElement,null);if(!e){var c=this.getCurrentRange();if(!c.collapsed)return;e=c.startContainer}n=r="."+this._getIceNodeClass("deleteType"),i=o="."+this._getIceNodeClass("insertType"),c=s.getNode(e,n+","+i),e=s.find(this.element,"["+this.changeIdAttribute+"="+s.attr(c,this.changeIdAttribute)+"]"),a=[].map.call(e,function(e){for(var t=e.parentElement;t&&-1===this.blockParentsNodeName.indexOf(t.nodeName);)t=t.parentElement;return t}.bind(this)),t||(r=i,o=n),ice.dom.is(c,o)?s.each(e,function(e,t){s.replaceWith(t,ice.dom.contents(t))}):s.is(c,r)&&(s.remove(e),(a=a.filter(function(e){return s.hasNoTextOrStubContent(e)})).length&&t&&s.remove(a))},isInsideChange:function(e){var t="."+this._getIceNodeClass("insertType")+", ."+this._getIceNodeClass("deleteType");if(!e){if(range=this.getCurrentRange(),!range.collapsed)return!1;e=range.startContainer}return!!ice.dom.getNode(e,t)},addChangeType:function(e,t,n,i){n={tag:t,alias:n};i&&(n.action=i),this.changeTypes[e]=n},getIceNode:function(e,t){t="."+this._getIceNodeClass(t);return ice.dom.getNode(e,t)},_moveRangeToValidTrackingPos:function(e){for(var t=!1,n=this._getVoidElement(e.endContainer);n;){try{e.moveEnd(ice.dom.CHARACTER_UNIT,1),e.moveEnd(ice.dom.CHARACTER_UNIT,-1)}catch(e){t=!0}if(t||ice.dom.onBlockBoundary(e.endContainer,e.startContainer,this.blockEls)){e.setStartAfter(n),e.collapse(!0);break}(n=this._getVoidElement(e.endContainer))?(e.setEnd(e.endContainer,0),e.moveEnd(ice.dom.CHARACTER_UNIT,ice.dom.getNodeCharacterLength(e.endContainer)),e.collapse()):(e.setStart(e.endContainer,0),e.collapse(!0))}},_getNoTrackElement:function(e){var t=this._getNoTrackSelector();return ice.dom.is(e,t)?e:ice.dom.parents(e,t)[0]||null},_getNoTrackSelector:function(){return this.noTrack},_getVoidElement:function(e){var t=this._getVoidElSelector();return ice.dom.is(e,t)?e:ice.dom.parents(e,t)[0]||null},_getVoidElSelector:function(){return"."+this._getIceNodeClass("deleteType")+","+this.avoid},_currentUserIceNode:function(e){return ice.dom.attr(e,this.userIdAttribute)==this.currentUser.id},_getChangeTypeFromAlias:function(e){var t,n=null;for(t in this.changeTypes)this.changeTypes.hasOwnProperty(t)&&this.changeTypes[t].alias==e&&(n=t);return n},_getIceNodeClass:function(e){return this.attrValuePrefix+this.changeTypes[e].alias},getUserStyle:function(e){return this._userStyles[e]||this.setUserStyle(e,this.getNewStyleId(e))},setUserStyle:function(e,t){t=this.stylePrefix+"-"+t;return this._userStyles[e]=t},getNewStyleId:function(e){return this._userStyles[e]?this._userStyles[e].match(/\d+/)[0]:this._trackedUsersId.length%this.styleColorsNumber+1},addChange:function(e,t){var n=this._batchChangeid||this.getNewChangeId();this._changes[n]||(this._changes[n]={type:this._getChangeTypeFromAlias(e),time:(new Date).getTime(),userid:this.currentUser.id,username:this.currentUser.name});var i=this;return ice.dom.foreach(t,function(e){i.addNodeToChange(n,t[e])}),n},addNodeToChange:function(e,t){null!==this._batchChangeid&&(e=this._batchChangeid);var n=this.getChange(e);t.getAttribute(this.changeIdAttribute)||t.setAttribute(this.changeIdAttribute,e),t.getAttribute(this.userIdAttribute)||t.setAttribute(this.userIdAttribute,n.userid),t.getAttribute(this.userNameAttribute)||t.setAttribute(this.userNameAttribute,n.username),t.getAttribute(this.timeAttribute)||t.setAttribute(this.timeAttribute,n.time),ice.dom.hasClass(t,this._getIceNodeClass(n.type))||ice.dom.addClass(t,this._getIceNodeClass(n.type));n=this.getUserStyle(n.userid);ice.dom.hasClass(t,n)||ice.dom.addClass(t,n)},getChange:function(e){var t=null;return t=this._changes[e]?this._changes[e]:t},getNewChangeId:function(){var n,e=(n=(new Date).getTime(),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),("x"==e?t:3&t|8).toString(16)}));return e=this._changes[e]?this.getNewChangeId():e},startBatchChange:function(){return this._batchChangeid=this.getNewChangeId(),this._batchChangeid},endBatchChange:function(e){e===this._batchChangeid&&(this._batchChangeid=null)},getCurrentRange:function(){return this.selection.getRangeAt(0)},_insertNode:function(e,t,n){ice.dom.isBlockElement(t.startContainer)||ice.dom.canContainTextElement(ice.dom.getBlockParent(t.startContainer,this.element))||!t.startContainer.previousSibling||t.setStart(t.startContainer.previousSibling,0);t.startContainer;var i=ice.dom.isBlockElement(t.startContainer)&&t.startContainer||ice.dom.getBlockParent(t.startContainer,this.element)||null;if(i===this.element){var r=document.createElement(this.blockEl);return i.appendChild(r),t.setStart(r,0),t.collapse(),this._insertNode(e,t,n)}ice.dom.hasNoTextOrStubContent(i)&&(ice.dom.empty(i),ice.dom.append(i,"<br>"),t.setStart(i,0));i=this.getIceNode(t.startContainer,"insertType"),i=this._currentUserIceNode(i);n&&i||(i||(e=this.createIceNode("insertType",e)),t.insertNode(e),t.setEnd(e,1),n?t.setStart(e,0):t.collapse(),this.selection.addRange(t))},_handleVoidEl:function(e,t){e=this._getVoidElement(e);return!(!e||this.getIceNode(e,"deleteType"))&&(t.collapse(!0),!0)},_deleteSelection:function(e){for(var t=new ice.Bookmark(this.env,e),n=ice.dom.getElementsBetween(t.start,t.end),i=ice.dom.parents(e.startContainer,this.blockEls.join(", "))[0],r=ice.dom.parents(e.endContainer,this.blockEls.join(", "))[0],o=[],n=n.filter(function(e){return 1===e.nodeType&&e.className?-1===e.className.indexOf(this.classNotTracked):e}.bind(this)),s=0;s<n.length;s++){var a=n[s];if(!ice.dom.isBlockElement(a)||(o.push(a),ice.dom.canContainTextElement(a))){if((a.nodeType!==ice.dom.TEXT_NODE||0!==ice.dom.getNodeTextContent(a).length)&&!this._getVoidElement(a))if(a.nodeType===ice.dom.TEXT_NODE){var c=ice.dom.getBlockParent(a);this._addNodeTracking(a,!1,!0,!0),ice.dom.hasNoTextOrStubContent(c)&&ice.dom.remove(c)}else if(!(ice.dom.BREAK_ELEMENT==ice.dom.getTagName(a)||a.classList&&a.classList.contains(this.classNotTracked)))if(ice.dom.isStubElement(a))this._addNodeTracking(a,!1,!0);else for(ice.dom.hasNoTextOrStubContent(a)&&ice.dom.remove(a),j=0;j<a.childNodes.length;j++){var l=a.childNodes[j];n.push(l)}}else for(var d=0;d<a.childNodes.length;d++)n.push(a.childNodes[d])}if(this.mergeBlocks&&i!==r){for(;o.length;)ice.dom.mergeContainers(o.shift(),i);ice.dom.removeBRFromChild(r),ice.dom.removeBRFromChild(i),ice.dom.mergeContainers(r,i)}t.selectBookmark(),e.collapse(!0)},_deleteRight:function(e){var t=ice.dom.isBlockElement(e.startContainer)&&e.startContainer||ice.dom.getBlockParent(e.startContainer,this.element)||null,n=(!t||ice.dom.hasNoTextOrStubContent(t),t&&ice.dom.getNextContentNode(t,this.element)),i=!!n&&ice.dom.hasNoTextOrStubContent(n),r=e.endContainer,o=e.endOffset,s=e.commonAncestorContainer;if(s.nodeType!==ice.dom.TEXT_NODE){if(0===o&&ice.dom.isBlockElement(s)&&!ice.dom.canContainTextElement(s)){var a=s.firstElementChild;if(a)return e.setStart(a,0),e.collapse(),this._deleteRight(e)}if(s.childNodes.length>o){var c=document.createTextNode(" ");return s.insertBefore(c,s.childNodes[o]),e.setStart(c,1),e.collapse(!0),l=this._deleteRight(e),ice.dom.remove(c),l}return c=ice.dom.getNextContentNode(s,this.element),e.setEnd(c,0),e.collapse(),this._deleteRight(e)}if(e.moveEnd(ice.dom.CHARACTER_UNIT,1),e.moveEnd(ice.dom.CHARACTER_UNIT,-1),o===r.data.length&&!ice.dom.hasNoTextOrStubContent(r)){if(!(c=ice.dom.getNextNode(r,this.element)))return e.selectNodeContents(r),e.collapse(),!1;if("IMG"===(c=(c=ice.dom.BREAK_ELEMENT==ice.dom.getTagName(c)?ice.dom.getNextNode(c,this.element):c).nodeType===ice.dom.TEXT_NODE?c.parentNode:c).nodeName)return void c.parentNode.removeChild(c);if(!c.isContentEditable){var l=this._addNodeTracking(c,!1,!1),r=document.createTextNode("");return c.parentNode.insertBefore(r,c.nextSibling),e.selectNode(r),e.collapse(!0),l}if(this._handleVoidEl(c,e))return!0;if(ice.dom.isChildOf(c,t)&&ice.dom.isStubElement(c))return this._addNodeTracking(c,e,!1)}if(this._handleVoidEl(c,e))return!0;if(this._getNoTrackElement(e.endContainer.parentElement))return e.deleteContents(),!1;if(ice.dom.isOnBlockBoundary(e.startContainer,e.endContainer,this.element)){if(this.mergeBlocks&&ice.dom.is(ice.dom.getBlockParent(c,this.element),this.blockEl)){n!==ice.dom.getBlockParent(e.endContainer,this.element)&&e.setEnd(n,0);for(var d=ice.dom.getElementsBetween(e.startContainer,e.endContainer),h=0;h<d.length;h++)ice.dom.remove(d[h]);l=e.startContainer,c=e.endContainer;return ice.dom.remove(ice.dom.find(l,"br")),ice.dom.remove(ice.dom.find(c,"br")),ice.dom.mergeBlockWithSibling(e,ice.dom.getBlockParent(e.endContainer,this.element)||t)}return i?ice.dom.remove(n):e.setStart(n,0),e.collapse(!0),!0}n=e.endContainer.splitText(e.endOffset),n.splitText(1);return this._addNodeTracking(n,e,!1)},_deleteLeft:function(e){var t,n=ice.dom.isBlockElement(e.startContainer)&&e.startContainer||ice.dom.getBlockParent(e.startContainer,this.element)||null,i=(!n||ice.dom.hasNoTextOrStubContent(n),n&&ice.dom.getPrevContentNode(n,this.element)),r=!!i&&ice.dom.hasNoTextOrStubContent(i),o=e.startContainer,s=e.startOffset,a=e.commonAncestorContainer;if(0===s||a.nodeType!==ice.dom.TEXT_NODE){if(ice.dom.isBlockElement(a)&&!ice.dom.canContainTextElement(a))if(0===s){var c=a.firstElementChild;if(c)return e.setStart(c,0),e.collapse(),this._deleteLeft(e)}else{var l=a.lastElementChild;if(l&&(t=e.getLastSelectableChild(l)))return e.setStart(t,t.data.length),e.collapse(),this._deleteLeft(e)}if(!(c=0===s?ice.dom.getPrevContentNode(o,this.element):a.childNodes[s-1]))return!1;if("IMG"===(c=(c=ice.dom.is(c,"."+this._getIceNodeClass("insertType")+", ."+this._getIceNodeClass("deleteType"))&&0<c.childNodes.length&&c.lastChild?c.lastChild:c).nodeType===ice.dom.TEXT_NODE?c.parentNode:c).nodeName)return void c.parentNode.removeChild(c);if(!c.isContentEditable){l=this._addNodeTracking(c,!1,!0),o=document.createTextNode("");return c.parentNode.insertBefore(o,c),e.selectNode(o),e.collapse(!0),l}if(this._handleVoidEl(c,e))return!0;if(ice.dom.isStubElement(c)&&ice.dom.isChildOf(c,n)||!c.isContentEditable)return this._addNodeTracking(c,e,!0);if(ice.dom.isStubElement(c))return ice.dom.remove(c),e.collapse(!0),!1;if(c!==n&&!ice.dom.isChildOf(c,n)){if((c=!ice.dom.canContainTextElement(c)?c.lastElementChild:c).lastChild&&c.lastChild.nodeType!==ice.dom.TEXT_NODE&&ice.dom.isStubElement(c.lastChild)&&"BR"!==c.lastChild.tagName)return e.setStartAfter(c.lastChild),e.collapse(!0),!0;if((t=e.getLastSelectableChild(c))&&!ice.dom.isOnBlockBoundary(e.startContainer,t,this.element))return e.selectNodeContents(t),e.collapse(),!0}}if(1===s&&!ice.dom.isBlockElement(a)&&1<e.startContainer.childNodes.length&&e.startContainer.childNodes[0].nodeType===ice.dom.TEXT_NODE&&0===e.startContainer.childNodes[0].data.length)return e.setStart(e.startContainer,0),this._deleteLeft(e);if(e.moveStart(ice.dom.CHARACTER_UNIT,-1),e.moveStart(ice.dom.CHARACTER_UNIT,1),this._getNoTrackElement(e.startContainer.parentElement))return e.deleteContents(),!1;if(ice.dom.isOnBlockBoundary(e.startContainer,e.endContainer,this.element)){if(r)return ice.dom.remove(i),e.collapse(),!0;if(this.mergeBlocks&&ice.dom.is(ice.dom.getBlockParent(c,this.element),this.blockEl)){i&&i!==ice.dom.getBlockParent(e.startContainer,this.element)&&e.setStart(i,i.childNodes.length);for(var d=ice.dom.getElementsBetween(e.startContainer,e.endContainer),h=0;h<d.length;h++)ice.dom.remove(d[h]);r=e.startContainer,c=e.endContainer;return ice.dom.remove(ice.dom.find(r,"br")),ice.dom.remove(ice.dom.find(c,"br")),ice.dom.mergeBlockWithSibling(e,ice.dom.getBlockParent(e.endContainer,this.element)||n)}return i&&i.lastChild&&ice.dom.isStubElement(i.lastChild)?(e.setStartAfter(i.lastChild),e.collapse(!0),!0):((t=e.getLastSelectableChild(i))?(e.setStart(t,t.data.length),e.collapse(!0)):i&&(e.setStart(i,i.childNodes.length),e.collapse(!0)),!0)}i=e.startContainer.splitText(e.startOffset-1),i.splitText(1);return this._addNodeTracking(i,e,!0)},_addNodeTracking:function(e,t,n){var i=this.getIceNode(e,"insertType");if(i&&this._currentUserIceNode(i)){t&&n&&t.selectNode(e),e.parentNode.removeChild(e);var r=ice.dom.cloneNode(i);return ice.dom.remove(ice.dom.find(r,".iceBookmark")),null!==i&&ice.dom.hasNoTextOrStubContent(r[0])&&(r=this.env.document.createTextNode(""),ice.dom.insertBefore(i,r),t&&(t.setStart(r,0),t.collapse(!0)),ice.dom.replaceWith(i,ice.dom.contents(i))),!0}if(t&&this.getIceNode(e,"deleteType")){e.normalize();var o=!1;if(n){for(var s=ice.dom.getPrevContentNode(e,this.element);!o;)(c=this.getIceNode(s,"deleteType"))?s=ice.dom.getPrevContentNode(s,this.element):o=!0;return s&&(l=t.getLastSelectableChild(s),t.setStart(s=l?l:s,ice.dom.getNodeCharacterLength(s)),t.collapse(!0)),!0}for(var a=ice.dom.getNextContentNode(e,this.element);!o;)(c=this.getIceNode(a,"deleteType"))?a=ice.dom.getNextContentNode(a,this.element):o=!0;return a&&(t.selectNodeContents(a),t.collapse(!0)),!0}e.previousSibling&&e.previousSibling.nodeType===ice.dom.TEXT_NODE&&0===e.previousSibling.length&&e.parentNode.removeChild(e.previousSibling),e.nextSibling&&e.nextSibling.nodeType===ice.dom.TEXT_NODE&&0===e.nextSibling.length&&e.parentNode.removeChild(e.nextSibling);var c,i=this.getIceNode(e.previousSibling,"deleteType"),l=this.getIceNode(e.nextSibling,"deleteType");return i&&this._currentUserIceNode(i)?((c=i).appendChild(e),l&&this._currentUserIceNode(l)&&(i=ice.dom.extractContent(l),ice.dom.append(c,i),l.parentNode.removeChild(l))):l&&this._currentUserIceNode(l)?(c=l).insertBefore(e,c.firstChild):(c=this.createIceNode("deleteType"),e.parentNode.insertBefore(c,e),c.appendChild(e)),t&&(ice.dom.isStubElement(e)?t.selectNode(e):t.selectNodeContents(e),n?t.collapse(!0):t.collapse(),e.normalize()),!0},_handleAncillaryKey:function(e){var t=e.keyCode||e.which,n=ice.dom.browser(),i=!0,r=(e.shiftKey,this.getCurrentRange());switch(t){case ice.dom.DOM_VK_DELETE:i=this.deleteContents(),this.pluginsManager.fireKeyPressed(e);break;case 46:i=this.deleteContents(!0),this.pluginsManager.fireKeyPressed(e);break;case ice.dom.DOM_VK_DOWN:case ice.dom.DOM_VK_UP:case ice.dom.DOM_VK_LEFT:this.pluginsManager.fireCaretPositioned(),"mozilla"===n.type&&(this.visible(r.startContainer)||(r.startContainer.parentNode.previousSibling?(r.setEnd(r.startContainer.parentNode.previousSibling,0),r.moveEnd(ice.dom.CHARACTER_UNIT,ice.dom.getNodeCharacterLength(r.endContainer))):r.setEnd(r.startContainer.parentNode.nextSibling,0),r.collapse(!1))),i=!1;break;case ice.dom.DOM_VK_RIGHT:this.pluginsManager.fireCaretPositioned(),"mozilla"===n.type&&(this.visible(r.startContainer)||r.startContainer.parentNode.nextSibling&&(r.setStart(r.startContainer.parentNode.nextSibling,0),r.collapse(!0))),i=!1;break;case 32:i=!0,r=this.getCurrentRange();this._moveRangeToValidTrackingPos(r,r.startContainer),this.insert("\xa0",r),r=this.getCurrentRange(),this._moveRangeToValidTrackingPos(r,r.startContainer),this.insert("\u200b",r);break;default:i=!1}return!0!==i||(ice.dom.preventDefault(e),!1)},keyDown:function(e){if(!this.pluginsManager.fireKeyDown(e))return ice.dom.preventDefault(e),!1;var t=!1;return!1===this._handleSpecialKey(e)?(!0!==ice.dom.isBrowser("msie")&&(this._preventKeyPress=!0),!1):!!(!0!==e.ctrlKey&&!0!==e.metaKey||!0!==ice.dom.isBrowser("msie")&&!0!==ice.dom.isBrowser("chrome")||this.pluginsManager.fireKeyPressed(e))&&(!(t=27!==e.keyCode?!this._handleAncillaryKey(e):t)||(ice.dom.preventDefault(e),!1))},keyPress:function(e){if(!0!==this._preventKeyPress){if(!this.pluginsManager.fireKeyPress(e))return!1;var t=null;null==e.which?t=String.fromCharCode(e.keyCode):0<e.which&&(t=String.fromCharCode(e.which));var n=this.getCurrentRange(),i=ice.dom.parents(n.startContainer,"br")[0]||null;if(i&&(n.moveToNextEl(i),i.parentNode.removeChild(i)),null!==t&&!0!==e.ctrlKey&&!0!==e.metaKey)switch(e.keyCode||e.which){case ice.dom.DOM_VK_DELETE:return this._handleAncillaryKey(e);case ice.dom.DOM_VK_ENTER:return this._handleEnter();case 32:return this._handleAncillaryKey(e);default:return this._moveRangeToValidTrackingPos(n,n.startContainer),this.insert(e.key)}return this._handleAncillaryKey(e)}this._preventKeyPress=!1},_handleEnter:function(){return this.getCurrentRange().collapsed||this.deleteContents(),!0},_handleSpecialKey:function(e){var t,n,i=e.which,r=!1;return 65===(i=null===i?e.keyCode:i)&&(!0!==e.ctrlKey&&!0!==e.metaKey||(r=!0,t=this.getCurrentRange(),!0===ice.dom.isBrowser("msie")?(i=this.env.document.createTextNode(""),n=this.env.document.createTextNode(""),this.element.firstChild?ice.dom.insertBefore(this.element.firstChild,i):this.element.appendChild(i),this.element.appendChild(n),t.setStart(i,0),t.setEnd(n,0)):(t.setStart(t.getFirstSelectableChild(this.element),0),n=t.getLastSelectableChild(this.element),t.setEnd(n,n.length)),this.selection.addRange(t))),!0!==r||(ice.dom.preventDefault(e),!1)},mouseUp:function(e,t){if(!this.pluginsManager.fireClicked(e))return!1;this.pluginsManager.fireSelectionChanged(this.getCurrentRange())},mouseDown:function(e,t){if(!this.pluginsManager.fireMouseDown(e))return!1;this.pluginsManager.fireCaretUpdated()}},this.ice=this.ice||{},this.ice.InlineChangeEditor=e}.call(this),function(){var i=null,h={DOM_VK_DELETE:8,DOM_VK_LEFT:37,DOM_VK_UP:38,DOM_VK_RIGHT:39,DOM_VK_DOWN:40,DOM_VK_ENTER:13,ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12,CHARACTER_UNIT:"character",WORD_UNIT:"word",BREAK_ELEMENT:"br",CONTENT_STUB_ELEMENTS:["img","hr","br","iframe","param","link","meta","input","frame","col","base","area"],BLOCK_ELEMENTS:["p","div","pre","ul","ol","li","table","tbody","td","th","fieldset","form","blockquote","dl","dt","dd","dir","center","address","h1","h2","h3","h4","h5","h6"],TEXT_CONTAINER_ELEMENTS:["p","div","pre","li","td","th","blockquote","dt","dd","center","address","h1","h2","h3","h4","h5","h6"]};h.STUB_ELEMENTS=h.CONTENT_STUB_ELEMENTS.slice(),h.STUB_ELEMENTS.push(h.BREAK_ELEMENT),h.getKeyChar=function(e){return String.fromCharCode(e.which)},h.getClass=function(e,t,n){return t=t||document.body,e="."+e.split(" ").join("."),n&&(e=n+e),jQuery.makeArray(jQuery(t).find(e))},h.getId=function(e,t){return t=t||document,element=t.getElementById(e),element},h.getTag=function(e,t){return t=t||document,jQuery.makeArray(jQuery(t).find(e))},h.getElementWidth=function(e){return e.offsetWidth},h.getElementHeight=function(e){return e.offsetHeight},h.getElementDimensions=function(e){return{width:h.getElementWidth(e),height:h.getElementHeight(e)}},h.trim=function(e){return jQuery.trim(e)},h.empty=function(e){if(e)return jQuery(e).empty()},h.remove=function(e){if(e)return jQuery(e).remove()},h.prepend=function(e,t){jQuery(e).prepend(t)},h.append=function(e,t){jQuery(e).append(t)},h.insertBefore=function(e,t){jQuery(e).before(t)},h.insertAfter=function(e,t){jQuery(e).after(t)},h.getHtml=function(e){return jQuery(e).html()},h.setHtml=function(e,t){e&&jQuery(e).html(t)},h.removeWhitespace=function(e){jQuery(e).contents().filter(function(){return this.nodeType!=ice.dom.TEXT_NODE&&"UL"==this.nodeName||"OL"==this.nodeName?(h.removeWhitespace(this),!1):this.nodeType==ice.dom.TEXT_NODE&&!/\S/.test(this.nodeValue)}).remove()},h.contents=function(e){return jQuery.makeArray(jQuery(e).contents())},h.extractContent=function(e){for(var t,n=document.createDocumentFragment();t=e.firstChild;)n.appendChild(t);return n},h.getNode=function(e,t){return h.is(e,t)?e:h.parents(e,t)[0]||null},h.getParents=function(e,t,n){for(var i=jQuery(e).parents(t),r=i.length,o=[],s=0;s<r&&i[s]!==n;s++)o.push(i[s]);return o},h.hasBlockChildren=function(e){for(var t=e.childNodes.length,n=0;n<t;n++)if(e.childNodes[n].nodeType===h.ELEMENT_NODE&&!0===h.isBlockElement(e.childNodes[n]))return!0;return!1},h.removeTag=function(e,t){return jQuery(e).find(t).replaceWith(function(){return jQuery(this).contents()}),e},h.stripEnclosingTags=function(e,t){e=jQuery(e);return e.find("*").not(t).replaceWith(function(){var e,t=jQuery();try{t=(e=jQuery(this)).contents()}catch(e){}return 0===t.length&&e.remove(),t}),e[0]},h.getSiblings=function(e,t,n,i){if(!0===n)return"prev"===t?jQuery(e).prevAll():jQuery(e).nextAll();var r=[];if("prev"===t)for(;e.previousSibling&&(e=e.previousSibling)!==i;)r.push(e);else for(;e.nextSibling&&(e=e.nextSibling)!==i;)r.push(e);return r},h.getNodeTextContent=function(e){return jQuery(e).text()},h.getNodeStubContent=function(e){return jQuery(e).find(h.CONTENT_STUB_ELEMENTS.join(", "))},h.hasNoTextOrStubContent=function(e){return!(0<h.getNodeTextContent(e).length)&&!(0<jQuery(e).find(h.CONTENT_STUB_ELEMENTS.join(", ")).length)},h.getNodeCharacterLength=function(e){return h.getNodeTextContent(e).length+jQuery(e).find(h.STUB_ELEMENTS.join(", ")).length},h.setNodeTextContent=function(e,t){return jQuery(e).text(t)},h.getTagName=function(e){return e.tagName&&e.tagName.toLowerCase()||null},h.getIframeDocument=function(e){var t=null;return e.contentDocument?t=e.contentDocument:e.contentWindow?t=e.contentWindow.document:e.document&&(t=e.document),t},h.isBlockElement=function(e){return-1!=h.BLOCK_ELEMENTS.lastIndexOf(e.nodeName.toLowerCase())},h.isStubElement=function(e){return-1!=h.STUB_ELEMENTS.lastIndexOf(e.nodeName.toLowerCase())},h.removeBRFromChild=function(e){if(e&&e.hasChildNodes())for(var t=0;t<e.childNodes.length;t++){var n=e.childNodes[t];n&&ice.dom.BREAK_ELEMENT==ice.dom.getTagName(n)&&n.parentNode.removeChild(n)}},h.isChildOf=function(e,t){try{for(;e&&e.parentNode;){if(e.parentNode===t)return!0;e=e.parentNode}}catch(e){}return!1},h.isChildOfTagName=function(e,t){try{for(;e&&e.parentNode;){if(e.parentNode&&e.parentNode.tagName&&e.parentNode.tagName.toLowerCase()===t)return e.parentNode;e=e.parentNode}}catch(e){}return!1},h.isChildOfTagNames=function(e,t){try{for(;e&&e.parentNode;){if(e.parentNode&&e.parentNode.tagName){tagName=e.parentNode.tagName.toLowerCase();for(var n=0;n<t.length;n++)if(tagName===t[n])return e.parentNode}e=e.parentNode}}catch(e){}return null},h.isChildOfClassName=function(e,t){try{for(;e&&e.parentNode;){if(jQuery(e.parentNode).hasClass(t))return e.parentNode;e=e.parentNode}}catch(e){}return null},h.cloneNode=function(e,t){return void 0===t&&(t=!0),jQuery(e).clone(t)},h.bind=function(e,t,n){return jQuery(e).bind(t,n)},h.unbind=function(e,t,n){return jQuery(e).unbind(t,n)},h.attr=function(e,t,n){return n?jQuery(e).attr(t,n):jQuery(e).attr(t)},h.replaceWith=function(e,t){return jQuery(e).replaceWith(t)},h.removeAttr=function(e,t){jQuery(e).removeAttr(t)},h.getElementsBetween=function(e,t){var n=[];if(e===t)return n;if(!0===h.isChildOf(t,e)){for(var i=e.childNodes.length,r=0;r<i&&e.childNodes[r]!==t;r++){if(!0===h.isChildOf(t,e.childNodes[r]))return h.arrayMerge(n,h.getElementsBetween(e.childNodes[r],t));n.push(e.childNodes[r])}return n}for(var o=e.nextSibling;o;){if(!0===h.isChildOf(t,o))return n=h.arrayMerge(n,h.getElementsBetween(o,t));if(o===t)return n;n.push(o),o=o.nextSibling}for(var s=h.getParents(e),a=h.getParents(t),c=h.arrayDiff(s,a,!0),l=c.length,d=0;d<l-1;d++)n=h.arrayMerge(n,h.getSiblings(c[d],"next"));a=c[c.length-1];return n=h.arrayMerge(n,h.getElementsBetween(a,t))},h.getCommonAncestor=function(e,t){for(var n=e;n;){if(!0===h.isChildOf(t,n))return n;n=n.parentNode}return null},h.getNextNode=function(e,t){if(e)for(;e.parentNode;){if(e===t)return null;if(e.nextSibling){if(e.nextSibling.nodeType!==h.TEXT_NODE||0!==e.nextSibling.length)return h.getFirstChild(e.nextSibling);e=e.nextSibling}else e=e.parentNode}return null},h.getNextContentNode=function(e,t){if(e)for(;e.parentNode;){if(e===t)return null;if(e.nextSibling&&h.canContainTextElement(h.getBlockParent(e))){if(e.nextSibling.nodeType!==h.TEXT_NODE||0!==e.nextSibling.length)return e.nextSibling;e=e.nextSibling}else{if(e.nextElementSibling)return e.nextElementSibling;e=e.parentNode}}return null},h.getPrevNode=function(e,t){if(e)for(;e.parentNode;){if(e===t)return null;if(e.previousSibling){if(e.previousSibling.nodeType!==h.TEXT_NODE||0!==e.previousSibling.length)return h.getLastChild(e.previousSibling);e=e.previousSibling}else e=e.parentNode}return null},h.getPrevContentNode=function(e,t){if(e)for(;e.parentNode;){if(e===t)return null;if(e.previousSibling&&h.canContainTextElement(h.getBlockParent(e))){if(e.previousSibling.nodeType!==h.TEXT_NODE||0!==e.previousSibling.length)return e.previousSibling;e=e.previousSibling}else{if(e.previousElementSibling)return e.previousElementSibling;e=e.parentNode}}return null},h.canContainTextElement=function(e){return!(!e||!e.nodeName)&&-1!=h.TEXT_CONTAINER_ELEMENTS.lastIndexOf(e.nodeName.toLowerCase())},h.getFirstChild=function(e){return e.firstChild?e.firstChild.nodeType===h.ELEMENT_NODE?h.getFirstChild(e.firstChild):e.firstChild:e},h.getLastChild=function(e){return e.lastChild?e.lastChild.nodeType===h.ELEMENT_NODE?h.getLastChild(e.lastChild):e.lastChild:e},h.removeEmptyNodes=function(e,t){for(var n=jQuery(e).find(":empty"),i=n.length;0<i;)!1===h.isStubElement(n[--i])&&(t&&!1===t.call(this,n[i])||h.remove(n[i]))},h.create=function(e){return jQuery(e)[0]},h.find=function(e,t){return jQuery(e).find(t)},h.children=function(e,t){return jQuery(e).children(t)},h.parent=function(e,t){return jQuery(e).parent(t)[0]},h.parents=function(e,t){return jQuery(e).parents(t)},h.is=function(e,t){return jQuery(e).is(t)},h.extend=function(e,t,n,i){return jQuery.extend.apply(this,arguments)},h.walk=function(e,t,n){e&&!1!==t.call(this,e,n=n||0)&&(e.childNodes&&0<e.childNodes.length?h.walk(e.firstChild,t,n+1):e.nextSibling?h.walk(e.nextSibling,t,n):e.parentNode&&e.parentNode.nextSibling&&h.walk(e.parentNode.nextSibling,t,n-1))},h.revWalk=function(e,t){e&&!1!==t.call(this,e)&&(e.childNodes&&0<e.childNodes.length?h.walk(e.lastChild,t):e.previousSibling?h.walk(e.previousSibling,t):e.parentNode&&e.parentNode.previousSibling&&h.walk(e.parentNode.previousSibling,t))},h.setStyle=function(e,t,n){e&&jQuery(e).css(t,n)},h.getStyle=function(e,t){return jQuery(e).css(t)},h.hasClass=function(e,t){return jQuery(e).hasClass(t)},h.addClass=function(e,t){jQuery(e).addClass(t)},h.removeClass=function(e,t){jQuery(e).removeClass(t)},h.preventDefault=function(e){e.preventDefault(),h.stopPropagation(e)},h.stopPropagation=function(e){e.stopPropagation()},h.noInclusionInherits=function(e,t){(t instanceof String||"string"==typeof t)&&(t=window[t]),(e instanceof String||"string"==typeof e)&&(e=window[e]);function n(){}if(!0===h.isset(t))for(var i in t.prototype)e.prototype[i]?n.prototype[i]=t.prototype[i]:e.prototype[i]=t.prototype[i];e.prototype&&(n.prototype.constructor=t,e.prototype.super=new n)},h.each=function(e,n){jQuery.each(e,function(e,t){n.call(this,e,t)})},h.foreach=function(e,t){if(e instanceof Array||e instanceof NodeList||void 0!==e.length&&void 0!==e.item){for(var n=e.length,i=0;i<n;i++)if(!1===t.call(this,i,e[i]))break}else for(var r in e)if(!0===e.hasOwnProperty(r))if(!1===t.call(this,r))break},h.isBlank=function(e){return!(e&&!/^\s*$/.test(e))},h.isFn=function(e){return"function"==typeof e},h.isObj=function(e){return null!==e&&"object"==typeof e},h.isset=function(e){return null!=e},h.isArray=function(e){return jQuery.isArray(e)},h.isNumeric=function(e){return null!==e.match(/^\d+$/)},h.getUniqueId=function(){return((new Date).getTime()+""+Math.ceil(1e6*Math.random())).substr(5,18).replace(/,/,"")},h.inArray=function(e,t){for(var n=t.length,i=0;i<n;i++)if(e===t[i])return!0;return!1},h.arrayDiff=function(e,t,n){for(var i=e.length,r=[],o=0;o<i;o++)!1===h.inArray(e[o],t)&&r.push(e[o]);if(!0!==n)for(var i=t.length,s=0;s<i;s++)!1===h.inArray(t[s],e)&&r.push(t[s]);return r},h.arrayMerge=function(e,t){for(var n=t.length,i=0;i<n;i++)e.push(t[i]);return e},h.stripTags=function(e,t){if("string"==typeof t){var n=jQuery("<div>"+e+"</div>");return n.find("*").not(t).remove(),n.html()}for(var i,r=new RegExp(/<\/?(\w+)((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim),o=e;null!=(i=r.exec(e));)!1!==h.isset(t)&&!0===h.inArray(i[1],t)||(o=o.replace(i[0],""));return o},h.browser=function(){return i||(e=navigator.userAgent.toLowerCase(),n=(n=e).toLowerCase(),t={browser:(n=/(chrome)[ \/]([\w.]+)/.exec(n)||/(webkit)[ \/]([\w.]+)/.exec(n)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(n)||/(msie) ([\w.]+)/.exec(n)||n.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(n)||[])[1]||"",version:n[2]||"0"},n={type:"unknown",version:0,msie:!1},t.browser&&(n[t.browser]=!0,n.version=t.version||0,n.type=t.browser),n.chrome?n.webkit=!0:n.webkit&&(n.safari=!0),n.webkit&&(n.type="webkit"),n.firefox=1==/firefox/.test(e),n.msie||(n.msie=!!/trident/.test(e)),i=n),$.extend({},i);var e,t,n},h.getBrowserType=function(){if(null===this._browserType){for(var e=["msie","firefox","chrome","safari"],t=e.length,n=0;n<t;n++)if(!0===new RegExp(e[n],"i").test(navigator.userAgent))return this._browserType=e[n],this._browserType;this._browserType="other"}return this._browserType},h.getWebkitType=function(){return"webkit"!==h.browser().type?(console.log("Not a webkit!"),!1):0<Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")?"safari":"chrome"},h.isBrowser=function(e){return h.browser().type===e},h.getBlockParent=function(e,t){if(!0===h.isBlockElement(e))return e;if(e)for(;e.parentNode;){if((e=e.parentNode)===t)return null;if(!0===h.isBlockElement(e))return e}return null},h.findNodeParent=function(e,t,n){if(e)for(;e.parentNode;){if(e===n)return null;if(!0===h.is(e,t))return e;e=e.parentNode}return null},h.onBlockBoundary=function(e,t,n){return!(!e||!t)&&(h.isChildOfTagNames(e,n)||h.is(e,n.join(", "))&&e||null)!==(h.isChildOfTagNames(t,n)||h.is(t,n.join(", "))&&t||null)},h.isOnBlockBoundary=function(e,t,n){return!(!e||!t)&&(h.getBlockParent(e,n)||h.isBlockElement(e,n)&&e||null)!==(h.getBlockParent(t,n)||h.isBlockElement(t,n)&&t||null)},h.mergeContainers=function(e,t){if(!e||!t)return!1;if(e.nodeType===h.TEXT_NODE||h.isStubElement(e))t.appendChild(e);else if(e.nodeType===h.ELEMENT_NODE){for(;e.firstChild;)t.appendChild(e.firstChild);h.remove(e)}return!0},h.mergeBlockWithSibling=function(e,t,n){var i=(n?jQuery(t).next():jQuery(t).prev()).get(0);return n?h.mergeContainers(i,t):h.mergeContainers(t,i),e.collapse(!0),!0},h.date=function(e,t,n){if(null!==t||!n||(t=h.tsIso8601ToTimestamp(n))){for(var i=new Date(t),r=e.split(""),o=r.length,s="",a=0;a<o;a++){var c="",l=r[a];switch(l){case"D":case"l":c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][i.getDay()];"D"===l&&(c=c.substring(0,3));break;case"F":case"m":(c=i.getMonth()+1)<10&&(c="0"+c);break;case"M":months=["January","February","March","April","May","June","July","August","September","October","November","December"],c=months[i.getMonth()],"M"===l&&(c=c.substring(0,3));break;case"d":c=i.getDate();break;case"S":c=h.getOrdinalSuffix(i.getDate());break;case"Y":c=i.getFullYear();break;case"y":c=(c=i.getFullYear()).toString().substring(2);break;case"H":c=i.getHours();break;case"h":0===(c=i.getHours())?c=12:12<c&&(c-=12);break;case"i":c=h.addNumberPadding(i.getMinutes());break;case"a":c="am",12<=i.getHours()&&(c="pm");break;default:c=l}s+=c}return s}},h.getOrdinalSuffix=function(e){var t="",n=e%100;if(4<=n&&n<=20)t="th";else switch(e%10){case 1:t="st";break;case 2:t="nd";break;case 3:t="rd";break;default:t="th"}return t},h.addNumberPadding=function(e){return e=e<10?"0"+e:e},h.tsIso8601ToTimestamp=function(e){var t=e.match(new RegExp(/(\d\d\d\d)(?:-?(\d\d)(?:-?(\d\d)(?:[T ](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(?:Z|(?:([-+])(\d\d)(?::?(\d\d))?)?)?)?)?)?/));if(t){var n=new Date;n.setDate(t[3]),n.setFullYear(t[1]),n.setMonth(t[2]-1),n.setHours(t[4]),n.setMinutes(t[5]),n.setSeconds(t[6]);e=60*t[9];return"+"===t[8]&&(e*=-1),e-=n.getTimezoneOffset(),n.getTime()+60*e*1e3}return null},this.dom=h}.call(this.ice),function(){var e=function(t,e,n){this.env=t,this.element=t.element,this.selection=this.env.selection,n||this.removeBookmarks(this.element);var i,r=e||this.selection.getRangeAt(0),o=(e=r.cloneRange()).startContainer,t=(e.endContainer,e.startOffset);e.endOffset;e.collapse(!1);n=this.env.document.createElement("span");n.style.display="none",ice.dom.setHtml(n," "),ice.dom.addClass(n,"iceBookmark iceBookmark_end"),n.setAttribute("iceBookmark","end"),e.insertNode(n),ice.dom.isChildOf(n,this.element)||this.element.appendChild(n),e.setStart(o,t),e.collapse(!0);t=this.env.document.createElement("span");t.style.display="none",ice.dom.addClass(t,"iceBookmark iceBookmark_start"),ice.dom.setHtml(t," "),t.setAttribute("iceBookmark","start");try{e.insertNode(t),t.previousSibling===n&&(i=t,t=n,n=i)}catch(e){ice.dom.insertBefore(n,t)}!1===ice.dom.isChildOf(t,this.element)&&(this.element.firstChild?ice.dom.insertBefore(this.element.firstChild,t):this.element.appendChild(t)),n.previousSibling||(i=this.env.document.createTextNode(""),ice.dom.insertBefore(n,i)),t.nextSibling||(i=this.env.document.createTextNode(""),ice.dom.insertAfter(t,i)),r.setStart(t.nextSibling,0),r.setEnd(n.previousSibling,n.previousSibling.length||0),this.start=t,this.end=n};e.prototype={selectBookmark:function(){var e,t=this.selection.getRangeAt(0),n=null,i=null,r=0,o=null;this.start.nextSibling===this.end||0===ice.dom.getElementsBetween(this.start,this.end).length?this.end.nextSibling?n=ice.dom.getFirstChild(this.end.nextSibling):this.start.previousSibling?(n=ice.dom.getFirstChild(this.start.previousSibling)).nodeType===ice.dom.TEXT_NODE&&(r=n.length):(this.end.parentNode.appendChild(this.env.document.createTextNode("")),n=ice.dom.getFirstChild(this.end.nextSibling)):(this.start.nextSibling?n=ice.dom.getFirstChild(this.start.nextSibling):(this.start.previousSibling||(e=this.env.document.createTextNode(""),ice.dom.insertBefore(this.start,e)),r=(n=ice.dom.getLastChild(this.start.previousSibling)).length),this.end.previousSibling?i=ice.dom.getLastChild(this.end.previousSibling):(i=ice.dom.getFirstChild(this.end.nextSibling||this.end),o=0)),ice.dom.remove([this.start,this.end]),null===i?(t.setEnd(n,r),t.collapse(!1)):(t.setStart(n,r),null===o&&(o=i.length||0),t.setEnd(i,o));try{this.selection.addRange(t)}catch(e){}},getBookmark:function(e,t){return ice.dom.getClass("iceBookmark_"+t,e)[0]},removeBookmarks:function(e){ice.dom.remove(ice.dom.getClass("iceBookmark",e,"span"))}},this.Bookmark=e}.call(this.ice),function(){var e=function(e){this._selection=null,this.env=e,this._initializeRangeLibrary(),this._getSelection()};e.prototype={_getSelection:function(){return this._selection?this._selection.refresh():this.env.frame?this._selection=rangy.getIframeSelection(this.env.frame):this._selection=rangy.getSelection(),this._selection},createRange:function(){return rangy.createRange(this.env.document)},getRangeAt:function(e){this._selection.refresh();try{return this._selection.getRangeAt(e)}catch(e){return this._selection=null,this._getSelection().getRangeAt(0)}},addRange:function(e){this._selection||(this._selection=this._getSelection()),this._selection.setSingleRange(e),this._selection.ranges=[e]},_initializeRangeLibrary:function(){var n=this;rangy.init(),rangy.config.checkSelectionRanges=!1;function i(e,t,n,i){if(0!==n)switch(t){case ice.dom.CHARACTER_UNIT:0<n?e.moveCharRight(i,n):e.moveCharLeft(i,-1*n);break;case ice.dom.WORD_UNIT:}}rangy.rangePrototype.moveStart=function(e,t){i(this,e,t,!0)},rangy.rangePrototype.moveEnd=function(e,t){i(this,e,t,!1)},rangy.rangePrototype.setRange=function(e,t,n){e?this.setStart(t,n):this.setEnd(t,n)},rangy.rangePrototype.moveCharLeft=function(e,t){var n=e?(i=this.startContainer,this.startOffset):(i=this.endContainer,this.endOffset);if(i.nodeType===ice.dom.ELEMENT_NODE&&" "!==i.innerHTML)if(i.hasChildNodes()&&i.childNodes[n]){for(i=i.childNodes[n],i=this.getPreviousTextNode(i);i&&i.nodeType==ice.dom.TEXT_NODE&&""===i.nodeValue;)i=this.getPreviousTextNode(i);n=i.data.length-t}else n=-1*t;else n-=t;if(n<0)for(;n<0;){var i;if(!(i=this.getPreviousTextNode(i,[])))return;i.nodeType!==ice.dom.ELEMENT_NODE&&(n+=i.data.length)}this.setRange(e,i,n)},rangy.rangePrototype.moveCharRight=function(e,t){var n,i=e?(n=this.startContainer,this.startOffset):(n=this.endContainer,this.endOffset);n.nodeType===ice.dom.ELEMENT_NODE?((n=n.childNodes[i]).nodeType!==ice.dom.TEXT_NODE&&(n=this.getNextTextNode(n)),i=t):i+=t;var r=i-n.data.length;if(0<r){for(var o=[];0<r;)if((n=this.getNextContainer(n,o)).nodeType!==ice.dom.ELEMENT_NODE){if(n.data.length>=r)break;0<n.data.length&&(r-=n.data.length)}i=r}this.setRange(e,n,i)},rangy.rangePrototype.getNextContainer=function(e,t){if(!e)return null;for(;e.nextSibling;)if((e=e.nextSibling).nodeType!==ice.dom.TEXT_NODE){var n=this.getFirstSelectableChild(e);if(null!==n)return n}else if(!0===this.isSelectable(e))return e;for(;e&&!e.nextSibling;)e=e.parentNode;if(!e)return null;if(e=e.nextSibling,!0===this.isSelectable(e))return e;t&&!0===ice.dom.isBlockElement(e)&&t.push(e);var i=this.getFirstSelectableChild(e);return null!==i?i:this.getNextContainer(e,t)},rangy.rangePrototype.getPreviousContainer=function(e,t){if(!e)return null;for(;e.previousSibling;)if((e=e.previousSibling).nodeType!==ice.dom.TEXT_NODE){if(!0===ice.dom.isStubElement(e))return e;var n=this.getLastSelectableChild(e);if(null!==n)return n}else if(!0===this.isSelectable(e))return e;for(;e&&!e.previousSibling;)e=e.parentNode;if(!e)return null;if(e=e.previousSibling,!0===this.isSelectable(e))return e;t&&!0===ice.dom.isBlockElement(e)&&t.push(e);var i=this.getLastSelectableChild(e);return null!==i?i:this.getPreviousContainer(e,t)},rangy.rangePrototype.getNextTextNode=function(e){return e.nodeType===ice.dom.ELEMENT_NODE&&0!==e.childNodes.length?this.getFirstSelectableChild(e):(e=this.getNextContainer(e)).nodeType===ice.dom.TEXT_NODE?e:this.getNextTextNode(e)},rangy.rangePrototype.getPreviousTextNode=function(e,t){return(e=this.getPreviousContainer(e,t)).nodeType===ice.dom.TEXT_NODE?e:this.getPreviousTextNode(e,t)},rangy.rangePrototype.getFirstSelectableChild=function(e){if(e){if(e.nodeType===ice.dom.TEXT_NODE)return e;for(var t=e.firstChild;t;){if(!0===this.isSelectable(t))return t;if(t.firstChild){var n=this.getFirstSelectableChild(t);if(null!==n)return n;t=t.nextSibling}else t=t.nextSibling}}return null},rangy.rangePrototype.getLastSelectableChild=function(e){if(e){if(e.nodeType===ice.dom.TEXT_NODE)return e;for(var t=e.lastChild;t;){if(!0===this.isSelectable(t))return t;if(t.lastChild){var n=this.getLastSelectableChild(t);if(null!==n)return n;t=t.previousSibling}else t=t.previousSibling}}return null},rangy.rangePrototype.isSelectable=function(e){return!(!e||e.nodeType!==ice.dom.TEXT_NODE||0===e.data.length)},rangy.rangePrototype.getHTMLContents=function(e){e=e||this.cloneContents();var t=n.env.document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML},rangy.rangePrototype.getHTMLContentsObj=function(){return this.cloneContents()}}},this.Selection=e}.call(this.ice),function(){function e(e){this._ice=e}e.prototype={start:function(){},clicked:function(e){return!0},mouseDown:function(e){return!0},keyDown:function(e){return!0},keyPress:function(e){return!0},selectionChanged:function(e){},setEnabled:function(e){},setDisabled:function(e){},caretUpdated:function(){},nodeInserted:function(e,t){},nodeCreated:function(e,t){},caretPositioned:function(){},remove:function(){this._ice.removeKeyPressListener(this)},setSettings:function(e){}},this.IcePlugin=e}.call(this.ice),function(){function e(e){this.plugins={},this.pluginConstructors={},this.keyPressListeners={},this.activePlugin=null,this.pluginSets={},this.activePluginSet=null,this._ice=e}e.prototype={getPluginNames:function(){var e,t=[];for(e in this.plugins)t.push(e);return t},addPluginObject:function(e,t){this.plugins[e]=t},addPlugin:function(e,t){if("function"!=typeof t)throw Error("IcePluginException: plugin must be a constructor function");!1===ice.dom.isset(this.pluginConstructors[e])&&(this.pluginConstructors[e]=t)},loadPlugins:function(e,t){if(0===e.length)t.call(this);else{var n=e.shift();if("object"==typeof n&&(n=n.name),!0!==ice.dom.isset(ice._plugin[n]))throw new Error("plugin was not included in the page: "+n);this.addPlugin(n,ice._plugin[n]),this.loadPlugins(e,t)}},_enableSet:function(e){this.activePluginSet=e;for(var t=this.pluginSets[e].length,n=0;n<t;n++){var i=this.pluginSets[e][n],r="",r="object"==typeof i?i.name:i,o=this.pluginConstructors[r];o&&(o=new o(this._ice),this.plugins[r]=o,!0===ice.dom.isset(i.settings)&&o.setSettings(i.settings),o.start())}},setActivePlugin:function(e){this.activePlugin=e},getActivePlugin:function(){return this.activePlugin},_getPluginName:function(e){var t=e.toString(),e="function ".length;return t.substr(e,t.indexOf("(")-e)},removePlugin:function(e){this.plugins[e]&&this.plugins[e].remove()},getPlugin:function(e){return this.plugins[e]},usePlugins:function(e,t,n){var i=this;!0===ice.dom.isset(t)?this.pluginSets[e]=t:this.pluginSets[e]=[];t=this.pluginSets[e].concat([]);this.loadPlugins(t,function(){i._enableSet(e),n&&n.call(this)})},disablePlugin:function(e){this.plugins[e].disable()},isPluginElement:function(e){for(var t in this.plugins)if(this.plugins[t].isPluginElement&&!0===this.plugins[t].isPluginElement(e))return!0;return!1},fireKeyPressed:function(e){if(!1===this._fireKeyPressFns(e,"all_keys"))return!1;var t,n=[];switch(!0!==e.ctrlKey&&!0!==e.metaKey||n.push("ctrl"),!0===e.shiftKey&&n.push("shift"),!0===e.altKey&&n.push("alt"),e.keyCode){case 13:n.push("enter");break;case ice.dom.DOM_VK_LEFT:n.push("left");break;case ice.dom.DOM_VK_RIGHT:n.push("right");break;case ice.dom.DOM_VK_UP:n.push("up");break;case ice.dom.DOM_VK_DOWN:n.push("down");break;case 9:n.push("tab");break;case ice.dom.DOM_VK_DELETE:n.push("delete");break;default:e.keyCode?t=e.keyCode:e.which&&(t=e.which),t&&n.push(String.fromCharCode(t).toLowerCase())}var i=n.sort().join("+");return this._fireKeyPressFns(e,i)},_fireKeyPressFns:function(e,t){if(this.keyPressListeners[t])for(var n=this.keyPressListeners[t].length,i=0;i<n;i++){var r=this.keyPressListeners[t][i],o=r.fn,s=r.plugin,r=r.data;if(o)if(!0===ice.dom.isFn(o)){if(!0===o.call(s,e,r))return ice.dom.preventDefault(e),!1}else if(s[o]&&!0===s[o].call(s,e,r))return ice.dom.preventDefault(e),!1}return!0},fireSelectionChanged:function(e){for(var t in this.plugins)this.plugins[t].selectionChanged(e)},fireNodeInserted:function(e,t){for(var n in this.plugins)if(!1===this.plugins[n].nodeInserted(e,t))return!1},fireNodeCreated:function(e,t){for(var n in this.plugins)if(!1===this.plugins[n].nodeCreated(e,t))return!1},fireCaretPositioned:function(){for(var e in this.plugins)this.plugins[e].caretPositioned()},fireClicked:function(e){var t,n=!0;for(t in this.plugins)!1===this.plugins[t].clicked(e)&&(n=!1);return n},fireMouseDown:function(e){var t,n=!0;for(t in this.plugins)!1===this.plugins[t].mouseDown(e)&&(n=!1);return n},fireKeyDown:function(e){var t,n=!0;for(t in this.plugins)!1===this.plugins[t].keyDown(e)&&(n=!1);return n},fireKeyPress:function(e){var t,n=!0;for(t in this.plugins)!1===this.plugins[t].keyPress(e)&&(n=!1);return n},fireEnabled:function(e){for(var t in this.plugins)this.plugins[t].setEnabled(e)},fireDisabled:function(e){for(var t in this.plugins)this.plugins[t].setDisabled(e)},fireCaretUpdated:function(){for(var e in this.plugins)this.plugins[e].caretUpdated&&this.plugins[e].caretUpdated()}},this._plugin={},this.IcePluginManager=e}.call(this.ice),function(){var e=function(e){this._ice=e};e.prototype={nodeCreated:function(e,t){e.setAttribute("title",(t.action||"Modified")+" by "+e.getAttribute(this._ice.userNameAttribute)+" - "+ice.dom.date("m/d/Y h:ia",parseInt(e.getAttribute(this._ice.timeAttribute))))}},ice.dom.noInclusionInherits(e,ice.IcePlugin),this._plugin.IceAddTitlePlugin=e}.call(this.ice),function(){var e=function(e){this._ice=e,this._tmpNode=null,this._tmpNodeTagName="icepaste",this._pasteId="icepastediv";var t=this;this.pasteType="formattedClean",this.preserve="p",this.beforePasteClean=function(e){return e},this.afterPasteClean=function(e){return e},e.element.oncopy=function(){return t.handleCopy.apply(t)}};e.prototype={setSettings:function(e){e=e||{},ice.dom.extend(this,e),this.preserve+=","+this._tmpNodeTagName,this.setupPreserved()},keyDown:function(e){if(!0===e.metaKey||!0===e.ctrlKey)return 86==e.keyCode?this.handlePaste():88==e.keyCode&&this.handleCut(),!0},handleCopy:function(e){},handlePaste:function(e){var t,n=this._ice.getCurrentRange();switch(n.collapsed||(this._ice.isTracking?(this._ice.deleteContents(),n=n.cloneRange()):(n.deleteContents(),n.collapse(!0))),this._ice.isTracking&&this._ice._moveRangeToValidTrackingPos(n),n.startContainer==this._ice.element&&((t=ice.dom.find(this._ice.element,this._ice.blockEl)[0])||(t=ice.dom.create("<"+this._ice.blockEl+" ><br/></"+this._ice.blockEl+">"),this._ice.element.appendChild(t)),n.setStart(t,0),n.collapse(!0),this._ice.env.selection.addRange(n)),this._tmpNode=this._ice.env.document.createElement(this._tmpNodeTagName),n.insertNode(this._tmpNode),this.pasteType){case"formatted":this.setupPaste();break;case"formattedClean":this.setupPaste(!0)}return!0},setupPaste:function(t){var e=this.createDiv(this._pasteId),n=this,i=this._ice.getCurrentRange();return i.selectNodeContents(e),this._ice.selection.addRange(i),e.onpaste=function(e){setTimeout(function(){n.handlePasteValue(t)},0),e.stopPropagation()},e.focus(),!0},handlePasteValue:function(e){var t=this._ice.env.document,n=t.getElementById(this._pasteId),i=ice.dom.getHtml(n),r=ice.dom.children("<div>"+i+"</div>",this._ice.blockEl);1===r.length&&ice.dom.getNodeTextContent("<div>"+i+"</div>")===ice.dom.getNodeTextContent(r)&&(i=ice.dom.getHtml(i)),i=this.beforePasteClean.call(this,i),e&&(i=this._ice.getCleanContent(i),i=this.stripPaste(i)),i=this.afterPasteClean.call(this,i);var i=ice.dom.trim(i),o=this._ice.getCurrentRange();o.setStartAfter(this._tmpNode),o.collapse(!0);var s,a=null,c=null,l=null,d=o.createContextualFragment(i),h=this._ice.startBatchChange();if(ice.dom.hasBlockChildren(d)){r=ice.dom.isChildOfTagName(this._tmpNode,this._ice.blockEl);o.setEndAfter(r.lastChild),this._ice.selection.addRange(o);e=o.extractContents(),i=t.createElement(this._ice.blockEl);i.appendChild(e),ice.dom.insertAfter(r,i),o.setStart(i,0),o.collapse(!0),this._ice.selection.addRange(o);for(var u,f=o.startContainer;d.firstChild;)3!==d.firstChild.nodeType||jQuery.trim(d.firstChild.nodeValue)?ice.dom.isBlockElement(d.firstChild)?(""!==d.firstChild.textContent&&(u=a=null,this._ice.isTracking?(u=this._ice.createIceNode("insertType"),this._ice.addChange("insertType",[u]),l=t.createElement(d.firstChild.tagName),u.innerHTML=d.firstChild.innerHTML,l.appendChild(u)):(u=l=t.createElement(d.firstChild.tagName),l.innerHTML=d.firstChild.innerHTML),c=u,ice.dom.insertBefore(f,l)),d.removeChild(d.firstChild)):(a||(l=t.createElement(this._ice.blockEl),ice.dom.insertBefore(f,l),this._ice.isTracking?(a=this._ice.createIceNode("insertType"),this._ice.addChange("insertType",[a]),l.appendChild(a)):a=l),(c=a).appendChild(d.removeChild(d.firstChild))):d.removeChild(d.firstChild);i.textContent||i.parentNode.removeChild(i)}else if(this._ice.isTracking)l=this._ice.createIceNode("insertType",d),this._ice.addChange("insertType",[l]),o.insertNode(l),c=l;else for(;s=d.firstChild;)o.insertNode(s),o.setStartAfter(s),o.collapse(!0),c=s;this._ice.endBatchChange(h),n.parentNode.removeChild(n),this._cleanup(c)},createDiv:function(e){var t=this._ice.env.document,n=t.getElementById(e);n&&ice.dom.remove(n);n=t.createElement("div");return n.id=e,n.setAttribute("contentEditable",!0),ice.dom.setStyle(n,"width","1px"),ice.dom.setStyle(n,"height","1px"),ice.dom.setStyle(n,"overflow","hidden"),ice.dom.setStyle(n,"position","fixed"),ice.dom.setStyle(n,"top","10px"),ice.dom.setStyle(n,"left","10px"),n.appendChild(t.createElement("br")),t.body.appendChild(n),n},handleCut:function(){var e,t=this,n=this._ice.getCurrentRange();n.collapsed||(this.cutElement=this.createDiv("icecut"),this.cutElement.innerHTML=n.getHTMLContents().replace(/ </g," <").replace(/> /g,"> "),(this._ice.isTracking?this._ice:n).deleteContents(),(e=this._ice.env.document.createRange()).setStart(this.cutElement.firstChild,0),e.setEndAfter(this.cutElement.lastChild),setTimeout(function(){t.cutElement.focus(),setTimeout(function(){ice.dom.remove(t.cutElement),n.setStart(n.startContainer,n.startOffset),n.collapse(!1),t._ice.env.selection.addRange(n)},100)},0),t._ice.env.selection.addRange(e))},stripPaste:function(e){return e=this._cleanWordPaste(e),e=this.cleanPreserved(e)},setupPreserved:function(){var i=this;this._tags="",this._attributesMap=[],ice.dom.each(this.preserve.split(","),function(e,t){t.match(/(\w+)(\[(.+)\])?/);var n=RegExp.$1,t=RegExp.$3;i._tags&&(i._tags+=","),i._tags+=n.toLowerCase(),i._attributesMap[n]=t.split("|")})},cleanPreserved:function(e){var s=this,t=this._ice.env.document.createElement("div");return t.innerHTML=e,t=ice.dom.stripEnclosingTags(t,this._tags),ice.dom.each(ice.dom.find(t,this._tags),function(e,t){if(ice.dom.hasClass(t,"skip-clean"))return!0;var n=t.tagName.toLowerCase(),i=s._attributesMap[n];if(i[0]&&"*"===i[0])return!0;if(t.hasAttributes())for(var r=t.attributes,o=r.length-1;0<=o;o--)ice.dom.inArray(r[o].name,i)||t.removeAttribute(r[o].name)}),t.innerHTML},_cleanWordPaste:function(e){return e=(e=(e=(e=(e=e.replace(/<(meta|link)[^>]+>/g,"")).replace(/<!--(.|\s)*?-->/g,"")).replace(/<style>[\s\S]*?<\/style>/g,"")).replace(/<\/?\w+:[^>]*>/gi,"")).replace(/<\\?\?xml[^>]*>/gi,""),e=(e=this._cleanPaste(e)).replace(/<(\w[^>]*) (lang)=([^ |>]*)([^>]*)/gi,"<$1$4")},_cleanPaste:function(e){return e=(e=(e=(e=e.replace(/<b(\s+|>)/g,"<strong$1")).replace(/<\/b(\s+|>)/g,"</strong$1")).replace(/<i(\s+|>)/g,"<em$1")).replace(/<\/i(\s+|>)/g,"</em$1")},_cleanup:function(e){try{(this._ice.env.frame?this._ice.env.frame.contentWindow:this._ice.element).focus(),e=e&&e.lastChild||e||this._tmpNode;var t=this._ice.getCurrentRange();t.setStartAfter(e),t.collapse(!0),this._ice.selection.addRange(t),this._tmpNode.parentNode.removeChild(this._tmpNode),this._tmpNode=null;for(var n=this._ice.env.document.getElementsByClassName(this._ice.changeTypes.insertType.alias),i=0;i<n.length;i++)n[i].textContent||n[i].parentNode&&n[i].parentNode.removeChild(n[i])}catch(e){window.console&&console.error(e)}}},ice.dom.noInclusionInherits(e,ice.IcePlugin),this._plugin.IceCopyPastePlugin=e}.call(this.ice),function(){function e(e){this._ice=e}var t=this.ice;e.prototype={convert:function(e){var n=this;try{n._ice.placeholdDeletes(),t.dom.each(e.getElementsByTagName(this._ice.blockEl),function(e,t){n._convertBlock(t)})}catch(e){window.console&&console.error(e)}finally{n._ice.revertDeletePlaceholders()}},_convertBlock:function(e){var n,i,r,o,s,a,c,l,d,h,u,f,g,m,p,C;t.dom.getNodeTextContent(e)<2||(o=String.fromCharCode(8216),s=String.fromCharCode(8217),a=String.fromCharCode(8220),c=String.fromCharCode(8221),l=function(e){return/\d/.test(e)},d=function(e){return/\w/.test(e)},h=function(e){return e===String.fromCharCode(160)||e===String.fromCharCode(32)},u=function(e){return h(e)||"("===e},f=function(e){return h(e)||null==e||";"===e||")"===e||"."==e||"!"===e||","===e||"?"===e||":"===e},g=function(e){return!h(e)},m=function(e){return"'"===e||e===o||e===s},p=t.dom.getHtml(e).match(/(<("[^"]*"|'[^']*'|[^'">])*>|&.*;|.)/g),C=function(e,t,n){var o=e.length,s=n<0?-1:1;return function e(t,n,i){if(n<0||o<=n)return null;var r=t[n+s];return r&&1==r.length&&!(i+=-1*s)?r:e(t,n+s,i)}(e,t,n)},t.dom.each(p,function(e,t){if(1==(t=" "==t?p[e]=" ":t).length){switch(n=C(p,e,-1),i=t,r=C(p,e,1),i){case o:case s:i="'";case"'":(null==n||h(n))&&l(r)&&l(C(p,e,2))&&f(C(p,e,3))?i=s:null==n||u(n)&&g(r)?i=o:(null==r||g(n)&&f(r)||d(n)&&d(r))&&(i=s);break;case a:case c:i='"';case'"':f(r)&&h(n)&&m(C(p,e,-2))?i=c:null==n||u(n)&&g(r)?i=a:null==r||g(n)&&f(r)?i=c:(null==n||h(n))&&h(r)&&m(C(p,e,1))&&(i=a)}null!=i&&(p[e]=i)}}),t.dom.setHtml(e,p.join("")))}},t.dom.noInclusionInherits(e,t.IcePlugin),this.ice._plugin.IceSmartQuotesPlugin=e}.call(this),function(){function e(e){this._ice=e}e.prototype={keyDown:function(e){if(ice.dom.isBrowser("mozilla")){var t=parseInt(ice.dom.browser().version);if(14<t&&173===e.keyCode||t<=14&&109===e.keyCode)return this.convertEmdash(e)}else if(189===e.keyCode)return this.convertEmdash(e);return!0},convertEmdash:function(e){var t=this._ice.getCurrentRange();if(t.collapsed){try{t.moveStart(ice.dom.CHARACTER_UNIT,-1);var n=ice.dom.getParents(t.startContainer,this._ice.blockEl)[0],i=ice.dom.getParents(t.endContainer,this._ice.blockEl)[0];if(n===i&&!this._ice.getIceNode(t.startContainer,"deleteType")&&(c=t.toHtml(),"-"===c)){t.extractContents(),t.collapse();var r=this._ice.env.document.createTextNode("\u2014");return this._ice.isTracking?this._ice._insertNode(r,t):(t.insertNode(r),t.setStart(r,1),t.collapse(!0)),!(this._ice._preventKeyPress=!0)}}catch(e){}t.collapse()}return!0}},ice.dom.noInclusionInherits(e,ice.IcePlugin),this._plugin.IceEmdashPlugin=e}.call(this.ice);