mumuki-gobstones-code-runner 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2260 @@
1
+ <!--
2
+ @license
3
+ Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
+ Code distributed by Google as part of the polymer project is also
8
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
+ --><link rel="import" href="polymer-micro.html"><script>(function () {
10
+ function resolveCss(cssText, ownerDocument) {
11
+ return cssText.replace(CSS_URL_RX, function (m, pre, url, post) {
12
+ return pre + '\'' + resolve(url.replace(/["']/g, ''), ownerDocument) + '\'' + post;
13
+ });
14
+ }
15
+ function resolveAttrs(element, ownerDocument) {
16
+ for (var name in URL_ATTRS) {
17
+ var a$ = URL_ATTRS[name];
18
+ for (var i = 0, l = a$.length, a, at, v; i < l && (a = a$[i]); i++) {
19
+ if (name === '*' || element.localName === name) {
20
+ at = element.attributes[a];
21
+ v = at && at.value;
22
+ if (v && v.search(BINDING_RX) < 0) {
23
+ at.value = a === 'style' ? resolveCss(v, ownerDocument) : resolve(v, ownerDocument);
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
29
+ function resolve(url, ownerDocument) {
30
+ if (url && ABS_URL.test(url)) {
31
+ return url;
32
+ }
33
+ var resolver = getUrlResolver(ownerDocument);
34
+ resolver.href = url;
35
+ return resolver.href || url;
36
+ }
37
+ var tempDoc;
38
+ var tempDocBase;
39
+ function resolveUrl(url, baseUri) {
40
+ if (!tempDoc) {
41
+ tempDoc = document.implementation.createHTMLDocument('temp');
42
+ tempDocBase = tempDoc.createElement('base');
43
+ tempDoc.head.appendChild(tempDocBase);
44
+ }
45
+ tempDocBase.href = baseUri;
46
+ return resolve(url, tempDoc);
47
+ }
48
+ function getUrlResolver(ownerDocument) {
49
+ return ownerDocument.body.__urlResolver || (ownerDocument.body.__urlResolver = ownerDocument.createElement('a'));
50
+ }
51
+ function pathFromUrl(url) {
52
+ return url.substring(0, url.lastIndexOf('/') + 1);
53
+ }
54
+ var CSS_URL_RX = /(url\()([^)]*)(\))/g;
55
+ var URL_ATTRS = {
56
+ '*': [
57
+ 'href',
58
+ 'src',
59
+ 'style',
60
+ 'url'
61
+ ],
62
+ form: ['action']
63
+ };
64
+ var ABS_URL = /(^\/)|(^#)|(^[\w-\d]*:)/;
65
+ var BINDING_RX = /\{\{|\[\[/;
66
+ Polymer.ResolveUrl = {
67
+ resolveCss: resolveCss,
68
+ resolveAttrs: resolveAttrs,
69
+ resolveUrl: resolveUrl,
70
+ pathFromUrl: pathFromUrl
71
+ };
72
+ Polymer.rootPath = Polymer.Settings.rootPath || pathFromUrl(document.baseURI || window.location.href);
73
+ }());Polymer.Base._addFeature({
74
+ _prepTemplate: function () {
75
+ var module;
76
+ if (this._template === undefined) {
77
+ module = Polymer.DomModule.import(this.is);
78
+ var template = module && module.querySelector('template');
79
+ if (Polymer.Settings.strictTemplatePolicy && !template) {
80
+ throw new Error('strictTemplatePolicy: expecting dom-module or null _template for ' + this.is);
81
+ }
82
+ this._template = template;
83
+ }
84
+ if (module) {
85
+ var assetPath = module.getAttribute('assetpath') || '';
86
+ var importURL = Polymer.ResolveUrl.resolveUrl(assetPath, module.ownerDocument.baseURI);
87
+ this._importPath = Polymer.ResolveUrl.pathFromUrl(importURL);
88
+ } else {
89
+ this._importPath = '';
90
+ }
91
+ if (this._template && this._template.hasAttribute('is')) {
92
+ this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
93
+ }
94
+ if (this._template && !this._template.content && window.HTMLTemplateElement && HTMLTemplateElement.decorate) {
95
+ HTMLTemplateElement.decorate(this._template);
96
+ }
97
+ },
98
+ _stampTemplate: function () {
99
+ if (this._template) {
100
+ this.root = this.instanceTemplate(this._template);
101
+ }
102
+ },
103
+ instanceTemplate: function (template) {
104
+ var dom = document.importNode(template._content || template.content, true);
105
+ return dom;
106
+ }
107
+ });(function () {
108
+ var baseAttachedCallback = Polymer.Base.attachedCallback;
109
+ var baseDetachedCallback = Polymer.Base.detachedCallback;
110
+ Polymer.Base._addFeature({
111
+ _hostStack: [],
112
+ ready: function () {
113
+ },
114
+ _registerHost: function (host) {
115
+ this.dataHost = host = host || Polymer.Base._hostStack[Polymer.Base._hostStack.length - 1];
116
+ if (host && host._clients) {
117
+ host._clients.push(this);
118
+ }
119
+ this._clients = null;
120
+ this._clientsReadied = false;
121
+ },
122
+ _beginHosting: function () {
123
+ Polymer.Base._hostStack.push(this);
124
+ if (!this._clients) {
125
+ this._clients = [];
126
+ }
127
+ },
128
+ _endHosting: function () {
129
+ Polymer.Base._hostStack.pop();
130
+ },
131
+ _tryReady: function () {
132
+ this._readied = false;
133
+ if (this._canReady()) {
134
+ this._ready();
135
+ }
136
+ },
137
+ _canReady: function () {
138
+ return !this.dataHost || this.dataHost._clientsReadied;
139
+ },
140
+ _ready: function () {
141
+ this._beforeClientsReady();
142
+ if (this._template) {
143
+ this._setupRoot();
144
+ this._readyClients();
145
+ }
146
+ this._clientsReadied = true;
147
+ this._clients = null;
148
+ this._afterClientsReady();
149
+ this._readySelf();
150
+ },
151
+ _readyClients: function () {
152
+ this._beginDistribute();
153
+ var c$ = this._clients;
154
+ if (c$) {
155
+ for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
156
+ c._ready();
157
+ }
158
+ }
159
+ this._finishDistribute();
160
+ },
161
+ _readySelf: function () {
162
+ for (var i = 0, b; i < this.behaviors.length; i++) {
163
+ b = this.behaviors[i];
164
+ if (b.ready) {
165
+ b.ready.call(this);
166
+ }
167
+ }
168
+ if (this.ready) {
169
+ this.ready();
170
+ }
171
+ this._readied = true;
172
+ if (this._attachedPending) {
173
+ this._attachedPending = false;
174
+ this.attachedCallback();
175
+ }
176
+ },
177
+ _beforeClientsReady: function () {
178
+ },
179
+ _afterClientsReady: function () {
180
+ },
181
+ _beforeAttached: function () {
182
+ },
183
+ attachedCallback: function () {
184
+ if (this._readied) {
185
+ this._beforeAttached();
186
+ baseAttachedCallback.call(this);
187
+ } else {
188
+ this._attachedPending = true;
189
+ }
190
+ },
191
+ detachedCallback: function () {
192
+ if (this._readied) {
193
+ baseDetachedCallback.call(this);
194
+ } else {
195
+ this._attachedPending = false;
196
+ }
197
+ }
198
+ });
199
+ }());Polymer.ArraySplice = function () {
200
+ function newSplice(index, removed, addedCount) {
201
+ return {
202
+ index: index,
203
+ removed: removed,
204
+ addedCount: addedCount
205
+ };
206
+ }
207
+ var EDIT_LEAVE = 0;
208
+ var EDIT_UPDATE = 1;
209
+ var EDIT_ADD = 2;
210
+ var EDIT_DELETE = 3;
211
+ function ArraySplice() {
212
+ }
213
+ ArraySplice.prototype = {
214
+ calcEditDistances: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
215
+ var rowCount = oldEnd - oldStart + 1;
216
+ var columnCount = currentEnd - currentStart + 1;
217
+ var distances = new Array(rowCount);
218
+ for (var i = 0; i < rowCount; i++) {
219
+ distances[i] = new Array(columnCount);
220
+ distances[i][0] = i;
221
+ }
222
+ for (var j = 0; j < columnCount; j++)
223
+ distances[0][j] = j;
224
+ for (i = 1; i < rowCount; i++) {
225
+ for (j = 1; j < columnCount; j++) {
226
+ if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1]))
227
+ distances[i][j] = distances[i - 1][j - 1];
228
+ else {
229
+ var north = distances[i - 1][j] + 1;
230
+ var west = distances[i][j - 1] + 1;
231
+ distances[i][j] = north < west ? north : west;
232
+ }
233
+ }
234
+ }
235
+ return distances;
236
+ },
237
+ spliceOperationsFromEditDistances: function (distances) {
238
+ var i = distances.length - 1;
239
+ var j = distances[0].length - 1;
240
+ var current = distances[i][j];
241
+ var edits = [];
242
+ while (i > 0 || j > 0) {
243
+ if (i == 0) {
244
+ edits.push(EDIT_ADD);
245
+ j--;
246
+ continue;
247
+ }
248
+ if (j == 0) {
249
+ edits.push(EDIT_DELETE);
250
+ i--;
251
+ continue;
252
+ }
253
+ var northWest = distances[i - 1][j - 1];
254
+ var west = distances[i - 1][j];
255
+ var north = distances[i][j - 1];
256
+ var min;
257
+ if (west < north)
258
+ min = west < northWest ? west : northWest;
259
+ else
260
+ min = north < northWest ? north : northWest;
261
+ if (min == northWest) {
262
+ if (northWest == current) {
263
+ edits.push(EDIT_LEAVE);
264
+ } else {
265
+ edits.push(EDIT_UPDATE);
266
+ current = northWest;
267
+ }
268
+ i--;
269
+ j--;
270
+ } else if (min == west) {
271
+ edits.push(EDIT_DELETE);
272
+ i--;
273
+ current = west;
274
+ } else {
275
+ edits.push(EDIT_ADD);
276
+ j--;
277
+ current = north;
278
+ }
279
+ }
280
+ edits.reverse();
281
+ return edits;
282
+ },
283
+ calcSplices: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
284
+ var prefixCount = 0;
285
+ var suffixCount = 0;
286
+ var minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);
287
+ if (currentStart == 0 && oldStart == 0)
288
+ prefixCount = this.sharedPrefix(current, old, minLength);
289
+ if (currentEnd == current.length && oldEnd == old.length)
290
+ suffixCount = this.sharedSuffix(current, old, minLength - prefixCount);
291
+ currentStart += prefixCount;
292
+ oldStart += prefixCount;
293
+ currentEnd -= suffixCount;
294
+ oldEnd -= suffixCount;
295
+ if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)
296
+ return [];
297
+ if (currentStart == currentEnd) {
298
+ var splice = newSplice(currentStart, [], 0);
299
+ while (oldStart < oldEnd)
300
+ splice.removed.push(old[oldStart++]);
301
+ return [splice];
302
+ } else if (oldStart == oldEnd)
303
+ return [newSplice(currentStart, [], currentEnd - currentStart)];
304
+ var ops = this.spliceOperationsFromEditDistances(this.calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd));
305
+ splice = undefined;
306
+ var splices = [];
307
+ var index = currentStart;
308
+ var oldIndex = oldStart;
309
+ for (var i = 0; i < ops.length; i++) {
310
+ switch (ops[i]) {
311
+ case EDIT_LEAVE:
312
+ if (splice) {
313
+ splices.push(splice);
314
+ splice = undefined;
315
+ }
316
+ index++;
317
+ oldIndex++;
318
+ break;
319
+ case EDIT_UPDATE:
320
+ if (!splice)
321
+ splice = newSplice(index, [], 0);
322
+ splice.addedCount++;
323
+ index++;
324
+ splice.removed.push(old[oldIndex]);
325
+ oldIndex++;
326
+ break;
327
+ case EDIT_ADD:
328
+ if (!splice)
329
+ splice = newSplice(index, [], 0);
330
+ splice.addedCount++;
331
+ index++;
332
+ break;
333
+ case EDIT_DELETE:
334
+ if (!splice)
335
+ splice = newSplice(index, [], 0);
336
+ splice.removed.push(old[oldIndex]);
337
+ oldIndex++;
338
+ break;
339
+ }
340
+ }
341
+ if (splice) {
342
+ splices.push(splice);
343
+ }
344
+ return splices;
345
+ },
346
+ sharedPrefix: function (current, old, searchLength) {
347
+ for (var i = 0; i < searchLength; i++)
348
+ if (!this.equals(current[i], old[i]))
349
+ return i;
350
+ return searchLength;
351
+ },
352
+ sharedSuffix: function (current, old, searchLength) {
353
+ var index1 = current.length;
354
+ var index2 = old.length;
355
+ var count = 0;
356
+ while (count < searchLength && this.equals(current[--index1], old[--index2]))
357
+ count++;
358
+ return count;
359
+ },
360
+ calculateSplices: function (current, previous) {
361
+ return this.calcSplices(current, 0, current.length, previous, 0, previous.length);
362
+ },
363
+ equals: function (currentValue, previousValue) {
364
+ return currentValue === previousValue;
365
+ }
366
+ };
367
+ return new ArraySplice();
368
+ }();Polymer.domInnerHTML = function () {
369
+ var escapeAttrRegExp = /[&\u00A0"]/g;
370
+ var escapeDataRegExp = /[&\u00A0<>]/g;
371
+ function escapeReplace(c) {
372
+ switch (c) {
373
+ case '&':
374
+ return '&amp;';
375
+ case '<':
376
+ return '&lt;';
377
+ case '>':
378
+ return '&gt;';
379
+ case '"':
380
+ return '&quot;';
381
+ case '\xA0':
382
+ return '&nbsp;';
383
+ }
384
+ }
385
+ function escapeAttr(s) {
386
+ return s.replace(escapeAttrRegExp, escapeReplace);
387
+ }
388
+ function escapeData(s) {
389
+ return s.replace(escapeDataRegExp, escapeReplace);
390
+ }
391
+ function makeSet(arr) {
392
+ var set = {};
393
+ for (var i = 0; i < arr.length; i++) {
394
+ set[arr[i]] = true;
395
+ }
396
+ return set;
397
+ }
398
+ var voidElements = makeSet([
399
+ 'area',
400
+ 'base',
401
+ 'br',
402
+ 'col',
403
+ 'command',
404
+ 'embed',
405
+ 'hr',
406
+ 'img',
407
+ 'input',
408
+ 'keygen',
409
+ 'link',
410
+ 'meta',
411
+ 'param',
412
+ 'source',
413
+ 'track',
414
+ 'wbr'
415
+ ]);
416
+ var plaintextParents = makeSet([
417
+ 'style',
418
+ 'script',
419
+ 'xmp',
420
+ 'iframe',
421
+ 'noembed',
422
+ 'noframes',
423
+ 'plaintext',
424
+ 'noscript'
425
+ ]);
426
+ function getOuterHTML(node, parentNode, composed) {
427
+ switch (node.nodeType) {
428
+ case Node.ELEMENT_NODE:
429
+ var tagName = node.localName;
430
+ var s = '<' + tagName;
431
+ var attrs = node.attributes;
432
+ for (var i = 0, attr; attr = attrs[i]; i++) {
433
+ s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
434
+ }
435
+ s += '>';
436
+ if (voidElements[tagName]) {
437
+ return s;
438
+ }
439
+ return s + getInnerHTML(node, composed) + '</' + tagName + '>';
440
+ case Node.TEXT_NODE:
441
+ var data = node.data;
442
+ if (parentNode && plaintextParents[parentNode.localName]) {
443
+ return data;
444
+ }
445
+ return escapeData(data);
446
+ case Node.COMMENT_NODE:
447
+ return '<!--' + node.data + '-->';
448
+ default:
449
+ console.error(node);
450
+ throw new Error('not implemented');
451
+ }
452
+ }
453
+ function getInnerHTML(node, composed) {
454
+ if (node instanceof HTMLTemplateElement)
455
+ node = node.content;
456
+ var s = '';
457
+ var c$ = Polymer.dom(node).childNodes;
458
+ for (var i = 0, l = c$.length, child; i < l && (child = c$[i]); i++) {
459
+ s += getOuterHTML(child, node, composed);
460
+ }
461
+ return s;
462
+ }
463
+ return { getInnerHTML: getInnerHTML };
464
+ }();(function () {
465
+ 'use strict';
466
+ var nativeInsertBefore = Element.prototype.insertBefore;
467
+ var nativeAppendChild = Element.prototype.appendChild;
468
+ var nativeRemoveChild = Element.prototype.removeChild;
469
+ Polymer.TreeApi = {
470
+ arrayCopyChildNodes: function (parent) {
471
+ var copy = [], i = 0;
472
+ for (var n = parent.firstChild; n; n = n.nextSibling) {
473
+ copy[i++] = n;
474
+ }
475
+ return copy;
476
+ },
477
+ arrayCopyChildren: function (parent) {
478
+ var copy = [], i = 0;
479
+ for (var n = parent.firstElementChild; n; n = n.nextElementSibling) {
480
+ copy[i++] = n;
481
+ }
482
+ return copy;
483
+ },
484
+ arrayCopy: function (a$) {
485
+ var l = a$.length;
486
+ var copy = new Array(l);
487
+ for (var i = 0; i < l; i++) {
488
+ copy[i] = a$[i];
489
+ }
490
+ return copy;
491
+ }
492
+ };
493
+ Polymer.TreeApi.Logical = {
494
+ hasParentNode: function (node) {
495
+ return Boolean(node.__dom && node.__dom.parentNode);
496
+ },
497
+ hasChildNodes: function (node) {
498
+ return Boolean(node.__dom && node.__dom.childNodes !== undefined);
499
+ },
500
+ getChildNodes: function (node) {
501
+ return this.hasChildNodes(node) ? this._getChildNodes(node) : node.childNodes;
502
+ },
503
+ _getChildNodes: function (node) {
504
+ if (!node.__dom.childNodes) {
505
+ node.__dom.childNodes = [];
506
+ for (var n = node.__dom.firstChild; n; n = n.__dom.nextSibling) {
507
+ node.__dom.childNodes.push(n);
508
+ }
509
+ }
510
+ return node.__dom.childNodes;
511
+ },
512
+ getParentNode: function (node) {
513
+ return node.__dom && node.__dom.parentNode !== undefined ? node.__dom.parentNode : node.parentNode;
514
+ },
515
+ getFirstChild: function (node) {
516
+ return node.__dom && node.__dom.firstChild !== undefined ? node.__dom.firstChild : node.firstChild;
517
+ },
518
+ getLastChild: function (node) {
519
+ return node.__dom && node.__dom.lastChild !== undefined ? node.__dom.lastChild : node.lastChild;
520
+ },
521
+ getNextSibling: function (node) {
522
+ return node.__dom && node.__dom.nextSibling !== undefined ? node.__dom.nextSibling : node.nextSibling;
523
+ },
524
+ getPreviousSibling: function (node) {
525
+ return node.__dom && node.__dom.previousSibling !== undefined ? node.__dom.previousSibling : node.previousSibling;
526
+ },
527
+ getFirstElementChild: function (node) {
528
+ return node.__dom && node.__dom.firstChild !== undefined ? this._getFirstElementChild(node) : node.firstElementChild;
529
+ },
530
+ _getFirstElementChild: function (node) {
531
+ var n = node.__dom.firstChild;
532
+ while (n && n.nodeType !== Node.ELEMENT_NODE) {
533
+ n = n.__dom.nextSibling;
534
+ }
535
+ return n;
536
+ },
537
+ getLastElementChild: function (node) {
538
+ return node.__dom && node.__dom.lastChild !== undefined ? this._getLastElementChild(node) : node.lastElementChild;
539
+ },
540
+ _getLastElementChild: function (node) {
541
+ var n = node.__dom.lastChild;
542
+ while (n && n.nodeType !== Node.ELEMENT_NODE) {
543
+ n = n.__dom.previousSibling;
544
+ }
545
+ return n;
546
+ },
547
+ getNextElementSibling: function (node) {
548
+ return node.__dom && node.__dom.nextSibling !== undefined ? this._getNextElementSibling(node) : node.nextElementSibling;
549
+ },
550
+ _getNextElementSibling: function (node) {
551
+ var n = node.__dom.nextSibling;
552
+ while (n && n.nodeType !== Node.ELEMENT_NODE) {
553
+ n = n.__dom.nextSibling;
554
+ }
555
+ return n;
556
+ },
557
+ getPreviousElementSibling: function (node) {
558
+ return node.__dom && node.__dom.previousSibling !== undefined ? this._getPreviousElementSibling(node) : node.previousElementSibling;
559
+ },
560
+ _getPreviousElementSibling: function (node) {
561
+ var n = node.__dom.previousSibling;
562
+ while (n && n.nodeType !== Node.ELEMENT_NODE) {
563
+ n = n.__dom.previousSibling;
564
+ }
565
+ return n;
566
+ },
567
+ saveChildNodes: function (node) {
568
+ if (!this.hasChildNodes(node)) {
569
+ node.__dom = node.__dom || {};
570
+ node.__dom.firstChild = node.firstChild;
571
+ node.__dom.lastChild = node.lastChild;
572
+ node.__dom.childNodes = [];
573
+ for (var n = node.firstChild; n; n = n.nextSibling) {
574
+ n.__dom = n.__dom || {};
575
+ n.__dom.parentNode = node;
576
+ node.__dom.childNodes.push(n);
577
+ n.__dom.nextSibling = n.nextSibling;
578
+ n.__dom.previousSibling = n.previousSibling;
579
+ }
580
+ }
581
+ },
582
+ recordInsertBefore: function (node, container, ref_node) {
583
+ container.__dom.childNodes = null;
584
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
585
+ for (var n = node.firstChild; n; n = n.nextSibling) {
586
+ this._linkNode(n, container, ref_node);
587
+ }
588
+ } else {
589
+ this._linkNode(node, container, ref_node);
590
+ }
591
+ },
592
+ _linkNode: function (node, container, ref_node) {
593
+ node.__dom = node.__dom || {};
594
+ container.__dom = container.__dom || {};
595
+ if (ref_node) {
596
+ ref_node.__dom = ref_node.__dom || {};
597
+ }
598
+ node.__dom.previousSibling = ref_node ? ref_node.__dom.previousSibling : container.__dom.lastChild;
599
+ if (node.__dom.previousSibling) {
600
+ node.__dom.previousSibling.__dom.nextSibling = node;
601
+ }
602
+ node.__dom.nextSibling = ref_node || null;
603
+ if (node.__dom.nextSibling) {
604
+ node.__dom.nextSibling.__dom.previousSibling = node;
605
+ }
606
+ node.__dom.parentNode = container;
607
+ if (ref_node) {
608
+ if (ref_node === container.__dom.firstChild) {
609
+ container.__dom.firstChild = node;
610
+ }
611
+ } else {
612
+ container.__dom.lastChild = node;
613
+ if (!container.__dom.firstChild) {
614
+ container.__dom.firstChild = node;
615
+ }
616
+ }
617
+ container.__dom.childNodes = null;
618
+ },
619
+ recordRemoveChild: function (node, container) {
620
+ node.__dom = node.__dom || {};
621
+ container.__dom = container.__dom || {};
622
+ if (node === container.__dom.firstChild) {
623
+ container.__dom.firstChild = node.__dom.nextSibling;
624
+ }
625
+ if (node === container.__dom.lastChild) {
626
+ container.__dom.lastChild = node.__dom.previousSibling;
627
+ }
628
+ var p = node.__dom.previousSibling;
629
+ var n = node.__dom.nextSibling;
630
+ if (p) {
631
+ p.__dom.nextSibling = n;
632
+ }
633
+ if (n) {
634
+ n.__dom.previousSibling = p;
635
+ }
636
+ node.__dom.parentNode = node.__dom.previousSibling = node.__dom.nextSibling = undefined;
637
+ container.__dom.childNodes = null;
638
+ }
639
+ };
640
+ Polymer.TreeApi.Composed = {
641
+ getChildNodes: function (node) {
642
+ return Polymer.TreeApi.arrayCopyChildNodes(node);
643
+ },
644
+ getParentNode: function (node) {
645
+ return node.parentNode;
646
+ },
647
+ clearChildNodes: function (node) {
648
+ node.textContent = '';
649
+ },
650
+ insertBefore: function (parentNode, newChild, refChild) {
651
+ return nativeInsertBefore.call(parentNode, newChild, refChild || null);
652
+ },
653
+ appendChild: function (parentNode, newChild) {
654
+ return nativeAppendChild.call(parentNode, newChild);
655
+ },
656
+ removeChild: function (parentNode, node) {
657
+ return nativeRemoveChild.call(parentNode, node);
658
+ }
659
+ };
660
+ }());Polymer.DomApi = function () {
661
+ 'use strict';
662
+ var Settings = Polymer.Settings;
663
+ var TreeApi = Polymer.TreeApi;
664
+ var DomApi = function (node) {
665
+ this.node = needsToWrap ? DomApi.wrap(node) : node;
666
+ };
667
+ var needsToWrap = Settings.hasShadow && !Settings.nativeShadow;
668
+ DomApi.wrap = window.wrap ? window.wrap : function (node) {
669
+ return node;
670
+ };
671
+ DomApi.prototype = {
672
+ flush: function () {
673
+ Polymer.dom.flush();
674
+ },
675
+ deepContains: function (node) {
676
+ if (this.node.contains(node)) {
677
+ return true;
678
+ }
679
+ var n = node;
680
+ var doc = node.ownerDocument;
681
+ while (n && n !== doc && n !== this.node) {
682
+ n = Polymer.dom(n).parentNode || n.host;
683
+ }
684
+ return n === this.node;
685
+ },
686
+ queryDistributedElements: function (selector) {
687
+ var c$ = this.getEffectiveChildNodes();
688
+ var list = [];
689
+ for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
690
+ if (c.nodeType === Node.ELEMENT_NODE && DomApi.matchesSelector.call(c, selector)) {
691
+ list.push(c);
692
+ }
693
+ }
694
+ return list;
695
+ },
696
+ getEffectiveChildNodes: function () {
697
+ var list = [];
698
+ var c$ = this.childNodes;
699
+ for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
700
+ if (c.localName === CONTENT) {
701
+ var d$ = dom(c).getDistributedNodes();
702
+ for (var j = 0; j < d$.length; j++) {
703
+ list.push(d$[j]);
704
+ }
705
+ } else {
706
+ list.push(c);
707
+ }
708
+ }
709
+ return list;
710
+ },
711
+ observeNodes: function (callback) {
712
+ if (callback) {
713
+ if (!this.observer) {
714
+ this.observer = this.node.localName === CONTENT ? new DomApi.DistributedNodesObserver(this) : new DomApi.EffectiveNodesObserver(this);
715
+ }
716
+ return this.observer.addListener(callback);
717
+ }
718
+ },
719
+ unobserveNodes: function (handle) {
720
+ if (this.observer) {
721
+ this.observer.removeListener(handle);
722
+ }
723
+ },
724
+ notifyObserver: function () {
725
+ if (this.observer) {
726
+ this.observer.notify();
727
+ }
728
+ },
729
+ _query: function (matcher, node, halter) {
730
+ node = node || this.node;
731
+ var list = [];
732
+ this._queryElements(TreeApi.Logical.getChildNodes(node), matcher, halter, list);
733
+ return list;
734
+ },
735
+ _queryElements: function (elements, matcher, halter, list) {
736
+ for (var i = 0, l = elements.length, c; i < l && (c = elements[i]); i++) {
737
+ if (c.nodeType === Node.ELEMENT_NODE) {
738
+ if (this._queryElement(c, matcher, halter, list)) {
739
+ return true;
740
+ }
741
+ }
742
+ }
743
+ },
744
+ _queryElement: function (node, matcher, halter, list) {
745
+ var result = matcher(node);
746
+ if (result) {
747
+ list.push(node);
748
+ }
749
+ if (halter && halter(result)) {
750
+ return result;
751
+ }
752
+ this._queryElements(TreeApi.Logical.getChildNodes(node), matcher, halter, list);
753
+ }
754
+ };
755
+ var CONTENT = DomApi.CONTENT = 'content';
756
+ var dom = DomApi.factory = function (node) {
757
+ node = node || document;
758
+ if (!node.__domApi) {
759
+ node.__domApi = new DomApi.ctor(node);
760
+ }
761
+ return node.__domApi;
762
+ };
763
+ DomApi.hasApi = function (node) {
764
+ return Boolean(node.__domApi);
765
+ };
766
+ DomApi.ctor = DomApi;
767
+ Polymer.dom = function (obj, patch) {
768
+ if (obj instanceof Event) {
769
+ return Polymer.EventApi.factory(obj);
770
+ } else {
771
+ return DomApi.factory(obj, patch);
772
+ }
773
+ };
774
+ var p = Element.prototype;
775
+ DomApi.matchesSelector = p.matches || p.matchesSelector || p.mozMatchesSelector || p.msMatchesSelector || p.oMatchesSelector || p.webkitMatchesSelector;
776
+ return DomApi;
777
+ }();(function () {
778
+ 'use strict';
779
+ var Settings = Polymer.Settings;
780
+ var DomApi = Polymer.DomApi;
781
+ var dom = DomApi.factory;
782
+ var TreeApi = Polymer.TreeApi;
783
+ var getInnerHTML = Polymer.domInnerHTML.getInnerHTML;
784
+ var CONTENT = DomApi.CONTENT;
785
+ if (Settings.useShadow) {
786
+ return;
787
+ }
788
+ var nativeCloneNode = Element.prototype.cloneNode;
789
+ var nativeImportNode = Document.prototype.importNode;
790
+ Polymer.Base.mixin(DomApi.prototype, {
791
+ _lazyDistribute: function (host) {
792
+ if (host.shadyRoot && host.shadyRoot._distributionClean) {
793
+ host.shadyRoot._distributionClean = false;
794
+ Polymer.dom.addDebouncer(host.debounce('_distribute', host._distributeContent));
795
+ }
796
+ },
797
+ appendChild: function (node) {
798
+ return this.insertBefore(node);
799
+ },
800
+ insertBefore: function (node, ref_node) {
801
+ if (ref_node && TreeApi.Logical.getParentNode(ref_node) !== this.node) {
802
+ throw Error('The ref_node to be inserted before is not a child ' + 'of this node');
803
+ }
804
+ if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
805
+ var parent = TreeApi.Logical.getParentNode(node);
806
+ if (parent) {
807
+ if (DomApi.hasApi(parent)) {
808
+ dom(parent).notifyObserver();
809
+ }
810
+ this._removeNode(node);
811
+ } else {
812
+ this._removeOwnerShadyRoot(node);
813
+ }
814
+ }
815
+ if (!this._addNode(node, ref_node)) {
816
+ if (ref_node) {
817
+ ref_node = ref_node.localName === CONTENT ? this._firstComposedNode(ref_node) : ref_node;
818
+ }
819
+ var container = this.node._isShadyRoot ? this.node.host : this.node;
820
+ if (ref_node) {
821
+ TreeApi.Composed.insertBefore(container, node, ref_node);
822
+ } else {
823
+ TreeApi.Composed.appendChild(container, node);
824
+ }
825
+ }
826
+ this.notifyObserver();
827
+ return node;
828
+ },
829
+ _addNode: function (node, ref_node) {
830
+ var root = this.getOwnerRoot();
831
+ if (root) {
832
+ var ipAdded = this._maybeAddInsertionPoint(node, this.node);
833
+ if (!root._invalidInsertionPoints) {
834
+ root._invalidInsertionPoints = ipAdded;
835
+ }
836
+ this._addNodeToHost(root.host, node);
837
+ }
838
+ if (TreeApi.Logical.hasChildNodes(this.node)) {
839
+ TreeApi.Logical.recordInsertBefore(node, this.node, ref_node);
840
+ }
841
+ var handled = this._maybeDistribute(node) || this.node.shadyRoot;
842
+ if (handled) {
843
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
844
+ while (node.firstChild) {
845
+ TreeApi.Composed.removeChild(node, node.firstChild);
846
+ }
847
+ } else {
848
+ var parent = TreeApi.Composed.getParentNode(node);
849
+ if (parent) {
850
+ TreeApi.Composed.removeChild(parent, node);
851
+ }
852
+ }
853
+ }
854
+ return handled;
855
+ },
856
+ removeChild: function (node) {
857
+ if (TreeApi.Logical.getParentNode(node) !== this.node) {
858
+ throw Error('The node to be removed is not a child of this node: ' + node);
859
+ }
860
+ if (!this._removeNode(node)) {
861
+ var container = this.node._isShadyRoot ? this.node.host : this.node;
862
+ var parent = TreeApi.Composed.getParentNode(node);
863
+ if (container === parent) {
864
+ TreeApi.Composed.removeChild(container, node);
865
+ }
866
+ }
867
+ this.notifyObserver();
868
+ return node;
869
+ },
870
+ _removeNode: function (node) {
871
+ var logicalParent = TreeApi.Logical.hasParentNode(node) && TreeApi.Logical.getParentNode(node);
872
+ var distributed;
873
+ var root = this._ownerShadyRootForNode(node);
874
+ if (logicalParent) {
875
+ distributed = dom(node)._maybeDistributeParent();
876
+ TreeApi.Logical.recordRemoveChild(node, logicalParent);
877
+ if (root && this._removeDistributedChildren(root, node)) {
878
+ root._invalidInsertionPoints = true;
879
+ this._lazyDistribute(root.host);
880
+ }
881
+ }
882
+ this._removeOwnerShadyRoot(node);
883
+ if (root) {
884
+ this._removeNodeFromHost(root.host, node);
885
+ }
886
+ return distributed;
887
+ },
888
+ replaceChild: function (node, ref_node) {
889
+ this.insertBefore(node, ref_node);
890
+ this.removeChild(ref_node);
891
+ return node;
892
+ },
893
+ _hasCachedOwnerRoot: function (node) {
894
+ return Boolean(node._ownerShadyRoot !== undefined);
895
+ },
896
+ getOwnerRoot: function () {
897
+ return this._ownerShadyRootForNode(this.node);
898
+ },
899
+ _ownerShadyRootForNode: function (node) {
900
+ if (!node) {
901
+ return;
902
+ }
903
+ var root = node._ownerShadyRoot;
904
+ if (root === undefined) {
905
+ if (node._isShadyRoot) {
906
+ root = node;
907
+ } else {
908
+ var parent = TreeApi.Logical.getParentNode(node);
909
+ if (parent) {
910
+ root = parent._isShadyRoot ? parent : this._ownerShadyRootForNode(parent);
911
+ } else {
912
+ root = null;
913
+ }
914
+ }
915
+ if (root || document.documentElement.contains(node)) {
916
+ node._ownerShadyRoot = root;
917
+ }
918
+ }
919
+ return root;
920
+ },
921
+ _maybeDistribute: function (node) {
922
+ var fragContent = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && !node.__noContent && dom(node).querySelector(CONTENT);
923
+ var wrappedContent = fragContent && TreeApi.Logical.getParentNode(fragContent).nodeType !== Node.DOCUMENT_FRAGMENT_NODE;
924
+ var hasContent = fragContent || node.localName === CONTENT;
925
+ if (hasContent) {
926
+ var root = this.getOwnerRoot();
927
+ if (root) {
928
+ this._lazyDistribute(root.host);
929
+ }
930
+ }
931
+ var needsDist = this._nodeNeedsDistribution(this.node);
932
+ if (needsDist) {
933
+ this._lazyDistribute(this.node);
934
+ }
935
+ return needsDist || hasContent && !wrappedContent;
936
+ },
937
+ _maybeAddInsertionPoint: function (node, parent) {
938
+ var added;
939
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && !node.__noContent) {
940
+ var c$ = dom(node).querySelectorAll(CONTENT);
941
+ for (var i = 0, n, np, na; i < c$.length && (n = c$[i]); i++) {
942
+ np = TreeApi.Logical.getParentNode(n);
943
+ if (np === node) {
944
+ np = parent;
945
+ }
946
+ na = this._maybeAddInsertionPoint(n, np);
947
+ added = added || na;
948
+ }
949
+ } else if (node.localName === CONTENT) {
950
+ TreeApi.Logical.saveChildNodes(parent);
951
+ TreeApi.Logical.saveChildNodes(node);
952
+ added = true;
953
+ }
954
+ return added;
955
+ },
956
+ _updateInsertionPoints: function (host) {
957
+ var i$ = host.shadyRoot._insertionPoints = dom(host.shadyRoot).querySelectorAll(CONTENT);
958
+ for (var i = 0, c; i < i$.length; i++) {
959
+ c = i$[i];
960
+ TreeApi.Logical.saveChildNodes(c);
961
+ TreeApi.Logical.saveChildNodes(TreeApi.Logical.getParentNode(c));
962
+ }
963
+ },
964
+ _nodeNeedsDistribution: function (node) {
965
+ return node && node.shadyRoot && DomApi.hasInsertionPoint(node.shadyRoot);
966
+ },
967
+ _addNodeToHost: function (host, node) {
968
+ if (host._elementAdd) {
969
+ host._elementAdd(node);
970
+ }
971
+ },
972
+ _removeNodeFromHost: function (host, node) {
973
+ if (host._elementRemove) {
974
+ host._elementRemove(node);
975
+ }
976
+ },
977
+ _removeDistributedChildren: function (root, container) {
978
+ var hostNeedsDist;
979
+ var ip$ = root._insertionPoints;
980
+ for (var i = 0; i < ip$.length; i++) {
981
+ var content = ip$[i];
982
+ if (this._contains(container, content)) {
983
+ var dc$ = dom(content).getDistributedNodes();
984
+ for (var j = 0; j < dc$.length; j++) {
985
+ hostNeedsDist = true;
986
+ var node = dc$[j];
987
+ var parent = TreeApi.Composed.getParentNode(node);
988
+ if (parent) {
989
+ TreeApi.Composed.removeChild(parent, node);
990
+ }
991
+ }
992
+ }
993
+ }
994
+ return hostNeedsDist;
995
+ },
996
+ _contains: function (container, node) {
997
+ while (node) {
998
+ if (node == container) {
999
+ return true;
1000
+ }
1001
+ node = TreeApi.Logical.getParentNode(node);
1002
+ }
1003
+ },
1004
+ _removeOwnerShadyRoot: function (node) {
1005
+ if (this._hasCachedOwnerRoot(node)) {
1006
+ var c$ = TreeApi.Logical.getChildNodes(node);
1007
+ for (var i = 0, l = c$.length, n; i < l && (n = c$[i]); i++) {
1008
+ this._removeOwnerShadyRoot(n);
1009
+ }
1010
+ }
1011
+ node._ownerShadyRoot = undefined;
1012
+ },
1013
+ _firstComposedNode: function (content) {
1014
+ var n$ = dom(content).getDistributedNodes();
1015
+ for (var i = 0, l = n$.length, n, p$; i < l && (n = n$[i]); i++) {
1016
+ p$ = dom(n).getDestinationInsertionPoints();
1017
+ if (p$[p$.length - 1] === content) {
1018
+ return n;
1019
+ }
1020
+ }
1021
+ },
1022
+ querySelector: function (selector) {
1023
+ var result = this._query(function (n) {
1024
+ return DomApi.matchesSelector.call(n, selector);
1025
+ }, this.node, function (n) {
1026
+ return Boolean(n);
1027
+ })[0];
1028
+ return result || null;
1029
+ },
1030
+ querySelectorAll: function (selector) {
1031
+ return this._query(function (n) {
1032
+ return DomApi.matchesSelector.call(n, selector);
1033
+ }, this.node);
1034
+ },
1035
+ getDestinationInsertionPoints: function () {
1036
+ return this.node._destinationInsertionPoints || [];
1037
+ },
1038
+ getDistributedNodes: function () {
1039
+ return this.node._distributedNodes || [];
1040
+ },
1041
+ _clear: function () {
1042
+ while (this.childNodes.length) {
1043
+ this.removeChild(this.childNodes[0]);
1044
+ }
1045
+ },
1046
+ setAttribute: function (name, value) {
1047
+ this.node.setAttribute(name, value);
1048
+ this._maybeDistributeForAttributeChange(this.node, name);
1049
+ },
1050
+ removeAttribute: function (name) {
1051
+ this.node.removeAttribute(name);
1052
+ this._maybeDistributeForAttributeChange(this.node, name);
1053
+ },
1054
+ _maybeDistributeForAttributeChange: function (element, name) {
1055
+ if (name === 'select' && element.localName === 'content') {
1056
+ var ownerRoot = this.getOwnerRoot();
1057
+ if (ownerRoot && this._nodeNeedsDistribution(ownerRoot.host)) {
1058
+ this._lazyDistribute(ownerRoot.host);
1059
+ return;
1060
+ }
1061
+ }
1062
+ this._maybeDistributeParent();
1063
+ },
1064
+ _maybeDistributeParent: function () {
1065
+ if (this._nodeNeedsDistribution(this.parentNode)) {
1066
+ this._lazyDistribute(this.parentNode);
1067
+ return true;
1068
+ }
1069
+ },
1070
+ cloneNode: function (deep) {
1071
+ var n = nativeCloneNode.call(this.node, false);
1072
+ if (deep) {
1073
+ var c$ = this.childNodes;
1074
+ var d = dom(n);
1075
+ for (var i = 0, nc; i < c$.length; i++) {
1076
+ nc = dom(c$[i]).cloneNode(true);
1077
+ d.appendChild(nc);
1078
+ }
1079
+ }
1080
+ return n;
1081
+ },
1082
+ importNode: function (externalNode, deep) {
1083
+ var doc = this.node instanceof Document ? this.node : this.node.ownerDocument;
1084
+ var n = nativeImportNode.call(doc, externalNode, false);
1085
+ if (deep) {
1086
+ var c$ = TreeApi.Logical.getChildNodes(externalNode);
1087
+ var d = dom(n);
1088
+ for (var i = 0, nc; i < c$.length; i++) {
1089
+ nc = dom(doc).importNode(c$[i], true);
1090
+ d.appendChild(nc);
1091
+ }
1092
+ }
1093
+ return n;
1094
+ },
1095
+ _getComposedInnerHTML: function () {
1096
+ return getInnerHTML(this.node, true);
1097
+ }
1098
+ });
1099
+ Object.defineProperties(DomApi.prototype, {
1100
+ activeElement: {
1101
+ get: function () {
1102
+ var active = document.activeElement;
1103
+ if (!active) {
1104
+ return null;
1105
+ }
1106
+ var isShadyRoot = !!this.node._isShadyRoot;
1107
+ if (this.node !== document) {
1108
+ if (!isShadyRoot) {
1109
+ return null;
1110
+ }
1111
+ if (this.node.host === active || !this.node.host.contains(active)) {
1112
+ return null;
1113
+ }
1114
+ }
1115
+ var activeRoot = dom(active).getOwnerRoot();
1116
+ while (activeRoot && activeRoot !== this.node) {
1117
+ active = activeRoot.host;
1118
+ activeRoot = dom(active).getOwnerRoot();
1119
+ }
1120
+ if (this.node === document) {
1121
+ return activeRoot ? null : active;
1122
+ } else {
1123
+ return activeRoot === this.node ? active : null;
1124
+ }
1125
+ },
1126
+ configurable: true
1127
+ },
1128
+ childNodes: {
1129
+ get: function () {
1130
+ var c$ = TreeApi.Logical.getChildNodes(this.node);
1131
+ return Array.isArray(c$) ? c$ : TreeApi.arrayCopyChildNodes(this.node);
1132
+ },
1133
+ configurable: true
1134
+ },
1135
+ children: {
1136
+ get: function () {
1137
+ if (TreeApi.Logical.hasChildNodes(this.node)) {
1138
+ return Array.prototype.filter.call(this.childNodes, function (n) {
1139
+ return n.nodeType === Node.ELEMENT_NODE;
1140
+ });
1141
+ } else {
1142
+ return TreeApi.arrayCopyChildren(this.node);
1143
+ }
1144
+ },
1145
+ configurable: true
1146
+ },
1147
+ parentNode: {
1148
+ get: function () {
1149
+ return TreeApi.Logical.getParentNode(this.node);
1150
+ },
1151
+ configurable: true
1152
+ },
1153
+ firstChild: {
1154
+ get: function () {
1155
+ return TreeApi.Logical.getFirstChild(this.node);
1156
+ },
1157
+ configurable: true
1158
+ },
1159
+ lastChild: {
1160
+ get: function () {
1161
+ return TreeApi.Logical.getLastChild(this.node);
1162
+ },
1163
+ configurable: true
1164
+ },
1165
+ nextSibling: {
1166
+ get: function () {
1167
+ return TreeApi.Logical.getNextSibling(this.node);
1168
+ },
1169
+ configurable: true
1170
+ },
1171
+ previousSibling: {
1172
+ get: function () {
1173
+ return TreeApi.Logical.getPreviousSibling(this.node);
1174
+ },
1175
+ configurable: true
1176
+ },
1177
+ firstElementChild: {
1178
+ get: function () {
1179
+ return TreeApi.Logical.getFirstElementChild(this.node);
1180
+ },
1181
+ configurable: true
1182
+ },
1183
+ lastElementChild: {
1184
+ get: function () {
1185
+ return TreeApi.Logical.getLastElementChild(this.node);
1186
+ },
1187
+ configurable: true
1188
+ },
1189
+ nextElementSibling: {
1190
+ get: function () {
1191
+ return TreeApi.Logical.getNextElementSibling(this.node);
1192
+ },
1193
+ configurable: true
1194
+ },
1195
+ previousElementSibling: {
1196
+ get: function () {
1197
+ return TreeApi.Logical.getPreviousElementSibling(this.node);
1198
+ },
1199
+ configurable: true
1200
+ },
1201
+ textContent: {
1202
+ get: function () {
1203
+ var nt = this.node.nodeType;
1204
+ if (nt === Node.TEXT_NODE || nt === Node.COMMENT_NODE) {
1205
+ return this.node.textContent;
1206
+ } else {
1207
+ var tc = [];
1208
+ for (var i = 0, cn = this.childNodes, c; c = cn[i]; i++) {
1209
+ if (c.nodeType !== Node.COMMENT_NODE) {
1210
+ tc.push(c.textContent);
1211
+ }
1212
+ }
1213
+ return tc.join('');
1214
+ }
1215
+ },
1216
+ set: function (text) {
1217
+ var nt = this.node.nodeType;
1218
+ if (nt === Node.TEXT_NODE || nt === Node.COMMENT_NODE) {
1219
+ this.node.textContent = text;
1220
+ } else {
1221
+ this._clear();
1222
+ if (text) {
1223
+ this.appendChild(document.createTextNode(text));
1224
+ }
1225
+ }
1226
+ },
1227
+ configurable: true
1228
+ },
1229
+ innerHTML: {
1230
+ get: function () {
1231
+ var nt = this.node.nodeType;
1232
+ if (nt === Node.TEXT_NODE || nt === Node.COMMENT_NODE) {
1233
+ return null;
1234
+ } else {
1235
+ return getInnerHTML(this.node);
1236
+ }
1237
+ },
1238
+ set: function (text) {
1239
+ var nt = this.node.nodeType;
1240
+ if (nt !== Node.TEXT_NODE || nt !== Node.COMMENT_NODE) {
1241
+ this._clear();
1242
+ var d = document.createElement('div');
1243
+ d.innerHTML = text;
1244
+ var c$ = TreeApi.arrayCopyChildNodes(d);
1245
+ for (var i = 0; i < c$.length; i++) {
1246
+ this.appendChild(c$[i]);
1247
+ }
1248
+ }
1249
+ },
1250
+ configurable: true
1251
+ }
1252
+ });
1253
+ DomApi.hasInsertionPoint = function (root) {
1254
+ return Boolean(root && root._insertionPoints.length);
1255
+ };
1256
+ }());(function () {
1257
+ 'use strict';
1258
+ var Settings = Polymer.Settings;
1259
+ var TreeApi = Polymer.TreeApi;
1260
+ var DomApi = Polymer.DomApi;
1261
+ if (!Settings.useShadow) {
1262
+ return;
1263
+ }
1264
+ Polymer.Base.mixin(DomApi.prototype, {
1265
+ querySelectorAll: function (selector) {
1266
+ return TreeApi.arrayCopy(this.node.querySelectorAll(selector));
1267
+ },
1268
+ getOwnerRoot: function () {
1269
+ var n = this.node;
1270
+ while (n) {
1271
+ if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE && n.host) {
1272
+ return n;
1273
+ }
1274
+ n = n.parentNode;
1275
+ }
1276
+ },
1277
+ importNode: function (externalNode, deep) {
1278
+ var doc = this.node instanceof Document ? this.node : this.node.ownerDocument;
1279
+ return doc.importNode(externalNode, deep);
1280
+ },
1281
+ getDestinationInsertionPoints: function () {
1282
+ var n$ = this.node.getDestinationInsertionPoints && this.node.getDestinationInsertionPoints();
1283
+ return n$ ? TreeApi.arrayCopy(n$) : [];
1284
+ },
1285
+ getDistributedNodes: function () {
1286
+ var n$ = this.node.getDistributedNodes && this.node.getDistributedNodes();
1287
+ return n$ ? TreeApi.arrayCopy(n$) : [];
1288
+ }
1289
+ });
1290
+ Object.defineProperties(DomApi.prototype, {
1291
+ activeElement: {
1292
+ get: function () {
1293
+ var node = DomApi.wrap(this.node);
1294
+ var activeElement = node.activeElement;
1295
+ return node.contains(activeElement) ? activeElement : null;
1296
+ },
1297
+ configurable: true
1298
+ },
1299
+ childNodes: {
1300
+ get: function () {
1301
+ return TreeApi.arrayCopyChildNodes(this.node);
1302
+ },
1303
+ configurable: true
1304
+ },
1305
+ children: {
1306
+ get: function () {
1307
+ return TreeApi.arrayCopyChildren(this.node);
1308
+ },
1309
+ configurable: true
1310
+ },
1311
+ textContent: {
1312
+ get: function () {
1313
+ return this.node.textContent;
1314
+ },
1315
+ set: function (value) {
1316
+ return this.node.textContent = value;
1317
+ },
1318
+ configurable: true
1319
+ },
1320
+ innerHTML: {
1321
+ get: function () {
1322
+ return this.node.innerHTML;
1323
+ },
1324
+ set: function (value) {
1325
+ return this.node.innerHTML = value;
1326
+ },
1327
+ configurable: true
1328
+ }
1329
+ });
1330
+ var forwardMethods = function (m$) {
1331
+ for (var i = 0; i < m$.length; i++) {
1332
+ forwardMethod(m$[i]);
1333
+ }
1334
+ };
1335
+ var forwardMethod = function (method) {
1336
+ DomApi.prototype[method] = function () {
1337
+ return this.node[method].apply(this.node, arguments);
1338
+ };
1339
+ };
1340
+ forwardMethods([
1341
+ 'cloneNode',
1342
+ 'appendChild',
1343
+ 'insertBefore',
1344
+ 'removeChild',
1345
+ 'replaceChild',
1346
+ 'setAttribute',
1347
+ 'removeAttribute',
1348
+ 'querySelector'
1349
+ ]);
1350
+ var forwardProperties = function (f$) {
1351
+ for (var i = 0; i < f$.length; i++) {
1352
+ forwardProperty(f$[i]);
1353
+ }
1354
+ };
1355
+ var forwardProperty = function (name) {
1356
+ Object.defineProperty(DomApi.prototype, name, {
1357
+ get: function () {
1358
+ return this.node[name];
1359
+ },
1360
+ configurable: true
1361
+ });
1362
+ };
1363
+ forwardProperties([
1364
+ 'parentNode',
1365
+ 'firstChild',
1366
+ 'lastChild',
1367
+ 'nextSibling',
1368
+ 'previousSibling',
1369
+ 'firstElementChild',
1370
+ 'lastElementChild',
1371
+ 'nextElementSibling',
1372
+ 'previousElementSibling'
1373
+ ]);
1374
+ }());Polymer.Base.mixin(Polymer.dom, {
1375
+ _flushGuard: 0,
1376
+ _FLUSH_MAX: 100,
1377
+ _needsTakeRecords: !Polymer.Settings.useNativeCustomElements,
1378
+ _debouncers: [],
1379
+ _staticFlushList: [],
1380
+ _finishDebouncer: null,
1381
+ flush: function () {
1382
+ this._flushGuard = 0;
1383
+ this._prepareFlush();
1384
+ while (this._debouncers.length && this._flushGuard < this._FLUSH_MAX) {
1385
+ while (this._debouncers.length) {
1386
+ this._debouncers.shift().complete();
1387
+ }
1388
+ if (this._finishDebouncer) {
1389
+ this._finishDebouncer.complete();
1390
+ }
1391
+ this._prepareFlush();
1392
+ this._flushGuard++;
1393
+ }
1394
+ if (this._flushGuard >= this._FLUSH_MAX) {
1395
+ console.warn('Polymer.dom.flush aborted. Flush may not be complete.');
1396
+ }
1397
+ },
1398
+ _prepareFlush: function () {
1399
+ if (this._needsTakeRecords) {
1400
+ CustomElements.takeRecords();
1401
+ }
1402
+ for (var i = 0; i < this._staticFlushList.length; i++) {
1403
+ this._staticFlushList[i]();
1404
+ }
1405
+ },
1406
+ addStaticFlush: function (fn) {
1407
+ this._staticFlushList.push(fn);
1408
+ },
1409
+ removeStaticFlush: function (fn) {
1410
+ var i = this._staticFlushList.indexOf(fn);
1411
+ if (i >= 0) {
1412
+ this._staticFlushList.splice(i, 1);
1413
+ }
1414
+ },
1415
+ addDebouncer: function (debouncer) {
1416
+ this._debouncers.push(debouncer);
1417
+ this._finishDebouncer = Polymer.Debounce(this._finishDebouncer, this._finishFlush);
1418
+ },
1419
+ _finishFlush: function () {
1420
+ Polymer.dom._debouncers = [];
1421
+ }
1422
+ });Polymer.EventApi = function () {
1423
+ 'use strict';
1424
+ var DomApi = Polymer.DomApi.ctor;
1425
+ var Settings = Polymer.Settings;
1426
+ DomApi.Event = function (event) {
1427
+ this.event = event;
1428
+ };
1429
+ if (Settings.useShadow) {
1430
+ DomApi.Event.prototype = {
1431
+ get rootTarget() {
1432
+ return this.event.path[0];
1433
+ },
1434
+ get localTarget() {
1435
+ return this.event.target;
1436
+ },
1437
+ get path() {
1438
+ var path = this.event.path;
1439
+ if (!Array.isArray(path)) {
1440
+ path = Array.prototype.slice.call(path);
1441
+ }
1442
+ return path;
1443
+ }
1444
+ };
1445
+ } else {
1446
+ DomApi.Event.prototype = {
1447
+ get rootTarget() {
1448
+ return this.event.target;
1449
+ },
1450
+ get localTarget() {
1451
+ var current = this.event.currentTarget;
1452
+ var currentRoot = current && Polymer.dom(current).getOwnerRoot();
1453
+ var p$ = this.path;
1454
+ for (var i = 0; i < p$.length; i++) {
1455
+ if (Polymer.dom(p$[i]).getOwnerRoot() === currentRoot) {
1456
+ return p$[i];
1457
+ }
1458
+ }
1459
+ },
1460
+ get path() {
1461
+ if (!this.event._path) {
1462
+ var path = [];
1463
+ var current = this.rootTarget;
1464
+ while (current) {
1465
+ path.push(current);
1466
+ var insertionPoints = Polymer.dom(current).getDestinationInsertionPoints();
1467
+ if (insertionPoints.length) {
1468
+ for (var i = 0; i < insertionPoints.length - 1; i++) {
1469
+ path.push(insertionPoints[i]);
1470
+ }
1471
+ current = insertionPoints[insertionPoints.length - 1];
1472
+ } else {
1473
+ current = Polymer.dom(current).parentNode || current.host;
1474
+ }
1475
+ }
1476
+ path.push(window);
1477
+ this.event._path = path;
1478
+ }
1479
+ return this.event._path;
1480
+ }
1481
+ };
1482
+ }
1483
+ var factory = function (event) {
1484
+ if (!event.__eventApi) {
1485
+ event.__eventApi = new DomApi.Event(event);
1486
+ }
1487
+ return event.__eventApi;
1488
+ };
1489
+ return { factory: factory };
1490
+ }();(function () {
1491
+ 'use strict';
1492
+ var DomApi = Polymer.DomApi.ctor;
1493
+ var useShadow = Polymer.Settings.useShadow;
1494
+ Object.defineProperty(DomApi.prototype, 'classList', {
1495
+ get: function () {
1496
+ if (!this._classList) {
1497
+ this._classList = new DomApi.ClassList(this);
1498
+ }
1499
+ return this._classList;
1500
+ },
1501
+ configurable: true
1502
+ });
1503
+ DomApi.ClassList = function (host) {
1504
+ this.domApi = host;
1505
+ this.node = host.node;
1506
+ };
1507
+ DomApi.ClassList.prototype = {
1508
+ add: function () {
1509
+ this.node.classList.add.apply(this.node.classList, arguments);
1510
+ this._distributeParent();
1511
+ },
1512
+ remove: function () {
1513
+ this.node.classList.remove.apply(this.node.classList, arguments);
1514
+ this._distributeParent();
1515
+ },
1516
+ toggle: function () {
1517
+ this.node.classList.toggle.apply(this.node.classList, arguments);
1518
+ this._distributeParent();
1519
+ },
1520
+ _distributeParent: function () {
1521
+ if (!useShadow) {
1522
+ this.domApi._maybeDistributeParent();
1523
+ }
1524
+ },
1525
+ contains: function () {
1526
+ return this.node.classList.contains.apply(this.node.classList, arguments);
1527
+ }
1528
+ };
1529
+ }());(function () {
1530
+ 'use strict';
1531
+ var DomApi = Polymer.DomApi.ctor;
1532
+ var Settings = Polymer.Settings;
1533
+ DomApi.EffectiveNodesObserver = function (domApi) {
1534
+ this.domApi = domApi;
1535
+ this.node = this.domApi.node;
1536
+ this._listeners = [];
1537
+ };
1538
+ DomApi.EffectiveNodesObserver.prototype = {
1539
+ addListener: function (callback) {
1540
+ if (!this._isSetup) {
1541
+ this._setup();
1542
+ this._isSetup = true;
1543
+ }
1544
+ var listener = {
1545
+ fn: callback,
1546
+ _nodes: []
1547
+ };
1548
+ this._listeners.push(listener);
1549
+ this._scheduleNotify();
1550
+ return listener;
1551
+ },
1552
+ removeListener: function (handle) {
1553
+ var i = this._listeners.indexOf(handle);
1554
+ if (i >= 0) {
1555
+ this._listeners.splice(i, 1);
1556
+ handle._nodes = [];
1557
+ }
1558
+ if (!this._hasListeners()) {
1559
+ this._cleanup();
1560
+ this._isSetup = false;
1561
+ }
1562
+ },
1563
+ _setup: function () {
1564
+ this._observeContentElements(this.domApi.childNodes);
1565
+ },
1566
+ _cleanup: function () {
1567
+ this._unobserveContentElements(this.domApi.childNodes);
1568
+ },
1569
+ _hasListeners: function () {
1570
+ return Boolean(this._listeners.length);
1571
+ },
1572
+ _scheduleNotify: function () {
1573
+ if (this._debouncer) {
1574
+ this._debouncer.stop();
1575
+ }
1576
+ this._debouncer = Polymer.Debounce(this._debouncer, this._notify);
1577
+ this._debouncer.context = this;
1578
+ Polymer.dom.addDebouncer(this._debouncer);
1579
+ },
1580
+ notify: function () {
1581
+ if (this._hasListeners()) {
1582
+ this._scheduleNotify();
1583
+ }
1584
+ },
1585
+ _notify: function () {
1586
+ this._beforeCallListeners();
1587
+ this._callListeners();
1588
+ },
1589
+ _beforeCallListeners: function () {
1590
+ this._updateContentElements();
1591
+ },
1592
+ _updateContentElements: function () {
1593
+ this._observeContentElements(this.domApi.childNodes);
1594
+ },
1595
+ _observeContentElements: function (elements) {
1596
+ for (var i = 0, n; i < elements.length && (n = elements[i]); i++) {
1597
+ if (this._isContent(n)) {
1598
+ n.__observeNodesMap = n.__observeNodesMap || new WeakMap();
1599
+ if (!n.__observeNodesMap.has(this)) {
1600
+ n.__observeNodesMap.set(this, this._observeContent(n));
1601
+ }
1602
+ }
1603
+ }
1604
+ },
1605
+ _observeContent: function (content) {
1606
+ var self = this;
1607
+ var h = Polymer.dom(content).observeNodes(function () {
1608
+ self._scheduleNotify();
1609
+ });
1610
+ h._avoidChangeCalculation = true;
1611
+ return h;
1612
+ },
1613
+ _unobserveContentElements: function (elements) {
1614
+ for (var i = 0, n, h; i < elements.length && (n = elements[i]); i++) {
1615
+ if (this._isContent(n)) {
1616
+ h = n.__observeNodesMap && n.__observeNodesMap.get(this);
1617
+ if (h) {
1618
+ Polymer.dom(n).unobserveNodes(h);
1619
+ n.__observeNodesMap.delete(this);
1620
+ }
1621
+ }
1622
+ }
1623
+ },
1624
+ _isContent: function (node) {
1625
+ return node.localName === 'content';
1626
+ },
1627
+ _callListeners: function () {
1628
+ var o$ = this._listeners;
1629
+ var nodes = this._getEffectiveNodes();
1630
+ for (var i = 0, o; i < o$.length && (o = o$[i]); i++) {
1631
+ var info = this._generateListenerInfo(o, nodes);
1632
+ if (info || o._alwaysNotify) {
1633
+ this._callListener(o, info);
1634
+ }
1635
+ }
1636
+ },
1637
+ _getEffectiveNodes: function () {
1638
+ return this.domApi.getEffectiveChildNodes();
1639
+ },
1640
+ _generateListenerInfo: function (listener, newNodes) {
1641
+ if (listener._avoidChangeCalculation) {
1642
+ return true;
1643
+ }
1644
+ var oldNodes = listener._nodes;
1645
+ var info = {
1646
+ target: this.node,
1647
+ addedNodes: [],
1648
+ removedNodes: []
1649
+ };
1650
+ var splices = Polymer.ArraySplice.calculateSplices(newNodes, oldNodes);
1651
+ for (var i = 0, s; i < splices.length && (s = splices[i]); i++) {
1652
+ for (var j = 0, n; j < s.removed.length && (n = s.removed[j]); j++) {
1653
+ info.removedNodes.push(n);
1654
+ }
1655
+ }
1656
+ for (i = 0, s; i < splices.length && (s = splices[i]); i++) {
1657
+ for (j = s.index; j < s.index + s.addedCount; j++) {
1658
+ info.addedNodes.push(newNodes[j]);
1659
+ }
1660
+ }
1661
+ listener._nodes = newNodes;
1662
+ if (info.addedNodes.length || info.removedNodes.length) {
1663
+ return info;
1664
+ }
1665
+ },
1666
+ _callListener: function (listener, info) {
1667
+ return listener.fn.call(this.node, info);
1668
+ },
1669
+ enableShadowAttributeTracking: function () {
1670
+ }
1671
+ };
1672
+ if (Settings.useShadow) {
1673
+ var baseSetup = DomApi.EffectiveNodesObserver.prototype._setup;
1674
+ var baseCleanup = DomApi.EffectiveNodesObserver.prototype._cleanup;
1675
+ Polymer.Base.mixin(DomApi.EffectiveNodesObserver.prototype, {
1676
+ _setup: function () {
1677
+ if (!this._observer) {
1678
+ var self = this;
1679
+ this._mutationHandler = function (mxns) {
1680
+ if (mxns && mxns.length) {
1681
+ self._scheduleNotify();
1682
+ }
1683
+ };
1684
+ this._observer = new MutationObserver(this._mutationHandler);
1685
+ this._boundFlush = function () {
1686
+ self._flush();
1687
+ };
1688
+ Polymer.dom.addStaticFlush(this._boundFlush);
1689
+ this._observer.observe(this.node, { childList: true });
1690
+ }
1691
+ baseSetup.call(this);
1692
+ },
1693
+ _cleanup: function () {
1694
+ this._observer.disconnect();
1695
+ this._observer = null;
1696
+ this._mutationHandler = null;
1697
+ Polymer.dom.removeStaticFlush(this._boundFlush);
1698
+ baseCleanup.call(this);
1699
+ },
1700
+ _flush: function () {
1701
+ if (this._observer) {
1702
+ this._mutationHandler(this._observer.takeRecords());
1703
+ }
1704
+ },
1705
+ enableShadowAttributeTracking: function () {
1706
+ if (this._observer) {
1707
+ this._makeContentListenersAlwaysNotify();
1708
+ this._observer.disconnect();
1709
+ this._observer.observe(this.node, {
1710
+ childList: true,
1711
+ attributes: true,
1712
+ subtree: true
1713
+ });
1714
+ var root = this.domApi.getOwnerRoot();
1715
+ var host = root && root.host;
1716
+ if (host && Polymer.dom(host).observer) {
1717
+ Polymer.dom(host).observer.enableShadowAttributeTracking();
1718
+ }
1719
+ }
1720
+ },
1721
+ _makeContentListenersAlwaysNotify: function () {
1722
+ for (var i = 0, h; i < this._listeners.length; i++) {
1723
+ h = this._listeners[i];
1724
+ h._alwaysNotify = h._isContentListener;
1725
+ }
1726
+ }
1727
+ });
1728
+ }
1729
+ }());(function () {
1730
+ 'use strict';
1731
+ var DomApi = Polymer.DomApi.ctor;
1732
+ var Settings = Polymer.Settings;
1733
+ DomApi.DistributedNodesObserver = function (domApi) {
1734
+ DomApi.EffectiveNodesObserver.call(this, domApi);
1735
+ };
1736
+ DomApi.DistributedNodesObserver.prototype = Object.create(DomApi.EffectiveNodesObserver.prototype);
1737
+ Polymer.Base.mixin(DomApi.DistributedNodesObserver.prototype, {
1738
+ _setup: function () {
1739
+ },
1740
+ _cleanup: function () {
1741
+ },
1742
+ _beforeCallListeners: function () {
1743
+ },
1744
+ _getEffectiveNodes: function () {
1745
+ return this.domApi.getDistributedNodes();
1746
+ }
1747
+ });
1748
+ if (Settings.useShadow) {
1749
+ Polymer.Base.mixin(DomApi.DistributedNodesObserver.prototype, {
1750
+ _setup: function () {
1751
+ if (!this._observer) {
1752
+ var root = this.domApi.getOwnerRoot();
1753
+ var host = root && root.host;
1754
+ if (host) {
1755
+ var self = this;
1756
+ this._observer = Polymer.dom(host).observeNodes(function () {
1757
+ self._scheduleNotify();
1758
+ });
1759
+ this._observer._isContentListener = true;
1760
+ if (this._hasAttrSelect()) {
1761
+ Polymer.dom(host).observer.enableShadowAttributeTracking();
1762
+ }
1763
+ }
1764
+ }
1765
+ },
1766
+ _hasAttrSelect: function () {
1767
+ var select = this.node.getAttribute('select');
1768
+ return select && select.match(/[[.]+/);
1769
+ },
1770
+ _cleanup: function () {
1771
+ var root = this.domApi.getOwnerRoot();
1772
+ var host = root && root.host;
1773
+ if (host) {
1774
+ Polymer.dom(host).unobserveNodes(this._observer);
1775
+ }
1776
+ this._observer = null;
1777
+ }
1778
+ });
1779
+ }
1780
+ }());(function () {
1781
+ var DomApi = Polymer.DomApi;
1782
+ var TreeApi = Polymer.TreeApi;
1783
+ Polymer.Base._addFeature({
1784
+ _prepShady: function () {
1785
+ this._useContent = this._useContent || Boolean(this._template);
1786
+ },
1787
+ _setupShady: function () {
1788
+ this.shadyRoot = null;
1789
+ if (!this.__domApi) {
1790
+ this.__domApi = null;
1791
+ }
1792
+ if (!this.__dom) {
1793
+ this.__dom = null;
1794
+ }
1795
+ if (!this._ownerShadyRoot) {
1796
+ this._ownerShadyRoot = undefined;
1797
+ }
1798
+ },
1799
+ _poolContent: function () {
1800
+ if (this._useContent) {
1801
+ TreeApi.Logical.saveChildNodes(this);
1802
+ }
1803
+ },
1804
+ _setupRoot: function () {
1805
+ if (this._useContent) {
1806
+ this._createLocalRoot();
1807
+ if (!this.dataHost) {
1808
+ upgradeLogicalChildren(TreeApi.Logical.getChildNodes(this));
1809
+ }
1810
+ }
1811
+ },
1812
+ _createLocalRoot: function () {
1813
+ this.shadyRoot = this.root;
1814
+ this.shadyRoot._distributionClean = false;
1815
+ this.shadyRoot._hasDistributed = false;
1816
+ this.shadyRoot._isShadyRoot = true;
1817
+ this.shadyRoot._dirtyRoots = [];
1818
+ var i$ = this.shadyRoot._insertionPoints = !this._notes || this._notes._hasContent ? this.shadyRoot.querySelectorAll('content') : [];
1819
+ TreeApi.Logical.saveChildNodes(this.shadyRoot);
1820
+ for (var i = 0, c; i < i$.length; i++) {
1821
+ c = i$[i];
1822
+ TreeApi.Logical.saveChildNodes(c);
1823
+ TreeApi.Logical.saveChildNodes(c.parentNode);
1824
+ }
1825
+ this.shadyRoot.host = this;
1826
+ },
1827
+ distributeContent: function (updateInsertionPoints) {
1828
+ if (this.shadyRoot) {
1829
+ this.shadyRoot._invalidInsertionPoints = this.shadyRoot._invalidInsertionPoints || updateInsertionPoints;
1830
+ var host = getTopDistributingHost(this);
1831
+ Polymer.dom(this)._lazyDistribute(host);
1832
+ }
1833
+ },
1834
+ _distributeContent: function () {
1835
+ if (this._useContent && !this.shadyRoot._distributionClean) {
1836
+ if (this.shadyRoot._invalidInsertionPoints) {
1837
+ Polymer.dom(this)._updateInsertionPoints(this);
1838
+ this.shadyRoot._invalidInsertionPoints = false;
1839
+ }
1840
+ this._beginDistribute();
1841
+ this._distributeDirtyRoots();
1842
+ this._finishDistribute();
1843
+ }
1844
+ },
1845
+ _beginDistribute: function () {
1846
+ if (this._useContent && DomApi.hasInsertionPoint(this.shadyRoot)) {
1847
+ this._resetDistribution();
1848
+ this._distributePool(this.shadyRoot, this._collectPool());
1849
+ }
1850
+ },
1851
+ _distributeDirtyRoots: function () {
1852
+ var c$ = this.shadyRoot._dirtyRoots;
1853
+ for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
1854
+ c._distributeContent();
1855
+ }
1856
+ this.shadyRoot._dirtyRoots = [];
1857
+ },
1858
+ _finishDistribute: function () {
1859
+ if (this._useContent) {
1860
+ this.shadyRoot._distributionClean = true;
1861
+ if (DomApi.hasInsertionPoint(this.shadyRoot)) {
1862
+ this._composeTree();
1863
+ notifyContentObservers(this.shadyRoot);
1864
+ } else {
1865
+ if (!this.shadyRoot._hasDistributed) {
1866
+ TreeApi.Composed.clearChildNodes(this);
1867
+ this.appendChild(this.shadyRoot);
1868
+ } else {
1869
+ var children = this._composeNode(this);
1870
+ this._updateChildNodes(this, children);
1871
+ }
1872
+ }
1873
+ if (!this.shadyRoot._hasDistributed) {
1874
+ notifyInitialDistribution(this);
1875
+ }
1876
+ this.shadyRoot._hasDistributed = true;
1877
+ }
1878
+ },
1879
+ elementMatches: function (selector, node) {
1880
+ node = node || this;
1881
+ return DomApi.matchesSelector.call(node, selector);
1882
+ },
1883
+ _resetDistribution: function () {
1884
+ var children = TreeApi.Logical.getChildNodes(this);
1885
+ for (var i = 0; i < children.length; i++) {
1886
+ var child = children[i];
1887
+ if (child._destinationInsertionPoints) {
1888
+ child._destinationInsertionPoints = undefined;
1889
+ }
1890
+ if (isInsertionPoint(child)) {
1891
+ clearDistributedDestinationInsertionPoints(child);
1892
+ }
1893
+ }
1894
+ var root = this.shadyRoot;
1895
+ var p$ = root._insertionPoints;
1896
+ for (var j = 0; j < p$.length; j++) {
1897
+ p$[j]._distributedNodes = [];
1898
+ }
1899
+ },
1900
+ _collectPool: function () {
1901
+ var pool = [];
1902
+ var children = TreeApi.Logical.getChildNodes(this);
1903
+ for (var i = 0; i < children.length; i++) {
1904
+ var child = children[i];
1905
+ if (isInsertionPoint(child)) {
1906
+ pool.push.apply(pool, child._distributedNodes);
1907
+ } else {
1908
+ pool.push(child);
1909
+ }
1910
+ }
1911
+ return pool;
1912
+ },
1913
+ _distributePool: function (node, pool) {
1914
+ var p$ = node._insertionPoints;
1915
+ for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
1916
+ this._distributeInsertionPoint(p, pool);
1917
+ maybeRedistributeParent(p, this);
1918
+ }
1919
+ },
1920
+ _distributeInsertionPoint: function (content, pool) {
1921
+ var anyDistributed = false;
1922
+ for (var i = 0, l = pool.length, node; i < l; i++) {
1923
+ node = pool[i];
1924
+ if (!node) {
1925
+ continue;
1926
+ }
1927
+ if (this._matchesContentSelect(node, content)) {
1928
+ distributeNodeInto(node, content);
1929
+ pool[i] = undefined;
1930
+ anyDistributed = true;
1931
+ }
1932
+ }
1933
+ if (!anyDistributed) {
1934
+ var children = TreeApi.Logical.getChildNodes(content);
1935
+ for (var j = 0; j < children.length; j++) {
1936
+ distributeNodeInto(children[j], content);
1937
+ }
1938
+ }
1939
+ },
1940
+ _composeTree: function () {
1941
+ this._updateChildNodes(this, this._composeNode(this));
1942
+ var p$ = this.shadyRoot._insertionPoints;
1943
+ for (var i = 0, l = p$.length, p, parent; i < l && (p = p$[i]); i++) {
1944
+ parent = TreeApi.Logical.getParentNode(p);
1945
+ if (!parent._useContent && parent !== this && parent !== this.shadyRoot) {
1946
+ this._updateChildNodes(parent, this._composeNode(parent));
1947
+ }
1948
+ }
1949
+ },
1950
+ _composeNode: function (node) {
1951
+ var children = [];
1952
+ var c$ = TreeApi.Logical.getChildNodes(node.shadyRoot || node);
1953
+ for (var i = 0; i < c$.length; i++) {
1954
+ var child = c$[i];
1955
+ if (isInsertionPoint(child)) {
1956
+ var distributedNodes = child._distributedNodes;
1957
+ for (var j = 0; j < distributedNodes.length; j++) {
1958
+ var distributedNode = distributedNodes[j];
1959
+ if (isFinalDestination(child, distributedNode)) {
1960
+ children.push(distributedNode);
1961
+ }
1962
+ }
1963
+ } else {
1964
+ children.push(child);
1965
+ }
1966
+ }
1967
+ return children;
1968
+ },
1969
+ _updateChildNodes: function (container, children) {
1970
+ var composed = TreeApi.Composed.getChildNodes(container);
1971
+ var splices = Polymer.ArraySplice.calculateSplices(children, composed);
1972
+ for (var i = 0, d = 0, s; i < splices.length && (s = splices[i]); i++) {
1973
+ for (var j = 0, n; j < s.removed.length && (n = s.removed[j]); j++) {
1974
+ if (TreeApi.Composed.getParentNode(n) === container) {
1975
+ TreeApi.Composed.removeChild(container, n);
1976
+ }
1977
+ composed.splice(s.index + d, 1);
1978
+ }
1979
+ d -= s.addedCount;
1980
+ }
1981
+ for (var i = 0, s, next; i < splices.length && (s = splices[i]); i++) {
1982
+ next = composed[s.index];
1983
+ for (j = s.index, n; j < s.index + s.addedCount; j++) {
1984
+ n = children[j];
1985
+ TreeApi.Composed.insertBefore(container, n, next);
1986
+ composed.splice(j, 0, n);
1987
+ }
1988
+ }
1989
+ },
1990
+ _matchesContentSelect: function (node, contentElement) {
1991
+ var select = contentElement.getAttribute('select');
1992
+ if (!select) {
1993
+ return true;
1994
+ }
1995
+ select = select.trim();
1996
+ if (!select) {
1997
+ return true;
1998
+ }
1999
+ if (!(node instanceof Element)) {
2000
+ return false;
2001
+ }
2002
+ var validSelectors = /^(:not\()?[*.#[a-zA-Z_|]/;
2003
+ if (!validSelectors.test(select)) {
2004
+ return false;
2005
+ }
2006
+ return this.elementMatches(select, node);
2007
+ },
2008
+ _elementAdd: function () {
2009
+ },
2010
+ _elementRemove: function () {
2011
+ }
2012
+ });
2013
+ var domHostDesc = {
2014
+ get: function () {
2015
+ var root = Polymer.dom(this).getOwnerRoot();
2016
+ return root && root.host;
2017
+ },
2018
+ configurable: true
2019
+ };
2020
+ Object.defineProperty(Polymer.Base, 'domHost', domHostDesc);
2021
+ Polymer.BaseDescriptors.domHost = domHostDesc;
2022
+ function distributeNodeInto(child, insertionPoint) {
2023
+ insertionPoint._distributedNodes.push(child);
2024
+ var points = child._destinationInsertionPoints;
2025
+ if (!points) {
2026
+ child._destinationInsertionPoints = [insertionPoint];
2027
+ } else {
2028
+ points.push(insertionPoint);
2029
+ }
2030
+ }
2031
+ function clearDistributedDestinationInsertionPoints(content) {
2032
+ var e$ = content._distributedNodes;
2033
+ if (e$) {
2034
+ for (var i = 0; i < e$.length; i++) {
2035
+ var d = e$[i]._destinationInsertionPoints;
2036
+ if (d) {
2037
+ d.splice(d.indexOf(content) + 1, d.length);
2038
+ }
2039
+ }
2040
+ }
2041
+ }
2042
+ function maybeRedistributeParent(content, host) {
2043
+ var parent = TreeApi.Logical.getParentNode(content);
2044
+ if (parent && parent.shadyRoot && DomApi.hasInsertionPoint(parent.shadyRoot) && parent.shadyRoot._distributionClean) {
2045
+ parent.shadyRoot._distributionClean = false;
2046
+ host.shadyRoot._dirtyRoots.push(parent);
2047
+ }
2048
+ }
2049
+ function isFinalDestination(insertionPoint, node) {
2050
+ var points = node._destinationInsertionPoints;
2051
+ return points && points[points.length - 1] === insertionPoint;
2052
+ }
2053
+ function isInsertionPoint(node) {
2054
+ return node.localName == 'content';
2055
+ }
2056
+ function getTopDistributingHost(host) {
2057
+ while (host && hostNeedsRedistribution(host)) {
2058
+ host = host.domHost;
2059
+ }
2060
+ return host;
2061
+ }
2062
+ function hostNeedsRedistribution(host) {
2063
+ var c$ = TreeApi.Logical.getChildNodes(host);
2064
+ for (var i = 0, c; i < c$.length; i++) {
2065
+ c = c$[i];
2066
+ if (c.localName && c.localName === 'content') {
2067
+ return host.domHost;
2068
+ }
2069
+ }
2070
+ }
2071
+ function notifyContentObservers(root) {
2072
+ for (var i = 0, c; i < root._insertionPoints.length; i++) {
2073
+ c = root._insertionPoints[i];
2074
+ if (DomApi.hasApi(c)) {
2075
+ Polymer.dom(c).notifyObserver();
2076
+ }
2077
+ }
2078
+ }
2079
+ function notifyInitialDistribution(host) {
2080
+ if (DomApi.hasApi(host)) {
2081
+ Polymer.dom(host).notifyObserver();
2082
+ }
2083
+ }
2084
+ var needsUpgrade = window.CustomElements && !CustomElements.useNative;
2085
+ function upgradeLogicalChildren(children) {
2086
+ if (needsUpgrade && children) {
2087
+ for (var i = 0; i < children.length; i++) {
2088
+ CustomElements.upgrade(children[i]);
2089
+ }
2090
+ }
2091
+ }
2092
+ }());if (Polymer.Settings.useShadow) {
2093
+ Polymer.Base._addFeature({
2094
+ _poolContent: function () {
2095
+ },
2096
+ _beginDistribute: function () {
2097
+ },
2098
+ distributeContent: function () {
2099
+ },
2100
+ _distributeContent: function () {
2101
+ },
2102
+ _finishDistribute: function () {
2103
+ },
2104
+ _createLocalRoot: function () {
2105
+ this.createShadowRoot();
2106
+ this.shadowRoot.appendChild(this.root);
2107
+ this.root = this.shadowRoot;
2108
+ }
2109
+ });
2110
+ }Polymer.Async = {
2111
+ _currVal: 0,
2112
+ _lastVal: 0,
2113
+ _callbacks: [],
2114
+ _twiddleContent: 0,
2115
+ _twiddle: document.createTextNode(''),
2116
+ run: function (callback, waitTime) {
2117
+ if (waitTime > 0) {
2118
+ return ~setTimeout(callback, waitTime);
2119
+ } else {
2120
+ this._twiddle.textContent = this._twiddleContent++;
2121
+ this._callbacks.push(callback);
2122
+ return this._currVal++;
2123
+ }
2124
+ },
2125
+ cancel: function (handle) {
2126
+ if (handle < 0) {
2127
+ clearTimeout(~handle);
2128
+ } else {
2129
+ var idx = handle - this._lastVal;
2130
+ if (idx >= 0) {
2131
+ if (!this._callbacks[idx]) {
2132
+ throw 'invalid async handle: ' + handle;
2133
+ }
2134
+ this._callbacks[idx] = null;
2135
+ }
2136
+ }
2137
+ },
2138
+ _atEndOfMicrotask: function () {
2139
+ var len = this._callbacks.length;
2140
+ for (var i = 0; i < len; i++) {
2141
+ var cb = this._callbacks[i];
2142
+ if (cb) {
2143
+ try {
2144
+ cb();
2145
+ } catch (e) {
2146
+ i++;
2147
+ this._callbacks.splice(0, i);
2148
+ this._lastVal += i;
2149
+ this._twiddle.textContent = this._twiddleContent++;
2150
+ throw e;
2151
+ }
2152
+ }
2153
+ }
2154
+ this._callbacks.splice(0, len);
2155
+ this._lastVal += len;
2156
+ }
2157
+ };
2158
+ new window.MutationObserver(function () {
2159
+ Polymer.Async._atEndOfMicrotask();
2160
+ }).observe(Polymer.Async._twiddle, { characterData: true });Polymer.Debounce = function () {
2161
+ var Async = Polymer.Async;
2162
+ var Debouncer = function (context) {
2163
+ this.context = context;
2164
+ var self = this;
2165
+ this.boundComplete = function () {
2166
+ self.complete();
2167
+ };
2168
+ };
2169
+ Debouncer.prototype = {
2170
+ go: function (callback, wait) {
2171
+ var h;
2172
+ this.finish = function () {
2173
+ Async.cancel(h);
2174
+ };
2175
+ h = Async.run(this.boundComplete, wait);
2176
+ this.callback = callback;
2177
+ },
2178
+ stop: function () {
2179
+ if (this.finish) {
2180
+ this.finish();
2181
+ this.finish = null;
2182
+ this.callback = null;
2183
+ }
2184
+ },
2185
+ complete: function () {
2186
+ if (this.finish) {
2187
+ var callback = this.callback;
2188
+ this.stop();
2189
+ callback.call(this.context);
2190
+ }
2191
+ }
2192
+ };
2193
+ function debounce(debouncer, callback, wait) {
2194
+ if (debouncer) {
2195
+ debouncer.stop();
2196
+ } else {
2197
+ debouncer = new Debouncer(this);
2198
+ }
2199
+ debouncer.go(callback, wait);
2200
+ return debouncer;
2201
+ }
2202
+ return debounce;
2203
+ }();Polymer.Base._addFeature({
2204
+ _setupDebouncers: function () {
2205
+ this._debouncers = {};
2206
+ },
2207
+ debounce: function (jobName, callback, wait) {
2208
+ return this._debouncers[jobName] = Polymer.Debounce.call(this, this._debouncers[jobName], callback, wait);
2209
+ },
2210
+ isDebouncerActive: function (jobName) {
2211
+ var debouncer = this._debouncers[jobName];
2212
+ return !!(debouncer && debouncer.finish);
2213
+ },
2214
+ flushDebouncer: function (jobName) {
2215
+ var debouncer = this._debouncers[jobName];
2216
+ if (debouncer) {
2217
+ debouncer.complete();
2218
+ }
2219
+ },
2220
+ cancelDebouncer: function (jobName) {
2221
+ var debouncer = this._debouncers[jobName];
2222
+ if (debouncer) {
2223
+ debouncer.stop();
2224
+ }
2225
+ }
2226
+ });Polymer.DomModule = document.createElement('dom-module');
2227
+ Polymer.Base._addFeature({
2228
+ _registerFeatures: function () {
2229
+ this._prepIs();
2230
+ this._prepBehaviors();
2231
+ this._prepConstructor();
2232
+ this._prepTemplate();
2233
+ this._prepShady();
2234
+ this._prepPropertyInfo();
2235
+ },
2236
+ _prepBehavior: function (b) {
2237
+ this._addHostAttributes(b.hostAttributes);
2238
+ },
2239
+ _initFeatures: function () {
2240
+ this._registerHost();
2241
+ if (this._template) {
2242
+ this._poolContent();
2243
+ this._beginHosting();
2244
+ this._stampTemplate();
2245
+ this._endHosting();
2246
+ }
2247
+ this._marshalHostAttributes();
2248
+ this._setupDebouncers();
2249
+ this._marshalBehaviors();
2250
+ this._tryReady();
2251
+ },
2252
+ _marshalBehavior: function (b) {
2253
+ }
2254
+ });</script>
2255
+
2256
+
2257
+
2258
+
2259
+
2260
+