/** * Rangy, a cross-browser JavaScript range and selection library * http://code.google.com/p/rangy/ * * Copyright 2012, Tim Down * Licensed under the MIT license. * Version: 1.3alpha.681 * Build date: 20 July 2012 */ window.rangy=function(){function h(c,d){var e=typeof c[d];return e==b||e==a&&!!c[d]||e=="unknown"}function i(b,c){return typeof b[c]==a&&!!b[c]}function j(a,b){return typeof a[b]!=c}function k(a){return function(b,c){var d=c.length;while(d--)if(!a(b,c[d]))return!1;return!0}}function o(a){return a&&l(a,g)&&n(a,f)}function q(a,b){b?window.alert(a):typeof window.console!=c&&typeof window.console.log!=c&&window.console.log(a)}function r(a){p.initialized=!0,p.supported=!1,q("Rangy is not supported on this page in your browser. Reason: "+a,p.config.alertOnFail)}function s(a){q("Rangy warning: "+a,p.config.alertOnWarn)}function v(){if(p.initialized)return;var a,b=!1,c=!1;h(document,"createRange")&&(a=document.createRange(),l(a,e)&&n(a,d)&&(b=!0),a.detach());var f=i(document,"body")?document.body:document.getElementsByTagName("body")[0];if(!f||f.nodeName.toLowerCase()!="body"){r("No body element found");return}f&&h(f,"createTextRange")&&(a=f.createTextRange(),o(a)&&(c=!0));if(!b&&!c){r("Neither Range nor TextRange are available");return}p.initialized=!0,p.features={implementsDomRange:b,implementsTextRange:c};var g=u.concat(t);for(var j=0,k=g.length;jb?(f.node=d,f.offset-=b):f.node==a.parentNode&&f.offset>j(a)&&++f.offset;return d}function t(a){if(a.nodeType==9)return a;if(typeof a.ownerDocument!=c)return a.ownerDocument;if(typeof a.document!=c)return a.document;if(a.parentNode)return t(a.parentNode);throw b.createError("getDocument: no document found for node")}function u(a){var d=t(a);if(typeof d.defaultView!=c)return d.defaultView;if(typeof d.parentWindow!=c)return d.parentWindow;throw b.createError("Cannot get a window object for node")}function v(a){if(typeof a.contentDocument!=c)return a.contentDocument;if(typeof a.contentWindow!=c)return a.contentWindow.document;throw b.createError("getIframeDocument: No Document object found for iframe element")}function w(a){if(typeof a.contentWindow!=c)return a.contentWindow;if(typeof a.contentDocument!=c)return a.contentDocument.defaultView;throw b.createError("getIframeWindow: No Window object found for iframe element")}function x(a){return d.isHostObject(a,"body")?a.body:a.getElementsByTagName("body")[0]}function y(a){return a&&d.isHostMethod(a,"setTimeout")&&d.isHostObject(a,"document")}function z(a){var b;return a?d.isHostProperty(a,"nodeType")?b=a.nodeType==1&&a.tagName.toLowerCase()=="iframe"?v(a):t(a):y(a)&&(b=a.document):b=document,b}function A(a){var b;while(b=a.parentNode)a=b;return a}function B(a,c,d,e){var f,g,h,i,k;if(a==d)return c===e?0:c["+a.childNodes.length+"]"}return a.nodeName}function D(a){var b=t(a).createDocumentFragment(),c;while(c=a.firstChild)b.appendChild(c);return b}function E(a){this.root=a,this._next=a}function F(a){return new E(a)}function G(a,b){this.node=a,this.offset=b}function H(a){this.code=this[a],this.codeName=a,this.message="DOMException: "+this.codeName}var c="undefined",d=a.util;d.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||b.fail("document missing a Node creation method"),d.isHostMethod(document,"getElementsByTagName")||b.fail("document missing getElementsByTagName method");var e=document.createElement("div");d.areHostMethods(e,["insertBefore","appendChild","cloneNode"]||!d.areHostObjects(e,["previousSibling","nextSibling","childNodes","parentNode"]))||b.fail("Incomplete Element implementation"),d.isHostProperty(e,"innerHTML")||b.fail("Element is missing innerHTML property");var f=document.createTextNode("test");d.areHostMethods(f,["splitText","deleteData","insertData","appendData","cloneNode"]||!d.areHostObjects(e,["previousSibling","nextSibling","childNodes","parentNode"])||!d.areHostProperties(f,["data"]))||b.fail("Incomplete Text Node implementation");var g=function(a,b){var c=a.length;while(c--)if(a[c]===b)return!0;return!1};E.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var a=this._current=this._next,b,c;if(this._current){b=a.firstChild;if(b)this._next=b;else{c=null;while(a!==this.root&&!(c=a.nextSibling))a=a.parentNode;this._next=c}}return this._current},detach:function(){this._current=this._next=this.root=null}},G.prototype={equals:function(a){return!!a&&this.node===a.node&&this.offset==a.offset},inspect:function(){return"[DomPosition("+C(this.node)+":"+this.offset+")]"},toString:function(){return this.inspect()}},H.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},H.prototype.toString=function(){return this.message},a.dom={arrayContains:g,isHtmlNamespace:h,parentElement:i,getNodeIndex:j,getNodeLength:k,getCommonAncestor:l,isAncestorOf:m,isOrIsAncestorOf:n,getClosestAncestorIn:o,isCharacterDataNode:p,isTextOrCommentNode:q,insertAfter:r,splitDataNode:s,getDocument:t,getWindow:u,getIframeWindow:w,getIframeDocument:v,getBody:x,isWindow:y,getContentDocument:z,getRootContainer:A,comparePoints:B,inspectNode:C,fragmentFromNodeChildren:D,createIterator:F,DomPosition:G},a.DOMException=H}),rangy.createModule("DomRange",function(a,b){function g(a,b){return a.nodeType!=3&&(c.isOrIsAncestorOf(a,b.startContainer)||c.isOrIsAncestorOf(a,b.endContainer))}function h(a){return c.getDocument(a.startContainer)}function i(a){return new e(a.parentNode,c.getNodeIndex(a))}function j(a){return new e(a.parentNode,c.getNodeIndex(a)+1)}function k(a,b,d){var e=a.nodeType==11?a.firstChild:a;return c.isCharacterDataNode(b)?d==b.length?c.insertAfter(a,b):b.parentNode.insertBefore(a,d==0?b:c.splitDataNode(b,d)):d>=b.childNodes.length?b.appendChild(a):b.insertBefore(a,b.childNodes[d]),e}function l(a,b,d){O(a),O(b);if(h(b)!=h(a))throw new f("WRONG_DOCUMENT_ERR");var e=c.comparePoints(a.startContainer,a.startOffset,b.endContainer,b.endOffset),g=c.comparePoints(a.endContainer,a.endOffset,b.startContainer,b.startOffset);return d?e<=0&&g>=0:e<0&&g>0}function m(a){var b;for(var c,d=h(a.range).createDocumentFragment(),e;c=a.next();){b=a.isPartiallySelectedSubtree(),c=c.cloneNode(!b),b&&(e=a.getSubtreeIterator(),c.appendChild(m(e)),e.detach(!0));if(c.nodeType==10)throw new f("HIERARCHY_REQUEST_ERR");d.appendChild(c)}return d}function n(a,b,d){var e,f;d=d||{stop:!1};for(var g,h;g=a.next();)if(a.isPartiallySelectedSubtree()){if(b(g)===!1){d.stop=!0;return}h=a.getSubtreeIterator(),n(h,b,d),h.detach(!0);if(d.stop)return}else{e=c.createIterator(g);while(f=e.next())if(b(f)===!1){d.stop=!0;return}}}function o(a){var b;while(a.next())a.isPartiallySelectedSubtree()?(b=a.getSubtreeIterator(),o(b),b.detach(!0)):a.remove()}function p(a){for(var b,c=h(a.range).createDocumentFragment(),d;b=a.next();){a.isPartiallySelectedSubtree()?(b=b.cloneNode(!1),d=a.getSubtreeIterator(),b.appendChild(p(d)),d.detach(!0)):a.remove();if(b.nodeType==10)throw new f("HIERARCHY_REQUEST_ERR");c.appendChild(b)}return c}function q(a,b,c){var d=!!b&&!!b.length,e,f=!!c;d&&(e=new RegExp("^("+b.join("|")+")$"));var g=[];return n(new s(a,!1),function(a){(!d||e.test(a.nodeType))&&(!f||c(a))&&g.push(a)}),g}function r(a){var b=typeof a.getName=="undefined"?"Range":a.getName();return"["+b+"("+c.inspectNode(a.startContainer)+":"+a.startOffset+", "+c.inspectNode(a.endContainer)+":"+a.endOffset+")]"}function s(a,b){this.range=a,this.clonePartiallySelectedTextNodes=b;if(!a.collapsed){this.sc=a.startContainer,this.so=a.startOffset,this.ec=a.endContainer,this.eo=a.endOffset;var d=a.commonAncestorContainer;this.sc===this.ec&&c.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc===d&&!c.isCharacterDataNode(this.sc)?this.sc.childNodes[this.so]:c.getClosestAncestorIn(this.sc,d,!0),this._last=this.ec===d&&!c.isCharacterDataNode(this.ec)?this.ec.childNodes[this.eo-1]:c.getClosestAncestorIn(this.ec,d,!0))}}function t(a){this.code=this[a],this.codeName=a,this.message="RangeException: "+this.codeName}function z(a){return function(b,d){var e,f=d?b:b.parentNode;while(f){e=f.nodeType;if(c.arrayContains(a,e))return f;f=f.parentNode}return null}}function E(a,b){if(D(a,b))throw new t("INVALID_NODE_TYPE_ERR")}function F(a){if(!a.startContainer)throw new f("INVALID_STATE_ERR")}function G(a,b){if(!c.arrayContains(b,a.nodeType))throw new t("INVALID_NODE_TYPE_ERR")}function H(a,b){if(b<0||b>(c.isCharacterDataNode(a)?a.length:a.childNodes.length))throw new f("INDEX_SIZE_ERR")}function I(a,b){if(B(a,!0)!==B(b,!0))throw new f("WRONG_DOCUMENT_ERR")}function J(a){if(C(a,!0))throw new f("NO_MODIFICATION_ALLOWED_ERR")}function K(a,b){if(!a)throw new f(b)}function L(a){return!c.arrayContains(v,a.nodeType)&&!B(a,!0)}function M(a,b){return b<=(c.isCharacterDataNode(a)?a.length:a.childNodes.length)}function N(a){return!!a.startContainer&&!!a.endContainer&&!L(a.startContainer)&&!L(a.endContainer)&&M(a.startContainer,a.startOffset)&&M(a.endContainer,a.endOffset)}function O(a){F(a);if(!N(a))throw new Error("Range error: Range is no longer valid after DOM mutation ("+a.inspect()+")")}function T(a,b){O(a);var d=a.startContainer,e=a.startOffset,f=a.endContainer,g=a.endOffset,h=d===f;c.isCharacterDataNode(f)&&g>0&&g0&&e=c.getNodeIndex(d)&&g++,e=0),a.setStartAndEnd(d,e,f,g)}function bb(){}function cb(a){a.START_TO_START=V,a.START_TO_END=W,a.END_TO_END=X,a.END_TO_START=Y,a.NODE_BEFORE=Z,a.NODE_AFTER=$,a.NODE_BEFORE_AND_AFTER=_,a.NODE_INSIDE=ab}function db(a){cb(a),cb(a.prototype)}function eb(a,b){return function(){O(this);var d=this.startContainer,e=this.startOffset,f=this.commonAncestorContainer,g=new s(this,!0),h,i;d!==f&&(h=c.getClosestAncestorIn(d,f,!0),i=j(h),d=i.node,e=i.offset),n(g,J),g.reset();var k=a(g);return g.detach(),b(this,d,e,d,e),k}}function fb(a,b,e){function f(a,b){return function(c){F(this),G(c,u),G(A(c),v);var d=(a?i:j)(c);(b?h:k)(this,d.node,d.offset)}}function h(a,d,e){var f=a.endContainer,g=a.endOffset;if(d!==a.startContainer||e!==a.startOffset){if(A(d)!=A(f)||c.comparePoints(d,e,f,g)==1)f=d,g=e;b(a,d,e,f,g)}}function k(a,d,e){var f=a.startContainer,g=a.startOffset;if(d!==a.endContainer||e!==a.endOffset){if(A(d)!=A(f)||c.comparePoints(d,e,f,g)==-1)f=d,g=e;b(a,f,g,d,e)}}a.prototype=new bb,d.extend(a.prototype,{setStart:function(a,b){F(this),E(a,!0),H(a,b),h(this,a,b)},setEnd:function(a,b){F(this),E(a,!0),H(a,b),k(this,a,b)},setStartAndEnd:function(){F(this);var a=arguments,c=a[0],d=a[1],e=c,f=d;switch(a.length){case 3:f=a[2];break;case 4:e=a[2],f=a[3]}b(this,c,d,e,f)},setStartBefore:f(!0,!0),setStartAfter:f(!1,!0),setEndBefore:f(!0,!1),setEndAfter:f(!1,!1),collapse:function(a){O(this),a?b(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):b(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(a){F(this),E(a,!0),b(this,a,0,a,c.getNodeLength(a))},selectNode:function(a){F(this),E(a,!1),G(a,u);var c=i(a),d=j(a);b(this,c.node,c.offset,d.node,d.offset)},extractContents:eb(p,b),deleteContents:eb(o,b),canSurroundContents:function(){O(this),J(this.startContainer),J(this.endContainer);var a=new s(this,!0),b=a._first&&g(a._first,this)||a._last&&g(a._last,this);return a.detach(),!b},detach:function(){e(this)},splitBoundaries:function(){T(this)},splitBoundariesPreservingPositions:function(a){T(this,a)},normalizeBoundaries:function(){O(this);var a=this.startContainer,d=this.startOffset,e=this.endContainer,f=this.endOffset,g=function(a){var b=a.nextSibling;b&&b.nodeType==a.nodeType&&(e=a,f=a.length,a.appendData(b.data),b.parentNode.removeChild(b))},h=function(b){var g=b.previousSibling;if(g&&g.nodeType==b.nodeType){a=b;var h=b.length;d=g.length,b.insertData(0,g.data),g.parentNode.removeChild(g);if(a==e)f+=d,e=a;else if(e==b.parentNode){var i=c.getNodeIndex(b);f==i?(e=b,f=h):f>i&&f--}}},i=!0;if(c.isCharacterDataNode(e))e.length==f&&g(e);else{if(f>0){var j=e.childNodes[f-1];j&&c.isCharacterDataNode(j)&&g(j)}i=!this.collapsed}if(i){if(c.isCharacterDataNode(a))d==0&&h(a);else if(dx",Q=P.firstChild.nodeType==3}catch(R){}a.features.htmlParsingConforms=Q;var S=Q?function(a){var b=this.startContainer,d=c.getDocument(b);if(!b)throw new f("INVALID_STATE_ERR");var e=null;return b.nodeType==1?e=b:c.isCharacterDataNode(b)&&(e=c.parentElement(b)),e===null||e.nodeName=="HTML"&&c.isHtmlNamespace(c.getDocument(e).documentElement)&&c.isHtmlNamespace(e)?e=d.createElement("body"):e=e.cloneNode(!1),e.innerHTML=a,c.fragmentFromNodeChildren(e)}:function(a){F(this);var b=h(this),d=b.createElement("body");return d.innerHTML=a,c.fragmentFromNodeChildren(d)},U=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],V=0,W=1,X=2,Y=3,Z=0,$=1,_=2,ab=3;bb.prototype={compareBoundaryPoints:function(a,b){O(this),I(this.startContainer,b.startContainer);var d,e,f,g,h=a==Y||a==V?"start":"end",i=a==W||a==V?"start":"end";return d=this[h+"Container"],e=this[h+"Offset"],f=b[i+"Container"],g=b[i+"Offset"],c.comparePoints(d,e,f,g)},insertNode:function(a){O(this),G(a,x),J(this.startContainer);if(c.isOrIsAncestorOf(a,this.startContainer))throw new f("HIERARCHY_REQUEST_ERR");var b=k(a,this.startContainer,this.startOffset);this.setStartBefore(b)},cloneContents:function(){O(this);var a,b;if(this.collapsed)return h(this).createDocumentFragment();if(this.startContainer===this.endContainer&&c.isCharacterDataNode(this.startContainer))return a=this.startContainer.cloneNode(!0),a.data=a.data.slice(this.startOffset,this.endOffset),b=h(this).createDocumentFragment(),b.appendChild(a),b;var d=new s(this,!0);return a=m(d),d.detach(),a},canSurroundContents:function(){O(this),J(this.startContainer),J(this.endContainer);var a=new s(this,!0),b=a._first&&g(a._first,this)||a._last&&g(a._last,this);return a.detach(),!b},surroundContents:function(a){G(a,y);if(!this.canSurroundContents())throw new t("BAD_BOUNDARYPOINTS_ERR");var b=this.extractContents();if(a.hasChildNodes())while(a.lastChild)a.removeChild(a.lastChild);k(a,this.startContainer,this.startOffset),a.appendChild(b),this.selectNode(a)},cloneRange:function(){O(this);var a=new jb(h(this)),b=U.length,c;while(b--)c=U[b],a[c]=this[c];return a},toString:function(){O(this);var a=this.startContainer;if(a===this.endContainer&&c.isCharacterDataNode(a))return a.nodeType==3||a.nodeType==4?a.data.slice(this.startOffset,this.endOffset):"";var b=[],d=new s(this,!0);return n(d,function(a){(a.nodeType==3||a.nodeType==4)&&b.push(a.data)}),d.detach(),b.join("")},compareNode:function(a){O(this);var b=a.parentNode,d=c.getNodeIndex(a);if(!b)throw new f("NOT_FOUND_ERR");var e=this.comparePoint(b,d),g=this.comparePoint(b,d+1);return e<0?g>0?_:Z:g>0?$:ab},comparePoint:function(a,b){return O(this),K(a,"HIERARCHY_REQUEST_ERR"),I(a,this.startContainer),c.comparePoints(a,b,this.startContainer,this.startOffset)<0?-1:c.comparePoints(a,b,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:S,toHtml:function(){O(this);var a=this.commonAncestorContainer.parentNode.cloneNode(!1);return a.appendChild(this.cloneContents()),a.innerHTML},intersectsNode:function(a,b){O(this),K(a,"NOT_FOUND_ERR");if(c.getDocument(a)!==h(this))return!1;var d=a.parentNode,e=c.getNodeIndex(a);K(d,"NOT_FOUND_ERR");var f=c.comparePoints(d,e,this.endContainer,this.endOffset),g=c.comparePoints(d,e+1,this.startContainer,this.startOffset);return b?f<=0&&g>=0:f<0&&g>0},isPointInRange:function(a,b){return O(this),K(a,"HIERARCHY_REQUEST_ERR"),I(a,this.startContainer),c.comparePoints(a,b,this.startContainer,this.startOffset)>=0&&c.comparePoints(a,b,this.endContainer,this.endOffset)<=0},intersectsRange:function(a){return l(this,a,!1)},intersectsOrTouchesRange:function(a){return l(this,a,!0)},intersection:function(a){if(this.intersectsRange(a)){var b=c.comparePoints(this.startContainer,this.startOffset,a.startContainer,a.startOffset),d=c.comparePoints(this.endContainer,this.endOffset,a.endContainer,a.endOffset),e=this.cloneRange();return b==-1&&e.setStart(a.startContainer,a.startOffset),d==1&&e.setEnd(a.endContainer,a.endOffset),e}return null},union:function(a){if(this.intersectsOrTouchesRange(a)){var b=this.cloneRange();return c.comparePoints(a.startContainer,a.startOffset,this.startContainer,this.startOffset)==-1&&b.setStart(a.startContainer,a.startOffset),c.comparePoints(a.endContainer,a.endOffset,this.endContainer,this.endOffset)==1&&b.setEnd(a.endContainer,a.endOffset),b}throw new t("Ranges do not intersect")},containsNode:function(a,b){return b?this.intersectsNode(a,!1):this.compareNode(a)==ab},containsNodeContents:function(a){return this.comparePoint(a,0)>=0&&this.comparePoint(a,c.getNodeLength(a))<=0},containsRange:function(a){var b=this.intersection(a);return b!==null&&a.equals(b)},containsNodeText:function(a){var b=this.cloneRange();b.selectNode(a);var c=b.getNodes([3]);if(c.length>0){b.setStart(c[0],0);var d=c.pop();b.setEnd(d,d.length);var e=this.containsRange(b);return b.detach(),e}return this.containsNodeContents(a)},getNodes:function(a,b){return O(this),q(this,a,b)},getDocument:function(){return h(this)},collapseBefore:function(a){F(this),this.setEndBefore(a),this.collapse(!1)},collapseAfter:function(a){F(this),this.setStartAfter(a),this.collapse(!0)},getName:function(){return"DomRange"},equals:function(a){return jb.rangesEqual(this,a)},isValid:function(){return N(this)},inspect:function(){return r(this)}},fb(jb,hb,ib),a.rangePrototype=bb.prototype,d.extend(jb,{rangeProperties:U,RangeIterator:s,copyComparisonConstants:db,createPrototypeRange:fb,inspect:r,getRangeDocument:h,rangesEqual:function(a,b){return a.startContainer===b.startContainer&&a.startOffset===b.startOffset&&a.endContainer===b.endContainer&&a.endOffset===b.endOffset}}),a.DomRange=jb,a.RangeException=t}),rangy.createModule("WrappedRange",function(a,b){function h(a,c){a=d.getContentDocument(a);if(!a)throw b.createError(c+"(): Parameter must be a Document or other DOM node, or a Window object");return a}function i(a){var b=a.parentElement(),c=a.duplicate();c.collapse(!0);var e=c.parentElement();c=a.duplicate(),c.collapse(!1);var f=c.parentElement(),g=e==f?e:d.getCommonAncestor(e,f);return g==b?g:d.getCommonAncestor(b,g)}function j(a){return a.compareEndPoints("StartToEnd",a)==0}function k(a,b,c,e,g){var h=a.duplicate();h.collapse(c);var i=h.parentElement();d.isOrIsAncestorOf(b,i)||(i=b);if(!i.canHaveHTML)return new f(i.parentNode,d.getNodeIndex(i));var j=d.getDocument(i).createElement("span");j.parentNode&&j.parentNode.removeChild(j);var k,l=c?"StartToStart":"StartToEnd",m,n,o,p,q=g&&g.containerElement==i?g.nodeIndex:0,r=i.childNodes.length,s=r,t=s;for(;;){t==r?i.appendChild(j):i.insertBefore(j,i.childNodes[t]),h.moveToElementText(j),k=h.compareEndPoints(l,a);if(k==0||q==s)break;if(k==-1){if(s==q+1)break;q=t}else s=s==q+1?q:t;t=Math.floor((q+s)/2),i.removeChild(j)}p=j.nextSibling;if(k==-1&&p&&d.isCharacterDataNode(p)){h.setEndPoint(c?"EndToStart":"EndToEnd",a);var u;if(/[\r\n]/.test(p.data)){var v=h.duplicate(),w=v.text.replace(/\r\n/g,"\r").length;u=v.moveStart("character",w);while((k=v.compareEndPoints("StartToEnd",v))==-1)u++,v.moveStart("character",1)}else u=h.text.length;o=new f(p,u)}else m=(e||!c)&&j.previousSibling,n=(e||c)&&j.nextSibling,n&&d.isCharacterDataNode(n)?o=new f(n,0):m&&d.isCharacterDataNode(m)?o=new f(m,m.data.length):o=new f(i,d.getNodeIndex(j));return j.parentNode.removeChild(j),{boundaryPosition:o,nodeInfo:{nodeIndex:t,containerElement:i}}}function l(a,b){var c,e,f=a.offset,g=d.getDocument(a.node),h,i,j=g.body.createTextRange(),k=d.isCharacterDataNode(a.node);return k?(c=a.node,e=c.parentNode):(i=a.node.childNodes,c=f1)T(this,a);else{this.removeAllRanges();for(var b=0,c=a.length;b1?T(this,a):b&&this.addRange(a[0])}}S.getRangeAt=function(a){if(a<0||a>=this.rangeCount)throw new h("INDEX_SIZE_ERR");return this._ranges[a].cloneRange()};var V;if(s)V=function(b){var c;a.isSelectionValid(b.win)?c=b.docSelection.createRange():(c=d.getBody(b.win.document).createTextRange(),c.collapse(!0)),b.docSelection.type==l?L(b):J(c)?K(b,c):F(b)};else if(e.isHostMethod(t,"getRangeAt")&&typeof t.rangeCount=="number")V=function(b){if(B&&r&&b.docSelection.type==l)L(b);else{b._ranges.length=b.rangeCount=b.nativeSelection.rangeCount;if(b.rangeCount){for(var c=0,d=b.rangeCount;c