forked from fin-hypergrid/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fin-hypergrid.min.html
29 lines (29 loc) · 426 KB
/
fin-hypergrid.min.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!--
The OpenFin Hypergrid is a high performant canvas based general grid control. It is implemented as a Polymer HTML5 web-component. See [Polymer](https://www.polymer-project.org/) and [Web Components](http://www.w3.org/TR/components-intro/).
<br>
### Openfin polymerized hypergrid Demo
To see the "pink" demo
- see the [github pages hosted deplyment](http://openfin.github.io/fin-hypergrid/components/fin-hypergrid/demo.html) or
- run the [openfin installer](https://dl.openfin.co/services/download?fileName=hypergrid-demo-installer&config=http://openfin.github.io/fin-hypergrid/components/fin-hypergrid/demo.json)
### The Hypergrid is dependent on several other OpenFin projects
- [fin-canvas](http://stevewirts.github.io/fin-canvas/components/fin-canvas/): a wrapper to provide a simpler interface to the HTML5 canvas component
- [fin-rectangle](http://stevewirts.github.io/fin-rectangle/components/fin-rectangle/): a small library providing Point and Rectangle objects
- [fin-vampire-bar](http://datamadic.github.io/fin-vampire-bar/components/fin-vampire-bar/): a web-component based general scroll bar control
### Pluggable Grid Behaviors
The Hypergrid design makes no assumptions about the data you wish to view which allows for external data sources and external manipulation and analytics. Manipulations such as sorting, aggregation, and grouping can be achieved using best of breed high-performant real time tools designed for such purposes. All the code that impacts these operations has been factored into an Object called [PluggableGridBehavior](index.html#fin-hypergrid-behavior-default). A PluggableGridBehavior can be thought of as a traditional tablemodel but with a little more responsibility. There are Three example PluggableGridBehaviors provided, the base or DefaultGridBehavior, a QGridBehavior, and an InMemoryGridBehavior.
@group OpenFin hypergrid
@element fin-hypergrid
@homepage http://github.com/openfin/fin-hypergrid
--><html><head><style shim-shadowdom="">html /deep/ [layout][horizontal],html /deep/ [layout][vertical]{display:-ms-flexbox;display:-webkit-flex;display:flex}html /deep/ [layout][horizontal][inline],html /deep/ [layout][vertical][inline]{display:-ms-inline-flexbox;display:-webkit-inline-flex;display:inline-flex}html /deep/ [layout][horizontal]{-ms-flex-direction:row;-webkit-flex-direction:row;flex-direction:row}html /deep/ [layout][horizontal][reverse]{-ms-flex-direction:row-reverse;-webkit-flex-direction:row-reverse;flex-direction:row-reverse}html /deep/ [layout][vertical]{-ms-flex-direction:column;-webkit-flex-direction:column;flex-direction:column}html /deep/ [layout][vertical][reverse]{-ms-flex-direction:column-reverse;-webkit-flex-direction:column-reverse;flex-direction:column-reverse}html /deep/ [layout][wrap]{-ms-flex-wrap:wrap;-webkit-flex-wrap:wrap;flex-wrap:wrap}html /deep/ [layout][wrap-reverse]{-ms-flex-wrap:wrap-reverse;-webkit-flex-wrap:wrap-reverse;flex-wrap:wrap-reverse}html /deep/ [flex]{-ms-flex:1 1 0;-webkit-flex:1;flex:1;-webkit-flex-basis:0;flex-basis:0}html /deep/ [vertical][layout]>[flex][auto-vertical],html /deep/ [vertical][layout]::shadow [flex][auto-vertical]{-ms-flex:1 1 auto;-webkit-flex-basis:auto;flex-basis:auto}html /deep/ [flex][auto]{-ms-flex:1 1 auto;-webkit-flex-basis:auto;flex-basis:auto}html /deep/ [flex][none]{-ms-flex:none;-webkit-flex:none;flex:none}html /deep/ [flex][one]{-ms-flex:1;-webkit-flex:1;flex:1}html /deep/ [flex][two]{-ms-flex:2;-webkit-flex:2;flex:2}html /deep/ [flex][three]{-ms-flex:3;-webkit-flex:3;flex:3}html /deep/ [flex][four]{-ms-flex:4;-webkit-flex:4;flex:4}html /deep/ [flex][five]{-ms-flex:5;-webkit-flex:5;flex:5}html /deep/ [flex][six]{-ms-flex:6;-webkit-flex:6;flex:6}html /deep/ [flex][seven]{-ms-flex:7;-webkit-flex:7;flex:7}html /deep/ [flex][eight]{-ms-flex:8;-webkit-flex:8;flex:8}html /deep/ [flex][nine]{-ms-flex:9;-webkit-flex:9;flex:9}html /deep/ [flex][ten]{-ms-flex:10;-webkit-flex:10;flex:10}html /deep/ [flex][eleven]{-ms-flex:11;-webkit-flex:11;flex:11}html /deep/ [flex][twelve]{-ms-flex:12;-webkit-flex:12;flex:12}html /deep/ [layout][start]{-ms-flex-align:start;-webkit-align-items:flex-start;align-items:flex-start}html /deep/ [layout][center],html /deep/ [layout][center-center]{-ms-flex-align:center;-webkit-align-items:center;align-items:center}html /deep/ [layout][end]{-ms-flex-align:end;-webkit-align-items:flex-end;align-items:flex-end}html /deep/ [layout][start-justified]{-ms-flex-pack:start;-webkit-justify-content:flex-start;justify-content:flex-start}html /deep/ [layout][center-justified],html /deep/ [layout][center-center]{-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center}html /deep/ [layout][end-justified]{-ms-flex-pack:end;-webkit-justify-content:flex-end;justify-content:flex-end}html /deep/ [layout][around-justified]{-ms-flex-pack:distribute;-webkit-justify-content:space-around;justify-content:space-around}html /deep/ [layout][justified]{-ms-flex-pack:justify;-webkit-justify-content:space-between;justify-content:space-between}html /deep/ [self-start]{-ms-align-self:flex-start;-webkit-align-self:flex-start;align-self:flex-start}html /deep/ [self-center]{-ms-align-self:center;-webkit-align-self:center;align-self:center}html /deep/ [self-end]{-ms-align-self:flex-end;-webkit-align-self:flex-end;align-self:flex-end}html /deep/ [self-stretch]{-ms-align-self:stretch;-webkit-align-self:stretch;align-self:stretch}html /deep/ [block]{display:block}html /deep/ [hidden]{display:none!important}html /deep/ [relative]{position:relative}html /deep/ [fit]{position:absolute;top:0;right:0;bottom:0;left:0}body[fullbleed]{margin:0;height:100vh}html /deep/ [segment],html /deep/ segment{display:block;position:relative;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;margin:1em .5em;padding:1em;background-color:#fff;-webkit-box-shadow:0 0 0 1px rgba(0,0,0,.1);box-shadow:0 0 0 1px rgba(0,0,0,.1);border-radius:5px 5px 5px 5px}</style><script>window.PolymerGestures={};(function(scope){var hasFullPath=false;var pathTest=document.createElement("meta");if(pathTest.createShadowRoot){var sr=pathTest.createShadowRoot();var s=document.createElement("span");sr.appendChild(s);pathTest.addEventListener("testpath",function(ev){if(ev.path){hasFullPath=ev.path[0]===s}ev.stopPropagation()});var ev=new CustomEvent("testpath",{bubbles:true});document.head.appendChild(pathTest);s.dispatchEvent(ev);pathTest.parentNode.removeChild(pathTest);sr=s=null}pathTest=null;var target={shadow:function(inEl){if(inEl){return inEl.shadowRoot||inEl.webkitShadowRoot}},canTarget:function(shadow){return shadow&&Boolean(shadow.elementFromPoint)},targetingShadow:function(inEl){var s=this.shadow(inEl);if(this.canTarget(s)){return s}},olderShadow:function(shadow){var os=shadow.olderShadowRoot;if(!os){var se=shadow.querySelector("shadow");if(se){os=se.olderShadowRoot}}return os},allShadows:function(element){var shadows=[],s=this.shadow(element);while(s){shadows.push(s);s=this.olderShadow(s)}return shadows},searchRoot:function(inRoot,x,y){var t,st,sr,os;if(inRoot){t=inRoot.elementFromPoint(x,y);if(t){sr=this.targetingShadow(t)}else if(inRoot!==document){sr=this.olderShadow(inRoot)}return this.searchRoot(sr,x,y)||t}},owner:function(element){if(!element){return document}var s=element;while(s.parentNode){s=s.parentNode}if(s.nodeType!=Node.DOCUMENT_NODE&&s.nodeType!=Node.DOCUMENT_FRAGMENT_NODE){s=document}return s},findTarget:function(inEvent){if(hasFullPath&&inEvent.path&&inEvent.path.length){return inEvent.path[0]}var x=inEvent.clientX,y=inEvent.clientY;var s=this.owner(inEvent.target);if(!s.elementFromPoint(x,y)){s=document}return this.searchRoot(s,x,y)},findTouchAction:function(inEvent){var n;if(hasFullPath&&inEvent.path&&inEvent.path.length){var path=inEvent.path;for(var i=0;i<path.length;i++){n=path[i];if(n.nodeType===Node.ELEMENT_NODE&&n.hasAttribute("touch-action")){return n.getAttribute("touch-action")}}}else{n=inEvent.target;while(n){if(n.nodeType===Node.ELEMENT_NODE&&n.hasAttribute("touch-action")){return n.getAttribute("touch-action")}n=n.parentNode||n.host}}return"auto"},LCA:function(a,b){if(a===b){return a}if(a&&!b){return a}if(b&&!a){return b}if(!b&&!a){return document}if(a.contains&&a.contains(b)){return a}if(b.contains&&b.contains(a)){return b}var adepth=this.depth(a);var bdepth=this.depth(b);var d=adepth-bdepth;if(d>=0){a=this.walk(a,d)}else{b=this.walk(b,-d)}while(a&&b&&a!==b){a=a.parentNode||a.host;b=b.parentNode||b.host}return a},walk:function(n,u){for(var i=0;n&&i<u;i++){n=n.parentNode||n.host}return n},depth:function(n){var d=0;while(n){d++;n=n.parentNode||n.host}return d},deepContains:function(a,b){var common=this.LCA(a,b);return common===a},insideNode:function(node,x,y){var rect=node.getBoundingClientRect();return rect.left<=x&&x<=rect.right&&rect.top<=y&&y<=rect.bottom},path:function(event){var p;if(hasFullPath&&event.path&&event.path.length){p=event.path}else{p=[];var n=this.findTarget(event);while(n){p.push(n);n=n.parentNode||n.host}}return p}};scope.targetFinding=target;scope.findTarget=target.findTarget.bind(target);scope.deepContains=target.deepContains.bind(target);scope.insideNode=target.insideNode})(window.PolymerGestures);(function(){function shadowSelector(v){return"html /deep/ "+selector(v)}function selector(v){return'[touch-action="'+v+'"]'}function rule(v){return"{ -ms-touch-action: "+v+"; touch-action: "+v+";}"}var attrib2css=["none","auto","pan-x","pan-y",{rule:"pan-x pan-y",selectors:["pan-x pan-y","pan-y pan-x"]},"manipulation"];var styles="";var hasTouchAction=typeof document.head.style.touchAction==="string";var hasShadowRoot=!window.ShadowDOMPolyfill&&document.head.createShadowRoot;if(hasTouchAction){attrib2css.forEach(function(r){if(String(r)===r){styles+=selector(r)+rule(r)+"\n";if(hasShadowRoot){styles+=shadowSelector(r)+rule(r)+"\n"}}else{styles+=r.selectors.map(selector)+rule(r.rule)+"\n";if(hasShadowRoot){styles+=r.selectors.map(shadowSelector)+rule(r.rule)+"\n"}}});var el=document.createElement("style");el.textContent=styles;document.head.appendChild(el)}})();(function(scope){var MOUSE_PROPS=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","pageX","pageY"];var MOUSE_DEFAULTS=[false,false,null,null,0,0,0,0,false,false,false,false,0,null,0,0];var NOP_FACTORY=function(){return function(){}};var eventFactory={preventTap:NOP_FACTORY,makeBaseEvent:function(inType,inDict){var e=document.createEvent("Event");e.initEvent(inType,inDict.bubbles||false,inDict.cancelable||false);e.preventTap=eventFactory.preventTap(e);return e},makeGestureEvent:function(inType,inDict){inDict=inDict||Object.create(null);var e=this.makeBaseEvent(inType,inDict);for(var i=0,keys=Object.keys(inDict),k;i<keys.length;i++){k=keys[i];if(k!=="bubbles"&&k!=="cancelable"){e[k]=inDict[k]}}return e},makePointerEvent:function(inType,inDict){inDict=inDict||Object.create(null);var e=this.makeBaseEvent(inType,inDict);for(var i=2,p;i<MOUSE_PROPS.length;i++){p=MOUSE_PROPS[i];e[p]=inDict[p]||MOUSE_DEFAULTS[i]}e.buttons=inDict.buttons||0;var pressure=0;if(inDict.pressure){pressure=inDict.pressure}else{pressure=e.buttons?.5:0}e.x=e.clientX;e.y=e.clientY;e.pointerId=inDict.pointerId||0;e.width=inDict.width||0;e.height=inDict.height||0;e.pressure=pressure;e.tiltX=inDict.tiltX||0;e.tiltY=inDict.tiltY||0;e.pointerType=inDict.pointerType||"";e.hwTimestamp=inDict.hwTimestamp||0;e.isPrimary=inDict.isPrimary||false;e._source=inDict._source||"";return e}};scope.eventFactory=eventFactory})(window.PolymerGestures);(function(scope){var USE_MAP=window.Map&&window.Map.prototype.forEach;var POINTERS_FN=function(){return this.size};function PointerMap(){if(USE_MAP){var m=new Map;m.pointers=POINTERS_FN;return m}else{this.keys=[];this.values=[]}}PointerMap.prototype={set:function(inId,inEvent){var i=this.keys.indexOf(inId);if(i>-1){this.values[i]=inEvent}else{this.keys.push(inId);this.values.push(inEvent)}},has:function(inId){return this.keys.indexOf(inId)>-1},"delete":function(inId){var i=this.keys.indexOf(inId);if(i>-1){this.keys.splice(i,1);this.values.splice(i,1)}},get:function(inId){var i=this.keys.indexOf(inId);return this.values[i]},clear:function(){this.keys.length=0;this.values.length=0},forEach:function(callback,thisArg){this.values.forEach(function(v,i){callback.call(thisArg,v,this.keys[i],this)},this)},pointers:function(){return this.keys.length}};scope.PointerMap=PointerMap})(window.PolymerGestures);(function(scope){var CLONE_PROPS=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","which","pageX","pageY","timeStamp","preventTap","tapPrevented","_source"];var CLONE_DEFAULTS=[false,false,null,null,0,0,0,0,false,false,false,false,0,null,0,0,0,0,0,0,0,"",0,false,"",null,null,0,0,0,0,function(){},false];var HAS_SVG_INSTANCE=typeof SVGElementInstance!=="undefined";var eventFactory=scope.eventFactory;var currentGestures;var dispatcher={IS_IOS:false,pointermap:new scope.PointerMap,requiredGestures:new scope.PointerMap,eventMap:Object.create(null),eventSources:Object.create(null),eventSourceList:[],gestures:[],dependencyMap:{down:{listeners:0,index:-1},up:{listeners:0,index:-1}},gestureQueue:[],registerSource:function(name,source){var s=source;var newEvents=s.events;if(newEvents){newEvents.forEach(function(e){if(s[e]){this.eventMap[e]=s[e].bind(s)}},this);this.eventSources[name]=s;this.eventSourceList.push(s)}},registerGesture:function(name,source){var obj=Object.create(null);obj.listeners=0;obj.index=this.gestures.length;for(var i=0,g;i<source.exposes.length;i++){g=source.exposes[i].toLowerCase();this.dependencyMap[g]=obj}this.gestures.push(source)},register:function(element,initial){var l=this.eventSourceList.length;for(var i=0,es;i<l&&(es=this.eventSourceList[i]);i++){es.register.call(es,element,initial)}},unregister:function(element){var l=this.eventSourceList.length;for(var i=0,es;i<l&&(es=this.eventSourceList[i]);i++){es.unregister.call(es,element)}},down:function(inEvent){this.requiredGestures.set(inEvent.pointerId,currentGestures);this.fireEvent("down",inEvent)},move:function(inEvent){inEvent.type="move";this.fillGestureQueue(inEvent)},up:function(inEvent){this.fireEvent("up",inEvent);this.requiredGestures.delete(inEvent.pointerId)},cancel:function(inEvent){inEvent.tapPrevented=true;this.fireEvent("up",inEvent);this.requiredGestures.delete(inEvent.pointerId)},addGestureDependency:function(node,currentGestures){var gesturesWanted=node._pgEvents;if(gesturesWanted&¤tGestures){var gk=Object.keys(gesturesWanted);for(var i=0,r,ri,g;i<gk.length;i++){g=gk[i];if(gesturesWanted[g]>0){r=this.dependencyMap[g];ri=r?r.index:-1;currentGestures[ri]=true}}}},eventHandler:function(inEvent){var type=inEvent.type;if(type==="touchstart"||type==="mousedown"||type==="pointerdown"||type==="MSPointerDown"){if(!inEvent._handledByPG){currentGestures={}}if(this.IS_IOS){var ev=inEvent;if(type==="touchstart"){var ct=inEvent.changedTouches[0];ev={target:inEvent.target,clientX:ct.clientX,clientY:ct.clientY,path:inEvent.path}}var nodes=inEvent.path||scope.targetFinding.path(ev);for(var i=0,n;i<nodes.length;i++){n=nodes[i];this.addGestureDependency(n,currentGestures)}}else{this.addGestureDependency(inEvent.currentTarget,currentGestures)}}if(inEvent._handledByPG){return}var fn=this.eventMap&&this.eventMap[type];if(fn){fn(inEvent)}inEvent._handledByPG=true},listen:function(target,events){for(var i=0,l=events.length,e;i<l&&(e=events[i]);i++){this.addEvent(target,e)}},unlisten:function(target,events){for(var i=0,l=events.length,e;i<l&&(e=events[i]);i++){this.removeEvent(target,e)}},addEvent:function(target,eventName){target.addEventListener(eventName,this.boundHandler)},removeEvent:function(target,eventName){target.removeEventListener(eventName,this.boundHandler)},makeEvent:function(inType,inEvent){var e=eventFactory.makePointerEvent(inType,inEvent);e.preventDefault=inEvent.preventDefault;e.tapPrevented=inEvent.tapPrevented;e._target=e._target||inEvent.target;return e},fireEvent:function(inType,inEvent){var e=this.makeEvent(inType,inEvent);return this.dispatchEvent(e)},cloneEvent:function(inEvent){var eventCopy=Object.create(null),p;for(var i=0;i<CLONE_PROPS.length;i++){p=CLONE_PROPS[i];eventCopy[p]=inEvent[p]||CLONE_DEFAULTS[i];if(p==="target"||p==="relatedTarget"){if(HAS_SVG_INSTANCE&&eventCopy[p]instanceof SVGElementInstance){eventCopy[p]=eventCopy[p].correspondingUseElement}}}eventCopy.preventDefault=function(){inEvent.preventDefault()};return eventCopy},dispatchEvent:function(inEvent){var t=inEvent._target;if(t){t.dispatchEvent(inEvent);var clone=this.cloneEvent(inEvent);clone.target=t;this.fillGestureQueue(clone)}},gestureTrigger:function(){for(var i=0,e,rg;i<this.gestureQueue.length;i++){e=this.gestureQueue[i];rg=e._requiredGestures;if(rg){for(var j=0,g,fn;j<this.gestures.length;j++){if(rg[j]){g=this.gestures[j];fn=g[e.type];if(fn){fn.call(g,e)}}}}}this.gestureQueue.length=0},fillGestureQueue:function(ev){if(!this.gestureQueue.length){requestAnimationFrame(this.boundGestureTrigger)}ev._requiredGestures=this.requiredGestures.get(ev.pointerId);this.gestureQueue.push(ev)}};dispatcher.boundHandler=dispatcher.eventHandler.bind(dispatcher);dispatcher.boundGestureTrigger=dispatcher.gestureTrigger.bind(dispatcher);scope.dispatcher=dispatcher;scope.activateGesture=function(node,gesture){var g=gesture.toLowerCase();var dep=dispatcher.dependencyMap[g];if(dep){var recognizer=dispatcher.gestures[dep.index];if(!node._pgListeners){dispatcher.register(node);node._pgListeners=0}if(recognizer){var touchAction=recognizer.defaultActions&&recognizer.defaultActions[g];var actionNode;switch(node.nodeType){case Node.ELEMENT_NODE:actionNode=node;break;case Node.DOCUMENT_FRAGMENT_NODE:actionNode=node.host;break;default:actionNode=null;break}if(touchAction&&actionNode&&!actionNode.hasAttribute("touch-action")){actionNode.setAttribute("touch-action",touchAction)}}if(!node._pgEvents){node._pgEvents={}}node._pgEvents[g]=(node._pgEvents[g]||0)+1;node._pgListeners++}return Boolean(dep)};scope.addEventListener=function(node,gesture,handler,capture){if(handler){scope.activateGesture(node,gesture);node.addEventListener(gesture,handler,capture)}};scope.deactivateGesture=function(node,gesture){var g=gesture.toLowerCase();var dep=dispatcher.dependencyMap[g];if(dep){if(node._pgListeners>0){node._pgListeners--}if(node._pgListeners===0){dispatcher.unregister(node)}if(node._pgEvents){if(node._pgEvents[g]>0){node._pgEvents[g]--}else{node._pgEvents[g]=0}}}return Boolean(dep)};scope.removeEventListener=function(node,gesture,handler,capture){if(handler){scope.deactivateGesture(node,gesture);node.removeEventListener(gesture,handler,capture)}}})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var pointermap=dispatcher.pointermap;var DEDUP_DIST=25;var WHICH_TO_BUTTONS=[0,1,4,2];var currentButtons=0;var FIREFOX_LINUX=/Linux.*Firefox\//i;var HAS_BUTTONS=function(){if(FIREFOX_LINUX.test(navigator.userAgent)){return false}try{return new MouseEvent("test",{buttons:1}).buttons===1}catch(e){return false}}();var mouseEvents={POINTER_ID:1,POINTER_TYPE:"mouse",events:["mousedown","mousemove","mouseup"],exposes:["down","up","move"],register:function(target){dispatcher.listen(target,this.events)},unregister:function(target){if(target.nodeType===Node.DOCUMENT_NODE){return}dispatcher.unlisten(target,this.events)},lastTouches:[],isEventSimulatedFromTouch:function(inEvent){var lts=this.lastTouches;var x=inEvent.clientX,y=inEvent.clientY;for(var i=0,l=lts.length,t;i<l&&(t=lts[i]);i++){var dx=Math.abs(x-t.x),dy=Math.abs(y-t.y);if(dx<=DEDUP_DIST&&dy<=DEDUP_DIST){return true}}},prepareEvent:function(inEvent){var e=dispatcher.cloneEvent(inEvent);e.pointerId=this.POINTER_ID;e.isPrimary=true;e.pointerType=this.POINTER_TYPE;e._source="mouse";if(!HAS_BUTTONS){var type=inEvent.type;var bit=WHICH_TO_BUTTONS[inEvent.which]||0;if(type==="mousedown"){currentButtons|=bit}else if(type==="mouseup"){currentButtons&=~bit}e.buttons=currentButtons}return e},mousedown:function(inEvent){if(!this.isEventSimulatedFromTouch(inEvent)){var p=pointermap.has(this.POINTER_ID);var e=this.prepareEvent(inEvent);e.target=scope.findTarget(inEvent);pointermap.set(this.POINTER_ID,e.target);dispatcher.down(e)}},mousemove:function(inEvent){if(!this.isEventSimulatedFromTouch(inEvent)){var target=pointermap.get(this.POINTER_ID);if(target){var e=this.prepareEvent(inEvent);e.target=target;if((HAS_BUTTONS?e.buttons:e.which)===0){if(!HAS_BUTTONS){currentButtons=e.buttons=0}dispatcher.cancel(e);this.cleanupMouse(e.buttons)}else{dispatcher.move(e)}}}},mouseup:function(inEvent){if(!this.isEventSimulatedFromTouch(inEvent)){var e=this.prepareEvent(inEvent);e.relatedTarget=scope.findTarget(inEvent);e.target=pointermap.get(this.POINTER_ID);dispatcher.up(e);this.cleanupMouse(e.buttons)}},cleanupMouse:function(buttons){if(buttons===0){pointermap.delete(this.POINTER_ID)}}};scope.mouseEvents=mouseEvents})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var allShadows=scope.targetFinding.allShadows.bind(scope.targetFinding);var pointermap=dispatcher.pointermap;var touchMap=Array.prototype.map.call.bind(Array.prototype.map);var DEDUP_TIMEOUT=2500;var DEDUP_DIST=25;var CLICK_COUNT_TIMEOUT=200;var HYSTERESIS=20;var ATTRIB="touch-action";var HAS_TOUCH_ACTION=false;var touchEvents={IS_IOS:false,events:["touchstart","touchmove","touchend","touchcancel"],exposes:["down","up","move"],register:function(target,initial){if(this.IS_IOS?initial:!initial){dispatcher.listen(target,this.events)}},unregister:function(target){if(!this.IS_IOS){dispatcher.unlisten(target,this.events)}},scrollTypes:{EMITTER:"none",XSCROLLER:"pan-x",YSCROLLER:"pan-y"},touchActionToScrollType:function(touchAction){var t=touchAction;var st=this.scrollTypes;if(t===st.EMITTER){return"none"}else if(t===st.XSCROLLER){return"X"}else if(t===st.YSCROLLER){return"Y"}else{return"XY"}},POINTER_TYPE:"touch",firstTouch:null,isPrimaryTouch:function(inTouch){return this.firstTouch===inTouch.identifier},setPrimaryTouch:function(inTouch){if(pointermap.pointers()===0||pointermap.pointers()===1&&pointermap.has(1)){this.firstTouch=inTouch.identifier;this.firstXY={X:inTouch.clientX,Y:inTouch.clientY};this.firstTarget=inTouch.target;this.scrolling=null;this.cancelResetClickCount()}},removePrimaryPointer:function(inPointer){if(inPointer.isPrimary){this.firstTouch=null;this.firstXY=null;this.resetClickCount()}},clickCount:0,resetId:null,resetClickCount:function(){var fn=function(){this.clickCount=0;this.resetId=null}.bind(this);this.resetId=setTimeout(fn,CLICK_COUNT_TIMEOUT)},cancelResetClickCount:function(){if(this.resetId){clearTimeout(this.resetId)}},typeToButtons:function(type){var ret=0;if(type==="touchstart"||type==="touchmove"){ret=1}return ret},findTarget:function(touch,id){if(this.currentTouchEvent.type==="touchstart"){if(this.isPrimaryTouch(touch)){var fastPath={clientX:touch.clientX,clientY:touch.clientY,path:this.currentTouchEvent.path,target:this.currentTouchEvent.target};return scope.findTarget(fastPath)}else{return scope.findTarget(touch)}}return pointermap.get(id)},touchToPointer:function(inTouch){var cte=this.currentTouchEvent;var e=dispatcher.cloneEvent(inTouch);var id=e.pointerId=inTouch.identifier+2;e.target=this.findTarget(inTouch,id);e.bubbles=true;e.cancelable=true;e.detail=this.clickCount;e.buttons=this.typeToButtons(cte.type);e.width=inTouch.webkitRadiusX||inTouch.radiusX||0;e.height=inTouch.webkitRadiusY||inTouch.radiusY||0;e.pressure=inTouch.webkitForce||inTouch.force||.5;e.isPrimary=this.isPrimaryTouch(inTouch);e.pointerType=this.POINTER_TYPE;e._source="touch";var self=this;e.preventDefault=function(){self.scrolling=false;self.firstXY=null;cte.preventDefault()};return e},processTouches:function(inEvent,inFunction){var tl=inEvent.changedTouches;this.currentTouchEvent=inEvent;for(var i=0,t,p;i<tl.length;i++){t=tl[i];p=this.touchToPointer(t);if(inEvent.type==="touchstart"){pointermap.set(p.pointerId,p.target)}if(pointermap.has(p.pointerId)){inFunction.call(this,p)}if(inEvent.type==="touchend"||inEvent._cancel){this.cleanUpPointer(p)}}},shouldScroll:function(inEvent){if(this.firstXY){var ret;var touchAction=scope.targetFinding.findTouchAction(inEvent);var scrollAxis=this.touchActionToScrollType(touchAction);if(scrollAxis==="none"){ret=false}else if(scrollAxis==="XY"){ret=true}else{var t=inEvent.changedTouches[0];var a=scrollAxis;var oa=scrollAxis==="Y"?"X":"Y";var da=Math.abs(t["client"+a]-this.firstXY[a]);var doa=Math.abs(t["client"+oa]-this.firstXY[oa]);ret=da>=doa}return ret}},findTouch:function(inTL,inId){for(var i=0,l=inTL.length,t;i<l&&(t=inTL[i]);i++){if(t.identifier===inId){return true}}},vacuumTouches:function(inEvent){var tl=inEvent.touches;if(pointermap.pointers()>=tl.length){var d=[];pointermap.forEach(function(value,key){if(key!==1&&!this.findTouch(tl,key-2)){var p=value;d.push(p)}},this);d.forEach(function(p){this.cancel(p);pointermap.delete(p.pointerId)},this)}},touchstart:function(inEvent){this.vacuumTouches(inEvent);this.setPrimaryTouch(inEvent.changedTouches[0]);this.dedupSynthMouse(inEvent);if(!this.scrolling){this.clickCount++;this.processTouches(inEvent,this.down)}},down:function(inPointer){dispatcher.down(inPointer)},touchmove:function(inEvent){if(HAS_TOUCH_ACTION){if(inEvent.cancelable){this.processTouches(inEvent,this.move)}}else{if(!this.scrolling){if(this.scrolling===null&&this.shouldScroll(inEvent)){this.scrolling=true}else{this.scrolling=false;inEvent.preventDefault();this.processTouches(inEvent,this.move)}}else if(this.firstXY){var t=inEvent.changedTouches[0];var dx=t.clientX-this.firstXY.X;var dy=t.clientY-this.firstXY.Y;var dd=Math.sqrt(dx*dx+dy*dy);if(dd>=HYSTERESIS){this.touchcancel(inEvent);this.scrolling=true;this.firstXY=null}}}},move:function(inPointer){dispatcher.move(inPointer)},touchend:function(inEvent){this.dedupSynthMouse(inEvent);this.processTouches(inEvent,this.up)},up:function(inPointer){inPointer.relatedTarget=scope.findTarget(inPointer);dispatcher.up(inPointer)},cancel:function(inPointer){dispatcher.cancel(inPointer)},touchcancel:function(inEvent){inEvent._cancel=true;this.processTouches(inEvent,this.cancel)},cleanUpPointer:function(inPointer){pointermap["delete"](inPointer.pointerId);this.removePrimaryPointer(inPointer)},dedupSynthMouse:function(inEvent){var lts=scope.mouseEvents.lastTouches;var t=inEvent.changedTouches[0];if(this.isPrimaryTouch(t)){var lt={x:t.clientX,y:t.clientY};lts.push(lt);var fn=function(lts,lt){var i=lts.indexOf(lt);if(i>-1){lts.splice(i,1)}}.bind(null,lts,lt);setTimeout(fn,DEDUP_TIMEOUT)}}};var STOP_PROP_FN=Event.prototype.stopImmediatePropagation||Event.prototype.stopPropagation;document.addEventListener("click",function(ev){var x=ev.clientX,y=ev.clientY;var closeTo=function(touch){var dx=Math.abs(x-touch.x),dy=Math.abs(y-touch.y);return dx<=DEDUP_DIST&&dy<=DEDUP_DIST};var wasTouched=scope.mouseEvents.lastTouches.some(closeTo);var path=scope.targetFinding.path(ev);if(wasTouched){for(var i=0;i<path.length;i++){if(path[i]===touchEvents.firstTarget){return}}ev.preventDefault();STOP_PROP_FN.call(ev)}},true);scope.touchEvents=touchEvents})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var pointermap=dispatcher.pointermap;var HAS_BITMAP_TYPE=window.MSPointerEvent&&typeof window.MSPointerEvent.MSPOINTER_TYPE_MOUSE==="number";var msEvents={events:["MSPointerDown","MSPointerMove","MSPointerUp","MSPointerCancel"],register:function(target){dispatcher.listen(target,this.events)},unregister:function(target){if(target.nodeType===Node.DOCUMENT_NODE){return}dispatcher.unlisten(target,this.events)},POINTER_TYPES:["","unavailable","touch","pen","mouse"],prepareEvent:function(inEvent){var e=inEvent;e=dispatcher.cloneEvent(inEvent);if(HAS_BITMAP_TYPE){e.pointerType=this.POINTER_TYPES[inEvent.pointerType]}e._source="ms";return e},cleanup:function(id){pointermap["delete"](id)},MSPointerDown:function(inEvent){var e=this.prepareEvent(inEvent);e.target=scope.findTarget(inEvent);pointermap.set(inEvent.pointerId,e.target);dispatcher.down(e)},MSPointerMove:function(inEvent){var target=pointermap.get(inEvent.pointerId);if(target){var e=this.prepareEvent(inEvent);e.target=target;dispatcher.move(e)}},MSPointerUp:function(inEvent){var e=this.prepareEvent(inEvent);e.relatedTarget=scope.findTarget(inEvent);e.target=pointermap.get(e.pointerId);dispatcher.up(e);this.cleanup(inEvent.pointerId)},MSPointerCancel:function(inEvent){var e=this.prepareEvent(inEvent);e.relatedTarget=scope.findTarget(inEvent);e.target=pointermap.get(e.pointerId);dispatcher.cancel(e);this.cleanup(inEvent.pointerId)}};scope.msEvents=msEvents})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var pointermap=dispatcher.pointermap;var pointerEvents={events:["pointerdown","pointermove","pointerup","pointercancel"],prepareEvent:function(inEvent){var e=dispatcher.cloneEvent(inEvent);e._source="pointer";return e},register:function(target){dispatcher.listen(target,this.events)},unregister:function(target){if(target.nodeType===Node.DOCUMENT_NODE){return}dispatcher.unlisten(target,this.events)},cleanup:function(id){pointermap["delete"](id)},pointerdown:function(inEvent){var e=this.prepareEvent(inEvent);e.target=scope.findTarget(inEvent);pointermap.set(e.pointerId,e.target);dispatcher.down(e)},pointermove:function(inEvent){var target=pointermap.get(inEvent.pointerId);if(target){var e=this.prepareEvent(inEvent);e.target=target;dispatcher.move(e)}},pointerup:function(inEvent){var e=this.prepareEvent(inEvent);e.relatedTarget=scope.findTarget(inEvent);e.target=pointermap.get(e.pointerId);dispatcher.up(e);this.cleanup(inEvent.pointerId)},pointercancel:function(inEvent){var e=this.prepareEvent(inEvent);e.relatedTarget=scope.findTarget(inEvent);e.target=pointermap.get(e.pointerId);dispatcher.cancel(e);this.cleanup(inEvent.pointerId)}};scope.pointerEvents=pointerEvents})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var nav=window.navigator;if(window.PointerEvent){dispatcher.registerSource("pointer",scope.pointerEvents)}else if(nav.msPointerEnabled){dispatcher.registerSource("ms",scope.msEvents)}else{dispatcher.registerSource("mouse",scope.mouseEvents);if(window.ontouchstart!==undefined){dispatcher.registerSource("touch",scope.touchEvents)}}var ua=navigator.userAgent;var IS_IOS=ua.match(/iPad|iPhone|iPod/)&&"ontouchstart"in window;dispatcher.IS_IOS=IS_IOS;scope.touchEvents.IS_IOS=IS_IOS;dispatcher.register(document,true)})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var eventFactory=scope.eventFactory;var pointermap=new scope.PointerMap;var track={events:["down","move","up"],exposes:["trackstart","track","trackx","tracky","trackend"],defaultActions:{track:"none",trackx:"pan-y",tracky:"pan-x"},WIGGLE_THRESHOLD:4,clampDir:function(inDelta){return inDelta>0?1:-1},calcPositionDelta:function(inA,inB){var x=0,y=0;if(inA&&inB){x=inB.pageX-inA.pageX;y=inB.pageY-inA.pageY}return{x:x,y:y}},fireTrack:function(inType,inEvent,inTrackingData){var t=inTrackingData;var d=this.calcPositionDelta(t.downEvent,inEvent);var dd=this.calcPositionDelta(t.lastMoveEvent,inEvent);if(dd.x){t.xDirection=this.clampDir(dd.x)}else if(inType==="trackx"){return}if(dd.y){t.yDirection=this.clampDir(dd.y)}else if(inType==="tracky"){return}var gestureProto={bubbles:true,cancelable:true,trackInfo:t.trackInfo,relatedTarget:inEvent.relatedTarget,pointerType:inEvent.pointerType,pointerId:inEvent.pointerId,_source:"track"};if(inType!=="tracky"){gestureProto.x=inEvent.x;gestureProto.dx=d.x;gestureProto.ddx=dd.x;gestureProto.clientX=inEvent.clientX;gestureProto.pageX=inEvent.pageX;gestureProto.screenX=inEvent.screenX;gestureProto.xDirection=t.xDirection}if(inType!=="trackx"){gestureProto.dy=d.y;gestureProto.ddy=dd.y;gestureProto.y=inEvent.y;gestureProto.clientY=inEvent.clientY;gestureProto.pageY=inEvent.pageY;gestureProto.screenY=inEvent.screenY;gestureProto.yDirection=t.yDirection}var e=eventFactory.makeGestureEvent(inType,gestureProto);t.downTarget.dispatchEvent(e)},down:function(inEvent){if(inEvent.isPrimary&&(inEvent.pointerType==="mouse"?inEvent.buttons===1:true)){var p={downEvent:inEvent,downTarget:inEvent.target,trackInfo:{},lastMoveEvent:null,xDirection:0,yDirection:0,tracking:false};pointermap.set(inEvent.pointerId,p)}},move:function(inEvent){var p=pointermap.get(inEvent.pointerId);if(p){if(!p.tracking){var d=this.calcPositionDelta(p.downEvent,inEvent);var move=d.x*d.x+d.y*d.y;if(move>this.WIGGLE_THRESHOLD){p.tracking=true;p.lastMoveEvent=p.downEvent;this.fireTrack("trackstart",inEvent,p)}}if(p.tracking){this.fireTrack("track",inEvent,p);this.fireTrack("trackx",inEvent,p);this.fireTrack("tracky",inEvent,p)}p.lastMoveEvent=inEvent}},up:function(inEvent){var p=pointermap.get(inEvent.pointerId);if(p){if(p.tracking){this.fireTrack("trackend",inEvent,p)}pointermap.delete(inEvent.pointerId)}}};dispatcher.registerGesture("track",track)})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var eventFactory=scope.eventFactory;var hold={HOLD_DELAY:200,WIGGLE_THRESHOLD:16,events:["down","move","up"],exposes:["hold","holdpulse","release"],heldPointer:null,holdJob:null,pulse:function(){var hold=Date.now()-this.heldPointer.timeStamp;var type=this.held?"holdpulse":"hold";this.fireHold(type,hold);this.held=true},cancel:function(){clearInterval(this.holdJob);if(this.held){this.fireHold("release")}this.held=false;this.heldPointer=null;this.target=null;this.holdJob=null},down:function(inEvent){if(inEvent.isPrimary&&!this.heldPointer){this.heldPointer=inEvent;this.target=inEvent.target;this.holdJob=setInterval(this.pulse.bind(this),this.HOLD_DELAY)}},up:function(inEvent){if(this.heldPointer&&this.heldPointer.pointerId===inEvent.pointerId){this.cancel()}},move:function(inEvent){if(this.heldPointer&&this.heldPointer.pointerId===inEvent.pointerId){var x=inEvent.clientX-this.heldPointer.clientX;var y=inEvent.clientY-this.heldPointer.clientY;if(x*x+y*y>this.WIGGLE_THRESHOLD){this.cancel()}}},fireHold:function(inType,inHoldTime){var p={bubbles:true,cancelable:true,pointerType:this.heldPointer.pointerType,pointerId:this.heldPointer.pointerId,x:this.heldPointer.clientX,y:this.heldPointer.clientY,_source:"hold"};if(inHoldTime){p.holdTime=inHoldTime}var e=eventFactory.makeGestureEvent(inType,p);this.target.dispatchEvent(e)}};dispatcher.registerGesture("hold",hold)})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var eventFactory=scope.eventFactory;var pointermap=new scope.PointerMap;var tap={events:["down","up"],exposes:["tap"],down:function(inEvent){if(inEvent.isPrimary&&!inEvent.tapPrevented){pointermap.set(inEvent.pointerId,{target:inEvent.target,buttons:inEvent.buttons,x:inEvent.clientX,y:inEvent.clientY})}},shouldTap:function(e,downState){var tap=true;if(e.pointerType==="mouse"){tap=e.buttons^1&&downState.buttons&1}return tap&&!e.tapPrevented},up:function(inEvent){var start=pointermap.get(inEvent.pointerId);if(start&&this.shouldTap(inEvent,start)){var t=scope.targetFinding.LCA(start.target,inEvent.relatedTarget);if(t){var e=eventFactory.makeGestureEvent("tap",{bubbles:true,cancelable:true,x:inEvent.clientX,y:inEvent.clientY,detail:inEvent.detail,pointerType:inEvent.pointerType,pointerId:inEvent.pointerId,altKey:inEvent.altKey,ctrlKey:inEvent.ctrlKey,metaKey:inEvent.metaKey,shiftKey:inEvent.shiftKey,_source:"tap"});t.dispatchEvent(e)}}pointermap.delete(inEvent.pointerId)}};eventFactory.preventTap=function(e){return function(){e.tapPrevented=true;pointermap.delete(e.pointerId)}};dispatcher.registerGesture("tap",tap)})(window.PolymerGestures);(function(scope){var dispatcher=scope.dispatcher;var eventFactory=scope.eventFactory;var pointermap=new scope.PointerMap;var RAD_TO_DEG=180/Math.PI;var pinch={events:["down","up","move","cancel"],exposes:["pinchstart","pinch","pinchend","rotate"],defaultActions:{pinch:"none",rotate:"none"},reference:{},down:function(inEvent){pointermap.set(inEvent.pointerId,inEvent);if(pointermap.pointers()==2){var points=this.calcChord();var angle=this.calcAngle(points);this.reference={angle:angle,diameter:points.diameter,target:scope.targetFinding.LCA(points.a.target,points.b.target)};this.firePinch("pinchstart",points.diameter,points)}},up:function(inEvent){var p=pointermap.get(inEvent.pointerId);var num=pointermap.pointers();if(p){if(num===2){var points=this.calcChord();this.firePinch("pinchend",points.diameter,points)}pointermap.delete(inEvent.pointerId)}},move:function(inEvent){if(pointermap.has(inEvent.pointerId)){pointermap.set(inEvent.pointerId,inEvent);if(pointermap.pointers()>1){this.calcPinchRotate()}}},cancel:function(inEvent){this.up(inEvent)},firePinch:function(type,diameter,points){var zoom=diameter/this.reference.diameter;var e=eventFactory.makeGestureEvent(type,{bubbles:true,cancelable:true,scale:zoom,centerX:points.center.x,centerY:points.center.y,_source:"pinch"});this.reference.target.dispatchEvent(e)},fireRotate:function(angle,points){var diff=Math.round((angle-this.reference.angle)%360);var e=eventFactory.makeGestureEvent("rotate",{bubbles:true,cancelable:true,angle:diff,centerX:points.center.x,centerY:points.center.y,_source:"pinch"});this.reference.target.dispatchEvent(e)},calcPinchRotate:function(){var points=this.calcChord();var diameter=points.diameter;var angle=this.calcAngle(points);if(diameter!=this.reference.diameter){this.firePinch("pinch",diameter,points)}if(angle!=this.reference.angle){this.fireRotate(angle,points)}},calcChord:function(){var pointers=[];pointermap.forEach(function(p){pointers.push(p)});var dist=0;var points={a:pointers[0],b:pointers[1]};var x,y,d;for(var i=0;i<pointers.length;i++){var a=pointers[i];for(var j=i+1;j<pointers.length;j++){
var b=pointers[j];x=Math.abs(a.clientX-b.clientX);y=Math.abs(a.clientY-b.clientY);d=x+y;if(d>dist){dist=d;points={a:a,b:b}}}}x=Math.abs(points.a.clientX+points.b.clientX)/2;y=Math.abs(points.a.clientY+points.b.clientY)/2;points.center={x:x,y:y};points.diameter=dist;return points},calcAngle:function(points){var x=points.a.clientX-points.b.clientX;var y=points.a.clientY-points.b.clientY;return(360+Math.atan2(y,x)*RAD_TO_DEG)%360}};dispatcher.registerGesture("pinch",pinch)})(window.PolymerGestures);(function(global){"use strict";var Token,TokenName,Syntax,Messages,source,index,length,delegate,lookahead,state;Token={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8};TokenName={};TokenName[Token.BooleanLiteral]="Boolean";TokenName[Token.EOF]="<end>";TokenName[Token.Identifier]="Identifier";TokenName[Token.Keyword]="Keyword";TokenName[Token.NullLiteral]="Null";TokenName[Token.NumericLiteral]="Numeric";TokenName[Token.Punctuator]="Punctuator";TokenName[Token.StringLiteral]="String";Syntax={ArrayExpression:"ArrayExpression",BinaryExpression:"BinaryExpression",CallExpression:"CallExpression",ConditionalExpression:"ConditionalExpression",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",Identifier:"Identifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ThisExpression:"ThisExpression",UnaryExpression:"UnaryExpression"};Messages={UnexpectedToken:"Unexpected token %0",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared"};function assert(condition,message){if(!condition){throw new Error("ASSERT: "+message)}}function isDecimalDigit(ch){return ch>=48&&ch<=57}function isWhiteSpace(ch){return ch===32||ch===9||ch===11||ch===12||ch===160||ch>=5760&&" \ufeff".indexOf(String.fromCharCode(ch))>0}function isLineTerminator(ch){return ch===10||ch===13||ch===8232||ch===8233}function isIdentifierStart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122}function isIdentifierPart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=48&&ch<=57}function isKeyword(id){return id==="this"}function skipWhitespace(){while(index<length&&isWhiteSpace(source.charCodeAt(index))){++index}}function getIdentifier(){var start,ch;start=index++;while(index<length){ch=source.charCodeAt(index);if(isIdentifierPart(ch)){++index}else{break}}return source.slice(start,index)}function scanIdentifier(){var start,id,type;start=index;id=getIdentifier();if(id.length===1){type=Token.Identifier}else if(isKeyword(id)){type=Token.Keyword}else if(id==="null"){type=Token.NullLiteral}else if(id==="true"||id==="false"){type=Token.BooleanLiteral}else{type=Token.Identifier}return{type:type,value:id,range:[start,index]}}function scanPunctuator(){var start=index,code=source.charCodeAt(index),code2,ch1=source[index],ch2;switch(code){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:++index;return{type:Token.Punctuator,value:String.fromCharCode(code),range:[start,index]};default:code2=source.charCodeAt(index+1);if(code2===61){switch(code){case 37:case 38:case 42:case 43:case 45:case 47:case 60:case 62:case 124:index+=2;return{type:Token.Punctuator,value:String.fromCharCode(code)+String.fromCharCode(code2),range:[start,index]};case 33:case 61:index+=2;if(source.charCodeAt(index)===61){++index}return{type:Token.Punctuator,value:source.slice(start,index),range:[start,index]};default:break}}break}ch2=source[index+1];if(ch1===ch2&&"&|".indexOf(ch1)>=0){index+=2;return{type:Token.Punctuator,value:ch1+ch2,range:[start,index]}}if("<>=!+-*%&|^/".indexOf(ch1)>=0){++index;return{type:Token.Punctuator,value:ch1,range:[start,index]}}throwError({},Messages.UnexpectedToken,"ILLEGAL")}function scanNumericLiteral(){var number,start,ch;ch=source[index];assert(isDecimalDigit(ch.charCodeAt(0))||ch===".","Numeric literal must start with a decimal digit or a decimal point");start=index;number="";if(ch!=="."){number=source[index++];ch=source[index];if(number==="0"){if(ch&&isDecimalDigit(ch.charCodeAt(0))){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}while(isDecimalDigit(source.charCodeAt(index))){number+=source[index++]}ch=source[index]}if(ch==="."){number+=source[index++];while(isDecimalDigit(source.charCodeAt(index))){number+=source[index++]}ch=source[index]}if(ch==="e"||ch==="E"){number+=source[index++];ch=source[index];if(ch==="+"||ch==="-"){number+=source[index++]}if(isDecimalDigit(source.charCodeAt(index))){while(isDecimalDigit(source.charCodeAt(index))){number+=source[index++]}}else{throwError({},Messages.UnexpectedToken,"ILLEGAL")}}if(isIdentifierStart(source.charCodeAt(index))){throwError({},Messages.UnexpectedToken,"ILLEGAL")}return{type:Token.NumericLiteral,value:parseFloat(number),range:[start,index]}}function scanStringLiteral(){var str="",quote,start,ch,octal=false;quote=source[index];assert(quote==="'"||quote==='"',"String literal must starts with a quote");start=index;++index;while(index<length){ch=source[index++];if(ch===quote){quote="";break}else if(ch==="\\"){ch=source[index++];if(!ch||!isLineTerminator(ch.charCodeAt(0))){switch(ch){case"n":str+="\n";break;case"r":str+="\r";break;case"t":str+=" ";break;case"b":str+="\b";break;case"f":str+="\f";break;case"v":str+="";break;default:str+=ch;break}}else{if(ch==="\r"&&source[index]==="\n"){++index}}}else if(isLineTerminator(ch.charCodeAt(0))){break}else{str+=ch}}if(quote!==""){throwError({},Messages.UnexpectedToken,"ILLEGAL")}return{type:Token.StringLiteral,value:str,octal:octal,range:[start,index]}}function isIdentifierName(token){return token.type===Token.Identifier||token.type===Token.Keyword||token.type===Token.BooleanLiteral||token.type===Token.NullLiteral}function advance(){var ch;skipWhitespace();if(index>=length){return{type:Token.EOF,range:[index,index]}}ch=source.charCodeAt(index);if(ch===40||ch===41||ch===58){return scanPunctuator()}if(ch===39||ch===34){return scanStringLiteral()}if(isIdentifierStart(ch)){return scanIdentifier()}if(ch===46){if(isDecimalDigit(source.charCodeAt(index+1))){return scanNumericLiteral()}return scanPunctuator()}if(isDecimalDigit(ch)){return scanNumericLiteral()}return scanPunctuator()}function lex(){var token;token=lookahead;index=token.range[1];lookahead=advance();index=token.range[1];return token}function peek(){var pos;pos=index;lookahead=advance();index=pos}function throwError(token,messageFormat){var error,args=Array.prototype.slice.call(arguments,2),msg=messageFormat.replace(/%(\d)/g,function(whole,index){assert(index<args.length,"Message reference must be in range");return args[index]});error=new Error(msg);error.index=index;error.description=msg;throw error}function throwUnexpected(token){throwError(token,Messages.UnexpectedToken,token.value)}function expect(value){var token=lex();if(token.type!==Token.Punctuator||token.value!==value){throwUnexpected(token)}}function match(value){return lookahead.type===Token.Punctuator&&lookahead.value===value}function matchKeyword(keyword){return lookahead.type===Token.Keyword&&lookahead.value===keyword}function consumeSemicolon(){if(source.charCodeAt(index)===59){lex();return}skipWhitespace();if(match(";")){lex();return}if(lookahead.type!==Token.EOF&&!match("}")){throwUnexpected(lookahead)}}function parseArrayInitialiser(){var elements=[];expect("[");while(!match("]")){if(match(",")){lex();elements.push(null)}else{elements.push(parseExpression());if(!match("]")){expect(",")}}}expect("]");return delegate.createArrayExpression(elements)}function parseObjectPropertyKey(){var token;skipWhitespace();token=lex();if(token.type===Token.StringLiteral||token.type===Token.NumericLiteral){return delegate.createLiteral(token)}return delegate.createIdentifier(token.value)}function parseObjectProperty(){var token,key;token=lookahead;skipWhitespace();if(token.type===Token.EOF||token.type===Token.Punctuator){throwUnexpected(token)}key=parseObjectPropertyKey();expect(":");return delegate.createProperty("init",key,parseExpression())}function parseObjectInitialiser(){var properties=[];expect("{");while(!match("}")){properties.push(parseObjectProperty());if(!match("}")){expect(",")}}expect("}");return delegate.createObjectExpression(properties)}function parseGroupExpression(){var expr;expect("(");expr=parseExpression();expect(")");return expr}function parsePrimaryExpression(){var type,token,expr;if(match("(")){return parseGroupExpression()}type=lookahead.type;if(type===Token.Identifier){expr=delegate.createIdentifier(lex().value)}else if(type===Token.StringLiteral||type===Token.NumericLiteral){expr=delegate.createLiteral(lex())}else if(type===Token.Keyword){if(matchKeyword("this")){lex();expr=delegate.createThisExpression()}}else if(type===Token.BooleanLiteral){token=lex();token.value=token.value==="true";expr=delegate.createLiteral(token)}else if(type===Token.NullLiteral){token=lex();token.value=null;expr=delegate.createLiteral(token)}else if(match("[")){expr=parseArrayInitialiser()}else if(match("{")){expr=parseObjectInitialiser()}if(expr){return expr}throwUnexpected(lex())}function parseArguments(){var args=[];expect("(");if(!match(")")){while(index<length){args.push(parseExpression());if(match(")")){break}expect(",")}}expect(")");return args}function parseNonComputedProperty(){var token;token=lex();if(!isIdentifierName(token)){throwUnexpected(token)}return delegate.createIdentifier(token.value)}function parseNonComputedMember(){expect(".");return parseNonComputedProperty()}function parseComputedMember(){var expr;expect("[");expr=parseExpression();expect("]");return expr}function parseLeftHandSideExpression(){var expr,args,property;expr=parsePrimaryExpression();while(true){if(match("[")){property=parseComputedMember();expr=delegate.createMemberExpression("[",expr,property)}else if(match(".")){property=parseNonComputedMember();expr=delegate.createMemberExpression(".",expr,property)}else if(match("(")){args=parseArguments();expr=delegate.createCallExpression(expr,args)}else{break}}return expr}var parsePostfixExpression=parseLeftHandSideExpression;function parseUnaryExpression(){var token,expr;if(lookahead.type!==Token.Punctuator&&lookahead.type!==Token.Keyword){expr=parsePostfixExpression()}else if(match("+")||match("-")||match("!")){token=lex();expr=parseUnaryExpression();expr=delegate.createUnaryExpression(token.value,expr)}else if(matchKeyword("delete")||matchKeyword("void")||matchKeyword("typeof")){throwError({},Messages.UnexpectedToken)}else{expr=parsePostfixExpression()}return expr}function binaryPrecedence(token){var prec=0;if(token.type!==Token.Punctuator&&token.type!==Token.Keyword){return 0}switch(token.value){case"||":prec=1;break;case"&&":prec=2;break;case"==":case"!=":case"===":case"!==":prec=6;break;case"<":case">":case"<=":case">=":case"instanceof":prec=7;break;case"in":prec=7;break;case"+":case"-":prec=9;break;case"*":case"/":case"%":prec=11;break;default:break}return prec}function parseBinaryExpression(){var expr,token,prec,stack,right,operator,left,i;left=parseUnaryExpression();token=lookahead;prec=binaryPrecedence(token);if(prec===0){return left}token.prec=prec;lex();right=parseUnaryExpression();stack=[left,token,right];while((prec=binaryPrecedence(lookahead))>0){while(stack.length>2&&prec<=stack[stack.length-2].prec){right=stack.pop();operator=stack.pop().value;left=stack.pop();expr=delegate.createBinaryExpression(operator,left,right);stack.push(expr)}token=lex();token.prec=prec;stack.push(token);expr=parseUnaryExpression();stack.push(expr)}i=stack.length-1;expr=stack[i];while(i>1){expr=delegate.createBinaryExpression(stack[i-1].value,stack[i-2],expr);i-=2}return expr}function parseConditionalExpression(){var expr,consequent,alternate;expr=parseBinaryExpression();if(match("?")){lex();consequent=parseConditionalExpression();expect(":");alternate=parseConditionalExpression();expr=delegate.createConditionalExpression(expr,consequent,alternate)}return expr}var parseExpression=parseConditionalExpression;function parseFilter(){var identifier,args;identifier=lex();if(identifier.type!==Token.Identifier){throwUnexpected(identifier)}args=match("(")?parseArguments():[];return delegate.createFilter(identifier.value,args)}function parseFilters(){while(match("|")){lex();parseFilter()}}function parseTopLevel(){skipWhitespace();peek();var expr=parseExpression();if(expr){if(lookahead.value===","||lookahead.value=="in"&&expr.type===Syntax.Identifier){parseInExpression(expr)}else{parseFilters();if(lookahead.value==="as"){parseAsExpression(expr)}else{delegate.createTopLevel(expr)}}}if(lookahead.type!==Token.EOF){throwUnexpected(lookahead)}}function parseAsExpression(expr){lex();var identifier=lex().value;delegate.createAsExpression(expr,identifier)}function parseInExpression(identifier){var indexName;if(lookahead.value===","){lex();if(lookahead.type!==Token.Identifier)throwUnexpected(lookahead);indexName=lex().value}lex();var expr=parseExpression();parseFilters();delegate.createInExpression(identifier.name,indexName,expr)}function parse(code,inDelegate){delegate=inDelegate;source=code;index=0;length=source.length;lookahead=null;state={labelSet:{}};return parseTopLevel()}global.esprima={parse:parse}})(this);(function(global){"use strict";function prepareBinding(expressionText,name,node,filterRegistry){var expression;try{expression=getExpression(expressionText);if(expression.scopeIdent&&(node.nodeType!==Node.ELEMENT_NODE||node.tagName!=="TEMPLATE"||name!=="bind"&&name!=="repeat")){throw Error("as and in can only be used within <template bind/repeat>")}}catch(ex){console.error("Invalid expression syntax: "+expressionText,ex);return}return function(model,node,oneTime){var binding=expression.getBinding(model,filterRegistry,oneTime);if(expression.scopeIdent&&binding){node.polymerExpressionScopeIdent_=expression.scopeIdent;if(expression.indexIdent)node.polymerExpressionIndexIdent_=expression.indexIdent}return binding}}var expressionParseCache=Object.create(null);function getExpression(expressionText){var expression=expressionParseCache[expressionText];if(!expression){var delegate=new ASTDelegate;esprima.parse(expressionText,delegate);expression=new Expression(delegate);expressionParseCache[expressionText]=expression}return expression}function Literal(value){this.value=value;this.valueFn_=undefined}Literal.prototype={valueFn:function(){if(!this.valueFn_){var value=this.value;this.valueFn_=function(){return value}}return this.valueFn_}};function IdentPath(name){this.name=name;this.path=Path.get(name)}IdentPath.prototype={valueFn:function(){if(!this.valueFn_){var name=this.name;var path=this.path;this.valueFn_=function(model,observer){if(observer)observer.addPath(model,path);return path.getValueFrom(model)}}return this.valueFn_},setValue:function(model,newValue){if(this.path.length==1)model=findScope(model,this.path[0]);return this.path.setValueFrom(model,newValue)}};function MemberExpression(object,property,accessor){this.computed=accessor=="[";this.dynamicDeps=typeof object=="function"||object.dynamicDeps||this.computed&&!(property instanceof Literal);this.simplePath=!this.dynamicDeps&&(property instanceof IdentPath||property instanceof Literal)&&(object instanceof MemberExpression||object instanceof IdentPath);this.object=this.simplePath?object:getFn(object);this.property=!this.computed||this.simplePath?property:getFn(property)}MemberExpression.prototype={get fullPath(){if(!this.fullPath_){var parts=this.object instanceof MemberExpression?this.object.fullPath.slice():[this.object.name];parts.push(this.property instanceof IdentPath?this.property.name:this.property.value);this.fullPath_=Path.get(parts)}return this.fullPath_},valueFn:function(){if(!this.valueFn_){var object=this.object;if(this.simplePath){var path=this.fullPath;this.valueFn_=function(model,observer){if(observer)observer.addPath(model,path);return path.getValueFrom(model)}}else if(!this.computed){var path=Path.get(this.property.name);this.valueFn_=function(model,observer,filterRegistry){var context=object(model,observer,filterRegistry);if(observer)observer.addPath(context,path);return path.getValueFrom(context)}}else{var property=this.property;this.valueFn_=function(model,observer,filterRegistry){var context=object(model,observer,filterRegistry);var propName=property(model,observer,filterRegistry);if(observer)observer.addPath(context,[propName]);return context?context[propName]:undefined}}}return this.valueFn_},setValue:function(model,newValue){if(this.simplePath){this.fullPath.setValueFrom(model,newValue);return newValue}var object=this.object(model);var propName=this.property instanceof IdentPath?this.property.name:this.property(model);return object[propName]=newValue}};function Filter(name,args){this.name=name;this.args=[];for(var i=0;i<args.length;i++){this.args[i]=getFn(args[i])}}Filter.prototype={transform:function(model,observer,filterRegistry,toModelDirection,initialArgs){var context=model;var fn=context[this.name];if(!fn){fn=filterRegistry[this.name];if(!fn){console.error("Cannot find function or filter: "+this.name);return}}if(toModelDirection){fn=fn.toModel}else if(typeof fn.toDOM=="function"){fn=fn.toDOM}if(typeof fn!="function"){console.error("Cannot find function or filter: "+this.name);return}var args=initialArgs||[];for(var i=0;i<this.args.length;i++){args.push(getFn(this.args[i])(model,observer,filterRegistry))}return fn.apply(context,args)}};function notImplemented(){throw Error("Not Implemented")}var unaryOperators={"+":function(v){return+v},"-":function(v){return-v},"!":function(v){return!v}};var binaryOperators={"+":function(l,r){return l+r},"-":function(l,r){return l-r},"*":function(l,r){return l*r},"/":function(l,r){return l/r},"%":function(l,r){return l%r},"<":function(l,r){return l<r},">":function(l,r){return l>r},"<=":function(l,r){return l<=r},">=":function(l,r){return l>=r},"==":function(l,r){return l==r},"!=":function(l,r){return l!=r},"===":function(l,r){return l===r},"!==":function(l,r){return l!==r},"&&":function(l,r){return l&&r},"||":function(l,r){return l||r}};function getFn(arg){return typeof arg=="function"?arg:arg.valueFn()}function ASTDelegate(){this.expression=null;this.filters=[];this.deps={};this.currentPath=undefined;this.scopeIdent=undefined;this.indexIdent=undefined;this.dynamicDeps=false}ASTDelegate.prototype={createUnaryExpression:function(op,argument){if(!unaryOperators[op])throw Error("Disallowed operator: "+op);argument=getFn(argument);return function(model,observer,filterRegistry){return unaryOperators[op](argument(model,observer,filterRegistry))}},createBinaryExpression:function(op,left,right){if(!binaryOperators[op])throw Error("Disallowed operator: "+op);left=getFn(left);right=getFn(right);switch(op){case"||":this.dynamicDeps=true;return function(model,observer,filterRegistry){return left(model,observer,filterRegistry)||right(model,observer,filterRegistry)};case"&&":this.dynamicDeps=true;return function(model,observer,filterRegistry){return left(model,observer,filterRegistry)&&right(model,observer,filterRegistry)}}return function(model,observer,filterRegistry){return binaryOperators[op](left(model,observer,filterRegistry),right(model,observer,filterRegistry))}},createConditionalExpression:function(test,consequent,alternate){test=getFn(test);consequent=getFn(consequent);alternate=getFn(alternate);this.dynamicDeps=true;return function(model,observer,filterRegistry){return test(model,observer,filterRegistry)?consequent(model,observer,filterRegistry):alternate(model,observer,filterRegistry)}},createIdentifier:function(name){var ident=new IdentPath(name);ident.type="Identifier";return ident},createMemberExpression:function(accessor,object,property){var ex=new MemberExpression(object,property,accessor);if(ex.dynamicDeps)this.dynamicDeps=true;return ex},createCallExpression:function(expression,args){if(!(expression instanceof IdentPath))throw Error("Only identifier function invocations are allowed");var filter=new Filter(expression.name,args);return function(model,observer,filterRegistry){return filter.transform(model,observer,filterRegistry,false)}},createLiteral:function(token){return new Literal(token.value)},createArrayExpression:function(elements){for(var i=0;i<elements.length;i++)elements[i]=getFn(elements[i]);return function(model,observer,filterRegistry){var arr=[];for(var i=0;i<elements.length;i++)arr.push(elements[i](model,observer,filterRegistry));return arr}},createProperty:function(kind,key,value){return{key:key instanceof IdentPath?key.name:key.value,value:value}},createObjectExpression:function(properties){for(var i=0;i<properties.length;i++)properties[i].value=getFn(properties[i].value);return function(model,observer,filterRegistry){var obj={};for(var i=0;i<properties.length;i++)obj[properties[i].key]=properties[i].value(model,observer,filterRegistry);return obj}},createFilter:function(name,args){this.filters.push(new Filter(name,args))},createAsExpression:function(expression,scopeIdent){this.expression=expression;this.scopeIdent=scopeIdent},createInExpression:function(scopeIdent,indexIdent,expression){this.expression=expression;this.scopeIdent=scopeIdent;this.indexIdent=indexIdent},createTopLevel:function(expression){this.expression=expression},createThisExpression:notImplemented};function ConstantObservable(value){this.value_=value}ConstantObservable.prototype={open:function(){return this.value_},discardChanges:function(){return this.value_},deliver:function(){},close:function(){}};function Expression(delegate){this.scopeIdent=delegate.scopeIdent;this.indexIdent=delegate.indexIdent;if(!delegate.expression)throw Error("No expression found.");this.expression=delegate.expression;getFn(this.expression);this.filters=delegate.filters;this.dynamicDeps=delegate.dynamicDeps}Expression.prototype={getBinding:function(model,filterRegistry,oneTime){if(oneTime)return this.getValue(model,undefined,filterRegistry);var observer=new CompoundObserver;var firstValue=this.getValue(model,observer,filterRegistry);var firstTime=true;var self=this;function valueFn(){if(firstTime){firstTime=false;return firstValue}if(self.dynamicDeps)observer.startReset();var value=self.getValue(model,self.dynamicDeps?observer:undefined,filterRegistry);if(self.dynamicDeps)observer.finishReset();return value}function setValueFn(newValue){self.setValue(model,newValue,filterRegistry);return newValue}return new ObserverTransform(observer,valueFn,setValueFn,true)},getValue:function(model,observer,filterRegistry){var value=getFn(this.expression)(model,observer,filterRegistry);for(var i=0;i<this.filters.length;i++){value=this.filters[i].transform(model,observer,filterRegistry,false,[value])}return value},setValue:function(model,newValue,filterRegistry){var count=this.filters?this.filters.length:0;while(count-->0){newValue=this.filters[count].transform(model,undefined,filterRegistry,true,[newValue])}if(this.expression.setValue)return this.expression.setValue(model,newValue)}};function convertStylePropertyName(name){return String(name).replace(/[A-Z]/g,function(c){return"-"+c.toLowerCase()})}var parentScopeName="@"+Math.random().toString(36).slice(2);function findScope(model,prop){while(model[parentScopeName]&&!Object.prototype.hasOwnProperty.call(model,prop)){model=model[parentScopeName]}return model}function isLiteralExpression(pathString){switch(pathString){case"":return false;case"false":case"null":case"true":return true}if(!isNaN(Number(pathString)))return true;return false}function PolymerExpressions(){}PolymerExpressions.prototype={styleObject:function(value){var parts=[];for(var key in value){parts.push(convertStylePropertyName(key)+": "+value[key])}return parts.join("; ")},tokenList:function(value){var tokens=[];for(var key in value){if(value[key])tokens.push(key)}return tokens.join(" ")},prepareInstancePositionChanged:function(template){var indexIdent=template.polymerExpressionIndexIdent_;if(!indexIdent)return;return function(templateInstance,index){templateInstance.model[indexIdent]=index}},prepareBinding:function(pathString,name,node){var path=Path.get(pathString);if(!isLiteralExpression(pathString)&&path.valid){if(path.length==1){return function(model,node,oneTime){if(oneTime)return path.getValueFrom(model);var scope=findScope(model,path[0]);return new PathObserver(scope,path)}}return}return prepareBinding(pathString,name,node,this)},prepareInstanceModel:function(template){var scopeName=template.polymerExpressionScopeIdent_;if(!scopeName)return;var parentScope=template.templateInstance?template.templateInstance.model:template.model;var indexName=template.polymerExpressionIndexIdent_;return function(model){return createScopeObject(parentScope,model,scopeName,indexName)}}};var createScopeObject="__proto__"in{}?function(parentScope,model,scopeName,indexName){var scope={};scope[scopeName]=model;scope[indexName]=undefined;scope[parentScopeName]=parentScope;scope.__proto__=parentScope;return scope}:function(parentScope,model,scopeName,indexName){var scope=Object.create(parentScope);Object.defineProperty(scope,scopeName,{value:model,configurable:true,writable:true});Object.defineProperty(scope,indexName,{value:undefined,configurable:true,writable:true});Object.defineProperty(scope,parentScopeName,{value:parentScope,configurable:true,writable:true});return scope};global.PolymerExpressions=PolymerExpressions;PolymerExpressions.getExpression=getExpression})(this);Polymer={version:"0.5.5"};if(typeof window.Polymer==="function"){Polymer={}}(function(scope){function withDependencies(task,depends){depends=depends||[];if(!depends.map){depends=[depends]}return task.apply(this,depends.map(marshal))}function module(name,dependsOrFactory,moduleFactory){var module;switch(arguments.length){case 0:return;case 1:module=null;break;case 2:module=dependsOrFactory.apply(this);break;default:module=withDependencies(moduleFactory,dependsOrFactory);break}modules[name]=module}function marshal(name){return modules[name]}var modules={};function using(depends,task){HTMLImports.whenImportsReady(function(){withDependencies(task,depends)})}scope.marshal=marshal;scope.modularize=module;scope.using=using})(window);if(!window.WebComponents){if(!window.WebComponents){WebComponents={flush:function(){},flags:{log:{}}};Platform=WebComponents;CustomElements={useNative:true,ready:true,takeRecords:function(){},"instanceof":function(obj,base){return obj instanceof base}};HTMLImports={useNative:true};addEventListener("HTMLImportsLoaded",function(){document.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:true}))});ShadowDOMPolyfill=null;wrap=unwrap=function(n){return n}}window.HTMLImports=window.HTMLImports||{flags:{}};(function(scope){var IMPORT_LINK_TYPE="import";var useNative=Boolean(IMPORT_LINK_TYPE in document.createElement("link"));var hasShadowDOMPolyfill=Boolean(window.ShadowDOMPolyfill);var wrap=function(node){return hasShadowDOMPolyfill?ShadowDOMPolyfill.wrapIfNeeded(node):node};var rootDocument=wrap(document);var currentScriptDescriptor={get:function(){var script=HTMLImports.currentScript||document.currentScript||(document.readyState!=="complete"?document.scripts[document.scripts.length-1]:null);return wrap(script)},configurable:true};Object.defineProperty(document,"_currentScript",currentScriptDescriptor);Object.defineProperty(rootDocument,"_currentScript",currentScriptDescriptor);var isIE=/Trident/.test(navigator.userAgent);function whenReady(callback,doc){doc=doc||rootDocument;whenDocumentReady(function(){watchImportsLoad(callback,doc)},doc)}var requiredReadyState=isIE?"complete":"interactive";var READY_EVENT="readystatechange";function isDocumentReady(doc){return doc.readyState==="complete"||doc.readyState===requiredReadyState}function whenDocumentReady(callback,doc){if(!isDocumentReady(doc)){var checkReady=function(){if(doc.readyState==="complete"||doc.readyState===requiredReadyState){doc.removeEventListener(READY_EVENT,checkReady);whenDocumentReady(callback,doc)}};doc.addEventListener(READY_EVENT,checkReady)}else if(callback){callback()}}function markTargetLoaded(event){event.target.__loaded=true}function watchImportsLoad(callback,doc){var imports=doc.querySelectorAll("link[rel=import]");var loaded=0,l=imports.length;function checkDone(d){if(loaded==l&&callback){callback()}}function loadedImport(e){markTargetLoaded(e);loaded++;checkDone()}if(l){for(var i=0,imp;i<l&&(imp=imports[i]);i++){if(isImportLoaded(imp)){loadedImport.call(imp,{target:imp})}else{imp.addEventListener("load",loadedImport);imp.addEventListener("error",loadedImport)}}}else{checkDone()}}function isImportLoaded(link){return useNative?link.__loaded||link.import&&link.import.readyState!=="loading":link.__importParsed}if(useNative){new MutationObserver(function(mxns){for(var i=0,l=mxns.length,m;i<l&&(m=mxns[i]);i++){if(m.addedNodes){handleImports(m.addedNodes)}}}).observe(document.head,{childList:true});function handleImports(nodes){for(var i=0,l=nodes.length,n;i<l&&(n=nodes[i]);i++){if(isImport(n)){handleImport(n)}}}function isImport(element){return element.localName==="link"&&element.rel==="import"}function handleImport(element){var loaded=element.import;if(loaded){markTargetLoaded({target:element})}else{element.addEventListener("load",markTargetLoaded);element.addEventListener("error",markTargetLoaded)}}(function(){if(document.readyState==="loading"){var imports=document.querySelectorAll("link[rel=import]");for(var i=0,l=imports.length,imp;i<l&&(imp=imports[i]);i++){handleImport(imp)}}})()}whenReady(function(){HTMLImports.ready=true;HTMLImports.readyTime=(new Date).getTime();rootDocument.dispatchEvent(new CustomEvent("HTMLImportsLoaded",{bubbles:true}))});scope.IMPORT_LINK_TYPE=IMPORT_LINK_TYPE;scope.useNative=useNative;scope.rootDocument=rootDocument;scope.whenReady=whenReady;scope.isIE=isIE})(HTMLImports);(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;"+" } \n";var head=document.querySelector("head");head.insertBefore(style,head.firstChild)})(Platform)}(function(global){"use strict";var testingExposeCycleCount=global.testingExposeCycleCount;function detectObjectObserve(){if(typeof Object.observe!=="function"||typeof Array.observe!=="function"){return false}var records=[];function callback(recs){records=recs}var test={};var arr=[];Object.observe(test,callback);Array.observe(arr,callback);test.id=1;test.id=2;delete test.id;arr.push(1,2);arr.length=0;Object.deliverChangeRecords(callback);if(records.length!==5)return false;if(records[0].type!="add"||records[1].type!="update"||records[2].type!="delete"||records[3].type!="splice"||records[4].type!="splice"){return false}Object.unobserve(test,callback);Array.unobserve(arr,callback);return true}var hasObserve=detectObjectObserve();function detectEval(){if(typeof chrome!=="undefined"&&chrome.app&&chrome.app.runtime){return false}if(typeof navigator!="undefined"&&navigator.getDeviceStorage){return false}try{var f=new Function("","return true;");return f()}catch(ex){return false}}var hasEval=detectEval();function isIndex(s){return+s===s>>>0&&s!==""}function toNumber(s){return+s}function isObject(obj){return obj===Object(obj)}var numberIsNaN=global.Number.isNaN||function(value){return typeof value==="number"&&global.isNaN(value)};function areSameValue(left,right){if(left===right)return left!==0||1/left===1/right;if(numberIsNaN(left)&&numberIsNaN(right))return true;return left!==left&&right!==right}var createObject="__proto__"in{}?function(obj){return obj}:function(obj){var proto=obj.__proto__;if(!proto)return obj;var newObject=Object.create(proto);Object.getOwnPropertyNames(obj).forEach(function(name){Object.defineProperty(newObject,name,Object.getOwnPropertyDescriptor(obj,name))});return newObject};var identStart="[$_a-zA-Z]";var identPart="[$_a-zA-Z0-9]";var identRegExp=new RegExp("^"+identStart+"+"+identPart+"*"+"$");
function getPathCharType(char){if(char===undefined)return"eof";var code=char.charCodeAt(0);switch(code){case 91:case 93:case 46:case 34:case 39:case 48:return char;case 95:case 36:return"ident";case 32:case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"ws"}if(97<=code&&code<=122||65<=code&&code<=90)return"ident";if(49<=code&&code<=57)return"number";return"else"}var pathStateMachine={beforePath:{ws:["beforePath"],ident:["inIdent","append"],"[":["beforeElement"],eof:["afterPath"]},inPath:{ws:["inPath"],".":["beforeIdent"],"[":["beforeElement"],eof:["afterPath"]},beforeIdent:{ws:["beforeIdent"],ident:["inIdent","append"]},inIdent:{ident:["inIdent","append"],0:["inIdent","append"],number:["inIdent","append"],ws:["inPath","push"],".":["beforeIdent","push"],"[":["beforeElement","push"],eof:["afterPath","push"]},beforeElement:{ws:["beforeElement"],0:["afterZero","append"],number:["inIndex","append"],"'":["inSingleQuote","append",""],'"':["inDoubleQuote","append",""]},afterZero:{ws:["afterElement","push"],"]":["inPath","push"]},inIndex:{0:["inIndex","append"],number:["inIndex","append"],ws:["afterElement"],"]":["inPath","push"]},inSingleQuote:{"'":["afterElement"],eof:["error"],"else":["inSingleQuote","append"]},inDoubleQuote:{'"':["afterElement"],eof:["error"],"else":["inDoubleQuote","append"]},afterElement:{ws:["afterElement"],"]":["inPath","push"]}};function noop(){}function parsePath(path){var keys=[];var index=-1;var c,newChar,key,type,transition,action,typeMap,mode="beforePath";var actions={push:function(){if(key===undefined)return;keys.push(key);key=undefined},append:function(){if(key===undefined)key=newChar;else key+=newChar}};function maybeUnescapeQuote(){if(index>=path.length)return;var nextChar=path[index+1];if(mode=="inSingleQuote"&&nextChar=="'"||mode=="inDoubleQuote"&&nextChar=='"'){index++;newChar=nextChar;actions.append();return true}}while(mode){index++;c=path[index];if(c=="\\"&&maybeUnescapeQuote(mode))continue;type=getPathCharType(c);typeMap=pathStateMachine[mode];transition=typeMap[type]||typeMap["else"]||"error";if(transition=="error")return;mode=transition[0];action=actions[transition[1]]||noop;newChar=transition[2]===undefined?c:transition[2];action();if(mode==="afterPath"){return keys}}return}function isIdent(s){return identRegExp.test(s)}var constructorIsPrivate={};function Path(parts,privateToken){if(privateToken!==constructorIsPrivate)throw Error("Use Path.get to retrieve path objects");for(var i=0;i<parts.length;i++){this.push(String(parts[i]))}if(hasEval&&this.length){this.getValueFrom=this.compiledGetValueFromFn()}}var pathCache={};function getPath(pathString){if(pathString instanceof Path)return pathString;if(pathString==null||pathString.length==0)pathString="";if(typeof pathString!="string"){if(isIndex(pathString.length)){return new Path(pathString,constructorIsPrivate)}pathString=String(pathString)}var path=pathCache[pathString];if(path)return path;var parts=parsePath(pathString);if(!parts)return invalidPath;var path=new Path(parts,constructorIsPrivate);pathCache[pathString]=path;return path}Path.get=getPath;function formatAccessor(key){if(isIndex(key)){return"["+key+"]"}else{return'["'+key.replace(/"/g,'\\"')+'"]'}}Path.prototype=createObject({__proto__:[],valid:true,toString:function(){var pathString="";for(var i=0;i<this.length;i++){var key=this[i];if(isIdent(key)){pathString+=i?"."+key:key}else{pathString+=formatAccessor(key)}}return pathString},getValueFrom:function(obj,directObserver){for(var i=0;i<this.length;i++){if(obj==null)return;obj=obj[this[i]]}return obj},iterateObjects:function(obj,observe){for(var i=0;i<this.length;i++){if(i)obj=obj[this[i-1]];if(!isObject(obj))return;observe(obj,this[i])}},compiledGetValueFromFn:function(){var str="";var pathString="obj";str+="if (obj != null";var i=0;var key;for(;i<this.length-1;i++){key=this[i];pathString+=isIdent(key)?"."+key:formatAccessor(key);str+=" &&\n "+pathString+" != null"}str+=")\n";var key=this[i];pathString+=isIdent(key)?"."+key:formatAccessor(key);str+=" return "+pathString+";\nelse\n return undefined;";return new Function("obj",str)},setValueFrom:function(obj,value){if(!this.length)return false;for(var i=0;i<this.length-1;i++){if(!isObject(obj))return false;obj=obj[this[i]]}if(!isObject(obj))return false;obj[this[i]]=value;return true}});var invalidPath=new Path("",constructorIsPrivate);invalidPath.valid=false;invalidPath.getValueFrom=invalidPath.setValueFrom=function(){};var MAX_DIRTY_CHECK_CYCLES=1e3;function dirtyCheck(observer){var cycles=0;while(cycles<MAX_DIRTY_CHECK_CYCLES&&observer.check_()){cycles++}if(testingExposeCycleCount)global.dirtyCheckCycleCount=cycles;return cycles>0}function objectIsEmpty(object){for(var prop in object)return false;return true}function diffIsEmpty(diff){return objectIsEmpty(diff.added)&&objectIsEmpty(diff.removed)&&objectIsEmpty(diff.changed)}function diffObjectFromOldObject(object,oldObject){var added={};var removed={};var changed={};for(var prop in oldObject){var newValue=object[prop];if(newValue!==undefined&&newValue===oldObject[prop])continue;if(!(prop in object)){removed[prop]=undefined;continue}if(newValue!==oldObject[prop])changed[prop]=newValue}for(var prop in object){if(prop in oldObject)continue;added[prop]=object[prop]}if(Array.isArray(object)&&object.length!==oldObject.length)changed.length=object.length;return{added:added,removed:removed,changed:changed}}var eomTasks=[];function runEOMTasks(){if(!eomTasks.length)return false;for(var i=0;i<eomTasks.length;i++){eomTasks[i]()}eomTasks.length=0;return true}var runEOM=hasObserve?function(){return function(fn){return Promise.resolve().then(fn)}}():function(){return function(fn){eomTasks.push(fn)}}();var observedObjectCache=[];function newObservedObject(){var observer;var object;var discardRecords=false;var first=true;function callback(records){if(observer&&observer.state_===OPENED&&!discardRecords)observer.check_(records)}return{open:function(obs){if(observer)throw Error("ObservedObject in use");if(!first)Object.deliverChangeRecords(callback);observer=obs;first=false},observe:function(obj,arrayObserve){object=obj;if(arrayObserve)Array.observe(object,callback);else Object.observe(object,callback)},deliver:function(discard){discardRecords=discard;Object.deliverChangeRecords(callback);discardRecords=false},close:function(){observer=undefined;Object.unobserve(object,callback);observedObjectCache.push(this)}}}function getObservedObject(observer,object,arrayObserve){var dir=observedObjectCache.pop()||newObservedObject();dir.open(observer);dir.observe(object,arrayObserve);return dir}var observedSetCache=[];function newObservedSet(){var observerCount=0;var observers=[];var objects=[];var rootObj;var rootObjProps;function observe(obj,prop){if(!obj)return;if(obj===rootObj)rootObjProps[prop]=true;if(objects.indexOf(obj)<0){objects.push(obj);Object.observe(obj,callback)}observe(Object.getPrototypeOf(obj),prop)}function allRootObjNonObservedProps(recs){for(var i=0;i<recs.length;i++){var rec=recs[i];if(rec.object!==rootObj||rootObjProps[rec.name]||rec.type==="setPrototype"){return false}}return true}function callback(recs){if(allRootObjNonObservedProps(recs))return;var observer;for(var i=0;i<observers.length;i++){observer=observers[i];if(observer.state_==OPENED){observer.iterateObjects_(observe)}}for(var i=0;i<observers.length;i++){observer=observers[i];if(observer.state_==OPENED){observer.check_()}}}var record={objects:objects,get rootObject(){return rootObj},set rootObject(value){rootObj=value;rootObjProps={}},open:function(obs,object){observers.push(obs);observerCount++;obs.iterateObjects_(observe)},close:function(obs){observerCount--;if(observerCount>0){return}for(var i=0;i<objects.length;i++){Object.unobserve(objects[i],callback);Observer.unobservedCount++}observers.length=0;objects.length=0;rootObj=undefined;rootObjProps=undefined;observedSetCache.push(this);if(lastObservedSet===this)lastObservedSet=null}};return record}var lastObservedSet;function getObservedSet(observer,obj){if(!lastObservedSet||lastObservedSet.rootObject!==obj){lastObservedSet=observedSetCache.pop()||newObservedSet();lastObservedSet.rootObject=obj}lastObservedSet.open(observer,obj);return lastObservedSet}var UNOPENED=0;var OPENED=1;var CLOSED=2;var RESETTING=3;var nextObserverId=1;function Observer(){this.state_=UNOPENED;this.callback_=undefined;this.target_=undefined;this.directObserver_=undefined;this.value_=undefined;this.id_=nextObserverId++}Observer.prototype={open:function(callback,target){if(this.state_!=UNOPENED)throw Error("Observer has already been opened.");addToAll(this);this.callback_=callback;this.target_=target;this.connect_();this.state_=OPENED;return this.value_},close:function(){if(this.state_!=OPENED)return;removeFromAll(this);this.disconnect_();this.value_=undefined;this.callback_=undefined;this.target_=undefined;this.state_=CLOSED},deliver:function(){if(this.state_!=OPENED)return;dirtyCheck(this)},report_:function(changes){try{this.callback_.apply(this.target_,changes)}catch(ex){Observer._errorThrownDuringCallback=true;console.error("Exception caught during observer callback: "+(ex.stack||ex))}},discardChanges:function(){this.check_(undefined,true);return this.value_}};var collectObservers=!hasObserve;var allObservers;Observer._allObserversCount=0;if(collectObservers){allObservers=[]}function addToAll(observer){Observer._allObserversCount++;if(!collectObservers)return;allObservers.push(observer)}function removeFromAll(observer){Observer._allObserversCount--}var runningMicrotaskCheckpoint=false;global.Platform=global.Platform||{};global.Platform.performMicrotaskCheckpoint=function(){if(runningMicrotaskCheckpoint)return;if(!collectObservers)return;runningMicrotaskCheckpoint=true;var cycles=0;var anyChanged,toCheck;do{cycles++;toCheck=allObservers;allObservers=[];anyChanged=false;for(var i=0;i<toCheck.length;i++){var observer=toCheck[i];if(observer.state_!=OPENED)continue;if(observer.check_())anyChanged=true;allObservers.push(observer)}if(runEOMTasks())anyChanged=true}while(cycles<MAX_DIRTY_CHECK_CYCLES&&anyChanged);if(testingExposeCycleCount)global.dirtyCheckCycleCount=cycles;runningMicrotaskCheckpoint=false};if(collectObservers){global.Platform.clearObservers=function(){allObservers=[]}}function ObjectObserver(object){Observer.call(this);this.value_=object;this.oldObject_=undefined}ObjectObserver.prototype=createObject({__proto__:Observer.prototype,arrayObserve:false,connect_:function(callback,target){if(hasObserve){this.directObserver_=getObservedObject(this,this.value_,this.arrayObserve)}else{this.oldObject_=this.copyObject(this.value_)}},copyObject:function(object){var copy=Array.isArray(object)?[]:{};for(var prop in object){copy[prop]=object[prop]}if(Array.isArray(object))copy.length=object.length;return copy},check_:function(changeRecords,skipChanges){var diff;var oldValues;if(hasObserve){if(!changeRecords)return false;oldValues={};diff=diffObjectFromChangeRecords(this.value_,changeRecords,oldValues)}else{oldValues=this.oldObject_;diff=diffObjectFromOldObject(this.value_,this.oldObject_)}if(diffIsEmpty(diff))return false;if(!hasObserve)this.oldObject_=this.copyObject(this.value_);this.report_([diff.added||{},diff.removed||{},diff.changed||{},function(property){return oldValues[property]}]);return true},disconnect_:function(){if(hasObserve){this.directObserver_.close();this.directObserver_=undefined}else{this.oldObject_=undefined}},deliver:function(){if(this.state_!=OPENED)return;if(hasObserve)this.directObserver_.deliver(false);else dirtyCheck(this)},discardChanges:function(){if(this.directObserver_)this.directObserver_.deliver(true);else this.oldObject_=this.copyObject(this.value_);return this.value_}});function ArrayObserver(array){if(!Array.isArray(array))throw Error("Provided object is not an Array");ObjectObserver.call(this,array)}ArrayObserver.prototype=createObject({__proto__:ObjectObserver.prototype,arrayObserve:true,copyObject:function(arr){return arr.slice()},check_:function(changeRecords){var splices;if(hasObserve){if(!changeRecords)return false;splices=projectArraySplices(this.value_,changeRecords)}else{splices=calcSplices(this.value_,0,this.value_.length,this.oldObject_,0,this.oldObject_.length)}if(!splices||!splices.length)return false;if(!hasObserve)this.oldObject_=this.copyObject(this.value_);this.report_([splices]);return true}});ArrayObserver.applySplices=function(previous,current,splices){splices.forEach(function(splice){var spliceArgs=[splice.index,splice.removed.length];var addIndex=splice.index;while(addIndex<splice.index+splice.addedCount){spliceArgs.push(current[addIndex]);addIndex++}Array.prototype.splice.apply(previous,spliceArgs)})};function PathObserver(object,path){Observer.call(this);this.object_=object;this.path_=getPath(path);this.directObserver_=undefined}PathObserver.prototype=createObject({__proto__:Observer.prototype,get path(){return this.path_},connect_:function(){if(hasObserve)this.directObserver_=getObservedSet(this,this.object_);this.check_(undefined,true)},disconnect_:function(){this.value_=undefined;if(this.directObserver_){this.directObserver_.close(this);this.directObserver_=undefined}},iterateObjects_:function(observe){this.path_.iterateObjects(this.object_,observe)},check_:function(changeRecords,skipChanges){var oldValue=this.value_;this.value_=this.path_.getValueFrom(this.object_);if(skipChanges||areSameValue(this.value_,oldValue))return false;this.report_([this.value_,oldValue,this]);return true},setValue:function(newValue){if(this.path_)this.path_.setValueFrom(this.object_,newValue)}});function CompoundObserver(reportChangesOnOpen){Observer.call(this);this.reportChangesOnOpen_=reportChangesOnOpen;this.value_=[];this.directObserver_=undefined;this.observed_=[]}var observerSentinel={};CompoundObserver.prototype=createObject({__proto__:Observer.prototype,connect_:function(){if(hasObserve){var object;var needsDirectObserver=false;for(var i=0;i<this.observed_.length;i+=2){object=this.observed_[i];if(object!==observerSentinel){needsDirectObserver=true;break}}if(needsDirectObserver)this.directObserver_=getObservedSet(this,object)}this.check_(undefined,!this.reportChangesOnOpen_)},disconnect_:function(){for(var i=0;i<this.observed_.length;i+=2){if(this.observed_[i]===observerSentinel)this.observed_[i+1].close()}this.observed_.length=0;this.value_.length=0;if(this.directObserver_){this.directObserver_.close(this);this.directObserver_=undefined}},addPath:function(object,path){if(this.state_!=UNOPENED&&this.state_!=RESETTING)throw Error("Cannot add paths once started.");var path=getPath(path);this.observed_.push(object,path);if(!this.reportChangesOnOpen_)return;var index=this.observed_.length/2-1;this.value_[index]=path.getValueFrom(object)},addObserver:function(observer){if(this.state_!=UNOPENED&&this.state_!=RESETTING)throw Error("Cannot add observers once started.");this.observed_.push(observerSentinel,observer);if(!this.reportChangesOnOpen_)return;var index=this.observed_.length/2-1;this.value_[index]=observer.open(this.deliver,this)},startReset:function(){if(this.state_!=OPENED)throw Error("Can only reset while open");this.state_=RESETTING;this.disconnect_()},finishReset:function(){if(this.state_!=RESETTING)throw Error("Can only finishReset after startReset");this.state_=OPENED;this.connect_();return this.value_},iterateObjects_:function(observe){var object;for(var i=0;i<this.observed_.length;i+=2){object=this.observed_[i];if(object!==observerSentinel)this.observed_[i+1].iterateObjects(object,observe)}},check_:function(changeRecords,skipChanges){var oldValues;for(var i=0;i<this.observed_.length;i+=2){var object=this.observed_[i];var path=this.observed_[i+1];var value;if(object===observerSentinel){var observable=path;value=this.state_===UNOPENED?observable.open(this.deliver,this):observable.discardChanges()}else{value=path.getValueFrom(object)}if(skipChanges){this.value_[i/2]=value;continue}if(areSameValue(value,this.value_[i/2]))continue;oldValues=oldValues||[];oldValues[i/2]=this.value_[i/2];this.value_[i/2]=value}if(!oldValues)return false;this.report_([this.value_,oldValues,this.observed_]);return true}});function identFn(value){return value}function ObserverTransform(observable,getValueFn,setValueFn,dontPassThroughSet){this.callback_=undefined;this.target_=undefined;this.value_=undefined;this.observable_=observable;this.getValueFn_=getValueFn||identFn;this.setValueFn_=setValueFn||identFn;this.dontPassThroughSet_=dontPassThroughSet}ObserverTransform.prototype={open:function(callback,target){this.callback_=callback;this.target_=target;this.value_=this.getValueFn_(this.observable_.open(this.observedCallback_,this));return this.value_},observedCallback_:function(value){value=this.getValueFn_(value);if(areSameValue(value,this.value_))return;var oldValue=this.value_;this.value_=value;this.callback_.call(this.target_,this.value_,oldValue)},discardChanges:function(){this.value_=this.getValueFn_(this.observable_.discardChanges());return this.value_},deliver:function(){return this.observable_.deliver()},setValue:function(value){value=this.setValueFn_(value);if(!this.dontPassThroughSet_&&this.observable_.setValue)return this.observable_.setValue(value)},close:function(){if(this.observable_)this.observable_.close();this.callback_=undefined;this.target_=undefined;this.observable_=undefined;this.value_=undefined;this.getValueFn_=undefined;this.setValueFn_=undefined}};var expectedRecordTypes={add:true,update:true,"delete":true};function diffObjectFromChangeRecords(object,changeRecords,oldValues){var added={};var removed={};for(var i=0;i<changeRecords.length;i++){var record=changeRecords[i];if(!expectedRecordTypes[record.type]){console.error("Unknown changeRecord type: "+record.type);console.error(record);continue}if(!(record.name in oldValues))oldValues[record.name]=record.oldValue;if(record.type=="update")continue;if(record.type=="add"){if(record.name in removed)delete removed[record.name];else added[record.name]=true;continue}if(record.name in added){delete added[record.name];delete oldValues[record.name]}else{removed[record.name]=true}}for(var prop in added)added[prop]=object[prop];for(var prop in removed)removed[prop]=undefined;var changed={};for(var prop in oldValues){if(prop in added||prop in removed)continue;var newValue=object[prop];if(oldValues[prop]!==newValue)changed[prop]=newValue}return{added:added,removed:removed,changed:changed}}function newSplice(index,removed,addedCount){return{index:index,removed:removed,addedCount:addedCount}}var EDIT_LEAVE=0;var EDIT_UPDATE=1;var EDIT_ADD=2;var EDIT_DELETE=3;function ArraySplice(){}ArraySplice.prototype={calcEditDistances:function(current,currentStart,currentEnd,old,oldStart,oldEnd){var rowCount=oldEnd-oldStart+1;var columnCount=currentEnd-currentStart+1;var distances=new Array(rowCount);for(var i=0;i<rowCount;i++){distances[i]=new Array(columnCount);distances[i][0]=i}for(var j=0;j<columnCount;j++)distances[0][j]=j;for(var i=1;i<rowCount;i++){for(var j=1;j<columnCount;j++){if(this.equals(current[currentStart+j-1],old[oldStart+i-1]))distances[i][j]=distances[i-1][j-1];else{var north=distances[i-1][j]+1;var west=distances[i][j-1]+1;distances[i][j]=north<west?north:west}}}return distances},spliceOperationsFromEditDistances:function(distances){var i=distances.length-1;var j=distances[0].length-1;var current=distances[i][j];var edits=[];while(i>0||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<north)min=west<northWest?west:northWest;else min=north<northWest?north:northWest;if(min==northWest){if(northWest==current){edits.push(EDIT_LEAVE)}else{edits.push(EDIT_UPDATE);current=northWest}i--;j--}else if(min==west){edits.push(EDIT_DELETE);i--;current=west}else{edits.push(EDIT_ADD);j--;current=north}}edits.reverse();return edits},calcSplices:function(current,currentStart,currentEnd,old,oldStart,oldEnd){var prefixCount=0;var suffixCount=0;var minLength=Math.min(currentEnd-currentStart,oldEnd-oldStart);if(currentStart==0&&oldStart==0)prefixCount=this.sharedPrefix(current,old,minLength);if(currentEnd==current.length&&oldEnd==old.length)suffixCount=this.sharedSuffix(current,old,minLength-prefixCount);currentStart+=prefixCount;oldStart+=prefixCount;currentEnd-=suffixCount;oldEnd-=suffixCount;if(currentEnd-currentStart==0&&oldEnd-oldStart==0)return[];if(currentStart==currentEnd){var splice=newSplice(currentStart,[],0);while(oldStart<oldEnd)splice.removed.push(old[oldStart++]);return[splice]}else if(oldStart==oldEnd)return[newSplice(currentStart,[],currentEnd-currentStart)];var ops=this.spliceOperationsFromEditDistances(this.calcEditDistances(current,currentStart,currentEnd,old,oldStart,oldEnd));var splice=undefined;var splices=[];var index=currentStart;var oldIndex=oldStart;for(var i=0;i<ops.length;i++){switch(ops[i]){case EDIT_LEAVE:if(splice){splices.push(splice);splice=undefined}index++;oldIndex++;break;case EDIT_UPDATE:if(!splice)splice=newSplice(index,[],0);splice.addedCount++;index++;splice.removed.push(old[oldIndex]);oldIndex++;break;case EDIT_ADD:if(!splice)splice=newSplice(index,[],0);splice.addedCount++;index++;break;case EDIT_DELETE:if(!splice)splice=newSplice(index,[],0);splice.removed.push(old[oldIndex]);oldIndex++;break}}if(splice){splices.push(splice)}return splices},sharedPrefix:function(current,old,searchLength){for(var i=0;i<searchLength;i++)if(!this.equals(current[i],old[i]))return i;return searchLength},sharedSuffix:function(current,old,searchLength){var index1=current.length;var index2=old.length;var count=0;while(count<searchLength&&this.equals(current[--index1],old[--index2]))count++;return count},calculateSplices:function(current,previous){return this.calcSplices(current,0,current.length,previous,0,previous.length)},equals:function(currentValue,previousValue){return currentValue===previousValue}};var arraySplice=new ArraySplice;function calcSplices(current,currentStart,currentEnd,old,oldStart,oldEnd){return arraySplice.calcSplices(current,currentStart,currentEnd,old,oldStart,oldEnd)}function intersect(start1,end1,start2,end2){if(end1<start2||end2<start1)return-1;if(end1==start2||end2==start1)return 0;if(start1<start2){if(end1<end2)return end1-start2;else return end2-start2}else{if(end2<end1)return end2-start1;else return end1-start1}}function mergeSplice(splices,index,removed,addedCount){var splice=newSplice(index,removed,addedCount);var inserted=false;var insertionOffset=0;for(var i=0;i<splices.length;i++){var current=splices[i];current.index+=insertionOffset;if(inserted)continue;var intersectCount=intersect(splice.index,splice.index+splice.removed.length,current.index,current.index+current.addedCount);if(intersectCount>=0){splices.splice(i,1);i--;insertionOffset-=current.addedCount-current.removed.length;splice.addedCount+=current.addedCount-intersectCount;var deleteCount=splice.removed.length+current.removed.length-intersectCount;if(!splice.addedCount&&!deleteCount){inserted=true}else{var removed=current.removed;if(splice.index<current.index){var prepend=splice.removed.slice(0,current.index-splice.index);Array.prototype.push.apply(prepend,removed);removed=prepend}if(splice.index+splice.removed.length>current.index+current.addedCount){var append=splice.removed.slice(current.index+current.addedCount-splice.index);Array.prototype.push.apply(removed,append)}splice.removed=removed;if(current.index<splice.index){splice.index=current.index}}}else if(splice.index<current.index){inserted=true;splices.splice(i,0,splice);i++;var offset=splice.addedCount-splice.removed.length;current.index+=offset;insertionOffset+=offset}}if(!inserted)splices.push(splice)}function createInitialSplices(array,changeRecords){var splices=[];for(var i=0;i<changeRecords.length;i++){var record=changeRecords[i];switch(record.type){case"splice":mergeSplice(splices,record.index,record.removed.slice(),record.addedCount);break;case"add":case"update":case"delete":if(!isIndex(record.name))continue;var index=toNumber(record.name);if(index<0)continue;mergeSplice(splices,index,[record.oldValue],1);break;default:console.error("Unexpected record type: "+JSON.stringify(record));break}}return splices}function projectArraySplices(array,changeRecords){var splices=[];createInitialSplices(array,changeRecords).forEach(function(splice){if(splice.addedCount==1&&splice.removed.length==1){if(splice.removed[0]!==array[splice.index])splices.push(splice);return}splices=splices.concat(calcSplices(array,splice.index,splice.index+splice.addedCount,splice.removed,0,splice.removed.length))});return splices}var expose=global;if(typeof exports!=="undefined"&&!exports.nodeType){if(typeof module!=="undefined"&&module.exports){exports=module.exports}expose=exports}expose.Observer=Observer;expose.Observer.runEOM_=runEOM;expose.Observer.observerSentinel_=observerSentinel;expose.Observer.hasObjectObserve=hasObserve;expose.ArrayObserver=ArrayObserver;expose.ArrayObserver.calculateSplices=function(current,previous){return arraySplice.calculateSplices(current,previous)};expose.ArraySplice=ArraySplice;expose.ObjectObserver=ObjectObserver;expose.PathObserver=PathObserver;expose.CompoundObserver=CompoundObserver;expose.Path=Path;expose.ObserverTransform=ObserverTransform})(typeof global!=="undefined"&&global&&typeof module!=="undefined"&&module?global:this||window);(function(global){"use strict";var filter=Array.prototype.filter.call.bind(Array.prototype.filter);function getTreeScope(node){while(node.parentNode){node=node.parentNode}return typeof node.getElementById==="function"?node:null}Node.prototype.bind=function(name,observable){console.error("Unhandled binding to Node: ",this,name,observable)};Node.prototype.bindFinished=function(){};function updateBindings(node,name,binding){var bindings=node.bindings_;if(!bindings)bindings=node.bindings_={};if(bindings[name])binding[name].close();return bindings[name]=binding}function returnBinding(node,name,binding){return binding}function sanitizeValue(value){return value==null?"":value}function updateText(node,value){node.data=sanitizeValue(value)}function textBinding(node){return function(value){return updateText(node,value)}}var maybeUpdateBindings=returnBinding;Object.defineProperty(Platform,"enableBindingsReflection",{get:function(){return maybeUpdateBindings===updateBindings},set:function(enable){maybeUpdateBindings=enable?updateBindings:returnBinding;return enable},configurable:true});Text.prototype.bind=function(name,value,oneTime){if(name!=="textContent")return Node.prototype.bind.call(this,name,value,oneTime);if(oneTime)return updateText(this,value);var observable=value;updateText(this,observable.open(textBinding(this)));return maybeUpdateBindings(this,name,observable)};function updateAttribute(el,name,conditional,value){if(conditional){if(value)el.setAttribute(name,"");else el.removeAttribute(name);return}el.setAttribute(name,sanitizeValue(value))}function attributeBinding(el,name,conditional){return function(value){updateAttribute(el,name,conditional,value)}}Element.prototype.bind=function(name,value,oneTime){var conditional=name[name.length-1]=="?";if(conditional){this.removeAttribute(name);name=name.slice(0,-1)}if(oneTime)return updateAttribute(this,name,conditional,value);var observable=value;updateAttribute(this,name,conditional,observable.open(attributeBinding(this,name,conditional)));return maybeUpdateBindings(this,name,observable)};var checkboxEventType;(function(){var div=document.createElement("div");var checkbox=div.appendChild(document.createElement("input"));checkbox.setAttribute("type","checkbox");var first;var count=0;checkbox.addEventListener("click",function(e){count++;first=first||"click"});checkbox.addEventListener("change",function(){count++;first=first||"change"});var event=document.createEvent("MouseEvent");event.initMouseEvent("click",true,true,window,0,0,0,0,0,false,false,false,false,0,null);checkbox.dispatchEvent(event);checkboxEventType=count==1?"change":first})();function getEventForInputType(element){switch(element.type){case"checkbox":return checkboxEventType;case"radio":case"select-multiple":case"select-one":return"change";case"range":if(/Trident|MSIE/.test(navigator.userAgent))return"change";default:return"input"}}function updateInput(input,property,value,santizeFn){input[property]=(santizeFn||sanitizeValue)(value)}function inputBinding(input,property,santizeFn){return function(value){return updateInput(input,property,value,santizeFn)}}function noop(){}function bindInputEvent(input,property,observable,postEventFn){var eventType=getEventForInputType(input);function eventHandler(){var isNum=property=="value"&&input.type=="number";observable.setValue(isNum?input.valueAsNumber:input[property]);observable.discardChanges();(postEventFn||noop)(input);Platform.performMicrotaskCheckpoint()}input.addEventListener(eventType,eventHandler);return{close:function(){input.removeEventListener(eventType,eventHandler);observable.close()},observable_:observable}}function booleanSanitize(value){return Boolean(value)}function getAssociatedRadioButtons(element){if(element.form){return filter(element.form.elements,function(el){return el!=element&&el.tagName=="INPUT"&&el.type=="radio"&&el.name==element.name})}else{var treeScope=getTreeScope(element);if(!treeScope)return[];var radios=treeScope.querySelectorAll('input[type="radio"][name="'+element.name+'"]');return filter(radios,function(el){return el!=element&&!el.form})}}function checkedPostEvent(input){if(input.tagName==="INPUT"&&input.type==="radio"){getAssociatedRadioButtons(input).forEach(function(radio){var checkedBinding=radio.bindings_.checked;if(checkedBinding){checkedBinding.observable_.setValue(false)}})}}HTMLInputElement.prototype.bind=function(name,value,oneTime){if(name!=="value"&&name!=="checked")return HTMLElement.prototype.bind.call(this,name,value,oneTime);this.removeAttribute(name);var sanitizeFn=name=="checked"?booleanSanitize:sanitizeValue;var postEventFn=name=="checked"?checkedPostEvent:noop;if(oneTime)return updateInput(this,name,value,sanitizeFn);var observable=value;var binding=bindInputEvent(this,name,observable,postEventFn);updateInput(this,name,observable.open(inputBinding(this,name,sanitizeFn)),sanitizeFn);return updateBindings(this,name,binding)};HTMLTextAreaElement.prototype.bind=function(name,value,oneTime){if(name!=="value")return HTMLElement.prototype.bind.call(this,name,value,oneTime);this.removeAttribute("value");if(oneTime)return updateInput(this,"value",value);var observable=value;var binding=bindInputEvent(this,"value",observable);updateInput(this,"value",observable.open(inputBinding(this,"value",sanitizeValue)));return maybeUpdateBindings(this,name,binding)};function updateOption(option,value){var parentNode=option.parentNode;var select;var selectBinding;var oldValue;if(parentNode instanceof HTMLSelectElement&&parentNode.bindings_&&parentNode.bindings_.value){select=parentNode;selectBinding=select.bindings_.value;oldValue=select.value}option.value=sanitizeValue(value);if(select&&select.value!=oldValue){selectBinding.observable_.setValue(select.value);selectBinding.observable_.discardChanges();Platform.performMicrotaskCheckpoint()}}function optionBinding(option){return function(value){updateOption(option,value)}}HTMLOptionElement.prototype.bind=function(name,value,oneTime){if(name!=="value")return HTMLElement.prototype.bind.call(this,name,value,oneTime);this.removeAttribute("value");if(oneTime)return updateOption(this,value);var observable=value;var binding=bindInputEvent(this,"value",observable);updateOption(this,observable.open(optionBinding(this)));return maybeUpdateBindings(this,name,binding)};HTMLSelectElement.prototype.bind=function(name,value,oneTime){if(name==="selectedindex")name="selectedIndex";if(name!=="selectedIndex"&&name!=="value")return HTMLElement.prototype.bind.call(this,name,value,oneTime);this.removeAttribute(name);if(oneTime)return updateInput(this,name,value);
var observable=value;var binding=bindInputEvent(this,name,observable);updateInput(this,name,observable.open(inputBinding(this,name)));return updateBindings(this,name,binding)}})(this);(function(global){"use strict";function assert(v){if(!v)throw new Error("Assertion failed")}var forEach=Array.prototype.forEach.call.bind(Array.prototype.forEach);function getFragmentRoot(node){var p;while(p=node.parentNode){node=p}return node}function searchRefId(node,id){if(!id)return;var ref;var selector="#"+id;while(!ref){node=getFragmentRoot(node);if(node.protoContent_)ref=node.protoContent_.querySelector(selector);else if(node.getElementById)ref=node.getElementById(id);if(ref||!node.templateCreator_)break;node=node.templateCreator_}return ref}function getInstanceRoot(node){while(node.parentNode){node=node.parentNode}return node.templateCreator_?node:null}var Map;if(global.Map&&typeof global.Map.prototype.forEach==="function"){Map=global.Map}else{Map=function(){this.keys=[];this.values=[]};Map.prototype={set:function(key,value){var index=this.keys.indexOf(key);if(index<0){this.keys.push(key);this.values.push(value)}else{this.values[index]=value}},get:function(key){var index=this.keys.indexOf(key);if(index<0)return;return this.values[index]},"delete":function(key,value){var index=this.keys.indexOf(key);if(index<0)return false;this.keys.splice(index,1);this.values.splice(index,1);return true},forEach:function(f,opt_this){for(var i=0;i<this.keys.length;i++)f.call(opt_this||this,this.values[i],this.keys[i],this)}}}var createObject="__proto__"in{}?function(obj){return obj}:function(obj){var proto=obj.__proto__;if(!proto)return obj;var newObject=Object.create(proto);Object.getOwnPropertyNames(obj).forEach(function(name){Object.defineProperty(newObject,name,Object.getOwnPropertyDescriptor(obj,name))});return newObject};if(typeof document.contains!="function"){Document.prototype.contains=function(node){if(node===this||node.parentNode===this)return true;return this.documentElement.contains(node)}}var BIND="bind";var REPEAT="repeat";var IF="if";var templateAttributeDirectives={template:true,repeat:true,bind:true,ref:true,"if":true};var semanticTemplateElements={THEAD:true,TBODY:true,TFOOT:true,TH:true,TR:true,TD:true,COLGROUP:true,COL:true,CAPTION:true,OPTION:true,OPTGROUP:true};var hasTemplateElement=typeof HTMLTemplateElement!=="undefined";if(hasTemplateElement){(function(){var t=document.createElement("template");var d=t.content.ownerDocument;var html=d.appendChild(d.createElement("html"));var head=html.appendChild(d.createElement("head"));var base=d.createElement("base");base.href=document.baseURI;head.appendChild(base)})()}var allTemplatesSelectors="template, "+Object.keys(semanticTemplateElements).map(function(tagName){return tagName.toLowerCase()+"[template]"}).join(", ");function isSVGTemplate(el){return el.tagName=="template"&&el.namespaceURI=="http://www.w3.org/2000/svg"}function isHTMLTemplate(el){return el.tagName=="TEMPLATE"&&el.namespaceURI=="http://www.w3.org/1999/xhtml"}function isAttributeTemplate(el){return Boolean(semanticTemplateElements[el.tagName]&&el.hasAttribute("template"))}function isTemplate(el){if(el.isTemplate_===undefined)el.isTemplate_=el.tagName=="TEMPLATE"||isAttributeTemplate(el);return el.isTemplate_}document.addEventListener("DOMContentLoaded",function(e){bootstrapTemplatesRecursivelyFrom(document);Platform.performMicrotaskCheckpoint()},false);function forAllTemplatesFrom(node,fn){var subTemplates=node.querySelectorAll(allTemplatesSelectors);if(isTemplate(node))fn(node);forEach(subTemplates,fn)}function bootstrapTemplatesRecursivelyFrom(node){function bootstrap(template){if(!HTMLTemplateElement.decorate(template))bootstrapTemplatesRecursivelyFrom(template.content)}forAllTemplatesFrom(node,bootstrap)}if(!hasTemplateElement){global.HTMLTemplateElement=function(){throw TypeError("Illegal constructor")}}var hasProto="__proto__"in{};function mixin(to,from){Object.getOwnPropertyNames(from).forEach(function(name){Object.defineProperty(to,name,Object.getOwnPropertyDescriptor(from,name))})}function getOrCreateTemplateContentsOwner(template){var doc=template.ownerDocument;if(!doc.defaultView)return doc;var d=doc.templateContentsOwner_;if(!d){d=doc.implementation.createHTMLDocument("");while(d.lastChild){d.removeChild(d.lastChild)}doc.templateContentsOwner_=d}return d}function getTemplateStagingDocument(template){if(!template.stagingDocument_){var owner=template.ownerDocument;if(!owner.stagingDocument_){owner.stagingDocument_=owner.implementation.createHTMLDocument("");owner.stagingDocument_.isStagingDocument=true;var base=owner.stagingDocument_.createElement("base");base.href=document.baseURI;owner.stagingDocument_.head.appendChild(base);owner.stagingDocument_.stagingDocument_=owner.stagingDocument_}template.stagingDocument_=owner.stagingDocument_}return template.stagingDocument_}function extractTemplateFromAttributeTemplate(el){var template=el.ownerDocument.createElement("template");el.parentNode.insertBefore(template,el);var attribs=el.attributes;var count=attribs.length;while(count-->0){var attrib=attribs[count];if(templateAttributeDirectives[attrib.name]){if(attrib.name!=="template")template.setAttribute(attrib.name,attrib.value);el.removeAttribute(attrib.name)}}return template}function extractTemplateFromSVGTemplate(el){var template=el.ownerDocument.createElement("template");el.parentNode.insertBefore(template,el);var attribs=el.attributes;var count=attribs.length;while(count-->0){var attrib=attribs[count];template.setAttribute(attrib.name,attrib.value);el.removeAttribute(attrib.name)}el.parentNode.removeChild(el);return template}function liftNonNativeTemplateChildrenIntoContent(template,el,useRoot){var content=template.content;if(useRoot){content.appendChild(el);return}var child;while(child=el.firstChild){content.appendChild(child)}}var templateObserver;if(typeof MutationObserver=="function"){templateObserver=new MutationObserver(function(records){for(var i=0;i<records.length;i++){records[i].target.refChanged_()}})}HTMLTemplateElement.decorate=function(el,opt_instanceRef){if(el.templateIsDecorated_)return false;var templateElement=el;templateElement.templateIsDecorated_=true;var isNativeHTMLTemplate=isHTMLTemplate(templateElement)&&hasTemplateElement;var bootstrapContents=isNativeHTMLTemplate;var liftContents=!isNativeHTMLTemplate;var liftRoot=false;if(!isNativeHTMLTemplate){if(isAttributeTemplate(templateElement)){assert(!opt_instanceRef);templateElement=extractTemplateFromAttributeTemplate(el);templateElement.templateIsDecorated_=true;isNativeHTMLTemplate=hasTemplateElement;liftRoot=true}else if(isSVGTemplate(templateElement)){templateElement=extractTemplateFromSVGTemplate(el);templateElement.templateIsDecorated_=true;isNativeHTMLTemplate=hasTemplateElement}}if(!isNativeHTMLTemplate){fixTemplateElementPrototype(templateElement);var doc=getOrCreateTemplateContentsOwner(templateElement);templateElement.content_=doc.createDocumentFragment()}if(opt_instanceRef){templateElement.instanceRef_=opt_instanceRef}else if(liftContents){liftNonNativeTemplateChildrenIntoContent(templateElement,el,liftRoot)}else if(bootstrapContents){bootstrapTemplatesRecursivelyFrom(templateElement.content)}return true};HTMLTemplateElement.bootstrap=bootstrapTemplatesRecursivelyFrom;var htmlElement=global.HTMLUnknownElement||HTMLElement;var contentDescriptor={get:function(){return this.content_},enumerable:true,configurable:true};if(!hasTemplateElement){HTMLTemplateElement.prototype=Object.create(htmlElement.prototype);Object.defineProperty(HTMLTemplateElement.prototype,"content",contentDescriptor)}function fixTemplateElementPrototype(el){if(hasProto)el.__proto__=HTMLTemplateElement.prototype;else mixin(el,HTMLTemplateElement.prototype)}function ensureSetModelScheduled(template){if(!template.setModelFn_){template.setModelFn_=function(){template.setModelFnScheduled_=false;var map=getBindings(template,template.delegate_&&template.delegate_.prepareBinding);processBindings(template,map,template.model_)}}if(!template.setModelFnScheduled_){template.setModelFnScheduled_=true;Observer.runEOM_(template.setModelFn_)}}mixin(HTMLTemplateElement.prototype,{bind:function(name,value,oneTime){if(name!="ref")return Element.prototype.bind.call(this,name,value,oneTime);var self=this;var ref=oneTime?value:value.open(function(ref){self.setAttribute("ref",ref);self.refChanged_()});this.setAttribute("ref",ref);this.refChanged_();if(oneTime)return;if(!this.bindings_){this.bindings_={ref:value}}else{this.bindings_.ref=value}return value},processBindingDirectives_:function(directives){if(this.iterator_)this.iterator_.closeDeps();if(!directives.if&&!directives.bind&&!directives.repeat){if(this.iterator_){this.iterator_.close();this.iterator_=undefined}return}if(!this.iterator_){this.iterator_=new TemplateIterator(this)}this.iterator_.updateDependencies(directives,this.model_);if(templateObserver){templateObserver.observe(this,{attributes:true,attributeFilter:["ref"]})}return this.iterator_},createInstance:function(model,bindingDelegate,delegate_){if(bindingDelegate)delegate_=this.newDelegate_(bindingDelegate);else if(!delegate_)delegate_=this.delegate_;if(!this.refContent_)this.refContent_=this.ref_.content;var content=this.refContent_;if(content.firstChild===null)return emptyInstance;var map=getInstanceBindingMap(content,delegate_);var stagingDocument=getTemplateStagingDocument(this);var instance=stagingDocument.createDocumentFragment();instance.templateCreator_=this;instance.protoContent_=content;instance.bindings_=[];instance.terminator_=null;var instanceRecord=instance.templateInstance_={firstNode:null,lastNode:null,model:model};var i=0;var collectTerminator=false;for(var child=content.firstChild;child;child=child.nextSibling){if(child.nextSibling===null)collectTerminator=true;var clone=cloneAndBindInstance(child,instance,stagingDocument,map.children[i++],model,delegate_,instance.bindings_);clone.templateInstance_=instanceRecord;if(collectTerminator)instance.terminator_=clone}instanceRecord.firstNode=instance.firstChild;instanceRecord.lastNode=instance.lastChild;instance.templateCreator_=undefined;instance.protoContent_=undefined;return instance},get model(){return this.model_},set model(model){this.model_=model;ensureSetModelScheduled(this)},get bindingDelegate(){return this.delegate_&&this.delegate_.raw},refChanged_:function(){if(!this.iterator_||this.refContent_===this.ref_.content)return;this.refContent_=undefined;this.iterator_.valueChanged();this.iterator_.updateIteratedValue(this.iterator_.getUpdatedValue())},clear:function(){this.model_=undefined;this.delegate_=undefined;if(this.bindings_&&this.bindings_.ref)this.bindings_.ref.close();this.refContent_=undefined;if(!this.iterator_)return;this.iterator_.valueChanged();this.iterator_.close();this.iterator_=undefined},setDelegate_:function(delegate){this.delegate_=delegate;this.bindingMap_=undefined;if(this.iterator_){this.iterator_.instancePositionChangedFn_=undefined;this.iterator_.instanceModelFn_=undefined}},newDelegate_:function(bindingDelegate){if(!bindingDelegate)return;function delegateFn(name){var fn=bindingDelegate&&bindingDelegate[name];if(typeof fn!="function")return;return function(){return fn.apply(bindingDelegate,arguments)}}return{bindingMaps:{},raw:bindingDelegate,prepareBinding:delegateFn("prepareBinding"),prepareInstanceModel:delegateFn("prepareInstanceModel"),prepareInstancePositionChanged:delegateFn("prepareInstancePositionChanged")}},set bindingDelegate(bindingDelegate){if(this.delegate_){throw Error("Template must be cleared before a new bindingDelegate "+"can be assigned")}this.setDelegate_(this.newDelegate_(bindingDelegate))},get ref_(){var ref=searchRefId(this,this.getAttribute("ref"));if(!ref)ref=this.instanceRef_;if(!ref)return this;var nextRef=ref.ref_;return nextRef?nextRef:ref}});function parseMustaches(s,name,node,prepareBindingFn){if(!s||!s.length)return;var tokens;var length=s.length;var startIndex=0,lastIndex=0,endIndex=0;var onlyOneTime=true;while(lastIndex<length){var startIndex=s.indexOf("{{",lastIndex);var oneTimeStart=s.indexOf("[[",lastIndex);var oneTime=false;var terminator="}}";if(oneTimeStart>=0&&(startIndex<0||oneTimeStart<startIndex)){startIndex=oneTimeStart;oneTime=true;terminator="]]"}endIndex=startIndex<0?-1:s.indexOf(terminator,startIndex+2);if(endIndex<0){if(!tokens)return;tokens.push(s.slice(lastIndex));break}tokens=tokens||[];tokens.push(s.slice(lastIndex,startIndex));var pathString=s.slice(startIndex+2,endIndex).trim();tokens.push(oneTime);onlyOneTime=onlyOneTime&&oneTime;var delegateFn=prepareBindingFn&&prepareBindingFn(pathString,name,node);if(delegateFn==null){tokens.push(Path.get(pathString))}else{tokens.push(null)}tokens.push(delegateFn);lastIndex=endIndex+2}if(lastIndex===length)tokens.push("");tokens.hasOnePath=tokens.length===5;tokens.isSimplePath=tokens.hasOnePath&&tokens[0]==""&&tokens[4]=="";tokens.onlyOneTime=onlyOneTime;tokens.combinator=function(values){var newValue=tokens[0];for(var i=1;i<tokens.length;i+=4){var value=tokens.hasOnePath?values:values[(i-1)/4];if(value!==undefined)newValue+=value;newValue+=tokens[i+3]}return newValue};return tokens}function processOneTimeBinding(name,tokens,node,model){if(tokens.hasOnePath){var delegateFn=tokens[3];var value=delegateFn?delegateFn(model,node,true):tokens[2].getValueFrom(model);return tokens.isSimplePath?value:tokens.combinator(value)}var values=[];for(var i=1;i<tokens.length;i+=4){var delegateFn=tokens[i+2];values[(i-1)/4]=delegateFn?delegateFn(model,node):tokens[i+1].getValueFrom(model)}return tokens.combinator(values)}function processSinglePathBinding(name,tokens,node,model){var delegateFn=tokens[3];var observer=delegateFn?delegateFn(model,node,false):new PathObserver(model,tokens[2]);return tokens.isSimplePath?observer:new ObserverTransform(observer,tokens.combinator)}function processBinding(name,tokens,node,model){if(tokens.onlyOneTime)return processOneTimeBinding(name,tokens,node,model);if(tokens.hasOnePath)return processSinglePathBinding(name,tokens,node,model);var observer=new CompoundObserver;for(var i=1;i<tokens.length;i+=4){var oneTime=tokens[i];var delegateFn=tokens[i+2];if(delegateFn){var value=delegateFn(model,node,oneTime);if(oneTime)observer.addPath(value);else observer.addObserver(value);continue}var path=tokens[i+1];if(oneTime)observer.addPath(path.getValueFrom(model));else observer.addPath(model,path)}return new ObserverTransform(observer,tokens.combinator)}function processBindings(node,bindings,model,instanceBindings){for(var i=0;i<bindings.length;i+=2){var name=bindings[i];var tokens=bindings[i+1];var value=processBinding(name,tokens,node,model);var binding=node.bind(name,value,tokens.onlyOneTime);if(binding&&instanceBindings)instanceBindings.push(binding)}node.bindFinished();if(!bindings.isTemplate)return;node.model_=model;var iter=node.processBindingDirectives_(bindings);if(instanceBindings&&iter)instanceBindings.push(iter)}function parseWithDefault(el,name,prepareBindingFn){var v=el.getAttribute(name);return parseMustaches(v==""?"{{}}":v,name,el,prepareBindingFn)}function parseAttributeBindings(element,prepareBindingFn){assert(element);var bindings=[];var ifFound=false;var bindFound=false;for(var i=0;i<element.attributes.length;i++){var attr=element.attributes[i];var name=attr.name;var value=attr.value;while(name[0]==="_"){name=name.substring(1)}if(isTemplate(element)&&(name===IF||name===BIND||name===REPEAT)){continue}var tokens=parseMustaches(value,name,element,prepareBindingFn);if(!tokens)continue;bindings.push(name,tokens)}if(isTemplate(element)){bindings.isTemplate=true;bindings.if=parseWithDefault(element,IF,prepareBindingFn);bindings.bind=parseWithDefault(element,BIND,prepareBindingFn);bindings.repeat=parseWithDefault(element,REPEAT,prepareBindingFn);if(bindings.if&&!bindings.bind&&!bindings.repeat)bindings.bind=parseMustaches("{{}}",BIND,element,prepareBindingFn)}return bindings}function getBindings(node,prepareBindingFn){if(node.nodeType===Node.ELEMENT_NODE)return parseAttributeBindings(node,prepareBindingFn);if(node.nodeType===Node.TEXT_NODE){var tokens=parseMustaches(node.data,"textContent",node,prepareBindingFn);if(tokens)return["textContent",tokens]}return[]}function cloneAndBindInstance(node,parent,stagingDocument,bindings,model,delegate,instanceBindings,instanceRecord){var clone=parent.appendChild(stagingDocument.importNode(node,false));var i=0;for(var child=node.firstChild;child;child=child.nextSibling){cloneAndBindInstance(child,clone,stagingDocument,bindings.children[i++],model,delegate,instanceBindings)}if(bindings.isTemplate){HTMLTemplateElement.decorate(clone,node);if(delegate)clone.setDelegate_(delegate)}processBindings(clone,bindings,model,instanceBindings);return clone}function createInstanceBindingMap(node,prepareBindingFn){var map=getBindings(node,prepareBindingFn);map.children={};var index=0;for(var child=node.firstChild;child;child=child.nextSibling){map.children[index++]=createInstanceBindingMap(child,prepareBindingFn)}return map}var contentUidCounter=1;function getContentUid(content){var id=content.id_;if(!id)id=content.id_=contentUidCounter++;return id}function getInstanceBindingMap(content,delegate_){var contentId=getContentUid(content);if(delegate_){var map=delegate_.bindingMaps[contentId];if(!map){map=delegate_.bindingMaps[contentId]=createInstanceBindingMap(content,delegate_.prepareBinding)||[]}return map}var map=content.bindingMap_;if(!map){map=content.bindingMap_=createInstanceBindingMap(content,undefined)||[]}return map}Object.defineProperty(Node.prototype,"templateInstance",{get:function(){var instance=this.templateInstance_;return instance?instance:this.parentNode?this.parentNode.templateInstance:undefined}});var emptyInstance=document.createDocumentFragment();emptyInstance.bindings_=[];emptyInstance.terminator_=null;function TemplateIterator(templateElement){this.closed=false;this.templateElement_=templateElement;this.instances=[];this.deps=undefined;this.iteratedValue=[];this.presentValue=undefined;this.arrayObserver=undefined}TemplateIterator.prototype={closeDeps:function(){var deps=this.deps;if(deps){if(deps.ifOneTime===false)deps.ifValue.close();if(deps.oneTime===false)deps.value.close()}},updateDependencies:function(directives,model){this.closeDeps();var deps=this.deps={};var template=this.templateElement_;var ifValue=true;if(directives.if){deps.hasIf=true;deps.ifOneTime=directives.if.onlyOneTime;deps.ifValue=processBinding(IF,directives.if,template,model);ifValue=deps.ifValue;if(deps.ifOneTime&&!ifValue){this.valueChanged();return}if(!deps.ifOneTime)ifValue=ifValue.open(this.updateIfValue,this)}if(directives.repeat){deps.repeat=true;deps.oneTime=directives.repeat.onlyOneTime;deps.value=processBinding(REPEAT,directives.repeat,template,model)}else{deps.repeat=false;deps.oneTime=directives.bind.onlyOneTime;deps.value=processBinding(BIND,directives.bind,template,model)}var value=deps.value;if(!deps.oneTime)value=value.open(this.updateIteratedValue,this);if(!ifValue){this.valueChanged();return}this.updateValue(value)},getUpdatedValue:function(){var value=this.deps.value;if(!this.deps.oneTime)value=value.discardChanges();return value},updateIfValue:function(ifValue){if(!ifValue){this.valueChanged();return}this.updateValue(this.getUpdatedValue())},updateIteratedValue:function(value){if(this.deps.hasIf){var ifValue=this.deps.ifValue;if(!this.deps.ifOneTime)ifValue=ifValue.discardChanges();if(!ifValue){this.valueChanged();return}}this.updateValue(value)},updateValue:function(value){if(!this.deps.repeat)value=[value];var observe=this.deps.repeat&&!this.deps.oneTime&&Array.isArray(value);this.valueChanged(value,observe)},valueChanged:function(value,observeValue){if(!Array.isArray(value))value=[];if(value===this.iteratedValue)return;this.unobserve();this.presentValue=value;if(observeValue){this.arrayObserver=new ArrayObserver(this.presentValue);this.arrayObserver.open(this.handleSplices,this)}this.handleSplices(ArrayObserver.calculateSplices(this.presentValue,this.iteratedValue))},getLastInstanceNode:function(index){if(index==-1)return this.templateElement_;var instance=this.instances[index];var terminator=instance.terminator_;if(!terminator)return this.getLastInstanceNode(index-1);if(terminator.nodeType!==Node.ELEMENT_NODE||this.templateElement_===terminator){return terminator}var subtemplateIterator=terminator.iterator_;if(!subtemplateIterator)return terminator;return subtemplateIterator.getLastTemplateNode()},getLastTemplateNode:function(){return this.getLastInstanceNode(this.instances.length-1)},insertInstanceAt:function(index,fragment){var previousInstanceLast=this.getLastInstanceNode(index-1);var parent=this.templateElement_.parentNode;this.instances.splice(index,0,fragment);parent.insertBefore(fragment,previousInstanceLast.nextSibling)},extractInstanceAt:function(index){var previousInstanceLast=this.getLastInstanceNode(index-1);var lastNode=this.getLastInstanceNode(index);var parent=this.templateElement_.parentNode;var instance=this.instances.splice(index,1)[0];while(lastNode!==previousInstanceLast){var node=previousInstanceLast.nextSibling;if(node==lastNode)lastNode=previousInstanceLast;instance.appendChild(parent.removeChild(node))}return instance},getDelegateFn:function(fn){fn=fn&&fn(this.templateElement_);return typeof fn==="function"?fn:null},handleSplices:function(splices){if(this.closed||!splices.length)return;var template=this.templateElement_;if(!template.parentNode){this.close();return}ArrayObserver.applySplices(this.iteratedValue,this.presentValue,splices);var delegate=template.delegate_;if(this.instanceModelFn_===undefined){this.instanceModelFn_=this.getDelegateFn(delegate&&delegate.prepareInstanceModel)}if(this.instancePositionChangedFn_===undefined){this.instancePositionChangedFn_=this.getDelegateFn(delegate&&delegate.prepareInstancePositionChanged)}var instanceCache=new Map;var removeDelta=0;for(var i=0;i<splices.length;i++){var splice=splices[i];var removed=splice.removed;for(var j=0;j<removed.length;j++){var model=removed[j];var instance=this.extractInstanceAt(splice.index+removeDelta);if(instance!==emptyInstance){instanceCache.set(model,instance)}}removeDelta-=splice.addedCount}for(var i=0;i<splices.length;i++){var splice=splices[i];var addIndex=splice.index;for(;addIndex<splice.index+splice.addedCount;addIndex++){var model=this.iteratedValue[addIndex];var instance=instanceCache.get(model);if(instance){instanceCache.delete(model)}else{if(this.instanceModelFn_){model=this.instanceModelFn_(model)}if(model===undefined){instance=emptyInstance}else{instance=template.createInstance(model,undefined,delegate)}}this.insertInstanceAt(addIndex,instance)}}instanceCache.forEach(function(instance){this.closeInstanceBindings(instance)},this);if(this.instancePositionChangedFn_)this.reportInstancesMoved(splices)},reportInstanceMoved:function(index){var instance=this.instances[index];if(instance===emptyInstance)return;this.instancePositionChangedFn_(instance.templateInstance_,index)},reportInstancesMoved:function(splices){var index=0;var offset=0;for(var i=0;i<splices.length;i++){var splice=splices[i];if(offset!=0){while(index<splice.index){this.reportInstanceMoved(index);index++}}else{index=splice.index}while(index<splice.index+splice.addedCount){this.reportInstanceMoved(index);index++}offset+=splice.addedCount-splice.removed.length}if(offset==0)return;var length=this.instances.length;while(index<length){this.reportInstanceMoved(index);index++}},closeInstanceBindings:function(instance){var bindings=instance.bindings_;for(var i=0;i<bindings.length;i++){bindings[i].close()}},unobserve:function(){if(!this.arrayObserver)return;this.arrayObserver.close();this.arrayObserver=undefined},close:function(){if(this.closed)return;this.unobserve();for(var i=0;i<this.instances.length;i++){this.closeInstanceBindings(this.instances[i])}this.instances.length=0;this.closeDeps();this.templateElement_.iterator_=undefined;this.closed=true}};HTMLTemplateElement.forAllTemplatesFrom_=forAllTemplatesFrom})(this);(function(scope){"use strict";var hasWorkingUrl=false;if(!scope.forceJURL){try{var u=new URL("b","http://a");u.pathname="c%20d";hasWorkingUrl=u.href==="http://a/c%20d"}catch(e){}}if(hasWorkingUrl)return;var relative=Object.create(null);relative["ftp"]=21;relative["file"]=0;relative["gopher"]=70;relative["http"]=80;relative["https"]=443;relative["ws"]=80;relative["wss"]=443;var relativePathDotMapping=Object.create(null);relativePathDotMapping["%2e"]=".";relativePathDotMapping[".%2e"]="..";relativePathDotMapping["%2e."]="..";relativePathDotMapping["%2e%2e"]="..";function isRelativeScheme(scheme){return relative[scheme]!==undefined}function invalid(){clear.call(this);this._isInvalid=true}function IDNAToASCII(h){if(""==h){invalid.call(this)}return h.toLowerCase()}function percentEscape(c){var unicode=c.charCodeAt(0);if(unicode>32&&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){query="?";state="query"}else if("#"==c){this._fragment="#";state="fragment"}else{if(EOF!=c&&" "!=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;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="?";state="query"}else if("#"==c){this._host=base._host;this._port=base._port;this._path=base._path.slice();this._query=base._query;this._fragment="#";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._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}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;i<buffer.length;i++){var cp=buffer[i];if(" "==cp||"\n"==cp||"\r"==cp){err("Invalid whitespace in authority.");continue}if(":"==cp&&null===this._password){this._password="";continue}var tempC=percentEscape(cp);null!==this._password?this._password+=tempC:this._username+=tempC}buffer=""}else if(EOF==c||"/"==c||"\\"==c||"?"==c||"#"==c){cursor-=buffer.length;buffer="";state="host";continue}else{buffer+=c}break;case"file host":if(EOF==c||"/"==c||"\\"==c||"?"==c||"#"==c){if(buffer.length==2&&ALPHA.test(buffer[0])&&(buffer[1]==":"||buffer[1]=="|")){state="relative path"}else if(buffer.length==0){state="relative path start"}else{this._host=IDNAToASCII.call(this,buffer);buffer="";state="relative path start"}continue}else if(" "==c||"\n"==c||"\r"==c){err("Invalid whitespace in file host.")}else{buffer+=c}break;case"host":case"hostname":if(":"==c&&!seenBracket){this._host=IDNAToASCII.call(this,buffer);buffer="";state="port";if("hostname"==stateOverride){break loop}}else if(EOF==c||"/"==c||"\\"==c||"?"==c||"#"==c){this._host=IDNAToASCII.call(this,buffer);buffer="";state="relative path start";if(stateOverride){break loop}continue}else if(" "!=c&&"\n"!=c&&"\r"!=c){if("["==c){seenBracket=true}else if("]"==c){seenBracket=false}buffer+=c}else{err("Invalid code point in host/hostname: "+c)}break;case"port":if(/[0-9]/.test(c)){buffer+=c}else if(EOF==c||"/"==c||"\\"==c||"?"==c||"#"==c||stateOverride){if(""!=buffer){var temp=parseInt(buffer,10);if(temp!=relative[this._scheme]){this._port=temp+""}buffer=""}if(stateOverride){break loop}state="relative path start";continue}else if(" "==c||"\n"==c||"\r"==c){err("Invalid code point in port: "+c)}else{invalid.call(this)}break;case"relative path start":if("\\"==c)err("'\\' not allowed in path.");state="relative path";if("/"!=c&&"\\"!=c){continue}break;case"relative path":if(EOF==c||"/"==c||"\\"==c||!stateOverride&&("?"==c||"#"==c)){if("\\"==c){err("\\ not allowed in relative path.")}var tmp;if(tmp=relativePathDotMapping[buffer.toLowerCase()]){buffer=tmp}if(".."==buffer){this._path.pop();if("/"!=c&&"\\"!=c){this._path.push("")}}else if("."==buffer&&"/"!=c&&"\\"!=c){this._path.push("")}else if("."!=buffer){if("file"==this._scheme&&this._path.length==0&&buffer.length==2&&ALPHA.test(buffer[0])&&buffer[1]=="|"){buffer=buffer[0]+":"}this._path.push(buffer)}buffer="";if("?"==c){this._query="?";state="query"}else if("#"==c){this._fragment="#";state="fragment"}}else if(" "!=c&&"\n"!=c&&"\r"!=c){buffer+=percentEscape(c)}break;case"query":if(!stateOverride&&"#"==c){this._fragment="#";state="fragment"}else if(EOF!=c&&" "!=c&&"\n"!=c&&"\r"!=c){this._query+=percentEscapeQuery(c)}break;case"fragment":if(EOF!=c&&" "!=c&&"\n"!=c&&"\r"!=c){this._fragment+=c}break}cursor++}}function clear(){this._scheme="";this._schemeData="";this._username="";this._password=null;this._host="";this._port="";this._path=[];this._query="";this._fragment="";this._isInvalid=false;this._isRelative=false}function jURL(url,base){if(base!==undefined&&!(base instanceof jURL))base=new jURL(String(base));this._url=url;clear.call(this);var input=url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g,"");parse.call(this,input,null,base)}jURL.prototype={get href(){if(this._isInvalid)return this._url;var authority="";if(""!=this._username||null!=this._password){authority=this._username+(null!=this._password?":"+this._password:"")+"@"}return this.protocol+(this._isRelative?"//"+authority+this.host:"")+this.pathname+this._query+this._fragment},set href(href){clear.call(this);parse.call(this,href)},get protocol(){return this._scheme+":"},set protocol(protocol){if(this._isInvalid)return;
parse.call(this,protocol+":","scheme start")},get host(){return this._isInvalid?"":this._port?this._host+":"+this._port:this._host},set host(host){if(this._isInvalid||!this._isRelative)return;parse.call(this,host,"host")},get hostname(){return this._host},set hostname(hostname){if(this._isInvalid||!this._isRelative)return;parse.call(this,hostname,"hostname")},get port(){return this._port},set port(port){if(this._isInvalid||!this._isRelative)return;parse.call(this,port,"port")},get pathname(){return this._isInvalid?"":this._isRelative?"/"+this._path.join("/"):this._schemeData},set pathname(pathname){if(this._isInvalid||!this._isRelative)return;this._path=[];parse.call(this,pathname,"relative path start")},get search(){return this._isInvalid||!this._query||"?"==this._query?"":this._query},set search(search){if(this._isInvalid||!this._isRelative)return;this._query="?";if("?"==search[0])search=search.slice(1);parse.call(this,search,"query")},get hash(){return this._isInvalid||!this._fragment||"#"==this._fragment?"":this._fragment},set hash(hash){if(this._isInvalid)return;this._fragment="#";if("#"==hash[0])hash=hash.slice(1);parse.call(this,hash,"fragment")},get origin(){var host;if(this._isInvalid||!this._scheme){return""}switch(this._scheme){case"data":case"file":case"javascript":case"mailto":return"null"}host=this.host;if(!host){return""}return this._scheme+"://"+host}};var OriginalURL=scope.URL;if(OriginalURL){jURL.createObjectURL=function(blob){return OriginalURL.createObjectURL.apply(OriginalURL,arguments)};jURL.revokeObjectURL=function(url){OriginalURL.revokeObjectURL(url)}}scope.URL=jURL})(this);(function(scope){var iterations=0;var callbacks=[];var twiddle=document.createTextNode("");function endOfMicrotask(callback){twiddle.textContent=iterations++;callbacks.push(callback)}function atEndOfMicrotask(){while(callbacks.length){callbacks.shift()()}}new(window.MutationObserver||JsMutationObserver)(atEndOfMicrotask).observe(twiddle,{characterData:true});scope.endOfMicrotask=endOfMicrotask;Platform.endOfMicrotask=endOfMicrotask})(Polymer);(function(scope){var endOfMicrotask=scope.endOfMicrotask;var log=window.WebComponents?WebComponents.flags.log:{};var style=document.createElement("style");style.textContent="template {display: none !important;} /* injected by platform.js */";var head=document.querySelector("head");head.insertBefore(style,head.firstChild);var flushing;function flush(){if(!flushing){flushing=true;endOfMicrotask(function(){flushing=false;log.data&&console.group("flush");Platform.performMicrotaskCheckpoint();log.data&&console.groupEnd()})}}if(!Observer.hasObjectObserve){var FLUSH_POLL_INTERVAL=125;window.addEventListener("WebComponentsReady",function(){flush();var visibilityHandler=function(){if(document.visibilityState==="hidden"){if(scope.flushPoll){clearInterval(scope.flushPoll)}}else{scope.flushPoll=setInterval(flush,FLUSH_POLL_INTERVAL)}};if(typeof document.visibilityState==="string"){document.addEventListener("visibilitychange",visibilityHandler)}visibilityHandler()})}else{flush=function(){}}if(window.CustomElements&&!CustomElements.useNative){var originalImportNode=Document.prototype.importNode;Document.prototype.importNode=function(node,deep){var imported=originalImportNode.call(this,node,deep);CustomElements.upgradeAll(imported);return imported}}scope.flush=flush;Platform.flush=flush})(window.Polymer);(function(scope){var urlResolver={resolveDom:function(root,url){url=url||baseUrl(root);this.resolveAttributes(root,url);this.resolveStyles(root,url);var templates=root.querySelectorAll("template");if(templates){for(var i=0,l=templates.length,t;i<l&&(t=templates[i]);i++){if(t.content){this.resolveDom(t.content,url)}}}},resolveTemplate:function(template){this.resolveDom(template.content,baseUrl(template))},resolveStyles:function(root,url){var styles=root.querySelectorAll("style");if(styles){for(var i=0,l=styles.length,s;i<l&&(s=styles[i]);i++){this.resolveStyle(s,url)}}},resolveStyle:function(style,url){url=url||baseUrl(style);style.textContent=this.resolveCssText(style.textContent,url)},resolveCssText:function(cssText,baseUrl,keepAbsolute){cssText=replaceUrlsInCssText(cssText,baseUrl,keepAbsolute,CSS_URL_REGEXP);return replaceUrlsInCssText(cssText,baseUrl,keepAbsolute,CSS_IMPORT_REGEXP)},resolveAttributes:function(root,url){if(root.hasAttributes&&root.hasAttributes()){this.resolveElementAttributes(root,url)}var nodes=root&&root.querySelectorAll(URL_ATTRS_SELECTOR);if(nodes){for(var i=0,l=nodes.length,n;i<l&&(n=nodes[i]);i++){this.resolveElementAttributes(n,url)}}},resolveElementAttributes:function(node,url){url=url||baseUrl(node);URL_ATTRS.forEach(function(v){var attr=node.attributes[v];var value=attr&&attr.value;var replacement;if(value&&value.search(URL_TEMPLATE_SEARCH)<0){if(v==="style"){replacement=replaceUrlsInCssText(value,url,false,CSS_URL_REGEXP)}else{replacement=resolveRelativeUrl(url,value)}attr.value=replacement}})}};var CSS_URL_REGEXP=/(url\()([^)]*)(\))/g;var CSS_IMPORT_REGEXP=/(@import[\s]+(?!url\())([^;]*)(;)/g;var URL_ATTRS=["href","src","action","style","url"];var URL_ATTRS_SELECTOR="["+URL_ATTRS.join("],[")+"]";var URL_TEMPLATE_SEARCH="{{.*}}";var URL_HASH="#";function baseUrl(node){var u=new URL(node.ownerDocument.baseURI);u.search="";u.hash="";return u}function replaceUrlsInCssText(cssText,baseUrl,keepAbsolute,regexp){return cssText.replace(regexp,function(m,pre,url,post){var urlPath=url.replace(/["']/g,"");urlPath=resolveRelativeUrl(baseUrl,urlPath,keepAbsolute);return pre+"'"+urlPath+"'"+post})}function resolveRelativeUrl(baseUrl,url,keepAbsolute){if(url&&url[0]==="/"){return url}if(url&&url[0]==="#"){return url}var u=new URL(url,baseUrl);return keepAbsolute?u.href:makeDocumentRelPath(u.href)}function makeDocumentRelPath(url){var root=baseUrl(document.documentElement);var u=new URL(url,root);if(u.host===root.host&&u.port===root.port&&u.protocol===root.protocol){return makeRelPath(root,u)}else{return url}}function makeRelPath(sourceUrl,targetUrl){var source=sourceUrl.pathname;var target=targetUrl.pathname;var s=source.split("/");var t=target.split("/");while(s.length&&s[0]===t[0]){s.shift();t.shift()}for(var i=0,l=s.length-1;i<l;i++){t.unshift("..")}var hash=targetUrl.href.slice(-1)===URL_HASH?URL_HASH:targetUrl.hash;return t.join("/")+targetUrl.search+hash}scope.urlResolver=urlResolver})(Polymer);(function(scope){var endOfMicrotask=Polymer.endOfMicrotask;function Loader(regex){this.cache=Object.create(null);this.map=Object.create(null);this.requests=0;this.regex=regex}Loader.prototype={extractUrls:function(text,base){var matches=[];var matched,u;while(matched=this.regex.exec(text)){u=new URL(matched[1],base);matches.push({matched:matched[0],url:u.href})}return matches},process:function(text,root,callback){var matches=this.extractUrls(text,root);var done=callback.bind(null,this.map);this.fetch(matches,done)},fetch:function(matches,callback){var inflight=matches.length;if(!inflight){return callback()}var done=function(){if(--inflight===0){callback()}};var m,req,url;for(var i=0;i<inflight;i++){m=matches[i];url=m.url;req=this.cache[url];if(!req){req=this.xhr(url);req.match=m;this.cache[url]=req}req.wait(done)}},handleXhr:function(request){var match=request.match;var url=match.url;var response=request.response||request.responseText||"";this.map[url]=response;this.fetch(this.extractUrls(response,url),request.resolve)},xhr:function(url){this.requests++;var request=new XMLHttpRequest;request.open("GET",url,true);request.send();request.onerror=request.onload=this.handleXhr.bind(this,request);request.pending=[];request.resolve=function(){var pending=request.pending;for(var i=0;i<pending.length;i++){pending[i]()}request.pending=null};request.wait=function(fn){if(request.pending){request.pending.push(fn)}else{endOfMicrotask(fn)}};return request}};scope.Loader=Loader})(Polymer);(function(scope){var urlResolver=scope.urlResolver;var Loader=scope.Loader;function StyleResolver(){this.loader=new Loader(this.regex)}StyleResolver.prototype={regex:/@import\s+(?:url)?["'\(]*([^'"\)]*)['"\)]*;/g,resolve:function(text,url,callback){var done=function(map){callback(this.flatten(text,url,map))}.bind(this);this.loader.process(text,url,done)},resolveNode:function(style,url,callback){var text=style.textContent;var done=function(text){style.textContent=text;callback(style)};this.resolve(text,url,done)},flatten:function(text,base,map){var matches=this.loader.extractUrls(text,base);var match,url,intermediate;for(var i=0;i<matches.length;i++){match=matches[i];url=match.url;intermediate=urlResolver.resolveCssText(map[url],url,true);intermediate=this.flatten(intermediate,base,map);text=text.replace(match.matched,intermediate)}return text},loadStyles:function(styles,base,callback){var loaded=0,l=styles.length;function loadedStyle(style){loaded++;if(loaded===l&&callback){callback()}}for(var i=0,s;i<l&&(s=styles[i]);i++){this.resolveNode(s,base,loadedStyle)}}};var styleResolver=new StyleResolver;scope.styleResolver=styleResolver})(Polymer);(function(scope){function extend(prototype,api){if(prototype&&api){Object.getOwnPropertyNames(api).forEach(function(n){var pd=Object.getOwnPropertyDescriptor(api,n);if(pd){Object.defineProperty(prototype,n,pd);if(typeof pd.value=="function"){pd.value.nom=n}}})}return prototype}function mixin(inObj){var obj=inObj||{};for(var i=1;i<arguments.length;i++){var p=arguments[i];try{for(var n in p){copyProperty(n,p,obj)}}catch(x){}}return obj}function copyProperty(inName,inSource,inTarget){var pd=getPropertyDescriptor(inSource,inName);Object.defineProperty(inTarget,inName,pd)}function getPropertyDescriptor(inObject,inName){if(inObject){var pd=Object.getOwnPropertyDescriptor(inObject,inName);return pd||getPropertyDescriptor(Object.getPrototypeOf(inObject),inName)}}scope.extend=extend;scope.mixin=mixin;Platform.mixin=mixin})(Polymer);(function(scope){var Job=function(inContext){this.context=inContext;this.boundComplete=this.complete.bind(this)};Job.prototype={go:function(callback,wait){this.callback=callback;var h;if(!wait){h=requestAnimationFrame(this.boundComplete);this.handle=function(){cancelAnimationFrame(h)}}else{h=setTimeout(this.boundComplete,wait);this.handle=function(){clearTimeout(h)}}},stop:function(){if(this.handle){this.handle();this.handle=null}},complete:function(){if(this.handle){this.stop();this.callback.call(this.context)}}};function job(job,callback,wait){if(job){job.stop()}else{job=new Job(this)}job.go(callback,wait);return job}scope.job=job})(Polymer);(function(scope){var registry={};HTMLElement.register=function(tag,prototype){registry[tag]=prototype};HTMLElement.getPrototypeForTag=function(tag){var prototype=!tag?HTMLElement.prototype:registry[tag];return prototype||Object.getPrototypeOf(document.createElement(tag))};var originalStopPropagation=Event.prototype.stopPropagation;Event.prototype.stopPropagation=function(){this.cancelBubble=true;originalStopPropagation.apply(this,arguments)};var add=DOMTokenList.prototype.add;var remove=DOMTokenList.prototype.remove;DOMTokenList.prototype.add=function(){for(var i=0;i<arguments.length;i++){add.call(this,arguments[i])}};DOMTokenList.prototype.remove=function(){for(var i=0;i<arguments.length;i++){remove.call(this,arguments[i])}};DOMTokenList.prototype.toggle=function(name,bool){if(arguments.length==1){bool=!this.contains(name)}bool?this.add(name):this.remove(name)};DOMTokenList.prototype.switch=function(oldName,newName){oldName&&this.remove(oldName);newName&&this.add(newName)};var ArraySlice=function(){return Array.prototype.slice.call(this)};var namedNodeMap=window.NamedNodeMap||window.MozNamedAttrMap||{};NodeList.prototype.array=ArraySlice;namedNodeMap.prototype.array=ArraySlice;HTMLCollection.prototype.array=ArraySlice;function createDOM(inTagOrNode,inHTML,inAttrs){var dom=typeof inTagOrNode=="string"?document.createElement(inTagOrNode):inTagOrNode.cloneNode(true);dom.innerHTML=inHTML;if(inAttrs){for(var n in inAttrs){dom.setAttribute(n,inAttrs[n])}}return dom}scope.createDOM=createDOM})(Polymer);(function(scope){function $super(arrayOfArgs){var caller=$super.caller;var nom=caller.nom;var _super=caller._super;if(!_super){if(!nom){nom=caller.nom=nameInThis.call(this,caller)}if(!nom){console.warn("called super() on a method not installed declaratively (has no .nom property)")}_super=memoizeSuper(caller,nom,getPrototypeOf(this))}var fn=_super[nom];if(fn){if(!fn._super){memoizeSuper(fn,nom,_super)}return fn.apply(this,arrayOfArgs||[])}}function nameInThis(value){var p=this.__proto__;while(p&&p!==HTMLElement.prototype){var n$=Object.getOwnPropertyNames(p);for(var i=0,l=n$.length,n;i<l&&(n=n$[i]);i++){var d=Object.getOwnPropertyDescriptor(p,n);if(typeof d.value==="function"&&d.value===value){return n}}p=p.__proto__}}function memoizeSuper(method,name,proto){var s=nextSuper(proto,name,method);if(s[name]){s[name].nom=name}return method._super=s}function nextSuper(proto,name,caller){while(proto){if(proto[name]!==caller&&proto[name]){return proto}proto=getPrototypeOf(proto)}return Object}function getPrototypeOf(prototype){return prototype.__proto__}function hintSuper(prototype){for(var n in prototype){var pd=Object.getOwnPropertyDescriptor(prototype,n);if(pd&&typeof pd.value==="function"){pd.value.nom=n}}}scope.super=$super})(Polymer);(function(scope){function noopHandler(value){return value}var typeHandlers={string:noopHandler,undefined:noopHandler,date:function(value){return new Date(Date.parse(value)||Date.now())},"boolean":function(value){if(value===""){return true}return value==="false"?false:!!value},number:function(value){var n=parseFloat(value);if(n===0){n=parseInt(value)}return isNaN(n)?value:n},object:function(value,currentValue){if(currentValue===null){return value}try{return JSON.parse(value.replace(/'/g,'"'))}catch(e){return value}},"function":function(value,currentValue){return currentValue}};function deserializeValue(value,currentValue){var inferredType=typeof currentValue;if(currentValue instanceof Date){inferredType="date"}return typeHandlers[inferredType](value,currentValue)}scope.deserializeValue=deserializeValue})(Polymer);(function(scope){var extend=scope.extend;var api={};api.declaration={};api.instance={};api.publish=function(apis,prototype){for(var n in apis){extend(prototype,apis[n])}};scope.api=api})(Polymer);(function(scope){var utils={async:function(method,args,timeout){Polymer.flush();args=args&&args.length?args:[args];var fn=function(){(this[method]||method).apply(this,args)}.bind(this);var handle=timeout?setTimeout(fn,timeout):requestAnimationFrame(fn);return timeout?handle:~handle},cancelAsync:function(handle){if(handle<0){cancelAnimationFrame(~handle)}else{clearTimeout(handle)}},fire:function(type,detail,onNode,bubbles,cancelable){var node=onNode||this;var detail=detail===null||detail===undefined?{}:detail;var event=new CustomEvent(type,{bubbles:bubbles!==undefined?bubbles:true,cancelable:cancelable!==undefined?cancelable:true,detail:detail});node.dispatchEvent(event);return event},asyncFire:function(){this.async("fire",arguments)},classFollows:function(anew,old,className){if(old){old.classList.remove(className)}if(anew){anew.classList.add(className)}},injectBoundHTML:function(html,element){var template=document.createElement("template");template.innerHTML=html;var fragment=this.instanceTemplate(template);if(element){element.textContent="";element.appendChild(fragment)}return fragment}};var nop=function(){};var nob={};utils.asyncMethod=utils.async;scope.api.instance.utils=utils;scope.nop=nop;scope.nob=nob})(Polymer);(function(scope){var log=window.WebComponents?WebComponents.flags.log:{};var EVENT_PREFIX="on-";var events={EVENT_PREFIX:EVENT_PREFIX,addHostListeners:function(){var events=this.eventDelegates;log.events&&Object.keys(events).length>0&&console.log("[%s] addHostListeners:",this.localName,events);for(var type in events){var methodName=events[type];PolymerGestures.addEventListener(this,type,this.element.getEventHandler(this,this,methodName))}},dispatchMethod:function(obj,method,args){if(obj){log.events&&console.group("[%s] dispatch [%s]",obj.localName,method);var fn=typeof method==="function"?method:obj[method];if(fn){fn[args?"apply":"call"](obj,args)}log.events&&console.groupEnd();Polymer.flush()}}};scope.api.instance.events=events;scope.addEventListener=function(node,eventType,handlerFn,capture){PolymerGestures.addEventListener(wrap(node),eventType,handlerFn,capture)};scope.removeEventListener=function(node,eventType,handlerFn,capture){PolymerGestures.removeEventListener(wrap(node),eventType,handlerFn,capture)}})(Polymer);(function(scope){var attributes={copyInstanceAttributes:function(){var a$=this._instanceAttributes;for(var k in a$){if(!this.hasAttribute(k)){this.setAttribute(k,a$[k])}}},takeAttributes:function(){if(this._publishLC){for(var i=0,a$=this.attributes,l=a$.length,a;(a=a$[i])&&i<l;i++){this.attributeToProperty(a.name,a.value)}}},attributeToProperty:function(name,value){var name=this.propertyForAttribute(name);if(name){if(value&&value.search(scope.bindPattern)>=0){return}var currentValue=this[name];var value=this.deserializeValue(value,currentValue);if(value!==currentValue){this[name]=value}}},propertyForAttribute:function(name){var match=this._publishLC&&this._publishLC[name];return match},deserializeValue:function(stringValue,currentValue){return scope.deserializeValue(stringValue,currentValue)},serializeValue:function(value,inferredType){if(inferredType==="boolean"){return value?"":undefined}else if(inferredType!=="object"&&inferredType!=="function"&&value!==undefined){return value}},reflectPropertyToAttribute:function(name){var inferredType=typeof this[name];var serializedValue=this.serializeValue(this[name],inferredType);if(serializedValue!==undefined){this.setAttribute(name,serializedValue)}else if(inferredType==="boolean"){this.removeAttribute(name)}}};scope.api.instance.attributes=attributes})(Polymer);(function(scope){var log=window.WebComponents?WebComponents.flags.log:{};var OBSERVE_SUFFIX="Changed";var empty=[];var updateRecord={object:undefined,type:"update",name:undefined,oldValue:undefined};var numberIsNaN=Number.isNaN||function(value){return typeof value==="number"&&isNaN(value)};function areSameValue(left,right){if(left===right)return left!==0||1/left===1/right;if(numberIsNaN(left)&&numberIsNaN(right))return true;return left!==left&&right!==right}function resolveBindingValue(oldValue,value){if(value===undefined&&oldValue===null){return value}return value===null||value===undefined?oldValue:value}var properties={createPropertyObserver:function(){var n$=this._observeNames;if(n$&&n$.length){var o=this._propertyObserver=new CompoundObserver(true);this.registerObserver(o);for(var i=0,l=n$.length,n;i<l&&(n=n$[i]);i++){o.addPath(this,n);this.observeArrayValue(n,this[n],null)}}},openPropertyObserver:function(){if(this._propertyObserver){this._propertyObserver.open(this.notifyPropertyChanges,this)}},notifyPropertyChanges:function(newValues,oldValues,paths){var name,method,called={};for(var i in oldValues){name=paths[2*i+1];method=this.observe[name];if(method){var ov=oldValues[i],nv=newValues[i];this.observeArrayValue(name,nv,ov);if(!called[method]){if(ov!==undefined&&ov!==null||nv!==undefined&&nv!==null){called[method]=true;this.invokeMethod(method,[ov,nv,arguments])}}}}},invokeMethod:function(method,args){var fn=this[method]||method;if(typeof fn==="function"){fn.apply(this,args)}},deliverChanges:function(){if(this._propertyObserver){this._propertyObserver.deliver()}},observeArrayValue:function(name,value,old){var callbackName=this.observe[name];if(callbackName){if(Array.isArray(old)){log.observe&&console.log("[%s] observeArrayValue: unregister observer [%s]",this.localName,name);this.closeNamedObserver(name+"__array")}if(Array.isArray(value)){log.observe&&console.log("[%s] observeArrayValue: register observer [%s]",this.localName,name,value);var observer=new ArrayObserver(value);observer.open(function(splices){this.invokeMethod(callbackName,[splices])},this);this.registerNamedObserver(name+"__array",observer)}}},emitPropertyChangeRecord:function(name,value,oldValue){var object=this;if(areSameValue(value,oldValue)){return}this._propertyChanged(name,value,oldValue);if(!Observer.hasObjectObserve){return}var notifier=this._objectNotifier;if(!notifier){notifier=this._objectNotifier=Object.getNotifier(this)}updateRecord.object=this;updateRecord.name=name;updateRecord.oldValue=oldValue;notifier.notify(updateRecord)},_propertyChanged:function(name,value,oldValue){if(this.reflect[name]){this.reflectPropertyToAttribute(name)}},bindProperty:function(property,observable,oneTime){if(oneTime){this[property]=observable;return}var computed=this.element.prototype.computed;if(computed&&computed[property]){var privateComputedBoundValue=property+"ComputedBoundObservable_";this[privateComputedBoundValue]=observable;return}return this.bindToAccessor(property,observable,resolveBindingValue)},bindToAccessor:function(name,observable,resolveFn){var privateName=name+"_";var privateObservable=name+"Observable_";var privateComputedBoundValue=name+"ComputedBoundObservable_";this[privateObservable]=observable;var oldValue=this[privateName];var self=this;function updateValue(value,oldValue){self[privateName]=value;var setObserveable=self[privateComputedBoundValue];if(setObserveable&&typeof setObserveable.setValue=="function"){setObserveable.setValue(value)}self.emitPropertyChangeRecord(name,value,oldValue)}var value=observable.open(updateValue);if(resolveFn&&!areSameValue(oldValue,value)){var resolvedValue=resolveFn(oldValue,value);if(!areSameValue(value,resolvedValue)){value=resolvedValue;if(observable.setValue){observable.setValue(value)}}}updateValue(value,oldValue);var observer={close:function(){observable.close();self[privateObservable]=undefined;self[privateComputedBoundValue]=undefined}};this.registerObserver(observer);return observer},createComputedProperties:function(){if(!this._computedNames){return}for(var i=0;i<this._computedNames.length;i++){var name=this._computedNames[i];var expressionText=this.computed[name];try{var expression=PolymerExpressions.getExpression(expressionText);var observable=expression.getBinding(this,this.element.syntax);this.bindToAccessor(name,observable)}catch(ex){console.error("Failed to create computed property",ex)}}},registerObserver:function(observer){if(!this._observers){this._observers=[observer];return}this._observers.push(observer)},closeObservers:function(){if(!this._observers){return}var observers=this._observers;for(var i=0;i<observers.length;i++){var observer=observers[i];if(observer&&typeof observer.close=="function"){observer.close()}}this._observers=[]},registerNamedObserver:function(name,observer){var o$=this._namedObservers||(this._namedObservers={});o$[name]=observer},closeNamedObserver:function(name){var o$=this._namedObservers;if(o$&&o$[name]){o$[name].close();o$[name]=null;return true}},closeNamedObservers:function(){if(this._namedObservers){for(var i in this._namedObservers){this.closeNamedObserver(i)}this._namedObservers={}}}};var LOG_OBSERVE="[%s] watching [%s]";var LOG_OBSERVED="[%s#%s] watch: [%s] now [%s] was [%s]";var LOG_CHANGED="[%s#%s] propertyChanged: [%s] now [%s] was [%s]";scope.api.instance.properties=properties})(Polymer);(function(scope){var log=window.WebComponents?WebComponents.flags.log:{};var mdv={instanceTemplate:function(template){HTMLTemplateElement.decorate(template);var syntax=this.syntax||!template.bindingDelegate&&this.element.syntax;var dom=template.createInstance(this,syntax);var observers=dom.bindings_;for(var i=0;i<observers.length;i++){this.registerObserver(observers[i])}return dom},bind:function(name,observable,oneTime){var property=this.propertyForAttribute(name);if(!property){return this.mixinSuper(arguments)}else{var observer=this.bindProperty(property,observable,oneTime);if(Platform.enableBindingsReflection&&observer){observer.path=observable.path_;this._recordBinding(property,observer)}if(this.reflect[property]){this.reflectPropertyToAttribute(property)}return observer}},_recordBinding:function(name,observer){this.bindings_=this.bindings_||{};this.bindings_[name]=observer},bindFinished:function(){this.makeElementReady()},asyncUnbindAll:function(){if(!this._unbound){log.unbind&&console.log("[%s] asyncUnbindAll",this.localName);this._unbindAllJob=this.job(this._unbindAllJob,this.unbindAll,0)}},unbindAll:function(){if(!this._unbound){this.closeObservers();this.closeNamedObservers();this._unbound=true}},cancelUnbindAll:function(){if(this._unbound){log.unbind&&console.warn("[%s] already unbound, cannot cancel unbindAll",this.localName);return}log.unbind&&console.log("[%s] cancelUnbindAll",this.localName);if(this._unbindAllJob){this._unbindAllJob=this._unbindAllJob.stop()}}};function unbindNodeTree(node){forNodeTree(node,_nodeUnbindAll)}function _nodeUnbindAll(node){node.unbindAll()}function forNodeTree(node,callback){if(node){callback(node);for(var child=node.firstChild;child;child=child.nextSibling){forNodeTree(child,callback)}}}var mustachePattern=/\{\{([^{}]*)}}/;scope.bindPattern=mustachePattern;scope.api.instance.mdv=mdv})(Polymer);(function(scope){var base={PolymerBase:true,job:function(job,callback,wait){if(typeof job==="string"){var n="___"+job;this[n]=Polymer.job.call(this,this[n],callback,wait)}else{return Polymer.job.call(this,job,callback,wait)}},"super":Polymer.super,created:function(){},ready:function(){},createdCallback:function(){if(this.templateInstance&&this.templateInstance.model){console.warn("Attributes on "+this.localName+" were data bound "+"prior to Polymer upgrading the element. This may result in "+"incorrect binding types.")}this.created();this.prepareElement();if(!this.ownerDocument.isStagingDocument){this.makeElementReady()}},prepareElement:function(){if(this._elementPrepared){console.warn("Element already prepared",this.localName);return}this._elementPrepared=true;this.shadowRoots={};this.createPropertyObserver();this.openPropertyObserver();this.copyInstanceAttributes();this.takeAttributes();this.addHostListeners()},makeElementReady:function(){if(this._readied){return}this._readied=true;this.createComputedProperties();this.parseDeclarations(this.__proto__);this.removeAttribute("unresolved");this.ready()},attributeChangedCallback:function(name,oldValue){if(name!=="class"&&name!=="style"){this.attributeToProperty(name,this.getAttribute(name))}if(this.attributeChanged){this.attributeChanged.apply(this,arguments)}},attachedCallback:function(){this.cancelUnbindAll();if(this.attached){this.attached()}if(!this.hasBeenAttached){this.hasBeenAttached=true;if(this.domReady){this.async("domReady")}}},detachedCallback:function(){if(!this.preventDispose){this.asyncUnbindAll()}if(this.detached){this.detached()}if(this.leftView){this.leftView()}},parseDeclarations:function(p){if(p&&p.element){this.parseDeclarations(p.__proto__);p.parseDeclaration.call(this,p.element)}},parseDeclaration:function(elementElement){var template=this.fetchTemplate(elementElement);if(template){var root=this.shadowFromTemplate(template);this.shadowRoots[elementElement.name]=root}},fetchTemplate:function(elementElement){return elementElement.querySelector("template")},shadowFromTemplate:function(template){if(template){var root=this.createShadowRoot();var dom=this.instanceTemplate(template);root.appendChild(dom);this.shadowRootReady(root,template);return root}},lightFromTemplate:function(template,refNode){if(template){this.eventController=this;var dom=this.instanceTemplate(template);if(refNode){this.insertBefore(dom,refNode)}else{this.appendChild(dom)}this.shadowRootReady(this);return dom}},shadowRootReady:function(root){this.marshalNodeReferences(root)},marshalNodeReferences:function(root){var $=this.$=this.$||{};if(root){var n$=root.querySelectorAll("[id]");for(var i=0,l=n$.length,n;i<l&&(n=n$[i]);i++){$[n.id]=n}}},onMutation:function(node,listener){var observer=new MutationObserver(function(mutations){listener.call(this,observer,mutations);observer.disconnect()}.bind(this));observer.observe(node,{childList:true,subtree:true})}};function isBase(object){return object.hasOwnProperty("PolymerBase")}function PolymerBase(){}PolymerBase.prototype=base;base.constructor=PolymerBase;scope.Base=PolymerBase;scope.isBase=isBase;scope.api.instance.base=base})(Polymer);(function(scope){var log=window.WebComponents?WebComponents.flags.log:{};var hasShadowDOMPolyfill=window.ShadowDOMPolyfill;var STYLE_SCOPE_ATTRIBUTE="element";var STYLE_CONTROLLER_SCOPE="controller";var styles={STYLE_SCOPE_ATTRIBUTE:STYLE_SCOPE_ATTRIBUTE,installControllerStyles:function(){var scope=this.findStyleScope();if(scope&&!this.scopeHasNamedStyle(scope,this.localName)){var proto=getPrototypeOf(this),cssText="";while(proto&&proto.element){cssText+=proto.element.cssTextForScope(STYLE_CONTROLLER_SCOPE);proto=getPrototypeOf(proto)}if(cssText){this.installScopeCssText(cssText,scope)}}},installScopeStyle:function(style,name,scope){var scope=scope||this.findStyleScope(),name=name||"";if(scope&&!this.scopeHasNamedStyle(scope,this.localName+name)){var cssText="";if(style instanceof Array){for(var i=0,l=style.length,s;i<l&&(s=style[i]);i++){cssText+=s.textContent+"\n\n"}}else{cssText=style.textContent}this.installScopeCssText(cssText,scope,name)}},installScopeCssText:function(cssText,scope,name){scope=scope||this.findStyleScope();name=name||"";if(!scope){return}if(hasShadowDOMPolyfill){cssText=shimCssText(cssText,scope.host)}var style=this.element.cssTextToScopeStyle(cssText,STYLE_CONTROLLER_SCOPE);Polymer.applyStyleToScope(style,scope);this.styleCacheForScope(scope)[this.localName+name]=true},findStyleScope:function(node){var n=node||this;while(n.parentNode){n=n.parentNode}return n},scopeHasNamedStyle:function(scope,name){var cache=this.styleCacheForScope(scope);return cache[name]},styleCacheForScope:function(scope){if(hasShadowDOMPolyfill){var scopeName=scope.host?scope.host.localName:scope.localName;return polyfillScopeStyleCache[scopeName]||(polyfillScopeStyleCache[scopeName]={})}else{return scope._scopeStyles=scope._scopeStyles||{}}}};var polyfillScopeStyleCache={};function getPrototypeOf(prototype){return prototype.__proto__}function shimCssText(cssText,host){var name="",is=false;if(host){name=host.localName;is=host.hasAttribute("is")}var selector=WebComponents.ShadowCSS.makeScopeSelector(name,is);return WebComponents.ShadowCSS.shimCssText(cssText,selector)}scope.api.instance.styles=styles})(Polymer);(function(scope){var extend=scope.extend;var api=scope.api;function element(name,prototype){if(typeof name!=="string"){var script=prototype||document._currentScript;prototype=name;name=script&&script.parentNode&&script.parentNode.getAttribute?script.parentNode.getAttribute("name"):"";if(!name){throw"Element name could not be inferred."}}if(getRegisteredPrototype(name)){throw"Already registered (Polymer) prototype for element "+name}registerPrototype(name,prototype);notifyPrototype(name)}function waitingForPrototype(name,client){waitPrototype[name]=client}var waitPrototype={};function notifyPrototype(name){if(waitPrototype[name]){waitPrototype[name].registerWhenReady();delete waitPrototype[name]}}var prototypesByName={};function registerPrototype(name,prototype){return prototypesByName[name]=prototype||{}}function getRegisteredPrototype(name){return prototypesByName[name]}function instanceOfType(element,type){if(typeof type!=="string"){return false}var proto=HTMLElement.getPrototypeForTag(type);var ctor=proto&&proto.constructor;if(!ctor){return false}if(CustomElements.instanceof){return CustomElements.instanceof(element,ctor)}return element instanceof ctor}scope.getRegisteredPrototype=getRegisteredPrototype;scope.waitingForPrototype=waitingForPrototype;scope.instanceOfType=instanceOfType;window.Polymer=element;extend(Polymer,scope);if(WebComponents.consumeDeclarations){WebComponents.consumeDeclarations(function(declarations){if(declarations){for(var i=0,l=declarations.length,d;i<l&&(d=declarations[i]);i++){element.apply(null,d)}}})}})(Polymer);
(function(scope){var path={resolveElementPaths:function(node){Polymer.urlResolver.resolveDom(node)},addResolvePathApi:function(){var assetPath=this.getAttribute("assetpath")||"";var root=new URL(assetPath,this.ownerDocument.baseURI);this.prototype.resolvePath=function(urlPath,base){var u=new URL(urlPath,base||root);return u.href}}};scope.api.declaration.path=path})(Polymer);(function(scope){var log=window.WebComponents?WebComponents.flags.log:{};var api=scope.api.instance.styles;var STYLE_SCOPE_ATTRIBUTE=api.STYLE_SCOPE_ATTRIBUTE;var hasShadowDOMPolyfill=window.ShadowDOMPolyfill;var STYLE_SELECTOR="style";var STYLE_LOADABLE_MATCH="@import";var SHEET_SELECTOR="link[rel=stylesheet]";var STYLE_GLOBAL_SCOPE="global";var SCOPE_ATTR="polymer-scope";var styles={loadStyles:function(callback){var template=this.fetchTemplate();var content=template&&this.templateContent();if(content){this.convertSheetsToStyles(content);var styles=this.findLoadableStyles(content);if(styles.length){var templateUrl=template.ownerDocument.baseURI;return Polymer.styleResolver.loadStyles(styles,templateUrl,callback)}}if(callback){callback()}},convertSheetsToStyles:function(root){var s$=root.querySelectorAll(SHEET_SELECTOR);for(var i=0,l=s$.length,s,c;i<l&&(s=s$[i]);i++){c=createStyleElement(importRuleForSheet(s,this.ownerDocument.baseURI),this.ownerDocument);this.copySheetAttributes(c,s);s.parentNode.replaceChild(c,s)}},copySheetAttributes:function(style,link){for(var i=0,a$=link.attributes,l=a$.length,a;(a=a$[i])&&i<l;i++){if(a.name!=="rel"&&a.name!=="href"){style.setAttribute(a.name,a.value)}}},findLoadableStyles:function(root){var loadables=[];if(root){var s$=root.querySelectorAll(STYLE_SELECTOR);for(var i=0,l=s$.length,s;i<l&&(s=s$[i]);i++){if(s.textContent.match(STYLE_LOADABLE_MATCH)){loadables.push(s)}}}return loadables},installSheets:function(){this.cacheSheets();this.cacheStyles();this.installLocalSheets();this.installGlobalStyles()},cacheSheets:function(){this.sheets=this.findNodes(SHEET_SELECTOR);this.sheets.forEach(function(s){if(s.parentNode){s.parentNode.removeChild(s)}})},cacheStyles:function(){this.styles=this.findNodes(STYLE_SELECTOR+"["+SCOPE_ATTR+"]");this.styles.forEach(function(s){if(s.parentNode){s.parentNode.removeChild(s)}})},installLocalSheets:function(){var sheets=this.sheets.filter(function(s){return!s.hasAttribute(SCOPE_ATTR)});var content=this.templateContent();if(content){var cssText="";sheets.forEach(function(sheet){cssText+=cssTextFromSheet(sheet)+"\n"});if(cssText){var style=createStyleElement(cssText,this.ownerDocument);content.insertBefore(style,content.firstChild)}}},findNodes:function(selector,matcher){var nodes=this.querySelectorAll(selector).array();var content=this.templateContent();if(content){var templateNodes=content.querySelectorAll(selector).array();nodes=nodes.concat(templateNodes)}return matcher?nodes.filter(matcher):nodes},installGlobalStyles:function(){var style=this.styleForScope(STYLE_GLOBAL_SCOPE);applyStyleToScope(style,document.head)},cssTextForScope:function(scopeDescriptor){var cssText="";var selector="["+SCOPE_ATTR+"="+scopeDescriptor+"]";var matcher=function(s){return matchesSelector(s,selector)};var sheets=this.sheets.filter(matcher);sheets.forEach(function(sheet){cssText+=cssTextFromSheet(sheet)+"\n\n"});var styles=this.styles.filter(matcher);styles.forEach(function(style){cssText+=style.textContent+"\n\n"});return cssText},styleForScope:function(scopeDescriptor){var cssText=this.cssTextForScope(scopeDescriptor);return this.cssTextToScopeStyle(cssText,scopeDescriptor)},cssTextToScopeStyle:function(cssText,scopeDescriptor){if(cssText){var style=createStyleElement(cssText);style.setAttribute(STYLE_SCOPE_ATTRIBUTE,this.getAttribute("name")+"-"+scopeDescriptor);return style}}};function importRuleForSheet(sheet,baseUrl){var href=new URL(sheet.getAttribute("href"),baseUrl).href;return"@import '"+href+"';"}function applyStyleToScope(style,scope){if(style){if(scope===document){scope=document.head}if(hasShadowDOMPolyfill){scope=document.head}var clone=createStyleElement(style.textContent);var attr=style.getAttribute(STYLE_SCOPE_ATTRIBUTE);if(attr){clone.setAttribute(STYLE_SCOPE_ATTRIBUTE,attr)}var refNode=scope.firstElementChild;if(scope===document.head){var selector="style["+STYLE_SCOPE_ATTRIBUTE+"]";var s$=document.head.querySelectorAll(selector);if(s$.length){refNode=s$[s$.length-1].nextElementSibling}}scope.insertBefore(clone,refNode)}}function createStyleElement(cssText,scope){scope=scope||document;scope=scope.createElement?scope:scope.ownerDocument;var style=scope.createElement("style");style.textContent=cssText;return style}function cssTextFromSheet(sheet){return sheet&&sheet.__resource||""}function matchesSelector(node,inSelector){if(matches){return matches.call(node,inSelector)}}var p=HTMLElement.prototype;var matches=p.matches||p.matchesSelector||p.webkitMatchesSelector||p.mozMatchesSelector;scope.api.declaration.styles=styles;scope.applyStyleToScope=applyStyleToScope})(Polymer);(function(scope){var log=window.WebComponents?WebComponents.flags.log:{};var api=scope.api.instance.events;var EVENT_PREFIX=api.EVENT_PREFIX;var mixedCaseEventTypes={};["webkitAnimationStart","webkitAnimationEnd","webkitTransitionEnd","DOMFocusOut","DOMFocusIn","DOMMouseScroll"].forEach(function(e){mixedCaseEventTypes[e.toLowerCase()]=e});var events={parseHostEvents:function(){var delegates=this.prototype.eventDelegates;this.addAttributeDelegates(delegates)},addAttributeDelegates:function(delegates){for(var i=0,a;a=this.attributes[i];i++){if(this.hasEventPrefix(a.name)){delegates[this.removeEventPrefix(a.name)]=a.value.replace("{{","").replace("}}","").trim()}}},hasEventPrefix:function(n){return n&&n[0]==="o"&&n[1]==="n"&&n[2]==="-"},removeEventPrefix:function(n){return n.slice(prefixLength)},findController:function(node){while(node.parentNode){if(node.eventController){return node.eventController}node=node.parentNode}return node.host},getEventHandler:function(controller,target,method){var events=this;return function(e){if(!controller||!controller.PolymerBase){controller=events.findController(target)}var args=[e,e.detail,e.currentTarget];controller.dispatchMethod(controller,method,args)}},prepareEventBinding:function(pathString,name,node){if(!this.hasEventPrefix(name))return;var eventType=this.removeEventPrefix(name);eventType=mixedCaseEventTypes[eventType]||eventType;var events=this;return function(model,node,oneTime){var handler=events.getEventHandler(undefined,node,pathString);PolymerGestures.addEventListener(node,eventType,handler);if(oneTime)return;function bindingValue(){return"{{ "+pathString+" }}"}return{open:bindingValue,discardChanges:bindingValue,close:function(){PolymerGestures.removeEventListener(node,eventType,handler)}}}}};var prefixLength=EVENT_PREFIX.length;scope.api.declaration.events=events})(Polymer);(function(scope){var observationBlacklist=["attribute"];var properties={inferObservers:function(prototype){var observe=prototype.observe,property;for(var n in prototype){if(n.slice(-7)==="Changed"){property=n.slice(0,-7);if(this.canObserveProperty(property)){if(!observe){observe=prototype.observe={}}observe[property]=observe[property]||n}}}},canObserveProperty:function(property){return observationBlacklist.indexOf(property)<0},explodeObservers:function(prototype){var o=prototype.observe;if(o){var exploded={};for(var n in o){var names=n.split(" ");for(var i=0,ni;ni=names[i];i++){exploded[ni]=o[n]}}prototype.observe=exploded}},optimizePropertyMaps:function(prototype){if(prototype.observe){var a=prototype._observeNames=[];for(var n in prototype.observe){var names=n.split(" ");for(var i=0,ni;ni=names[i];i++){a.push(ni)}}}if(prototype.publish){var a=prototype._publishNames=[];for(var n in prototype.publish){a.push(n)}}if(prototype.computed){var a=prototype._computedNames=[];for(var n in prototype.computed){a.push(n)}}},publishProperties:function(prototype,base){var publish=prototype.publish;if(publish){this.requireProperties(publish,prototype,base);this.filterInvalidAccessorNames(publish);prototype._publishLC=this.lowerCaseMap(publish)}var computed=prototype.computed;if(computed){this.filterInvalidAccessorNames(computed)}},filterInvalidAccessorNames:function(propertyNames){for(var name in propertyNames){if(this.propertyNameBlacklist[name]){console.warn('Cannot define property "'+name+'" for element "'+this.name+'" because it has the same name as an HTMLElement '+"property, and not all browsers support overriding that. "+"Consider giving it a different name.");delete propertyNames[name]}}},requireProperties:function(propertyInfos,prototype,base){prototype.reflect=prototype.reflect||{};for(var n in propertyInfos){var value=propertyInfos[n];if(value&&value.reflect!==undefined){prototype.reflect[n]=Boolean(value.reflect);value=value.value}if(value!==undefined){prototype[n]=value}}},lowerCaseMap:function(properties){var map={};for(var n in properties){map[n.toLowerCase()]=n}return map},createPropertyAccessor:function(name,ignoreWrites){var proto=this.prototype;var privateName=name+"_";var privateObservable=name+"Observable_";proto[privateName]=proto[name];Object.defineProperty(proto,name,{get:function(){var observable=this[privateObservable];if(observable)observable.deliver();return this[privateName]},set:function(value){if(ignoreWrites){return this[privateName]}var observable=this[privateObservable];if(observable){observable.setValue(value);return}var oldValue=this[privateName];this[privateName]=value;this.emitPropertyChangeRecord(name,value,oldValue);return value},configurable:true})},createPropertyAccessors:function(prototype){var n$=prototype._computedNames;if(n$&&n$.length){for(var i=0,l=n$.length,n,fn;i<l&&(n=n$[i]);i++){this.createPropertyAccessor(n,true)}}var n$=prototype._publishNames;if(n$&&n$.length){for(var i=0,l=n$.length,n,fn;i<l&&(n=n$[i]);i++){if(!prototype.computed||!prototype.computed[n]){this.createPropertyAccessor(n)}}}},propertyNameBlacklist:{children:1,"class":1,id:1,hidden:1,style:1,title:1}};scope.api.declaration.properties=properties})(Polymer);(function(scope){var ATTRIBUTES_ATTRIBUTE="attributes";var ATTRIBUTES_REGEX=/\s|,/;var attributes={inheritAttributesObjects:function(prototype){this.inheritObject(prototype,"publishLC");this.inheritObject(prototype,"_instanceAttributes")},publishAttributes:function(prototype,base){var attributes=this.getAttribute(ATTRIBUTES_ATTRIBUTE);if(attributes){var publish=prototype.publish||(prototype.publish={});var names=attributes.split(ATTRIBUTES_REGEX);for(var i=0,l=names.length,n;i<l;i++){n=names[i].trim();if(n&&publish[n]===undefined){publish[n]=undefined}}}},accumulateInstanceAttributes:function(){var clonable=this.prototype._instanceAttributes;var a$=this.attributes;for(var i=0,l=a$.length,a;i<l&&(a=a$[i]);i++){if(this.isInstanceAttribute(a.name)){clonable[a.name]=a.value}}},isInstanceAttribute:function(name){return!this.blackList[name]&&name.slice(0,3)!=="on-"},blackList:{name:1,"extends":1,constructor:1,noscript:1,assetpath:1,"cache-csstext":1}};attributes.blackList[ATTRIBUTES_ATTRIBUTE]=1;scope.api.declaration.attributes=attributes})(Polymer);(function(scope){var events=scope.api.declaration.events;var syntax=new PolymerExpressions;var prepareBinding=syntax.prepareBinding;syntax.prepareBinding=function(pathString,name,node){return events.prepareEventBinding(pathString,name,node)||prepareBinding.call(syntax,pathString,name,node)};var mdv={syntax:syntax,fetchTemplate:function(){return this.querySelector("template")},templateContent:function(){var template=this.fetchTemplate();return template&&template.content},installBindingDelegate:function(template){if(template){template.bindingDelegate=this.syntax}}};scope.api.declaration.mdv=mdv})(Polymer);(function(scope){var api=scope.api;var isBase=scope.isBase;var extend=scope.extend;var hasShadowDOMPolyfill=window.ShadowDOMPolyfill;var prototype={register:function(name,extendeeName){this.buildPrototype(name,extendeeName);this.registerPrototype(name,extendeeName);this.publishConstructor()},buildPrototype:function(name,extendeeName){var extension=scope.getRegisteredPrototype(name);var base=this.generateBasePrototype(extendeeName);this.desugarBeforeChaining(extension,base);this.prototype=this.chainPrototypes(extension,base);this.desugarAfterChaining(name,extendeeName)},desugarBeforeChaining:function(prototype,base){prototype.element=this;this.publishAttributes(prototype,base);this.publishProperties(prototype,base);this.inferObservers(prototype);this.explodeObservers(prototype)},chainPrototypes:function(prototype,base){this.inheritMetaData(prototype,base);var chained=this.chainObject(prototype,base);ensurePrototypeTraversal(chained);return chained},inheritMetaData:function(prototype,base){this.inheritObject("observe",prototype,base);this.inheritObject("publish",prototype,base);this.inheritObject("reflect",prototype,base);this.inheritObject("_publishLC",prototype,base);this.inheritObject("_instanceAttributes",prototype,base);this.inheritObject("eventDelegates",prototype,base)},desugarAfterChaining:function(name,extendee){this.optimizePropertyMaps(this.prototype);this.createPropertyAccessors(this.prototype);this.installBindingDelegate(this.fetchTemplate());this.installSheets();this.resolveElementPaths(this);this.accumulateInstanceAttributes();this.parseHostEvents();this.addResolvePathApi();if(hasShadowDOMPolyfill){WebComponents.ShadowCSS.shimStyling(this.templateContent(),name,extendee)}if(this.prototype.registerCallback){this.prototype.registerCallback(this)}},publishConstructor:function(){var symbol=this.getAttribute("constructor");if(symbol){window[symbol]=this.ctor}},generateBasePrototype:function(extnds){var prototype=this.findBasePrototype(extnds);if(!prototype){var prototype=HTMLElement.getPrototypeForTag(extnds);prototype=this.ensureBaseApi(prototype);memoizedBases[extnds]=prototype}return prototype},findBasePrototype:function(name){return memoizedBases[name]},ensureBaseApi:function(prototype){if(prototype.PolymerBase){return prototype}var extended=Object.create(prototype);api.publish(api.instance,extended);this.mixinMethod(extended,prototype,api.instance.mdv,"bind");return extended},mixinMethod:function(extended,prototype,api,name){var $super=function(args){return prototype[name].apply(this,args)};extended[name]=function(){this.mixinSuper=$super;return api[name].apply(this,arguments)}},inheritObject:function(name,prototype,base){var source=prototype[name]||{};prototype[name]=this.chainObject(source,base[name])},registerPrototype:function(name,extendee){var info={prototype:this.prototype};var typeExtension=this.findTypeExtension(extendee);if(typeExtension){info.extends=typeExtension}HTMLElement.register(name,this.prototype);this.ctor=document.registerElement(name,info)},findTypeExtension:function(name){if(name&&name.indexOf("-")<0){return name}else{var p=this.findBasePrototype(name);if(p.element){return this.findTypeExtension(p.element.extends)}}}};var memoizedBases={};if(Object.__proto__){prototype.chainObject=function(object,inherited){if(object&&inherited&&object!==inherited){object.__proto__=inherited}return object}}else{prototype.chainObject=function(object,inherited){if(object&&inherited&&object!==inherited){var chained=Object.create(inherited);object=extend(chained,object)}return object}}function ensurePrototypeTraversal(prototype){if(!Object.__proto__){var ancestor=Object.getPrototypeOf(prototype);prototype.__proto__=ancestor;if(isBase(ancestor)){ancestor.__proto__=Object.getPrototypeOf(ancestor)}}}api.declaration.prototype=prototype})(Polymer);(function(scope){var queue={wait:function(element){if(!element.__queue){element.__queue={};elements.push(element)}},enqueue:function(element,check,go){var shouldAdd=element.__queue&&!element.__queue.check;if(shouldAdd){queueForElement(element).push(element);element.__queue.check=check;element.__queue.go=go}return this.indexOf(element)!==0},indexOf:function(element){var i=queueForElement(element).indexOf(element);if(i>=0&&document.contains(element)){i+=HTMLImports.useNative||HTMLImports.ready?importQueue.length:1e9}return i},go:function(element){var readied=this.remove(element);if(readied){element.__queue.flushable=true;this.addToFlushQueue(readied);this.check()}},remove:function(element){var i=this.indexOf(element);if(i!==0){return}return queueForElement(element).shift()},check:function(){var element=this.nextElement();if(element){element.__queue.check.call(element)}if(this.canReady()){this.ready();return true}},nextElement:function(){return nextQueued()},canReady:function(){return!this.waitToReady&&this.isEmpty()},isEmpty:function(){for(var i=0,l=elements.length,e;i<l&&(e=elements[i]);i++){if(e.__queue&&!e.__queue.flushable){return}}return true},addToFlushQueue:function(element){flushQueue.push(element)},flush:function(){if(this.flushing){return}this.flushing=true;var element;while(flushQueue.length){element=flushQueue.shift();element.__queue.go.call(element);element.__queue=null}this.flushing=false},ready:function(){var polyfillWasReady=CustomElements.ready;CustomElements.ready=false;this.flush();if(!CustomElements.useNative){CustomElements.upgradeDocumentTree(document)}CustomElements.ready=polyfillWasReady;Polymer.flush();requestAnimationFrame(this.flushReadyCallbacks)},addReadyCallback:function(callback){if(callback){readyCallbacks.push(callback)}},flushReadyCallbacks:function(){if(readyCallbacks){var fn;while(readyCallbacks.length){fn=readyCallbacks.shift();fn()}}},waitingFor:function(){var e$=[];for(var i=0,l=elements.length,e;i<l&&(e=elements[i]);i++){if(e.__queue&&!e.__queue.flushable){e$.push(e)}}return e$},waitToReady:true};var elements=[];var flushQueue=[];var importQueue=[];var mainQueue=[];var readyCallbacks=[];function queueForElement(element){return document.contains(element)?mainQueue:importQueue}function nextQueued(){return importQueue.length?importQueue[0]:mainQueue[0]}function whenReady(callback){queue.waitToReady=true;Polymer.endOfMicrotask(function(){HTMLImports.whenReady(function(){queue.addReadyCallback(callback);queue.waitToReady=false;queue.check()})})}function forceReady(timeout){if(timeout===undefined){queue.ready();return}var handle=setTimeout(function(){queue.ready()},timeout);Polymer.whenReady(function(){clearTimeout(handle)})}scope.elements=elements;scope.waitingFor=queue.waitingFor.bind(queue);scope.forceReady=forceReady;scope.queue=queue;scope.whenReady=scope.whenPolymerReady=whenReady})(Polymer);(function(scope){var extend=scope.extend;var api=scope.api;var queue=scope.queue;var whenReady=scope.whenReady;var getRegisteredPrototype=scope.getRegisteredPrototype;var waitingForPrototype=scope.waitingForPrototype;var prototype=extend(Object.create(HTMLElement.prototype),{createdCallback:function(){if(this.getAttribute("name")){this.init()}},init:function(){this.name=this.getAttribute("name");this.extends=this.getAttribute("extends");queue.wait(this);this.loadResources();this.registerWhenReady()},registerWhenReady:function(){if(this.registered||this.waitingForPrototype(this.name)||this.waitingForQueue()||this.waitingForResources()){return}queue.go(this)},_register:function(){if(isCustomTag(this.extends)&&!isRegistered(this.extends)){console.warn("%s is attempting to extend %s, an unregistered element "+"or one that was not registered with Polymer.",this.name,this.extends)}this.register(this.name,this.extends);this.registered=true},waitingForPrototype:function(name){if(!getRegisteredPrototype(name)){waitingForPrototype(name,this);this.handleNoScript(name);return true}},handleNoScript:function(name){if(this.hasAttribute("noscript")&&!this.noscript){this.noscript=true;Polymer(name)}},waitingForResources:function(){return this._needsResources},waitingForQueue:function(){return queue.enqueue(this,this.registerWhenReady,this._register)},loadResources:function(){this._needsResources=true;this.loadStyles(function(){this._needsResources=false;this.registerWhenReady()}.bind(this))}});api.publish(api.declaration,prototype);function isRegistered(name){return Boolean(HTMLElement.getPrototypeForTag(name))}function isCustomTag(name){return name&&name.indexOf("-")>=0}whenReady(function(){document.body.removeAttribute("unresolved");document.dispatchEvent(new CustomEvent("polymer-ready",{bubbles:true}))});document.registerElement("polymer-element",{prototype:prototype})})(Polymer);(function(scope){var whenReady=scope.whenReady;function importElements(node,callback){if(node){document.head.appendChild(node);whenReady(callback)}else if(callback){callback()}}function _import(urls,callback){if(urls&&urls.length){var frag=document.createDocumentFragment();for(var i=0,l=urls.length,url,link;i<l&&(url=urls[i]);i++){link=document.createElement("link");link.rel="import";link.href=url;frag.appendChild(link)}importElements(frag,callback)}else if(callback){callback()}}scope.import=_import;scope.importElements=importElements})(Polymer);(function(){var element=document.createElement("polymer-element");element.setAttribute("name","auto-binding");element.setAttribute("extends","template");element.init();Polymer("auto-binding",{createdCallback:function(){this.syntax=this.bindingDelegate=this.makeSyntax();Polymer.whenPolymerReady(function(){this.model=this;this.setAttribute("bind","");this.async(function(){this.marshalNodeReferences(this.parentNode);this.fire("template-bound")})}.bind(this))},makeSyntax:function(){var events=Object.create(Polymer.api.declaration.events);var self=this;events.findController=function(){return self.model};var syntax=new PolymerExpressions;var prepareBinding=syntax.prepareBinding;syntax.prepareBinding=function(pathString,name,node){return events.prepareEventBinding(pathString,name,node)||prepareBinding.call(syntax,pathString,name,node)};return syntax}})})();</script><style type="text/css">:host{display:block;position:relative}</style><script>(function(){"use strict";if(typeof define==="function"&&define.amd){define(function(){return r})}else if(typeof module!=="undefined"&&module.exports){module.exports=r}else if(typeof window!=="undefined"){window.SimpleLRU=r}r.version="0.0.3";function t(t,i){for(var e in i)t[e]=i[e]}var i=Object.create;var e=function(){var e,n;if(typeof i==="function"){e=function(){this.data=i(null)};n={get:function(t){return this.data[t]},has:function(t){return!!this.data[t]}}}else{e=function(){this.data={}};n={get:function(t){if(this.has(t))return this.data[t]},has:function(t){return Object.prototype.hasOwnProperty.call(this.data,t)}}}t(n,{set:function(t,i){this.data[t]=i},del:function(t){var i=this.get(t);if(typeof i!=="undefined"){delete this.data[t];return i}}});t(e.prototype,n);return e}();function n(t,i,e){this.key=t;this.val=i;this.index=e}function r(t){if(typeof t!=="number")throw new TypeError("max is requried");this.max(t);this.reset()}t(r.prototype,{set:function(t,i){var e=this._byKey.get(t);if(e){this._touch(e);e.val=i;return}e=new n(t,i,this._head++);this._byKey.set(t,e);this._byOrder[e.index]=e;this._len++;this._trim()},del:function(t){var i=this._byKey.del(t);if(!i)return;delete this._byOrder[i.index];this._len--;if(this._len===0){this._head=this._tail=0}else{if(i.index===this._head-1)this._pop();if(i.index===this._tail)this._shift()}return i.val},get:function(t){var i=this._byKey.get(t);if(i){this._touch(i);return i.val}},peek:function(t){var i=this._byKey.get(t);if(i)return i.val},has:function(t){return this._byKey.has(t)},length:function(){return this._len},reset:function(){this._byKey=new e;this._byOrder=i?i(null):{};this._head=0;this._tail=0;this._len=0},max:function(t){if(typeof t!=="number")return this._max;if(t<1)throw new TypeError("max should be a positive number");var i=(this._max||0)>t;this._max=t;if(i)this._trim()},keys:function(){var t=0,i=this._tail,e=this._head,n=new Array(this._len);for(var r=i;r<e;r++){var h=this._byOrder[r];if(h)n[t++]=h.key}return n},_touch:function(t){if(t.index!==this._head-1){var i=t.index===this._tail;delete this._byOrder[t.index];t.index=this._head++;this._byOrder[t.index]=t;if(i)this._shift()}},_trim:function(){var t=this._max;while(t<this._len){var i=this._byOrder[this._tail];this.del(i.key)}},_shift:function(){var t=this._tail,i=this._head;for(var e=t;e<i;e++){var n=this._byOrder[e];if(n){this._tail=e;return n}}},_pop:function(){var t=this._tail,i=this._head;for(var e=i-1;e>=t;e--){var n=this._byOrder[e];if(n){this._head=e+1;return n}}}})})();</script><script>(function(){function a(a){this._value=a}function b(a,b,c,d){var e,f,g=Math.pow(10,b);return f=(c(a*g)/g).toFixed(b),d&&(e=new RegExp("0{1,"+d+"}$"),f=f.replace(e,"")),f}function c(a,b,c){var d;return d=b.indexOf("$")>-1?e(a,b,c):b.indexOf("%")>-1?f(a,b,c):b.indexOf(":")>-1?g(a,b):i(a._value,b,c)}function d(a,b){var c,d,e,f,g,i=b,j=["KB","MB","GB","TB","PB","EB","ZB","YB"],k=!1;if(b.indexOf(":")>-1)a._value=h(b);else if(b===q)a._value=0;else{for("."!==o[p].delimiters.decimal&&(b=b.replace(/\./g,"").replace(o[p].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+o[p].abbreviations.thousand+"(?:\\)|(\\"+o[p].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+o[p].abbreviations.million+"(?:\\)|(\\"+o[p].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+o[p].abbreviations.billion+"(?:\\)|(\\"+o[p].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+o[p].abbreviations.trillion+"(?:\\)|(\\"+o[p].currency.symbol+")?(?:\\))?)?$"),g=0;g<=j.length&&!(k=b.indexOf(j[g])>-1?Math.pow(1024,g+1):!1);g++);a._value=(k?k:1)*(i.match(c)?Math.pow(10,3):1)*(i.match(d)?Math.pow(10,6):1)*(i.match(e)?Math.pow(10,9):1)*(i.match(f)?Math.pow(10,12):1)*(b.indexOf("%")>-1?.01:1)*((b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1)*Number(b.replace(/[^0-9\.]+/g,"")),a._value=k?Math.ceil(a._value):a._value}return a._value}function e(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),j="";return b.indexOf(" $")>-1?(j=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(j=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=i(a._value,b,c),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,o[p].currency.symbol+j),e=e.join("")):e=o[p].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+o[p].currency.symbol),e=e.join("")):e=e+j+o[p].currency.symbol,e}function f(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=i(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function g(a){var b=Math.floor(a._value/60/60),c=Math.floor((a._value-60*b*60)/60),d=Math.round(a._value-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function h(a){var b=a.split(":"),c=0;return 3===b.length?(c+=60*Number(b[0])*60,c+=60*Number(b[1]),c+=Number(b[2])):2===b.length&&(c+=60*Number(b[0]),c+=Number(b[1])),Number(c)}function i(a,c,d){var e,f,g,h,i,j,k=!1,l=!1,m=!1,n="",r=!1,s=!1,t=!1,u=!1,v=!1,w="",x="",y=Math.abs(a),z=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],A="",B=!1;if(0===a&&null!==q)return q;if(c.indexOf("(")>-1?(k=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(l=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(r=c.indexOf("aK")>=0,s=c.indexOf("aM")>=0,t=c.indexOf("aB")>=0,u=c.indexOf("aT")>=0,v=r||s||t||u,c.indexOf(" a")>-1?(n=" ",c=c.replace(" a","")):c=c.replace("a",""),y>=Math.pow(10,12)&&!v||u?(n+=o[p].abbreviations.trillion,a/=Math.pow(10,12)):y<Math.pow(10,12)&&y>=Math.pow(10,9)&&!v||t?(n+=o[p].abbreviations.billion,a/=Math.pow(10,9)):y<Math.pow(10,9)&&y>=Math.pow(10,6)&&!v||s?(n+=o[p].abbreviations.million,a/=Math.pow(10,6)):(y<Math.pow(10,6)&&y>=Math.pow(10,3)&&!v||r)&&(n+=o[p].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("b")>-1)for(c.indexOf(" b")>-1?(w=" ",c=c.replace(" b","")):c=c.replace("b",""),g=0;g<=z.length;g++)if(e=Math.pow(1024,g),f=Math.pow(1024,g+1),a>=e&&f>a){w+=z[g],e>0&&(a/=e);break}return c.indexOf("o")>-1&&(c.indexOf(" o")>-1?(x=" ",c=c.replace(" o","")):c=c.replace("o",""),x+=o[p].ordinal(a)),c.indexOf("[.]")>-1&&(m=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(i.indexOf("[")>-1?(i=i.replace("]",""),i=i.split("["),A=b(a,i[0].length+i[1].length,d,i[1].length)):A=b(a,i.length,d),h=A.split(".")[0],A=A.split(".")[1].length?o[p].delimiters.decimal+A.split(".")[1]:"",m&&0===Number(A.slice(1))&&(A="")):h=b(a,null,d),h.indexOf("-")>-1&&(h=h.slice(1),B=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+o[p].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&B?"(":"")+(!k&&B?"-":"")+(!B&&l?"+":"")+h+A+(x?x:"")+(n?n:"")+(w?w:"")+(k&&B?")":"")}function j(a,b){o[a]=b}function k(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function l(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=k(a),d=k(b);return c>d?c:d},-1/0)}var m,n="1.5.3",o={},p="en",q=null,r="0,0",s="undefined"!=typeof module&&module.exports;m=function(b){return m.isNumeral(b)?b=b.value():0===b||"undefined"==typeof b?b=0:Number(b)||(b=m.fn.unformat(b)),new a(Number(b))},m.version=n,m.isNumeral=function(b){return b instanceof a},m.language=function(a,b){if(!a)return p;if(a&&!b){if(!o[a])throw new Error("Unknown language : "+a);p=a}return(b||!o[a])&&j(a,b),m},m.languageData=function(a){if(!a)return o[p];if(!o[a])throw new Error("Unknown language : "+a);return o[a]},m.language("en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),m.zeroFormat=function(a){q="string"==typeof a?a:null},m.defaultFormat=function(a){r="string"==typeof a?a:"0.0"},"function"!=typeof Array.prototype.reduce&&(Array.prototype.reduce=function(a,b){"use strict";if(null===this||"undefined"==typeof this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof a)throw new TypeError(a+" is not a function");var c,d,e=this.length>>>0,f=!1;for(1<arguments.length&&(d=b,f=!0),c=0;e>c;++c)this.hasOwnProperty(c)&&(f?d=a(d,this[c],c,this):(d=this[c],f=!0));if(!f)throw new TypeError("Reduce of empty array with no initial value");return d}),m.fn=a.prototype={clone:function(){return m(this)},format:function(a,b){return c(this,a?a:r,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:d(this,a?a:r)},value:function(){return this._value},valueOf:function(){return this._value},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b){return a+c*b}var c=l.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b){return a-c*b}var c=l.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b){var c=l(a,b);return a*c*b*c/(c*c)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b){var c=l(a,b);return a*c/(b*c)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(m(this._value).subtract(a).value())}},s&&(module.exports=m),"undefined"==typeof ender&&(this.numeral=m),"function"==typeof define&&define.amd&&define([],function(){return m})}).call(this);</script></head><body><div hidden=""><polymer-element name="fin-rectangle" assetpath="/dev/fin-rectangle/"><script>"use strict";(function(){function pointEqualsPoint(a,b){return a.x===b.x&&a.y===b.y}function rectangleContains(rect,x,y){var minX=rect.origin.x;var minY=rect.origin.y;var maxX=minX+rect.extent.x;var maxY=minY+rect.extent.y;if(rect.extent.x<0){minX=maxX;maxX=rect.origin.x}if(rect.extent.y<0){minY=maxY;maxY=rect.origin.y}var result=x>=minX&&y>=minY&&x<=maxX&&y<=maxY;return result}function createPoint(x,y){var that={};Object.defineProperty(that,"x",{value:x||0,writable:false,enumerable:true,configurable:false});Object.defineProperty(that,"y",{value:y||0,writable:false,enumerable:true,configurable:false});that.plus=function(point){var result=createPoint(this.x+point.x,this.y+point.y);return result};that.plusXY=function(newX,newY){var result=createPoint(this.x+newX,this.y+newY);return result};that.minus=function(point){var result=createPoint(this.x-point.x,this.y-point.y);return result};that.min=function(point){var result=createPoint(Math.min(this.x,point.x),Math.min(this.y,point.y));return result};that.max=function(point){var result=createPoint(Math.max(this.x,point.x),Math.max(this.y,point.y));return result};that.distance=function(point){var dx=point.x-this.x,dy=point.y-this.y,result=Math.sqrt(dx*dx+dy*dy);return result};that.greaterThan=function(point){var result=this.x>point.x&&this.y>point.y;return result};that.lessThan=function(point){var result=this.x<point.x&&this.y<point.y;return result};that.greaterThanEqualTo=function(point){var result=this.x>=point.x&&this.y>=point.y;return result};that.lessThanEqualTo=function(point){var result=this.x<=point.x&&this.y<=point.y;return result};that.isContainedWithinRectangle=function(rect){return rectangleContains(rect,this.x,this.y)};that.equals=function(point){if(!point){return false}return pointEqualsPoint(this,point)};return that}function createRectangle(x,y,width,height){var that={};var origin=createPoint(x,y);var extent=createPoint(width,height);var corner=createPoint(x+width,y+height);var center=createPoint(x+width/2,y+height/2);Object.defineProperty(that,"origin",{value:origin,writable:false,enumerable:true,configurable:false});Object.defineProperty(that,"extent",{value:extent,writable:false,enumerable:true,configurable:false});Object.defineProperty(that,"corner",{value:corner,writable:false,enumerable:true,configurable:false});Object.defineProperty(that,"center",{value:center,writable:false,enumerable:true,configurable:false});that.top=function(){return this.origin.y};that.left=function(){return this.origin.x};that.bottom=function(){return this.top()+this.extent.y};that.right=function(){return this.left()+this.extent.x};that.width=function(){return this.extent.x};that.height=function(){return this.extent.y};that.area=function(){return this.extent.x*this.extent.y};that.flattenXAt=function(x){var o=this.origin;var e=this.extent;return createRectangle(x,o.y,0,e.y)};that.flattenYAt=function(y){var o=this.origin;var e=this.extent;return createRectangle(o.x,y,e.x,0)};that.contains=function(pointOrRect){var result=pointOrRect.isContainedWithinRectangle(this);return result};that.isContainedWithinRectangle=function(rect){var result=rect.origin.lessThanEqualTo(this.origin)&&rect.corner.greaterThanEqualTo(this.corner);return result};that.insetBy=function(thickness){var result=createRectangle(this.origin.x+thickness,this.origin.y+thickness,this.extent.x-2*thickness,this.extent.y-2*thickness);return result};that.union=function(rectangle){var anOrigin=this.origin.min(rectangle.origin),aCorner=this.corner.max(rectangle.corner),width=aCorner.x-anOrigin.x,height=aCorner.y-anOrigin.y,result=createRectangle(anOrigin.x,anOrigin.y,width,height);return result};that.forEach=function(func){var xstart=this.origin.x;var xstop=this.origin.x+this.extent.x;var ystart=this.origin.y;var ystop=this.origin.y+this.extent.y;for(var x=xstart;x<xstop;x++){for(var y=ystart;y<ystop;y++){func(x,y)}}};that.intersect=function(rectangle,ifNoneAction){var point=rectangle.origin,myCorner=this.corner,left=null,right=null,top=null,bottom=null,result=null;if(ifNoneAction&&!this.intersects(rectangle)){return ifNoneAction.call(this,rectangle)}if(point.x>this.origin.x){left=point.x}else{left=this.origin.x}if(point.y>this.origin.y){top=point.y}else{top=this.origin.y}point=rectangle.corner;if(point.x<myCorner.x){right=point.x}else{right=myCorner.x}if(point.y<myCorner.y){bottom=point.y}else{bottom=myCorner.y}result=createRectangle(left,top,right-left,bottom-top);return result};that.intersects=function(rectangle){var rOrigin=rectangle.origin,rCorner=rectangle.corner;if(rCorner.x<=this.origin.x){return false}if(rCorner.y<=this.origin.y){return false}if(rOrigin.x>=this.corner.x){return false}if(rOrigin.y>=this.corner.y){return false}return true};return that}Polymer("fin-rectangle",{point:{create:createPoint},rectangle:{create:createRectangle,contains:rectangleContains}})})();</script></polymer-element><polymer-element name="fin-canvas" assetpath="/dev/fin-canvas/"><template><style>:host{overflow:hidden;position:absolute;top:0;right:0;bottom:0;left:0}button{position:fixed;top:0;left:0;height:0;width:0;border:none;color:transparent;background-color:transparent;outline:0}div.container{position:relative;top:0;right:0;bottom:0;left:0}</style><button></button><canvas class="canvas" on-tap="{{fintap}}" on-hold="{{finhold}}" on-holdpulse="{{finholdpulse}}" on-flick="{{finflick}}" on-release="{{finrelease}}" on-dblclick="{{findblclick}}" on-trackstart="{{fintrackstart}}" on-track="{{fintrack}}" on-trackend="{{fintrackend}}"></canvas></template><script>"use strict";(function(){var paintables=[];var resizables=[];var paintLoopRunning=true;var resizeLoopRunning=true;var paintLoopFunction=function(now){if(!paintLoopRunning){return}for(var i=0;i<paintables.length;i++){try{paintables[i](now)}catch(e){}}requestAnimationFrame(paintLoopFunction)};requestAnimationFrame(paintLoopFunction);var resizablesLoopFunction=function(now){if(!resizeLoopRunning){return}for(var i=0;i<resizables.length;i++){try{resizables[i](now)}catch(e){}}};setInterval(resizablesLoopFunction,200);var charMap=[];var empty=["",""];for(var i=0;i<256;i++){charMap[i]=empty}charMap[27]=["ESC","ESCSHIFT"];charMap[192]=["`","~"];charMap[49]=["1","!"];charMap[50]=["2","@"];charMap[51]=["3","#"];charMap[52]=["4","$"];charMap[53]=["5","%"];charMap[54]=["6","^"];charMap[55]=["7","&"];charMap[56]=["8","*"];charMap[57]=["9","("];charMap[48]=["0",")"];charMap[189]=["-","_"];charMap[187]=["=","+"];charMap[8]=["DELETE","DELETESHIFT"];charMap[9]=["TAB","TABSHIFT"];charMap[81]=["q","Q"];charMap[87]=["w","W"];charMap[69]=["e","E"];charMap[82]=["r","R"];charMap[84]=["t","T"];charMap[89]=["y","Y"];charMap[85]=["u","U"];charMap[73]=["i","I"];charMap[79]=["o","O"];charMap[80]=["p","P"];charMap[219]=["[","{"];charMap[221]=["]","}"];charMap[220]=["\\","|"];charMap[220]=["CAPSLOCK","CAPSLOCKSHIFT"];charMap[65]=["a","A"];charMap[83]=["s","S"];charMap[68]=["d","D"];charMap[70]=["f","F"];charMap[71]=["g","G"];charMap[72]=["h","H"];charMap[74]=["j","J"];charMap[75]=["k","K"];charMap[76]=["l","L"];charMap[186]=[";",":"];charMap[222]=["'","|"];charMap[13]=["RETURN","RETURNSHIFT"];charMap[16]=["SHIFT","SHIFT"];charMap[90]=["z","Z"];charMap[88]=["x","X"];charMap[67]=["c","C"];charMap[86]=["v","V"];charMap[66]=["b","B"];charMap[78]=["n","N"];charMap[77]=["m","M"];charMap[188]=[",","<"];charMap[190]=[".",">"];charMap[191]=["/","?"];charMap[16]=["SHIFT","SHIFT"];charMap[17]=["CTRL","CTRLSHIFT"];charMap[18]=["ALT","ALTSHIFT"];charMap[91]=["COMMANDLEFT","COMMANDLEFTSHIFT"];charMap[32]=["SPACE","SPACESHIFT"];charMap[93]=["COMMANDRIGHT","COMMANDRIGHTSHIFT"];charMap[18]=["ALT","ALTSHIFT"];charMap[38]=["UP","UPSHIFT"];charMap[37]=["LEFT","LEFTSHIFT"];charMap[40]=["DOWN","DOWNSHIFT"];charMap[39]=["RIGHT","RIGHTSHIFT"];charMap[33]=["PAGEUP","PAGEUPSHIFT"];charMap[34]=["PAGEDOWN","PAGEDOWNSHIFT"];charMap[35]=["PAGERIGHT","PAGERIGHTSHIFT"];charMap[36]=["PAGELEFT","PAGELEFTSHIFT"];Polymer("fin-canvas",{g:null,canvas:null,canvasCTX:null,focuser:null,buffer:null,ctx:null,mouseLocation:null,holdPulseCount:-1,dragstart:null,origin:null,bounds:null,repaintNow:false,size:null,mousedown:false,dragging:false,focused:false,repeatKeyCount:0,repeatKey:null,repeatKeyStartTime:0,currentKeys:[],hasMouse:false,lastDoubleClickTime:0,dragEndTime:0,ready:function(){var self=this;this.dragEndtime=Date.now();this.g=document.createElement("fin-rectangle");this.canvas=this.shadowRoot.querySelector(".canvas");this.focuser=this.shadowRoot.querySelector("button");this.canvasCTX=this.canvas.getContext("2d");this.buffer=document.createElement("canvas");this.bufferCTX=this.buffer.getContext("2d");this.mouseLocation=this.g.point.create(-1,-1);this.dragstart=this.g.point.create(-1,-1);this.bounds=this.g.rectangle.create(0,0,0,0);this.hasMouse=false;this.onmouseover=function(){self.hasMouse=true};document.addEventListener("mousemove",function(e){if(!self.hasMouse&&!self.isDragging()){return}self.finmousemove(e)});document.addEventListener("mouseup",function(e){self.finmouseup(e)});document.addEventListener("wheel",function(e){self.finwheelmoved(e)});this.focuser.addEventListener("focus",function(e){self.finfocusgained(e)});this.focuser.addEventListener("blur",function(e){self.finfocuslost(e)});this.addEventListener("mousedown",function(e){self.finmousedown(e)});this.addEventListener("mouseout",function(e){self.hasMouse=false;self.finmouseout(e)});document.addEventListener("keydown",function(e){self.finkeydown(e)});document.addEventListener("keyup",function(e){self.finkeyup(e)});this.addEventListener("click",function(e){self.finclick(e)});this.addEventListener("contextmenu",function(e){self.fincontextmenu(e)});this.resize();this.beginResizing();this.beginPainting()},stopPaintThread:function(){paintLoopRunning=false},restartPaintThread:function(){if(paintLoopRunning){return}paintLoopRunning=true;requestAnimationFrame(paintLoopFunction)},stopResizeThread:function(){resizeLoopRunning=false},restartResizeThread:function(){if(resizeLoopRunning){return}resizeLoopRunning=true;setInterval(resizablesLoopFunction,200)},detached:function(){this.stopPainting();this.stopResizing()},isHiDPI:function(){return this.getAttribute("hidpi")!==null},useBitBlit:function(){return this.getAttribute("bitblit")!=="false"},getFPS:function(){var fps=this.getAttribute("fps");if(fps===0||!fps){fps=0}fps=parseInt(fps);return fps},getComponent:function(){var comp=this.children[0];return comp},tickPaint:function(now){var fps=this.getFPS();if(fps===0){return}var interval=1e3/fps;var lastRepaintTime=0;var delta=now-lastRepaintTime;if(delta>interval&&this.repaintNow){lastRepaintTime=now-delta%interval;this.paintNow()}},beginPainting:function(){var self=this;this.repaintNow=true;this.tickPainter=function(now){self.tickPaint(now)};paintables.push(this.tickPainter)},stopPainting:function(){paintables.splice(paintables.indexOf(this.tickPainter),1)},beginResizing:function(){var self=this;this.tickResizer=function(){self.checksize()};resizables.push(this.tickResizer)},stopResizing:function(){resizables.splice(resizables.indexOf(this.tickResizer),1)},checksize:function(){var sizeNow=this.getBoundingClientRect();if(sizeNow.width!==this.size.width||sizeNow.height!==this.size.height){this.sizeChangedNotification()}},sizeChangedNotification:function(){this.resize()},resize:function(){this.size=this.getBoundingClientRect();this.canvas.width=this.clientWidth;this.canvas.height=this.clientHeight;this.buffer.width=this.clientWidth;this.buffer.height=this.clientHeight;var ratio=1;var useBitBlit=this.useBitBlit();var isHIDPI=window.devicePixelRatio&&this.isHiDPI();if(isHIDPI){var devicePixelRatio=window.devicePixelRatio||1;var backingStoreRatio=this.canvasCTX.webkitBackingStorePixelRatio||this.canvasCTX.mozBackingStorePixelRatio||this.canvasCTX.msBackingStorePixelRatio||this.canvasCTX.oBackingStorePixelRatio||this.canvasCTX.backingStorePixelRatio||1;ratio=devicePixelRatio/backingStoreRatio}var width=this.canvas.getAttribute("width");var height=this.canvas.getAttribute("height");this.canvas.width=width*ratio;this.canvas.height=height*ratio;this.buffer.width=width*ratio;this.buffer.height=height*ratio;this.canvas.style.width=width+"px";this.canvas.style.height=height+"px";this.buffer.style.width=width+"px";this.buffer.style.height=height+"px";this.bufferCTX.scale(ratio,ratio);if(isHIDPI&&!useBitBlit){this.canvasCTX.scale(ratio,ratio)}this.bounds=this.g.rectangle.create(0,0,this.size.width,this.size.height);var comp=this.getComponent();if(comp){comp.setBounds(this.bounds)}this.resizeNotification();this.paintNow()},resizeNotification:function(){},getBounds:function(){return this.bounds},paintNow:function(){var self=this;this.safePaintImmediately(function(gc){gc.clearRect(0,0,self.canvas.width,self.canvas.height);self.paint(gc);self.repaintNow=false})},safePaintImmediately:function(paintFunction){var useBitBlit=this.useBitBlit();var gc=useBitBlit?this.bufferCTX:this.canvasCTX;try{gc.save();paintFunction(gc)}finally{gc.restore()}if(useBitBlit){this.flushBuffer()}},flushBuffer:function(){if(this.buffer.width>0&&this.buffer.height>0){this.canvasCTX.drawImage(this.buffer,0,0)}},paint:function(gc){var comp=this.getComponent();if(comp){comp._paint(gc)}},finmousemove:function(e){if(!this.isDragging()&&this.mousedown){this.beDragging();this.dispatchEvent(new CustomEvent("fin-canvas-dragstart",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}));this.dragstart=this.g.point.create(this.mouseLocation.x,this.mouseLocation.y)}this.mouseLocation=this.getLocal(e);if(this.isDragging()){this.dispatchEvent(new CustomEvent("fin-canvas-drag",{detail:{primitiveEvent:e,mouse:this.mouseLocation,dragstart:this.dragstart,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}))}if(this.bounds.contains(this.mouseLocation)){this.dispatchEvent(new CustomEvent("fin-canvas-mousemove",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys}}))}},finmousedown:function(e){this.mouseLocation=this.getLocal(e);this.mousedown=true;this.dispatchEvent(new CustomEvent("fin-canvas-mousedown",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}));this.takeFocus()},finmouseup:function(e){if(this.isDragging()){this.dispatchEvent(new CustomEvent("fin-canvas-dragend",{detail:{primitiveEvent:e,mouse:this.mouseLocation,dragstart:this.dragstart,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}));this.beNotDragging();this.dragEndtime=Date.now()}this.mousedown=false;this.dispatchEvent(new CustomEvent("fin-canvas-mouseup",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}));this.mouseLocation=this.g.point.create(-1,-1)},finmouseout:function(e){if(!this.mousedown){this.mouseLocation=this.g.point.create(-1,-1)}this.dispatchEvent(new CustomEvent("fin-canvas-mouseout",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys}}))},finwheelmoved:function(e){if(this.isDragging()||!this.hasFocus()){return}e.preventDefault();this.dispatchEvent(new CustomEvent("fin-canvas-wheelmoved",{detail:{mouse:this.mouseLocation,keys:this.currentKeys,primitiveEvent:e,isRightClick:this.isRightClick(e)}}))},finclick:function(e){this.mouseLocation=this.getLocal(e);this.dispatchEvent(new CustomEvent("fin-canvas-click",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}))},finrelease:function(e){this.holdPulseCount=0;this.mouseLocation=this.getLocal(e);this.dispatchEvent(new CustomEvent("fin-canvas-release",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys}}))},finflick:function(e){if(!this.hasFocus()){return}this.mouseLocation=this.getLocal(e);this.dispatchEvent(new CustomEvent("fin-canvas-flick",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}))},fintrackstart:function(e){if(!this.hasFocus()){return}this.mouseLocation=this.getLocal(e);this.dispatchEvent(new CustomEvent("fin-canvas-trackstart",{detail:{mouse:this.mouseLocation,keys:this.currentKeys,primitiveEvent:e}}))},fintrack:function(e){if(!this.hasFocus()){return}this.mouseLocation=this.getLocal(e);this.dispatchEvent(new CustomEvent("fin-canvas-track",{detail:{mouse:this.mouseLocation,keys:this.currentKeys,primitiveEvent:e}}))},fintrackend:function(e){this.mouseLocation=this.getLocal(e);this.dispatchEvent(new CustomEvent("fin-canvas-trackend",{detail:{mouse:this.mouseLocation,keys:this.currentKeys,primitiveEvent:e}}))},finhold:function(e){this.mouseLocation=this.getLocal(e);this.dispatchEvent(new CustomEvent("fin-canvas-hold",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}))},finholdpulse:function(e){this.mouseLocation=this.getLocal(e);this.dispatchEvent(new CustomEvent("fin-canvas-holdpulse",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys,count:this.holdPulseCount++}}))},fintap:function(e){var self=this;var now=Date.now();var dif=now-this.lastDoubleClickTime;if(dif<300){return}if(now-this.dragEndtime<100){return}setTimeout(function(){self._fintap(e)},180)},_fintap:function(e){var now=Date.now();var dif=now-this.lastDoubleClickTime;if(dif<300){return}this.mouseLocation=this.getLocal(e);this.dispatchEvent(new CustomEvent("fin-canvas-tap",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}))},findblclick:function(e){this.mouseLocation=this.getLocal(e);this.lastDoubleClickTime=Date.now();this.dispatchEvent(new CustomEvent("fin-canvas-dblclick",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}))},getCharMap:function(){return charMap},finkeydown:function(e){if(!this.hasFocus()){return}var charMap=this.getCharMap();var keyChar=e.shiftKey?charMap[e.keyCode][1]:charMap[e.keyCode][0];if(e.repeat){if(this.repeatKey===keyChar){this.repeatKeyCount++}else{this.repeatKey=keyChar;this.repeatKeyStartTime=Date.now()}}else{this.repeatKey=null;this.repeatKeyCount=0;this.repeatKeyStartTime=0}if(this.currentKeys.indexOf(keyChar)===-1){this.currentKeys.push(keyChar)}this.dispatchEvent(new CustomEvent("fin-canvas-keydown",{detail:{primitiveEvent:e,alt:e.altKey,ctrl:e.ctrlKey,"char":keyChar,code:e.charCode,key:e.keyCode,meta:e.metaKey,repeatCount:this.repeatKeyCount,repeatStartTime:this.repeatKeyStartTime,shift:e.shiftKey,identifier:e.keyIdentifier,currentKeys:this.currentKeys.slice(0)}}))},finkeyup:function(e){var keyChar=e.shiftKey?charMap[e.keyCode][1]:charMap[e.keyCode][0];this.currentKeys.splice(this.currentKeys.indexOf(keyChar),1);if(!this.hasFocus()){return}this.repeatKeyCount=0;this.repeatKey=null;this.repeatKeyStartTime=0;this.dispatchEvent(new CustomEvent("fin-canvas-keyup",{detail:{primitiveEvent:e,alt:e.altKey,ctrl:e.ctrlKey,"char":keyChar,code:e.charCode,key:e.keyCode,meta:e.metaKey,repeat:e.repeat,shift:e.shiftKey,identifier:e.keyIdentifier,currentKeys:this.currentKeys.slice(0)}}))},finfocusgained:function(e){this.focused=true;this.dispatchEvent(new CustomEvent("fin-canvas-focus-gained",{detail:{primitiveEvent:e}}))},finfocuslost:function(e){this.focused=false;this.dispatchEvent(new CustomEvent("fin-canvas-focus-lost",{detail:{primitiveEvent:e}}))},fincontextmenu:function(e){this.dispatchEvent(new CustomEvent("fin-canvas-context-menu",{detail:{primitiveEvent:e,mouse:this.mouseLocation,keys:this.currentKeys,isRightClick:this.isRightClick(e)}}))},repaint:function(){var fps=this.getFPS();this.repaintNow=true;if(!paintLoopRunning||fps===0){this.paintNow()}},getMouseLocation:function(){return this.mouseLocation},getOrigin:function(){var rect=this.getBoundingClientRect();var p=this.g.point.create(rect.left,rect.top);return p},getLocal:function(e){var rect=this.getBoundingClientRect();var p=this.g.point.create((e.x||e.clientX)-rect.left,(e.y||e.clientY)-rect.top);return p},hasFocus:function(){return this.focused},takeFocus:function(){var self=this;if(document.activeElement!==this.focuser){setTimeout(function(){self.focuser.focus()},10)}},beDragging:function(){this.dragging=true;this.disableDocumentElementSelection()},beNotDragging:function(){this.dragging=false;this.enableDocumentElementSelection()},isDragging:function(){return this.dragging},disableDocumentElementSelection:function(){var style=document.body.style;style.cssText=style.cssText+"-webkit-user-select: none"},enableDocumentElementSelection:function(){var style=document.body.style;style.cssText=style.cssText.replace("-webkit-user-select: none","")},setFocusable:function(boolean){if(boolean===true){this.focuser.style.display=""}else{this.focuser.style.display="none"}},isRightClick:function(e){var isRightMB;e=e||window.event;if("which"in e){isRightMB=e.which===3}else if("button"in e){isRightMB=e.button===2}return isRightMB}})})();</script></polymer-element><polymer-element name="fin-vampire-bar" attributes="" assetpath="/dev/fin-vampire-bar/"><template><style>.scroll-bar{width:13px;position:absolute;top:0;bottom:0;background-color:#E7E7E7;border:1px solid #DDD}.scroll-bar-gutter{position:absolute;top:0;bottom:0;right:0;left:0;margin-top:15px;margin-bottom:35px;border-radius:4px}.scroll-bar.horizontal{height:13px;width:100%;position:absolute;left:0;right:100%;top:100%}.horizontal .scroll-bar-gutter{position:absolute;top:0;bottom:0;right:0;left:0;margin-top:0;margin-bottom:0;margin-left:15px;margin-right:34px}.scroll-bar-up{position:absolute;top:1px;left:1px;width:12px;height:12px;background-color:#B6B6B6;border-radius:4px;-o-transition:background-color .1s ease-in;-ms-transition:background-color .1s ease-in;-moz-transition:background-color .1s ease-in;-webkit-transition:background-color .1s ease-in;transition:background-color .1s ease-in}.scroll-bar.horizontal .scroll-bar-up{position:absolute;top:1px;right:1px;left:auto;width:12px;height:12px}.scroll-bar-thumb{background-color:#B6B6B6;width:8px;height:20px;top:0;left:3px;position:absolute;border-radius:6px;-o-transition:background-color .1s ease-in;-ms-transition:background-color .1s ease-in;-moz-transition:background-color .1s ease-in;-webkit-transition:background-color .1s ease-in;transition:background-color .1s ease-in}.scroll-bar-thumb:hover,.scroll-bar-up:hover,.scroll-bar-down:hover{background-color:#4E4E4E}.scroll-bar.horizontal .scroll-bar-thumb{height:8px;width:20px;left:0;top:3px;position:absolute}.scroll-bar-down{position:absolute;bottom:1px;left:1px;width:12px;height:12px;background-color:#B6B6B6;border-radius:4px;-o-transition:background-color .1s ease-in;-ms-transition:background-color .1s ease-in;-moz-transition:background-color .1s ease-in;-webkit-transition:background-color .1s ease-in;transition:background-color .1s ease-in}.scroll-bar.horizontal .scroll-bar-down{position:absolute;top:1px;left:1px;width:12px;height:12px}</style><div class="scroll-bar"><div on-holdpulse="{{onUpHold}}" on-tap="{{onUpClick}}" class="scroll-bar-up"></div><div on-holdpulse="{{onGutterHold}}" on-tap="{{onGutterClick}}" class="scroll-bar-gutter"><div class="scroll-bar-thumb" draggable="false"></div></div><div on-holdpulse="{{onDownHold}}" on-tap="{{onDownClick}}" class="scroll-bar-down"></div></div></template><script>"use strict";(function(){var noop=function(){};var throttle=function(func,wait,options){var context,args,result;var timeout=null;var previous=0;if(!options){options={}}var later=function(){previous=options.leading===false?0:Date.now();timeout=null;result=func.apply(context,args);if(!timeout){context=args=null}};return function(){var now=Date.now();if(!previous&&options.leading===false){previous=now}var remaining=wait-(now-previous);context=this;args=arguments;if(remaining<=0||remaining>wait){clearTimeout(timeout);timeout=null;previous=now;result=func.apply(context,args);if(!timeout){context=args=null}}else if(!timeout&&options.trailing!==false){timeout=setTimeout(later,remaining)}return result}};Polymer("fin-vampire-bar",{setRangeAdapter:function(rangeAdapter){var that=this;that.rangeAdapter=rangeAdapter;if(that.thumb){that.thumb.rangeAdapter=rangeAdapter}rangeAdapter.valueChanged=function(){var value=rangeAdapter.getValue();if(value||value===0){try{that.supressUpdates=true;that.moveToPercent(value)}finally{that.supressUpdates=false}}}},offset:0,attached:function(){var that=this;this.bar=this.shadowRoot.querySelector(".scroll-bar");this.thumb=this.shadowRoot.querySelector(".scroll-bar-thumb");this.gutter=this.shadowRoot.querySelector(".scroll-bar-gutter");this.stepUp=this.shadowRoot.querySelector(".scroll-bar-up");this.stepDown=this.shadowRoot.querySelector(".scroll-bar-down");this.configureOrientation();that.isScrolling=false;that.attachThumbMouseDown().attachThumbMouseMove().attachThumbMouseUp()},throttledWheelEvent:throttle(function(event){var that=this;var directionXY=that.orientation.toUpperCase(),styleProperty=directionXY==="Y"?"top":"left",rangeStop=that.rangeAdapter.rangeStop(),currentPercent=that.thumb.style&&that.thumb.style[styleProperty]&&parseFloat(that.thumb.style[styleProperty])||0,direction=event["delta"+directionXY]>0?1:-1,currentPercentAsRows=Math.round(that.rangeAdapter.rangeStop()*currentPercent),oneMoreRow=Math.round(currentPercentAsRows+1*direction),ranged=oneMoreRow/rangeStop/100;ranged=ranged>1?1:ranged;ranged=ranged<0?0:ranged;that.rangeAdapter.setValue(ranged)},30),attachWheelEvent:function(){var that=this;document.addEventListener("wheel",function(event){event.preventDefault();that.throttledWheelEvent(event)});return that},attachThumbMouseDown:function(){var that=this;that.thumb.addEventListener("mousedown",function(event){noop(event);that.isScrolling=true;var direction=that.orientation==="y"?"top":"left";var distanceFromEdge=that.gutter.getBoundingClientRect()[direction];if(that.orientation==="y"){that.offset=distanceFromEdge+11}else{that.offset=distanceFromEdge+11}});return that},attachThumbMouseMove:function(){var that=this;document.addEventListener("mousemove",function(event){if(that.isScrolling){var offset=0;if(that.orientation==="y"){offset=event.y||event.clientY}else{offset=event.x||event.clientX}that.moveThumb(offset)}});return that},attachThumbMouseUp:function(){var that=this;document.addEventListener("mouseup",function(){if(that.isScrolling){that.offset=0;that.isScrolling=false}});return that},onUpClick:function(){console.log("up click")},onUpHold:function(event){event.preventTap();console.log("hold me up..",Date.now())},onDownClick:function(){console.log("down click")},onDownHold:function(event){event.preventTap();console.log("hold me down ..",Date.now())},onGutterClick:function(){console.log("click")},onGutterHold:function(event){event.preventTap();console.log("hold me in the gutter..",Date.now())},moveThumb:function(pageLocation){var that=this,direction=this.orientation==="y"?"top":"left",maxScroll=that.getMaxScroll(),offBy=pageLocation-that.offset;offBy=offBy<0?0:offBy;offBy=offBy/maxScroll;offBy=offBy>1?1:offBy;offBy=offBy*100;that.thumb.style[direction]=offBy+"%";if(that.rangeAdapter){if(that.supressUpdates){return}that.rangeAdapter.setValue(offBy/100)}},moveToPercent:function(percent){var that=this;if(!that.isScrolling){that.moveThumb(percent*this.getMaxScroll())}},setValueUpdatedCallback:function(callback){this.valueUpdatedCallback=callback},setOrientation:function(orientation){this.orientation=orientation},getMaxScroll:function(){var direction=this.orientation==="y"?"clientHeight":"clientWidth";return this.gutter[direction]},configureOrientation:function(){var orientation="y";if("horizontal"in this.attributes){orientation="x";this.bar.classList.add("horizontal")}this.setOrientation(orientation)},tickle:function(){this.rangeAdapter.setValue(this.lastPercent)},lastPercent:0,createRangeAdapter:function(subject,userConfig){var config=userConfig||{step:1,page:40,rangeStart:0,rangeStop:100},that={};that.valueObj={value:null};that.subjectChanged=function(){that.valueObj.value=that.computeNormalizedValue();that.valueChanged()};that.rangeStart=function(value){if(value===undefined){return config.rangeStart}};that.rangeStop=function(value){if(value===undefined){return config.rangeStop}};that.page=function(value){if(value===undefined){return config.page}};that.setValue=function(newValue){if(typeof newValue!=="number"){return}var deNormalized=Math.floor(newValue*(config.rangeStop-config.rangeStart)+config.rangeStart);subject.setValue(deNormalized);that.valueObj.value=newValue;that.valueChanged()};that.computeNormalizedValue=function(){var value=(subject.getValue()-config.rangeStart)/(config.rangeStop-config.rangeStart);return value};that.getValue=function(){return that.valueObj.value};that.valueChanged=function(){};return that}})})();</script></polymer-element><polymer-element name="fin-hypergrid-dnd-list" attributes="label list" assetpath="/dev/fin-hypergrid-dnd-list/"><template><style type="text/css">:host{display:block;position:relative}*{user-select:none;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none}.dnd-header{z-index:1;font-family:Roboto,sans-serif;text-transform:capitalize;position:relative;display:flex;flex-direction:row;justify-content:center;align-items:center;width:90%;height:46px;background-color:#00796b;color:#fff;margin-left:5%;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);overflow:hidden}.list{background-color:#fff;position:absolute;top:46px;left:5%;right:5%;overflow-y:auto;list-style-type:none;margin:0;padding-top:0;padding-left:0;bottom:10%;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24)}.controls{position:absolute;display:flex;flex-direction:row;justify-content:center;align-items:center;width:100%;bottom:0;height:10%}.level1{opacity:.7;z-index:2;position:absolute;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24);-webkit-transform:translate(-2px,-2px);-moz-transform:translate(-2px,-2px);-ms-transform:translate(-2px,-2px);-o-transform:translate(-2px,-2px);transform:translate(-2px,-2px)}.level2{opacity:.7;z-index:2;position:absolute;border:1px solid #e0e0e0;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);-webkit-transform:translate(-4px,-4px);-moz-transform:translate(-4px,-4px);-ms-transform:translate(-4px,-4px);-o-transform:translate(-4px,-4px);transform:translate(-4px,-4px)}.level3{opacity:.7;z-index:2;position:absolute;border:1px solid #e0e0e0;box-shadow:0 10px 20px rgba(0,0,0,.19),0 6px 6px rgba(0,0,0,.23);-webkit-transform:translate(-6px,-6px);-moz-transform:translate(-6px,-6px);-ms-transform:translate(-6px,-6px);-o-transform:translate(-6px,-6px);transform:translate(-6px,-6px)}.level4{opacity:.7;z-index:2;position:absolute;border:1px solid #e0e0e0;box-shadow:0 14px 28px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.22);-webkit-transform:translate(-8px,-8px);-moz-transform:translate(-8px,-8px);-ms-transform:translate(-8px,-8px);-o-transform:translate(-8px,-8px);transform:translate(-8px,-8px)}.level5{opacity:.7;z-index:2;position:absolute;border:1px solid #e0e0e0;box-shadow:0 19px 38px rgba(0,0,0,.3),0 15px 12px rgba(0,0,0,.22);-webkit-transform:translate(-10px,-10px);-moz-transform:translate(-10px,-10px);-ms-transform:translate(-10px,-10px);-o-transform:translate(-10px,-10px);transform:translate(-10px,-10px)}.spacer{visibility:hidden;overflow:hidden}.transition{transition:height 200ms ease-in}.beSmall{height:0}.beBig{height:51px}</style><div class="font-special toolbar dnd-header">{{title}}</div><ul id="ulist" class="font-special list" touch-action="pan-y" size="3"><template repeat="{{item, i in list}}"><li value="{{idAdapter(i)}}_spacer" class="spacer beSmall"></li><li value="{{idAdapter(i)}}" class="item" style="-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;user-select:none;white-space:nowrap;line-height: 46px;list-style-type: none;font-family: 'Roboto', sans-serif;border-bottom: 1px solid #e0e0e0;text-transform: capitalize;cursor: move;background-color: white;color: black;"><span style="font-size: 30px;color: #b6b6b6;margin: 8px;position: relative;top: 2px;cursor: move;">
⬤
</span>
{{labelAdapter(item)}}
</li></template><li value="last_spacer" class="spacer beSmall"></li></ul></template><script>"use strict";(function(){var noop=function(){};Polymer("fin-hypergrid-dnd-list",{label:"label",id:"id",attached:function(){this.title=this.title||"title";this.list=this.list||[{id:0,label:"list item zero"},{id:1,label:"list item one"},{id:2,label:"list item two"},{id:3,label:"list item three"},{id:4,label:"list item four"},{id:5,label:"list item five"},{id:6,label:"list item six"},{id:7,label:"list item seven"},{id:8,label:"list item eight"},{id:9,label:"list item nine"}];var parent=this.parentElement;var self=this;parent.oncontextmenu=function(){return false};PolymerGestures.addEventListener(this.$.ulist,"trackstart",function(e){var li=e.path[0];if(li.nodeName!=="LI"){return}self.initiateItemDrag(li,e)})},getRowHeights:function(){var bounds=this.$.ulist.getBoundingClientRect();var items=this.$.ulist.querySelectorAll("li.item").array();if(items.length===0){return[0]}var boundries=items.map(function(e){return e.getBoundingClientRect().top-bounds.top});var last=items[items.length-1];boundries.push(boundries[boundries.length-1]+last.getBoundingClientRect().height);boundries[0]=0;return boundries},labelAdapter:function(item){if(typeof item==="object"){return item[this.label]}return item},idAdapter:function(item){if(typeof item==="object"){return item[this.id]}return item},handleDragHoverEnter:function(dragged,x,y){noop(dragged,x,y)},handleDragHoverExit:function(dragged,x,y){noop(dragged,x,y);this.correctItemState()},handleDragOver:function(dragged,x,y){var self=this;var bounds=this.$.ulist.getBoundingClientRect();var boundries=this.getRowHeights();var localY=y-bounds.top;var minValue=1e6;var minIndex=0;for(var i=0;i<boundries.length;i++){var distance=Math.abs(localY-boundries[i]);if(distance<minValue){minIndex=i;minValue=distance}}var overRow=minIndex;if(this.overRow!==overRow){if(this.isTransition){return}this.isTransition=true;var spacers=this.$.ulist.querySelectorAll("li.spacer");if(this.overRow||this.overRow===0){var previous=this.$.ulist.querySelector("li.spacer.beBig");if(previous){previous.classList.add("transition");requestAnimationFrame(function(){previous.classList.remove("beBig");previous.classList.add("beSmall")})}}this.overRow=overRow;var spacer=spacers[overRow];spacer.classList.add("transition");requestAnimationFrame(function(){spacer.classList.remove("beSmall");spacer.classList.add("beBig");setTimeout(function(){spacer.classList.remove("transition");self.isTransition=false},210)})}},handleDrag:function(e){if(!this.dragFodder){return}var dragFodderRect=this.dragFodder.getBoundingClientRect();var cxo=dragFodderRect.width/2;var cyo=dragFodderRect.height/2;var globalX=(e.x||e.clientX)-this.dragEventStart[0];var globalY=(e.y||e.clientY)-this.dragEventStart[1];this.setCssLocation(this.dragFodder.style,globalX,globalY);this.dragFodder.style.display="none";var dropTarget=document.elementFromPoint(globalX+cxo,globalY+cyo);this.dragFodder.style.display="";if(dropTarget&&dropTarget.handleDragOver){if(this.currentDropTarget!==dropTarget){if(!dropTarget.canDropItem(this.list,dropTarget.list,this.dragFodder.sourceIndex,this.dragFodder.dragItem,e)){return}if(this.currentDropTarget){this.currentDropTarget.handleDragHoverExit(this.dragFodder,globalX+cxo,globalY+cyo)}this.currentDropTarget=dropTarget;this.currentDropTarget.handleDragHoverEnter(this.dragFodder,globalX+cxo,globalY+cyo)}dropTarget.handleDragOver(this.dragFodder,globalX+cxo,globalY+cyo)}},handleDrop:function(e){noop(e);var dropTarget=this.currentDropTarget;var dragFodder=this.dragFodder;dropTarget.listItemDropped(dragFodder)},listItemDropped:function(listItem){var self=this;var dropSpacer=this.$.ulist.querySelector("li.spacer.beBig");var items=this.$.ulist.querySelectorAll("li").array();var sourceItem=listItem.dragItem;var insertIndex=items.indexOf(dropSpacer)/2;var targetRect=dropSpacer.getBoundingClientRect();var targetTop=targetRect.top;var targetLeft=targetRect.left;listItem.style.webkitTransition="-webkit-transform 150ms ease-in";listItem.style.MozTransition="-moz-transform 150ms ease-in";listItem.style.msTransition="-ms-transform 150ms ease-in";listItem.style.oTransition="-o-transform 150ms ease-in";listItem.style.transition="transform 150ms ease-in";requestAnimationFrame(function(){self.setCssLocation(listItem.style,targetLeft,targetTop);setTimeout(function(){listItem.parentElement.removeChild(listItem);dropSpacer.classList.remove("beBig");dropSpacer.classList.add("beSmall");self.list.splice(insertIndex,0,sourceItem);self.overRow=undefined},170)})},canDragItem:function(list,item,index,e){noop(list,item,index,e);return true},canDropItem:function(sourceList,myList,sourceIndex,item,e){noop(sourceList,myList,sourceIndex,item,e);return true},initiateItemDrag:function(li,e){li.dragSource=this;li.dragIndex=parseInt(li.getAttribute("value"));li.dragItem=this.list[li.dragIndex];if(!this.canDragItem(this.list,li.dragItem,li.dragIndex,e)){return}this.overRow=undefined;var transitions=this.$.ulist.querySelectorAll(".transition").array();transitions.forEach(function(e){e.classList.remove("transition")});e.preventDefault();var goAwayer=li.nextElementSibling;var bounds=li.getBoundingClientRect();var self=this;var parent=this.$.ulist;var parentBounds=parent.getBoundingClientRect();li.style.width=parentBounds.width+"px";this.list.splice(li.dragIndex,1);this.dragFodder=li;this.dragEventStart=[(e.x||e.clientX)-bounds.left,(e.y||e.clientY)-bounds.top];goAwayer.classList.add("beBig");goAwayer.classList.remove("beSmall");document.body.appendChild(li);PolymerGestures.addEventListener(li,"track",function(e){self.handleDrag(e)});PolymerGestures.addEventListener(li,"trackend",function(e){self.handleDrop(e)});requestAnimationFrame(function(){setTimeout(function(){goAwayer.classList.remove("transition")},210)})},setCssLocation:function(style,x,y){style.position="fixed";style.zIndex=10;style.top=0;style.left=0;style.webkitTransform="translate("+x+"px, "+y+"px)";style.MozTransform="translate("+x+"px, "+y+"px)";style.mmsTransform="translate("+x+"px, "+y+"px)";style.oTransform="translate("+x+"px, "+y+"px)";style.transform="translate("+x+"px, "+y+"px)";style.border="1px solid #bbbbbb";style.boxShadow="0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)"},correctItemState:function(){var self=this;var spacer=this.$.ulist.querySelector("li.spacer.beBig");if(spacer){requestAnimationFrame(function(){spacer.classList.remove("beBig");spacer.classList.add("beSmall");spacer.classList.add("transition");setTimeout(function(){spacer.classList.remove("transition");self.overRow=undefined},210)})}}})})();</script></polymer-element><polymer-element name="fin-canvas-component" class="fin-canvas-component" attributes="layoutProperties" assetpath="/dev/fin-canvas/"><template></template><script>"use strict";(function(){Polymer("fin-canvas-component",{ready:function(){this.readyInit()},readyInit:function(){this.g=document.createElement("fin-rectangle");this.parent=null;this.bounds=this.g.rectangle.create(0,0,0,0);this.color=this.color||"black";this.backgroundColor=null;this.layoutProperties=this.layoutProperties||[0,0,1,0,1,0,0,0];if(typeof this.layoutProperties==="string"){this.layoutProperties=JSON.parse(this.layoutProperties)}},setBounds:function(rectangle){this.bounds=rectangle},getBounds:function(){return this.bounds},_paint:function(gc){try{gc.save();gc.translate(this.bounds.left(),this.bounds.top());var bgColor=this.getBackgroundColor();if(bgColor){var rect=this.getBounds();gc.beginPath();gc.fillStyle=bgColor;gc.fillRect(0,0,rect.width(),rect.height());gc.stroke()}this.paint(gc)}finally{gc.restore()}},paint:function(){},getBackgroundColor:function(){return this.backgroundColor},setBackgroundColor:function(colorValue){this.backgroundColor=colorValue},repaint:function(){if(this.parent){this.parent.repaint()}},setParent:function(newParent){this.parent=newParent},getLayoutProperties:function(){return this.layoutProperties},setLayoutProperties:function(properties){this.layoutProperties=properties},getComponent:function(){var comp=this.children[0];return comp}})})();</script></polymer-element><polymer-element name="fin-hypergrid-renderer" extends="fin-canvas-component" assetpath="/dev/fin-hypergrid/polymer/html/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";var noop=function(){};var fontData={};var textWidthCache=new SimpleLRU(1e4);var config={getTextWidth:function(gc,string){if(string===null||string===undefined){return 0}string=string+"";if(string.length===0){return 0}var key=gc.font+string;var width=textWidthCache.get(key);if(!width){width=gc.measureText(string).width;textWidthCache.set(key,width)}return width},getTextHeight:function(font){var result=fontData[font];if(result){return result}result={};var text=document.createElement("span");text.textContent="Hg";text.style.font=font;var block=document.createElement("div");block.style.display="inline-block";block.style.width="1px";block.style.height="0px";var div=document.createElement("div");div.appendChild(text);div.appendChild(block);div.style.position="absolute";document.body.appendChild(div);try{block.style.verticalAlign="baseline";var blockRect=block.getBoundingClientRect();var textRect=text.getBoundingClientRect();result.ascent=blockRect.top-textRect.top;block.style.verticalAlign="bottom";result.height=blockRect.top-textRect.top;result.descent=result.height-result.ascent}finally{document.body.removeChild(div)}if(result.height!==0){fontData[font]=result}return result}};(function(){var cellConfig=function(x,y,value,fgColor,bgColor,fgSelColor,bgSelColor,font,isSelected,isColumnHovered,isRowHovered,halign,hoffset,voffset,properties){config.x=x;config.y=y;config.value=value;config.fgColor=fgColor;config.bgColor=undefined;config.fgSelColor=fgSelColor;config.bgSelColor=bgSelColor;config.font=font;config.isSelected=isSelected;config.isColumnHovered=isColumnHovered||false;config.isRowHovered=isRowHovered||false;config.halign=halign||"center";config.hoffset=hoffset;config.voffset=voffset;config.properties=properties;return config};Polymer("fin-hypergrid-renderer",{attached:function(){this.readyInit();this.renderedColumnWidths=[0];this.renderedColumnMinWidths=[];this.renderedFixedColumnMinWidths=[];this.renderedHeight=0;this.renderedRowHeights=[0];this.renderedColumns=[];this.renderedRows=[];this.insertionBounds=[]},resolveProperty:function(key){return this.grid.resolveProperty(key)},cellConfig:function(x,y,value,fgColor,bgColor,fgSelColor,bgSelColor,font,isSelected,isColumnHovered,isRowHovered,halign,hoffset,voffset){var config=cellConfig(x,y,value,fgColor,bgColor,fgSelColor,bgSelColor,font,isSelected,isColumnHovered,isRowHovered,halign,hoffset,voffset,this.grid.lnfProperties);return config},getGrid:function(){return this.grid},setGrid:function(grid){this.grid=grid},paint:function(gc){if(!this.grid){return}this.renderGrid(gc);this.getGrid().gridRenderedNotification()},getViewableRows:function(){return this.renderedRows.length},getVisibleRows:function(){return this.renderedRows},getViewableColumns:function(){return this.renderedColumns.length},getVisibleColumns:function(){return this.renderedColumns},overColumnDivider:function(x){x=Math.round(x);var whichCol=this.renderedColumnWidths.indexOf(x-1);if(whichCol<0){whichCol=this.renderedColumnWidths.indexOf(x)}if(whichCol<0){whichCol=this.renderedColumnWidths.indexOf(x-2)}if(whichCol<0){whichCol=this.renderedColumnWidths.indexOf(x+1)}if(whichCol<0){whichCol=this.renderedColumnWidths.indexOf(x-3)}return whichCol},overRowDivider:function(y){y=Math.round(y);var which=this.renderedRowHeights.indexOf(y+1);if(which<0){which=this.renderedRowHeights.indexOf(y)}if(which<0){which=this.renderedRowHeights.indexOf(y-1)}return which},getBoundsOfCell:function(cell){return this._getBoundsOfCell(cell.x,cell.y)},_getBoundsOfCell:function(x,y){var ox=this.renderedColumnWidths[x],oy=this.renderedRowHeights[y],cx=this.renderedColumnWidths[x+1],cy=this.renderedRowHeights[y+1],ex=cx-ox,ey=cy-oy;var bounds=this.g.rectangle.create(ox,oy,ex,ey);return bounds},getColumnFromPixelX:function(pixelX){pixelX=pixelX-this.getBehavior().getFixedColumnsWidth();var width=0;var c;for(c=0;c<this.insertionBounds.length;c++){width=this.insertionBounds[c];if(pixelX<width){return c}}return c},getGridCellFromMousePoint:function(point){var width=0;var height=0;var x,y;var c,r;var previous=0;for(c=1;c<this.renderedColumnWidths.length;c++){width=this.renderedColumnWidths[c];if(point.x<width){x=Math.max(0,point.x-previous-2);break}previous=width}c--;previous=0;for(r=1;r<this.renderedRowHeights.length;r++){height=this.renderedRowHeights[r];if(point.y<height){y=Math.max(0,point.y-previous-2);break}previous=height}r--;if(point.x<0){c=-1}if(point.y<0){r=-1}return{gridCell:this.g.point.create(c,r),mousePoint:this.g.point.create(x,y)}},isColumnVisible:function(colIndex){var isVisible=this.renderedColumns.indexOf(colIndex)!==-1;return isVisible},getFinalVisableColumnBoundry:function(){var isMaxX=this.isLastColumnVisible();var chop=isMaxX?2:1;var colWall=this.renderedColumnWidths[this.renderedColumnWidths.length-chop];var result=Math.min(colWall,this.getBounds().width()-200);return result},isRowVisible:function(rowIndex){var isVisible=this.renderedRows.indexOf(rowIndex)!==-1;return isVisible},isSelected:function(x,y){return this.getGrid().isSelected(x,y)},renderGrid:function(gc){var offsetX=this.getBehavior().getFixedColumnsWidth();var offsetY=this.getBehavior().getFixedRowsHeight();gc.beginPath();this.paintTopLeft(gc,offsetX,offsetY);this.paintHeaders(gc,0,0);this.paintCells(gc,offsetX,offsetY);this.paintGridlines(gc,offsetX,offsetY);this.blankOutOverflow(gc);this.renderOverrides(gc);gc.closePath()},resetTextWidthCache:function(){textWidthCache=new SimpleLRU(1e4)},blankOutOverflow:function(gc){var isMaxX=this.isLastColumnVisible();var chop=isMaxX?2:1;var x=this.renderedColumnWidths[this.renderedColumnWidths.length-chop];var bounds=this.getGrid().getBoundingClientRect();var width=bounds.width-x;var height=bounds.height;gc.fillStyle=this.resolveProperty("backgroundColor2");gc.fillRect(x,0,width,height)},renderOverrides:function(gc){var grid=this.getGrid();var cache=grid.renderOverridesCache;for(var key in cache){if(cache.hasOwnProperty(key)){var override=cache[key];if(override){this.renderOverride(gc,override)}}}},renderOverride:function(gc,override){var behavior=this.getBehavior();var columnStarts=this.renderedColumnWidths;var fixedColCount=behavior.getFixedColumnCount();var hdpiRatio=override.hdpiratio;var startX=hdpiRatio*columnStarts[override.columnIndex+fixedColCount];var width=override.width;var height=override.height;var targetCTX=override.ctx;var imgData=gc.getImageData(startX,0,width*hdpiRatio,height*hdpiRatio);targetCTX.putImageData(imgData,0,0);gc.fillStyle=this.resolveProperty("backgroundColor2");gc.fillRect(Math.round(startX/hdpiRatio),0,width,height)},paintGridlines:function(gc,offsetX,offsetY){var drawThemH=this.resolveProperty("gridLinesH");var drawThemV=this.resolveProperty("gridLinesV");var behavior=this.getBehavior();var lineColor=this.resolveProperty("lineColor");var numColumns=this.getColumnCount();var numRows=behavior.getRowCount();var numFixedColumns=behavior.getFixedColumnCount();var numFixedRows=behavior.getFixedRowCount();var fixedColumnsWidth=behavior.getFixedColumnsWidth();var fixedRowsHeight=behavior.getFixedRowsHeight();this.renderedColumnWidths=[0];this.renderedHeight=0;this.renderedRowHeights=[0];this.renderedColumns=[];this.renderedRows=[];this.insertionBounds=[];var insertionBoundsCursor=0;var scrollTop=this.getScrollTop();var scrollLeft=this.getScrollLeft();var viewWidth=this.getBounds().width()-200;var viewHeight=this.getBounds().height();gc.beginPath();gc.strokeStyle=lineColor;gc.lineWidth=1;var c,r,x,y,width,height;gc.moveTo(0,0);y=0;for(r=0;r<numFixedRows;r++){height=this.getFixedRowHeight(r);y=y+height;this.renderedRowHeights.push(Math.round(y));if(drawThemH){gc.moveTo(fixedColumnsWidth,y+.5);gc.lineTo(viewWidth,y+.5)}}gc.moveTo(0,0);x=0;for(c=0;c<numFixedColumns;c++){width=this.getFixedColumnWidth(c);x=x+width;this.renderedColumnWidths.push(Math.round(x));if(drawThemV){gc.moveTo(x+.5,fixedRowsHeight);gc.lineTo(x+.5,viewHeight)}}gc.moveTo(0,0);x=offsetX;var previousInsertionBoundsCursorValue=0;for(c=0;c<numColumns+1;c++){width=this.getColumnWidth(c+scrollLeft);this.renderedColumns.push(c+scrollLeft);if(x>viewWidth||numColumns<scrollLeft+c){this.renderedColumns.length=Math.max(0,this.renderedColumns.length-2);break}if(drawThemV){gc.moveTo(x+.5,0);gc.lineTo(x+.5,viewHeight)}x=x+width;this.renderedColumnWidths.push(Math.round(x));insertionBoundsCursor=insertionBoundsCursor+Math.round(width/2)+previousInsertionBoundsCursorValue;this.insertionBounds.push(insertionBoundsCursor);previousInsertionBoundsCursorValue=Math.round(width/2)}gc.moveTo(0,0);y=offsetY;for(r=0;r<numRows;r++){height=this.getRowHeight(r+scrollTop);this.renderedRows.push(r+scrollTop);if(y>viewHeight||numRows<scrollTop+r){this.renderedRows.length=Math.max(0,this.renderedRows.length-2);break}if(drawThemH){gc.moveTo(0,y+.5);gc.lineTo(viewWidth,y+.5)}y=y+height;this.renderedHeight=this.renderedHeight+height;this.renderedRowHeights.push(Math.round(y))}gc.stroke();gc.closePath()},paintHeaders:function(ctx,offsetX,offsetY){this.paintFixedRows(ctx,offsetX+this.getBehavior().getFixedColumnsWidth(),offsetY,this.getColumnCount(),this.getBehavior().getFixedRowCount());this.paintFixedColumns(ctx,offsetX,offsetY+this.getBehavior().getFixedRowsHeight(),this.getBehavior().getFixedColumnCount(),this.getBehavior().getRowCount())},isHovered:function(x,y){return this.grid.isHovered(x,y)},isRowHovered:function(y){return this.grid.isRowHovered(y)},isColumnHovered:function(x){return this.grid.isColumnHovered(x)},paintFixedRows:function(gc,offsetX,offsetY,numColumns,numRows){var behavior=this.getBehavior();var x=offsetX;var scrollLeft=this.getScrollLeft();var font=this.resolveProperty("fixedRowFont");var voffset=this.resolveProperty("voffset");var hoffset=this.resolveProperty("hoffset");var fgColor=this.resolveProperty("fixedRowColor");var bgColor=this.resolveProperty("fixedRowBackgroundColor");var fgSelColor=this.resolveProperty("fixedRowFGSelColor");var bgSelColor=this.resolveProperty("fixedRowBGSelColor");var cellProvider=this.getGrid().getCellProvider();var viewWidth=this.getBounds().width()-200;var viewHeight=behavior.getFixedRowsHeight();for(var c=0;c<numColumns;c++){var width=this.getColumnWidth(c+scrollLeft);if(x>viewWidth||numColumns<=scrollLeft+c){return}var isSelected=this.isFixedRowCellSelected(c+scrollLeft);var y=offsetY;gc.fillStyle=bgColor;gc.fillRect(x,y,x+width,viewHeight-y);this.renderedColumnMinWidths[c+scrollLeft]=0;for(var r=0;r<numRows;r++){var height=this.getFixedRowHeight(r);var align=behavior._getFixedRowAlignment(c+scrollLeft,r);var value=behavior._getFixedRowValue(c+scrollLeft,r);var isColumnHovered=this.isColumnHovered(c);var isRowHovered=false;var translatedX=behavior.translateColumnIndex(c+scrollLeft);var config=this.cellConfig(translatedX,r,value,fgColor,bgColor,fgSelColor,bgSelColor,font,isSelected,isColumnHovered,isRowHovered,align,hoffset,voffset);var cell=cellProvider.getFixedRowCell(config);config.minWidth=0;behavior.cellFixedRowPrePaintNotification(cell);cell.paint(gc,x,y,width,height);this.renderedColumnMinWidths[c+scrollLeft]=Math.max(config.minWidth||0,this.renderedColumnMinWidths[c+scrollLeft]);if(behavior.highlightCellOnHover(isColumnHovered,isRowHovered)){gc.beginPath();var pre=gc.globalAlpha;gc.globalAlpha=.2;gc.fillRect(x+2,y+2,width-3,height-3);gc.globalAlpha=pre;gc.stroke();gc.closePath()}y=y+height}x=x+width}},paintFixedColumns:function(gc,offsetX,offsetY,numColumns,numRows){var behavior=this.getBehavior();var x=offsetX;var font=this.resolveProperty("fixedColumnFont");var voffset=this.resolveProperty("voffset");var hoffset=this.resolveProperty("hoffset");var fgColor=this.resolveProperty("fixedColumnColor");var bgColor=this.resolveProperty("fixedColumnBackgroundColor");var fgSelColor=this.resolveProperty("fixedColumnFGSelColor");var bgSelColor=this.resolveProperty("fixedColumnBGSelColor");var scrollTop=this.getScrollTop();var cellProvider=this.getGrid().getCellProvider();var viewHeight=this.getBounds().height();for(var c=0;c<numColumns;c++){var width=this.getFixedColumnWidth(c);var align=behavior.getFixedColumnAlignment(c);var y=offsetY;gc.fillStyle=bgColor;gc.fillRect(x,y,width,viewHeight-y);for(var r=0;r<numRows;r++){var height=this.getRowHeight(r+scrollTop);var isSelected=this.isFixedColumnCellSelected(r+scrollTop);if(y>viewHeight||numRows<=scrollTop+r){break}var value=behavior.getFixedColumnValue(c,r+scrollTop);var isColumnHovered=false;var isRowHovered=this.isRowHovered(r);var config=this.cellConfig(c,r+scrollTop,value,fgColor,bgColor,fgSelColor,bgSelColor,font,isSelected,isColumnHovered,isRowHovered,align,hoffset,voffset);var cell=cellProvider.getFixedColumnCell(config);config.minWidth=0;behavior.cellFixedColumnPrePaintNotification(cell);cell.paint(gc,x,y,width,height);this.renderedFixedColumnMinWidths[c]=Math.max(config.minWidth||0,this.renderedFixedColumnMinWidths[c]);if(behavior.highlightCellOnHover(isColumnHovered,isRowHovered)){gc.beginPath();var pre=gc.globalAlpha;gc.globalAlpha=.2;gc.fillRect(x+2,y+2,width-3,height-3);gc.globalAlpha=pre;gc.stroke();gc.closePath()}y=y+height}x=x+width}},paintCells:function(gc,offsetX,offsetY){try{gc.save();this._paintCells(gc,offsetX,offsetY)}catch(e){console.error(e)}finally{gc.restore()}},_paintCells:function(gc,offsetX,offsetY){var behavior=this.getBehavior();var numColumns=this.getColumnCount();var numRows=behavior.getRowCount();var x=offsetX;var startY=offsetY;var scrollTop=this.getScrollTop();var scrollLeft=this.getScrollLeft();var cellProvider=this.getGrid().getCellProvider();var font=this.resolveProperty("font");var voffset=this.resolveProperty("voffset");var hoffset=this.resolveProperty("hoffset");var fgColor=this.resolveProperty("color");var bgColor=this.resolveProperty("backgroundColor");var fgSelColor=this.resolveProperty("foregroundSelColor");var bgSelColor=this.resolveProperty("backgroundSelColor");var viewWidth=this.getBounds().width()-200;var viewHeight=this.getBounds().height();for(var c=0;c<numColumns;c++){var width=this.getColumnWidth(c+scrollLeft);if(x>viewWidth||numColumns<=scrollLeft+c){return}var y=startY;var translatedX=behavior.translateColumnIndex(c+scrollLeft);var columnAlign=behavior._getColumnAlignment(c+scrollLeft);var columnProperties=behavior.getColumnProperties(translatedX);var overrideFGColor=columnProperties.fgColor||fgColor;var overrideFont=columnProperties.font||font;gc.fillStyle=columnProperties.bgColor||bgColor;gc.fillRect(x,y,x+width,viewHeight-y);for(var r=0;r<numRows;r++){var isSelected=this.isSelected(c+scrollLeft,r+scrollTop);var height=this.getRowHeight(r+scrollTop);if(y>viewHeight||numRows<=scrollTop+r){break}var value=behavior._getValue(c+scrollLeft,r+scrollTop);var isColumnHovered=this.isColumnHovered(c);var isRowHovered=this.isRowHovered(r);var config=this.cellConfig(translatedX,r+scrollTop,value,overrideFGColor,bgColor,fgSelColor,bgSelColor,overrideFont,isSelected,isColumnHovered,isRowHovered,columnAlign,hoffset,voffset);behavior.cellPrePaintNotification(config);var cell=cellProvider.getCell(config);config.minWidth=0;cell.paint(gc,x,y,width,height);this.renderedColumnMinWidths[c+scrollLeft]=Math.max(config.minWidth||0,this.renderedColumnMinWidths[c+scrollLeft]);if(behavior.highlightCellOnHover(isColumnHovered,isRowHovered)){gc.beginPath();var pre=gc.globalAlpha;gc.globalAlpha=.2;gc.fillRect(x+2,y+2,width-3,height-3);gc.globalAlpha=pre;gc.stroke();gc.closePath()}y=y+height}x=x+width}},paintTopLeft:function(gc,offsetX,offsetY){noop(offsetX,offsetY);try{gc.save();this._paintTopLeft(gc)}finally{gc.restore()}},_paintTopLeft:function(gc){var behavior=this.getBehavior();var numColumns=behavior.getFixedColumnCount();var numRows=behavior.getFixedRowCount();var x=0;var startY=0;var cellProvider=this.getGrid().getCellProvider();var font=this.resolveProperty("topLeftFont");var voffset=this.resolveProperty("voffset");var hoffset=this.resolveProperty("hoffset");var fgColor=this.resolveProperty("topLeftColor");var bgColor=this.resolveProperty("topLeftBackgroundColor");var fgSelColor=this.resolveProperty("topLeftFGSelColor");var bgSelColor=this.resolveProperty("topLeftBGSelColor");var viewWidth=behavior.getFixedColumnsWidth();var viewHeight=behavior.getFixedRowsHeight();for(var c=0;c<numColumns;c++){var width=this.getFixedColumnWidth(c);if(x>viewWidth||numColumns<=c){return}var y=startY;var r=0;var columnAlign=behavior.getTopLeftAlignment(c,r);gc.fillStyle=bgColor;gc.fillRect(x,y,x+width,viewHeight-y);this.renderedFixedColumnMinWidths[c]=0;for(;r<numRows;r++){var height=this.getFixedRowHeight(r);if(y>viewHeight||numRows<=r){break}var value=behavior.getTopLeftValue(c,r);var isColumnHovered=this.isHovered(c);var isRowHovered=this.isHovered(r);var config=this.cellConfig(x,r,value,fgColor,bgColor,fgSelColor,bgSelColor,font,false,isColumnHovered,isRowHovered,columnAlign,hoffset,voffset);var cell=cellProvider.getTopLeftCell(config);config.minWidth=0;behavior.cellTopLeftPrePaintNotification(cell);cell.paint(gc,x,y,width,height);var minWidth=config.minWidth;this.renderedFixedColumnMinWidths[c]=Math.max(minWidth||0,this.renderedFixedColumnMinWidths[c]);y=y+height}x=x+width}},isFixedRowCellSelected:function(colIndex){return this.getGrid().isFixedRowCellSelected(colIndex)},isFixedColumnCellSelected:function(rowIndex){return this.getGrid().isFixedColumnCellSelected(rowIndex)},getScrollTop:function(){var st=this.getGrid().getVScrollValue();return st},getScrollLeft:function(){var st=this.getGrid().getHScrollValue();return st},getBehavior:function(){return this.getGrid().getBehavior()},getFixedRowHeight:function(rowIndex){var height=this.getBehavior().getFixedRowHeight(rowIndex);return height},getRowHeight:function(rowIndex){var height=this.getBehavior().getRowHeight(rowIndex);return height},getColumnWidth:function(columnIndex){var width=this.getBehavior()._getColumnWidth(columnIndex);return width},getFixedColumnWidth:function(columnIndex){var height=this.getBehavior().getFixedColumnWidth(columnIndex);return height},isLastColumnVisible:function(){var lastColumnIndex=this.getColumnCount()-1;var isMax=this.renderedColumns.indexOf(lastColumnIndex)!==-1;return isMax},getColumnCount:function(){var count=this.getGrid().getColumnCount();return count},getRenderedWidth:function(index){return this.renderedColumnWidths[index]},getRenderedHeight:function(index){return this.renderedRowHeights[index]},getCanvas:function(){return this.getGrid().getCanvas()},repaintCell:function(x,y){if(this.isDraggingColumn()){return}var self=this;var behavior=this.getBehavior();var numFixedCols=behavior.getFixedColumnCount();var numFixedRows=behavior.getFixedRowCount();var scrollLeft=this.getScrollLeft();var unTranslatedX=behavior.unTranslateColumnIndex(x+scrollLeft);if(!this.isRowVisible(y)||!this.isColumnVisible(unTranslatedX)){return}var ox=this.renderedColumnWidths[numFixedCols+unTranslatedX],oy=this.renderedRowHeights[numFixedRows+y],cx=this.renderedColumnWidths[numFixedCols+unTranslatedX+1],cy=this.renderedRowHeights[numFixedRows+y+1],ex=cx-ox,ey=cy-oy;var func=function(gc){self._repaintCell(gc,x,unTranslatedX,y,ox,oy,ex,ey)};this.getCanvas().safePaintImmediately(func)},_repaintCell:function(ctx,translatedX,x,y,startX,startY,width,height){ctx.rect(startX+1,startY+1,width,height);ctx.clip();var behavior=this.getBehavior();var scrollTop=this.getScrollTop();var scrollLeft=this.getScrollLeft();var cellProvider=this.getGrid().getCellProvider();var font=this.resolveProperty("font");var voffset=this.resolveProperty("voffset");var hoffset=this.resolveProperty("hoffset");var fgColor=this.resolveProperty("color");var bgColor=this.resolveProperty("backgroundColor");var fgSelColor=this.resolveProperty("foregroundSelColor");var bgSelColor=this.resolveProperty("backgroundSelColor");var columnAlign=behavior._getColumnAlignment(translatedX);var columnProperties=behavior.getColumnProperties(translatedX);var overrideFGColor=columnProperties.fgColor||fgColor;var overrideFont=columnProperties.font||font;ctx.fillStyle=columnProperties.bgColor||bgColor;ctx.fillRect(startX,startY,width,height);var isSelected=this.isSelected(x+scrollLeft,y+scrollTop);var value=behavior._getValue(x+scrollLeft,y+scrollTop);var isColumnHovered=this.isHovered(x,y);var isRowHovered=this.isHovered(x,y);var config=this.cellConfig(translatedX,y+scrollTop,value,overrideFGColor,bgColor,fgSelColor,bgSelColor,overrideFont,isSelected,isColumnHovered,isRowHovered,columnAlign,hoffset,voffset);behavior.cellPrePaintNotification(config);var cell=cellProvider.getCell(config);cell.paint(ctx,startX,startY,width,height)},isDraggingColumn:function(){return this.getGrid().isDraggingColumn()},getPageUpRow:function(){if(this.renderedRowHeights.length===0){return}var behavior=this.getBehavior();var h=this.renderedHeight;var topRow=this.renderedRows[0];while(h>0&&topRow>=1){topRow--;var eachHeight=behavior.getRowHeight(topRow);h=h-eachHeight}if(topRow===0){return 0}return topRow+1},getPageDownRow:function(){if(this.renderedRowHeights.length===0){return}var row=this.renderedRows[this.renderedRows.length-1]+1;return row}})})();</script></polymer-element><polymer-element name="fin-hypergrid-selection-model" assetpath="/dev/fin-hypergrid/polymer/html/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-selection-model",{rectangles:null,selections:null,flattenedX:null,flattenedY:null,ready:function(){this.rectangles=document.createElement("fin-rectangle");this.selections=[];this.flattenedX=[];this.flattenedY=[]},getGrid:function(){return null},select:function(ox,oy,ex,ey){var newSelection=this.rectangles.rectangle.create(ox,oy,ex,ey);this.selections.push(newSelection);this.flattenedX.push(newSelection.flattenXAt(0));this.flattenedY.push(newSelection.flattenYAt(0));this.getGrid().selectionChanged()},clearMostRecentSelection:function(){this.selections.length=Math.max(0,this.selections.length-1);this.flattenedX.length=Math.max(0,this.flattenedX.length-1);this.flattenedY.length=Math.max(0,this.flattenedY.length-1)},getSelections:function(){return this.selections},hasSelections:function(){return this.selections.length!==0},isSelected:function(x,y){return this._isSelected(this.selections,x,y)},isFixedRowCellSelected:function(col){return this._isSelected(this.flattenedY,col,0)},isFixedColumnCellSelected:function(row){return this._isSelected(this.flattenedX,0,row)},_isSelected:function(selections,x,y){for(var i=0;i<selections.length;i++){var each=selections[i];if(this.rectangles.rectangle.contains(each,x,y)){return true}}return false},clear:function(){this.selections.length=0;this.flattenedX.length=0;this.flattenedY.length=0}})})();</script></polymer-element><polymer-element name="fin-hypergrid-excel" assetpath="/dev/fin-hypergrid/polymer/html/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){var excelOriginOffset=1;Polymer("fin-hypergrid-excel",{grid:{},running:false,publish:{publish:"onSelect",subscribe:"onExcelChange",interval:500,logging:false},installOn:function(grid){var self=this;this.grid=grid;if(!window.fin){if(this.logging){console.log("Excel integration only works within the OpenFin Runtime")}return}fin.desktop.main(function(){fin.desktop.Application.getCurrent();self.start()})},start:function(){var self=this;if(this.running){return}this.running=true;setInterval(function(){if(!self.running){return}self.publishToBus()},self.interval);self.subscribeToBus()},stop:function(){this.running=false;this.unSubscribeToBus()},createExcelDataFromSelections:function(){var selectionModel=this.grid.getSelectionModel();var selections=selectionModel.getSelections();if(selections.length===0){return}var collector=[];var obj;for(var i=0;i<selections.length;i++){var each=selections[i];var eachData=[];var xstart=each.origin.x;var xstop=each.origin.x+each.extent.x+1;var ystart=each.origin.y;var ystop=each.origin.y+each.extent.y+1;for(var y=ystart;y<ystop;y++){for(var x=xstart;x<xstop;x++){var data=this.grid.getValue(x,y);eachData.push(data+"")}}obj={region:[excelOriginOffset+ystart,excelOriginOffset+xstart,ystop,xstop],values:eachData};collector.push(obj)}obj={now:(new Date).getTime(),selection:collector};return obj},publishToBus:function(){if(!this.grid.hasSelections()){return}var excelMessage=this.createExcelDataFromSelections(this.grid);fin.desktop.InterApplicationBus.publish(this.publish,excelMessage);if(this.logging){console.log("push to excel",excelMessage)}},subscribeToBus:function(){fin.desktop.InterApplicationBus.subscribe("*",this.subscribe,this.subscriptionCallback.bind(this));fin.desktop.InterApplicationBus.subscribe("*","ExcelError",this.errorCallback.bind(this))},unSubscribeToBus:function(){fin.desktop.InterApplicationBus.unsubscribe("*",this.subscribe,this.subscriptionCallback.bind(this));fin.desktop.InterApplicationBus.unsubscribe("*","ExcelError",this.errorCallback.bind(this))},subscriptionCallback:function(data){var self=this;var sm=this.grid.getSelectionModel();if(this.logging){console.log(JSON.stringify(data))}if(data.cells&&data.cells.length>0){data.cells.forEach(function(cell){if(cell.value&&!sm.isSelected(cell.row,cell.column)){self.grid.setValue(cell.column-excelOriginOffset,cell.row-excelOriginOffset,cell.value)}})}},errorCallback:function(data){if(this.logging){console.error(JSON.stringify(data))}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-feature-base",{next:null,detached:null,cursor:null,currentHoverCell:null,created:function(){this.createdInit()},createdInit:function(){},setNext:function(nextFeature){if(this.next){this.next.setNext(nextFeature)}else{this.next=nextFeature;this.detached=nextFeature}},detachChain:function(){this.next=null},attachChain:function(){this.next=this.detached},handleMouseMove:function(grid,event){if(this.next){this.next.handleMouseMove(grid,event)}},handleMouseExit:function(grid,event){if(this.next){this.next.handleMouseExit(grid,event)}},handleMouseEnter:function(grid,event){if(this.next){this.next.handleMouseEnter(grid,event)}},handleMouseDown:function(grid,event){if(this.next){this.next.handleMouseDown(grid,event)}},handleMouseUp:function(grid,event){if(this.next){this.next.handleMouseUp(grid,event)}},handleKeyDown:function(grid,event){if(this.next){this.next.handleKeyDown(grid,event)}},handleKeyUp:function(grid,event){if(this.next){this.next.handleKeyUp(grid,event)}},handleWheelMoved:function(grid,event){if(this.next){this.next.handleWheelMoved(grid,event)}},handleDoubleClick:function(grid,event){if(this.next){this.next.handleDoubleClick(grid,event)}},handleHoldPulse:function(grid,event){if(this.next){this.next.handleHoldPulse(grid,event)}},handleTap:function(grid,event){if(this.next){this.next.handleTap(grid,event)}},handleMouseDrag:function(grid,event){if(this.next){this.next.handleMouseDrag(grid,event)}},toggleColumnPicker:function(grid){if(this.next){this.next.toggleColumnPicker(grid)}},isFixedRow:function(grid,event){var gridCell=event.gridCell;var isFixed=gridCell.y<grid.getFixedRowCount();return isFixed},isFixedColumn:function(grid,event){var gridCell=event.gridCell;var isFixed=gridCell.x<grid.getFixedColumnCount();return isFixed},isTopLeft:function(grid,event){var isTopLeft=this.isFixedRow(grid,event)&&this.isFixedColumn(grid,event);return isTopLeft},setCursor:function(grid){if(this.next){this.next.setCursor(grid)}if(this.cursor){grid.beCursor(this.cursor)}},initializeOn:function(grid){if(this.next){this.next.initializeOn(grid)}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-cell-provider" assetpath="/dev/fin-hypergrid/polymer/html/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";var noop=function(){};(function(){var underline=function(config,gc,text,x,y,thickness){var width=config.getTextWidth(gc,text);switch(gc.textAlign){case"center":x-=width/2;break;case"right":x-=width;break}gc.lineWidth=thickness;gc.moveTo(x+.5,y+.5);gc.lineTo(x+width+.5,y+.5)};var roundRect=function(gc,x,y,width,height,radius,fill,stroke){if(!stroke){stroke=true}if(!radius){radius=5}gc.beginPath();gc.moveTo(x+radius,y);gc.lineTo(x+width-radius,y);gc.quadraticCurveTo(x+width,y,x+width,y+radius);gc.lineTo(x+width,y+height-radius);gc.quadraticCurveTo(x+width,y+height,x+width-radius,y+height);gc.lineTo(x+radius,y+height);gc.quadraticCurveTo(x,y+height,x,y+height-radius);gc.lineTo(x,y+radius);gc.quadraticCurveTo(x,y,x+radius,y);gc.closePath();if(stroke){gc.stroke()}if(fill){gc.fill()}gc.closePath()};Polymer("fin-hypergrid-cell-provider",{created:function(){this.cellCache={};this.initializeCells()},getCell:function(config){var cell=this.cellCache.simpleCellRenderer;cell.config=config;return cell},getTopLeftCell:function(config){var cell=this.cellCache.emptyCellRenderer;cell.config=config;return cell},getFixedColumnCell:function(config){var cell=this.cellCache.simpleCellRenderer;cell.config=config;return cell},getFixedRowCell:function(config){var cell=this.cellCache.simpleCellRenderer;cell.config=config;return cell},defaultCellPaint:function(gc,x,y,width,height,isLink){isLink=isLink||false;var colHEdgeOffset=this.config.properties.cellPadding,halignOffset=0,valignOffset=this.config.voffset,halign=this.config.halign,isColumnHovered=this.config.isColumnHovered,isRowHovered=this.config.isRowHovered,val=this.config.value;var leftIcon,rightIcon,centerIcon,ixoffset,iyoffset;if(val&&val.constructor===Array){leftIcon=val[0];rightIcon=val[2];val=val[1];if(typeof val==="object"){centerIcon=val;val=null}if(leftIcon&&leftIcon.nodeName!=="IMG"){leftIcon=null}if(rightIcon&&rightIcon.nodeName!=="IMG"){rightIcon=null}if(centerIcon&¢erIcon.nodeName!=="IMG"){centerIcon=null}}if(gc.font!==this.config.font){gc.font=this.config.font}if(gc.textAlign!=="left"){gc.textAlign="left"}if(gc.textBaseline!=="middle"){gc.textBaseline="middle"}var fontMetrics=this.config.getTextHeight(this.config.font);var textWidth=this.config.getTextWidth(gc,val);this.config.minWidth=textWidth+2*colHEdgeOffset;if(halign==="right"){halignOffset=width-colHEdgeOffset-textWidth}else if(halign==="center"){halignOffset=(width-textWidth)/2}else if(halign==="left"){halignOffset=colHEdgeOffset}halignOffset=Math.max(0,halignOffset);valignOffset=valignOffset+Math.ceil(height/2);if(this.config.bgColor||this.config.isSelected){gc.fillStyle=this.config.isSelected?this.config.bgSelColor:this.config.bgColor;gc.fillRect(x,y,width,height)}var theColor=this.config.isSelected?this.config.fgSelColor:this.config.fgColor;if(gc.fillStyle!==theColor){gc.fillStyle=theColor;gc.strokeStyle=theColor}if(val!==null){gc.fillText(val,x+halignOffset,y+valignOffset)}if(isColumnHovered&&isRowHovered){gc.beginPath();if(isLink){gc.beginPath();underline(this.config,gc,val,x+halignOffset,y+valignOffset+Math.floor(fontMetrics.height/2),1);gc.stroke();gc.closePath()}}var iconWidth=0;if(leftIcon){iyoffset=Math.round((height-leftIcon.height)/2);ixoffset=Math.round((halignOffset-leftIcon.width)/2);gc.drawImage(leftIcon,x+ixoffset,y+iyoffset);iconWidth=Math.max(leftIcon.width+2)}if(rightIcon){iyoffset=Math.round((height-rightIcon.height)/2);ixoffset=Math.round((halignOffset-rightIcon.width)/2);gc.drawImage(rightIcon,x+width-ixoffset-rightIcon.width,y+iyoffset);iconWidth=Math.max(rightIcon.width+2)}if(centerIcon){iyoffset=Math.round((height-centerIcon.height)/2);ixoffset=Math.round((width-centerIcon.width)/2);gc.drawImage(centerIcon,x+width-ixoffset-centerIcon.width,y+iyoffset);iconWidth=Math.max(centerIcon.width+2)}this.config.minWidth=this.config.minWidth+2*iconWidth},paintSlider:function(gc,x,y,width,height){gc.strokeStyle="white";var val=this.config.value;var radius=height/2;var offset=width*val;var bgColor=this.config.isSelected?this.config.bgSelColor:"#333333";var btnGradient=gc.createLinearGradient(x,y,x,y+height);btnGradient.addColorStop(0,bgColor);btnGradient.addColorStop(1,"#666666");var arcGradient=gc.createLinearGradient(x,y,x,y+height);arcGradient.addColorStop(0,"#aaaaaa");arcGradient.addColorStop(1,"#777777");gc.fillStyle=btnGradient;roundRect(gc,x,y,width,height,radius,btnGradient);if(val<1){gc.fillStyle=arcGradient}else{gc.fillStyle="#eeeeee"}gc.beginPath();gc.arc(x+Math.max(offset-radius,radius),y+radius,radius,0,2*Math.PI);gc.fill();gc.closePath();this.config.minWidth=100},paintSparkbar:function(gc,x,y,width,height){gc.beginPath();var val=this.config.value;if(!val||!val.length){return}var count=val.length;var eWidth=width/count;var fgColor=this.config.isSelected?this.config.fgSelColor:this.config.fgColor;if(this.config.bgColor||this.config.isSelected){gc.fillStyle=this.config.isSelected?this.config.bgSelColor:this.config.bgColor;gc.fillRect(x,y,width,height)}gc.fillStyle=fgColor;for(var i=0;i<val.length;i++){var barheight=val[i]/110*height;gc.fillRect(x+5,y+height-barheight,eWidth*.6666,barheight);x=x+eWidth}gc.closePath();this.config.minWidth=count*10},paintSparkline:function(gc,x,y,width,height){gc.beginPath();var val=this.config.value;if(!val||!val.length){return}var count=val.length;var eWidth=width/count;var fgColor=this.config.isSelected?this.config.fgSelColor:this.config.fgColor;if(this.config.bgColor||this.config.isSelected){gc.fillStyle=this.config.isSelected?this.config.bgSelColor:this.config.bgColor;gc.fillRect(x,y,width,height)}gc.strokeStyle=fgColor;gc.fillStyle=fgColor;gc.beginPath();var prev;for(var i=0;i<val.length;i++){var barheight=val[i]/110*height;if(!prev){prev=barheight}gc.lineTo(x+5,y+height-barheight);gc.arc(x+5,y+height-barheight,1,0,2*Math.PI,false);x=x+eWidth}this.config.minWidth=count*10;gc.stroke();gc.closePath()},treeCellRenderer:function(gc,x,y,width,height){var val=this.config.value.data;var indent=this.config.value.indent;var icon=this.config.value.icon;if(this.config.bgColor||this.config.isSelected){gc.fillStyle=this.config.isSelected?this.config.bgSelColor:this.config.bgColor;gc.fillRect(x,y,width,height)}if(!val||!val.length){return}var valignOffset=Math.ceil(height/2);gc.fillStyle=this.config.isSelected?this.config.fgSelColor:this.config.fgColor;gc.fillText(icon+val,x+indent,y+valignOffset);var textWidth=this.config.getTextWidth(gc,icon+val);var minWidth=x+indent+textWidth+10;this.config.minWidth=minWidth},emptyCellRenderer:function(gc,x,y,width,height){noop(gc,x,y,width,height)},initializeCells:function(){var self=this;this.cellCache.simpleCellRenderer={paint:this.defaultCellPaint};this.cellCache.sliderCellRenderer={paint:this.paintSlider};this.cellCache.sparkbarCellRenderer={paint:this.paintSparkbar};this.cellCache.sparklineCellRenderer={paint:this.paintSparkline};this.cellCache.treeCellRenderer={paint:this.treeCellRenderer};this.cellCache.emptyCellRenderer={paint:this.emptyCellRenderer};this.cellCache.linkCellRenderer={paint:function(gc,x,y,width,height){self.config=this.config;self.defaultCellPaint(gc,x,y,width,height,true)}}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-key-paging" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";var commands={PAGEDOWN:function(grid){grid.pageDown()},PAGEUP:function(grid){grid.pageUp()},PAGELEFT:function(grid){grid.pageLeft()},PAGERIGHT:function(grid){grid.pageRight()}};(function(){Polymer("fin-hypergrid-feature-key-paging",{handleKeyDown:function(grid,event){var detail=event.detail.char;var func=commands[detail];if(func){func(grid)}else if(this.next){this.next.handleKeyDown(grid,event)}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-cell-click" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-feature-cell-click",{handleTap:function(grid,event){var fixedRowsHeight=grid.getFixedRowsHeight();var fixedColsWidth=grid.getFixedColumnsWidth();if(event.primitiveEvent.detail.mouse.y>fixedRowsHeight&&event.primitiveEvent.detail.mouse.x>fixedColsWidth){grid.cellClicked(event)}else if(this.next){this.next.handleTap(grid,event)}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-cell-selection" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-feature-cell-selection",{currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,rectangles:{},createdInit:function(){this.rectangles=document.createElement("fin-rectangle")},handleMouseUp:function(grid,event){this.dragging=false;if(this.next){this.next.handleMouseUp(grid,event)}},handleMouseDown:function(grid,event){var gridCell=event.gridCell;if(gridCell.y<grid.getFixedRowCount()){grid.clearSelections();this.dragging=false;if(this.next){this.next.handleMouseDown(grid,event)}return}else if(gridCell.x<grid.getFixedColumnCount()){grid.clearSelections();this.dragging=false;return}else{var primEvent=event.primitiveEvent;var keys=primEvent.detail.keys;this.dragging=true;this.extendSelection(grid,gridCell,keys)}},handleMouseDrag:function(grid,event){var mouseDown=grid.getMouseDown();if(!this.dragging){if(this.next){this.next.handleMouseDrag(grid,event)}}if(mouseDown.x<0||mouseDown.y<0){return}var gridCell=event.gridCell;var primEvent=event.primitiveEvent;this.currentDrag=primEvent.detail.mouse;this.lastDragCell=gridCell;this.checkDragScroll(grid,this.currentDrag);this.handleMouseDragCellSelection(grid,gridCell,primEvent.detail.keys)},handleKeyDown:function(grid,event){var command="handle"+event.detail.char;if(this[command]){this[command].call(this,grid,event.detail)}},handleMouseDragCellSelection:function(grid,mouse){var scrollTop=grid.getVScrollValue();var scrollLeft=grid.getHScrollValue();var numFixedColumns=grid.getFixedColumnCount();var numFixedRows=grid.getFixedRowCount();var x=mouse.x-numFixedColumns;var y=mouse.y-numFixedRows;x=Math.max(0,x);y=Math.max(0,y);var previousDragExtent=grid.getDragExtent();var mouseDown=grid.getMouseDown();var newX=x+scrollLeft-mouseDown.x;var newY=y+scrollTop-mouseDown.y;if(previousDragExtent.x===newX&&previousDragExtent.y===newY){return}grid.clearMostRecentSelection();grid.select(mouseDown.x,mouseDown.y,newX,newY);var newDragExtent=this.rectangles.point.create(newX,newY);grid.setDragExtent(newDragExtent);grid.repaint()},checkDragScroll:function(grid,mouse){if(!grid.resolveProperty("scrollingEnabled")){return}var b=grid.getDataBounds();var inside=b.contains(mouse);if(inside){if(grid.isScrollingNow()){grid.setScrollingNow(false)}}else if(!grid.isScrollingNow()){grid.setScrollingNow(true);this.scrollDrag(grid)}},scrollDrag:function(grid){if(!grid.isScrollingNow()){return}var b=grid.getDataBounds();var xOffset=0;var yOffset=0;if(this.currentDrag.x<b.origin.x){xOffset=-1}if(this.currentDrag.x>b.origin.x+b.extent.x){xOffset=1}if(this.currentDrag.y<b.origin.y){yOffset=-1}if(this.currentDrag.y>b.origin.y+b.extent.y){yOffset=1}grid.scrollBy(xOffset,yOffset);this.handleMouseDragCellSelection(grid,this.lastDragCell,[]);grid.repaint();setTimeout(this.scrollDrag.bind(this,grid),25)},extendSelection:function(grid,gridCell,keys){var hasCTRL=keys.indexOf("CTRL")!==-1;var hasSHIFT=keys.indexOf("SHIFT")!==-1;var scrollTop=grid.getVScrollValue();var scrollLeft=grid.getHScrollValue();var numFixedColumns=grid.getFixedColumnCount();var numFixedRows=grid.getFixedRowCount();var mousePoint=grid.getMouseDown();var x=gridCell.x-numFixedColumns+scrollLeft;var y=gridCell.y-numFixedRows+scrollTop;if(x<0||y<0){return}if(x===mousePoint.x&&y===mousePoint.y){grid.clearMostRecentSelection();grid.popMouseDown();grid.repaint();return}if(!hasCTRL&&!hasSHIFT){grid.clearSelections()}if(hasSHIFT){grid.clearMostRecentSelection();grid.select(mousePoint.x,mousePoint.y,x-mousePoint.x,y-mousePoint.y);grid.setDragExtent(this.rectangles.point.create(x-mousePoint.x,y-mousePoint.y))}else{grid.select(x,y,0,0);grid.setMouseDown(this.rectangles.point.create(x,y));grid.setDragExtent(this.rectangles.point.create(0,0))}grid.repaint()},handleDOWNSHIFT:function(grid){var count=this.getAutoScrollAcceleration();this.moveShiftSelect(grid,0,count)},handleUPSHIFT:function(grid){var count=this.getAutoScrollAcceleration();this.moveShiftSelect(grid,0,-count)},handleLEFTSHIFT:function(grid){this.moveShiftSelect(grid,-1,0)},handleRIGHTSHIFT:function(grid){this.moveShiftSelect(grid,1,0)},handleDOWN:function(grid){var count=this.getAutoScrollAcceleration();this.moveSingleSelect(grid,0,count)},handleUP:function(grid){var count=this.getAutoScrollAcceleration();this.moveSingleSelect(grid,0,-count)},handleLEFT:function(grid){this.moveSingleSelect(grid,-1,0)},handleRIGHT:function(grid){this.moveSingleSelect(grid,1,0)},getAutoScrollAcceleration:function(){var count=1;var elapsed=this.getAutoScrollDuration()/2e3;count=Math.max(1,Math.floor(elapsed*elapsed*elapsed*elapsed));return count},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var now=Date.now();if(now-this.sbLastAuto>500){this.setAutoScrollStartTime()}this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){if(Date.now()-this.sbLastAuto>500){return 0}return Date.now()-this.sbAutoStart},moveShiftSelect:function(grid,offsetX,offsetY){var maxColumns=grid.getColumnCount()-1;var maxRows=grid.getRowCount()-1;var maxViewableColumns=grid.getViewableColumns()-1;var maxViewableRows=grid.getViewableRows()-1;if(!grid.resolveProperty("scrollingEnabled")){maxColumns=Math.min(maxColumns,maxViewableColumns);maxRows=Math.min(maxRows,maxViewableRows)}var origin=grid.getMouseDown();var extent=grid.getDragExtent();var newX=extent.x+offsetX;var newY=extent.y+offsetY;newX=Math.min(maxColumns-origin.x,Math.max(-origin.x,newX));newY=Math.min(maxRows-origin.y,Math.max(-origin.y,newY));grid.clearMostRecentSelection();grid.select(origin.x,origin.y,newX,newY);grid.setDragExtent(this.rectangles.point.create(newX,newY));if(grid.insureModelColIsViewable(newX+origin.x,offsetX)){this.pingAutoScroll()}if(grid.insureModelRowIsViewable(newY+origin.y,offsetY)){this.pingAutoScroll()}grid.repaint()},moveSingleSelect:function(grid,offsetX,offsetY){var maxColumns=grid.getColumnCount()-1;var maxRows=grid.getRowCount()-1;var maxViewableColumns=grid.getViewableColumns()-1;var maxViewableRows=grid.getViewableRows()-1;if(!grid.resolveProperty("scrollingEnabled")){maxColumns=Math.min(maxColumns,maxViewableColumns);maxRows=Math.min(maxRows,maxViewableRows)}var mouseCorner=grid.getMouseDown().plus(grid.getDragExtent());var newX=mouseCorner.x+offsetX;var newY=mouseCorner.y+offsetY;newX=Math.min(maxColumns,Math.max(0,newX));newY=Math.min(maxRows,Math.max(0,newY));grid.clearSelections();grid.select(newX,newY,0,0);grid.setMouseDown(this.rectangles.point.create(newX,newY));grid.setDragExtent(this.rectangles.point.create(0,0));if(grid.insureModelColIsViewable(newX,offsetX)){this.pingAutoScroll()}if(grid.insureModelRowIsViewable(newY,offsetY)){this.pingAutoScroll()}grid.repaint()}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-overlay" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){var noop=function(){};var ANIMATION_TIME=200;Polymer("fin-hypergrid-feature-overlay",{openEditor:false,handleKeyUp:function(grid,event){var key=event.detail.char.toLowerCase();var keys=grid.resolveProperty("editorActivationKeys");if(keys.indexOf(key)>-1){this.toggleColumnPicker(grid)}},toggleColumnPicker:function(grid){if(this.isColumnPickerOpen(grid)){this.closeColumnPicker(grid)}else{this.openColumnPicker(grid)}},isColumnPickerOpen:function(grid){noop(grid);return this.overlay.style.display!=="none"},openColumnPicker:function(grid){if(this.isColumnPickerOpen()){return}this.openEditor=true;if(grid.getBehavior().openEditor(this.overlay)===false){return}var self=this;this.overlay.style.backgroundColor=grid.resolveProperty("backgroundColor");this.overlay.style.top="0%";this.overlay.style.right="0%";this.overlay.style.bottom="0%";this.overlay.style.left="0%";this.overlay.style.marginTop="15px";this.overlay.style.marginRight="35px";this.overlay.style.marginBottom="35px";this.overlay.style.marginLeft="15px";self.overlay.style.display="";if(!this._closer){this._closer=function(e){var key=self.getCharFor(grid,e.keyCode).toLowerCase();var keys=grid.resolveProperty("editorActivationKeys");if(keys.indexOf(key)>-1||e.keyCode===27){e.preventDefault();self.closeColumnPicker(grid)}}}grid.setFocusable(false);requestAnimationFrame(function(){self.overlay.style.opacity=.95;document.addEventListener("keydown",self._closer,false);self.overlay.focus()})},closeColumnPicker:function(grid){grid.setFocusable(true);if(!this.isColumnPickerOpen()){return}if(this.openEditor){this.openEditor=false}else{return}if(grid.getBehavior().closeEditor(this.overlay)===false){return}document.removeEventListener("keydown",this._closer,false);var self=this;requestAnimationFrame(function(){self.overlay.style.opacity=0});setTimeout(function(){self.overlay.innerHTML="";self.overlay.style.display="none";grid.takeFocus()},ANIMATION_TIME)},initializeOn:function(grid){this.initializeOverlaySurface(grid);if(this.next){this.next.initializeOn(grid)}},initializeOverlaySurface:function(grid){this.overlay=document.createElement("div");this.overlay.setAttribute("tabindex",0);this.overlay.style.outline="none";this.overlay.style.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)";this.overlay.style.position="absolute";this.overlay.style.display="none";this.overlay.style.transition="opacity "+ANIMATION_TIME+"ms ease-in";this.overlay.style.opacity=0;grid.appendChild(this.overlay)},getCharFor:function(grid,integer){var charMap=grid.getCanvas().getCharMap();return charMap[integer][0]}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-thumbwheel-scrolling" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-feature-thumbwheel-scrolling",{handleWheelMoved:function(grid,e){if(!grid.resolveProperty("scrollingEnabled")){return}var primEvent=e.primitiveEvent;var deltaY=primEvent.wheelDeltaY||-primEvent.deltaY;var deltaX=primEvent.wheelDeltaX||-primEvent.deltaX;if(deltaY>0){grid.scrollBy(0,-1)}else if(deltaY<-0){grid.scrollBy(0,1)}else if(deltaX>0){grid.scrollBy(-1,0)}else if(deltaX<-0){grid.scrollBy(1,0)}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-cell-editing" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-feature-cell-editing",{handleDoubleClick:function(grid,event){var fixedColCount=grid.getFixedColumnCount();var fixedRowCount=grid.getFixedRowCount();var gridCell=event.gridCell;if(gridCell.x>=fixedColCount&&gridCell.y>=fixedRowCount){var x=grid.getHScrollValue()+gridCell.x-fixedColCount;var y=grid.getVScrollValue()+gridCell.y-fixedRowCount;event.gridCell=grid.rectangles.point.create(x,y);grid._activateEditor(event)}else if(this.next){this.next.handleDoubleClick(grid,event)}},handleHoldPulse:function(grid,mouseEvent){var primEvent=mouseEvent.primitiveEvent;if(primEvent.detail.count<2){return}grid._activateEditor(mouseEvent)}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-column-sorting" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-feature-column-sorting",{handleTap:function(grid,event){var gridCell=event.gridCell;var inFixedRowArea=gridCell.y<grid.getFixedRowCount();var inFixedColumnArea=gridCell.x<grid.getFixedColumnCount();if(inFixedRowArea&&inFixedColumnArea){grid.topLeftClicked(event)}else if(inFixedRowArea){grid.fixedRowClicked(event)}else if(inFixedColumnArea){grid.fixedColumnClicked(event)}},handleMouseMove:function(grid,event){var y=event.gridCell.y;if(this.isFixedRow(grid,event)&&!this.isFixedColumn(grid,event)&&y<1){this.cursor="pointer"}else{this.cursor=null}if(this.next){this.next.handleMouseMove(grid,event)}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-column-resizing" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-feature-column-resizing",{dragIndex:-1,dragStart:-1,dragIndexStartingSize:-1,getFixedAreaCount:function(grid){return grid.getFixedColumnCount()},getMouseValue:function(event){return event.primitiveEvent.detail.mouse.x},getGridCellValue:function(gridCell){return gridCell.y},getScrollValue:function(grid){return grid.getHScrollValue()},getAreaSize:function(grid,index){return grid.getColumnWidth(index)},setAreaSize:function(grid,index,value){grid.setColumnWidth(index,value)},getOtherFixedAreaCount:function(grid){return grid.getFixedRowCount()},getFixedAreaSize:function(grid,index){return grid.getFixedColumnWidth(index)},getPreviousAbsoluteSize:function(grid,index){return grid.getRenderedWidth(index)},setFixedAreaSize:function(grid,index,value){grid.setFixedColumnWidth(index,value)},overAreaDivider:function(grid,event){return grid.overColumnDivider(event)},isFixedOtherArea:function(grid,event){return this.isFixedRow(grid,event)},getCursorName:function(){return"col-resize"},handleMouseDrag:function(grid,event){if(this.dragIndex>-1){var distance=this.getMouseValue(event)-this.getPreviousAbsoluteSize(grid,this.dragIndex);this.setSize(grid,this.dragIndex,distance)}else if(this.next){this.next.handleMouseDrag(grid,event)}},setSize:function(grid,areaIndex,size){var fixedAreaCount=this.getFixedAreaCount(grid);var scrollValue=this.getScrollValue(grid);if(areaIndex<fixedAreaCount){this.setFixedAreaSize(grid,areaIndex,size)}else{this.setAreaSize(grid,areaIndex-fixedAreaCount+scrollValue,size)}},getSize:function(grid,areaIndex){var fixedAreaCount=this.getFixedAreaCount(grid);if(areaIndex<0){return this.getFixedAreaSize(grid,fixedAreaCount+areaIndex)}else{return this.getAreaSize(grid,areaIndex)}},handleMouseDown:function(grid,event){var gridCell=event.gridCell;var overArea=this.overAreaDivider(grid,event);if(overArea>-1&&this.getGridCellValue(gridCell)<this.getOtherFixedAreaCount(grid)){var scrollValue=this.getScrollValue(grid);var fixedAreaCount=this.getFixedAreaCount(grid);this.dragIndex=overArea-1;this.dragStart=this.getMouseValue(event);if(overArea<fixedAreaCount){scrollValue=0}this.dragIndexStartingSize=this.getAreaSize(grid,overArea-fixedAreaCount+scrollValue);this.detachChain()}else if(this.next){this.next.handleMouseDown(grid,event)}},handleMouseUp:function(grid,event){if(this.dragIndex>-1){this.cursor=null;this.dragIndex=-1;event.primitiveEvent.stopPropagation();var self=this;setTimeout(function(){self.attachChain()},200)}else if(this.next){this.next.handleMouseUp(grid,event)}},handleMouseMove:function(grid,event){if(this.dragIndex>-1){return}this.cursor=null;if(this.next){this.next.handleMouseMove(grid,event)}this.checkForAreaResizeCursorChange(grid,event)},checkForAreaResizeCursorChange:function(grid,event){if(this.isFixedOtherArea(grid,event)&&this.overAreaDivider(grid,event)>-1){this.cursor=this.getCursorName()}else{this.cursor=null}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-column-moving" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){var noop=function(){};var columnAnimationTime=150;var dragger;var draggerCTX;var floatColumn;var floatColumnCTX;Polymer("fin-hypergrid-feature-column-moving",{floaterAnimationQueue:[],columnDragAutoScrollingRight:false,columnDragAutoScrollingLeft:false,dragArmed:false,dragging:false,dragCol:-1,dragOffset:0,initializeOn:function(grid){this.isFloatingNow=false;this.initializeAnimationSupport(grid);if(this.next){this.next.initializeOn(grid)}},initializeAnimationSupport:function(grid){noop(grid);if(!dragger){dragger=document.createElement("canvas");dragger.setAttribute("width","0px");dragger.setAttribute("height","0px");document.body.appendChild(dragger);draggerCTX=dragger.getContext("2d")}if(!floatColumn){floatColumn=document.createElement("canvas");floatColumn.setAttribute("width","0px");floatColumn.setAttribute("height","0px");document.body.appendChild(floatColumn);floatColumnCTX=floatColumn.getContext("2d")}},handleMouseDrag:function(grid,event){var gridCell=event.gridCell;var x,y;if(this.isFixedColumn(grid,event)){return}if(this.isFixedRow(grid,event)&&this.dragArmed&&!this.dragging){this.dragging=true;this.dragCol=gridCell.x-grid.getFixedColumnCount();this.dragOffset=event.mousePoint.x;this.detachChain();x=event.primitiveEvent.detail.mouse.x-this.dragOffset;y=event.primitiveEvent.detail.mouse.y;this.createDragColumn(grid,x,this.dragCol)}else if(this.next){this.next.handleMouseDrag(grid,event)}if(this.dragging){x=event.primitiveEvent.detail.mouse.x-this.dragOffset;y=event.primitiveEvent.detail.mouse.y;this.dragColumn(grid,x)}},handleMouseDown:function(grid,event){if(grid.getBehavior().isColumnReorderable()){if(this.isFixedRow(grid,event)){this.dragArmed=true}}if(this.next){this.next.handleMouseDown(grid,event)}},handleMouseUp:function(grid,event){if(this.dragging){this.cursor=null;var self=this;this.endDragColumn(grid);setTimeout(function(){self.attachChain()},200)}this.dragCol=-1;this.dragging=false;this.dragArmed=false;grid.repaint();if(this.next){this.next.handleMouseUp(grid,event)}},handleMouseMove:function(grid,event){this.cursor=null;if(this.next){this.next.handleMouseMove(grid,event)}if(this.isFixedRow(grid,event)&&this.dragging){this.cursor="none"}},floatColumnTo:function(grid,draggedToTheRight){this.floatingNow=true;var scrollLeft=grid.getHScrollValue();var floaterIndex=grid.renderOverridesCache.floater.columnIndex;var draggerIndex=grid.renderOverridesCache.dragger.columnIndex;var hdpiratio=grid.renderOverridesCache.dragger.hdpiratio;var numFixedColumns=grid.getFixedColumnCount();var draggerStartX;var floaterStartX;var draggerWidth=grid.getColumnWidth(draggerIndex+scrollLeft);var floaterWidth=grid.getColumnWidth(floaterIndex+scrollLeft);var max=grid.renderer.renderedColumnWidths.length-1;if(draggedToTheRight){draggerStartX=grid.renderer.renderedColumnWidths[Math.min(max,draggerIndex+numFixedColumns)];floaterStartX=draggerStartX+floaterWidth;grid.renderOverridesCache.dragger.startX=floaterStartX*hdpiratio;grid.renderOverridesCache.floater.startX=draggerStartX*hdpiratio;floaterStartX=draggerStartX+draggerWidth}else{floaterStartX=grid.renderer.renderedColumnWidths[Math.min(max,floaterIndex+numFixedColumns)];draggerStartX=floaterStartX+draggerWidth;grid.renderOverridesCache.dragger.startX=floaterStartX*hdpiratio;grid.renderOverridesCache.floater.startX=draggerStartX*hdpiratio}grid.getBehavior().swapColumns(draggerIndex+scrollLeft,floaterIndex+scrollLeft);grid.renderOverridesCache.dragger.columnIndex=floaterIndex;grid.renderOverridesCache.floater.columnIndex=draggerIndex;this.floaterAnimationQueue.unshift(this.doColumnMoveAnimation(grid,floaterStartX,draggerStartX));this.doFloaterAnimation(grid)},doColumnMoveAnimation:function(grid,floaterStartX,draggerStartX){var self=this;return function(){var d=floatColumn;d.style.display="inline";self.setCrossBrowserProperty(d,"transform","translate("+floaterStartX+"px, "+0+"px)");window.requestAnimationFrame(function(){self.setCrossBrowserProperty(d,"transition",(self.isWebkit?"-webkit-":"")+"transform "+columnAnimationTime+"ms ease");self.setCrossBrowserProperty(d,"transform","translate("+draggerStartX+"px, "+-2+"px)")});grid.repaint();setTimeout(function(){self.setCrossBrowserProperty(d,"transition","");grid.renderOverridesCache.floater=null;grid.repaint();self.doFloaterAnimation(grid);requestAnimationFrame(function(){d.style.display="none";self.isFloatingNow=false})},columnAnimationTime+50)}},doFloaterAnimation:function(grid){if(this.floaterAnimationQueue.length===0){this.floatingNow=false;grid.repaint();return}var animation=this.floaterAnimationQueue.pop();animation()},createFloatColumn:function(grid,columnIndex){var scrollLeft=grid.getHScrollValue();var numFixedColumns=grid.getFixedColumnCount();var columnWidth=columnIndex<0?grid.getFixedColumnWidth(numFixedColumns+columnIndex+scrollLeft):grid.getColumnWidth(columnIndex+scrollLeft);var colHeight=grid.clientHeight;var d=floatColumn;var style=d.style;var location=grid.getBoundingClientRect();style.top=location.top-2+"px";style.left=location.left+"px";style.position="fixed";var hdpiRatio=grid.getHiDPI(floatColumnCTX);d.setAttribute("width",Math.round(columnWidth*hdpiRatio)+"px");d.setAttribute("height",Math.round(colHeight*hdpiRatio)+"px");style.boxShadow="0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)";style.width=columnWidth+"px";style.height=colHeight+"px";style.borderTop="1px solid "+grid.renderer.resolveProperty("lineColor");style.backgroundColor=grid.renderer.resolveProperty("backgroundColor");var startX=grid.renderer.renderedColumnWidths[columnIndex+numFixedColumns];startX=startX*hdpiRatio;floatColumnCTX.scale(hdpiRatio,hdpiRatio);grid.renderOverridesCache.floater={columnIndex:columnIndex,ctx:floatColumnCTX,startX:startX,width:columnWidth,height:colHeight,hdpiratio:hdpiRatio};style.zIndex="4";this.setCrossBrowserProperty(d,"transform","translate("+startX+"px, "+-2+"px)");style.cursor="none";grid.repaint()},setCrossBrowserProperty:function(element,property,value){var uProperty=property[0].toUpperCase()+property.substr(1);this.setProp(element,"webkit"+uProperty,value);this.setProp(element,"Moz"+uProperty,value);this.setProp(element,"ms"+uProperty,value);this.setProp(element,"O"+uProperty,value);this.setProp(element,property,value)},setProp:function(element,property,value){if(property in element.style){element.style[property]=value}},createDragColumn:function(grid,x,columnIndex){var scrollLeft=grid.getHScrollValue();var numFixedColumns=grid.getFixedColumnCount();var hdpiRatio=grid.getHiDPI(draggerCTX);var columnWidth=columnIndex<0?grid.getFixedColumnWidth(numFixedColumns+columnIndex+scrollLeft):grid.getColumnWidth(columnIndex+scrollLeft);var colHeight=grid.clientHeight;var d=dragger;var location=grid.getBoundingClientRect();var style=d.style;style.top=location.top+"px";style.left=location.left+"px";style.position="fixed";style.opacity=.85;style.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)";style.borderTop="1px solid "+grid.renderer.resolveProperty("lineColor");style.backgroundColor=grid.renderer.resolveProperty("backgroundColor");d.setAttribute("width",Math.round(columnWidth*hdpiRatio)+"px");d.setAttribute("height",Math.round(colHeight*hdpiRatio)+"px");style.width=columnWidth+"px";style.height=colHeight+"px";var startX=grid.renderer.renderedColumnWidths[columnIndex+numFixedColumns];startX=startX*hdpiRatio;draggerCTX.scale(hdpiRatio,hdpiRatio);grid.renderOverridesCache.dragger={columnIndex:columnIndex,ctx:draggerCTX,startX:startX,width:columnWidth,height:colHeight,hdpiratio:hdpiRatio};this.setCrossBrowserProperty(d,"transform","translate("+x+"px, -5px)");style.zIndex="5";style.cursor="none";grid.repaint()},dragColumn:function(grid,x){var self=this;var autoScrollingNow=this.columnDragAutoScrollingRight||this.columnDragAutoScrollingLeft;var hdpiRatio=grid.getHiDPI(draggerCTX);var dragColumnIndex=grid.renderOverridesCache.dragger.columnIndex;var columnWidth=grid.renderOverridesCache.dragger.width;var minX=grid.getFixedColumnsWidth();var maxX=grid.renderer.getFinalVisableColumnBoundry()-columnWidth;x=Math.min(x,maxX+15);x=Math.max(minX-15,x);var atMin=x<minX&&dragColumnIndex!==0;var atMax=x>maxX;var d=dragger;this.setCrossBrowserProperty(d,"transition",(self.isWebkit?"-webkit-":"")+"transform "+0+"ms ease, box-shadow "+columnAnimationTime+"ms ease");this.setCrossBrowserProperty(d,"transform","translate("+x+"px, "+-10+"px)");requestAnimationFrame(function(){d.style.display="inline"});var overCol=grid.renderer.getColumnFromPixelX(x+d.width/2/hdpiRatio);if(atMin){overCol=0}if(atMax){overCol=grid.renderer.renderedColumns[grid.renderer.renderedColumns.length-1]}var doAFloat=dragColumnIndex>overCol;doAFloat=doAFloat||overCol-dragColumnIndex>1;if(doAFloat&&!atMax&&!autoScrollingNow){var draggedToTheRight=dragColumnIndex<overCol;if(draggedToTheRight){overCol=overCol-1}if(this.isFloatingNow){return}this.isFloatingNow=true;this.createFloatColumn(grid,overCol);this.floatColumnTo(grid,draggedToTheRight)}else{if(x<minX-10){this.checkAutoScrollToLeft(grid,x)}if(x>minX-10){this.columnDragAutoScrollingLeft=false}if(atMax||x>maxX+10){this.checkAutoScrollToRight(grid,x);return}if(x<maxX+10){this.columnDragAutoScrollingRight=false}}},checkAutoScrollToRight:function(grid,x){if(this.columnDragAutoScrollingRight){return}this.columnDragAutoScrollingRight=true;this._checkAutoScrollToRight(grid,x)},_checkAutoScrollToRight:function(grid,x){if(!this.columnDragAutoScrollingRight){return}var behavior=grid.getBehavior();var scrollLeft=grid.getHScrollValue();if(!grid.dragging||scrollLeft>grid.sbHScrollConfig.rangeStop-2){return}var draggedIndex=grid.renderOverridesCache.dragger.columnIndex;grid.scrollBy(1,0);var newIndex=draggedIndex+scrollLeft+1;behavior.swapColumns(newIndex,draggedIndex+scrollLeft);setTimeout(this._checkAutoScrollToRight.bind(this,grid,x),250)},findNewPositionOnScrollRight:function(dragIndex){noop(dragIndex);var scrollLeft=this.getHScrollValue();var behavior=this.getBehavior();var bounds=this.canvas.getBounds();var viewWidth=bounds.width()-behavior.getFixedColumnsWidth();var max=behavior.getColumnCount();for(var c=0;c<max;c++){var eachColumnWidth=behavior.getColumnWidth(scrollLeft+c);viewWidth=viewWidth-eachColumnWidth;if(viewWidth<0){return c-2}}return max-1},checkAutoScrollToLeft:function(grid,x){if(this.columnDragAutoScrollingLeft){return}this.columnDragAutoScrollingLeft=true;this._checkAutoScrollToLeft(grid,x)},_checkAutoScrollToLeft:function(grid,x){if(!this.columnDragAutoScrollingLeft){return}var behavior=grid.getBehavior();var scrollLeft=grid.getHScrollValue();if(!grid.dragging||scrollLeft<1){return}var draggedIndex=grid.renderOverridesCache.dragger.columnIndex;behavior.swapColumns(draggedIndex+scrollLeft,draggedIndex+scrollLeft-1);grid.scrollBy(-1,0);setTimeout(this._checkAutoScrollToLeft.bind(this,grid,x),250)},endDragColumn:function(grid){var self=this;var numFixedColumns=grid.getFixedColumnCount();var columnIndex=grid.renderOverridesCache.dragger.columnIndex;var startX=grid.renderer.renderedColumnWidths[columnIndex+numFixedColumns];var d=dragger;self.setCrossBrowserProperty(d,"transition",(self.isWebkit?"-webkit-":"")+"transform "+columnAnimationTime+"ms ease, box-shadow "+columnAnimationTime+"ms ease");self.setCrossBrowserProperty(d,"transform","translate("+startX+"px, "+-1+"px)");d.style.boxShadow="0px 0px 0px #888888";setTimeout(function(){grid.renderOverridesCache.dragger=null;grid.repaint();requestAnimationFrame(function(){d.style.display="none";grid.getBehavior().endDragColumnNotification()})},columnAnimationTime+50)}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-row-resizing" extends="fin-hypergrid-feature-column-resizing" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-feature-row-resizing",{dragArea:-1,dragStart:-1,dragAreaStartingSize:-1,getFixedAreaCount:function(grid){return grid.getFixedRowCount()},getMouseValue:function(event){return event.primitiveEvent.detail.mouse.y},getGridCellValue:function(gridCell){return gridCell.x},getScrollValue:function(grid){return grid.getVScrollValue()},getAreaSize:function(grid,index){return grid.getRowHeight(index)},setAreaSize:function(grid,index,value){grid.setRowHeight(index,value)},getOtherFixedAreaCount:function(grid){return grid.getFixedColumnCount()},getFixedAreaSize:function(grid,index){return grid.getFixedRowHeight(index)},setFixedAreaSize:function(grid,index,value){grid.setFixedRowHeight(index,value)},overAreaDivider:function(grid,event){return grid.overRowDivider(event)},isFixedOtherArea:function(grid,event){return this.isFixedColumn(grid,event)},getCursorName:function(){return"row-resize"},getPreviousAbsoluteSize:function(grid,index){return grid.getRenderedHeight(index)}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-on-hover" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-feature-on-hover",{handleMouseMove:function(grid,event){var currentHoverCell=grid.getHoverCell();if(!event.gridCell.equals(currentHoverCell)){if(currentHoverCell){this.handleMouseExit(grid,currentHoverCell)}this.handleMouseEnter(grid,event);grid.setHoverCell(event.gridCell)}else{if(this.next){this.next.handleMouseMove(grid,event)}}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-feature-column-autosizing" extends="fin-hypergrid-feature-base" assetpath="/dev/fin-hypergrid/polymer/html/features/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-feature-column-autosizing",{handleDoubleClick:function(grid,event){var fixedRowCount=grid.getFixedRowCount();var fixedColCount=grid.getFixedColumnCount();var gridCell=event.gridCell;if(gridCell.y<=fixedRowCount){var col=grid.getHScrollValue()+gridCell.x-fixedColCount;grid.autosizeColumn(col)}else if(this.next){this.next.handleDoubleClick(grid,event)}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-data-model-base" attributes="" assetpath="/dev/fin-hypergrid/polymer/html/data-models/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-data-model-base",{scrollPositionX:0,scrollPositionY:0,getValue:function(){},setValue:function(){},setScrollPositionX:function(x){this.scrollPositionX=x},getScrollPositionX:function(){return this.scrollPositionX},setScrollPositionY:function(y){this.scrollPositionY=y},getScrollPositionY:function(){return this.scrollPositionY}})})();</script></polymer-element><polymer-element name="fin-hypergrid-behavior-base" attributes="" assetpath="/dev/fin-hypergrid/polymer/html/behaviors/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){var noop=function(){};var imageCache={};var imgData=[["1-abs-down","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAFFJREFUKFNjQAL/oTTD////CWJkgFMjEAgD8Q4gLkMSgwOsGoGgDCQExcRrRFJImo1ICqmnEUSiYJgkMgYCrDYia8TQBFVIJ6cCAXJ0QDGDDQD67OYX9wdp0wAAAABJRU5ErkJggg=="],["1-abs-up","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAExJREFUKFPtjYEJACAIBN2hdZqr2dqu3tB8C5qghzPxlAQZJ4iWJ9E8DpACOmh7ZkLLwoWDNPJxSMONSwa5fzSBJy8z/9B6RpfVZaRO2oo/zJVRDvIAAAAASUVORK5CYII="],["1-down","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAGtJREFUKFOtjoEJgDAQA6uiC7iOc3U2t3sT6Uu+XxDBwFliEtoisnYWM3vFtQG6mWZQ2sEJqvy7tQC6FUzdqLaMpCH1OB1KcXgjBZ8HDhSHEuCIZeW/IcRvwEMFyjey7HjQA317KsvMIuW4AFTUEgvs+3wkAAAAAElFTkSuQmCC"],["1-up","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAAFBJREFUKFPtjdsNQCEIQ93BdZzL2dwOjw9CuV93AEmOJbYNxcw2DHL2P5wHcdR0mAoDuvxFyXHzBrp4UZQAEoUvTL4oBpLDyiveXVnh5WVKm6iPR8RbHxLhAAAAAElFTkSuQmCC"],["2-abs-down","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAH5JREFUKFOVkAsNgDAMROcBBxjAAEJwgAMcYGGmsIAGLJS7piE3FjJ2yRvpxus+SWLxTWbWRFOJyAgyuDgNDjD9EWewAzZgvElTVCJshLJfXED3jjwu77pG7UKBCvHTAPgwWeY8Kn5KLN4i81SyyOOdgHfzqMixQBb9FWvSdgNN871AHwblVAAAAABJRU5ErkJggg=="],["2-abs-up","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAJVJREFUKFN9kAEVgzAMRPEwBzOAgQnBwRzgYBZqCgtowAL7l6VtILB77zc01yttB7SfQRr+0j8uAugJBTb5sMBoni/QYNSQ91/wAW0g2Sbu9VAlhisubcSUeTCscYdrgt8fg0HJgQrScXXXt82DQckBgR6ghymtF0zKMSBQC2nS+mEBJYV0vBV0N1PzwiJKCtorZob5Cy2RFvXFQAKlAAAAAElFTkSuQmCC"],["2-down","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAJtJREFUKFOFkAsNAjEQRAsXMIADDJwBhOAABzjAwpnCAhqwUN4s2zJQCJO8bGa3018x1ayl1vqXpi3IrWVsuIcF7mrDFWYPTiC3gZUFD3ABbSDFJh6UumtBJ6WNsB/BtugbqSM8T7QBZQw0kK6rt57C24AyBgTagT5msV687Y02zAU9JNP7OfwV0vVuoLeF+swWUV6h7MUvjpTzA6fM6SVV2CbgAAAAAElFTkSuQmCC"],["2-up","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAAIxJREFUKFOVkFsRgDAMBOsBBxjAAEJwgAMcYAFTWEADFspe+iDQH8jMcrSX6yvEGA0KSf9fSB+k8DBD6GGDUx7sMGTvDhVccIQVtIDKFjHPNSH3bm9yaSGG/4MT/N5Rx9VdZxs7A2kDgupAD7PVOWciz4CgakiDOu8akCak4x2gu1lVzzUhTdBesSUsF/uHHu110bZRAAAAAElFTkSuQmCC"],["3-abs-down","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAJVJREFUKFONkQENhDAMRecBB2cAAyhAwTnAAQ6wgAa8nIXTcBbGf6NduiyEe8ljadlfOkiBbGvKOT8a6YLiJXf5oy2/8v1PcJKb5ABYJS+8LnTBqMFBFGOpjKfgIBl7t7pyGxQ+InecPcizMYZ8kzFLGnXUGLwLOTS5a6XuCqFFMib3A2p+Tfmq7GgMQU4+vC8/Vy+lEzGdowwHiWM2AAAAAElFTkSuQmCC"],["3-abs-up","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAJtJREFUKFOFkQERwjAMResBBzOAgSmYAhzgAAdYmAa8YAENWID3SgM5soN/95om6e+lW0OPb5DLTz6bDQOaYIW7fbjBoffGAZdOmEZ9hjN4gTqBjZ6/TUE2B0NeZLLPDUI1BGgHjr32PDUI1SAoRvSNS6+lJqGaJGkBC/9H3ZDFOR8gFNMRHNP3KXN/zZQPEYrRr3ixN7i+aq09ARE7/LLO8L26AAAAAElFTkSuQmCC"],["3-down","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAKdJREFUKFN1kQERwjAMRQscGMDBDGBgCqYABzjAARamAS9YQAMWyn8hodlt/Xfv0p80uXQrSdXjX7XWLqGTwO3NNQ1iFh9B/S2uufEgcEexI+EaxUMwAN0F98Kb2hjXxmoMwlzMuVRfviMjnQVrz+ZTQWHdAFKsyBsny6WiwroJkiZBwlblsKDTFCI5RrHXdBOsyfsQnl8z5EsKrclzfMUnNef1y5XyBYgdtwl+Lm+LAAAAAElFTkSuQmCC"],["3-up","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAAJpJREFUKFONkQsRwjAQBeMBBzWAgSqoAhzgAAdYqAa8YAENWAi7+cAx6UDfzPaae32ZS5pyzgVEqe97qA9K58tMaYIVnnrwgFPzPqFOCM5wBTdQF9CY4u7vwBZNbuTiGA3KGOigAzj2WtbBoIwBQX1Ez7iUXjApY0iCFrDxf9QN2ZzjB5QhdAbH9HzKtb/m960ib/Gm17jXXkov3zEEuQ7h10oAAAAASUVORK5CYII="],["back","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAD8GlDQ1BJQ0MgUHJvZmlsZQAAOI2NVd1v21QUP4lvXKQWP6Cxjg4Vi69VU1u5GxqtxgZJk6XpQhq5zdgqpMl1bhpT1za2021Vn/YCbwz4A4CyBx6QeEIaDMT2su0BtElTQRXVJKQ9dNpAaJP2gqpwrq9Tu13GuJGvfznndz7v0TVAx1ea45hJGWDe8l01n5GPn5iWO1YhCc9BJ/RAp6Z7TrpcLgIuxoVH1sNfIcHeNwfa6/9zdVappwMknkJsVz19HvFpgJSpO64PIN5G+fAp30Hc8TziHS4miFhheJbjLMMzHB8POFPqKGKWi6TXtSriJcT9MzH5bAzzHIK1I08t6hq6zHpRdu2aYdJYuk9Q/881bzZa8Xrx6fLmJo/iu4/VXnfH1BB/rmu5ScQvI77m+BkmfxXxvcZcJY14L0DymZp7pML5yTcW61PvIN6JuGr4halQvmjNlCa4bXJ5zj6qhpxrujeKPYMXEd+q00KR5yNAlWZzrF+Ie+uNsdC/MO4tTOZafhbroyXuR3Df08bLiHsQf+ja6gTPWVimZl7l/oUrjl8OcxDWLbNU5D6JRL2gxkDu16fGuC054OMhclsyXTOOFEL+kmMGs4i5kfNuQ62EnBuam8tzP+Q+tSqhz9SuqpZlvR1EfBiOJTSgYMMM7jpYsAEyqJCHDL4dcFFTAwNMlFDUUpQYiadhDmXteeWAw3HEmA2s15k1RmnP4RHuhBybdBOF7MfnICmSQ2SYjIBM3iRvkcMki9IRcnDTthyLz2Ld2fTzPjTQK+Mdg8y5nkZfFO+se9LQr3/09xZr+5GcaSufeAfAww60mAPx+q8u/bAr8rFCLrx7s+vqEkw8qb+p26n11Aruq6m1iJH6PbWGv1VIY25mkNE8PkaQhxfLIF7DZXx80HD/A3l2jLclYs061xNpWCfoB6WHJTjbH0mV35Q/lRXlC+W8cndbl9t2SfhU+Fb4UfhO+F74GWThknBZ+Em4InwjXIyd1ePnY/Psg3pb1TJNu15TMKWMtFt6ScpKL0ivSMXIn9QtDUlj0h7U7N48t3i8eC0GnMC91dX2sTivgloDTgUVeEGHLTizbf5Da9JLhkhh29QOs1luMcScmBXTIIt7xRFxSBxnuJWfuAd1I7jntkyd/pgKaIwVr3MgmDo2q8x6IdB5QH162mcX7ajtnHGN2bov71OU1+U0fqqoXLD0wX5ZM005UHmySz3qLtDqILDvIL+iH6jB9y2x83ok898GOPQX3lk3Itl0A+BrD6D7tUjWh3fis58BXDigN9yF8M5PJH4B8Gr79/F/XRm8m241mw/wvur4BGDj42bzn+Vmc+NL9L8GcMn8F1kAcXgSteGGAAABUUlEQVQ4EWNgGLQgZY12e9oa/S/YHIgsx4JNQdwirXaG/4zljEyMjOjy6HJM6ArCJmr0CQjyVBgr2DH++fMXRRqbHIoLfOpU5nELMyfKCasy/Pv/h+H3d4QBuOTgLnDIkl/CI8aSqCCtyPDmywuGb78+Mfz6+g/sAnxyYBdYREs/4pNklRVX4Gd49u4Jw////xk4WTkZfn35x4BPDmQ62AW/f/y/+Pvbf4YfP38y/Prxh+HX9z8MX359ZvgJdAE+ObgBZ98+C3xx7dva+8c/MTCzMTL8+/ef4fvPbww/P/1hwCcHN4DhAMOf8xufh7y8/m3Vw2NfGFjYmRi+//gBDMT/DHjlgCagxMLFrS/C9f5I/Pz393+srCk3PBBBNuGSQzEApPDSzhdxmn8k/v37yxD/+wckFkDiIIBPDqICidR0EJ2t7y0J9AMmwCeHqZrWIgAZ4PYDxftGYgAAAABJRU5ErkJggg=="],["expand","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAQ9JREFUOE9jcIoq/Y+MgYCBFAw2AMahmQEK7UL/kTGyHFFeAGkKOmoLxhgGIHNwYZCm0JMOYIzVACCAC2JzEUhTxFlnMCboAmRvIBsQc8kNjPG6AETjMiD+micYE+UCZAwSA2lKvuUDxnhdgIwLNqWDFcNw+n1/MEYWK9iYjqoJhGE2O8QU/FdplPsfesL+f9bjIBQMErOaqgtUjuYCEA1zNghbpyT815wgBbY570Xo/9znof/T7vn/V++X+N93sB2iB6YYhpENALFBCs2XqP0veB0OxiA2TDMIo2gGYZgXYBgkFrjQ7X/AAWsIXuAKFoNhFM34sN5Ehf8g/Pj9QyAXIY6iCB8GORvZ6RD8nwEA/ZSbmLCRhEoAAAAASUVORK5CYII="],["forth","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAB3RJTUUH1wkbCxU7wwzUCQAAAAlwSFlzAAAewQAAHsEBw2lUUwAAAARnQU1BAACxjwv8YQUAAACcUExURQAAADhUH3CvOHa3O2igNDZRHl2OLzhUHztYIFF7Kj5dIUBgIkNlJEhtJXi4Pna2Oz1cIUNlJEhtJk94KVF8KlN/K1SBK1WCLFaELVqJLlyOL1+SMGOYMmmiNGmjNG+sN2+tN3GvOHKwOHKxOXOzOXS0OnS1OnW2O3e3PXi4Pn28RH+9RoC+R4bCUInDVJHHXpvMa5zNbqTReabSfVhfgkQAAAAQdFJOUwAEh4eOm56goqSprLPi9P64yPeoAAAAZklEQVQY043FRwKCMAAAwUVAqVYUpAjYY6P9/29eAuSmcxn4ba6rAWIxUQIu3dMYA/K2OU6HgEP9qTK7D0iru3glvgyI3+VJ7D0ZsHsUt8jVZMDmeg6dIWBdbq0xYBXMlIClqfaHL3HSC6GZKibEAAAAAElFTkSuQmCC"],["up","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAD8GlDQ1BJQ0MgUHJvZmlsZQAAOI2NVd1v21QUP4lvXKQWP6Cxjg4Vi69VU1u5GxqtxgZJk6XpQhq5zdgqpMl1bhpT1za2021Vn/YCbwz4A4CyBx6QeEIaDMT2su0BtElTQRXVJKQ9dNpAaJP2gqpwrq9Tu13GuJGvfznndz7v0TVAx1ea45hJGWDe8l01n5GPn5iWO1YhCc9BJ/RAp6Z7TrpcLgIuxoVH1sNfIcHeNwfa6/9zdVappwMknkJsVz19HvFpgJSpO64PIN5G+fAp30Hc8TziHS4miFhheJbjLMMzHB8POFPqKGKWi6TXtSriJcT9MzH5bAzzHIK1I08t6hq6zHpRdu2aYdJYuk9Q/881bzZa8Xrx6fLmJo/iu4/VXnfH1BB/rmu5ScQvI77m+BkmfxXxvcZcJY14L0DymZp7pML5yTcW61PvIN6JuGr4halQvmjNlCa4bXJ5zj6qhpxrujeKPYMXEd+q00KR5yNAlWZzrF+Ie+uNsdC/MO4tTOZafhbroyXuR3Df08bLiHsQf+ja6gTPWVimZl7l/oUrjl8OcxDWLbNU5D6JRL2gxkDu16fGuC054OMhclsyXTOOFEL+kmMGs4i5kfNuQ62EnBuam8tzP+Q+tSqhz9SuqpZlvR1EfBiOJTSgYMMM7jpYsAEyqJCHDL4dcFFTAwNMlFDUUpQYiadhDmXteeWAw3HEmA2s15k1RmnP4RHuhBybdBOF7MfnICmSQ2SYjIBM3iRvkcMki9IRcnDTthyLz2Ld2fTzPjTQK+Mdg8y5nkZfFO+se9LQr3/09xZr+5GcaSufeAfAww60mAPx+q8u/bAr8rFCLrx7s+vqEkw8qb+p26n11Aruq6m1iJH6PbWGv1VIY25mkNE8PkaQhxfLIF7DZXx80HD/A3l2jLclYs061xNpWCfoB6WHJTjbH0mV35Q/lRXlC+W8cndbl9t2SfhU+Fb4UfhO+F74GWThknBZ+Em4InwjXIyd1ePnY/Psg3pb1TJNu15TMKWMtFt6ScpKL0ivSMXIn9QtDUlj0h7U7N48t3i8eC0GnMC91dX2sTivgloDTgUVeEGHLTizbf5Da9JLhkhh29QOs1luMcScmBXTIIt7xRFxSBxnuJWfuAd1I7jntkyd/pgKaIwVr3MgmDo2q8x6IdB5QH162mcX7ajtnHGN2bov71OU1+U0fqqoXLD0wX5ZM005UHmySz3qLtDqILDvIL+iH6jB9y2x83ok898GOPQX3lk3Itl0A+BrD6D7tUjWh3fis58BXDigN9yF8M5PJH4B8Gr79/F/XRm8m241mw/wvur4BGDj42bzn+Vmc+NL9L8GcMn8F1kAcXgSteGGAAABVUlEQVQ4EWNgoDWouVD5H58dTPgkHU7o/D/9YzM+JbjldLdI/T/6f8r/Bf8T/quvlsLpCkZsRqgtlPo/La6K4dSfLQzfv/1k4ORiZ1iw7BLDrfhnGOoxBCCaC4GajzF8+PYBbj47kLVy+Q2GWxnPUfSghIHhQlWgzYUMTxjuAm2GaP4PdAEI/wDi8EgNBu0Z8ijegZtmsdD4/8vvtxlYuVgZFNWEGOyNdcAuAGn+DrT9yPL7DO+/fwW7SJBTluFC0VWwXhaYG0/En4Ubxr2a57+yuSbD4W8HwNKcQPLL918MD6s/gdU8ZLgK08aA4gW46LffDN9/A+39+hOMQS5ghUuiMrAbAFbzneEHkAZhkEG/wAywBAqB1YBf3/8DAxGHDhTtDAzwMEAWZ+NkZPjO/YOBA+R2EACGHRsHhIlOYjXg8akvDBPvbGP4BTTgP8wQdJ2Dhg8A9SSD4ETIHK4AAAAASUVORK5CYII="],["down","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAD8GlDQ1BJQ0MgUHJvZmlsZQAAOI2NVd1v21QUP4lvXKQWP6Cxjg4Vi69VU1u5GxqtxgZJk6XpQhq5zdgqpMl1bhpT1za2021Vn/YCbwz4A4CyBx6QeEIaDMT2su0BtElTQRXVJKQ9dNpAaJP2gqpwrq9Tu13GuJGvfznndz7v0TVAx1ea45hJGWDe8l01n5GPn5iWO1YhCc9BJ/RAp6Z7TrpcLgIuxoVH1sNfIcHeNwfa6/9zdVappwMknkJsVz19HvFpgJSpO64PIN5G+fAp30Hc8TziHS4miFhheJbjLMMzHB8POFPqKGKWi6TXtSriJcT9MzH5bAzzHIK1I08t6hq6zHpRdu2aYdJYuk9Q/881bzZa8Xrx6fLmJo/iu4/VXnfH1BB/rmu5ScQvI77m+BkmfxXxvcZcJY14L0DymZp7pML5yTcW61PvIN6JuGr4halQvmjNlCa4bXJ5zj6qhpxrujeKPYMXEd+q00KR5yNAlWZzrF+Ie+uNsdC/MO4tTOZafhbroyXuR3Df08bLiHsQf+ja6gTPWVimZl7l/oUrjl8OcxDWLbNU5D6JRL2gxkDu16fGuC054OMhclsyXTOOFEL+kmMGs4i5kfNuQ62EnBuam8tzP+Q+tSqhz9SuqpZlvR1EfBiOJTSgYMMM7jpYsAEyqJCHDL4dcFFTAwNMlFDUUpQYiadhDmXteeWAw3HEmA2s15k1RmnP4RHuhBybdBOF7MfnICmSQ2SYjIBM3iRvkcMki9IRcnDTthyLz2Ld2fTzPjTQK+Mdg8y5nkZfFO+se9LQr3/09xZr+5GcaSufeAfAww60mAPx+q8u/bAr8rFCLrx7s+vqEkw8qb+p26n11Aruq6m1iJH6PbWGv1VIY25mkNE8PkaQhxfLIF7DZXx80HD/A3l2jLclYs061xNpWCfoB6WHJTjbH0mV35Q/lRXlC+W8cndbl9t2SfhU+Fb4UfhO+F74GWThknBZ+Em4InwjXIyd1ePnY/Psg3pb1TJNu15TMKWMtFt6ScpKL0ivSMXIn9QtDUlj0h7U7N48t3i8eC0GnMC91dX2sTivgloDTgUVeEGHLTizbf5Da9JLhkhh29QOs1luMcScmBXTIIt7xRFxSBxnuJWfuAd1I7jntkyd/pgKaIwVr3MgmDo2q8x6IdB5QH162mcX7ajtnHGN2bov71OU1+U0fqqoXLD0wX5ZM005UHmySz3qLtDqILDvIL+iH6jB9y2x83ok898GOPQX3lk3Itl0A+BrD6D7tUjWh3fis58BXDigN9yF8M5PJH4B8Gr79/F/XRm8m241mw/wvur4BGDj42bzn+Vmc+NL9L8GcMn8F1kAcXgSteGGAAABV0lEQVQ4EWNgGGjAiM0BItl8/7mFGBh+fWdg+A/EMPBi6icM9SwwSWRa1oyHITbKjuHem9sQ4a8MDHtXPmB4gawIysZqwK/v/xk4v3Iw/ABqBAEOIP71A8zEIJgwRIACbJyMDJxcIG2EAVYXQLRxgm0Gs7nZGdhwmIfdAC5WBk5WTgYGoEYQALIYfoNZmATcAIuFxv9ffr/NwArULCbLxnD3z3UGLi52hv/ffjKAIoKHk41BvpXvP8gIQU5ZhgtFV8ExghIthgtV/3fHpTE8YbjLcPfTTYafQMUgA2CAA2jguuX3GK5mPITrgzNgitQWSv2fFlfIcOrPMYYP3z7AhBlAnlm5/AbDrYznKHowYuFW/DPGrEX9DGYszgwCQBtBGkH0yg03MTTDTcfG0N0i9f/o/yn/F/xP+K++Wgrsd2zq8Io5nND57w7EeBURkqy5UEmZAYQsAADbOWDTAxBmkQAAAABJRU5ErkJggg=="],["pause","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB3klEQVQ4jX2Tz0sbURzE3wY8xH+j3i1evBSrUhpRQUwURfxZIirEEiF4k1iqYC/VFjwI4smYlBaClqIHqTFojKmmZq2godgWvejBQgV/RqZvNuERYtYHA8PM7Of0XSH4LFIeKZ/UXEb0rx7IC0XWK5XyC6vm14KWgHZlyG8JSlnlRzm5ls5rswFlBr3bFq7Ez9QW/qR+oCZsAzOqJlwlsz3ZbYMbI7fnAvxiyK33IHm3gV93OxjU3ZCZl6L/LTN2br2X+ZBwZAOepgEv9W7s3YaQTEXh0fvTgIDw0idTm7JbBTcGoCEPwJXoQvx6EbvXXzGQ6FMA+t2bFaNzJV6YA3q/t2H94iNilwvo33EqAH3s8jMiF5/AjSnAGW/G8r8ZhM5n0RdvVwD60LnP6LgxBXRu2TF/No4vfyfh3G5WAHpm82cT4MYU0Bqrhe/Ei8DJCDq+1SsA/YfTUdkNgxtTQFP0OaaO3Jg+9qAlWq0A9MzYcXMfkLkDR6Qcbw87MXHoRGPkmboDembsHJGKPHeQAdStPcHrAztGDxpRv1amAPTM2HGTHyDPs3jpEcb22/Bmvx2Pl4rUKdMzY8fN/VMuMQBWSQ5qAXFF0fMHM81tIud1SL2Tep8RveuBvCD92X9NeXkWOHF72gAAAABJRU5ErkJggg=="],["play","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAANjr9RwUqgAAACBjSFJNAACHDwAAjA0AAPmTAACE5QAAe4IAAOt1AAA/tAAAIlh1a16cAAAD8GlDQ1BJQ0MgUHJvZmlsZQAASMeNVd1v21QUP4lvXKQWP6Cxjg4Vi69VU1u5GxqtxgZJk6XpQhq5zdgqpMl1bhpT1za2021Vn/YCbwz4A4CyBx6QeEIaDMT2su0BtElTQRXVJKQ9dNpAaJP2gqpwrq9Tu13GuJGvfznndz7v0TVAx1ea45hJGWDe8l01n5GPn5iWO1YhCc9BJ/RAp6Z7TrpcLgIuxoVH1sNfIcHeNwfa6/9zdVappwMknkJsVz19HvFpgJSpO64PIN5G+fAp30Hc8TziHS4miFhheJbjLMMzHB8POFPqKGKWi6TXtSriJcT9MzH5bAzzHIK1I08t6hq6zHpRdu2aYdJYuk9Q/881bzZa8Xrx6fLmJo/iu4/VXnfH1BB/rmu5ScQvI77m+BkmfxXxvcZcJY14L0DymZp7pML5yTcW61PvIN6JuGr4halQvmjNlCa4bXJ5zj6qhpxrujeKPYMXEd+q00KR5yNAlWZzrF+Ie+uNsdC/MO4tTOZafhbroyXuR3Df08bLiHsQf+ja6gTPWVimZl7l/oUrjl8OcxDWLbNU5D6JRL2gxkDu16fGuC054OMhclsyXTOOFEL+kmMGs4i5kfNuQ62EnBuam8tzP+Q+tSqhz9SuqpZlvR1EfBiOJTSgYMMM7jpYsAEyqJCHDL4dcFFTAwNMlFDUUpQYiadhDmXteeWAw3HEmA2s15k1RmnP4RHuhBybdBOF7MfnICmSQ2SYjIBM3iRvkcMki9IRcnDTthyLz2Ld2fTzPjTQK+Mdg8y5nkZfFO+se9LQr3/09xZr+5GcaSufeAfAww60mAPx+q8u/bAr8rFCLrx7s+vqEkw8qb+p26n11Aruq6m1iJH6PbWGv1VIY25mkNE8PkaQhxfLIF7DZXx80HD/A3l2jLclYs061xNpWCfoB6WHJTjbH0mV35Q/lRXlC+W8cndbl9t2SfhU+Fb4UfhO+F74GWThknBZ+Em4InwjXIyd1ePnY/Psg3pb1TJNu15TMKWMtFt6ScpKL0ivSMXIn9QtDUlj0h7U7N48t3i8eC0GnMC91dX2sTivgloDTgUVeEGHLTizbf5Da9JLhkhh29QOs1luMcScmBXTIIt7xRFxSBxnuJWfuAd1I7jntkyd/pgKaIwVr3MgmDo2q8x6IdB5QH162mcX7ajtnHGN2bov71OU1+U0fqqoXLD0wX5ZM005UHmySz3qLtDqILDvIL+iH6jB9y2x83ok898GOPQX3lk3Itl0A+BrD6D7tUjWh3fis58BXDigN9yF8M5PJH4B8Gr79/F/XRm8m241mw/wvur4BGDj42bzn+Vmc+NL9L8GcMn8F1kAcXhLu7iPAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGHRFWHRTb2Z0d2FyZQBwYWludC5uZXQgNC4wLjVlhTJlAAABPElEQVQ4T2MAgaoTYuJgBrmg+rhcXupCmf9Fe2TDoUKkgYpDChkgA+pOKf4v2il3qWC3pCZUijhQBjUg6Kjt/9CTDv+rDiv8z9skuzRhPgMHVAl+ULwX1YCIs87/Yy65/S/erfA/Z71MGVQZblC4SxarAfHXPP8n3/IBukbudfY6KVeockxQuBm/Aen3/f9nPQ76n7VK+nDGKmFpqDYEyNlInAG5z0P/F7wO/5+5VHomSvjkrJQmyYDURdJbY3eKc0O1MzCkLyfOgKT50rdSl0obQLUhANBEvAakLJD+mTRbIg6qHBMATcZqQMoimf+x0yX7oMpwg4RZkigGgNgxkyX3J0wVlYAqwQ8SZkAMSFsi8z96otSz2EkS9lAp4kDcNKncuKlS/8N7JPOhQqSB6ElCMm4lSNFCNGBgAAAY+v7rj5j+SgAAAABJRU5ErkJggg=="],["swap","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAI9SURBVDjLpZNBS9RhEMZ/u60aZAdNSXdLrcxNS82DaRQVRBCUGngwwkOnvkB0yEt0qy/QKSrq5DUSQgLTSi01d80gcrXSTTdTViTU//+ded8ORihFYD4wl+FhYOY3T8A5x2YU3Ij54qOmp833zmX+14CWh431vm9OGs+8W9sPXOm49HsHqxarFhXbZ9W2EQxeECNnxUh0W2Y2kdwIcwtzJCbHY8+uvagBCAG0Vl3G4XDOYZ1jbPbj0ffJ0S6xQrT4AFszsxC1qFPycvJYXl45fOxG7ctXNweOB51zWBzW2V+l7MnbS21JLemFNBmhDIwIxhqMGowKxgjGNxkAISuWB2/uoqIE7Rb255dxMHKInO07CLkMxpMTpOZnmE7NEN4ZQUVITIyPDNyK1wEE1mJsud+QLUavl4cr2o5E64glhumJ9ag629TV1ttRd7VGNWQ/Dd6Ol/6VgguCDTjiYzGWvCWiReX4Pwxe2gPAX/Lx5rx1dAKt7c1OjCBGcOIoyC1kMb1IWTjKvqJSJqbGGR6Nk0gkOBitQMQyNDg0kmj/XA0QMr7hRPkp1ClqBbHKXNY88Q9xineVEC6IUFgQwZ62qFUsFm/Fq9p9Pvx66sl0XdD46y8sKiwuLZL6/o3nvd3Mp+cRJ4gVxCliFRFFjBqAQMOdM06MYHxB/FVEYqRPPG3z0/7qI/kazc/Pp7K6kuSXJEP9b2MznbM1f1D4l4oaI/Uq2qViJ1Ods9ENZ2Hy8dd+NdqtRivXUdhsnH8Cn6RstCM01H4AAAAASUVORK5CYII="],["collapse","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAPNJREFUOE9jcIoq/Y+MGXCACUc6/4MwlIsAyJrwGaA3UeE/CEO5CECMAYEL3f4HHLCG4AWuqGpAmpAxVBgOQM42X6L2v+B1OBiD2H0H27FahAFAmjUnSP1Pv+//P/d5KBin3fP/r94vgREecA6ya/Q7lf+HnrD/n/U4CAWDxKym6mJ3BcwbhZsz/iu0C8ExyBUgjCxWsDEdbgiMgRIOMDZIcfItHzAGscGSuADM+TAMEgNpir/mCca4DMBrKkhTzCU3MCbbBRFnncGYkAvgmkAA2YDQkw5gTJQLoEwUA4KO2oIxUQYgY5AYSBMyBiscJICBAQCpROGZ6kqHfwAAAABJRU5ErkJggg=="],["reset","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAL8SURBVDhPbZLZTxNRFMbnDzD65BsurC2tSFlENiG4EARBguzIGkBDwKAsIqA+EAIE45JgogaCxrdqgiQmxhAVjWIEpEioChRKUGmZTpeZaSlQ6OedoVYxnOSXe893vnPvzcml/o+V4WGJrbOmgm+tVLJN+UqeYL1Zp+TbLpy1qz7ud9m2D+u9tjq+qYTmLmbZuUvZIOsmNTnCauOvlWuX77dHuux/wzQ6sIvrbOziKrPBlqa64ZsrwF8u26Jxl4pg7WppxuSbHa52iuJry9rZgtOwZCdsUpgKC8nXtRqsDQ2SxgxY8pPddZbU2drSarHZdqsjxXTqqNl8MhYCXEkO1j59AFeeD6fFDMcXFazkQseECmxBuugROZMwtXKrQ0KxRdl95mPRMMdFgi3KxYZuEWtjn2FJT4HTTA4YHwN7rgTr8/PkkHFYUhNFrzkhjryssIgyRkWOmYKDYAoLxUr/MziNRmI6DUFzmkxwjI6Ie0tWJpwMA+5KA0whwaJmSkrqpgwSuZqRyGAMjyY3q2BXPgEjkRNkZAZarL56Le4FbfXlAGw9vTAGKETNKA1QUkxolJX28IEhOAJr4xOwPeiBkAswMSfAhMe6c/vTPtgePgbtLRdzY0o6Tem85WrdHl/opYFYffeevGIc+n1+ELR/ETTHt+/gWjug85SKGq0IU1K/5CFvf+71gwDXcQNO+wrMDVfF/F+4ztvYIPMxZOS6taX45BZKn5Z1d8HLf32BCAv+Clifv8A6TYO9cxd0TiEMBaWwkadvsBzY7l4s+MgheH/Igux0Wk4ixdTXe8wdDBvS7JdCYE4WDH1tA5aHR+AwMHDo9eDJ8HTnqzArVYgeAW1QhJKpur5T/EyWnkfHZ8mwpkhBYNpLhpkDIdAoDovMyIIw5envrs8eIcN90BsuNv+JxZor6dOHorWTPnKnmgxpO776HnBoYuJVS7e7ol1tW2O++JxsNiOvcTIkYlBNbp7w8seEtwzfImKhDjzUr8nMq14srtrtspOgqN9wa0YvcwzUuQAAAABJRU5ErkJggg=="],["rectangle-spacer","iVBORw0KGgoAAAANSUhEUgAAAAkAAAAECAYAAABcDxXOAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAA1JREFUGFdjGHSAgQEAAJQAAY8LvLEAAAAASUVORK5CYII="],["add-column","iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAPVJREFUOE9jUKtncAbi/0RgZwZsACQBUlDwOhwrJtqA3OehyIrBGE0MvwFZj4OwYqjmc9rN7Ft1mtknQ9WLQLUjDEi/749sGxiDxLSb2N6giwMNOwOkIYYAGTjDQLOR5RNME0wMxgcafAxIi+AMA3Q+ugFQ7Iw3DEDiMI3oGMMA9DCA8bFpBmGoOoQBybd8MDBUEYpByGJAjDAg/poniiSIDwzErzA+ugHazWwngDQiEGMuuWHFWk2sH2CaYBiYHs4BadRojDjrjKIITew8UNNO3RbOWUB2LRBjJqTQkw5YMUgOivEn5aCjtlgx0QYQgbEYwMAAAEqqlSGCjw+bAAAAAElFTkSuQmCC"],["up-rectangle","iVBORw0KGgoAAAANSUhEUgAAAAkAAAAECAYAAABcDxXOAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTFH80I3AAAAHklEQVQYV2PAAv5DaZwApACGsQJkBVgVYlMAxQwMABOrD/GvP+EWAAAAAElFTkSuQmCC"],["down-rectangle","iVBORw0KGgoAAAANSUhEUgAAAAkAAAAECAYAAABcDxXOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAABpJREFUGFdjgIL/eDAKIKgABggqgAE0BQwMAPTlD/Fpi0JfAAAAAElFTkSuQmCC"],["sortable","iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAAxSURBVChTY8AD/kNpkgBIEwwTDZA1Ea0ZmyYYHmQAmxNhmCAgSxMMkKUJBvBoYmAAAJCXH+FU1T8+AAAAAElFTkSuQmCC"],["empty","iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAANSURBVBhXY/j//z8DAAj8Av6IXwbgAAAAAElFTkSuQmCC"],["up-arrow","iVBORw0KGgoAAAANSUhEUgAAAAUAAAAKCAYAAAB8OZQwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAA9SURBVBhXbYvRCgAgCAOtqP//Y9tElw8NDrcDzd0DBCd7iSL3E0IvGOpf2fKXeZUFKDcYFMwBlDNWS76bXUM5P9In5AzyAAAAAElFTkSuQmCC"],["down-arrow","iVBORw0KGgoAAAANSUhEUgAAAAUAAAAKCAYAAAB8OZQwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAA+SURBVBhXhYvRCgAgCAOtqP//4+WWhtBDB1duqBUQ/2W5LLtSMFyW020skuecwOGj6QzfkuExt1LlcqICgG3S7z/SL/jVpgAAAABJRU5ErkJggg=="]];(function(){var each,img;for(var i=0;i<imgData.length;i++){each=imgData[i];img=new Image;img.src="data:image/png;base64,"+each[1];imageCache[each[0]]=img}})();Polymer("fin-hypergrid-behavior-base",{tableState:null,grid:null,editorTypes:["choice","textfield","color","slider","spinner","date"],featureChain:null,dataModel:null,getDataModel:function(){if(this.dataModel===null){this.setDataModel(this.getDefaultDataModel())}return this.dataModel},getDefaultDataModel:function(){var model=document.createElement("fin-hypergrid-data-model-base");return model},setDataModel:function(newDataModel){this.dataModel=newDataModel},clearObjectProperties:function(obj){for(var prop in obj){if(obj.hasOwnProperty(prop)){delete obj[prop]}}},ready:function(){this.readyInit()},readyInit:function(){this.cellProvider=this.createCellProvider();this.renderedColumnCount=30;this.renderedRowCount=60;this.dataUpdates={}},getState:function(){if(!this.tableState){this.tableState=this.getDefaultState();this.initColumnIndexes(this.tableState)}return this.tableState},clearState:function(){this.tableState=null},getDefaultState:function(){return{columnIndexes:[],fixedColumnIndexes:[],hiddenColumns:[],columnWidths:[],fixedColumnWidths:[],fixedColumnAutosized:[],rowHeights:{},fixedRowHeights:{},columnProperties:[],columnAutosized:[],fixedColumnCount:0,fixedRowCount:1}},setState:function(state){var tableState=this.getState();for(var key in state){if(state.hasOwnProperty(key)){tableState[key]=state[key]}}},resolveProperty:function(key){return this.grid.resolveProperty(key)},cellClicked:function(){},cellDoubleClicked:function(){},initColumnIndexes:function(tableState){var columnCount=this.getColumnCount();var fixedColumnCount=tableState.fixedColumnCount;var i;for(i=0;i<columnCount;i++){tableState.columnIndexes[i]=i}for(i=0;i<fixedColumnCount;i++){tableState.fixedColumnIndexes[i]=i}},insureColumnIndexesAreInitialized:function(){this.swapColumns(0,0)},swapColumns:function(src,tar){var tableState=this.getState();var fixedColumnCount=this.getState().fixedColumnCount;var indexes=tableState.columnIndexes;if(indexes.length===0){this.initColumnIndexes(tableState);indexes=tableState.columnIndexes}var tmp=indexes[src+fixedColumnCount];indexes[src+fixedColumnCount]=indexes[tar+fixedColumnCount];indexes[tar+fixedColumnCount]=tmp},translateColumnIndex:function(x){var tableState=this.getState();var fixedColumnCount=tableState.fixedColumnCount;var indexes=tableState.columnIndexes;if(indexes.length===0){return x}return indexes[x+fixedColumnCount]},unTranslateColumnIndex:function(x){var tableState=this.getState();return tableState.columnIndexes.indexOf(x)},setNextFeature:function(nextFeature){if(this.featureChain){this.featureChain.setNext(nextFeature)}else{this.featureChain=nextFeature}},installOn:function(grid){grid.setBehavior(this);this.initializeFeatureChain(grid)},initializeFeatureChain:function(grid){this.setNextFeature(document.createElement("fin-hypergrid-feature-key-paging"));this.setNextFeature(document.createElement("fin-hypergrid-feature-cell-click"));this.setNextFeature(document.createElement("fin-hypergrid-feature-overlay"));this.setNextFeature(document.createElement("fin-hypergrid-feature-column-resizing"));this.setNextFeature(document.createElement("fin-hypergrid-feature-row-resizing"));this.setNextFeature(document.createElement("fin-hypergrid-feature-cell-selection"));this.setNextFeature(document.createElement("fin-hypergrid-feature-column-moving"));this.setNextFeature(document.createElement("fin-hypergrid-feature-thumbwheel-scrolling"));this.setNextFeature(document.createElement("fin-hypergrid-feature-cell-editing"));this.setNextFeature(document.createElement("fin-hypergrid-feature-column-sorting"));this.setNextFeature(document.createElement("fin-hypergrid-feature-on-hover"));this.setNextFeature(document.createElement("fin-hypergrid-feature-column-autosizing"));this.featureChain.initializeOn(grid)},getCellProvider:function(){return this.cellProvider},setGrid:function(finGrid){this.grid=finGrid},getGrid:function(){return this.grid},createCellProvider:function(){var provider=document.createElement("fin-hypergrid-cell-provider");return provider},getTopLeftValue:function(){return""},_getValue:function(x,y){x=this.translateColumnIndex(x);var override=this.dataUpdates["p_"+x+"_"+y];if(override){return override}return this.getValue(x,y)},_setValue:function(x,y,value){x=this.translateColumnIndex(x);this.setValue(x,y,value)},_getFixedRowValue:function(x,y){x=this.translateColumnIndex(x);return this.getFixedRowValue(x,y)},getFixedColumnValue:function(x,y){return y+1},getRowCount:function(){return 1e15},_getColumnCount:function(){var tableState=this.getState();var fixedColumnCount=this.getState().fixedColumnCount;return this.getColumnCount()-tableState.hiddenColumns.length-fixedColumnCount},getFixedRowsHeight:function(){var count=this.getFixedRowCount();var total=0;for(var i=0;i<count;i++){total=total+this.getFixedRowHeight(i)}return total},getFixedRowHeight:function(rowNum){var tableState=this.getState();if(tableState.fixedRowHeights){var override=tableState.fixedRowHeights[rowNum];if(override){return override}}return this.resolveProperty("defaultFixedRowHeight")},setFixedRowHeight:function(rowNum,height){var tableState=this.getState();tableState.fixedRowHeights[rowNum]=Math.max(5,height);this.changed()},getRowHeight:function(rowNum){var tableState=this.getState();if(tableState.rowHeights){var override=tableState.rowHeights[rowNum];if(override){return override}}return this.getDefaultRowHeight()},getDefaultRowHeight:function(){if(!this.defaultRowHeight){this.defaultRowHeight=this.resolveProperty("defaultRowHeight")}return this.defaultRowHeight},setRowHeight:function(rowNum,height){var tableState=this.getState();tableState.rowHeights[rowNum]=Math.max(5,height);this.changed()},getFixedRowsMaxHeight:function(){var height=this.getFixedRowsHeight();return height},getFixedColumnsWidth:function(){var count=this.getFixedColumnCount();var total=0;for(var i=0;i<count;i++){total=total+this.getFixedColumnWidth(i)}return total},setFixedColumnWidth:function(colNumber,width){var tableState=this.getState();tableState.fixedColumnWidths[colNumber]=Math.max(5,width);this.changed()},getFixedColumnsMaxWidth:function(){var width=this.getFixedColumnsWidth();return width},getFixedColumnWidth:function(colNumber){var tableState=this.getState();var override=tableState.fixedColumnWidths[colNumber];if(override){return override}return this.resolveProperty("defaultFixedColumnWidth")},_getColumnWidth:function(x){x=this.translateColumnIndex(x);return this.getColumnWidth(x)},_setColumnWidth:function(x,width){x=this.translateColumnIndex(x);this.setColumnWidth(x,width);this.changed()},_setScrollPositionY:function(y){this.setScrollPositionY(y);this.changed()},_setScrollPositionX:function(x){this.setScrollPositionX(x);this.changed()},setRenderedColumnCount:function(count){this.renderedColumnCount=count},setRenderedRowCount:function(count){this.renderedRowCount=count},_getColumnAlignment:function(x){x=this.translateColumnIndex(x);return this.getColumnAlignment(x)},getTopLeftAlignment:function(){return"center"},getFixedColumnAlignment:function(){return this.resolveProperty("fixedColumnAlign")},_getFixedRowAlignment:function(x,y){x=this.translateColumnIndex(x);return this.getFixedRowAlignment(x,y)},topLeftClicked:function(grid,mouse){if(mouse.gridCell.x<this.getState().fixedColumnCount){this.fixedRowClicked(grid,mouse)}else{console.log("top Left clicked: "+mouse.gridCell.x,mouse)}},_fixedRowClicked:function(grid,mouse){var x=this.translateColumnIndex(this.getScrollPositionX()+mouse.gridCell.x-this.getFixedColumnCount());var translatedPoint=this.grid.rectangles.point.create(x,mouse.gridCell.y);mouse.gridCell=translatedPoint;this.fixedRowClicked(grid,mouse)},_fixedColumnClicked:function(grid,mouse){var translatedPoint=this.grid.rectangles.point.create(mouse.gridCell.x,this.getScrollPositionY()+mouse.gridCell.y-this.getFixedRowCount());mouse.gridCell=translatedPoint;this.fixedColumnClicked(grid,mouse)},setCursor:function(grid){grid.updateCursor();this.featureChain.setCursor(grid)},onMouseMove:function(grid,event){if(this.featureChain){this.featureChain.handleMouseMove(grid,event);this.setCursor(grid)}},onTap:function(grid,event){if(this.featureChain){this.featureChain.handleTap(grid,event);this.setCursor(grid)}},onWheelMoved:function(grid,event){if(this.featureChain){this.featureChain.handleWheelMoved(grid,event);this.setCursor(grid)}},onMouseUp:function(grid,event){if(this.featureChain){this.featureChain.handleMouseUp(grid,event);this.setCursor(grid)}},onMouseDrag:function(grid,event){if(this.featureChain){this.featureChain.handleMouseDrag(grid,event);this.setCursor(grid)}},onKeyDown:function(grid,event){if(this.featureChain){this.featureChain.handleKeyDown(grid,event);this.setCursor(grid)}},onKeyUp:function(grid,event){if(this.featureChain){this.featureChain.handleKeyUp(grid,event);this.setCursor(grid)}},onDoubleClick:function(grid,event){if(this.featureChain){this.featureChain.handleDoubleClick(grid,event);this.setCursor(grid)}},onHoldPulse:function(grid,event){if(this.featureChain){this.featureChain.handleHoldPulse(grid,event);this.setCursor(grid)}},toggleColumnPicker:function(){if(this.featureChain){this.featureChain.toggleColumnPicker(this.getGrid())}},handleMouseDown:function(grid,event){if(this.featureChain){this.featureChain.handleMouseDown(grid,event);this.setCursor(grid)}},handleMouseExit:function(grid,event){if(this.featureChain){this.featureChain.handleMouseExit(grid,event);this.setCursor(grid)}},_getCellEditorAt:function(x,y){noop(y);x=this.translateColumnIndex(x);return this.getCellEditorAt(x)},changed:function(){},shapeChanged:function(){},isColumnReorderable:function(){return true},getColumnProperties:function(columnIndex){var tableState=this.getState();var properties=tableState.columnProperties[columnIndex];if(!properties){properties={};tableState.columnProperties[columnIndex]=properties}return properties},setColumnProperty:function(columnIndex,key,value){var properties=this.getColumnProperties(columnIndex);properties[key]=value;this.changed()},getColumnDescriptors:function(){this.insureColumnIndexesAreInitialized();var tableState=this.getState();var columnCount=tableState.columnIndexes.length;var fixedColumnCount=this.getState().fixedColumnCount;var labels=[];for(var i=0;i<columnCount;i++){var id=tableState.columnIndexes[i];if(id>=fixedColumnCount){labels.push({id:id,label:this.getHeader(id),field:this.getField(id)})}}return labels},getField:function(colIndex){return colIndex},getHeader:function(colIndex){return this.getFixedRowValue(colIndex,0)},setColumnDescriptors:function(list){var tableState=this.getState();var fixedColumnCount=this.getState().fixedColumnCount;var columnCount=list.length;var indexes=[];var i;for(i=0;i<fixedColumnCount;i++){indexes.push(i)}for(i=0;i<columnCount;i++){indexes.push(list[i].id)}tableState.columnIndexes=indexes;this.changed()},getHiddenColumnDescriptors:function(){var tableState=this.getState();var indexes=tableState.hiddenColumns;var labels=new Array(indexes.length);for(var i=0;i<labels.length;i++){var id=indexes[i];labels[i]={id:id,label:this.getHeader(id),field:this.getField(id)}}return labels},setHiddenColumnDescriptors:function(list){var columnCount=list.length;var indexes=new Array(columnCount);for(var i=0;i<columnCount;i++){indexes[i]=list[i].id}var tableState=this.getState();tableState.hiddenColumns=indexes;this.changed()},hideColumns:function(arrayOfIndexes){var tableState=this.getState();var indexes=tableState.hiddenColumns;var order=tableState.columnIndexes;for(var i=0;i<arrayOfIndexes.length;i++){var each=arrayOfIndexes[i];if(indexes.indexOf(each)===-1){indexes.push(each);order.splice(order.indexOf(each),1)}}},getFixedColumnCount:function(){var tableState=this.getState();return tableState.fixedColumnCount||0},setFixedColumnCount:function(numberOfFixedColumns){var tableState=this.getState();tableState.fixedColumnCount=numberOfFixedColumns},getFixedRowCount:function(){return this.tableState.fixedRowCount||0},setFixedRowCount:function(numberOfFixedRows){this.tableState.fixedRowCount=numberOfFixedRows},openEditor:function(div){var container=document.createElement("div");var hidden=document.createElement("fin-hypergrid-dnd-list");var visible=document.createElement("fin-hypergrid-dnd-list");container.appendChild(hidden);container.appendChild(visible);this.beColumnStyle(hidden.style);hidden.title="hidden columns";hidden.list=this.getHiddenColumnDescriptors();this.beColumnStyle(visible.style);visible.style.left="50%";visible.title="visible columns";visible.list=this.getColumnDescriptors();div.lists={hidden:hidden.list,visible:visible.list};div.appendChild(container);return true},closeEditor:function(div){noop(div);var lists=div.lists;this.setColumnDescriptors(lists.visible);this.setHiddenColumnDescriptors(lists.hidden);return true},endDragColumnNotification:function(){},beColumnStyle:function(style){
style.top="5%";style.position="absolute";style.width="50%";style.height="99%";style.whiteSpace="nowrap"},getCursorAt:function(){return null},getValue:function(x,y){return x+", "+y},setValue:function(x,y,value){this.dataUpdates["p_"+x+"_"+y]=value},getColumnCount:function(){return 300},getColumnWidth:function(x){var tableState=this.getState();var override=tableState.columnWidths[x];if(override){return override}return this.resolveProperty("defaultColumnWidth")},setColumnWidth:function(x,width){var tableState=this.getState();tableState.columnWidths[x]=Math.max(5,width)},getColumnAlignment:function(){return"center"},setScrollPositionX:function(x){this.getDataModel().setScrollPositionX(x)},getScrollPositionX:function(){return this.getDataModel().getScrollPositionX()},setScrollPositionY:function(y){this.getDataModel().setScrollPositionY(y)},getScrollPositionY:function(){return this.getDataModel().getScrollPositionY()},getFixedRowAlignment:function(x,y){noop(x,y);return this.resolveProperty("fixedRowAlign")},getFixedRowValue:function(x){return x},getCellEditorAt:function(x,y){noop(x,y);var cellEditor=this.grid.resolveCellEditor("textfield");return cellEditor},fixedRowClicked:function(grid,mouse){this.toggleSort(mouse.gridCell.x)},toggleSort:function(colIndex){console.log("toggleSort("+colIndex+")")},fixedColumnClicked:function(grid,mouse){console.log("fixedColumnClicked("+mouse.gridCell.x+", "+mouse.gridCell.y+")")},highlightCellOnHover:function(isColumnHovered,isRowHovered){return isColumnHovered&&isRowHovered},getColumnId:function(x){x=this.translateColumnIndex(x);var col=this.getFixedRowValue(x,0);return col},getImage:function(key){var image=imageCache[key];return image},setImage:function(key,image){imageCache[key]=image},checkColumnAutosizing:function(fixedMinWidths,minWidths){var self=this;var tableState=this.getState();var myFixed=tableState.fixedColumnWidths;var myWidths=tableState.columnWidths;var repaint=false;var a,b,c,d=0;for(c=0;c<fixedMinWidths.length;c++){a=myFixed[c];b=fixedMinWidths[c];d=tableState.fixedColumnAutosized[c];if(a!==b||!d){myFixed[c]=!d?b:Math.max(a,b);tableState.fixedColumnAutosized[c]=true;repaint=true}}for(c=0;c<minWidths.length;c++){var ti=this.translateColumnIndex(c);a=myWidths[ti];b=minWidths[c];d=tableState.columnAutosized[c];if(a!==b||!d){myWidths[ti]=!d?b:Math.max(a,b);tableState.columnAutosized[c]=true;repaint=true}}if(repaint){setTimeout(function(){self.shapeChanged()})}},cellPrePaintNotification:function(){},cellFixedRowPrePaintNotification:function(){},cellFixedColumnPrePaintNotification:function(){},cellTopLeftPrePaintNotification:function(){},enhanceDoubleClickEvent:function(){},autosizeColumns:function(){var self=this;setTimeout(function(){var tableState=self.getState();tableState.fixedColumnAutosized=[];tableState.columnAutosized=[]},40)}})})();</script></polymer-element><polymer-element name="fin-hypergrid-behavior-default" extends="fin-hypergrid-behavior-base" assetpath="/dev/fin-hypergrid/polymer/html/behaviors/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){var alphaFor=function(i){var quo=Math.floor(i/26);var rem=i%26;var code="";if(quo>0){code+=String.fromCharCode("A".charCodeAt(0)+quo-1)}code+=String.fromCharCode("A".charCodeAt(0)+rem);return code};var a="ABCDEFGHIJKLMNOPQRSTUVWXYZ";Polymer("fin-hypergrid-behavior-default",{getValue:function(x,y){return x+", "+a[y%26]},getFixedRowValue:function(x){return alphaFor(x)},getFixedColumnCount:function(){return 1}})})();</script></polymer-element><polymer-element name="fin-hypergrid-behavior-gol" extends="fin-hypergrid-behavior-base" assetpath="/dev/fin-hypergrid/polymer/html/behaviors/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){var noop=function(){};var patterns=[[[false,true,true,true,false],[true,false,true,false,true],[false,false,true,false,false]],[[false,true,false],[true,false,false],[true,true,true]]];var colors=["#ffffff","#ffffff","#efefef","#00e7e7","#00dfdf","#00d7d7","#00cfcf","#00c7c7"];Polymer("fin-hypergrid-behavior-gol",{rows:45,columns:75,data:[],buffer:[],running:false,ready:function(){this.readyInit();this.rows=this.getAttribute("rows")||this.rows;this.columns=this.getAttribute("columns")||this.columns;this.resetPetriDish();this.running=false},createCellProvider:function(){var provider=document.createElement("fin-hypergrid-cell-provider");provider.cellCache.simpleCellRenderer.paint=function(gc,x,y,width,height){var weight=this.config.value[1];if(weight===0){return}var color=colors[weight];if(this.config.value[0]){color=this.config.fgColor}gc.fillStyle=color;gc.fillRect(x,y,width,height)};return provider},resetPetriDish:function(){this.data=[];this.buffer=[];this.initializeData(this.data);this.initializeData(this.buffer);this.populate();this.changed()},populate:function(){var x=0;var y=0;for(var i=0;i<15;i++){y=Math.round(Math.random()*this.rows*.6);x=Math.round(Math.random()*this.columns*.6);this.applyPatternAt(this.data,x,y,patterns[i%2],i%4)}},initializeData:function(array2D){for(var c=0;c<this.columns;c++){var col=[];array2D.push(col);for(var r=0;r<this.rows;r++){col.push([false,0])}}},toggleRunning:function(){this.running=!this.running;if(this.running){this.startLife()}},startLife:function(){if(!this.running){return}for(var c=1;c<this.columns-2;c++){for(var r=1;r<this.rows-2;r++){this.computeLifeAt(c,r)}}var temp=this.buffer;this.buffer=this.data;this.data=temp;this.changed();setTimeout(this.startLife.bind(this),125)},computeLifeAt:function(x,y){var me=this._getValue(x,y);var total=this.getNeighborCount(x,y);me[1]=total;if(me[0]){if(total<2){this.buffer[x][y]=[false,0]}else if(total<4){this.buffer[x][y]=[true,1]}else{this.buffer[x][y]=[false,0]}}else{this.buffer[x][y]=[total===3,total]}},getNeighborCount:function(x,y){var data=this.data;var total=0;if(data[x-1][y-1][0]){total++}if(data[x-1][y][0]){total++}if(data[x-1][y+1][0]){total++}if(data[x][y-1][0]){total++}if(data[x][y+1][0]){total++}if(data[x+1][y-1][0]){total++}if(data[x+1][y][0]){total++}if(data[x+1][y+1][0]){total++}return total},getValue:function(x,y){return this.data[x][y]},setValue:function(x,y,value){this.data[x][y]=value},getFixedColumnValue:function(x,y){return y},getFixedRowValue:function(x,y){noop(x,y);return""},getFixedColumnCount:function(){return 0},getFixedRowCount:function(){return 0},getColumnCount:function(){return this.data.length},getRowCount:function(){return this.data[0].length},getRowHeight:function(y){noop(y);return 10},getColumnWidth:function(x){noop(x);return 10},getNextState:function(){if(this.running){return"pause"}else{return"play"}},onTap:function(grid,mouse){var mX=this.getScrollPositionX()+mouse.gridCell.x;var mY=this.getScrollPositionY()+mouse.gridCell.y;var v=this._getValue(mX,mY)[0];this._setValue(mX,mY,[!v,1]);this.changed()},applyPatternAt:function(array,c,r,pattern,dir){var w=pattern.length;var h=pattern[0].length;var x=0;var y=0;if(dir===0){for(x=0;x<w;x++){for(y=0;y<h;y++){array[x+c][y+r]=[pattern[w-x-1][y],1]}}}else if(dir===1){for(x=0;x<w;x++){for(y=0;y<h;y++){array[x+c][y+r]=[pattern[x][y],1]}}}else if(dir===2){for(x=0;x<w;x++){for(y=0;y<h;y++){array[y+c][x+r]=[pattern[x][y],1]}}}else{for(x=0;x<w;x++){for(y=0;y<h;y++){array[y+c][x+r]=[pattern[w-x-1][y],1]}}}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-behavior-in-memory" extends="fin-hypergrid-behavior-base" assetpath="/dev/fin-hypergrid/polymer/html/behaviors/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){var alphaFor=function(i){var quo=Math.floor(i/26);var rem=i%26;var code="";if(quo>0){code+=String.fromCharCode("A".charCodeAt(0)+quo-1)}code+=String.fromCharCode("A".charCodeAt(0)+rem);return code};function rnd(max){return Math.floor(Math.random()*max)}var barRandomOffsets=[];for(var i=0;i<20;i++){barRandomOffsets.push([]);for(var r=0;r<10;r++){barRandomOffsets[i].push(10-rnd(20))}}Polymer("fin-hypergrid-behavior-in-memory",{ready:function(){this.rows=5e3;this.columns=100;this.readyInit();this.sortStates=[" -"," ↑"," ↓"];this.permuteInterval=50;this.values=new Array(this.rows*this.columns);this.order=[];this.createSort(0,2);this.createSort(0,14);this.createSort(0,22);this.initOrder();this.initialize();this.permute();this.reorder()},getDefaultState:function(){return{columnIndexes:[],fixedColumnIndexes:[],hiddenColumns:[],columnWidths:[],fixedColumnWidths:[],fixedColumnAutosized:[],rowHeights:{},fixedRowHeights:{},columnProperties:[],columnAutosized:[],fixedColumnCount:0,fixedRowCount:1,sorts:[],sortLookup:{},sorted:{}}},createCellProvider:function(){var provider=document.createElement("fin-hypergrid-cell-provider");provider.getCell=function(config){var renderer=provider.cellCache.simpleCellRenderer;config.halign="left";var x=config.x;if(x===41){renderer=provider.cellCache.sliderCellRenderer}else if(x===23){renderer=provider.cellCache.sparkbarCellRenderer}else if(x===3){renderer=provider.cellCache.sparklineCellRenderer}else if(x===2){var hex=Math.floor(Math.max(config.value,30)*255/100).toString(16);if(hex.length<1){hex="0"+hex}var bgColor="#"+"00"+hex+"00";config.bgColor=bgColor}renderer.config=config;return renderer};return provider},setValues:function(c){var self=this;for(var x=c.xstart;x<c.xstop;x=x+c.xinc){for(var y=c.ystart;y<c.ystop;y=y+c.yinc){this.setRandomValue(x,y,c.cutoff)}}self.changed()},initialize:function(){var config={xstart:0,xstop:this._getColumnCount(),xinc:1,ystart:0,ystop:this.getRowCount(),yinc:1,cutoff:2};this.setValues(config)},permute:function(){var self=this;var x=this.getScrollPositionX();var y=this.getScrollPositionY();var config={xstart:x,xstop:x+this.renderedColumnCount,xinc:1,ystart:y,ystop:y+this.renderedRowCount,yinc:1,cutoff:.05};this.setValues(config);setTimeout(function(){self.permute()},self.permuteInterval)},getCellEditorAt:function(x,y){var type=x!==9?"textfield":this.editorTypes[y%this.editorTypes.length];var cellEditor=this.grid.resolveCellEditor(type);return cellEditor},getColumnCount:function(){return this.columns},setRandomValue:function(col,row,cutoff){var rand=Math.random();var val=this.getValue(col,row);var rndV;if(rand>cutoff){return}if(col===13){val=rand<.1?true:false;this.setValue(col,row,val)}else if(col===23){if(!val){val=[rnd(100),rnd(100),rnd(100),rnd(100),rnd(100),rnd(100),rnd(100),rnd(100),rnd(100),rnd(100)]}else{rndV=Math.floor(60*rand);if(rndV>19){return}var rndOffsets=barRandomOffsets[rndV];for(var i=0;i<rndOffsets.length;i++){val[i]=Math.min(Math.max(0,val[i]+rndOffsets[i]),100)}}this.setValue(col,row,val)}else if(col===3){if(!val){val=[rnd(100),rnd(100),rnd(100),rnd(100),rnd(100),rnd(100),rnd(100),rnd(100),rnd(100),rnd(100)]}else{rndV=Math.floor(8e3*rand);if(rndV>99){return}if(val.shift){val.shift();val.push(rndV)}}this.setValue(col,row,val)}else if(col%10===0){val=rand<.1?false:true;this.setValue(col,row,val)}else if(col===9){if(val){return}var hex=row.toString(16).toUpperCase();while(hex.length<6){hex="0"+hex}val="0x"+hex;this.setValue(col,row,val)}else if(col%6===0){if(val){return}var profound="Quidquid latine dictum sit, altum sonatur.";this.setValue(col,row,profound)}else if(col%4===0){var ipsum="Lorem ipsum dolor sit amet, malis repudiare mei in. Cu munere expetendis mea, affert aliquid definiebas at nam. Te scripta delectus singulis mel, et vidit error legere eum, ea latine feugait ponderum vix. Ius ei electram patrioque, et eum propriae deseruisse necessitatibus. Epicurei adipisci ex duo. Quidam iudicabit ullamcorper ex vel, per quot ipsum ad, libris quaeque iudicabit et usu. Ut postea nominavi cum, id eius porro mundi qui. Nec ex altera dolorum definiebas, consul viderer ex est. ";var index=Math.max(0,rand*ipsum.length-20);val=ipsum.slice(index,index+20).toUpperCase();this.setValue(col,row,val)}else if(col===2||col===14||col===22){var v=Math.min(Math.floor(rand*2e3),100);this.setValue(col,row,Math.max(v))}else if(col===41){this.setValue(col,row,Math.random())}else{this.setValue(col,row,rand)}},indexOf:function(row,col){var index=col*this.rows+row;return index},createSort:function(type,col){var self=this;var that={};var tableState=this.getState();that.type=type;that.col=col;that.value=function(array,index){return array[self.indexOf(self.order[index],col)]};that.compare=function(array,first,last){var x=that.value(array,first),y=that.value(array,last);if(typeof x==="number"){if(that.type===1){if(!y){return-1}return x-y}else{if(!y){return 1}return y-x}}else{if(that.type===1){if(!y){return-1}return x<y?-1:1}else{if(!y){return 1}return y<x?-1:1}}return 0};tableState.sorts.push(that);tableState.sortLookup[col]=that},swap:function(array,x,y){var tmp=this.order[x];this.order[x]=this.order[y];this.order[y]=tmp},compare:function(array,first,last){var comp=0;var tableState=this.getState();for(var i=0;i<tableState.sorts.length;++i){var sort=tableState.sorts[i];if(sort.type!==0){comp=sort.compare(array,first,last);if(comp===0){continue}break}}return comp},initOrder:function(){this.order=[];for(var i=0;i<this.rows;++i){this.order[i]=i}},quicksort:function(array,first,last,depth){var tableState=this.getState();if(depth>1e3){console.log("sort aborted!");return}var pivot=0;if(depth===0){if(tableState.sorts.length<=0){return}var sort=tableState.sorts[0];while(!sort.value(array,last)&&last>first){--last}var sorted=true;for(pivot=first;pivot<last;++pivot){if(this.compare(array,pivot,pivot+1)>0){sorted=false;break}}if(sorted){return}}while(first<last){var right=last;var left=first;pivot=first+last>>1;if(pivot<0||pivot>=last){break}while(right>=left){while(left<=right&&this.compare(array,left,pivot)<=0){++left}while(left<=right&&this.compare(array,right,pivot)>0){--right}if(left>right){break}this.swap(array,left,right);if(pivot===right){pivot=left}left++;right--}this.swap(array,pivot,right);right--;if(Math.abs(right-first)>Math.abs(last-left)){if(left<last){this.quicksort(array,left,last,depth+1)}last=right}else{if(first<right){this.quicksort(array,first,right,depth+1)}first=left}}},reorder:function(){this.initOrder();this.quicksort(this.values,0,this.rows-1,0)},orderOf:function(y){var row=this.order[y];return row},setValue:function(x,y,value){var row=this.orderOf(y);var index=this.indexOf(row,x);this.values[index]=value},getValue:function(x,y){var row=this.orderOf(y);var index=this.indexOf(row,x);return this.values[index]},getRowCount:function(){return this.rows},getFixedRowValue:function(x){var sortIndicator="";var tableState=this.getState();if(tableState.sortLookup[x]&&!tableState.sorted[x]){tableState.sorted[x]=0;sortIndicator=this.sortStates[tableState.sorted[x]]}if(tableState.sorted[x]){sortIndicator=this.sortStates[tableState.sorted[x]]}return alphaFor(x)+sortIndicator},fixedRowClicked:function(grid,mouse){if([2,14,22].indexOf(mouse.gridCell.x)===-1){return}this.toggleSort(mouse.gridCell.x)},toggleSort:function(columnIndex){var tableState=this.getState();var current=tableState.sorted[columnIndex];var stateCount=this.sortStates.length;var sortStateIndex=(current+1)%stateCount;tableState.sorted[columnIndex]=sortStateIndex;tableState.sortLookup[columnIndex].type=sortStateIndex;this.reorder();this.changed()},getFixedColumnCount:function(){return 1}})})();</script></polymer-element><polymer-element name="fin-hypergrid-behavior-json" extends="fin-hypergrid-behavior-base" assetpath="/dev/fin-hypergrid/polymer/html/behaviors/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";var validIdentifierMatch=/^(?!(?:abstract|boolean|break|byte|case|catch|char|class|const|continue|debugger|default|delete|do|double|else|enum|export|extends|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|let|long|native|new|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|try|typeof|var|void|volatile|while|with|yield)$)[\x24\x41-\x5A\x5F\x61-\x7A\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376-\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E-\u066F\u0671-\u06D3\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4-\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0-\u0AE1\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58-\u0C59\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0-\u0CE1\u0CF1-\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E46\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065-\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE-\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5-\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A-\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC][\x24\x30-\x39\x41-\x5A\x5F\x61-\x7A\xA0\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376-\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7-\u09C8\u09CB-\u09CE\u09D7\u09DC-\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A3C\u0A3E-\u0A42\u0A47-\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47-\u0B48\u0B4B-\u0B4D\u0B56-\u0B57\u0B5C-\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82-\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55-\u0C56\u0C58-\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5-\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1-\u0CF2\u0D02-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2-\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18-\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772-\u1773\u1780-\u17D3\u17D7\u17DC-\u17DD\u17E0-\u17E9\u180B-\u180E\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2000-\u200A\u200C-\u200D\u2028-\u2029\u202F\u203F-\u2040\u2054\u205F\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3000\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC-\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33-\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFEFF\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\uFFFE]*$/;(function(){Polymer("fin-hypergrid-behavior-json",{data:[],headers:null,fields:null,totals:[],ready:function(){this.readyInit();this.sortStates=[undefined,"up-arrow","down-arrow"]},getDefaultState:function(){return{columnIndexes:[],fixedColumnIndexes:[],hiddenColumns:[],columnWidths:[],fixedColumnWidths:[],fixedColumnAutosized:[],rowHeights:{},fixedRowHeights:{},columnProperties:[],columnAutosized:[],sorted:[],fixedColumnCount:1,fixedRowCount:1}},isValidIdentifer:function(string){return 0===(string+"").search(validIdentifierMatch)},createCellProvider:function(){var tableState=this.getState();var provider=document.createElement("fin-hypergrid-cell-provider");provider.getTopLeftCell=function(config){var empty=this.cellCache.emptyCellRenderer;var render=this.cellCache.simpleCellRenderer;empty.config=config;render.config=config;if(tableState.fixedColumnCount>0){return render}else{return empty}};return provider},getTopLeftAlignment:function(x,y){return this.getFixedRowAlignment(x,y)},getFixedRowAlignment:function(x,y){if(y===0){return"center"}var cell=this.cellProvider.getCell({x:x,y:y});return cell.config.halign},getFixedColumnAlignment:function(x,y){var cell=this.cellProvider.getCell({x:x,y:y});return cell.config.halign},getTopLeftValue:function(x,y){return this.getFixedRowValue(x,y)},setHeaders:function(headerLabels){this.headers=headerLabels},getHeaders:function(){if(!this.headers||this.headers.length===0){this.setHeaders(this.getDefaultHeaders())}return this.headers},getHeader:function(x){var headers=this.getHeaders();return headers[x]},getDefaultHeaders:function(){var self=this;var fields=this.getFields();if(fields.length===0){return[]}var headers=fields.map(function(e){return self.headerify(e)});return headers},headerify:function(string){var pieces=string.replace(/[_-]/g," ").replace(/[A-Z]/g," $&").split(" ").map(function(s){return s.charAt(0).toUpperCase()+s.slice(1)});return pieces.join(" ")},setFields:function(fieldNames){this.fields=fieldNames},getFields:function(){if(!this.fields||this.fields.length===0){this.setFields(this.getDefaultFields())}return this.fields},getField:function(colIndex){return this.getFields()[colIndex]},getDefaultFields:function(){if(this.data&&this.data.length===0){return[]}var fields=[].concat(Object.getOwnPropertyNames(this.data[0]).filter(function(e){return e.substr(0,2)!=="__"}));return fields},setData:function(arrayOfUniformObjects){this.data=arrayOfUniformObjects;this.initColumnIndexes(this.getState());this.dataModified()},getData:function(){return this.data},dataModified:function(){this.initDataIndexes();this.applySorts();this.changed()},setTotals:function(nestedArray){this.totals=nestedArray;this.changed()},setColumns:function(columnDefinitions){var fields=new Array(columnDefinitions.length);var headers=new Array(columnDefinitions.length);for(var i=0;i<columnDefinitions.length;i++){var each=columnDefinitions[i];fields[i]=each.field;headers[i]=each.title}this.setFields(fields);this.setHeaders(headers)},initDataIndexes:function(){for(var i=0;i<this.data.length;i++){this.data[i].__si=i;this.data[i].__i=i}},getValue:function(x,y){var fields=this.getFields();var row=this.data[y];var result=row[fields[x]];if(typeof result==="function"){result=row[fields[x]]()}return result},setValue:function(x,y,value){var fields=this.getFields();this.data[y][fields[x]]=value},getFixedColumnValue:function(x,y){return this.getValue(x,y)},getFixedRowValue:function(x,y){if(y===0){var tableState=this.getState();var headers=this.getHeaders();var sortIndex=tableState.sorted[x]||0;return[undefined,headers[x],this.getImage(this.sortStates[sortIndex])]}else{return this.totals[y-1][x]}},getRowCount:function(){return this.data.length},getColumnCount:function(){var fields=this.getFields();return fields.length},setState:function(memento){var tableState=this.getState();for(var key in memento){if(memento.hasOwnProperty(key)){tableState[key]=memento[key]}}this.applySorts();this.changed()},applySorts:function(){var state=this.getState();var sorts=state.sorted;if(!sorts){return}var newData=new Array(this.data.length);var i;for(i=0;i<this.data.length;i++){var each=this.data[i];newData[each.__si]=each}this.data=newData;for(i=0;i<sorts.length;i++){if(sorts[i]>0){this.toggleSort(i,0);return}}},isComputedField:function(columnId){var row=this.data[0];var first=row[columnId];return typeof first==="function"},toggleSort:function(columnIndex,incrementIt){var tableState=this.getState();if(incrementIt===undefined){incrementIt=1}this.grid.clearSelections();var fields=this.getFields();if(columnIndex>=fields.length){return}var current=tableState.sorted[columnIndex]||0;var stateCount=this.sortStates.length;var sortStateIndex=(current+incrementIt)%stateCount;var i=0;for(;i<fields.length;i++){tableState.sorted[i]=0}tableState.sorted[columnIndex]=sortStateIndex;var colName=fields[columnIndex];if(sortStateIndex===0){var newData=new Array(this.data.length);for(i=0;i<this.data.length;i++){var each=this.data[i];newData[each.__si]=each}this.data=newData}else if(sortStateIndex>0){var theSorter;if(this.isValidIdentifer(colName)){if(this.isComputedField(colName)){theSorter=eval("(function (a, b) {"+" var first = a."+colName+"();"+" var second = b."+colName+"();"+" if (first === second) {"+" return a.__i - b.__i;};"+" if (first < second) {"+" return -1;};"+" return 1;"+"})")}else{theSorter=eval("(function (a, b) {"+" var first = a."+colName+";"+" var second = b."+colName+";"+" if (first === second) {"+" return a.__i - b.__i;};"+" if (first < second) {"+" return -1;};"+" return 1;"+"})")}this.data.sort(theSorter)}else{if(this.isComputedField(colName)){theSorter=function(a,b){var first=a[colName]();var second=b[colName]();if(first===second){return a.__i-b.__i}if(first<second){return-1}return 1}}else{theSorter=function(a,b){var first=a[colName];var second=b[colName];if(first===second){return a.__i-b.__i}if(first<second){return-1}return 1}}this.data.sort()}}if(sortStateIndex===2){this.data=this.data.reverse()}for(i=0;i<this.data.length;i++){this.data[i].__i=i}this.changed()},getRow:function(y){return this.data[y]},cellPrePaintNotification:function(config){var row=this.getRow(config.y);var columnId=this.getHeader(config.x);config.row=row;config.columnId=columnId},cellFixedColumnPrePaintNotification:function(config){var row=this.getRow(config.y);var columnId=this.getHeader(config.x);config.row=row;config.columnId=columnId},enhanceDoubleClickEvent:function(event){event.row=this.getRow(event.gridCell.y)},fixedRowClicked:function(grid,mouse){if(mouse.gridCell.y>0){return}this.toggleSort(mouse.gridCell.x)}})})();</script></polymer-element><polymer-element name="fin-hypergrid-behavior-q" extends="fin-hypergrid-behavior-base" attributes="url" assetpath="/dev/fin-hypergrid/polymer/html/behaviors/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){var typeAlignmentMap={j:"right",s:"left",t:"center",f:"right",d:"center"};Polymer("fin-hypergrid-behavior-q",{ready:function(){this.block={data:[],headers:[],rows:0};this.readyInit();this.sorted={};this.sortStates=[""," ^"," v"," |^|"," |v|"];this.ws=null;this.reconnect()},attributeChanged:function(attrName,oldVal,newVal){console.log(attrName,"old: "+oldVal,"new:",newVal);if(attrName==="url"){this.reconnect()}if(attrName==="table"){this.setScrollPositionY(0)}},connectTo:function(newUrl){this.setAttribute("url",newUrl);this.reconnect()},reconnect:function(){this.url=this.getAttribute("url");if(!this.url){return}this.connect();this.setScrollPositionY(0);this.scrolled=false},getValue:function(x,y){var override=this.dataUpdates["p_"+x+"_"+y];if(override){return override}var normalized=Math.floor(y-this.getScrollPositionY());if(this.block&&normalized<this.block.data.length){return this.block.data[normalized][x+1]}else{return""}},clearData:function(){this.block.rows=[];this.changed()},getRowCount:function(){return this.block.rows},getColumnCount:function(){return Math.max(0,this.block.headers.length-1)},getFixedColumnCount:function(){return 1},setScrollPositionY:function(y){if(this.scrollPositionY===y){return}this.scrollPositionY=y;if(!this.isConnected()){return}var tableName=this.getAttribute("table");if(!tableName){console.log("you must provide a table attribute for the q behavior");return}this.ws.send(JSON.stringify({cmd:"fetchTableData",data:{table:tableName,start:this.getScrollPositionY(),num:60}}))},isConnected:function(){if(!this.ws){return false}return this.ws.readyState===this.ws.OPEN},getFixedRowValue:function(x){if(!this.sorted[x+1]){this.sorted[x+1]=0}var sortIndicator=this.sortStates[this.sorted[x+1]];return this.block.headers[x+1][0]+sortIndicator},getHeader:function(x){return this.block.headers[x+1][0]},getFixedColumnValue:function(x,y){return y},getCanSort:function(){var canSort=this.block.features.sorting===true;return canSort},toggleSort:function(columnIndex){if(!this.getCanSort()){return}columnIndex++;var current=this.sorted[columnIndex];var stateCount=this.sortStates.length;this.sorted={};this.sorted[columnIndex]=(current+1)%stateCount;var state=this.sortStates[this.sorted[columnIndex]];var message={cmd:"sortTable",data:{table:this.getAttribute("table")||"trade",sort:current===stateCount-1?"":this.block.headers[columnIndex][0],asc:state.indexOf("^")>0,abs:state.indexOf("|")>0,start:this.getScrollPositionY(),num:60}};this.ws.send(JSON.stringify(message))},getColumnAlignment:function(x){var alignment=typeAlignmentMap[this.block.headers[x+1][1]];return alignment},connect:function(){var d;var oldSize;var self=this;var tableName=this.getAttribute("table");if(!tableName){console.log("you must provide a table attribute for the q behavior");return}if("WebSocket"in window){try{this.ws=new WebSocket(this.url)}catch(e){console.log("could not connect to "+this.url+", trying to reconnect in a moment...");return}console.log("connecting...");this.ws.onopen=function(){console.log("connected");self.ws.send(JSON.stringify({cmd:"fetchTableData",data:{table:tableName,start:self.getScrollPositionY()||0,num:60}}))};this.ws.onclose=function(){self.clearData();console.log("disconnected from "+this.url+", trying to reconnect in a moment...");setTimeout(function(){},2e3)};this.ws.onmessage=function(e){d=JSON.parse(e.data);oldSize=self.block.rows;self.block=d;if(d.rows!==oldSize){if(self.changed){self.changed()}}self.changed()};this.ws.onerror=function(e){self.clearData();console.error("problem with connection to q at "+this.url+", trying again in a moment...",e.data);setTimeout(function(){},2e3)}}else{console.error("WebSockets not supported on your browser.")}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-behavior-qtree" extends="fin-hypergrid-behavior-base" attributes="url" assetpath="/dev/fin-hypergrid/polymer/html/behaviors/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){var noop=function(){};var logMessages=false;var hierarchyColumn="g_";var typeAlignmentMap={j:"right",s:"left",t:"center",f:"right",i:"right",e:"right",d:"center"};var iCache=new SimpleLRU(1e4);iCache.set(0,"0");var fCache=new SimpleLRU(1e4);fCache.set(0,"0.00");var icommify=function(v){var result;if(v){result=iCache.get(v);if(result){return result}else{result=numeral(v).format("0,0");iCache.set(v,result);return result}}else{return""}};var fcommify=function(v){var result;if(v){result=iCache.get(v);if(result){return result}else{result=numeral(v).format("0,0.00");iCache.set(v,result);return result}}else{return""}};var typeFormatMap={J:function(v){return v},j:icommify,s:function(v){return v},t:function(v){return v},e:fcommify,i:icommify,f:fcommify,d:function(v){return v}};var propertiesMap={columns:{TEST:{formatter:fcommify,alignment:"right",modifyConfig:function(cell){noop(cell)}},USD:{formatter:fcommify,alignment:"right",modifyConfig:function(cell){cell.config.fgColor="green";if(cell.config.value<0){cell.config.fgColor="red"}}},QTY:{formatter:icommify,alignment:"right",modifyConfig:function(cell){cell.config.fgColor="green";if(cell.config.value<0){cell.config.fgColor="red"}}}}};var sortMap={a:"-up",d:"-down",A:"-abs-up",D:"-abs-down"};var imageMap={u:"up-rectangle",d:"down-rectangle","":"rectangle-spacer"};Polymer("fin-hypergrid-behavior-qtree",{ready:function(){this.block={properties:{columns:{}},count:0,visible:[],groups:[],sorts:{cols:[],rows:[]},hypertree:[{g_:[""]}]};this.readyInit();this.sorted={};this.ws=null;this.reconnect();this.msgCounter=Date.now();this.msgResponsesActions={};var cursorChanger=function(grid,event){if(this.isTopLeft(grid,event)){this.cursor="pointer"}else{this.cursor=null}if(this.next){this.next.handleMouseMove(grid,event)}};var self=this;setTimeout(function(){self.featureChain.handleMouseMove=cursorChanger;cursorChanger.bind(self.featureChain)},500)},getFixedRowCount:function(){return 2},createCellProvider:function(){var self=this;var provider=document.createElement("fin-hypergrid-cell-provider");var columns=propertiesMap.columns;provider.getCell=function(config){var cell=provider.cellCache.simpleCellRenderer;cell.config=config;var colId=self.block.visible[config.x];var type=self.block.qtypes[colId];var colProps;var colPropertyAlias=self.block.properties.columns[colId];if(colPropertyAlias){colProps=columns[colPropertyAlias];colProps.modifyConfig(cell)}var formatter=colProps?colProps.formatter:typeFormatMap[type]||function(v){return v};config.value=formatter(config.value);return cell};provider.getFixedColumnCell=function(config){var cell=provider.cellCache.treeCellRenderer;cell.config=config;return cell};provider.getFixedRowCell=function(config){var label=provider.cellCache.simpleCellRenderer;label.config=config;if(config.y===1){config.value=config.value[0];return provider.getCell(config)}config.value=config.value||"";return label};provider.getTopLeftCell=function(config){var label=provider.cellCache.simpleCellRenderer;label.config=config;if(config.y===0){return label}else{return label}};return provider},connectTo:function(newUrl){noop(newUrl)},reconnect:function(){this.url=this.getAttribute("url");if(!this.url){return}this.connect();this.setScrollPositionY(0);this.scrolled=false},getTopLeftValue:function(x,y){if(y===0){var image=this.getClickIndicator(hierarchyColumn);var clone=[image,"Hierarchy",this.getSortIndicator(hierarchyColumn)];return clone}else{return""}},getValue:function(x,y){var col=this.getColumnId(x);var normalized=Math.floor(y-this.getScrollPositionY());if(this.block&&typeof col==="string"){var val=this.block.hypertree[1][col][normalized];if(val||val===0){return val}}return""},clearData:function(){this.block.rows=[];this.changed()},getRowCount:function(){return Math.max(0,this.block.count-1)},getColumnCount:function(){return this.block.visible.length},setScrollPositionY:function(y){if(this.getScrollPositionY()===y){return}this.getDataModel().setScrollPositionY(y);if(!this.isConnected()){return}var startY=this.getScrollPositionY()||0;var stopY=startY+60;this.sendMessage({id:this.getNextMessageId(),fn:"get",start:startY,end:stopY})},isConnected:function(){if(!this.ws){return false}return this.ws.readyState===this.ws.OPEN},getFixedRowValue:function(x,y){var colId=this.getColumnId(x);if(y<1){var sortIndicator=this.getSortIndicator(colId);var clickIndicator=this.getClickIndicator(colId);return[clickIndicator,colId,sortIndicator]}var total=this.block.hypertree[0][colId];return total},getClickIndicator:function(colId){if(!this.block.icons){return this.getImage("rectangle-spacer")}var direction=this.block.icons[colId];var image=this.getImage(imageMap[direction]);return image},getSortIndicator:function(colId){var sortIndex=this.block.sorts.cols.indexOf(colId);if(sortIndex<0){return this.getImage("sortable")}var sortState=this.block.sorts.sorts[sortIndex];var symbol=sortIndex+1+sortMap[sortState];var state=this.getImage(symbol);return state},getFixedColumnValue:function(x,y){var indentPixels=10;var blob=this.block.hypertree[1];var transY=Math.max(0,y-this.getScrollPositionY());var data=blob.g_[transY];var level=blob.l_[transY];var indent=5+indentPixels+(level-1)*indentPixels;var icon="";if(!blob.e_[transY]){icon=blob.o_[transY]?"▾ ":"▸ "}return{data:data,indent:indent,icon:icon}},getCanSort:function(){return true},toggleSort:function(columnIndex){var colId=this.getColumnId(columnIndex);this._toggleSort(colId)},_toggleSort:function(colId){if(!this.getCanSort()){return}var msg={id:this.getNextMessageId(),fn:"sorts",col:colId};this.sendMessage(msg)},getFixedRowAlignment:function(x,y){if(y>0){return this.getColumnAlignment(x)}return this.resolveProperty("fixedRowAlign")},getColumnAlignment:function(x){var colId=this.getColumnId(x);var type=this.block.qtypes[colId];var colProps;var colPropertyAlias=this.block.properties.columns[colId];if(colPropertyAlias){colProps=propertiesMap.columns[colPropertyAlias]}var alignment=colProps?colProps.alignment:typeAlignmentMap[type];return alignment},getColumnId:function(x){var headers=this.block.visible;var col=headers[x];return col},getFixedColumnAlignment:function(){return"left"},topLeftClicked:function(grid,mouse){var gridY=mouse.gridCell.y;if(gridY<1){this.hierarchyCellClicked(grid,mouse)}else{this.controlCellClick(grid,mouse)}},hierarchyCellClicked:function(grid,mouse){var colId=hierarchyColumn;var colWidth=this.getFixedColumnWidth(0);var mouseX=mouse.mousePoint.x;var direction=this.block.icons[hierarchyColumn];if(mouseX<colWidth/2){if(direction){var colClick={id:this.getNextMessageId(),fn:"col",col:colId};this.sendMessage(colClick)}else{return}}else{this._toggleSort(colId)}},controlCellClick:function(grid,mouse){var colWidth=this.getFixedColumnWidth(0);var mouseX=mouse.mousePoint.x;var fn="expand";if(mouseX<colWidth/3){fn="collapse"}else if(mouseX<2*colWidth/3){fn="reset"}if(!this.isColumnReorderable()){fn="reset"}var msg={id:this.getNextMessageId(),fn:fn};this.sendMessage(msg)},fixedColumnClicked:function(grid,mouse){var rowNum=mouse.gridCell.y-this.getScrollPositionY();var rows=this.block.hypertree[1].n_[rowNum];if(rows.length===this.block.groups.length+1){return}var rowClick={id:this.getNextMessageId(),fn:"row",row:rows};this.sendMessage(rowClick)},fixedRowClicked:function(grid,mouse){var x=mouse.gridCell.x;var y=mouse.gridCell.y;if(y>0){return}var colId=this.getColumnId(x);var direction=this.block.icons[colId];var colWidth=this.getColumnWidth(x);var mousePoint=mouse.mousePoint.x;if(mousePoint<colWidth/2){if(direction){var colClick={id:this.getNextMessageId(),fn:"col",col:colId};this.sendMessage(colClick)}}else{this.toggleSort(x)}},cellDoubleClicked:function(cell){if(!this.isCellClickEnabled()){return}if(cell.x<this.getFixedColumnCount()||cell.y<this.getFixedRowCount()){return}var rowNum=cell.y-this.getScrollPositionY();var rows=this.block.hypertree[1].n_[rowNum];var colId=this.getColumnId(cell.x);var colClick={id:this.getNextMessageId(),fn:"cell",col:colId,row:rows};this.sendMessage(colClick)},sendMessage:function(message){if(logMessages){console.log("out-"+Date.now(),message)}this.ws.send(JSON.stringify(message))},isCellClickEnabled:function(){return this.block.cell},isColumnReorderable:function(){return this.block.reorderable},openEditor:function(div){if(!this.isColumnReorderable()){return false}var self=this;var container=document.createElement("div");var group=document.createElement("fin-hypergrid-dnd-list");var hidden=document.createElement("fin-hypergrid-dnd-list");var visible=document.createElement("fin-hypergrid-dnd-list");container.appendChild(group);container.appendChild(hidden);container.appendChild(visible);this.beColumnStyle(group.style);group.style.left="0%";group.title="groups";group.list=this.block.groups.slice(0);group.canDragItem=function(list,item,index,e){noop(item,index,e);if(self.block.ungrouped){return true}else{return list.length>1}};group.canDropItem=function(sourceList,myList,sourceIndex,item,e){noop(sourceList,myList,sourceIndex,e);return self.block.groupable.indexOf(item)>-1};this.beColumnStyle(hidden.style);hidden.style.left="33.3333%";hidden.title="hidden columns";hidden.list=this.block.invisible.slice(0);this.beColumnStyle(visible.style);visible.style.left="66.6666%";visible.title="visible columns";visible.list=this.block.visible.slice(0);visible.canDragItem=function(list,item,index,e){noop(item,index,e);return list.length>1};div.lists={group:group.list,hidden:hidden.list,visible:visible.list};div.appendChild(container);return true},closeEditor:function(div){var lists=div.lists;var changeCols={id:this.getNextMessageId(),fn:"groups",groups:lists.group,visible:lists.visible};this.sendMessage(changeCols);return true},getNextMessageId:function(onResponseDo){var id="js_"+this.msgCounter++;if(onResponseDo){this.msgResponsesActions[id]=onResponseDo}return id},endDragColumnNotification:function(){var self=this;var visible=this.block.visible.slice(0);for(var i=0;i<visible.length;i++){var transX=this.translateColumnIndex(i);visible[i]=this.getColumnId(transX)}var msgId=this.getNextMessageId(function(message){var colCount=self.getColumnCount();var widths=[];for(var i=0;i<colCount;i++){widths[i]=self._getColumnWidth(i)}self.initColumnIndexes(self.getState());for(i=0;i<colCount;i++){widths[i]=self._setColumnWidth(i,widths[i])}self.handleMessage(message)});var changeCols={id:msgId,fn:"groups",groups:this.block.groups,visible:visible};this.sendMessage(changeCols);return true},handleMessage:function(d){var tableState=this.getState();if(d.properties&&!d.properties.columns){d.properties.columns={}}this.block=d;if(!tableState.columnIndexes||tableState.columnIndexes.length===0||d.visible.length!==tableState.columnIndexes.length){this.initColumnIndexes(tableState)}this.changed()},connect:function(){var d={};var self=this;if("WebSocket"in window){try{this.ws=new WebSocket(this.url)}catch(e){console.log("could not connect to "+this.url+", trying to reconnect in a moment...");return}console.log("connecting...");this.ws.onopen=function(){self.setFixedColumnWidth(0,160);var startY=self.getScrollPositionY()||0;var stopY=startY+60;self.sendMessage({id:self.getNextMessageId(),fn:"get",start:startY,end:stopY})};this.ws.onclose=function(){console.log("disconnected from "+this.url+", trying to reconnect in a moment...")};this.ws.onmessage=function(e){d=JSON.parse(e.data);if(logMessages){console.log("in-"+Date.now(),d)}var msgId=d.id;var action=self.msgResponsesActions[msgId];if(action){action(d);self.msgResponsesActions[msgId]=undefined}else{self.handleMessage(d)}self.initButtonBar();self.autosizeColumns()};this.ws.onerror=function(e){self.clearData();console.error("problem with connection to q at "+this.url+", trying again in a moment...",e.data);setTimeout(function(){},2e3)}}else{console.error("WebSockets not supported on your browser.")}},beColumnStyle:function(style){style.top="5%";style.position="absolute";style.width="33.3333%";style.height="99%";style.whiteSpace="nowrap"},highlightCellOnHover:function(isColumnHovered,isRowHovered){return isRowHovered},getCellEditorAt:function(x,y){noop(x,y);return null},getFixedColumnCount:function(){return 1},getTreeStateDescription:function(){var object=this.block.message;var result='<table class="qtreedescription">\n';var data="<tr>";for(var property in object){if(object.hasOwnProperty(property)){result=result+"<col><col>";data=data+"<td>"+property+":</td><td>"+object[property]+"</td>\n"}}result=result+"\n"+data+"</tr></table>";return result},setButtonBarHolder:function(buttonBarHolder){this.buttonBarHolder=buttonBarHolder;this.initButtonBar()},initButtonBar:function(){var self=this;var image;var bbh=this.buttonBarHolder;if(!bbh){return}bbh.innerHTML="";var action=function(name){return function(){self.buttonBarIconClick(name)}};var imageNames=[];if(this.block.buttons){imageNames=Object.keys(this.block.buttons)}for(var i=0;i<imageNames.length;i++){var name=imageNames[i];image=this.getImage(name.toLowerCase()).cloneNode();bbh.appendChild(image);if(!this.block.buttons[name]){image.style.opacity=.4;image.style.cursor="default"}else{image.onclick=action(name)}image.setAttribute("title",name)}image=this.getImage("add-column").cloneNode();bbh.appendChild(image);image.setAttribute("title","open/close column editor");if(this.isColumnReorderable()){image.onclick=function(){self.toggleColumnPicker()}}else{image.style.opacity=.4;image.style.cursor="default"}},buttonBarIconClick:function(buttonLabel){var bbClick={id:this.getNextMessageId(),fn:buttonLabel};this.sendMessage(bbClick)}})})();</script></polymer-element><polymer-element name="fin-hypergrid-behavior-web-worker" extends="fin-hypergrid-behavior-base" assetpath="/dev/fin-hypergrid/polymer/html/behaviors/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){Polymer("fin-hypergrid-behavior-web-worker",{ready:function(){this.readyInit();var self=this;this.block={data:[],headers:[],rows:0};this.sortStates=[" "," ↑"," ↓"];this.worker=new Worker("js/json-web-worker.js");this.worker.onmessage=function(e){self.block=e.data;self.changed()}},getDefaultState:function(){return{columnIndexes:[],fixedColumnIndexes:[],hiddenColumns:[],columnWidths:[],fixedColumnWidths:[],fixedColumnAutosized:[],rowHeights:{},fixedRowHeights:{},columnProperties:[],columnAutosized:[],sorted:[],fixedColumnCount:1,fixedRowCount:1}},postMessage:function(message){this.worker.postMessage(message)},setData:function(jsonData){this.postMessage({cmd:"setData",data:jsonData});this.initialize()},initialize:function(){this.changed();this.postMessage({cmd:"fetchTableData",data:{start:this.getScrollPositionY()||0,num:60}})},getValue:function(x,y){var override=this.dataUpdates["p_"+x+"_"+y];if(override){return override}var fields=this.getFields();return this.block.data[y-this.getScrollPositionY()][fields[x]]},clearData:function(){this.block.rows=[];this.changed()},getRowCount:function(){return this.block.rows},getColumnCount:function(){return this.block.headers.length},setScrollPositionY:function(y){if(this.scrollPositionY===y){return}this.scrollPositionY=y;this.postMessage({cmd:"fetchTableData",data:{start:this.getScrollPositionY(),num:60}})},getFixedRowValue:function(x){if(!this.tableState.sorted[x]){this.tableState.sorted[x]=0}var sortIndicator=this.sortStates[this.tableState.sorted[x]];return this.block.headers[x]+sortIndicator},getFields:function(){return this.block.fields},getHeader:function(x){return this.block.headers[x]},getFixedColumnValue:function(x,y){return y},getCanSort:function(){var canSort=this.block.features.sorting===true;return canSort},toggleSort:function(columnIndex){if(!this.getCanSort()){return}this.grid.clearSelections();var current=this.tableState.sorted[columnIndex];var stateCount=this.sortStates.length;this.tableState.sorted={};this.tableState.sorted[columnIndex]=(current+1)%stateCount;var state=this.tableState.sorted[columnIndex];var message={cmd:"sortTable",data:{table:"trade",sortIndex:current===stateCount-1?-1:columnIndex,state:state,start:this.getScrollPositionY(),num:60}};this.postMessage(message)},getColumnAlignment:function(){return"center"},getFixedColumnCount:function(){return 1}})})();</script></polymer-element><polymer-element name="fin-hypergrid-cell-editor-base" assetpath="/dev/fin-hypergrid/polymer/html/cell-editors/"><template><style type="text/css">:host{display:block;position:relative}</style></template><script>"use strict";(function(){var noop=function(){};Polymer("fin-hypergrid-cell-editor-base",{isEditing:false,editorPoint:null,checkEditorPositionFlag:false,input:null,alias:"base",grid:null,initialValue:null,ready:function(){this.readyInit()},readyInit:function(){},getBehavior:function(){return this.grid.getBehavior()},gridRenderedNotification:function(){this.checkEditor()},scrollValueChangedNotification:function(){this.setCheckEditorPositionFlag()},setCheckEditorPositionFlag:function(){this.checkEditorPositionFlag=true},beginEditAt:function(point){this.setEditorPoint(point);var model=this.getBehavior();var value=model._getValue(point.x,point.y);var proceed=this.grid.fireBeforeCellEdit(point,value);if(!proceed){return}this.initialValue=value;this.setEditorValue(value);this.isEditing=true;this.setCheckEditorPositionFlag();this.checkEditor()},setEditorValue:function(value){noop(value)},getEditorPoint:function(){return this.editorPoint},setEditorPoint:function(point){this.editorPoint=point},showEditor:function(){},hideEditor:function(){},stopEditing:function(){if(!this.isEditing){return}this.saveEditorValue();this.isEditing=false;this.hideEditor()},saveEditorValue:function(){var point=this.getEditorPoint();var value=this.getEditorValue();if(value===this.initialValue){return}this.getBehavior()._setValue(point.x,point.y,value);this.grid.fireAfterCellEdit(point,this.initialValue,value)},getEditorValue:function(){},takeFocus:function(){},moveEditor:function(){var model=this.getBehavior();var numFixedColumns=model.getFixedColumnCount();var numFixedRows=model.getFixedRowCount();var vScroll=this.grid.getVScrollValue();var hScroll=this.grid.getHScrollValue();var editorPoint=this.getEditorPoint();var x=editorPoint.x+numFixedColumns-hScroll;var y=editorPoint.y+numFixedRows-vScroll;var eb=this.grid.getBoundsOfCell(this.rectangles.point.create(x,y));var db=this.grid.getDataBounds();var cellBounds=eb.intersect(db);this.setBounds(cellBounds);this.takeFocus()},setBounds:function(rectangle){noop(rectangle)},checkEditor:function(){if(!this.checkEditorPositionFlag){return}else{this.checkEditorPositionFlag=false}if(!this.isEditing){return}var editorPoint=this.getEditorPoint();if(this.grid.isDataVisible(editorPoint.x,editorPoint.y)){this.moveEditor();this.showEditor()}else{this.hideEditor()}}})})();</script></polymer-element><polymer-element name="fin-hypergrid-cell-editor-simple" extends="fin-hypergrid-cell-editor-base" assetpath="/dev/fin-hypergrid/polymer/html/cell-editors/"><template><style type="text/css">:host{display:block;position:relative}</style><div id="editor"></div></template><script>"use strict";(function(){Polymer("fin-hypergrid-cell-editor-simple",{alias:"simple",readyInit:function(){var self=this;this.rectangles=document.createElement("fin-rectangle");this.editorPoint=this.rectangles.point.create(0,0);this.input=this.shadowRoot.querySelector("#editor");this.input.addEventListener("keypress",function(e){if(e&&e.keyCode===13){e.preventDefault();self.stopEditing();self.grid.repaint();self.grid.takeFocus()}});this.input.style.position="absolute";this.input.style.display="none";this.input.style.border="solid 2px black";this.input.style.outline=0;this.input.style.padding=0;this.input.style.zIndex=1e3},getEditorValue:function(){var value=this.input.value;return value},setEditorValue:function(value){this.input.value=value+""},showEditor:function(){this.input.style.display="inline"},hideEditor:function(){this.input.style.display="none"},takeFocus:function(){var self=this;setTimeout(function(){self.input.focus();self.selectAll()},300)},selectAll:function(){},originOffset:function(){return[-2,-2]},setBounds:function(cellBounds){var originOffset=this.originOffset();var translation="translate("+(cellBounds.origin.x+originOffset[0])+"px,"+(cellBounds.origin.y+originOffset[1])+"px)";this.input.style.webkitTransform=translation;this.input.style.MozTransform=translation;this.input.style.msTransform=translation;this.input.style.OTransform=translation;this.input.style.width=cellBounds.extent.x+"px";this.input.style.height=cellBounds.extent.y+"px"}})})();</script></polymer-element><polymer-element name="fin-hypergrid-cell-editor-textfield" extends="fin-hypergrid-cell-editor-simple" assetpath="/dev/fin-hypergrid/polymer/html/cell-editors/"><template><style type="text/css">:host{display:block;position:relative}</style><input id="editor"></template><script>"use strict";(function(){Polymer("fin-hypergrid-cell-editor-textfield",{alias:"textfield",selectAll:function(){this.input.setSelectionRange(0,this.input.value.length)}})})();</script></polymer-element><polymer-element name="fin-hypergrid-cell-editor-choice" extends="fin-hypergrid-cell-editor-simple" assetpath="/dev/fin-hypergrid/polymer/html/cell-editors/"><template><style type="text/css">:host{display:block;position:relative}</style><select id="editor"><option template="" repeat="{{item in items}}" value="{{item}}">{{item}}</option></select></template><script>"use strict";(function(){Polymer("fin-hypergrid-cell-editor-choice",{alias:"choice",items:[],originOffset:function(){return[-1,-1]}})})();</script></polymer-element><polymer-element name="fin-hypergrid-cell-editor-color" extends="fin-hypergrid-cell-editor-simple" assetpath="/dev/fin-hypergrid/polymer/html/cell-editors/"><template><style type="text/css">:host{display:block;position:relative}</style><input id="editor" type="color"></template><script>"use strict";(function(){Polymer("fin-hypergrid-cell-editor-color",{alias:"color"})})();</script></polymer-element><polymer-element name="fin-hypergrid-cell-editor-date" extends="fin-hypergrid-cell-editor-simple" assetpath="/dev/fin-hypergrid/polymer/html/cell-editors/"><template><style type="text/css">:host{display:block;position:relative}</style><input id="editor" type="date"></template><script>"use strict";(function(){Polymer("fin-hypergrid-cell-editor-date",{alias:"date"})})();</script></polymer-element><polymer-element name="fin-hypergrid-cell-editor-slider" extends="fin-hypergrid-cell-editor-simple" assetpath="/dev/fin-hypergrid/polymer/html/cell-editors/"><template><style type="text/css">:host{display:block;position:relative}</style><input id="editor" type="range"></template><script>"use strict";(function(){Polymer("fin-hypergrid-cell-editor-slider",{alias:"slider"})})();</script></polymer-element><polymer-element name="fin-hypergrid-cell-editor-spinner" extends="fin-hypergrid-cell-editor-simple" assetpath="/dev/fin-hypergrid/polymer/html/cell-editors/"><template><style type="text/css">:host{display:block;position:relative}</style><input id="editor" type="number"></template><script>"use strict";(function(){Polymer("fin-hypergrid-cell-editor-spinner",{alias:"spinner"})})();</script></polymer-element></div>-->
<polymer-element name="fin-hypergrid" assetpath="polymer/html/"><template><style type="text/css">:host{position:relative;display:inline-block;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;overflow:hidden}fin-vampire-bar{opacity:0;-webkit-transition:opacity 500ms;-moz-transition:opacity 500ms;-ms-transition:opacity 500ms;-o-transition:opacity 500ms;transition:opacity 500ms}.visible{opacity:.75}.hidden{opacity:0}.verticalScroller{position:absolute;top:0;right:0;bottom:0;left:100%;margin:0 15px 15px -15px}.horizontalScroller{position:absolute;top:100%;right:0;bottom:0;left:0;margin:-15px 15px 15px 0}.editor{position:absolute;display:none;border:solid 2px #000;outline:0;padding:0;z-index:1000}fin-vampire-bar{z-index:10}</style><fin-plugins></fin-plugins><fin-vampire-bar class="horizontalScroller" horizontal=""></fin-vampire-bar><fin-vampire-bar class="verticalScroller"></fin-vampire-bar><fin-canvas><fin-hypergrid-renderer></fin-hypergrid-renderer></fin-canvas><input class="editor"><content></content></template><script>"use strict";(function(){var rectangles;var globalCellEditors={};var propertiesInitialized=false;var noop=function(){};var initializeBasicCellEditors=function(){initializeCellEditor("fin-hypergrid-cell-editor-textfield");initializeCellEditor("fin-hypergrid-cell-editor-choice");initializeCellEditor("fin-hypergrid-cell-editor-color");initializeCellEditor("fin-hypergrid-cell-editor-date");initializeCellEditor("fin-hypergrid-cell-editor-slider");initializeCellEditor("fin-hypergrid-cell-editor-spinner")};var initializeCellEditor=function(name){var cellEditor=document.createElement(name);globalCellEditors[cellEditor.alias]=cellEditor};var defaultProperties=function(){var properties={font:"13px Tahoma, Geneva, sans-serif",color:"rgb(25, 25, 25)",backgroundColor:"rgb(241, 241, 241)",foregroundSelColor:"rgb(25, 25, 25)",backgroundSelColor:"rgb(183, 219, 255)",topLeftFont:"12px Tahoma, Geneva, sans-serif",topLeftColor:"rgb(25, 25, 25)",topLeftBackgroundColor:"rgb(223, 227, 232)",topLeftFGSelColor:"rgb(25, 25, 25)",topLeftBGSelColor:"rgb(255, 220, 97)",fixedColumnFont:"12px Tahoma, Geneva, sans-serif",fixedColumnColor:"rgb(25, 25, 25)",fixedColumnBackgroundColor:"rgb(223, 227, 232)",fixedColumnFGSelColor:"rgb(25, 25, 25)",fixedColumnBGSelColor:"rgb(255, 220, 97)",fixedRowFont:"12px Tahoma, Geneva, sans-serif",fixedRowColor:"rgb(25, 25, 25)",fixedRowBackgroundColor:"rgb(223, 227, 232)",fixedRowFGSelColor:"rgb(25, 25, 25)",fixedRowBGSelColor:"rgb(255, 220, 97)",backgroundColor2:"rgb(201, 201, 201)",lineColor:"rgb(199, 199, 199)",voffset:0,scrollbarHoverOver:"visible",scrollbarHoverOff:"hidden",scrollingEnabled:true,fixedRowAlign:"center",fixedColAlign:"center",cellPadding:5,gridLinesH:true,gridLinesV:true,defaultRowHeight:20,defaultFixedRowHeight:20,defaultColumnWidth:100,defaultFixedColumnWidth:100,repaintIntervalRate:4,repaintImmediately:false,useBitBlit:false,useHiDPI:true,editorActivationKeys:["alt","esc"],columnAutosizing:true,readOnly:false};return properties};var buildPolymerTheme=function(){clearObjectProperties(polymerTheme);var pb=document.createElement("paper-button");pb.style.display="none";pb.setAttribute("disabled",true);document.body.appendChild(pb);var p=window.getComputedStyle(pb);var section=document.createElement("section");section.style.display="none";section.setAttribute("hero",true);document.body.appendChild(section);var h=window.getComputedStyle(document.querySelector("html"));var hb=window.getComputedStyle(document.querySelector("html, body"));var s=window.getComputedStyle(section);polymerTheme.fixedRowBackgroundColor=p.color;polymerTheme.fixedColumnBackgroundColor=p.color;polymerTheme.topLeftBackgroundColor=p.color;polymerTheme.lineColor=p.backgroundColor;polymerTheme.backgroundColor2=hb.backgroundColor;polymerTheme.color=h.color;polymerTheme.fontFamily=h.fontFamily;polymerTheme.backgroundColor=s.backgroundColor;pb.setAttribute("disabled",false);pb.setAttribute("secondary",true);pb.setAttribute("raised",true);p=window.getComputedStyle(pb);polymerTheme.fixedRowColor=p.color;polymerTheme.fixedColumnColor=p.color;polymerTheme.topLeftColor=p.color;polymerTheme.backgroundSelColor=p.backgroundColor;polymerTheme.foregroundSelColor=p.color;pb.setAttribute("secondary",false);pb.setAttribute("warning",true);polymerTheme.fixedRowFGSelColor=p.color;polymerTheme.fixedRowBGSelColor=p.backgroundColor;polymerTheme.fixedColumnFGSelColor=p.color;polymerTheme.fixedColumnBGSelColor=p.backgroundColor;if(polymerTheme.fixedRowBGSelColor==="rgba(0, 0, 0, 0)"||polymerTheme.lineColor==="transparent"){clearObjectProperties(polymerTheme)}document.body.removeChild(pb);document.body.removeChild(section)};var clearObjectProperties=function(obj){for(var prop in obj){if(obj.hasOwnProperty(prop)){delete obj[prop]}}};var defaults,polymerTheme,globalProperties;(function(){defaults=defaultProperties();polymerTheme=Object.create(defaults);globalProperties=Object.create(polymerTheme)})();Polymer("fin-hypergrid",{behavior:{setScrollPositionY:noop,setScrollPositionX:noop,getColumnCount:function(){return 0},getFixedColumnCount:function(){return 0},getFixedColumnsWidth:function(){return 0},getFixedColumnsMaxWidth:function(){return 0},setRenderedWidth:function(){return 0},getRowCount:function(){return 0},getFixedRowCount:function(){return 0},getFixedRowsHeight:function(){return 0},getFixedRowsMaxHeight:function(){return 0},setRenderedHeight:function(){return 0},getCellProvider:noop,click:noop,doubleClick:noop},isWebkit:true,mouseDown:[],dragExtent:null,vScrollValue:0,hScrollValue:0,rectangles:null,selectionModel:null,cellEditor:null,sbMouseIsDown:false,sbHScroller:null,sbVScroller:null,sbHScrollConfig:{},sbVScrollConfig:{},sbPrevVScrollValue:null,sbPrevHScrollValue:null,sbHValueHolder:{},sbVValueHolder:{},cellEditors:null,renderOverridesCache:{},hoverCell:null,isScrollButtonClick:false,domReady:function(){if(!propertiesInitialized){propertiesInitialized=true;buildPolymerTheme();initializeBasicCellEditors()}var self=this;rectangles=rectangles||document.createElement("fin-rectangle");this.rectangles=rectangles;this.lnfProperties=Object.create(globalProperties);this.isWebkit=navigator.userAgent.toLowerCase().indexOf("webkit")>-1;this.selectionModel=document.createElement("fin-hypergrid-selection-model");this.selectionModel.getGrid=function(){return self};this.cellEditors=Object.create(globalCellEditors);this.renderOverridesCache={};this.oncontextmenu=function(event){event.preventDefault();return false};this.clearMouseDown();this.dragExtent=rectangles.point.create(0,0);this.pluginsDo(function(each){if(each.installOn){each.installOn(self)}});this.numRows=0;this.numColumns=0;this.initCanvas();this.initRenderer();this.initScrollbars();document.body.addEventListener("copy",function(evt){self.checkClipboardCopy(evt)});this.resized();this.fire("load");this.isScrollButtonClick=false;setInterval(function(){self.checkRepaint()},16)},initializeCellEditor:function(cellEditorName){initializeCellEditor(cellEditorName)},isHovered:function(x,y){var p=this.getHoverCell();if(!p){return false}return p.x===x&&p.y===y},isColumnHovered:function(x){var p=this.getHoverCell();if(!p){return false}return p.x===x},isRowHovered:function(y){var p=this.getHoverCell();if(!p){return false}return p.y===y},getHoverCell:function(){return this.hoverCell},setHoverCell:function(point){var me=this.hoverCell;var fixedX=this.getFixedColumnCount();var fixedY=this.getFixedRowCount();var newPoint=rectangles.point.create(point.x-fixedX,point.y-fixedY);if(me&&me.equals(newPoint)){return}this.hoverCell=newPoint;this.fireSyntheticOnCellEnterEvent(newPoint);this.repaint()},addGlobalProperties:function(properties){if(!globalProperties){var self=this;setTimeout(function(){self.addGlobalProperties(properties)},10)}else{this._addGlobalProperties(properties)}},_addGlobalProperties:function(properties){for(var key in properties){if(properties.hasOwnProperty(key)){globalProperties[key]=properties[key]}}},addProperties:function(properties){for(var key in properties){if(properties.hasOwnProperty(key)){this.lnfProperties[key]=properties[key]}}this.refreshProperties()},refreshProperties:function(){var interval=this.resolveProperty("repaintIntervalRate");var useBitBlit=this.resolveProperty("useBitBlit");this.canvas=this.shadowRoot.querySelector("fin-canvas");interval=interval===undefined?15:interval;console.log("refresh rate = "+interval);this.canvas.setAttribute("fps",interval);this.canvas.setAttribute("bitblit",useBitBlit===true)},getState:function(){var state=this.getBehavior().getState();return state},setState:function(state){this.getBehavior().setState(state)},getMouseDown:function(){var last=this.mouseDown.length-1;if(last<0){return null}return this.mouseDown[last]},popMouseDown:function(){if(this.mouseDown.length===0){return}this.mouseDown.length=this.mouseDown.length-1},clearMouseDown:function(){this.mouseDown=[rectangles.point.create(-1,-1)];this.dragExtent=null},setMouseDown:function(point){this.mouseDown.push(point)},getDragExtent:function(){return this.dragExtent},setDragExtent:function(point){this.dragExtent=point},pluginsDo:function(func){var userPlugins=this.children.array();var pluginsTag=this.shadowRoot.querySelector("fin-plugins");var plugins=userPlugins;if(pluginsTag){var systemPlugins=pluginsTag.children.array();plugins=systemPlugins.concat(plugins)}for(var i=0;i<plugins.length;i++){var plugin=plugins[i];func(plugin)}},getCellProvider:function(){var provider=this.getBehavior().getCellProvider();return provider},gridRenderedNotification:function(){this.updateRenderedSizes();if(this.cellEditor){this.cellEditor.gridRenderedNotification()}this.checkColumnAutosizing();this.fireSyntheticGridRenderedEvent();this.repaintFlag=false},checkColumnAutosizing:function(){if(this.resolveProperty("columnAutosizing")===false){return}var renderer=this.getRenderer();var fixedColSizes=renderer.renderedFixedColumnMinWidths;var colSizes=renderer.renderedColumnMinWidths;this.getBehavior().checkColumnAutosizing(fixedColSizes,colSizes)},updateRenderedSizes:function(){var behavior=this.getBehavior();behavior.setRenderedColumnCount(this.getViewableColumns()+1);behavior.setRenderedRowCount(this.getViewableRows()+1)},resetTextWidthCache:function(){this.getRenderer().resetTextWidthCache()},checkClipboardCopy:function(event){if(!this.hasFocus()){return}event.preventDefault();var csvData=this.getSelectionAsTSV();event.clipboardData.setData("text/plain",csvData)},hasSelections:function(){if(!this.getSelectionModel){return}return this.getSelectionModel().hasSelections()},getSelectionAsTSV:function(){var selectionModel=this.getSelectionModel();var selections=selectionModel.getSelections();if(selections.length===0){return}var last=selections[selections.length-1];var area=last.area();if(area>1e4){alert("selection size is too big to copy to the paste buffer");return""}var behavior=this.getBehavior();var collector=[];var xstart=last.origin.x;var xstop=last.origin.x+last.extent.x+1;var ystart=last.origin.y;var ystop=last.origin.y+last.extent.y+1;for(var y=ystart;y<ystop;y++){for(var x=xstart;x<xstop;x++){var data=behavior._getValue(x,y);collector.push(data);if(x!==xstop-1){collector.push(" ")}}if(y!==ystop-1){collector.push("\n")}}var text=collector.join("");return text},hasFocus:function(){return this.getCanvas().hasFocus()},clearSelections:function(){this.getSelectionModel().clear();this.clearMouseDown()},clearMostRecentSelection:function(){this.getSelectionModel().clearMostRecentSelection()},select:function(ox,oy,ex,ey){if(ox<0||oy<0){return}this.getSelectionModel().select(ox,oy,ex,ey)},isSelected:function(x,y){return this.getSelectionModel().isSelected(x,y)},isFixedRowCellSelected:function(col){var selectionModel=this.getSelectionModel();var isSelected=selectionModel.isFixedRowCellSelected(col);return isSelected},isFixedColumnCellSelected:function(row){var selectionModel=this.getSelectionModel();var isSelected=selectionModel.isFixedColumnCellSelected(row);return isSelected},getSelectionModel:function(){return this.selectionModel},getBehavior:function(){return this.behavior},setBehavior:function(newBehavior){this.behavior=newBehavior;this.behavior.setGrid(this);this.behavior.changed=this.behaviorChanged.bind(this);this.behavior.shapeChanged=this.behaviorShapeChanged.bind(this)},behaviorChanged:function(){if(this.numColumns!==this.behavior._getColumnCount()||this.numRows!==this.behavior.getRowCount()){this.numColumns=this.behavior._getColumnCount();this.numRows=this.behavior.getRowCount();this.behaviorShapeChanged()}this.repaint()},getBounds:function(){var canvas=this.getCanvas();if(canvas){return canvas.getBounds()}else{return null}},resolveProperty:function(key){return this.lnfProperties[key]},behaviorShapeChanged:function(){this.synchronizeScrollingBoundries()},checkRepaint:function(){if(this.repaintFlag){var now=this.resolveProperty("repaintImmediately");var canvas=this.getCanvas();if(canvas){if(now===true){canvas.paintNow()}else{canvas.repaint()}}}},repaint:function(){this.repaintFlag=true},paintNow:function(){var canvas=this.getCanvas();canvas.paintNow()},isHiDPI:function(){return this.resolveProperty("useHiDPI")!==false},initCanvas:function(){var self=this;var interval=this.resolveProperty("repaintIntervalRate");var useBitBlit=this.resolveProperty("useBitBlit");this.canvas=this.shadowRoot.querySelector("fin-canvas");interval=interval===undefined?15:interval;this.canvas.setAttribute("fps",interval);this.canvas.setAttribute("bitblit",useBitBlit===true);this.canvas.isHiDPI=function(){return self.isHiDPI()};this.canvas.style.position="absolute";this.canvas.style.top=0;this.canvas.style.right="-200px";this.canvas.style.bottom=0;this.canvas.style.left=0;this.canvas.resizeNotification=function(){self.resized()};this.addFinEventListener("fin-canvas-mousemove",function(e){if(self.resolveProperty("readOnly")){return}var mouse=e.detail.mouse;var mouseEvent=self.getGridCellFromMousePoint(mouse);mouseEvent.primitiveEvent=e;self.delegateMouseMove(mouseEvent)});this.addFinEventListener("fin-canvas-mousedown",function(e){if(self.resolveProperty("readOnly")){return}self.stopEditing();var mouse=e.detail.mouse;var mouseEvent=self.getGridCellFromMousePoint(mouse);mouseEvent.primitiveEvent=e;self.delegateMouseDown(mouseEvent)});this.addFinEventListener("fin-canvas-mouseup",function(e){if(self.resolveProperty("readOnly")){return}self.dragging=false;if(self.isScrollingNow()){self.setScrollingNow(false)}if(self.columnDragAutoScrolling){self.columnDragAutoScrolling=false}var mouse=e.detail.mouse;var mouseEvent=self.getGridCellFromMousePoint(mouse);mouseEvent.primitiveEvent=e;self.delegateMouseUp(mouseEvent)});this.addFinEventListener("fin-canvas-tap",function(e){if(self.resolveProperty("readOnly")){return}self.stopEditing();var mouse=e.detail.mouse;var tapEvent=self.getGridCellFromMousePoint(mouse);tapEvent.primitiveEvent=e;self.fireSyntheticClickEvent(tapEvent);self.delegateTap(tapEvent)});this.addFinEventListener("fin-canvas-drag",function(e){if(self.resolveProperty("readOnly")){return}self.dragging=true;var mouse=e.detail.mouse;var mouseEvent=self.getGridCellFromMousePoint(mouse);mouseEvent.primitiveEvent=e;self.delegateMouseDrag(mouseEvent)});this.addFinEventListener("fin-canvas-keydown",function(e){if(self.resolveProperty("readOnly")){return}self.fireSyntheticKeydownEvent(e);self.delegateKeyDown(e)});this.addFinEventListener("fin-canvas-keyup",function(e){if(self.resolveProperty("readOnly")){return}self.fireSyntheticKeyupEvent(e);self.delegateKeyUp(e)});this.addFinEventListener("fin-canvas-track",function(e){if(self.resolveProperty("readOnly")){return}if(self.dragging){return}var primEvent=e.detail.primitiveEvent;if(Math.abs(primEvent.dy)>Math.abs(primEvent.dx)){if(primEvent.yDirection>0){self.scrollVBy(-2)}else if(primEvent.yDirection<-0){self.scrollVBy(2)}}else{if(primEvent.xDirection>0){self.scrollHBy(-1)}else if(primEvent.xDirection<-0){self.scrollHBy(1)}}});this.addFinEventListener("fin-canvas-holdpulse",function(e){if(self.resolveProperty("readOnly")){return}var mouse=e.detail.mouse;var mouseEvent=self.getGridCellFromMousePoint(mouse);mouseEvent.primitiveEvent=e;self.delegateHoldPulse(mouseEvent)});this.addFinEventListener("fin-canvas-dblclick",function(e){if(self.resolveProperty("readOnly")){return}var mouse=e.detail.mouse;var mouseEvent=self.getGridCellFromMousePoint(mouse);mouseEvent.primitiveEvent=e;self.fireSyntheticDoubleClickEvent(mouseEvent,e);self.delegateDoubleClick(mouseEvent)});this.addFinEventListener("fin-canvas-wheelmoved",function(e){var mouse=e.detail.mouse;var mouseEvent=self.getGridCellFromMousePoint(mouse);mouseEvent.primitiveEvent=e.detail.primitiveEvent;self.delegateWheelMoved(mouseEvent)});this.addFinEventListener("fin-canvas-mouseout",function(e){if(self.resolveProperty("readOnly")){return}var mouse=e.detail.mouse;var mouseEvent=self.getGridCellFromMousePoint(mouse);mouseEvent.primitiveEvent=e.detail.primitiveEvent;self.delegateMouseExit(mouseEvent)});this.canvas.removeAttribute("tabindex")},addFinEventListener:function(eventName,callback){this.canvas.addEventListener(eventName,callback)},setScrollingNow:function(isItNow){this.scrollingNow=isItNow},isScrollingNow:function(){return this.scrollingNow},overColumnDivider:function(mouseEvent){var x=mouseEvent.primitiveEvent.detail.mouse.x;var whichCol=this.getRenderer().overColumnDivider(x);return whichCol},overRowDivider:function(mouseEvent){var y=mouseEvent.primitiveEvent.detail.mouse.y;var which=this.getRenderer().overRowDivider(y);return which},beCursor:function(cursorName){this.style.cursor=cursorName},delegateWheelMoved:function(event){var behavior=this.getBehavior();behavior.onWheelMoved(this,event)},delegateMouseExit:function(event){var behavior=this.getBehavior();behavior.handleMouseExit(this,event)},delegateMouseMove:function(mouseDetails){var behavior=this.getBehavior();behavior.onMouseMove(this,mouseDetails)},delegateMouseDown:function(mouseDetails){var behavior=this.getBehavior();behavior.handleMouseDown(this,mouseDetails)},delegateMouseUp:function(mouseDetails){var behavior=this.getBehavior();behavior.onMouseUp(this,mouseDetails)},delegateTap:function(mouseDetails){var behavior=this.getBehavior();behavior.onTap(this,mouseDetails)},delegateMouseDrag:function(mouseDetails){var behavior=this.getBehavior();behavior.onMouseDrag(this,mouseDetails)},delegateDoubleClick:function(mouseDetails){var behavior=this.getBehavior();behavior.onDoubleClick(this,mouseDetails)},delegateHoldPulse:function(mouseDetails){var behavior=this.getBehavior();behavior.onHoldPulse(this,mouseDetails)},delegateKeyDown:function(event){var behavior=this.getBehavior();behavior.onKeyDown(this,event)},delegateKeyUp:function(event){var behavior=this.getBehavior();behavior.onKeyUp(this,event)},stopEditing:function(){if(this.cellEditor){if(this.cellEditor.stopEditing){this.cellEditor.stopEditing()}this.cellEditor=null}},registerCellEditor:function(alias,cellEditor){this.cellEditors[alias]=cellEditor},getDataBounds:function(){var colDNDHackWidth=200;var behavior=this.getBehavior();var b=this.canvas.bounds;var x=behavior.getFixedColumnsWidth()+2;var y=behavior.getFixedRowsHeight()+2;var result=rectangles.rectangle.create(x,y,b.origin.x+b.extent.x-x-colDNDHackWidth,b.origin.y+b.extent.y-y);return result},getCanvas:function(){return this.canvas},editAt:function(cellEditor,coordinates){this.cellEditor=cellEditor;var cell=coordinates.gridCell;var x=cell.x;var y=cell.y;if(x<0||y<0){return}var editPoint=rectangles.point.create(x,y);this.setMouseDown(editPoint);this.setDragExtent(rectangles.point.create(0,0));if(!cellEditor.isAdded){cellEditor.isAdded=true;this.shadowRoot.appendChild(cellEditor)}cellEditor.grid=this;cellEditor.beginEditAt(editPoint)},isColumnVisible:function(columnIndex){var isVisible=this.getRenderer().isColumnVisible(columnIndex);return isVisible},isDataRowVisible:function(rowIndex){var isVisible=this.getRenderer().isRowVisible(rowIndex);return isVisible},isDataVisible:function(columnIndex,rowIndex){var isVisible=this.isDataRowVisible(rowIndex)&&this.isColumnVisible(columnIndex);return isVisible},insureModelColIsViewable:function(colIndex,offsetX){var viewableColumns=this.getViewableColumns()-1;if(!this.isColumnVisible(colIndex)){var newSX=offsetX<0?colIndex:colIndex-viewableColumns;this.setHScrollValue(newSX);return true}return false},insureModelRowIsViewable:function(rowIndex,offsetY){var viewableRows=this.getViewableRows()-1;if(!this.isDataRowVisible(rowIndex)){var newSY=offsetY<0?rowIndex:rowIndex-viewableRows;this.setVScrollValue(newSY);return true}return false},scrollBy:function(offsetX,offsetY){this.scrollHBy(offsetX);this.scrollVBy(offsetY)},scrollVBy:function(offsetY){var max=this.sbVScrollConfig.rangeStop;var oldValue=this.getVScrollValue();var newValue=Math.min(max,Math.max(0,oldValue+offsetY));if(newValue===oldValue){return}this.setVScrollValue(newValue)},scrollHBy:function(offsetX){var max=this.sbHScrollConfig.rangeStop;var oldValue=this.getHScrollValue();var newValue=Math.min(max,Math.max(0,oldValue+offsetX));if(newValue===oldValue){return}this.setHScrollValue(newValue)},getGridCellFromMousePoint:function(mouse){var cell=this.getRenderer().getGridCellFromMousePoint(mouse);return cell},getBoundsOfCell:function(cell){var bounds=this.getRenderer().getBoundsOfCell(cell);return bounds},resized:function(){this.synchronizeScrollingBoundries()},cellClicked:function(event){var cell=event.gridCell;var colCount=this.getColumnCount();var rowCount=this.getRowCount();if(cell.x>colCount||cell.y>rowCount){return}var behavior=this.getBehavior();var hovered=this.getHoverCell();var sy=this.getVScrollValue();var x=hovered.x;if(hovered.x>-1){x=behavior.translateColumnIndex(hovered.x+this.getHScrollValue())}if(hovered.y<0){sy=0}hovered=rectangles.point.create(x,hovered.y+sy);this.getBehavior().cellClicked(hovered,event)},fireSyntheticKeydownEvent:function(keyEvent){var clickEvent=new CustomEvent("fin-keydown",{detail:keyEvent.detail});this.canvas.dispatchEvent(clickEvent)},fireSyntheticKeyupEvent:function(keyEvent){var clickEvent=new CustomEvent("fin-keyup",{detail:keyEvent.detail});this.canvas.dispatchEvent(clickEvent)},fireSyntheticOnCellEnterEvent:function(mouseEvent){var detail={gridCell:this.rectangles.point.create(mouseEvent.x+this.getHScrollValue(),mouseEvent.y+this.getVScrollValue()),time:Date.now(),grid:this};var clickEvent=new CustomEvent("fin-cell-enter",{detail:detail});this.canvas.dispatchEvent(clickEvent)},fireSyntheticOnCellExitEvent:function(mouseEvent){var detail={gridCell:this.rectangles.point.create(mouseEvent.x+this.getHScrollValue(),mouseEvent.y+this.getVScrollValue()),time:Date.now(),grid:this};var clickEvent=new CustomEvent("fin-cell-exit",{detail:detail});this.canvas.dispatchEvent(clickEvent)},fireSyntheticClickEvent:function(mouseEvent){var cell=mouseEvent.gridCell;var fixedColCount=this.getFixedColumnCount();var fixedRowCount=this.getFixedRowCount();var x=cell.x<fixedColCount?cell.x-fixedColCount:cell.x+this.getHScrollValue()-fixedColCount;var y=cell.y<fixedRowCount?cell.y-fixedRowCount:cell.y+this.getVScrollValue()-fixedRowCount;var detail={gridCell:this.rectangles.point.create(x,y),mousePoint:mouseEvent.mousePoint,primitiveEvent:mouseEvent,time:Date.now(),grid:this};this.getBehavior().enhanceDoubleClickEvent(detail);var clickEvent=new CustomEvent("fin-click",{detail:detail});this.canvas.dispatchEvent(clickEvent)},fireSyntheticDoubleClickEvent:function(mouseEvent){var cell=mouseEvent.gridCell;var behavior=this.getBehavior();var fixedColCount=this.getFixedColumnCount();var fixedRowCount=this.getFixedRowCount();var x=cell.x<fixedColCount?cell.x-fixedColCount:cell.x+this.getHScrollValue()-fixedColCount;var y=cell.y<fixedRowCount?cell.y-fixedRowCount:cell.y+this.getVScrollValue()-fixedRowCount;var detail={gridCell:this.rectangles.point.create(x,y),mousePoint:mouseEvent.mousePoint,time:Date.now(),grid:this};behavior.enhanceDoubleClickEvent(mouseEvent);var clickEvent=new CustomEvent("fin-double-click",{detail:detail});behavior.cellDoubleClicked(cell,mouseEvent);this.canvas.dispatchEvent(clickEvent)},fireSyntheticGridRenderedEvent:function(){var event=new CustomEvent("fin-grid-rendered",{detail:{source:this,time:Date.now()}});this.canvas.dispatchEvent(event)},fireScrollEvent:function(type,oldValue,newValue){var event=new CustomEvent(type,{detail:{oldValue:oldValue,value:newValue,time:Date.now()}});this.canvas.dispatchEvent(event);var self=this;self.lastScrollTime=Date.now();var hoverClassOver=self.resolveProperty("scrollbarHoverOver");var hoverClassOff=self.resolveProperty("scrollbarHoverOff");if(!self.resolveProperty("scrollingEnabled")){hoverClassOver="hidden";hoverClassOff="hidden"}if(type==="fin-scroll-x"){self.sbHScroller.classList.remove(hoverClassOff);self.sbHScroller.classList.add(hoverClassOver);setTimeout(function(){if(!self.sbMouseIsDown&&!self.scrollBarHasMouse&&Date.now()-self.lastScrollTime>100){self.sbHScroller.classList.remove(hoverClassOver);self.sbHScroller.classList.add(hoverClassOff)}},700)}else{self.sbVScroller.classList.remove(hoverClassOff);self.sbVScroller.classList.add(hoverClassOver);setTimeout(function(){if(!self.sbMouseIsDown&&!self.scrollBarHasMouse&&Date.now()-self.lastScrollTime>100){self.sbVScroller.classList.remove(hoverClassOver);self.sbVScroller.classList.add(hoverClassOff)}},700)}},setVScrollValue:function(y){var max=this.sbVScrollConfig.rangeStop;y=Math.min(max,Math.max(0,y));var self=this;if(y===this.vScrollValue){return}this.getBehavior()._setScrollPositionY(y);var oldY=this.vScrollValue;this.vScrollValue=y;this.scrollValueChangedNotification();setTimeout(function(){self.sbVRangeAdapter.subjectChanged();self.fireScrollEvent("fin-scroll-y",oldY,y)})},getVScrollValue:function(){return this.vScrollValue},setHScrollValue:function(x){var max=this.sbHScrollConfig.rangeStop;x=Math.min(max,Math.max(0,x));var self=this;if(x===this.hScrollValue){return}this.getBehavior()._setScrollPositionX(x);var oldX=this.hScrollValue;this.hScrollValue=x;this.scrollValueChangedNotification();setTimeout(function(){self.sbHRangeAdapter.subjectChanged();self.fireScrollEvent("fin-scroll-x",oldX,x)})},getHScrollValue:function(){return this.hScrollValue},takeFocus:function(){if(this.isEditing()){this.editorTakeFocus()}else{this.getCanvas().takeFocus()}},editorTakeFocus:function(){if(this.cellEditor){return this.cellEditor.takeFocus()}},isEditing:function(){if(this.cellEditor){return this.cellEditor.isEditing}return false},initScrollbars:function(){var self=this;var scrollbars=this.shadowRoot.querySelectorAll("fin-vampire-bar");this.sbHScroller=scrollbars[0];this.sbVScroller=scrollbars[1];this.sbHScroller.onUpClick=function(){self.scrollHBy(1);self.isScrollButtonClick=true};this.sbHScroller.onDownClick=function(){self.scrollHBy(-1);self.isScrollButtonClick=true};this.sbHScroller.onUpHold=function(event){event.preventTap();self.scrollHBy(1);self.isScrollButtonClick=true};this.sbHScroller.onDownHold=function(event){event.preventTap();self.scrollHBy(-1);self.isScrollButtonClick=true};this.sbHScroller.onmouseover=function(event){noop(event);self.isScrollButtonClick=false;var hoverClassOver=self.resolveProperty("scrollbarHoverOver");var hoverClassOff=self.resolveProperty("scrollbarHoverOff");if(!self.resolveProperty("scrollingEnabled")){hoverClassOver="hidden";hoverClassOff="hidden"}self.sbHScroller.classList.remove(hoverClassOff);self.sbHScroller.classList.add(hoverClassOver)};this.sbHScroller.onmouseout=function(event){noop(event);if(self.sbMouseIsDown){return}else{var hoverClassOver=self.resolveProperty("scrollbarHoverOver");var hoverClassOff=self.resolveProperty("scrollbarHoverOff");if(!self.resolveProperty("scrollingEnabled")){hoverClassOver="hidden";hoverClassOff="hidden"}self.sbHScroller.classList.remove(hoverClassOver);self.sbHScroller.classList.add(hoverClassOff)}};this.sbVScroller.onmouseover=function(event){noop(event);self.isScrollButtonClick=false;var hoverClassOver=self.resolveProperty("scrollbarHoverOver");var hoverClassOff=self.resolveProperty("scrollbarHoverOff");if(!self.resolveProperty("scrollingEnabled")){hoverClassOver="hidden";hoverClassOff="hidden"}self.sbVScroller.classList.remove(hoverClassOff);self.sbVScroller.classList.add(hoverClassOver)};this.sbVScroller.onmouseout=function(event){noop(event);if(self.sbMouseIsDown){return}else{var hoverClassOver=self.resolveProperty("scrollbarHoverOver");var hoverClassOff=self.resolveProperty("scrollbarHoverOff");if(!self.resolveProperty("scrollingEnabled")){hoverClassOver="hidden";hoverClassOff="hidden"}self.sbVScroller.classList.remove(hoverClassOver);self.sbVScroller.classList.add(hoverClassOff)}};this.addEventListener("mousedown",function(){self.sbMouseIsDown=true});this.sbVScroller.onUpClick=function(){self.scrollVBy(-1);self.isScrollButtonClick=true};this.sbVScroller.onDownClick=function(){self.scrollVBy(1);self.isScrollButtonClick=true};this.sbVScroller.onUpHold=function(event){event.preventTap();self.scrollVBy(-1);self.isScrollButtonClick=true};this.sbVScroller.onDownHold=function(event){event.preventTap();self.scrollVBy(1);self.isScrollButtonClick=true};this.addEventListener("mousedown",function(){self.sbMouseIsDown=true});document.addEventListener("mouseup",function(e){noop(e);if(!self.sbMouseIsDown){return}self.sbMouseIsDown=false;self.takeFocus();var x=e.x||e.clientX;var y=e.y||e.clientY;var elementAt=self.shadowRoot.elementFromPoint(x,y);self.scrollBarHasMouse=elementAt===self.sbVScroller||elementAt===self.sbHScroller;if(!self.scrollBarHasMouse){var hoverClassOver=self.resolveProperty("scrollbarHoverOver");var hoverClassOff=self.resolveProperty("scrollbarHoverOff");if(!self.resolveProperty("scrollingEnabled")){hoverClassOver="hidden";hoverClassOff="hidden"}self.sbVScroller.classList.remove(hoverClassOver);self.sbHScroller.classList.remove(hoverClassOver);self.sbVScroller.classList.add(hoverClassOff);self.sbHScroller.classList.add(hoverClassOff)}});this.sbHValueHolder={changed:false,getValue:function(){return self.getHScrollValue()},setValue:function(v){self.setHScrollValue(v)}};this.sbVValueHolder={changed:false,getValue:function(){return self.getVScrollValue()},setValue:function(v){self.setVScrollValue(v)}};this.sbHScrollConfig={step:1,page:40,rangeStart:0,rangeStop:0};this.sbVScrollConfig={step:1,page:40,rangeStart:0,rangeStop:0};this.sbHRangeAdapter=this.sbHScroller.createRangeAdapter(this.sbHValueHolder,this.sbHScrollConfig);this.sbVRangeAdapter=this.sbHScroller.createRangeAdapter(this.sbVValueHolder,this.sbVScrollConfig);this.sbHScroller.setRangeAdapter(this.sbHRangeAdapter);this.sbVScroller.setRangeAdapter(this.sbVRangeAdapter)},scrollValueChangedNotification:function(){if(this.hScrollValue===this.sbPrevHScrollValue&&this.vScrollValue===this.sbPrevVScrollValue){return}this.sbHValueHolder.changed=!this.sbHValueHolder.changed;this.sbVValueHolder.changed=!this.sbVValueHolder.changed;this.sbPrevHScrollValue=this.hScrollValue;this.sbPrevVScrollValue=this.vScrollValue;if(this.cellEditor){this.cellEditor.scrollValueChangedNotification()}},getValue:function(x,y){return this.getBehavior()._getValue(x,y)},setValue:function(x,y,value){this.getBehavior()._setValue(x,y,value)},synchronizeScrollingBoundries:function(){var behavior=this.getBehavior();if(!behavior){return}var numColumns=behavior._getColumnCount();var numRows=behavior.getRowCount();var bounds=this.getBounds();if(!bounds){return}var scrollableHeight=bounds.height()-behavior.getFixedRowsHeight();var scrollableWidth=bounds.width()-behavior.getFixedColumnsMaxWidth()-200;var lastPageColumnCount=0;var columnsWidth=0;for(;lastPageColumnCount<numColumns;lastPageColumnCount++){var eachWidth=behavior._getColumnWidth(numColumns-lastPageColumnCount-1);columnsWidth=columnsWidth+eachWidth;if(columnsWidth>scrollableWidth){break}}var lastPageRowCount=0;var rowsHeight=0;for(;lastPageRowCount<numRows;lastPageRowCount++){var eachHeight=behavior.getRowHeight(numRows-lastPageRowCount-1);rowsHeight=rowsHeight+eachHeight;if(rowsHeight>scrollableHeight){break}}this.sbVScrollConfig.rangeStop=behavior.getRowCount()-lastPageRowCount;this.sbHScrollConfig.rangeStop=behavior._getColumnCount()-lastPageColumnCount;this.setVScrollValue(Math.min(this.getVScrollValue(),this.sbVScrollConfig.rangeStop));this.setHScrollValue(Math.min(this.getHScrollValue(),this.sbHScrollConfig.rangeStop));this.repaint()},getViewableRows:function(){return this.getRenderer().getViewableRows()},getViewableColumns:function(){return this.getRenderer().getViewableColumns()},initRenderer:function(){this.renderer=this.shadowRoot.querySelector("fin-hypergrid-renderer");this.renderer.setGrid(this)},getRenderer:function(){return this.renderer},getColumnWidth:function(columnIndex){return this.getBehavior()._getColumnWidth(columnIndex)},setColumnWidth:function(columnIndex,columnWidth){this.getBehavior()._setColumnWidth(columnIndex,columnWidth)},getFixedColumnWidth:function(columnIndex){return this.getBehavior().getFixedColumnWidth(columnIndex)},getFixedColumnsWidth:function(){
return this.getBehavior().getFixedColumnsWidth()},setFixedColumnWidth:function(columnIndex,columnWidth){this.getBehavior().setFixedColumnWidth(columnIndex,columnWidth)},getRowHeight:function(rowIndex){return this.getBehavior().getRowHeight(rowIndex)},setRowHeight:function(rowIndex,rowHeight){this.getBehavior().setRowHeight(rowIndex,rowHeight)},getFixedRowHeight:function(rowIndex){return this.getBehavior().getFixedRowHeight(rowIndex)},setFixedRowHeight:function(rowIndex,rowHeight){this.getBehavior().setFixedRowHeight(rowIndex,rowHeight)},getFixedRowsHeight:function(){return this.getBehavior().getFixedRowsHeight()},getColumnCount:function(){return this.getBehavior()._getColumnCount()},getRowCount:function(){return this.getBehavior().getRowCount()},getFixedColumnCount:function(){return this.getBehavior().getFixedColumnCount()},getFixedRowCount:function(){return this.getBehavior().getFixedRowCount()},topLeftClicked:function(mouse){this.getBehavior().topLeftClicked(this,mouse)},fixedRowClicked:function(mouse){this.getBehavior()._fixedRowClicked(this,mouse)},fixedColumnClicked:function(mouse){this.getBehavior()._fixedColumnClicked(this,mouse)},_activateEditor:function(event){var gridCell=event.gridCell;this.activateEditor(gridCell.x,gridCell.y)},activateEditor:function(x,y){var editor=this.getCellEditorAt(x,y);if(editor){event.gridCell={x:x,y:y};this.editAt(editor,event)}},getCellEditorAt:function(x,y){return this.getBehavior()._getCellEditorAt(x,y)},toggleHiDPI:function(){if(this.canvas.isHiDPI()){this.removeAttribute("hidpi")}else{this.setAttribute("hidpi",null)}this.canvas.resize()},getHiDPI:function(ctx){if(window.devicePixelRatio&&this.canvas.isHiDPI()){var devicePixelRatio=window.devicePixelRatio||1;var backingStoreRatio=ctx.webkitBackingStorePixelRatio||ctx.mozBackingStorePixelRatio||ctx.msBackingStorePixelRatio||ctx.oBackingStorePixelRatio||ctx.backingStorePixelRatio||1;var ratio=devicePixelRatio/backingStoreRatio;return ratio}else{return 1}},getRenderedWidth:function(colIndex){return this.renderer.getRenderedWidth(colIndex)},getRenderedHeight:function(rowIndex){return this.renderer.getRenderedHeight(rowIndex)},resolveCellEditor:function(name){return this.cellEditors[name]},updateCursor:function(){var behavior=this.getBehavior();var cursor=behavior.getCursorAt(-1,-1);var hoverCell=this.getHoverCell();if(hoverCell&&hoverCell.x>-1&&hoverCell.y>-1){var x=hoverCell.x+this.getHScrollValue();x=behavior.translateColumnIndex(x);cursor=behavior.getCursorAt(x,hoverCell.y+this.getVScrollValue())}this.beCursor(cursor)},repaintCell:function(x,y){this.getRenderer().repaintCell(x,y)},isDraggingColumn:function(){if(this.renderOverridesCache.dragger){return true}else{return false}},pageUp:function(){var rowNum=this.getRenderer().getPageUpRow();this.setVScrollValue(rowNum)},pageDown:function(){var rowNum=this.getRenderer().getPageDownRow();this.setVScrollValue(rowNum)},pageLeft:function(){console.log("page left")},pageRight:function(){console.log("page right")},getRenderedData:function(){var behavior=this.getBehavior();var renderer=this.getRenderer();var colCount=this.getColumnCount();var rowCount=renderer.getViewableRows();var headers=[];var result=[];var r,c;for(c=0;c<colCount;c++){headers[c]=behavior.getColumnId(c,0)}for(r=0;r<rowCount;r++){var row={};row.hierarchy=behavior.getFixedColumnValue(0,r);for(c=0;c<colCount;c++){var field=headers[c];row[field]=behavior.getValue(c,r)}result[r]=row}return result},selectionChanged:function(){var event=new CustomEvent("fin-selection-changed",{detail:{time:Date.now()}});this.canvas.dispatchEvent(event)},getSelectedRow:function(){var sels=this.getSelectionModel().getSelections();if(sels.length<1){return}var behavior=this.getBehavior();var colCount=this.getColumnCount();var headers=[];var topRow=sels[0].origin.y;var c;for(c=0;c<colCount;c++){headers[c]=behavior.getColumnId(c,0)}var row={};row.hierarchy=behavior.getFixedColumnValue(0,topRow);for(c=0;c<colCount;c++){var field=headers[c];row[field]=behavior.getValue(c,topRow)}return row},fireBeforeCellEdit:function(cell,value){var clickEvent=new CustomEvent("fin-before-cell-edit",{detail:{value:value,gridCell:cell,time:Date.now()}});var proceed=this.canvas.dispatchEvent(clickEvent);return proceed},fireAfterCellEdit:function(cell,oldValue,newValue){var clickEvent=new CustomEvent("fin-after-cell-edit",{detail:{newValue:newValue,oldValue:oldValue,gridCell:cell,time:Date.now()}});this.canvas.dispatchEvent(clickEvent)},autosizeColumn:function(colIndex){var width,currentWidth;if(colIndex<0){var numFixedCols=this.getFixedColumnCount();colIndex=colIndex+numFixedCols;currentWidth=this.getFixedColumnWidth(colIndex);width=this.getRenderer().renderedFixedColumnMinWidths[colIndex];this.setFixedColumnWidth(colIndex,Math.max(width,currentWidth))}else{width=this.getRenderer().renderedColumnMinWidths[colIndex];this.setColumnWidth(colIndex,width)}},setFocusable:function(boolean){this.getCanvas().setFocusable(boolean)},getVisibleColumns:function(){return this.getRenderer().getVisibleColumns()},getVisibleRows:function(){return this.getRenderer().getVisibleRows()},updateSize:function(){this.canvas.checksize()},stopPaintThread:function(){this.canvas.stopPaintThread()},stopResizeThread:function(){this.canvas.stopResizeThread()},restartResizeThread:function(){this.canvas.restartResizeThread()},restartPaintThread:function(){this.canvas.restartPaintThread()}})})();</script></polymer-element></body></html>