diff --git a/core/client.js b/core/client.js index 5b1a5c48..a99ddb69 100644 --- a/core/client.js +++ b/core/client.js @@ -98,6 +98,58 @@ function edit() { }); } +function trace() { + var request = new XMLHttpRequest(); + request.addEventListener("loadend", function() { + if (request.status == 200) { + /* The trace is loaded. */ + console.log(typeof(request.response)); + var perfetto = window.open('/perfetto/'); + var done = false; + if (perfetto) { + function message_handler(message) { + if (message.data == 'PONG') { + perfetto.postMessage({ + perfetto: { + buffer: request.response, + title: 'Tilde Friends Trace', + url: window.location.href, + } + }, '*'); + done = true; + } + } + window.addEventListener('message', message_handler); + function ping_perfetto() { + perfetto.postMessage('PING', window.location.origin); + if (!done && !perfetto.closed) { + setTimeout(ping_perfetto, 50); + } else { + window.removeEventListener('message', message_handler); + } + } + setTimeout(ping_perfetto, 50); + } else { + alert("Unable to open perfetto."); + } + } else { + alert("Failed to load trace: " + request.status + "."); + } + }); + request.addEventListener("error", function() { + alert("Error loading trace."); + }); + request.addEventListener("timeout", function() { + alert("Timed out loading trace."); + }); + request.addEventListener("abort", function() { + alert("Loading trace aborted."); + }); + request.responseType = 'arraybuffer'; + request.open("GET", "/trace"); + request.send(); +} + function guessMode(name) { return name.endsWith(".js") ? "javascript" : name.endsWith(".html") ? "htmlmixed" : diff --git a/core/core.js b/core/core.js index 16be936e..272b25e5 100644 --- a/core/core.js +++ b/core/core.js @@ -333,6 +333,14 @@ async function staticFileHandler(request, response, blobId, uri) { response.end("File not found"); } +const k_mime_types = { + 'json': 'text/json', + 'js': 'text/javascript', + 'html': 'text/html', + 'css': 'text/css', + 'map': 'application/json', +}; + async function speedScopeHandler(request, response, uri) { var filename = uri || 'index.html'; if (filename.indexOf('..') != -1) { @@ -340,17 +348,27 @@ async function speedScopeHandler(request, response, uri) { response.end("File not found"); return; } - - const types = { - 'json': 'text/json', - 'js': 'text/javascript', - 'html': 'text/html', - 'css': 'text/css', - 'map': 'application/json', - }; try { var data = await File.readFile("deps/speedscope/" + filename); - response.writeHead(200, {"Content-Type": types[filename.split('.').pop()] || 'text/plain', "Content-Length": data.byteLength}); + response.writeHead(200, {"Content-Type": k_mime_types[filename.split('.').pop()] || 'text/plain', "Content-Length": data.byteLength}); + response.end(data); + } catch { + response.writeHead(404, {"Content-Type": "text/plain; charset=utf-8", "Content-Length": "File not found".length}); + response.end("File not found"); + } +} + +async function perfettoHandler(request, response, uri) { + var filename = uri || 'index.html'; + if (filename.indexOf('..') != -1) { + response.writeHead(404, {"Content-Type": "text/plain; charset=utf-8", "Content-Length": "File not found".length}); + response.end("File not found"); + return; + } + + try { + var data = await File.readFile("deps/perfetto/" + filename); + response.writeHead(200, {"Content-Type": k_mime_types[filename.split('.').pop()] || 'text/plain', "Content-Length": data.byteLength}); response.end(data); } catch { response.writeHead(404, {"Content-Type": "text/plain; charset=utf-8", "Content-Length": "File not found".length}); @@ -522,11 +540,13 @@ loadSettings().then(function() { return response.end(data); } else if (match = /^\/speedscope\/([\.\w-]*)$/.exec(request.uri)) { return speedScopeHandler(request, response, match[1]); + } else if (match = /^\/perfetto\/([\.\w-/]*)$/.exec(request.uri)) { + return perfettoHandler(request, response, match[1]); } else if (match = /^(.*)(\/save)$/.exec(request.uri)) { return blobHandler(request, response, match[1], match[2]); } else if (match = /^\/trace$/.exec(request.uri)) { var data = trace(); - response.writeHead(404, {"Content-Type": "application/json; charset=utf-8", "Content-Length": data.length.toString()}); + response.writeHead(200, {"Content-Type": "application/json; charset=utf-8", "Content-Length": data.length.toString()}); return response.end(data); } else if (request.uri == "/robots.txt") { return blobHandler(request, response, null, request.uri); diff --git a/core/index.html b/core/index.html index c0f0d38c..3b76c79b 100644 --- a/core/index.html +++ b/core/index.html @@ -13,7 +13,7 @@ Tilde Friends home edit - trace + trace diff --git a/deps/perfetto/assets/MaterialIcons.woff2 b/deps/perfetto/assets/MaterialIcons.woff2 new file mode 100644 index 00000000..2bd9d8ab Binary files /dev/null and b/deps/perfetto/assets/MaterialIcons.woff2 differ diff --git a/deps/perfetto/assets/Raleway-Regular.woff2 b/deps/perfetto/assets/Raleway-Regular.woff2 new file mode 100644 index 00000000..eba29a9a Binary files /dev/null and b/deps/perfetto/assets/Raleway-Regular.woff2 differ diff --git a/deps/perfetto/assets/Raleway-Thin.woff2 b/deps/perfetto/assets/Raleway-Thin.woff2 new file mode 100644 index 00000000..4a891c30 Binary files /dev/null and b/deps/perfetto/assets/Raleway-Thin.woff2 differ diff --git a/deps/perfetto/assets/Roboto-100.woff2 b/deps/perfetto/assets/Roboto-100.woff2 new file mode 100644 index 00000000..187d90f1 Binary files /dev/null and b/deps/perfetto/assets/Roboto-100.woff2 differ diff --git a/deps/perfetto/assets/Roboto-300.woff2 b/deps/perfetto/assets/Roboto-300.woff2 new file mode 100644 index 00000000..46445bf8 Binary files /dev/null and b/deps/perfetto/assets/Roboto-300.woff2 differ diff --git a/deps/perfetto/assets/Roboto-400.woff2 b/deps/perfetto/assets/Roboto-400.woff2 new file mode 100644 index 00000000..ebe1795f Binary files /dev/null and b/deps/perfetto/assets/Roboto-400.woff2 differ diff --git a/deps/perfetto/assets/Roboto-500.woff2 b/deps/perfetto/assets/Roboto-500.woff2 new file mode 100644 index 00000000..ce795fa8 Binary files /dev/null and b/deps/perfetto/assets/Roboto-500.woff2 differ diff --git a/deps/perfetto/assets/RobotoCondensed-Light.woff2 b/deps/perfetto/assets/RobotoCondensed-Light.woff2 new file mode 100644 index 00000000..cc645408 Binary files /dev/null and b/deps/perfetto/assets/RobotoCondensed-Light.woff2 differ diff --git a/deps/perfetto/assets/RobotoCondensed-Regular.woff2 b/deps/perfetto/assets/RobotoCondensed-Regular.woff2 new file mode 100644 index 00000000..746da3e5 Binary files /dev/null and b/deps/perfetto/assets/RobotoCondensed-Regular.woff2 differ diff --git a/deps/perfetto/assets/RobotoMono-Regular.woff2 b/deps/perfetto/assets/RobotoMono-Regular.woff2 new file mode 100644 index 00000000..6163de7b Binary files /dev/null and b/deps/perfetto/assets/RobotoMono-Regular.woff2 differ diff --git a/deps/perfetto/assets/brand.png b/deps/perfetto/assets/brand.png new file mode 100644 index 00000000..dc6f8b6f Binary files /dev/null and b/deps/perfetto/assets/brand.png differ diff --git a/deps/perfetto/assets/catapult_trace_viewer.html b/deps/perfetto/assets/catapult_trace_viewer.html new file mode 100644 index 00000000..ff677826 --- /dev/null +++ b/deps/perfetto/assets/catapult_trace_viewer.html @@ -0,0 +1,3946 @@ + + + + + + + + + + + + + + + + + + + chrome://tracing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deps/perfetto/assets/catapult_trace_viewer.js b/deps/perfetto/assets/catapult_trace_viewer.js new file mode 100644 index 00000000..197b1ef3 --- /dev/null +++ b/deps/perfetto/assets/catapult_trace_viewer.js @@ -0,0 +1,7539 @@ + +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/* WARNING: This file is auto generated. + * + * Do not edit directly. + */ + +(function(){window.WebComponents=window.WebComponents||{flags:{}};var file="webcomponents.js";var script=document.querySelector('script[src*="'+file+'"]');var flags={};if(!flags.noOpts){location.search.slice(1).split("&").forEach(function(option){var parts=option.split("=");var match;if(parts[0]&&(match=parts[0].match(/wc-(.+)/))){flags[match[1]]=parts[1]||true;}});if(script){for(var i=0,a;a=script.attributes[i];i++){if(a.name!=="src"){flags[a.name]=a.value||true;}}} +if(flags.log&&flags.log.split){var parts=flags.log.split(",");flags.log={};parts.forEach(function(f){flags.log[f]=true;});}else{flags.log={};}} +flags.shadow=flags.shadow||flags.shadowdom||flags.polyfill;if(flags.shadow==="native"){flags.shadow=false;}else{flags.shadow=flags.shadow||!HTMLElement.prototype.createShadowRoot;} +if(flags.register){window.CustomElements=window.CustomElements||{flags:{}};window.CustomElements.flags.register=flags.register;} +WebComponents.flags=flags;})();if(WebComponents.flags.shadow){if(typeof WeakMap==="undefined"){(function(){var defineProperty=Object.defineProperty;var counter=Date.now()%1e9;var WeakMap=function(){this.name="__st"+(Math.random()*1e9>>>0)+(counter++ +"__");};WeakMap.prototype={set:function(key,value){var entry=key[this.name];if(entry&&entry[0]===key)entry[1]=value;else defineProperty(key,this.name,{value:[key,value],writable:true});return this;},get:function(key){var entry;return(entry=key[this.name])&&entry[0]===key?entry[1]:undefined;},"delete":function(key){var entry=key[this.name];if(!entry||entry[0]!==key)return false;entry[0]=entry[1]=undefined;return true;},has:function(key){var entry=key[this.name];if(!entry)return false;return entry[0]===key;}};window.WeakMap=WeakMap;})();} +window.ShadowDOMPolyfill={};(function(scope){"use strict";var constructorTable=new WeakMap();var nativePrototypeTable=new WeakMap();var wrappers=Object.create(null);function detectEval(){if(typeof chrome!=="undefined"&&chrome.app&&chrome.app.runtime){return false;} +if(navigator.getDeviceStorage){return false;} +try{var f=new Function("return true;");return f();}catch(ex){return false;}} +var hasEval=detectEval();function assert(b){if(!b)throw new Error("Assertion failed");} +var defineProperty=Object.defineProperty;var getOwnPropertyNames=Object.getOwnPropertyNames;var getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor;function mixin(to,from){var names=getOwnPropertyNames(from);for(var i=0;i0||j>0){if(i==0){edits.push(EDIT_ADD);j--;continue;} +if(j==0){edits.push(EDIT_DELETE);i--;continue;} +var northWest=distances[i-1][j-1];var west=distances[i-1][j];var north=distances[i][j-1];var min;if(west0){for(var i=0;i0&&ancestorsB.length>0){var a=ancestorsA.pop();var b=ancestorsB.pop();if(a===b)result=a;else break;} +return result;} +function getTreeScopeRoot(ts){if(!ts.parent)return ts;return getTreeScopeRoot(ts.parent);} +function relatedTargetResolution(event,currentTarget,relatedTarget){if(currentTarget instanceof wrappers.Window)currentTarget=currentTarget.document;var currentTargetTree=getTreeScope(currentTarget);var relatedTargetTree=getTreeScope(relatedTarget);var relatedTargetEventPath=getEventPath(relatedTarget,event);var lowestCommonAncestorTree;var lowestCommonAncestorTree=lowestCommonInclusiveAncestor(currentTargetTree,relatedTargetTree);if(!lowestCommonAncestorTree)lowestCommonAncestorTree=relatedTargetTree.root;for(var commonAncestorTree=lowestCommonAncestorTree;commonAncestorTree;commonAncestorTree=commonAncestorTree.parent){var adjustedRelatedTarget;for(var i=0;i0;i--){if(!invoke(eventPath[i],event,phase,eventPath,overrideTarget))return false;} +return true;} +function dispatchAtTarget(event,eventPath,win,overrideTarget){var phase=AT_TARGET;var currentTarget=eventPath[0]||win;return invoke(currentTarget,event,phase,eventPath,overrideTarget);} +function dispatchBubbling(event,eventPath,win,overrideTarget){var phase=BUBBLING_PHASE;for(var i=1;i0){invoke(win,event,phase,eventPath,overrideTarget);}} +function invoke(currentTarget,event,phase,eventPath,overrideTarget){var listeners=listenersTable.get(currentTarget);if(!listeners)return true;var target=overrideTarget||eventRetargetting(eventPath,currentTarget);if(target===currentTarget){if(phase===CAPTURING_PHASE)return true;if(phase===BUBBLING_PHASE)phase=AT_TARGET;}else if(phase===BUBBLING_PHASE&&!event.bubbles){return true;} +if("relatedTarget"in event){var originalEvent=unwrap(event);var unwrappedRelatedTarget=originalEvent.relatedTarget;if(unwrappedRelatedTarget){if(unwrappedRelatedTarget instanceof Object&&unwrappedRelatedTarget.addEventListener){var relatedTarget=wrap(unwrappedRelatedTarget);var adjusted=relatedTargetResolution(event,currentTarget,relatedTarget);if(adjusted===target)return true;}else{adjusted=null;} +relatedTargetTable.set(event,adjusted);}} +eventPhaseTable.set(event,phase);var type=event.type;var anyRemoved=false;targetTable.set(event,target);currentTargetTable.set(event,currentTarget);listeners.depth++;for(var i=0,len=listeners.length;i=0;i--){node.removeChild(nodes[i]);nodes[i].parentNode_=parentNode;} +surpressMutations=false;for(var i=0;i>>/g," ");} +function shimMatchesSelector(selector){return String(selector).replace(/:host\(([^\s]+)\)/g,"$1").replace(/([^\s]):host/g,"$1").replace(":host","*").replace(/\^|\/shadow\/|\/shadow-deep\/|::shadow|\/deep\/|::content|>>>/g," ");} +function findOne(node,selector){var m,el=node.firstElementChild;while(el){if(el.matches(selector))return el;m=findOne(el,selector);if(m)return m;el=el.nextElementSibling;} +return null;} +function matchesSelector(el,selector){return el.matches(selector);} +var XHTML_NS="http://www.w3.org/1999/xhtml";function matchesTagName(el,localName,localNameLowerCase){var ln=el.localName;return ln===localName||ln===localNameLowerCase&&el.namespaceURI===XHTML_NS;} +function matchesEveryThing(){return true;} +function matchesLocalNameOnly(el,ns,localName){return el.localName===localName;} +function matchesNameSpace(el,ns){return el.namespaceURI===ns;} +function matchesLocalNameNS(el,ns,localName){return el.namespaceURI===ns&&el.localName===localName;} +function findElements(node,index,result,p,arg0,arg1){var el=node.firstElementChild;while(el){if(p(el,arg0,arg1))result[index++]=el;index=findElements(el,index,result,p,arg0,arg1);el=el.nextElementSibling;} +return index;} +function querySelectorAllFiltered(p,index,result,selector,deep){var target=unsafeUnwrap(this);var list;var root=getTreeScope(this).root;if(root instanceof scope.wrappers.ShadowRoot){return findElements(this,index,result,p,selector,null);}else if(target instanceof OriginalElement){list=originalElementQuerySelectorAll.call(target,selector);}else if(target instanceof OriginalDocument){list=originalDocumentQuerySelectorAll.call(target,selector);}else{return findElements(this,index,result,p,selector,null);} +return filterNodeList(list,index,result,deep);} +var SelectorsInterface={querySelector:function(selector){var shimmed=shimSelector(selector);var deep=shimmed!==selector;selector=shimmed;var target=unsafeUnwrap(this);var wrappedItem;var root=getTreeScope(this).root;if(root instanceof scope.wrappers.ShadowRoot){return findOne(this,selector);}else if(target instanceof OriginalElement){wrappedItem=wrap(originalElementQuerySelector.call(target,selector));}else if(target instanceof OriginalDocument){wrappedItem=wrap(originalDocumentQuerySelector.call(target,selector));}else{return findOne(this,selector);} +if(!wrappedItem){return wrappedItem;}else if(!deep&&(root=getTreeScope(wrappedItem).root)){if(root instanceof scope.wrappers.ShadowRoot){return findOne(this,selector);}} +return wrappedItem;},querySelectorAll:function(selector){var shimmed=shimSelector(selector);var deep=shimmed!==selector;selector=shimmed;var result=new NodeList();result.length=querySelectorAllFiltered.call(this,matchesSelector,0,result,selector,deep);return result;}};var MatchesInterface={matches:function(selector){selector=shimMatchesSelector(selector);return scope.originalMatches.call(unsafeUnwrap(this),selector);}};function getElementsByTagNameFiltered(p,index,result,localName,lowercase){var target=unsafeUnwrap(this);var list;var root=getTreeScope(this).root;if(root instanceof scope.wrappers.ShadowRoot){return findElements(this,index,result,p,localName,lowercase);}else if(target instanceof OriginalElement){list=originalElementGetElementsByTagName.call(target,localName,lowercase);}else if(target instanceof OriginalDocument){list=originalDocumentGetElementsByTagName.call(target,localName,lowercase);}else{return findElements(this,index,result,p,localName,lowercase);} +return filterNodeList(list,index,result,false);} +function getElementsByTagNameNSFiltered(p,index,result,ns,localName){var target=unsafeUnwrap(this);var list;var root=getTreeScope(this).root;if(root instanceof scope.wrappers.ShadowRoot){return findElements(this,index,result,p,ns,localName);}else if(target instanceof OriginalElement){list=originalElementGetElementsByTagNameNS.call(target,ns,localName);}else if(target instanceof OriginalDocument){list=originalDocumentGetElementsByTagNameNS.call(target,ns,localName);}else{return findElements(this,index,result,p,ns,localName);} +return filterNodeList(list,index,result,false);} +var GetElementsByInterface={getElementsByTagName:function(localName){var result=new HTMLCollection();var match=localName==="*"?matchesEveryThing:matchesTagName;result.length=getElementsByTagNameFiltered.call(this,match,0,result,localName,localName.toLowerCase());return result;},getElementsByClassName:function(className){return this.querySelectorAll("."+className);},getElementsByTagNameNS:function(ns,localName){var result=new HTMLCollection();var match=null;if(ns==="*"){match=localName==="*"?matchesEveryThing:matchesLocalNameOnly;}else{match=localName==="*"?matchesNameSpace:matchesLocalNameNS;} +result.length=getElementsByTagNameNSFiltered.call(this,match,0,result,ns||null,localName);return result;}};scope.GetElementsByInterface=GetElementsByInterface;scope.SelectorsInterface=SelectorsInterface;scope.MatchesInterface=MatchesInterface;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var NodeList=scope.wrappers.NodeList;function forwardElement(node){while(node&&node.nodeType!==Node.ELEMENT_NODE){node=node.nextSibling;} +return node;} +function backwardsElement(node){while(node&&node.nodeType!==Node.ELEMENT_NODE){node=node.previousSibling;} +return node;} +var ParentNodeInterface={get firstElementChild(){return forwardElement(this.firstChild);},get lastElementChild(){return backwardsElement(this.lastChild);},get childElementCount(){var count=0;for(var child=this.firstElementChild;child;child=child.nextElementSibling){count++;} +return count;},get children(){var wrapperList=new NodeList();var i=0;for(var child=this.firstElementChild;child;child=child.nextElementSibling){wrapperList[i++]=child;} +wrapperList.length=i;return wrapperList;},remove:function(){var p=this.parentNode;if(p)p.removeChild(this);}};var ChildNodeInterface={get nextElementSibling(){return forwardElement(this.nextSibling);},get previousElementSibling(){return backwardsElement(this.previousSibling);}};var NonElementParentNodeInterface={getElementById:function(id){if(/[ \t\n\r\f]/.test(id))return null;return this.querySelector('[id="'+id+'"]');}};scope.ChildNodeInterface=ChildNodeInterface;scope.NonElementParentNodeInterface=NonElementParentNodeInterface;scope.ParentNodeInterface=ParentNodeInterface;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var ChildNodeInterface=scope.ChildNodeInterface;var Node=scope.wrappers.Node;var enqueueMutation=scope.enqueueMutation;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var unsafeUnwrap=scope.unsafeUnwrap;var OriginalCharacterData=window.CharacterData;function CharacterData(node){Node.call(this,node);} +CharacterData.prototype=Object.create(Node.prototype);mixin(CharacterData.prototype,{get nodeValue(){return this.data;},set nodeValue(data){this.data=data;},get textContent(){return this.data;},set textContent(value){this.data=value;},get data(){return unsafeUnwrap(this).data;},set data(value){var oldValue=unsafeUnwrap(this).data;enqueueMutation(this,"characterData",{oldValue:oldValue});unsafeUnwrap(this).data=value;}});mixin(CharacterData.prototype,ChildNodeInterface);registerWrapper(OriginalCharacterData,CharacterData,document.createTextNode(""));scope.wrappers.CharacterData=CharacterData;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var CharacterData=scope.wrappers.CharacterData;var enqueueMutation=scope.enqueueMutation;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;function toUInt32(x){return x>>>0;} +var OriginalText=window.Text;function Text(node){CharacterData.call(this,node);} +Text.prototype=Object.create(CharacterData.prototype);mixin(Text.prototype,{splitText:function(offset){offset=toUInt32(offset);var s=this.data;if(offset>s.length)throw new Error("IndexSizeError");var head=s.slice(0,offset);var tail=s.slice(offset);this.data=head;var newTextNode=this.ownerDocument.createTextNode(tail);if(this.parentNode)this.parentNode.insertBefore(newTextNode,this.nextSibling);return newTextNode;}});registerWrapper(OriginalText,Text,document.createTextNode(""));scope.wrappers.Text=Text;})(window.ShadowDOMPolyfill);(function(scope){"use strict";if(!window.DOMTokenList){console.warn("Missing DOMTokenList prototype, please include a "+"compatible classList polyfill such as http://goo.gl/uTcepH.");return;} +var unsafeUnwrap=scope.unsafeUnwrap;var enqueueMutation=scope.enqueueMutation;function getClass(el){return unsafeUnwrap(el).getAttribute("class");} +function enqueueClassAttributeChange(el,oldValue){enqueueMutation(el,"attributes",{name:"class",namespace:null,oldValue:oldValue});} +function invalidateClass(el){scope.invalidateRendererBasedOnAttribute(el,"class");} +function changeClass(tokenList,method,args){var ownerElement=tokenList.ownerElement_;if(ownerElement==null){return method.apply(tokenList,args);} +var oldValue=getClass(ownerElement);var retv=method.apply(tokenList,args);if(getClass(ownerElement)!==oldValue){enqueueClassAttributeChange(ownerElement,oldValue);invalidateClass(ownerElement);} +return retv;} +var oldAdd=DOMTokenList.prototype.add;DOMTokenList.prototype.add=function(){changeClass(this,oldAdd,arguments);};var oldRemove=DOMTokenList.prototype.remove;DOMTokenList.prototype.remove=function(){changeClass(this,oldRemove,arguments);};var oldToggle=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(){return changeClass(this,oldToggle,arguments);};})(window.ShadowDOMPolyfill);(function(scope){"use strict";var ChildNodeInterface=scope.ChildNodeInterface;var GetElementsByInterface=scope.GetElementsByInterface;var Node=scope.wrappers.Node;var ParentNodeInterface=scope.ParentNodeInterface;var SelectorsInterface=scope.SelectorsInterface;var MatchesInterface=scope.MatchesInterface;var addWrapNodeListMethod=scope.addWrapNodeListMethod;var enqueueMutation=scope.enqueueMutation;var mixin=scope.mixin;var oneOf=scope.oneOf;var registerWrapper=scope.registerWrapper;var unsafeUnwrap=scope.unsafeUnwrap;var wrappers=scope.wrappers;var OriginalElement=window.Element;var matchesNames=["matches","mozMatchesSelector","msMatchesSelector","webkitMatchesSelector"].filter(function(name){return OriginalElement.prototype[name];});var matchesName=matchesNames[0];var originalMatches=OriginalElement.prototype[matchesName];function invalidateRendererBasedOnAttribute(element,name){var p=element.parentNode;if(!p||!p.shadowRoot)return;var renderer=scope.getRendererForHost(p);if(renderer.dependsOnAttribute(name))renderer.invalidate();} +function enqueAttributeChange(element,name,oldValue){enqueueMutation(element,"attributes",{name:name,namespace:null,oldValue:oldValue});} +var classListTable=new WeakMap();function Element(node){Node.call(this,node);} +Element.prototype=Object.create(Node.prototype);mixin(Element.prototype,{createShadowRoot:function(){var newShadowRoot=new wrappers.ShadowRoot(this);unsafeUnwrap(this).polymerShadowRoot_=newShadowRoot;var renderer=scope.getRendererForHost(this);renderer.invalidate();return newShadowRoot;},get shadowRoot(){return unsafeUnwrap(this).polymerShadowRoot_||null;},setAttribute:function(name,value){var oldValue=unsafeUnwrap(this).getAttribute(name);unsafeUnwrap(this).setAttribute(name,value);enqueAttributeChange(this,name,oldValue);invalidateRendererBasedOnAttribute(this,name);},removeAttribute:function(name){var oldValue=unsafeUnwrap(this).getAttribute(name);unsafeUnwrap(this).removeAttribute(name);enqueAttributeChange(this,name,oldValue);invalidateRendererBasedOnAttribute(this,name);},get classList(){var list=classListTable.get(this);if(!list){list=unsafeUnwrap(this).classList;if(!list)return;list.ownerElement_=this;classListTable.set(this,list);} +return list;},get className(){return unsafeUnwrap(this).className;},set className(v){this.setAttribute("class",v);},get id(){return unsafeUnwrap(this).id;},set id(v){this.setAttribute("id",v);}});matchesNames.forEach(function(name){if(name!=="matches"){Element.prototype[name]=function(selector){return this.matches(selector);};}});if(OriginalElement.prototype.webkitCreateShadowRoot){Element.prototype.webkitCreateShadowRoot=Element.prototype.createShadowRoot;} +mixin(Element.prototype,ChildNodeInterface);mixin(Element.prototype,GetElementsByInterface);mixin(Element.prototype,ParentNodeInterface);mixin(Element.prototype,SelectorsInterface);mixin(Element.prototype,MatchesInterface);registerWrapper(OriginalElement,Element,document.createElementNS(null,"x"));scope.invalidateRendererBasedOnAttribute=invalidateRendererBasedOnAttribute;scope.matchesNames=matchesNames;scope.originalMatches=originalMatches;scope.wrappers.Element=Element;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var Element=scope.wrappers.Element;var defineGetter=scope.defineGetter;var enqueueMutation=scope.enqueueMutation;var mixin=scope.mixin;var nodesWereAdded=scope.nodesWereAdded;var nodesWereRemoved=scope.nodesWereRemoved;var registerWrapper=scope.registerWrapper;var snapshotNodeList=scope.snapshotNodeList;var unsafeUnwrap=scope.unsafeUnwrap;var unwrap=scope.unwrap;var wrap=scope.wrap;var wrappers=scope.wrappers;var escapeAttrRegExp=/[&\u00A0"]/g;var escapeDataRegExp=/[&\u00A0<>]/g;function escapeReplace(c){switch(c){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case" ":return" ";}} +function escapeAttr(s){return s.replace(escapeAttrRegExp,escapeReplace);} +function escapeData(s){return s.replace(escapeDataRegExp,escapeReplace);} +function makeSet(arr){var set={};for(var i=0;i";} +return s+">"+getInnerHTML(node)+"";case Node.TEXT_NODE:var data=node.data;if(parentNode&&plaintextParents[parentNode.localName])return data;return escapeData(data);case Node.COMMENT_NODE:return"";default:console.error(node);throw new Error("not implemented");}} +function getInnerHTML(node){if(node instanceof wrappers.HTMLTemplateElement)node=node.content;var s="";for(var child=node.firstChild;child;child=child.nextSibling){s+=getOuterHTML(child,node);} +return s;} +function setInnerHTML(node,value,opt_tagName){var tagName=opt_tagName||"div";node.textContent="";var tempElement=unwrap(node.ownerDocument.createElement(tagName));tempElement.innerHTML=value;var firstChild;while(firstChild=tempElement.firstChild){node.appendChild(wrap(firstChild));}} +var oldIe=/MSIE/.test(navigator.userAgent);var OriginalHTMLElement=window.HTMLElement;var OriginalHTMLTemplateElement=window.HTMLTemplateElement;function HTMLElement(node){Element.call(this,node);} +HTMLElement.prototype=Object.create(Element.prototype);mixin(HTMLElement.prototype,{get innerHTML(){return getInnerHTML(this);},set innerHTML(value){if(oldIe&&plaintextParents[this.localName]){this.textContent=value;return;} +var removedNodes=snapshotNodeList(this.childNodes);if(this.invalidateShadowRenderer()){if(this instanceof wrappers.HTMLTemplateElement)setInnerHTML(this.content,value);else setInnerHTML(this,value,this.tagName);}else if(!OriginalHTMLTemplateElement&&this instanceof wrappers.HTMLTemplateElement){setInnerHTML(this.content,value);}else{unsafeUnwrap(this).innerHTML=value;} +var addedNodes=snapshotNodeList(this.childNodes);enqueueMutation(this,"childList",{addedNodes:addedNodes,removedNodes:removedNodes});nodesWereRemoved(removedNodes);nodesWereAdded(addedNodes,this);},get outerHTML(){return getOuterHTML(this,this.parentNode);},set outerHTML(value){var p=this.parentNode;if(p){p.invalidateShadowRenderer();var df=frag(p,value);p.replaceChild(df,this);}},insertAdjacentHTML:function(position,text){var contextElement,refNode;switch(String(position).toLowerCase()){case"beforebegin":contextElement=this.parentNode;refNode=this;break;case"afterend":contextElement=this.parentNode;refNode=this.nextSibling;break;case"afterbegin":contextElement=this;refNode=this.firstChild;break;case"beforeend":contextElement=this;refNode=null;break;default:return;} +var df=frag(contextElement,text);contextElement.insertBefore(df,refNode);},get hidden(){return this.hasAttribute("hidden");},set hidden(v){if(v){this.setAttribute("hidden","");}else{this.removeAttribute("hidden");}}});function frag(contextElement,html){var p=unwrap(contextElement.cloneNode(false));p.innerHTML=html;var df=unwrap(document.createDocumentFragment());var c;while(c=p.firstChild){df.appendChild(c);} +return wrap(df);} +function getter(name){return function(){scope.renderAllPending();return unsafeUnwrap(this)[name];};} +function getterRequiresRendering(name){defineGetter(HTMLElement,name,getter(name));} +["clientHeight","clientLeft","clientTop","clientWidth","offsetHeight","offsetLeft","offsetTop","offsetWidth","scrollHeight","scrollWidth"].forEach(getterRequiresRendering);function getterAndSetterRequiresRendering(name){Object.defineProperty(HTMLElement.prototype,name,{get:getter(name),set:function(v){scope.renderAllPending();unsafeUnwrap(this)[name]=v;},configurable:true,enumerable:true});} +["scrollLeft","scrollTop"].forEach(getterAndSetterRequiresRendering);function methodRequiresRendering(name){Object.defineProperty(HTMLElement.prototype,name,{value:function(){scope.renderAllPending();return unsafeUnwrap(this)[name].apply(unsafeUnwrap(this),arguments);},configurable:true,enumerable:true});} +["focus","getBoundingClientRect","getClientRects","scrollIntoView"].forEach(methodRequiresRendering);registerWrapper(OriginalHTMLElement,HTMLElement,document.createElement("b"));scope.wrappers.HTMLElement=HTMLElement;scope.getInnerHTML=getInnerHTML;scope.setInnerHTML=setInnerHTML;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var unsafeUnwrap=scope.unsafeUnwrap;var wrap=scope.wrap;var OriginalHTMLCanvasElement=window.HTMLCanvasElement;function HTMLCanvasElement(node){HTMLElement.call(this,node);} +HTMLCanvasElement.prototype=Object.create(HTMLElement.prototype);mixin(HTMLCanvasElement.prototype,{getContext:function(){var context=unsafeUnwrap(this).getContext.apply(unsafeUnwrap(this),arguments);return context&&wrap(context);}});registerWrapper(OriginalHTMLCanvasElement,HTMLCanvasElement,document.createElement("canvas"));scope.wrappers.HTMLCanvasElement=HTMLCanvasElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var OriginalHTMLContentElement=window.HTMLContentElement;function HTMLContentElement(node){HTMLElement.call(this,node);} +HTMLContentElement.prototype=Object.create(HTMLElement.prototype);mixin(HTMLContentElement.prototype,{constructor:HTMLContentElement,get select(){return this.getAttribute("select");},set select(value){this.setAttribute("select",value);},setAttribute:function(n,v){HTMLElement.prototype.setAttribute.call(this,n,v);if(String(n).toLowerCase()==="select")this.invalidateShadowRenderer(true);}});if(OriginalHTMLContentElement)registerWrapper(OriginalHTMLContentElement,HTMLContentElement);scope.wrappers.HTMLContentElement=HTMLContentElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var wrapHTMLCollection=scope.wrapHTMLCollection;var unwrap=scope.unwrap;var OriginalHTMLFormElement=window.HTMLFormElement;function HTMLFormElement(node){HTMLElement.call(this,node);} +HTMLFormElement.prototype=Object.create(HTMLElement.prototype);mixin(HTMLFormElement.prototype,{get elements(){return wrapHTMLCollection(unwrap(this).elements);}});registerWrapper(OriginalHTMLFormElement,HTMLFormElement,document.createElement("form"));scope.wrappers.HTMLFormElement=HTMLFormElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var registerWrapper=scope.registerWrapper;var unwrap=scope.unwrap;var rewrap=scope.rewrap;var OriginalHTMLImageElement=window.HTMLImageElement;function HTMLImageElement(node){HTMLElement.call(this,node);} +HTMLImageElement.prototype=Object.create(HTMLElement.prototype);registerWrapper(OriginalHTMLImageElement,HTMLImageElement,document.createElement("img"));function Image(width,height){if(!(this instanceof Image)){throw new TypeError("DOM object constructor cannot be called as a function.");} +var node=unwrap(document.createElement("img"));HTMLElement.call(this,node);rewrap(node,this);if(width!==undefined)node.width=width;if(height!==undefined)node.height=height;} +Image.prototype=HTMLImageElement.prototype;scope.wrappers.HTMLImageElement=HTMLImageElement;scope.wrappers.Image=Image;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var mixin=scope.mixin;var NodeList=scope.wrappers.NodeList;var registerWrapper=scope.registerWrapper;var OriginalHTMLShadowElement=window.HTMLShadowElement;function HTMLShadowElement(node){HTMLElement.call(this,node);} +HTMLShadowElement.prototype=Object.create(HTMLElement.prototype);HTMLShadowElement.prototype.constructor=HTMLShadowElement;if(OriginalHTMLShadowElement)registerWrapper(OriginalHTMLShadowElement,HTMLShadowElement);scope.wrappers.HTMLShadowElement=HTMLShadowElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var unsafeUnwrap=scope.unsafeUnwrap;var unwrap=scope.unwrap;var wrap=scope.wrap;var contentTable=new WeakMap();var templateContentsOwnerTable=new WeakMap();function getTemplateContentsOwner(doc){if(!doc.defaultView)return doc;var d=templateContentsOwnerTable.get(doc);if(!d){d=doc.implementation.createHTMLDocument("");while(d.lastChild){d.removeChild(d.lastChild);} +templateContentsOwnerTable.set(doc,d);} +return d;} +function extractContent(templateElement){var doc=getTemplateContentsOwner(templateElement.ownerDocument);var df=unwrap(doc.createDocumentFragment());var child;while(child=templateElement.firstChild){df.appendChild(child);} +return df;} +var OriginalHTMLTemplateElement=window.HTMLTemplateElement;function HTMLTemplateElement(node){HTMLElement.call(this,node);if(!OriginalHTMLTemplateElement){var content=extractContent(node);contentTable.set(this,wrap(content));}} +HTMLTemplateElement.prototype=Object.create(HTMLElement.prototype);mixin(HTMLTemplateElement.prototype,{constructor:HTMLTemplateElement,get content(){if(OriginalHTMLTemplateElement)return wrap(unsafeUnwrap(this).content);return contentTable.get(this);}});if(OriginalHTMLTemplateElement)registerWrapper(OriginalHTMLTemplateElement,HTMLTemplateElement);scope.wrappers.HTMLTemplateElement=HTMLTemplateElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var registerWrapper=scope.registerWrapper;var OriginalHTMLMediaElement=window.HTMLMediaElement;if(!OriginalHTMLMediaElement)return;function HTMLMediaElement(node){HTMLElement.call(this,node);} +HTMLMediaElement.prototype=Object.create(HTMLElement.prototype);registerWrapper(OriginalHTMLMediaElement,HTMLMediaElement,document.createElement("audio"));scope.wrappers.HTMLMediaElement=HTMLMediaElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLMediaElement=scope.wrappers.HTMLMediaElement;var registerWrapper=scope.registerWrapper;var unwrap=scope.unwrap;var rewrap=scope.rewrap;var OriginalHTMLAudioElement=window.HTMLAudioElement;if(!OriginalHTMLAudioElement)return;function HTMLAudioElement(node){HTMLMediaElement.call(this,node);} +HTMLAudioElement.prototype=Object.create(HTMLMediaElement.prototype);registerWrapper(OriginalHTMLAudioElement,HTMLAudioElement,document.createElement("audio"));function Audio(src){if(!(this instanceof Audio)){throw new TypeError("DOM object constructor cannot be called as a function.");} +var node=unwrap(document.createElement("audio"));HTMLMediaElement.call(this,node);rewrap(node,this);node.setAttribute("preload","auto");if(src!==undefined)node.setAttribute("src",src);} +Audio.prototype=HTMLAudioElement.prototype;scope.wrappers.HTMLAudioElement=HTMLAudioElement;scope.wrappers.Audio=Audio;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var rewrap=scope.rewrap;var unwrap=scope.unwrap;var wrap=scope.wrap;var OriginalHTMLOptionElement=window.HTMLOptionElement;function trimText(s){return s.replace(/\s+/g," ").trim();} +function HTMLOptionElement(node){HTMLElement.call(this,node);} +HTMLOptionElement.prototype=Object.create(HTMLElement.prototype);mixin(HTMLOptionElement.prototype,{get text(){return trimText(this.textContent);},set text(value){this.textContent=trimText(String(value));},get form(){return wrap(unwrap(this).form);}});registerWrapper(OriginalHTMLOptionElement,HTMLOptionElement,document.createElement("option"));function Option(text,value,defaultSelected,selected){if(!(this instanceof Option)){throw new TypeError("DOM object constructor cannot be called as a function.");} +var node=unwrap(document.createElement("option"));HTMLElement.call(this,node);rewrap(node,this);if(text!==undefined)node.text=text;if(value!==undefined)node.setAttribute("value",value);if(defaultSelected===true)node.setAttribute("selected","");node.selected=selected===true;} +Option.prototype=HTMLOptionElement.prototype;scope.wrappers.HTMLOptionElement=HTMLOptionElement;scope.wrappers.Option=Option;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var unwrap=scope.unwrap;var wrap=scope.wrap;var OriginalHTMLSelectElement=window.HTMLSelectElement;function HTMLSelectElement(node){HTMLElement.call(this,node);} +HTMLSelectElement.prototype=Object.create(HTMLElement.prototype);mixin(HTMLSelectElement.prototype,{add:function(element,before){if(typeof before==="object")before=unwrap(before);unwrap(this).add(unwrap(element),before);},remove:function(indexOrNode){if(indexOrNode===undefined){HTMLElement.prototype.remove.call(this);return;} +if(typeof indexOrNode==="object")indexOrNode=unwrap(indexOrNode);unwrap(this).remove(indexOrNode);},get form(){return wrap(unwrap(this).form);}});registerWrapper(OriginalHTMLSelectElement,HTMLSelectElement,document.createElement("select"));scope.wrappers.HTMLSelectElement=HTMLSelectElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var unwrap=scope.unwrap;var wrap=scope.wrap;var wrapHTMLCollection=scope.wrapHTMLCollection;var OriginalHTMLTableElement=window.HTMLTableElement;function HTMLTableElement(node){HTMLElement.call(this,node);} +HTMLTableElement.prototype=Object.create(HTMLElement.prototype);mixin(HTMLTableElement.prototype,{get caption(){return wrap(unwrap(this).caption);},createCaption:function(){return wrap(unwrap(this).createCaption());},get tHead(){return wrap(unwrap(this).tHead);},createTHead:function(){return wrap(unwrap(this).createTHead());},createTFoot:function(){return wrap(unwrap(this).createTFoot());},get tFoot(){return wrap(unwrap(this).tFoot);},get tBodies(){return wrapHTMLCollection(unwrap(this).tBodies);},createTBody:function(){return wrap(unwrap(this).createTBody());},get rows(){return wrapHTMLCollection(unwrap(this).rows);},insertRow:function(index){return wrap(unwrap(this).insertRow(index));}});registerWrapper(OriginalHTMLTableElement,HTMLTableElement,document.createElement("table"));scope.wrappers.HTMLTableElement=HTMLTableElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var wrapHTMLCollection=scope.wrapHTMLCollection;var unwrap=scope.unwrap;var wrap=scope.wrap;var OriginalHTMLTableSectionElement=window.HTMLTableSectionElement;function HTMLTableSectionElement(node){HTMLElement.call(this,node);} +HTMLTableSectionElement.prototype=Object.create(HTMLElement.prototype);mixin(HTMLTableSectionElement.prototype,{constructor:HTMLTableSectionElement,get rows(){return wrapHTMLCollection(unwrap(this).rows);},insertRow:function(index){return wrap(unwrap(this).insertRow(index));}});registerWrapper(OriginalHTMLTableSectionElement,HTMLTableSectionElement,document.createElement("thead"));scope.wrappers.HTMLTableSectionElement=HTMLTableSectionElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLElement=scope.wrappers.HTMLElement;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var wrapHTMLCollection=scope.wrapHTMLCollection;var unwrap=scope.unwrap;var wrap=scope.wrap;var OriginalHTMLTableRowElement=window.HTMLTableRowElement;function HTMLTableRowElement(node){HTMLElement.call(this,node);} +HTMLTableRowElement.prototype=Object.create(HTMLElement.prototype);mixin(HTMLTableRowElement.prototype,{get cells(){return wrapHTMLCollection(unwrap(this).cells);},insertCell:function(index){return wrap(unwrap(this).insertCell(index));}});registerWrapper(OriginalHTMLTableRowElement,HTMLTableRowElement,document.createElement("tr"));scope.wrappers.HTMLTableRowElement=HTMLTableRowElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var HTMLContentElement=scope.wrappers.HTMLContentElement;var HTMLElement=scope.wrappers.HTMLElement;var HTMLShadowElement=scope.wrappers.HTMLShadowElement;var HTMLTemplateElement=scope.wrappers.HTMLTemplateElement;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var OriginalHTMLUnknownElement=window.HTMLUnknownElement;function HTMLUnknownElement(node){switch(node.localName){case"content":return new HTMLContentElement(node);case"shadow":return new HTMLShadowElement(node);case"template":return new HTMLTemplateElement(node);} +HTMLElement.call(this,node);} +HTMLUnknownElement.prototype=Object.create(HTMLElement.prototype);registerWrapper(OriginalHTMLUnknownElement,HTMLUnknownElement);scope.wrappers.HTMLUnknownElement=HTMLUnknownElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var Element=scope.wrappers.Element;var HTMLElement=scope.wrappers.HTMLElement;var registerWrapper=scope.registerWrapper;var defineWrapGetter=scope.defineWrapGetter;var unsafeUnwrap=scope.unsafeUnwrap;var wrap=scope.wrap;var mixin=scope.mixin;var SVG_NS="http://www.w3.org/2000/svg";var OriginalSVGElement=window.SVGElement;var svgTitleElement=document.createElementNS(SVG_NS,"title");if(!("classList"in svgTitleElement)){var descr=Object.getOwnPropertyDescriptor(Element.prototype,"classList");Object.defineProperty(HTMLElement.prototype,"classList",descr);delete Element.prototype.classList;} +function SVGElement(node){Element.call(this,node);} +SVGElement.prototype=Object.create(Element.prototype);mixin(SVGElement.prototype,{get ownerSVGElement(){return wrap(unsafeUnwrap(this).ownerSVGElement);}});registerWrapper(OriginalSVGElement,SVGElement,document.createElementNS(SVG_NS,"title"));scope.wrappers.SVGElement=SVGElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var unwrap=scope.unwrap;var wrap=scope.wrap;var OriginalSVGUseElement=window.SVGUseElement;var SVG_NS="http://www.w3.org/2000/svg";var gWrapper=wrap(document.createElementNS(SVG_NS,"g"));var useElement=document.createElementNS(SVG_NS,"use");var SVGGElement=gWrapper.constructor;var parentInterfacePrototype=Object.getPrototypeOf(SVGGElement.prototype);var parentInterface=parentInterfacePrototype.constructor;function SVGUseElement(impl){parentInterface.call(this,impl);} +SVGUseElement.prototype=Object.create(parentInterfacePrototype);if("instanceRoot"in useElement){mixin(SVGUseElement.prototype,{get instanceRoot(){return wrap(unwrap(this).instanceRoot);},get animatedInstanceRoot(){return wrap(unwrap(this).animatedInstanceRoot);}});} +registerWrapper(OriginalSVGUseElement,SVGUseElement,useElement);scope.wrappers.SVGUseElement=SVGUseElement;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var EventTarget=scope.wrappers.EventTarget;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var unsafeUnwrap=scope.unsafeUnwrap;var wrap=scope.wrap;var OriginalSVGElementInstance=window.SVGElementInstance;if(!OriginalSVGElementInstance)return;function SVGElementInstance(impl){EventTarget.call(this,impl);} +SVGElementInstance.prototype=Object.create(EventTarget.prototype);mixin(SVGElementInstance.prototype,{get correspondingElement(){return wrap(unsafeUnwrap(this).correspondingElement);},get correspondingUseElement(){return wrap(unsafeUnwrap(this).correspondingUseElement);},get parentNode(){return wrap(unsafeUnwrap(this).parentNode);},get childNodes(){throw new Error("Not implemented");},get firstChild(){return wrap(unsafeUnwrap(this).firstChild);},get lastChild(){return wrap(unsafeUnwrap(this).lastChild);},get previousSibling(){return wrap(unsafeUnwrap(this).previousSibling);},get nextSibling(){return wrap(unsafeUnwrap(this).nextSibling);}});registerWrapper(OriginalSVGElementInstance,SVGElementInstance);scope.wrappers.SVGElementInstance=SVGElementInstance;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var setWrapper=scope.setWrapper;var unsafeUnwrap=scope.unsafeUnwrap;var unwrap=scope.unwrap;var unwrapIfNeeded=scope.unwrapIfNeeded;var wrap=scope.wrap;var OriginalCanvasRenderingContext2D=window.CanvasRenderingContext2D;function CanvasRenderingContext2D(impl){setWrapper(impl,this);} +mixin(CanvasRenderingContext2D.prototype,{get canvas(){return wrap(unsafeUnwrap(this).canvas);},drawImage:function(){arguments[0]=unwrapIfNeeded(arguments[0]);unsafeUnwrap(this).drawImage.apply(unsafeUnwrap(this),arguments);},createPattern:function(){arguments[0]=unwrap(arguments[0]);return unsafeUnwrap(this).createPattern.apply(unsafeUnwrap(this),arguments);}});registerWrapper(OriginalCanvasRenderingContext2D,CanvasRenderingContext2D,document.createElement("canvas").getContext("2d"));scope.wrappers.CanvasRenderingContext2D=CanvasRenderingContext2D;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var addForwardingProperties=scope.addForwardingProperties;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var setWrapper=scope.setWrapper;var unsafeUnwrap=scope.unsafeUnwrap;var unwrapIfNeeded=scope.unwrapIfNeeded;var wrap=scope.wrap;var OriginalWebGLRenderingContext=window.WebGLRenderingContext;if(!OriginalWebGLRenderingContext)return;function WebGLRenderingContext(impl){setWrapper(impl,this);} +mixin(WebGLRenderingContext.prototype,{get canvas(){return wrap(unsafeUnwrap(this).canvas);},texImage2D:function(){arguments[5]=unwrapIfNeeded(arguments[5]);unsafeUnwrap(this).texImage2D.apply(unsafeUnwrap(this),arguments);},texSubImage2D:function(){arguments[6]=unwrapIfNeeded(arguments[6]);unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this),arguments);}});var OriginalWebGLRenderingContextBase=Object.getPrototypeOf(OriginalWebGLRenderingContext.prototype);if(OriginalWebGLRenderingContextBase!==Object.prototype){addForwardingProperties(OriginalWebGLRenderingContextBase,WebGLRenderingContext.prototype);} +var instanceProperties=/WebKit/.test(navigator.userAgent)?{drawingBufferHeight:null,drawingBufferWidth:null}:{};registerWrapper(OriginalWebGLRenderingContext,WebGLRenderingContext,instanceProperties);scope.wrappers.WebGLRenderingContext=WebGLRenderingContext;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var Node=scope.wrappers.Node;var GetElementsByInterface=scope.GetElementsByInterface;var NonElementParentNodeInterface=scope.NonElementParentNodeInterface;var ParentNodeInterface=scope.ParentNodeInterface;var SelectorsInterface=scope.SelectorsInterface;var mixin=scope.mixin;var registerObject=scope.registerObject;var registerWrapper=scope.registerWrapper;var OriginalDocumentFragment=window.DocumentFragment;function DocumentFragment(node){Node.call(this,node);} +DocumentFragment.prototype=Object.create(Node.prototype);mixin(DocumentFragment.prototype,ParentNodeInterface);mixin(DocumentFragment.prototype,SelectorsInterface);mixin(DocumentFragment.prototype,GetElementsByInterface);mixin(DocumentFragment.prototype,NonElementParentNodeInterface);registerWrapper(OriginalDocumentFragment,DocumentFragment,document.createDocumentFragment());scope.wrappers.DocumentFragment=DocumentFragment;var Comment=registerObject(document.createComment(""));scope.wrappers.Comment=Comment;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var DocumentFragment=scope.wrappers.DocumentFragment;var TreeScope=scope.TreeScope;var elementFromPoint=scope.elementFromPoint;var getInnerHTML=scope.getInnerHTML;var getTreeScope=scope.getTreeScope;var mixin=scope.mixin;var rewrap=scope.rewrap;var setInnerHTML=scope.setInnerHTML;var unsafeUnwrap=scope.unsafeUnwrap;var unwrap=scope.unwrap;var wrap=scope.wrap;var shadowHostTable=new WeakMap();var nextOlderShadowTreeTable=new WeakMap();function ShadowRoot(hostWrapper){var node=unwrap(unsafeUnwrap(hostWrapper).ownerDocument.createDocumentFragment());DocumentFragment.call(this,node);rewrap(node,this);var oldShadowRoot=hostWrapper.shadowRoot;nextOlderShadowTreeTable.set(this,oldShadowRoot);this.treeScope_=new TreeScope(this,getTreeScope(oldShadowRoot||hostWrapper));shadowHostTable.set(this,hostWrapper);} +ShadowRoot.prototype=Object.create(DocumentFragment.prototype);mixin(ShadowRoot.prototype,{constructor:ShadowRoot,get innerHTML(){return getInnerHTML(this);},set innerHTML(value){setInnerHTML(this,value);this.invalidateShadowRenderer();},get olderShadowRoot(){return nextOlderShadowTreeTable.get(this)||null;},get host(){return shadowHostTable.get(this)||null;},invalidateShadowRenderer:function(){return shadowHostTable.get(this).invalidateShadowRenderer();},elementFromPoint:function(x,y){return elementFromPoint(this,this.ownerDocument,x,y);},getSelection:function(){return document.getSelection();},get activeElement(){var unwrappedActiveElement=unwrap(this).ownerDocument.activeElement;if(!unwrappedActiveElement||!unwrappedActiveElement.nodeType)return null;var activeElement=wrap(unwrappedActiveElement);while(!this.contains(activeElement)){while(activeElement.parentNode){activeElement=activeElement.parentNode;} +if(activeElement.host){activeElement=activeElement.host;}else{return null;}} +return activeElement;}});scope.wrappers.ShadowRoot=ShadowRoot;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var registerWrapper=scope.registerWrapper;var setWrapper=scope.setWrapper;var unsafeUnwrap=scope.unsafeUnwrap;var unwrap=scope.unwrap;var unwrapIfNeeded=scope.unwrapIfNeeded;var wrap=scope.wrap;var getTreeScope=scope.getTreeScope;var OriginalRange=window.Range;var ShadowRoot=scope.wrappers.ShadowRoot;function getHost(node){var root=getTreeScope(node).root;if(root instanceof ShadowRoot){return root.host;} +return null;} +function hostNodeToShadowNode(refNode,offset){if(refNode.shadowRoot){offset=Math.min(refNode.childNodes.length-1,offset);var child=refNode.childNodes[offset];if(child){var insertionPoint=scope.getDestinationInsertionPoints(child);if(insertionPoint.length>0){var parentNode=insertionPoint[0].parentNode;if(parentNode.nodeType==Node.ELEMENT_NODE){refNode=parentNode;}}}} +return refNode;} +function shadowNodeToHostNode(node){node=wrap(node);return getHost(node)||node;} +function Range(impl){setWrapper(impl,this);} +Range.prototype={get startContainer(){return shadowNodeToHostNode(unsafeUnwrap(this).startContainer);},get endContainer(){return shadowNodeToHostNode(unsafeUnwrap(this).endContainer);},get commonAncestorContainer(){return shadowNodeToHostNode(unsafeUnwrap(this).commonAncestorContainer);},setStart:function(refNode,offset){refNode=hostNodeToShadowNode(refNode,offset);unsafeUnwrap(this).setStart(unwrapIfNeeded(refNode),offset);},setEnd:function(refNode,offset){refNode=hostNodeToShadowNode(refNode,offset);unsafeUnwrap(this).setEnd(unwrapIfNeeded(refNode),offset);},setStartBefore:function(refNode){unsafeUnwrap(this).setStartBefore(unwrapIfNeeded(refNode));},setStartAfter:function(refNode){unsafeUnwrap(this).setStartAfter(unwrapIfNeeded(refNode));},setEndBefore:function(refNode){unsafeUnwrap(this).setEndBefore(unwrapIfNeeded(refNode));},setEndAfter:function(refNode){unsafeUnwrap(this).setEndAfter(unwrapIfNeeded(refNode));},selectNode:function(refNode){unsafeUnwrap(this).selectNode(unwrapIfNeeded(refNode));},selectNodeContents:function(refNode){unsafeUnwrap(this).selectNodeContents(unwrapIfNeeded(refNode));},compareBoundaryPoints:function(how,sourceRange){return unsafeUnwrap(this).compareBoundaryPoints(how,unwrap(sourceRange));},extractContents:function(){return wrap(unsafeUnwrap(this).extractContents());},cloneContents:function(){return wrap(unsafeUnwrap(this).cloneContents());},insertNode:function(node){unsafeUnwrap(this).insertNode(unwrapIfNeeded(node));},surroundContents:function(newParent){unsafeUnwrap(this).surroundContents(unwrapIfNeeded(newParent));},cloneRange:function(){return wrap(unsafeUnwrap(this).cloneRange());},isPointInRange:function(node,offset){return unsafeUnwrap(this).isPointInRange(unwrapIfNeeded(node),offset);},comparePoint:function(node,offset){return unsafeUnwrap(this).comparePoint(unwrapIfNeeded(node),offset);},intersectsNode:function(node){return unsafeUnwrap(this).intersectsNode(unwrapIfNeeded(node));},toString:function(){return unsafeUnwrap(this).toString();}};if(OriginalRange.prototype.createContextualFragment){Range.prototype.createContextualFragment=function(html){return wrap(unsafeUnwrap(this).createContextualFragment(html));};} +registerWrapper(window.Range,Range,document.createRange());scope.wrappers.Range=Range;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var Element=scope.wrappers.Element;var HTMLContentElement=scope.wrappers.HTMLContentElement;var HTMLShadowElement=scope.wrappers.HTMLShadowElement;var Node=scope.wrappers.Node;var ShadowRoot=scope.wrappers.ShadowRoot;var assert=scope.assert;var getTreeScope=scope.getTreeScope;var mixin=scope.mixin;var oneOf=scope.oneOf;var unsafeUnwrap=scope.unsafeUnwrap;var unwrap=scope.unwrap;var wrap=scope.wrap;var ArraySplice=scope.ArraySplice;function updateWrapperUpAndSideways(wrapper){wrapper.previousSibling_=wrapper.previousSibling;wrapper.nextSibling_=wrapper.nextSibling;wrapper.parentNode_=wrapper.parentNode;} +function updateWrapperDown(wrapper){wrapper.firstChild_=wrapper.firstChild;wrapper.lastChild_=wrapper.lastChild;} +function updateAllChildNodes(parentNodeWrapper){assert(parentNodeWrapper instanceof Node);for(var childWrapper=parentNodeWrapper.firstChild;childWrapper;childWrapper=childWrapper.nextSibling){updateWrapperUpAndSideways(childWrapper);} +updateWrapperDown(parentNodeWrapper);} +function insertBefore(parentNodeWrapper,newChildWrapper,refChildWrapper){var parentNode=unwrap(parentNodeWrapper);var newChild=unwrap(newChildWrapper);var refChild=refChildWrapper?unwrap(refChildWrapper):null;remove(newChildWrapper);updateWrapperUpAndSideways(newChildWrapper);if(!refChildWrapper){parentNodeWrapper.lastChild_=parentNodeWrapper.lastChild;if(parentNodeWrapper.lastChild===parentNodeWrapper.firstChild)parentNodeWrapper.firstChild_=parentNodeWrapper.firstChild;var lastChildWrapper=wrap(parentNode.lastChild);if(lastChildWrapper)lastChildWrapper.nextSibling_=lastChildWrapper.nextSibling;}else{if(parentNodeWrapper.firstChild===refChildWrapper)parentNodeWrapper.firstChild_=refChildWrapper;refChildWrapper.previousSibling_=refChildWrapper.previousSibling;} +scope.originalInsertBefore.call(parentNode,newChild,refChild);} +function remove(nodeWrapper){var node=unwrap(nodeWrapper);var parentNode=node.parentNode;if(!parentNode)return;var parentNodeWrapper=wrap(parentNode);updateWrapperUpAndSideways(nodeWrapper);if(nodeWrapper.previousSibling)nodeWrapper.previousSibling.nextSibling_=nodeWrapper;if(nodeWrapper.nextSibling)nodeWrapper.nextSibling.previousSibling_=nodeWrapper;if(parentNodeWrapper.lastChild===nodeWrapper)parentNodeWrapper.lastChild_=nodeWrapper;if(parentNodeWrapper.firstChild===nodeWrapper)parentNodeWrapper.firstChild_=nodeWrapper;scope.originalRemoveChild.call(parentNode,node);} +var distributedNodesTable=new WeakMap();var destinationInsertionPointsTable=new WeakMap();var rendererForHostTable=new WeakMap();function resetDistributedNodes(insertionPoint){distributedNodesTable.set(insertionPoint,[]);} +function getDistributedNodes(insertionPoint){var rv=distributedNodesTable.get(insertionPoint);if(!rv)distributedNodesTable.set(insertionPoint,rv=[]);return rv;} +function getChildNodesSnapshot(node){var result=[],i=0;for(var child=node.firstChild;child;child=child.nextSibling){result[i++]=child;} +return result;} +var request=oneOf(window,["requestAnimationFrame","mozRequestAnimationFrame","webkitRequestAnimationFrame","setTimeout"]);var pendingDirtyRenderers=[];var renderTimer;function renderAllPending(){for(var i=0;i=0;i--){var shadowTree=shadowTrees[i];var shadow=getShadowInsertionPoint(shadowTree);if(shadow){var olderShadowRoot=shadowTree.olderShadowRoot;if(olderShadowRoot){pool=poolPopulation(olderShadowRoot);} +for(var j=0;j=0;i--){newPrototype=Object.create(newPrototype);} +["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"].forEach(function(name){var f=prototype[name];if(!f)return;newPrototype[name]=function(){if(!(wrap(this)instanceof CustomElementConstructor)){rewrap(this);} +f.apply(wrap(this),arguments);};});var p={prototype:newPrototype};if(extendsOption)p.extends=extendsOption;function CustomElementConstructor(node){if(!node){if(extendsOption){return document.createElement(extendsOption,tagName);}else{return document.createElement(tagName);}} +setWrapper(node,this);} +CustomElementConstructor.prototype=prototype;CustomElementConstructor.prototype.constructor=CustomElementConstructor;scope.constructorTable.set(newPrototype,CustomElementConstructor);scope.nativePrototypeTable.set(prototype,newPrototype);var nativeConstructor=originalRegisterElement.call(unwrap(this),tagName,p);return CustomElementConstructor;};forwardMethodsToWrapper([window.HTMLDocument||window.Document],["registerElement"]);} +forwardMethodsToWrapper([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement,window.HTMLHtmlElement],["appendChild","compareDocumentPosition","contains","getElementsByClassName","getElementsByTagName","getElementsByTagNameNS","insertBefore","querySelector","querySelectorAll","removeChild","replaceChild"]);forwardMethodsToWrapper([window.HTMLBodyElement,window.HTMLHeadElement,window.HTMLHtmlElement],matchesNames);forwardMethodsToWrapper([window.HTMLDocument||window.Document],["adoptNode","importNode","contains","createComment","createDocumentFragment","createElement","createElementNS","createEvent","createEventNS","createRange","createTextNode","createTreeWalker","elementFromPoint","getElementById","getElementsByName","getSelection"]);mixin(Document.prototype,GetElementsByInterface);mixin(Document.prototype,ParentNodeInterface);mixin(Document.prototype,SelectorsInterface);mixin(Document.prototype,NonElementParentNodeInterface);mixin(Document.prototype,{get implementation(){var implementation=implementationTable.get(this);if(implementation)return implementation;implementation=new DOMImplementation(unwrap(this).implementation);implementationTable.set(this,implementation);return implementation;},get defaultView(){return wrap(unwrap(this).defaultView);}});registerWrapper(window.Document,Document,document.implementation.createHTMLDocument(""));if(window.HTMLDocument)registerWrapper(window.HTMLDocument,Document);wrapEventTargetMethods([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement]);function DOMImplementation(impl){setWrapper(impl,this);} +var originalCreateDocument=document.implementation.createDocument;DOMImplementation.prototype.createDocument=function(){arguments[2]=unwrap(arguments[2]);return wrap(originalCreateDocument.apply(unsafeUnwrap(this),arguments));};function wrapImplMethod(constructor,name){var original=document.implementation[name];constructor.prototype[name]=function(){return wrap(original.apply(unsafeUnwrap(this),arguments));};} +function forwardImplMethod(constructor,name){var original=document.implementation[name];constructor.prototype[name]=function(){return original.apply(unsafeUnwrap(this),arguments);};} +wrapImplMethod(DOMImplementation,"createDocumentType");wrapImplMethod(DOMImplementation,"createHTMLDocument");forwardImplMethod(DOMImplementation,"hasFeature");registerWrapper(window.DOMImplementation,DOMImplementation);forwardMethodsToWrapper([window.DOMImplementation],["createDocument","createDocumentType","createHTMLDocument","hasFeature"]);scope.adoptNodeNoRemove=adoptNodeNoRemove;scope.wrappers.DOMImplementation=DOMImplementation;scope.wrappers.Document=Document;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var EventTarget=scope.wrappers.EventTarget;var Selection=scope.wrappers.Selection;var mixin=scope.mixin;var registerWrapper=scope.registerWrapper;var renderAllPending=scope.renderAllPending;var unwrap=scope.unwrap;var unwrapIfNeeded=scope.unwrapIfNeeded;var wrap=scope.wrap;var OriginalWindow=window.Window;var originalGetComputedStyle=window.getComputedStyle;var originalGetDefaultComputedStyle=window.getDefaultComputedStyle;var originalGetSelection=window.getSelection;function Window(impl){EventTarget.call(this,impl);} +Window.prototype=Object.create(EventTarget.prototype);OriginalWindow.prototype.getComputedStyle=function(el,pseudo){return wrap(this||window).getComputedStyle(unwrapIfNeeded(el),pseudo);};if(originalGetDefaultComputedStyle){OriginalWindow.prototype.getDefaultComputedStyle=function(el,pseudo){return wrap(this||window).getDefaultComputedStyle(unwrapIfNeeded(el),pseudo);};} +OriginalWindow.prototype.getSelection=function(){return wrap(this||window).getSelection();};delete window.getComputedStyle;delete window.getDefaultComputedStyle;delete window.getSelection;["addEventListener","removeEventListener","dispatchEvent"].forEach(function(name){OriginalWindow.prototype[name]=function(){var w=wrap(this||window);return w[name].apply(w,arguments);};delete window[name];});mixin(Window.prototype,{getComputedStyle:function(el,pseudo){renderAllPending();return originalGetComputedStyle.call(unwrap(this),unwrapIfNeeded(el),pseudo);},getSelection:function(){renderAllPending();return new Selection(originalGetSelection.call(unwrap(this)));},get document(){return wrap(unwrap(this).document);}});if(originalGetDefaultComputedStyle){Window.prototype.getDefaultComputedStyle=function(el,pseudo){renderAllPending();return originalGetDefaultComputedStyle.call(unwrap(this),unwrapIfNeeded(el),pseudo);};} +registerWrapper(OriginalWindow,Window,window);scope.wrappers.Window=Window;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var unwrap=scope.unwrap;var OriginalDataTransfer=window.DataTransfer||window.Clipboard;var OriginalDataTransferSetDragImage=OriginalDataTransfer.prototype.setDragImage;if(OriginalDataTransferSetDragImage){OriginalDataTransfer.prototype.setDragImage=function(image,x,y){OriginalDataTransferSetDragImage.call(this,unwrap(image),x,y);};}})(window.ShadowDOMPolyfill);(function(scope){"use strict";var registerWrapper=scope.registerWrapper;var setWrapper=scope.setWrapper;var unwrap=scope.unwrap;var OriginalFormData=window.FormData;if(!OriginalFormData)return;function FormData(formElement){var impl;if(formElement instanceof OriginalFormData){impl=formElement;}else{impl=new OriginalFormData(formElement&&unwrap(formElement));} +setWrapper(impl,this);} +registerWrapper(OriginalFormData,FormData,new OriginalFormData());scope.wrappers.FormData=FormData;})(window.ShadowDOMPolyfill);(function(scope){"use strict";var unwrapIfNeeded=scope.unwrapIfNeeded;var originalSend=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.send=function(obj){return originalSend.call(this,unwrapIfNeeded(obj));};})(window.ShadowDOMPolyfill);(function(scope){"use strict";var isWrapperFor=scope.isWrapperFor;var elements={a:"HTMLAnchorElement",area:"HTMLAreaElement",audio:"HTMLAudioElement",base:"HTMLBaseElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",col:"HTMLTableColElement",content:"HTMLContentElement",data:"HTMLDataElement",datalist:"HTMLDataListElement",del:"HTMLModElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",font:"HTMLFontElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",head:"HTMLHeadElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",keygen:"HTMLKeygenElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",map:"HTMLMapElement",marquee:"HTMLMarqueeElement",menu:"HTMLMenuElement",menuitem:"HTMLMenuItemElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",script:"HTMLScriptElement",select:"HTMLSelectElement",shadow:"HTMLShadowElement",source:"HTMLSourceElement",span:"HTMLSpanElement",style:"HTMLStyleElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",template:"HTMLTemplateElement",textarea:"HTMLTextAreaElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",ul:"HTMLUListElement",video:"HTMLVideoElement"};function overrideConstructor(tagName){var nativeConstructorName=elements[tagName];var nativeConstructor=window[nativeConstructorName];if(!nativeConstructor)return;var element=document.createElement(tagName);var wrapperConstructor=element.constructor;window[nativeConstructorName]=wrapperConstructor;} +Object.keys(elements).forEach(overrideConstructor);Object.getOwnPropertyNames(scope.wrappers).forEach(function(name){window[name]=scope.wrappers[name];});})(window.ShadowDOMPolyfill);(function(scope){var ShadowCSS={strictStyling:false,registry:{},shimStyling:function(root,name,extendsName){var scopeStyles=this.prepareRoot(root,name,extendsName);var typeExtension=this.isTypeExtension(extendsName);var scopeSelector=this.makeScopeSelector(name,typeExtension);var cssText=stylesToCssText(scopeStyles,true);cssText=this.scopeCssText(cssText,scopeSelector);if(root){root.shimmedStyle=cssText;} +this.addCssToDocument(cssText,name);},shimStyle:function(style,selector){return this.shimCssText(style.textContent,selector);},shimCssText:function(cssText,selector){cssText=this.insertDirectives(cssText);return this.scopeCssText(cssText,selector);},makeScopeSelector:function(name,typeExtension){if(name){return typeExtension?"[is="+name+"]":name;} +return"";},isTypeExtension:function(extendsName){return extendsName&&extendsName.indexOf("-")<0;},prepareRoot:function(root,name,extendsName){var def=this.registerRoot(root,name,extendsName);this.replaceTextInStyles(def.rootStyles,this.insertDirectives);this.removeStyles(root,def.rootStyles);if(this.strictStyling){this.applyScopeToContent(root,name);} +return def.scopeStyles;},removeStyles:function(root,styles){for(var i=0,l=styles.length,s;i","+","~"],scoped=selector,attrName="["+scopeSelector+"]";splits.forEach(function(sep){var parts=scoped.split(sep);scoped=parts.map(function(p){var t=p.trim().replace(polyfillHostRe,"");if(t&&splits.indexOf(t)<0&&t.indexOf(attrName)<0){p=t.replace(/([^:]*)(:*)(.*)/,"$1"+attrName+"$2$3");} +return p;}).join(sep);});return scoped;},insertPolyfillHostInCssText:function(selector){return selector.replace(colonHostContextRe,polyfillHostContext).replace(colonHostRe,polyfillHost);},propertiesFromRule:function(rule){var cssText=rule.style.cssText;if(rule.style.content&&!rule.style.content.match(/['"]+|attr/)){cssText=cssText.replace(/content:[^;]*;/g,"content: '"+rule.style.content+"';");} +var style=rule.style;for(var i in style){if(style[i]==="initial"){cssText+=i+": initial; ";}} +return cssText;},replaceTextInStyles:function(styles,action){if(styles&&action){if(!(styles instanceof Array)){styles=[styles];} +Array.prototype.forEach.call(styles,function(s){s.textContent=action.call(this,s.textContent);},this);}},addCssToDocument:function(cssText,name){if(cssText.match("@import")){addOwnSheet(cssText,name);}else{addCssToDocument(cssText);}}};var selectorRe=/([^{]*)({[\s\S]*?})/gim,cssCommentRe=/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim,cssCommentNextSelectorRe=/\/\*\s*@polyfill ([^*]*\*+([^\/*][^*]*\*+)*\/)([^{]*?){/gim,cssContentNextSelectorRe=/polyfill-next-selector[^}]*content\:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim,cssCommentRuleRe=/\/\*\s@polyfill-rule([^*]*\*+([^\/*][^*]*\*+)*)\//gim,cssContentRuleRe=/(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,cssCommentUnscopedRuleRe=/\/\*\s@polyfill-unscoped-rule([^*]*\*+([^\/*][^*]*\*+)*)\//gim,cssContentUnscopedRuleRe=/(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,cssPseudoRe=/::(x-[^\s{,(]*)/gim,cssPartRe=/::part\(([^)]*)\)/gim,polyfillHost="-shadowcsshost",polyfillHostContext="-shadowcsscontext",parenSuffix=")(?:\\(("+"(?:\\([^)(]*\\)|[^)(]*)+?"+")\\))?([^,{]*)";var cssColonHostRe=new RegExp("("+polyfillHost+parenSuffix,"gim"),cssColonHostContextRe=new RegExp("("+polyfillHostContext+parenSuffix,"gim"),selectorReSuffix="([>\\s~+[.,{:][\\s\\S]*)?$",colonHostRe=/\:host/gim,colonHostContextRe=/\:host-context/gim,polyfillHostNoCombinator=polyfillHost+"-no-combinator",polyfillHostRe=new RegExp(polyfillHost,"gim"),polyfillHostContextRe=new RegExp(polyfillHostContext,"gim"),shadowDOMSelectorsRe=[/>>>/g,/::shadow/g,/::content/g,/\/deep\//g,/\/shadow\//g,/\/shadow-deep\//g,/\^\^/g,/\^(?!=)/g];function stylesToCssText(styles,preserveComments){var cssText="";Array.prototype.forEach.call(styles,function(s){cssText+=s.textContent+"\n\n";});if(!preserveComments){cssText=cssText.replace(cssCommentRe,"");} +return cssText;} +function cssTextToStyle(cssText){var style=document.createElement("style");style.textContent=cssText;return style;} +function cssToRules(cssText){var style=cssTextToStyle(cssText);document.head.appendChild(style);var rules=[];if(style.sheet){try{rules=style.sheet.cssRules;}catch(e){}}else{console.warn("sheet not found",style);} +style.parentNode.removeChild(style);return rules;} +var frame=document.createElement("iframe");frame.style.display="none";function initFrame(){frame.initialized=true;document.body.appendChild(frame);var doc=frame.contentDocument;var base=doc.createElement("base");base.href=document.baseURI;doc.head.appendChild(base);} +function inFrame(fn){if(!frame.initialized){initFrame();} +document.body.appendChild(frame);fn(frame.contentDocument);document.body.removeChild(frame);} +var isChrome=navigator.userAgent.match("Chrome");function withCssRules(cssText,callback){if(!callback){return;} +var rules;if(cssText.match("@import")&&isChrome){var style=cssTextToStyle(cssText);inFrame(function(doc){doc.head.appendChild(style.impl);rules=Array.prototype.slice.call(style.sheet.cssRules,0);callback(rules);});}else{rules=cssToRules(cssText);callback(rules);}} +function rulesToCss(cssRules){for(var i=0,css=[];i32&&unicode<127&&[34,35,60,62,63,96].indexOf(unicode)==-1){return c;} +return encodeURIComponent(c);} +function percentEscapeQuery(c){var unicode=c.charCodeAt(0);if(unicode>32&&unicode<127&&[34,35,60,62,96].indexOf(unicode)==-1){return c;} +return encodeURIComponent(c);} +var EOF=undefined,ALPHA=/[a-zA-Z]/,ALPHANUMERIC=/[a-zA-Z0-9\+\-\.]/;function parse(input,stateOverride,base){function err(message){errors.push(message);} +var state=stateOverride||"scheme start",cursor=0,buffer="",seenAt=false,seenBracket=false,errors=[];loop:while((input[cursor-1]!=EOF||cursor==0)&&!this._isInvalid){var c=input[cursor];switch(state){case"scheme start":if(c&&ALPHA.test(c)){buffer+=c.toLowerCase();state="scheme";}else if(!stateOverride){buffer="";state="no scheme";continue;}else{err("Invalid scheme.");break loop;} +break;case"scheme":if(c&&ALPHANUMERIC.test(c)){buffer+=c.toLowerCase();}else if(":"==c){this._scheme=buffer;buffer="";if(stateOverride){break loop;} +if(isRelativeScheme(this._scheme)){this._isRelative=true;} +if("file"==this._scheme){state="relative";}else if(this._isRelative&&base&&base._scheme==this._scheme){state="relative or authority";}else if(this._isRelative){state="authority first slash";}else{state="scheme data";}}else if(!stateOverride){buffer="";cursor=0;state="no scheme";continue;}else if(EOF==c){break loop;}else{err("Code point not allowed in scheme: "+c);break loop;} +break;case"scheme data":if("?"==c){this._query="?";state="query";}else if("#"==c){this._fragment="#";state="fragment";}else{if(EOF!=c&&"\t"!=c&&"\n"!=c&&"\r"!=c){this._schemeData+=percentEscape(c);}} +break;case"no scheme":if(!base||!isRelativeScheme(base._scheme)){err("Missing scheme.");invalid.call(this);}else{state="relative";continue;} +break;case"relative or authority":if("/"==c&&"/"==input[cursor+1]){state="authority ignore slashes";}else{err("Expected /, got: "+c);state="relative";continue;} +break;case"relative":this._isRelative=true;if("file"!=this._scheme)this._scheme=base._scheme;if(EOF==c){this._host=base._host;this._port=base._port;this._path=base._path.slice();this._query=base._query;this._username=base._username;this._password=base._password;break loop;}else if("/"==c||"\\"==c){if("\\"==c)err("\\ is an invalid code point.");state="relative slash";}else if("?"==c){this._host=base._host;this._port=base._port;this._path=base._path.slice();this._query="?";this._username=base._username;this._password=base._password;state="query";}else if("#"==c){this._host=base._host;this._port=base._port;this._path=base._path.slice();this._query=base._query;this._fragment="#";this._username=base._username;this._password=base._password;state="fragment";}else{var nextC=input[cursor+1];var nextNextC=input[cursor+2];if("file"!=this._scheme||!ALPHA.test(c)||nextC!=":"&&nextC!="|"||EOF!=nextNextC&&"/"!=nextNextC&&"\\"!=nextNextC&&"?"!=nextNextC&&"#"!=nextNextC){this._host=base._host;this._port=base._port;this._username=base._username;this._password=base._password;this._path=base._path.slice();this._path.pop();} +state="relative path";continue;} +break;case"relative slash":if("/"==c||"\\"==c){if("\\"==c){err("\\ is an invalid code point.");} +if("file"==this._scheme){state="file host";}else{state="authority ignore slashes";}}else{if("file"!=this._scheme){this._host=base._host;this._port=base._port;this._username=base._username;this._password=base._password;} +state="relative path";continue;} +break;case"authority first slash":if("/"==c){state="authority second slash";}else{err("Expected '/', got: "+c);state="authority ignore slashes";continue;} +break;case"authority second slash":state="authority ignore slashes";if("/"!=c){err("Expected '/', got: "+c);continue;} +break;case"authority ignore slashes":if("/"!=c&&"\\"!=c){state="authority";continue;}else{err("Expected authority, got: "+c);} +break;case"authority":if("@"==c){if(seenAt){err("@ already seen.");buffer+="%40";} +seenAt=true;for(var i=0;i0){var lastRecord=records[length-1];var recordToReplaceLast=selectRecord(lastRecord,record);if(recordToReplaceLast){records[length-1]=recordToReplaceLast;return;}}else{scheduleCallback(this.observer);} +records[length]=record;},addListeners:function(){this.addListeners_(this.target);},addListeners_:function(node){var options=this.options;if(options.attributes)node.addEventListener("DOMAttrModified",this,true);if(options.characterData)node.addEventListener("DOMCharacterDataModified",this,true);if(options.childList)node.addEventListener("DOMNodeInserted",this,true);if(options.childList||options.subtree)node.addEventListener("DOMNodeRemoved",this,true);},removeListeners:function(){this.removeListeners_(this.target);},removeListeners_:function(node){var options=this.options;if(options.attributes)node.removeEventListener("DOMAttrModified",this,true);if(options.characterData)node.removeEventListener("DOMCharacterDataModified",this,true);if(options.childList)node.removeEventListener("DOMNodeInserted",this,true);if(options.childList||options.subtree)node.removeEventListener("DOMNodeRemoved",this,true);},addTransientObserver:function(node){if(node===this.target)return;this.addListeners_(node);this.transientObservedNodes.push(node);var registrations=registrationsTable.get(node);if(!registrations)registrationsTable.set(node,registrations=[]);registrations.push(this);},removeTransientObservers:function(){var transientObservedNodes=this.transientObservedNodes;this.transientObservedNodes=[];transientObservedNodes.forEach(function(node){this.removeListeners_(node);var registrations=registrationsTable.get(node);for(var i=0;i=200&&request.status<300||request.status===304||request.status===0;},load:function(url,next,nextContext){var request=new XMLHttpRequest();if(scope.flags.debug||scope.flags.bust){url+="?"+Math.random();} +request.open("GET",url,xhr.async);request.addEventListener("readystatechange",function(e){if(request.readyState===4){var redirectedUrl=null;try{var locationHeader=request.getResponseHeader("Location");if(locationHeader){redirectedUrl=locationHeader.substr(0,1)==="/"?location.origin+locationHeader:locationHeader;}}catch(e){console.error(e.message);} +next.call(nextContext,!xhr.ok(request)&&request,request.response||request.responseText,redirectedUrl);}});request.send();return request;},loadDocument:function(url,next,nextContext){this.load(url,next,nextContext).responseType="document";}};scope.xhr=xhr;});window.HTMLImports.addModule(function(scope){var xhr=scope.xhr;var flags=scope.flags;var Loader=function(onLoad,onComplete){this.cache={};this.onload=onLoad;this.oncomplete=onComplete;this.inflight=0;this.pending={};};Loader.prototype={addNodes:function(nodes){this.inflight+=nodes.length;for(var i=0,l=nodes.length,n;i-1){body=atob(body);}else{body=decodeURIComponent(body);} +setTimeout(function(){this.receive(url,elt,null,body);}.bind(this),0);}else{var receiveXhr=function(err,resource,redirectedUrl){this.receive(url,elt,err,resource,redirectedUrl);}.bind(this);xhr.load(url,receiveXhr);}},receive:function(url,elt,err,resource,redirectedUrl){this.cache[url]=resource;var $p=this.pending[url];for(var i=0,l=$p.length,p;i=0){this.dynamicElements.splice(i,1);}},parseImport:function(elt){elt.import=elt.__doc;if(window.HTMLImports.__importsParsingHook){window.HTMLImports.__importsParsingHook(elt);} +if(elt.import){elt.import.__importParsed=true;} +this.markParsingComplete(elt);if(elt.__resource&&!elt.__error){elt.dispatchEvent(new CustomEvent("load",{bubbles:false}));}else{elt.dispatchEvent(new CustomEvent("error",{bubbles:false}));} +if(elt.__pending){var fn;while(elt.__pending.length){fn=elt.__pending.shift();if(fn){fn({target:elt});}}} +this.parseNext();},parseLink:function(linkElt){if(nodeIsImport(linkElt)){this.parseImport(linkElt);}else{linkElt.href=linkElt.href;this.parseGeneric(linkElt);}},parseStyle:function(elt){var src=elt;elt=cloneStyle(elt);src.__appliedElement=elt;elt.__importElement=src;this.parseGeneric(elt);},parseGeneric:function(elt){this.trackElement(elt);this.addElementToDocument(elt);},rootImportForElement:function(elt){var n=elt;while(n.ownerDocument.__importLink){n=n.ownerDocument.__importLink;} +return n;},addElementToDocument:function(elt){var port=this.rootImportForElement(elt.__importElement||elt);port.parentNode.insertBefore(elt,port);},trackElement:function(elt,callback){var self=this;var done=function(e){elt.removeEventListener("load",done);elt.removeEventListener("error",done);if(callback){callback(e);} +self.markParsingComplete(elt);self.parseNext();};elt.addEventListener("load",done);elt.addEventListener("error",done);if(isIE&&elt.localName==="style"){var fakeLoad=false;if(elt.textContent.indexOf("@import")==-1){fakeLoad=true;}else if(elt.sheet){fakeLoad=true;var csr=elt.sheet.cssRules;var len=csr?csr.length:0;for(var i=0,r;i=0;},hasResource:function(node){if(nodeIsImport(node)&&node.__doc===undefined){return false;} +return true;}};function nodeIsImport(elt){return elt.localName==="link"&&elt.rel===IMPORT_LINK_TYPE;} +function generateScriptDataUrl(script){var scriptContent=generateScriptContent(script);return"data:text/javascript;charset=utf-8,"+encodeURIComponent(scriptContent);} +function generateScriptContent(script){return script.textContent+generateSourceMapHint(script);} +function generateSourceMapHint(script){var owner=script.ownerDocument;owner.__importedScripts=owner.__importedScripts||0;var moniker=script.ownerDocument.baseURI;var num=owner.__importedScripts?"-"+owner.__importedScripts:"";owner.__importedScripts++;return"\n//# sourceURL="+moniker+num+".js\n";} +function cloneStyle(style){var clone=style.ownerDocument.createElement("style");clone.textContent=style.textContent;path.resolveUrlsInStyle(clone);return clone;} +scope.parser=importParser;scope.IMPORT_SELECTOR=IMPORT_SELECTOR;});window.HTMLImports.addModule(function(scope){var flags=scope.flags;var IMPORT_LINK_TYPE=scope.IMPORT_LINK_TYPE;var IMPORT_SELECTOR=scope.IMPORT_SELECTOR;var rootDocument=scope.rootDocument;var Loader=scope.Loader;var Observer=scope.Observer;var parser=scope.parser;var importer={documents:{},documentPreloadSelectors:IMPORT_SELECTOR,importsPreloadSelectors:[IMPORT_SELECTOR].join(","),loadNode:function(node){importLoader.addNode(node);},loadSubtree:function(parent){var nodes=this.marshalNodes(parent);importLoader.addNodes(nodes);},marshalNodes:function(parent){return parent.querySelectorAll(this.loadSelectorsForNode(parent));},loadSelectorsForNode:function(node){var doc=node.ownerDocument||node;return doc===rootDocument?this.documentPreloadSelectors:this.importsPreloadSelectors;},loaded:function(url,elt,resource,err,redirectedUrl){flags.load&&console.log("loaded",url,elt);elt.__resource=resource;elt.__error=err;if(isImportLink(elt)){var doc=this.documents[url];if(doc===undefined){doc=err?null:makeDocument(resource,redirectedUrl||url);if(doc){doc.__importLink=elt;this.bootDocument(doc);} +this.documents[url]=doc;} +elt.__doc=doc;} +parser.parseNext();},bootDocument:function(doc){this.loadSubtree(doc);this.observer.observe(doc);parser.parseNext();},loadedAll:function(){parser.parseNext();}};var importLoader=new Loader(importer.loaded.bind(importer),importer.loadedAll.bind(importer));importer.observer=new Observer();function isImportLink(elt){return isLinkRel(elt,IMPORT_LINK_TYPE);} +function isLinkRel(elt,rel){return elt.localName==="link"&&elt.getAttribute("rel")===rel;} +function hasBaseURIAccessor(doc){return!!Object.getOwnPropertyDescriptor(doc,"baseURI");} +function makeDocument(resource,url){var doc=document.implementation.createHTMLDocument(IMPORT_LINK_TYPE);doc._URL=url;var base=doc.createElement("base");base.setAttribute("href",url);if(!doc.baseURI&&!hasBaseURIAccessor(doc)){Object.defineProperty(doc,"baseURI",{value:url});} +var meta=doc.createElement("meta");meta.setAttribute("charset","utf-8");doc.head.appendChild(meta);doc.head.appendChild(base);doc.body.innerHTML=resource;if(window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap){HTMLTemplateElement.bootstrap(doc);} +return doc;} +if(!document.baseURI){var baseURIDescriptor={get:function(){var base=document.querySelector("base");return base?base.href:window.location.href;},configurable:true};Object.defineProperty(document,"baseURI",baseURIDescriptor);Object.defineProperty(rootDocument,"baseURI",baseURIDescriptor);} +scope.importer=importer;scope.importLoader=importLoader;});window.HTMLImports.addModule(function(scope){var parser=scope.parser;var importer=scope.importer;var dynamic={added:function(nodes){var owner,parsed,loading;for(var i=0,l=nodes.length,n;i=0){return;} +processingDocuments.push(doc);var imports=doc.querySelectorAll("link[rel="+IMPORT_LINK_TYPE+"]");for(var i=0,l=imports.length,n;i=0){implementPrototype(element,HTMLElement);} +return element;} +var domCreateElement=document.createElement.bind(document);var domCreateElementNS=document.createElementNS.bind(document);var isInstance;if(!Object.__proto__&&!useNative){isInstance=function(obj,ctor){if(obj instanceof ctor){return true;} +var p=obj;while(p){if(p===ctor.prototype){return true;} +p=p.__proto__;} +return false;};}else{isInstance=function(obj,base){return obj instanceof base;};} +function wrapDomMethodToForceUpgrade(obj,methodName){var orig=obj[methodName];obj[methodName]=function(){var n=orig.apply(this,arguments);upgradeAll(n);return n;};} +wrapDomMethodToForceUpgrade(Node.prototype,"cloneNode");wrapDomMethodToForceUpgrade(document,"importNode");document.registerElement=register;document.createElement=createElement;document.createElementNS=createElementNS;scope.registry=registry;scope.instanceof=isInstance;scope.reservedTagList=reservedTagList;scope.getRegisteredDefinition=getRegisteredDefinition;document.register=document.registerElement;});(function(scope){var useNative=scope.useNative;var initializeModules=scope.initializeModules;var isIE=scope.isIE;if(useNative){var nop=function(){};scope.watchShadow=nop;scope.upgrade=nop;scope.upgradeAll=nop;scope.upgradeDocumentTree=nop;scope.upgradeSubtree=nop;scope.takeRecords=nop;scope.instanceof=function(obj,base){return obj instanceof base;};}else{initializeModules();} +var upgradeDocumentTree=scope.upgradeDocumentTree;var upgradeDocument=scope.upgradeDocument;if(!window.wrap){if(window.ShadowDOMPolyfill){window.wrap=window.ShadowDOMPolyfill.wrapIfNeeded;window.unwrap=window.ShadowDOMPolyfill.unwrapIfNeeded;}else{window.wrap=window.unwrap=function(node){return node;};}} +if(window.HTMLImports){window.HTMLImports.__importsParsingHook=function(elt){if(elt.import){upgradeDocument(wrap(elt.import));}};} +function bootstrap(){upgradeDocumentTree(window.wrap(document));window.CustomElements.ready=true;var requestAnimationFrame=window.requestAnimationFrame||function(f){setTimeout(f,16);};requestAnimationFrame(function(){setTimeout(function(){window.CustomElements.readyTime=Date.now();if(window.HTMLImports){window.CustomElements.elapsed=window.CustomElements.readyTime-window.HTMLImports.readyTime;} +document.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:true}));});});} +if(document.readyState==="complete"||scope.flags.eager){bootstrap();}else if(document.readyState==="interactive"&&!window.attachEvent&&(!window.HTMLImports||window.HTMLImports.ready)){bootstrap();}else{var loadEvent=window.HTMLImports&&!window.HTMLImports.ready?"HTMLImportsLoaded":"DOMContentLoaded";window.addEventListener(loadEvent,bootstrap);}})(window.CustomElements);(function(scope){if(!Function.prototype.bind){Function.prototype.bind=function(scope){var self=this;var args=Array.prototype.slice.call(arguments,1);return function(){var args2=args.slice();args2.push.apply(args2,arguments);return self.apply(scope,args2);};};}})(window.WebComponents);(function(scope){var style=document.createElement("style");style.textContent=""+"body {"+"transition: opacity ease-in 0.2s;"+" } \n"+"body[unresolved] {"+"opacity: 0; display: block; overflow: hidden; position: relative;"+" } \n";var head=document.querySelector("head");head.insertBefore(style,head.firstChild);})(window.WebComponents);(function(scope){window.Platform=scope;})(window.WebComponents);'use strict';if(!window.CustomElements||window.CustomElements.hasNative){if(window.Polymer){throw new Error('Cannot proceed. Polymer already present.');} +window.Polymer={};window.Polymer.dom='shadow';} +(function(){function resolve(){document.body.removeAttribute('unresolved');} +if(window.WebComponents){addEventListener('WebComponentsReady',resolve);}else{if(document.readyState==='interactive'||document.readyState==='complete'){resolve();}else{addEventListener('DOMContentLoaded',resolve);}}}());window.Polymer={Settings:function(){var settings=window.Polymer||{};if(!settings.noUrlSettings){var parts=location.search.slice(1).split('&');for(var i=0,o;i=0&&(m=modules[i]);i--){if(m.__upgraded__){return;}else{CustomElements.upgrade(m);}}}}}());Polymer.Base._addFeature({_prepIs:function(){if(!this.is){var module=(document._currentScript||document.currentScript).parentNode;if(module.localName==='dom-module'){var id=module.id||module.getAttribute('name')||module.getAttribute('is');this.is=id;}} +if(this.is){this.is=this.is.toLowerCase();}}});Polymer.Base._addFeature({behaviors:[],_desugarBehaviors:function(){if(this.behaviors.length){this.behaviors=this._desugarSomeBehaviors(this.behaviors);}},_desugarSomeBehaviors:function(behaviors){var behaviorSet=[];behaviors=this._flattenBehaviorsList(behaviors);for(var i=behaviors.length-1;i>=0;i--){var b=behaviors[i];if(behaviorSet.indexOf(b)===-1){this._mixinBehavior(b);behaviorSet.unshift(b);}} +return behaviorSet;},_flattenBehaviorsList:function(behaviors){var flat=[];for(var i=0;i.'));} +if(this._template&&!this._template.content&&window.HTMLTemplateElement&&HTMLTemplateElement.decorate){HTMLTemplateElement.decorate(this._template);}},_stampTemplate:function(){if(this._template){this.root=this.instanceTemplate(this._template);}},instanceTemplate:function(template){var dom=document.importNode(template._content||template.content,true);return dom;}});(function(){var baseAttachedCallback=Polymer.Base.attachedCallback;var baseDetachedCallback=Polymer.Base.detachedCallback;Polymer.Base._addFeature({_hostStack:[],ready:function(){},_registerHost:function(host){this.dataHost=host=host||Polymer.Base._hostStack[Polymer.Base._hostStack.length-1];if(host&&host._clients){host._clients.push(this);} +this._clients=null;this._clientsReadied=false;},_beginHosting:function(){Polymer.Base._hostStack.push(this);if(!this._clients){this._clients=[];}},_endHosting:function(){Polymer.Base._hostStack.pop();},_tryReady:function(){this._readied=false;if(this._canReady()){this._ready();}},_canReady:function(){return!this.dataHost||this.dataHost._clientsReadied;},_ready:function(){this._beforeClientsReady();if(this._template){this._setupRoot();this._readyClients();} +this._clientsReadied=true;this._clients=null;this._afterClientsReady();this._readySelf();},_readyClients:function(){this._beginDistribute();var c$=this._clients;if(c$){for(var i=0,l=c$.length,c;i0||j>0){if(i==0){edits.push(EDIT_ADD);j--;continue;} +if(j==0){edits.push(EDIT_DELETE);i--;continue;} +var northWest=distances[i-1][j-1];var west=distances[i-1][j];var north=distances[i][j-1];var min;if(west]/g;function escapeReplace(c){switch(c){case'&':return'&';case'<':return'<';case'>':return'>';case'"':return'"';case'\xA0':return' ';}} +function escapeAttr(s){return s.replace(escapeAttrRegExp,escapeReplace);} +function escapeData(s){return s.replace(escapeDataRegExp,escapeReplace);} +function makeSet(arr){var set={};for(var i=0;i';case Node.TEXT_NODE:var data=node.data;if(parentNode&&plaintextParents[parentNode.localName]){return data;} +return escapeData(data);case Node.COMMENT_NODE:return'';default:console.error(node);throw new Error('not implemented');}} +function getInnerHTML(node,composed){if(node instanceof HTMLTemplateElement) +node=node.content;var s='';var c$=Polymer.dom(node).childNodes;for(var i=0,l=c$.length,child;i=this._FLUSH_MAX){console.warn('Polymer.dom.flush aborted. Flush may not be complete.');}},_prepareFlush:function(){if(this._needsTakeRecords){CustomElements.takeRecords();} +for(var i=0;i=0){this._staticFlushList.splice(i,1);}},addDebouncer:function(debouncer){this._debouncers.push(debouncer);this._finishDebouncer=Polymer.Debounce(this._finishDebouncer,this._finishFlush);},_finishFlush:function(){Polymer.dom._debouncers=[];}});Polymer.EventApi=function(){'use strict';var DomApi=Polymer.DomApi.ctor;var Settings=Polymer.Settings;DomApi.Event=function(event){this.event=event;};if(Settings.useShadow){DomApi.Event.prototype={get rootTarget(){return this.event.path[0];},get localTarget(){return this.event.target;},get path(){var path=this.event.path;if(!Array.isArray(path)){path=Array.prototype.slice.call(path);} +return path;}};}else{DomApi.Event.prototype={get rootTarget(){return this.event.target;},get localTarget(){var current=this.event.currentTarget;var currentRoot=current&&Polymer.dom(current).getOwnerRoot();var p$=this.path;for(var i=0;i=0){this._listeners.splice(i,1);handle._nodes=[];} +if(!this._hasListeners()){this._cleanup();this._isSetup=false;}},_setup:function(){this._observeContentElements(this.domApi.childNodes);},_cleanup:function(){this._unobserveContentElements(this.domApi.childNodes);},_hasListeners:function(){return Boolean(this._listeners.length);},_scheduleNotify:function(){if(this._debouncer){this._debouncer.stop();} +this._debouncer=Polymer.Debounce(this._debouncer,this._notify);this._debouncer.context=this;Polymer.dom.addDebouncer(this._debouncer);},notify:function(){if(this._hasListeners()){this._scheduleNotify();}},_notify:function(){this._beforeCallListeners();this._callListeners();},_beforeCallListeners:function(){this._updateContentElements();},_updateContentElements:function(){this._observeContentElements(this.domApi.childNodes);},_observeContentElements:function(elements){for(var i=0,n;i0){return~setTimeout(callback,waitTime);}else{this._twiddle.textContent=this._twiddleContent++;this._callbacks.push(callback);return this._currVal++;}},cancel:function(handle){if(handle<0){clearTimeout(~handle);}else{var idx=handle-this._lastVal;if(idx>=0){if(!this._callbacks[idx]){throw'invalid async handle: '+handle;} +this._callbacks[idx]=null;}}},_atEndOfMicrotask:function(){var len=this._callbacks.length;for(var i=0;ilastIndex){parts.push({literal:text.slice(lastIndex,m.index)});} +var mode=m[1][0];var negate=Boolean(m[2]);var value=m[3].trim();var customEvent,notifyEvent,colon;if(mode=='{'&&(colon=value.indexOf('::'))>0){notifyEvent=value.substring(colon+2);value=value.substring(0,colon);customEvent=true;} +parts.push({compoundIndex:parts.length,value:value,mode:mode,negate:negate,event:notifyEvent,customEvent:customEvent});lastIndex=re.lastIndex;} +if(lastIndex&&lastIndex-1;} +var SUPPORTS_PASSIVE=false;(function(){try{var opts=Object.defineProperty({},'passive',{get:function(){SUPPORTS_PASSIVE=true;}});window.addEventListener('test',null,opts);window.removeEventListener('test',null,opts);}catch(e){}}());function PASSIVE_TOUCH(eventName){if(isMouseEvent(eventName)||eventName==='touchend'){return;} +if(HAS_NATIVE_TA&&SUPPORTS_PASSIVE&&Polymer.Settings.passiveTouchGestures){return{passive:true};}} +var IS_TOUCH_ONLY=navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);var mouseCanceller=function(mouseEvent){var sc=mouseEvent.sourceCapabilities;if(sc&&!sc.firesTouchEvents){return;} +mouseEvent[HANDLED_OBJ]={skip:true};if(mouseEvent.type==='click'){var path=Polymer.dom(mouseEvent).path;if(path){for(var i=0;i=bcr.left&&x<=bcr.right&&(y>=bcr.top&&y<=bcr.bottom));} +return false;} +var POINTERSTATE={mouse:{target:null,mouseIgnoreJob:null},touch:{x:0,y:0,id:-1,scrollDecided:false}};function firstTouchAction(ev){var path=Polymer.dom(ev).path;var ta='auto';for(var i=0,n;i-1&&r.reset){r.reset();}}} +for(i=0,r;idx;}else if(ta==='pan-y'){prevent=dx>dy;} +if(prevent){ev.preventDefault();}else{Gestures.prevent('track');}}},add:function(node,evType,handler){node=wrap(node);var recognizer=this.gestures[evType];var deps=recognizer.deps;var name=recognizer.name;var gobj=node[GESTURE_KEY];if(!gobj){node[GESTURE_KEY]=gobj={};} +for(var i=0,dep,gd;iTRACK_LENGTH){this.moves.shift();} +this.moves.push(move);},movefn:null,upfn:null,prevent:false},reset:function(){this.info.state='start';this.info.started=false;this.info.moves=[];this.info.x=0;this.info.y=0;this.info.prevent=false;untrackDocument(this.info);},hasMovedEnough:function(x,y){if(this.info.prevent){return false;} +if(this.info.started){return true;} +var dx=Math.abs(this.info.x-x);var dy=Math.abs(this.info.y-y);return dx>=TRACK_DISTANCE||dy>=TRACK_DISTANCE;},mousedown:function(e){if(!hasLeftMouseButton(e)){return;} +var t=Gestures.findOriginalTarget(e);var self=this;var movefn=function movefn(e){var x=e.clientX,y=e.clientY;if(self.hasMovedEnough(x,y)){self.info.state=self.info.started?e.type==='mouseup'?'end':'track':'start';if(self.info.state==='start'){Gestures.prevent('tap');} +self.info.addMove({x:x,y:y});if(!hasLeftMouseButton(e)){self.info.state='end';untrackDocument(self.info);} +self.fire(t,e);self.info.started=true;}};var upfn=function upfn(e){if(self.info.started){movefn(e);} +untrackDocument(self.info);};trackDocument(this.info,movefn,upfn);this.info.x=e.clientX;this.info.y=e.clientY;},touchstart:function(e){var ct=e.changedTouches[0];this.info.x=ct.clientX;this.info.y=ct.clientY;},touchmove:function(e){var t=Gestures.findOriginalTarget(e);var ct=e.changedTouches[0];var x=ct.clientX,y=ct.clientY;if(this.hasMovedEnough(x,y)){if(this.info.state==='start'){Gestures.prevent('tap');} +this.info.addMove({x:x,y:y});this.fire(t,ct);this.info.state='track';this.info.started=true;}},touchend:function(e){var t=Gestures.findOriginalTarget(e);var ct=e.changedTouches[0];if(this.info.started){this.info.state='end';this.info.addMove({x:ct.clientX,y:ct.clientY});this.fire(t,ct,e);}},fire:function(target,touch,preventer){var secondlast=this.info.moves[this.info.moves.length-2];var lastmove=this.info.moves[this.info.moves.length-1];var dx=lastmove.x-this.info.x;var dy=lastmove.y-this.info.y;var ddx,ddy=0;if(secondlast){ddx=lastmove.x-secondlast.x;ddy=lastmove.y-secondlast.y;} +return Gestures.fire(target,'track',{state:this.info.state,x:touch.clientX,y:touch.clientY,dx:dx,dy:dy,ddx:ddx,ddy:ddy,sourceEvent:touch,preventer:preventer,hover:function(){return Gestures.deepTargetFind(touch.clientX,touch.clientY);}});}});Gestures.register({name:'tap',deps:['mousedown','click','touchstart','touchend'],flow:{start:['mousedown','touchstart'],end:['click','touchend']},emits:['tap'],info:{x:NaN,y:NaN,prevent:false},reset:function(){this.info.x=NaN;this.info.y=NaN;this.info.prevent=false;},save:function(e){this.info.x=e.clientX;this.info.y=e.clientY;},mousedown:function(e){if(hasLeftMouseButton(e)){this.save(e);}},click:function(e){if(hasLeftMouseButton(e)){this.forward(e);}},touchstart:function(e){this.save(e.changedTouches[0],e);},touchend:function(e){this.forward(e.changedTouches[0],e);},forward:function(e,preventer){var dx=Math.abs(e.clientX-this.info.x);var dy=Math.abs(e.clientY-this.info.y);var t=Gestures.findOriginalTarget(e);if(isNaN(dx)||isNaN(dy)||dx<=TAP_DISTANCE&&dy<=TAP_DISTANCE||isSyntheticClick(e)){if(!this.info.prevent){Gestures.fire(t,'tap',{x:e.clientX,y:e.clientY,sourceEvent:e,preventer:preventer});}}}});var DIRECTION_MAP={x:'pan-x',y:'pan-y',none:'none',all:'auto'};Polymer.Base._addFeature({_setupGestures:function(){this.__polymerGestures=null;},_listen:function(node,eventName,handler){if(Gestures.gestures[eventName]){Gestures.add(node,eventName,handler);}else{node.addEventListener(eventName,handler);}},_unlisten:function(node,eventName,handler){if(Gestures.gestures[eventName]){Gestures.remove(node,eventName,handler);}else{node.removeEventListener(eventName,handler);}},setScrollDirection:function(direction,node){node=node||this;Gestures.setTouchAction(node,DIRECTION_MAP[direction]||'auto');}});Polymer.Gestures=Gestures;}());(function(){'use strict';Polymer.Base._addFeature({$$:function(slctr){return Polymer.dom(this.root).querySelector(slctr);},toggleClass:function(name,bool,node){node=node||this;if(arguments.length==1){bool=!node.classList.contains(name);} +if(bool){Polymer.dom(node).classList.add(name);}else{Polymer.dom(node).classList.remove(name);}},toggleAttribute:function(name,bool,node){node=node||this;if(arguments.length==1){bool=!node.hasAttribute(name);} +if(bool){Polymer.dom(node).setAttribute(name,'');}else{Polymer.dom(node).removeAttribute(name);}},classFollows:function(name,toElement,fromElement){if(fromElement){Polymer.dom(fromElement).classList.remove(name);} +if(toElement){Polymer.dom(toElement).classList.add(name);}},attributeFollows:function(name,toElement,fromElement){if(fromElement){Polymer.dom(fromElement).removeAttribute(name);} +if(toElement){Polymer.dom(toElement).setAttribute(name,'');}},getEffectiveChildNodes:function(){return Polymer.dom(this).getEffectiveChildNodes();},getEffectiveChildren:function(){var list=Polymer.dom(this).getEffectiveChildNodes();return list.filter(function(n){return n.nodeType===Node.ELEMENT_NODE;});},getEffectiveTextContent:function(){var cn=this.getEffectiveChildNodes();var tc=[];for(var i=0,c;c=cn[i];i++){if(c.nodeType!==Node.COMMENT_NODE){tc.push(Polymer.dom(c).textContent);}} +return tc.join('');},queryEffectiveChildren:function(slctr){var e$=Polymer.dom(this).queryDistributedElements(slctr);return e$&&e$[0];},queryAllEffectiveChildren:function(slctr){return Polymer.dom(this).queryDistributedElements(slctr);},getContentChildNodes:function(slctr){var content=Polymer.dom(this.root).querySelector(slctr||'content');return content?Polymer.dom(content).getDistributedNodes():[];},getContentChildren:function(slctr){return this.getContentChildNodes(slctr).filter(function(n){return n.nodeType===Node.ELEMENT_NODE;});},fire:function(type,detail,options){options=options||Polymer.nob;var node=options.node||this;detail=detail===null||detail===undefined?{}:detail;var bubbles=options.bubbles===undefined?true:options.bubbles;var cancelable=Boolean(options.cancelable);var useCache=options._useCache;var event=this._getEvent(type,bubbles,cancelable,useCache);event.detail=detail;if(useCache){this.__eventCache[type]=null;} +node.dispatchEvent(event);if(useCache){this.__eventCache[type]=event;} +return event;},__eventCache:{},_getEvent:function(type,bubbles,cancelable,useCache){var event=useCache&&this.__eventCache[type];if(!event||(event.bubbles!=bubbles||event.cancelable!=cancelable)){event=new Event(type,{bubbles:Boolean(bubbles),cancelable:cancelable});} +return event;},async:function(callback,waitTime){var self=this;return Polymer.Async.run(function(){callback.call(self);},waitTime);},cancelAsync:function(handle){Polymer.Async.cancel(handle);},arrayDelete:function(path,item){var index;if(Array.isArray(path)){index=path.indexOf(item);if(index>=0){return path.splice(index,1);}}else{var arr=this._get(path);index=arr.indexOf(item);if(index>=0){return this.splice(path,index,1);}}},transform:function(transform,node){node=node||this;node.style.webkitTransform=transform;node.style.transform=transform;},translate3d:function(x,y,z,node){node=node||this;this.transform('translate3d('+x+','+y+','+z+')',node);},importHref:function(href,onload,onerror,optAsync){var link=document.createElement('link');link.rel='import';link.href=href;var list=Polymer.Base.importHref.imported=Polymer.Base.importHref.imported||{};var cached=list[link.href];var imprt=cached||link;var self=this;var loadListener=function(e){e.target.__firedLoad=true;e.target.removeEventListener('load',loadListener);e.target.removeEventListener('error',errorListener);return onload.call(self,e);};var errorListener=function(e){e.target.__firedError=true;e.target.removeEventListener('load',loadListener);e.target.removeEventListener('error',errorListener);return onerror.call(self,e);};if(onload){imprt.addEventListener('load',loadListener);} +if(onerror){imprt.addEventListener('error',errorListener);} +if(cached){if(cached.__firedLoad){cached.dispatchEvent(new Event('load'));} +if(cached.__firedError){cached.dispatchEvent(new Event('error'));}}else{list[link.href]=link;optAsync=Boolean(optAsync);if(optAsync){link.setAttribute('async','');} +document.head.appendChild(link);} +return imprt;},create:function(tag,props){var elt=document.createElement(tag);if(props){for(var n in props){elt[n]=props[n];}} +return elt;},isLightDescendant:function(node){return this!==node&&this.contains(node)&&Polymer.dom(this).getOwnerRoot()===Polymer.dom(node).getOwnerRoot();},isLocalDescendant:function(node){return this.root===Polymer.dom(node).getOwnerRoot();}});if(!Polymer.Settings.useNativeCustomElements){var importHref=Polymer.Base.importHref;Polymer.Base.importHref=function(href,onload,onerror,optAsync){CustomElements.ready=false;var loadFn=function(e){CustomElements.upgradeDocumentTree(document);CustomElements.ready=true;if(onload){return onload.call(this,e);}};return importHref.call(this,href,loadFn,onerror,optAsync);};}}());Polymer.Bind={prepareModel:function(model){Polymer.Base.mixin(model,this._modelApi);},_modelApi:{_notifyChange:function(source,event,value){value=value===undefined?this[source]:value;event=event||Polymer.CaseMap.camelToDashCase(source)+'-changed';this.fire(event,{value:value},{bubbles:false,cancelable:false,_useCache:Polymer.Settings.eventDataCache||!Polymer.Settings.isIE});},_propertySetter:function(property,value,effects,fromAbove){var old=this.__data__[property];if(old!==value&&(old===old||value===value)){this.__data__[property]=value;if(typeof value=='object'){this._clearPath(property);} +if(this._propertyChanged){this._propertyChanged(property,value,old);} +if(effects){this._effectEffects(property,value,effects,old,fromAbove);}} +return old;},__setProperty:function(property,value,quiet,node){node=node||this;var effects=node._propertyEffects&&node._propertyEffects[property];if(effects){node._propertySetter(property,value,effects,quiet);}else if(node[property]!==value){node[property]=value;}},_effectEffects:function(property,value,effects,old,fromAbove){for(var i=0,l=effects.length,fx;i1||effect.dynamicFn;for(var i=0,l=args.length;i='0'&&fc<='9'){fc='#';} +switch(fc){case'\'':case'"':a.value=arg.slice(1,-1);a.literal=true;break;case'#':a.value=Number(arg);a.literal=true;break;} +if(!a.literal){a.model=Polymer.Path.root(arg);a.structured=Polymer.Path.isDeep(arg);if(a.structured){a.wildcard=arg.slice(-2)=='.*';if(a.wildcard){a.name=arg.slice(0,-2);}}} +return a;},_marshalInstanceEffects:function(){Polymer.Bind.prepareInstance(this);if(this._bindListeners){Polymer.Bind.setupBindListeners(this);}},_applyEffectValue:function(info,value){var node=this._nodes[info.index];var property=info.name;value=this._computeFinalAnnotationValue(node,property,value,info);if(info.kind=='attribute'){this.serializeValueToAttribute(value,property,node);}else{var pinfo=node._propertyInfo&&node._propertyInfo[property];if(pinfo&&pinfo.readOnly){return;} +this.__setProperty(property,value,Polymer.Settings.suppressBindingNotifications,node);}},_computeFinalAnnotationValue:function(node,property,value,info){if(info.negate){value=!value;} +if(info.isCompound){var storage=node.__compoundStorage__[property];storage[info.compoundIndex]=value;value=storage.join('');} +if(info.kind!=='attribute'){if(property==='className'){value=this._scopeElementClass(node,value);} +if(property==='textContent'||node.localName=='input'&&property=='value'){value=value==undefined?'':value;}} +return value;},_executeStaticEffects:function(){if(this._propertyEffects&&this._propertyEffects.__static__){this._effectEffects('__static__',null,this._propertyEffects.__static__);}}});(function(){var usePolyfillProto=Polymer.Settings.usePolyfillProto;var avoidInstanceProperties=Boolean(Object.getOwnPropertyDescriptor(document.documentElement,'properties'));Polymer.Base._addFeature({_setupConfigure:function(initialConfig){this._config={};this._handlers=[];this._aboveConfig=null;if(initialConfig){for(var i in initialConfig){if(initialConfig[i]!==undefined){this._config[i]=initialConfig[i];}}}},_marshalAttributes:function(){this._takeAttributesToModel(this._config);},_attributeChangedImpl:function(name){var model=this._clientsReadied?this:this._config;this._setAttributeToProperty(model,name);},_configValue:function(name,value){var info=this._propertyInfo[name];if(!info||!info.readOnly){this._config[name]=value;}},_beforeClientsReady:function(){this._configure();},_configure:function(){this._configureAnnotationReferences();this._configureInstanceProperties();this._aboveConfig=this.mixin({},this._config);var config={};for(var i=0;i1){for(var i=0;i+~])'},resolveCss:Polymer.ResolveUrl.resolveCss,parser:Polymer.CssParse,ruleTypes:Polymer.CssParse.types};}();Polymer.StyleTransformer=function(){var styleUtil=Polymer.StyleUtil;var settings=Polymer.Settings;var api={dom:function(node,scope,useAttr,shouldRemoveScope){this._transformDom(node,scope||'',useAttr,shouldRemoveScope);},_transformDom:function(node,selector,useAttr,shouldRemoveScope){if(node.setAttribute){this.element(node,selector,useAttr,shouldRemoveScope);} +var c$=Polymer.dom(node).childNodes;for(var i=0;i *');rule.selector=self._dirShadowTransform(rule.selector);if(callback){callback(rule);}};} +for(var i=0,l=styles.length,s;i=0&&i *');selector=selector.replace(CONTENT_START,HOST+' $1');selector=this._ensureScopedDir(selector);selector=selector.replace(SIMPLE_SELECTOR_SEP,function(m,c,s){if(!stop){var info=self._transformCompoundSelector(s,c,scope,hostScope);stop=stop||info.stop;hostContext=hostContext||info.hostContext;dir=dir||info.dir;c=info.combinator;s=info.value;}else{s=s.replace(SCOPE_JUMP,' ');} +return c+s;});if(hostContext){selector=selector.replace(HOST_CONTEXT_PAREN,function(m,pre,paren,post){var replacement=pre+paren+' '+hostScope+post+COMPLEX_SELECTOR_SEP+' '+pre+hostScope+paren+post;if(dir){replacement+=self._additionalDirSelectors(paren,post,hostScope);} +return replacement;});} +return selector;},_transformDir:function(s){s=s.replace(HOST_DIR,HOST_DIR_REPLACE);s=s.replace(DIR_PAREN,DIR_REPLACE);return s;},_transformCompoundSelector:function(selector,combinator,scope,hostScope){var jumpIndex=selector.search(SCOPE_JUMP);var hostContext=false;var dir=false;if(selector.match(DIR_PAREN)){selector=this._transformDir(selector);dir=true;} +if(selector.indexOf(HOST_CONTEXT)>=0){hostContext=true;}else if(selector.indexOf(HOST)>=0){selector=this._transformHostSelector(selector,hostScope);}else if(jumpIndex!==0){selector=scope?this._transformSimpleSelector(selector,scope):selector;} +if(selector.indexOf(CONTENT)>=0){combinator='';} +var stop;if(jumpIndex>=0){selector=selector.replace(SCOPE_JUMP,' ');stop=true;} +return{value:selector,combinator:combinator,stop:stop,hostContext:hostContext,dir:dir};},_transformSimpleSelector:function(selector,scope){var p$=selector.split(PSEUDO_PREFIX);p$[0]+=scope;return p$.join(PSEUDO_PREFIX);},_transformHostSelector:function(selector,hostScope){var m=selector.match(HOST_PAREN);var paren=m&&m[2].trim()||'';if(paren){if(!paren[0].match(SIMPLE_SELECTOR_PREFIX)){var typeSelector=paren.split(SIMPLE_SELECTOR_PREFIX)[0];if(typeSelector===hostScope){return paren;}else{return SELECTOR_NO_MATCH;}}else{return selector.replace(HOST_PAREN,function(m,host,paren){return hostScope+paren;});}}else{return selector.replace(HOST,hostScope);}},documentRule:function(rule){rule.selector=rule.parsedSelector;this.normalizeRootSelector(rule);if(!settings.useNativeShadow){this._transformRule(rule,this._transformDocumentSelector);}},normalizeRootSelector:function(rule){rule.selector=rule.selector.replace(ROOT,'html');var parts=this._splitSelectorList(rule.selector);parts=parts.filter(function(part){return!part.match(HOST_OR_HOST_GT_STAR);});rule.selector=parts.join(COMPLEX_SELECTOR_SEP);},_transformDocumentSelector:function(selector){return this._transformComplexSelector(selector,SCOPE_DOC_SELECTOR);},_slottedToContent:function(cssText){return cssText.replace(SLOTTED_PAREN,CONTENT+'> $1');},_dirShadowTransform:function(selector){if(!selector.match(/:dir\(/)){return selector;} +return this._splitSelectorList(selector).map(function(s){s=this._ensureScopedDir(s);s=this._transformDir(s);var m=HOST_CONTEXT_PAREN.exec(s);if(m){s+=this._additionalDirSelectors(m[2],m[3],'');} +return s;},this).join(COMPLEX_SELECTOR_SEP);},SCOPE_NAME:'style-scope'};var SCOPE_NAME=api.SCOPE_NAME;var SCOPE_DOC_SELECTOR=':not(['+SCOPE_NAME+'])'+':not(.'+SCOPE_NAME+')';var COMPLEX_SELECTOR_SEP=',';var SIMPLE_SELECTOR_SEP=/(^|[\s>+~]+)((?:\[.+?\]|[^\s>+~=\[])+)/g;var SIMPLE_SELECTOR_PREFIX=/[[.:#*]/;var HOST=':host';var ROOT=':root';var HOST_PAREN=/(:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/;var HOST_CONTEXT=':host-context';var HOST_CONTEXT_PAREN=/(.*)(?::host-context)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))(.*)/;var CONTENT='::content';var SCOPE_JUMP=/::content|::shadow|\/deep\//;var CSS_CLASS_PREFIX='.';var CSS_ATTR_PREFIX='['+SCOPE_NAME+'~=';var CSS_ATTR_SUFFIX=']';var PSEUDO_PREFIX=':';var CLASS='class';var CONTENT_START=new RegExp('^('+CONTENT+')');var SELECTOR_NO_MATCH='should_not_match';var SLOTTED_PAREN=/(?:::slotted)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;var HOST_OR_HOST_GT_STAR=/:host(?:\s*>\s*\*)?/;var DIR_PAREN=/(.*):dir\((ltr|rtl)\)/;var DIR_REPLACE=':host-context([dir="$2"]) $1';var HOST_DIR=/:host\(:dir\((rtl|ltr)\)\)/g;var HOST_DIR_REPLACE=':host-context([dir="$1"])';return api;}();Polymer.StyleExtends=function(){var styleUtil=Polymer.StyleUtil;return{hasExtends:function(cssText){return Boolean(cssText.match(this.rx.EXTEND));},transform:function(style){var rules=styleUtil.rulesForStyle(style);var self=this;styleUtil.forEachRule(rules,function(rule){self._mapRuleOntoParent(rule);if(rule.parent){var m;while(m=self.rx.EXTEND.exec(rule.cssText)){var extend=m[1];var extendor=self._findExtendor(extend,rule);if(extendor){self._extendRule(rule,extendor);}}} +rule.cssText=rule.cssText.replace(self.rx.EXTEND,'');});return styleUtil.toCssText(rules,function(rule){if(rule.selector.match(self.rx.STRIP)){rule.cssText='';}},true);},_mapRuleOntoParent:function(rule){if(rule.parent){var map=rule.parent.map||(rule.parent.map={});var parts=rule.selector.split(',');for(var i=0,p;i1){property=sp[0].trim();value=replaceInitialOrInherit(property,sp.slice(1).join(':'));out[property]=value;}}} +return out;} +function invalidateMixinEntry(mixinEntry){var currentProto=ApplyShim.__currentElementProto;var currentElementName=currentProto&¤tProto.is;for(var elementName in mixinEntry.dependants){if(elementName!==currentElementName){mixinEntry.dependants[elementName].__applyShimInvalid=true;}}} +function produceCssProperties(matchText,propertyName,valueProperty,valueMixin){if(valueProperty){styleUtil.processVariableAndFallback(valueProperty,function(prefix,value){if(value&&mapGet(value)){valueMixin='@apply '+value+';';}});} +if(!valueMixin){return matchText;} +var mixinAsProperties=consumeCssProperties(valueMixin);var prefix=matchText.slice(0,matchText.indexOf('--'));var mixinValues=cssTextToMap(mixinAsProperties);var combinedProps=mixinValues;var mixinEntry=mapGet(propertyName);var oldProps=mixinEntry&&mixinEntry.properties;if(oldProps){combinedProps=Object.create(oldProps);combinedProps=Polymer.Base.mixin(combinedProps,mixinValues);}else{mapSet(propertyName,combinedProps);} +var out=[];var p,v;var needToInvalidate=false;for(p in combinedProps){v=mixinValues[p];if(v===undefined){v='initial';} +if(oldProps&&!(p in oldProps)){needToInvalidate=true;} +out.push(propertyName+MIXIN_VAR_SEP+p+': '+v);} +if(needToInvalidate){invalidateMixinEntry(mixinEntry);} +if(mixinEntry){mixinEntry.properties=combinedProps;} +if(valueProperty){prefix=matchText+';'+prefix;} +return prefix+out.join('; ')+';';} +function fixVars(matchText,varA,varB){return'var('+varA+','+'var('+varB+'))';} +function atApplyToCssProperties(mixinName,fallbacks){mixinName=mixinName.replace(APPLY_NAME_CLEAN,'');var vars=[];var mixinEntry=mapGet(mixinName);if(!mixinEntry){mapSet(mixinName,{});mixinEntry=mapGet(mixinName);} +if(mixinEntry){var currentProto=ApplyShim.__currentElementProto;if(currentProto){mixinEntry.dependants[currentProto.is]=currentProto;} +var p,parts,f;for(p in mixinEntry.properties){f=fallbacks&&fallbacks[p];parts=[p,': var(',mixinName,MIXIN_VAR_SEP,p];if(f){parts.push(',',f);} +parts.push(')');vars.push(parts.join(''));}} +return vars.join('; ');} +function consumeCssProperties(text){var m;while(m=MIXIN_MATCH.exec(text)){var matchText=m[0];var mixinName=m[1];var idx=m.index;var applyPos=idx+matchText.indexOf('@apply');var afterApplyPos=idx+matchText.length;var textBeforeApply=text.slice(0,applyPos);var textAfterApply=text.slice(afterApplyPos);var defaults=cssTextToMap(textBeforeApply);var replacement=atApplyToCssProperties(mixinName,defaults);text=[textBeforeApply,replacement,textAfterApply].join('');MIXIN_MATCH.lastIndex=idx+replacement.length;} +return text;} +var ApplyShim={_measureElement:null,_map:mixinMap,_separator:MIXIN_VAR_SEP,transform:function(styles,elementProto){this.__currentElementProto=elementProto;styleUtil.forRulesInStyles(styles,this._boundFindDefinitions);styleUtil.forRulesInStyles(styles,this._boundFindApplications);if(elementProto){elementProto.__applyShimInvalid=false;} +this.__currentElementProto=null;},_findDefinitions:function(rule){var cssText=rule.parsedCssText;cssText=cssText.replace(BAD_VAR,fixVars);cssText=cssText.replace(VAR_ASSIGN,produceCssProperties);rule.cssText=cssText;if(rule.selector===':root'){rule.selector=':host > *';}},_findApplications:function(rule){rule.cssText=consumeCssProperties(rule.cssText);},transformRule:function(rule){this._findDefinitions(rule);this._findApplications(rule);},_getInitialValueForProperty:function(property){if(!this._measureElement){this._measureElement=document.createElement('meta');this._measureElement.style.all='initial';document.head.appendChild(this._measureElement);} +return window.getComputedStyle(this._measureElement).getPropertyValue(property);}};ApplyShim._boundTransformRule=ApplyShim.transformRule.bind(ApplyShim);ApplyShim._boundFindDefinitions=ApplyShim._findDefinitions.bind(ApplyShim);ApplyShim._boundFindApplications=ApplyShim._findApplications.bind(ApplyShim);return ApplyShim;}();(function(){var prepElement=Polymer.Base._prepElement;var nativeShadow=Polymer.Settings.useNativeShadow;var styleUtil=Polymer.StyleUtil;var styleTransformer=Polymer.StyleTransformer;var styleExtends=Polymer.StyleExtends;var applyShim=Polymer.ApplyShim;var settings=Polymer.Settings;Polymer.Base._addFeature({_prepElement:function(element){if(this._encapsulateStyle&&this.__cssBuild!=='shady'){styleTransformer.element(element,this.is,this._scopeCssViaAttr);} +prepElement.call(this,element);},_prepStyles:function(){if(this._encapsulateStyle===undefined){this._encapsulateStyle=!nativeShadow;} +if(!nativeShadow){this._scopeStyle=styleUtil.applyStylePlaceHolder(this.is);} +this.__cssBuild=styleUtil.cssBuildTypeForModule(this.is);},_prepShimStyles:function(){if(this._template){var hasTargetedCssBuild=styleUtil.isTargetedBuild(this.__cssBuild);if(settings.useNativeCSSProperties&&this.__cssBuild==='shadow'&&hasTargetedCssBuild){if(settings.preserveStyleIncludes){styleUtil.styleIncludesToTemplate(this._template);} +return;} +this._styles=this._styles||this._collectStyles();if(settings.useNativeCSSProperties&&!this.__cssBuild){applyShim.transform(this._styles,this);} +var cssText=settings.useNativeCSSProperties&&hasTargetedCssBuild?this._styles.length&&this._styles[0].textContent.trim():styleTransformer.elementStyles(this);this._prepStyleProperties();if(!this._needsStyleProperties()&&cssText){styleUtil.applyCss(cssText,this.is,nativeShadow?this._template.content:null,this._scopeStyle);}}else{this._styles=[];}},_collectStyles:function(){var styles=[];var cssText='',m$=this.styleModules;if(m$){for(var i=0,l=m$.length,m;i=0){property=this.valueForProperties(property,props);}else{var self=this;var fn=function(prefix,value,fallback,suffix){var propertyValue=self.valueForProperty(props[value],props);if(!propertyValue||propertyValue==='initial'){propertyValue=self.valueForProperty(props[fallback]||fallback,props)||fallback;}else if(propertyValue==='apply-shim-inherit'){propertyValue='inherit';} +return prefix+(propertyValue||'')+suffix;};property=styleUtil.processVariableAndFallback(property,fn);}} +return property&&property.trim()||'';},valueForProperties:function(property,props){var parts=property.split(';');for(var i=0,p,m;i\s*\*/,_checkRoot:function(hostScope,selector){return Boolean(selector.match(this._rootSelector))||hostScope==='html'&&selector.indexOf('html')>-1;},whenHostOrRootRule:function(scope,rule,style,callback){if(!rule.propertyInfo){self.decorateRule(rule);} +if(!rule.propertyInfo.properties){return;} +var hostScope=scope.is?styleTransformer._calcHostScope(scope.is,scope.extends):'html';var parsedSelector=rule.parsedSelector;var isRoot=this._checkRoot(hostScope,parsedSelector);var isHost=!isRoot&&parsedSelector.indexOf(':host')===0;var cssBuild=scope.__cssBuild||style.__cssBuild;if(cssBuild==='shady'){isRoot=parsedSelector===hostScope+' > *.'+hostScope||parsedSelector.indexOf('html')>-1;isHost=!isRoot&&parsedSelector.indexOf(hostScope)===0;} +if(!isRoot&&!isHost){return;} +var selectorToMatch=hostScope;if(isHost){if(settings.useNativeShadow&&!rule.transformedSelector){rule.transformedSelector=styleTransformer._transformRuleCss(rule,styleTransformer._transformComplexSelector,scope.is,hostScope);} +selectorToMatch=rule.transformedSelector||rule.parsedSelector;} +if(isRoot&&hostScope==='html'){selectorToMatch=rule.transformedSelector||rule.parsedSelector;} +callback({selector:selectorToMatch,isHost:isHost,isRoot:isRoot});},hostAndRootPropertiesForScope:function(scope){var hostProps={},rootProps={},self=this;styleUtil.forActiveRulesInStyles(scope._styles,function(rule,style){self.whenHostOrRootRule(scope,rule,style,function(info){var element=scope._element||scope;if(matchesSelector.call(element,info.selector)){if(info.isHost){self.collectProperties(rule,hostProps);}else{self.collectProperties(rule,rootProps);}}});});return{rootProps:rootProps,hostProps:hostProps};},transformStyles:function(element,properties,scopeSelector){var self=this;var hostSelector=styleTransformer._calcHostScope(element.is,element.extends);var rxHostSelector=element.extends?'\\'+hostSelector.slice(0,-1)+'\\]':hostSelector;var hostRx=new RegExp(this.rx.HOST_PREFIX+rxHostSelector+this.rx.HOST_SUFFIX);var keyframeTransforms=this._elementKeyframeTransforms(element,scopeSelector);return styleTransformer.elementStyles(element,function(rule){self.applyProperties(rule,properties);if(!settings.useNativeShadow&&!Polymer.StyleUtil.isKeyframesSelector(rule)&&rule.cssText){self.applyKeyframeTransforms(rule,keyframeTransforms);self._scopeSelector(rule,hostRx,hostSelector,element._scopeCssViaAttr,scopeSelector);}});},_elementKeyframeTransforms:function(element,scopeSelector){var keyframesRules=element._styles._keyframes;var keyframeTransforms={};if(!settings.useNativeShadow&&keyframesRules){for(var i=0,keyframesRule=keyframesRules[i];i-1){style.textContent=cssText;} +styleUtil.applyStyle(style,null,element._scopeStyle);}} +if(style){style._useCount=style._useCount||0;if(element._customStyle!=style){style._useCount++;} +element._customStyle=style;} +return style;},mixinCustomStyle:function(props,customStyle){var v;for(var i in customStyle){v=customStyle[i];if(v||v===0){props[i]=v;}}},updateNativeStyleProperties:function(element,properties){var oldPropertyNames=element.__customStyleProperties;if(oldPropertyNames){for(var i=0;ithis.MAX){s$.shift();}},retrieve:function(is,keyValues,keyStyles){var cache=this.cache[is];if(cache){for(var i=cache.length-1,data;i>=0;i--){data=cache[i];if(keyStyles===data.styles&&this._objectsEqual(keyValues,data.keyValues)){return data;}}}},clear:function(){this.cache={};},_objectsEqual:function(target,source){var t,s;for(var i in target){t=target[i],s=source[i];if(!(typeof t==='object'&&t?this._objectsStrictlyEqual(t,s):t===s)){return false;}} +if(Array.isArray(target)){return target.length===source.length;} +return true;},_objectsStrictlyEqual:function(target,source){return this._objectsEqual(target,source)&&this._objectsEqual(source,target);}};}());Polymer.StyleDefaults=function(){var styleProperties=Polymer.StyleProperties;var StyleCache=Polymer.StyleCache;var nativeVariables=Polymer.Settings.useNativeCSSProperties;var api={_styles:[],_properties:null,customStyle:{},_styleCache:new StyleCache(),_element:Polymer.DomApi.wrap(document.documentElement),addStyle:function(style){this._styles.push(style);this._properties=null;},get _styleProperties(){if(!this._properties){styleProperties.decorateStyles(this._styles,this);this._styles._scopeStyleProperties=null;this._properties=styleProperties.hostAndRootPropertiesForScope(this).rootProps;styleProperties.mixinCustomStyle(this._properties,this.customStyle);styleProperties.reify(this._properties);} +return this._properties;},hasStyleProperties:function(){return Boolean(this._properties);},_needsStyleProperties:function(){},_computeStyleProperties:function(){return this._styleProperties;},updateStyles:function(properties){this._properties=null;if(properties){Polymer.Base.mixin(this.customStyle,properties);} +this._styleCache.clear();for(var i=0,s;i0){added.push(key);}} +return[{removed:removed,added:added}];}};Polymer.Collection.get=function(userArray){return Polymer._collections.get(userArray)||new Polymer.Collection(userArray);};Polymer.Collection.applySplices=function(userArray,splices){var coll=Polymer._collections.get(userArray);return coll?coll._applySplices(splices):null;};Polymer({is:'dom-repeat',extends:'template',_template:null,properties:{items:{type:Array},as:{type:String,value:'item'},indexAs:{type:String,value:'index'},sort:{type:Function,observer:'_sortChanged'},filter:{type:Function,observer:'_filterChanged'},observe:{type:String,observer:'_observeChanged'},delay:Number,renderedItemCount:{type:Number,notify:!Polymer.Settings.suppressTemplateNotifications,readOnly:true},initialCount:{type:Number,observer:'_initializeChunking'},targetFramerate:{type:Number,value:20},notifyDomChange:{type:Boolean},_targetFrameTime:{type:Number,computed:'_computeFrameTime(targetFramerate)'}},behaviors:[Polymer.Templatizer],observers:['_itemsChanged(items.*)'],created:function(){this._instances=[];this._pool=[];this._limit=Infinity;var self=this;this._boundRenderChunk=function(){self._renderChunk();};},detached:function(){this.__isDetached=true;for(var i=0;i=0;i--){var inst=this._instances[i];if(inst.isPlaceholder&&i=this._limit){inst=this._downgradeInstance(i,inst.__key__);} +keyToIdx[inst.__key__]=i;if(!inst.isPlaceholder){inst.__setProperty(this.indexAs,i,true);}} +this._pool.length=0;this._setRenderedItemCount(this._instances.length);if(!Polymer.Settings.suppressTemplateNotifications||this.notifyDomChange){this.fire('dom-change');} +this._tryRenderChunk();},_applyFullRefresh:function(){var c=this.collection;var keys;if(this._sortFn){keys=c?c.getKeys():[];}else{keys=[];var items=this.items;if(items){for(var i=0;i=i;j--){this._detachAndRemoveInstance(j);}},_numericSort:function(a,b){return a-b;},_applySplicesUserSort:function(splices){var c=this.collection;var keyMap={};var key;for(var i=0,s;i=0;i--){var idx=removedIdxs[i];if(idx!==undefined){this._detachAndRemoveInstance(idx);}}} +var self=this;if(addedKeys.length){if(this._filterFn){addedKeys=addedKeys.filter(function(a){return self._filterFn(c.getItem(a));});} +addedKeys.sort(function(a,b){return self._sortFn(c.getItem(a),c.getItem(b));});var start=0;for(i=0;i>1;var midKey=this._instances[mid].__key__;var cmp=this._sortFn(c.getItem(midKey),item);if(cmp<0){start=mid+1;}else if(cmp>0){end=mid-1;}else{idx=mid;break;}} +if(idx<0){idx=end+1;} +this._insertPlaceholder(idx,key);return idx;},_applySplicesArrayOrder:function(splices){for(var i=0,s;i=0){path=this.as+'.'+path.substring(dot+1);inst._notifyPath(path,value,true);}else{inst.__setProperty(this.as,value,true);}}}},itemForElement:function(el){var instance=this.modelForElement(el);return instance&&instance[this.as];},keyForElement:function(el){var instance=this.modelForElement(el);return instance&&instance.__key__;},indexForElement:function(el){var instance=this.modelForElement(el);return instance&&instance[this.indexAs];}});Polymer({is:'array-selector',_template:null,properties:{items:{type:Array,observer:'clearSelection'},multi:{type:Boolean,value:false,observer:'clearSelection'},selected:{type:Object,notify:true},selectedItem:{type:Object,notify:true},toggle:{type:Boolean,value:false}},clearSelection:function(){if(Array.isArray(this.selected)){for(var i=0;i