var MutationObserverCtor,__extends=this.__extends||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);function a(){this.constructor=e}a.prototype=t.prototype,e.prototype=new a};if(void 0===(MutationObserverCtor="undefined"!=typeof WebKitMutationObserver?WebKitMutationObserver:MutationObserver))throw console.error("DOM Mutation Observers are required."),console.error("https://developer.mozilla.org/en-US/docs/DOM/MutationObserver"),Error("DOM Mutation Observers are required");var Movement,NodeMap=function(){function r(){this.nodes=[],this.values=[]}return r.prototype.isIndex=function(e){return+e==e>>>0},r.prototype.nodeId=function(e){var t=e[r.ID_PROP];return t||(t=e[r.ID_PROP]=r.nextId_++),t},r.prototype.set=function(e,t){var r=this.nodeId(e);this.nodes[r]=e,this.values[r]=t},r.prototype.get=function(e){var t=this.nodeId(e);return this.values[t]},r.prototype.has=function(e){return this.nodeId(e)in this.nodes},r.prototype.delete=function(e){var t=this.nodeId(e);delete this.nodes[t],this.values[t]=void 0},r.prototype.keys=function(){var e=[];for(var t in this.nodes)this.isIndex(t)&&e.push(this.nodes[t]);return e},r.ID_PROP="__mutation_summary_node_map_id__",r.nextId_=1,r}();function enteredOrExited(e){return e===Movement.ENTERED||e===Movement.EXITED}!function(e){e[e.STAYED_OUT=0]="STAYED_OUT",e[e.ENTERED=1]="ENTERED",e[e.STAYED_IN=2]="STAYED_IN",e[e.REPARENTED=3]="REPARENTED",e[e.REORDERED=4]="REORDERED",e[e.EXITED=5]="EXITED"}(Movement||(Movement={}));var NodeChange=function(){function e(e,t,r,a,i,n,o,s){void 0===t&&(t=!1),void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===i&&(i=null),void 0===n&&(n=!1),void 0===o&&(o=null),void 0===s&&(s=null),this.node=e,this.childList=t,this.attributes=r,this.characterData=a,this.oldParentNode=i,this.added=n,this.attributeOldValues=o,this.characterDataOldValue=s,this.isCaseInsensitive=this.node.nodeType===Node.ELEMENT_NODE&&this.node instanceof HTMLElement&&this.node.ownerDocument instanceof HTMLDocument}return e.prototype.getAttributeOldValue=function(e){if(this.attributeOldValues)return this.isCaseInsensitive&&(e=e.toLowerCase()),this.attributeOldValues[e]},e.prototype.getAttributeNamesMutated=function(){var e=[];if(!this.attributeOldValues)return e;for(var t in this.attributeOldValues)e.push(t);return e},e.prototype.attributeMutated=function(e,t){this.attributes=!0,this.attributeOldValues=this.attributeOldValues||{},e in this.attributeOldValues||(this.attributeOldValues[e]=t)},e.prototype.characterDataMutated=function(e){this.characterData||(this.characterData=!0,this.characterDataOldValue=e)},e.prototype.removedFromParent=function(e){this.childList=!0,this.added||this.oldParentNode?this.added=!1:this.oldParentNode=e},e.prototype.insertedIntoParent=function(){this.childList=!0,this.added=!0},e.prototype.getOldParent=function(){if(this.childList){if(this.oldParentNode)return this.oldParentNode;if(this.added)return null}return this.node.parentNode},e}(),ChildListChange=function(){this.added=new NodeMap,this.removed=new NodeMap,this.maybeMoved=new NodeMap,this.oldPrevious=new NodeMap,this.moved=void 0},TreeChanges=function(o){function e(e,t){o.call(this),this.rootNode=e,this.reachableCache=void 0,this.wasReachableCache=void 0,this.anyParentsChanged=!1,this.anyAttributesChanged=!1,this.anyCharacterDataChanged=!1;for(var r=0;r<t.length;r++){var a=t[r];switch(a.type){case"childList":this.anyParentsChanged=!0;for(var i=0;i<a.removedNodes.length;i++){var n=a.removedNodes[i];this.getChange(n).removedFromParent(a.target)}for(i=0;i<a.addedNodes.length;i++){n=a.addedNodes[i];this.getChange(n).insertedIntoParent()}break;case"attributes":this.anyAttributesChanged=!0,this.getChange(a.target).attributeMutated(a.attributeName,a.oldValue);break;case"characterData":this.anyCharacterDataChanged=!0,this.getChange(a.target).characterDataMutated(a.oldValue)}}}return __extends(e,o),e.prototype.getChange=function(e){var t=this.get(e);return t||(t=new NodeChange(e),this.set(e,t)),t},e.prototype.getOldParent=function(e){var t=this.get(e);return t?t.getOldParent():e.parentNode},e.prototype.getIsReachable=function(e){if(e===this.rootNode)return!0;if(!e)return!1;this.reachableCache=this.reachableCache||new NodeMap;var t=this.reachableCache.get(e);return void 0===t&&(t=this.getIsReachable(e.parentNode),this.reachableCache.set(e,t)),t},e.prototype.getWasReachable=function(e){if(e===this.rootNode)return!0;if(!e)return!1;this.wasReachableCache=this.wasReachableCache||new NodeMap;var t=this.wasReachableCache.get(e);return void 0===t&&(t=this.getWasReachable(this.getOldParent(e)),this.wasReachableCache.set(e,t)),t},e.prototype.reachabilityChange=function(e){return this.getIsReachable(e)?this.getWasReachable(e)?Movement.STAYED_IN:Movement.ENTERED:this.getWasReachable(e)?Movement.EXITED:Movement.STAYED_OUT},e}(NodeMap),MutationProjection=function(){function e(e,t,r,a,i){this.rootNode=e,this.mutations=t,this.selectors=r,this.calcReordered=a,this.calcOldPreviousSibling=i,this.treeChanges=new TreeChanges(e,t),this.entered=[],this.exited=[],this.stayedIn=new NodeMap,this.visited=new NodeMap,this.childListChangeMap=void 0,this.characterDataOnly=void 0,this.matchCache=void 0,this.processMutations()}return e.prototype.processMutations=function(){if(this.treeChanges.anyParentsChanged||this.treeChanges.anyAttributesChanged)for(var e=this.treeChanges.keys(),t=0;t<e.length;t++)this.visitNode(e[t],void 0)},e.prototype.visitNode=function(e,t){if(!this.visited.has(e)){this.visited.set(e,!0);var r=this.treeChanges.get(e),a=t;if((r&&r.childList||null==a)&&(a=this.treeChanges.reachabilityChange(e)),a!==Movement.STAYED_OUT){if(this.matchabilityChange(e),a===Movement.ENTERED)this.entered.push(e);else if(a===Movement.EXITED)this.exited.push(e),this.ensureHasOldPreviousSiblingIfNeeded(e);else if(a===Movement.STAYED_IN){var i=Movement.STAYED_IN;r&&r.childList&&(r.oldParentNode!==e.parentNode?(i=Movement.REPARENTED,this.ensureHasOldPreviousSiblingIfNeeded(e)):this.calcReordered&&this.wasReordered(e)&&(i=Movement.REORDERED)),this.stayedIn.set(e,i)}if(a!==Movement.STAYED_IN)for(var n=e.firstChild;n;n=n.nextSibling)this.visitNode(n,a)}}},e.prototype.ensureHasOldPreviousSiblingIfNeeded=function(e){if(this.calcOldPreviousSibling){this.processChildlistChanges();var t=e.parentNode,r=this.treeChanges.get(e);r&&r.oldParentNode&&(t=r.oldParentNode);var a=this.childListChangeMap.get(t);a||(a=new ChildListChange,this.childListChangeMap.set(t,a)),a.oldPrevious.has(e)||a.oldPrevious.set(e,e.previousSibling)}},e.prototype.getChanged=function(e,t,r){this.selectors=t,this.characterDataOnly=r;for(var a=0;a<this.entered.length;a++){var i=this.entered[a];(s=this.matchabilityChange(i))!==Movement.ENTERED&&s!==Movement.STAYED_IN||e.added.push(i)}var n=this.stayedIn.keys();for(a=0;a<n.length;a++){i=n[a];if((s=this.matchabilityChange(i))===Movement.ENTERED)e.added.push(i);else if(s===Movement.EXITED)e.removed.push(i);else if(s===Movement.STAYED_IN&&(e.reparented||e.reordered)){var o=this.stayedIn.get(i);e.reparented&&o===Movement.REPARENTED?e.reparented.push(i):e.reordered&&o===Movement.REORDERED&&e.reordered.push(i)}}for(a=0;a<this.exited.length;a++){var s;i=this.exited[a];(s=this.matchabilityChange(i))!==Movement.EXITED&&s!==Movement.STAYED_IN||e.removed.push(i)}},e.prototype.getOldParentNode=function(e){var t=this.treeChanges.get(e);if(t&&t.childList)return t.oldParentNode?t.oldParentNode:null;var r=this.treeChanges.reachabilityChange(e);if(r===Movement.STAYED_OUT||r===Movement.ENTERED)throw Error("getOldParentNode requested on invalid node.");return e.parentNode},e.prototype.getOldPreviousSibling=function(e){var t=e.parentNode,r=this.treeChanges.get(e);r&&r.oldParentNode&&(t=r.oldParentNode);var a=this.childListChangeMap.get(t);if(!a)throw Error("getOldPreviousSibling requested on invalid node.");return a.oldPrevious.get(e)},e.prototype.getOldAttribute=function(e,t){var r=this.treeChanges.get(e);if(!r||!r.attributes)throw Error("getOldAttribute requested on invalid node.");var a=r.getAttributeOldValue(t);if(void 0===a)throw Error("getOldAttribute requested for unchanged attribute name.");return a},e.prototype.attributeChangedNodes=function(e){if(!this.treeChanges.anyAttributesChanged)return{};var t,r;if(e){t={},r={};for(var a=0;a<e.length;a++){t[c=e[a]]=!0,r[c.toLowerCase()]=c}}var i={},n=this.treeChanges.keys();for(a=0;a<n.length;a++){var o=n[a],s=this.treeChanges.get(o);if(s.attributes&&(Movement.STAYED_IN===this.treeChanges.reachabilityChange(o)&&Movement.STAYED_IN===this.matchabilityChange(o)))for(var h=o,d=s.getAttributeNamesMutated(),u=0;u<d.length;u++){var c=d[u];if(!t||t[c]||s.isCaseInsensitive&&r[c])s.getAttributeOldValue(c)!==h.getAttribute(c)&&(r&&s.isCaseInsensitive&&(c=r[c]),i[c]=i[c]||[],i[c].push(h))}}return i},e.prototype.getOldCharacterData=function(e){var t=this.treeChanges.get(e);if(!t||!t.characterData)throw Error("getOldCharacterData requested on invalid node.");return t.characterDataOldValue},e.prototype.getCharacterDataChanged=function(){if(!this.treeChanges.anyCharacterDataChanged)return[];for(var e=this.treeChanges.keys(),t=[],r=0;r<e.length;r++){var a=e[r];if(Movement.STAYED_IN===this.treeChanges.reachabilityChange(a)){var i=this.treeChanges.get(a);i.characterData&&a.textContent!=i.characterDataOldValue&&t.push(a)}}return t},e.prototype.computeMatchabilityChange=function(e,t){this.matchCache||(this.matchCache=[]),this.matchCache[e.uid]||(this.matchCache[e.uid]=new NodeMap);var r=this.matchCache[e.uid],a=r.get(t);return void 0===a&&(a=e.matchabilityChange(t,this.treeChanges.get(t)),r.set(t,a)),a},e.prototype.matchabilityChange=function(e){var t=this;if(this.characterDataOnly)switch(e.nodeType){case Node.COMMENT_NODE:case Node.TEXT_NODE:return Movement.STAYED_IN;default:return Movement.STAYED_OUT}if(!this.selectors)return Movement.STAYED_IN;if(e.nodeType!==Node.ELEMENT_NODE)return Movement.STAYED_OUT;for(var r=e,a=this.selectors.map(function(e){return t.computeMatchabilityChange(e,r)}),i=Movement.STAYED_OUT,n=0;i!==Movement.STAYED_IN&&n<a.length;){switch(a[n]){case Movement.STAYED_IN:i=Movement.STAYED_IN;break;case Movement.ENTERED:i=i===Movement.EXITED?Movement.STAYED_IN:Movement.ENTERED;break;case Movement.EXITED:i=i===Movement.ENTERED?Movement.STAYED_IN:Movement.EXITED}n++}return i},e.prototype.getChildlistChange=function(e){var t=this.childListChangeMap.get(e);return t||(t=new ChildListChange,this.childListChangeMap.set(e,t)),t},e.prototype.processChildlistChanges=function(){if(!this.childListChangeMap){this.childListChangeMap=new NodeMap;for(var e=0;e<this.mutations.length;e++){var t=this.mutations[e];if("childList"==t.type&&(this.treeChanges.reachabilityChange(t.target)===Movement.STAYED_IN||this.calcOldPreviousSibling)){for(var r=this.getChildlistChange(t.target),a=t.previousSibling,i=0;i<t.removedNodes.length;i++){o(n=t.removedNodes[i],a),r.added.has(n)?r.added.delete(n):(r.removed.set(n,!0),r.maybeMoved.delete(n)),a=n}o(t.nextSibling,a);for(i=0;i<t.addedNodes.length;i++){var n=t.addedNodes[i];r.removed.has(n)?(r.removed.delete(n),r.maybeMoved.set(n,!0)):r.added.set(n,!0)}}function o(e,t){!e||r.oldPrevious.has(e)||r.added.has(e)||r.maybeMoved.has(e)||t&&(r.added.has(t)||r.maybeMoved.has(t))||r.oldPrevious.set(e,t)}}}},e.prototype.wasReordered=function(e){if(!this.treeChanges.anyParentsChanged)return!1;this.processChildlistChanges();var t=e.parentNode,r=this.treeChanges.get(e);r&&r.oldParentNode&&(t=r.oldParentNode);var a=this.childListChangeMap.get(t);if(!a)return!1;if(a.moved)return a.moved.get(e);a.moved=new NodeMap;var i=new NodeMap;function n(e){if(!e)return!1;if(!a.maybeMoved.has(e))return!1;var t=a.moved.get(e);return void 0!==t||(i.has(e)?t=!0:(i.set(e,!0),t=function(e){if(s.has(e))return s.get(e);var t=e.previousSibling;for(;t&&(a.added.has(t)||n(t));)t=t.previousSibling;return s.set(e,t),t}(e)!==function e(t){var r=o.get(t);if(void 0!==r)return r;r=a.oldPrevious.get(t);for(;r&&(a.removed.has(r)||n(r));)r=e(r);void 0===r&&(r=t.previousSibling);o.set(t,r);return r}(e)),i.has(e)?(i.delete(e),a.moved.set(e,t)):t=a.moved.get(e)),t}var o=new NodeMap;var s=new NodeMap;return a.maybeMoved.keys().forEach(n),a.moved.get(e)},e}(),Summary=function(){function e(e,t){var r=this;if(this.projection=e,this.added=[],this.removed=[],this.reparented=t.all||t.element||t.characterData?[]:void 0,this.reordered=t.all?[]:void 0,e.getChanged(this,t.elementFilter,t.characterData),t.all||t.attribute||t.attributeList){var a=t.attribute?[t.attribute]:t.attributeList,i=e.attributeChangedNodes(a);t.attribute?this.valueChanged=i[t.attribute]||[]:(this.attributeChanged=i,t.attributeList&&t.attributeList.forEach(function(e){r.attributeChanged.hasOwnProperty(e)||(r.attributeChanged[e]=[])}))}if(t.all||t.characterData){var n=e.getCharacterDataChanged();t.characterData?this.valueChanged=n:this.characterDataChanged=n}this.reordered&&(this.getOldPreviousSibling=e.getOldPreviousSibling.bind(e))}return e.prototype.getOldParentNode=function(e){return this.projection.getOldParentNode(e)},e.prototype.getOldAttribute=function(e,t){return this.projection.getOldAttribute(e,t)},e.prototype.getOldCharacterData=function(e){return this.projection.getOldCharacterData(e)},e.prototype.getOldPreviousSibling=function(e){return this.projection.getOldPreviousSibling(e)},e}(),validNameInitialChar=/[a-zA-Z_]+/,validNameNonInitialChar=/[a-zA-Z0-9_\-]+/;function escapeQuotes(e){return'"'+e.replace(/"/,'\\"')+'"'}var Qualifier=function(){function e(){}return e.prototype.matches=function(e){if(null===e)return!1;if(void 0===this.attrValue)return!0;if(!this.contains)return this.attrValue==e;for(var t=e.split(" "),r=0;r<t.length;r++)if(this.attrValue===t[r])return!0;return!1},e.prototype.toString=function(){return"class"===this.attrName&&this.contains?"."+this.attrValue:"id"!==this.attrName||this.contains?this.contains?"["+this.attrName+"~="+escapeQuotes(this.attrValue)+"]":"attrValue"in this?"["+this.attrName+"="+escapeQuotes(this.attrValue)+"]":"["+this.attrName+"]":"#"+this.attrValue},e}(),Selector=function(){function l(){this.uid=l.nextUid++,this.qualifiers=[]}var e;return Object.defineProperty(l.prototype,"caseInsensitiveTagName",{get:function(){return this.tagName.toUpperCase()},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"selectorString",{get:function(){return this.tagName+this.qualifiers.join("")},enumerable:!0,configurable:!0}),l.prototype.isMatching=function(e){return e[l.matchesSelector](this.selectorString)},l.prototype.wasMatching=function(e,t,r){if(!t||!t.attributes)return r;var a=t.isCaseInsensitive?this.caseInsensitiveTagName:this.tagName;if("*"!==a&&a!==e.tagName)return!1;for(var i=[],n=!1,o=0;o<this.qualifiers.length;o++){var s=this.qualifiers[o],h=t.getAttributeOldValue(s.attrName);i.push(h),n=n||void 0!==h}if(!n)return r;for(o=0;o<this.qualifiers.length;o++){s=this.qualifiers[o];if(void 0===(h=i[o])&&(h=e.getAttribute(s.attrName)),!s.matches(h))return!1}return!0},l.prototype.matchabilityChange=function(e,t){var r=this.isMatching(e);return r?this.wasMatching(e,t,r)?Movement.STAYED_IN:Movement.ENTERED:this.wasMatching(e,t,r)?Movement.EXITED:Movement.STAYED_OUT},l.parseSelectors=function(e){var t,r,a=[];function i(){t&&(r&&(t.qualifiers.push(r),r=void 0),a.push(t)),t=new l}function n(){r&&t.qualifiers.push(r),r=new Qualifier}for(var o,s=/\s/,h="Invalid or unsupported selector syntax.",d=1,u=0;u<e.length;){var c=e[u++];switch(d){case 1:if(c.match(validNameInitialChar)){i(),t.tagName=c,d=2;break}if("*"==c){i(),t.tagName="*",d=3;break}if("."==c){i(),n(),t.tagName="*",r.attrName="class",r.contains=!0,d=4;break}if("#"==c){i(),n(),t.tagName="*",r.attrName="id",d=4;break}if("["==c){i(),n(),t.tagName="*",r.attrName="",d=6;break}if(c.match(s))break;throw Error(h);case 2:if(c.match(validNameNonInitialChar)){t.tagName+=c;break}if("."==c){n(),r.attrName="class",r.contains=!0,d=4;break}if("#"==c){n(),r.attrName="id",d=4;break}if("["==c){n(),r.attrName="",d=6;break}if(c.match(s)){d=14;break}if(","==c){d=1;break}throw Error(h);case 3:if("."==c){n(),r.attrName="class",r.contains=!0,d=4;break}if("#"==c){n(),r.attrName="id",d=4;break}if("["==c){n(),r.attrName="",d=6;break}if(c.match(s)){d=14;break}if(","==c){d=1;break}throw Error(h);case 4:if(c.match(validNameInitialChar)){r.attrValue=c,d=5;break}throw Error(h);case 5:if(c.match(validNameNonInitialChar)){r.attrValue+=c;break}if("."==c){n(),r.attrName="class",r.contains=!0,d=4;break}if("#"==c){n(),r.attrName="id",d=4;break}if("["==c){n(),d=6;break}if(c.match(s)){d=14;break}if(","==c){d=1;break}throw Error(h);case 6:if(c.match(validNameInitialChar)){r.attrName=c,d=7;break}if(c.match(s))break;throw Error(h);case 7:if(c.match(validNameNonInitialChar)){r.attrName+=c;break}if(c.match(s)){d=8;break}if("~"==c){r.contains=!0,d=9;break}if("="==c){r.attrValue="",d=11;break}if("]"==c){d=3;break}throw Error(h);case 8:if("~"==c){r.contains=!0,d=9;break}if("="==c){r.attrValue="",d=11;break}if("]"==c){d=3;break}if(c.match(s))break;throw Error(h);case 9:if("="==c){r.attrValue="",d=11;break}throw Error(h);case 10:if("]"==c){d=3;break}if(c.match(s))break;throw Error(h);case 11:if(c.match(s))break;if('"'==c||"'"==c){o=c,d=13;break}r.attrValue+=c,d=12;break;case 12:if(c.match(s)){d=10;break}if("]"==c){d=3;break}if("'"==c||'"'==c)throw Error(h);r.attrValue+=c;break;case 13:if(c==o){d=10;break}r.attrValue+=c;break;case 14:if(c.match(s))break;if(","==c){d=1;break}throw Error(h)}}switch(d){case 1:case 2:case 3:case 5:case 14:i();break;default:throw Error(h)}if(!a.length)throw Error(h);return a},l.nextUid=1,l.matchesSelector="function"==typeof(e=document.createElement("div")).webkitMatchesSelector?"webkitMatchesSelector":"function"==typeof e.mozMatchesSelector?"mozMatchesSelector":"function"==typeof e.msMatchesSelector?"msMatchesSelector":"matchesSelector",l}(),attributeFilterPattern=/^([a-zA-Z:_]+[a-zA-Z0-9_\-:\.]*)$/;function validateAttribute(e){if("string"!=typeof e)throw Error("Invalid request opion. attribute must be a non-zero length string.");if(!(e=e.trim()))throw Error("Invalid request opion. attribute must be a non-zero length string.");if(!e.match(attributeFilterPattern))throw Error("Invalid request option. invalid attribute name: "+e);return e}function validateElementAttributes(e){if(!e.trim().length)throw Error("Invalid request option: elementAttributes must contain at least one attribute.");for(var t={},r={},a=e.split(/\s+/),i=0;i<a.length;i++){if(n=a[i]){var n,o=(n=validateAttribute(n)).toLowerCase();if(t[o])throw Error("Invalid request option: observing multiple case variations of the same attribute is not supported.");r[n]=!0,t[o]=!0}}return Object.keys(r)}function elementFilterAttributes(e){var t={};return e.forEach(function(e){e.qualifiers.forEach(function(e){t[e.attrName]=!0})}),Object.keys(t)}var MutationSummary=function(){function s(e){var t=this;this.connected=!1,this.options=s.validateOptions(e),this.observerOptions=s.createObserverOptions(this.options.queries),this.root=this.options.rootNode,this.callback=this.options.callback,this.elementFilter=Array.prototype.concat.apply([],this.options.queries.map(function(e){return e.elementFilter?e.elementFilter:[]})),this.elementFilter.length||(this.elementFilter=void 0),this.calcReordered=this.options.queries.some(function(e){return e.all}),this.queryValidators=[],s.createQueryValidator&&(this.queryValidators=this.options.queries.map(function(e){return s.createQueryValidator(t.root,e)})),this.observer=new MutationObserverCtor(function(e){t.observerCallback(e)}),this.reconnect()}return s.createObserverOptions=function(e){var t,r={childList:!0,subtree:!0};function a(e){r.attributes&&!t||(r.attributes=!0,r.attributeOldValue=!0,e?(t=t||{},e.forEach(function(e){t[e]=!0,t[e.toLowerCase()]=!0})):t=void 0)}return e.forEach(function(e){if(e.characterData)return r.characterData=!0,void(r.characterDataOldValue=!0);if(e.all)return a(),r.characterData=!0,void(r.characterDataOldValue=!0);if(e.attribute)a([e.attribute.trim()]);else{var t=elementFilterAttributes(e.elementFilter).concat(e.attributeList||[]);t.length&&a(t)}}),t&&(r.attributeFilter=Object.keys(t)),r},s.validateOptions=function(e){for(var t in e)if(!(t in s.optionKeys))throw Error("Invalid option: "+t);if("function"!=typeof e.callback)throw Error("Invalid options: callback is required and must be a function");if(!e.queries||!e.queries.length)throw Error("Invalid options: queries must contain at least one query request object.");for(var r={callback:e.callback,rootNode:e.rootNode||document,observeOwnChanges:!!e.observeOwnChanges,oldPreviousSibling:!!e.oldPreviousSibling,queries:[]},a=0;a<e.queries.length;a++){var i=e.queries[a];if(i.all){if(1<Object.keys(i).length)throw Error("Invalid request option. all has no options.");r.queries.push({all:!0})}else if("attribute"in i){if((o={attribute:validateAttribute(i.attribute)}).elementFilter=Selector.parseSelectors("*["+o.attribute+"]"),1<Object.keys(i).length)throw Error("Invalid request option. attribute has no options.");r.queries.push(o)}else if("element"in i){var n=Object.keys(i).length,o={element:i.element,elementFilter:Selector.parseSelectors(i.element)};if(i.hasOwnProperty("elementAttributes")&&(o.attributeList=validateElementAttributes(i.elementAttributes),n--),1<n)throw Error("Invalid request option. element only allows elementAttributes option.");r.queries.push(o)}else{if(!i.characterData)throw Error("Invalid request option. Unknown query request.");if(1<Object.keys(i).length)throw Error("Invalid request option. characterData has no options.");r.queries.push({characterData:!0})}}return r},s.prototype.createSummaries=function(e){if(!e||!e.length)return[];for(var t=new MutationProjection(this.root,e,this.elementFilter,this.calcReordered,this.options.oldPreviousSibling),r=[],a=0;a<this.options.queries.length;a++)r.push(new Summary(t,this.options.queries[a]));return r},s.prototype.checkpointQueryValidators=function(){this.queryValidators.forEach(function(e){e&&e.recordPreviousState()})},s.prototype.runQueryValidators=function(r){this.queryValidators.forEach(function(e,t){e&&e.validate(r[t])})},s.prototype.changesToReport=function(e){return e.some(function(t){if(["added","removed","reordered","reparented","valueChanged","characterDataChanged"].some(function(e){return t[e]&&t[e].length}))return!0;if(t.attributeChanged&&Object.keys(t.attributeChanged).some(function(e){return!!t.attributeChanged[e].length}))return!0;return!1})},s.prototype.observerCallback=function(e){this.options.observeOwnChanges||this.observer.disconnect();var t=this.createSummaries(e);this.runQueryValidators(t),this.options.observeOwnChanges&&this.checkpointQueryValidators(),this.changesToReport(t)&&this.callback(t),!this.options.observeOwnChanges&&this.connected&&(this.checkpointQueryValidators(),this.observer.observe(this.root,this.observerOptions))},s.prototype.reconnect=function(){if(this.connected)throw Error("Already connected");this.observer.observe(this.root,this.observerOptions),this.connected=!0,this.checkpointQueryValidators()},s.prototype.takeSummaries=function(){if(!this.connected)throw Error("Not connected");var e=this.createSummaries(this.observer.takeRecords());return this.changesToReport(e)?e:void 0},s.prototype.disconnect=function(){var e=this.takeSummaries();return this.observer.disconnect(),this.connected=!1,e},s.NodeMap=NodeMap,s.parseElementFilter=Selector.parseSelectors,s.optionKeys={callback:!0,queries:!0,rootNode:!0,oldPreviousSibling:!0,observeOwnChanges:!0},s}();