1 (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Mapillary = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
4 var Queue = require('tinyqueue');
6 module.exports = polylabel;
7 module.exports.default = polylabel;
9 function polylabel(polygon, precision, debug) {
10 precision = precision || 1.0;
12 // find the bounding box of the outer ring
13 var minX, minY, maxX, maxY;
14 for (var i = 0; i < polygon[0].length; i++) {
15 var p = polygon[0][i];
16 if (!i || p[0] < minX) minX = p[0];
17 if (!i || p[1] < minY) minY = p[1];
18 if (!i || p[0] > maxX) maxX = p[0];
19 if (!i || p[1] > maxY) maxY = p[1];
22 var width = maxX - minX;
23 var height = maxY - minY;
24 var cellSize = Math.min(width, height);
27 // a priority queue of cells in order of their "potential" (max distance to polygon)
28 var cellQueue = new Queue(null, compareMax);
30 if (cellSize === 0) return [minX, minY];
32 // cover polygon with initial cells
33 for (var x = minX; x < maxX; x += cellSize) {
34 for (var y = minY; y < maxY; y += cellSize) {
35 cellQueue.push(new Cell(x + h, y + h, h, polygon));
39 // take centroid as the first best guess
40 var bestCell = getCentroidCell(polygon);
42 // special case for rectangular polygons
43 var bboxCell = new Cell(minX + width / 2, minY + height / 2, 0, polygon);
44 if (bboxCell.d > bestCell.d) bestCell = bboxCell;
46 var numProbes = cellQueue.length;
48 while (cellQueue.length) {
49 // pick the most promising cell from the queue
50 var cell = cellQueue.pop();
52 // update the best cell if we found a better one
53 if (cell.d > bestCell.d) {
55 if (debug) console.log('found best %d after %d probes', Math.round(1e4 * cell.d) / 1e4, numProbes);
58 // do not drill down further if there's no chance of a better solution
59 if (cell.max - bestCell.d <= precision) continue;
61 // split the cell into four cells
63 cellQueue.push(new Cell(cell.x - h, cell.y - h, h, polygon));
64 cellQueue.push(new Cell(cell.x + h, cell.y - h, h, polygon));
65 cellQueue.push(new Cell(cell.x - h, cell.y + h, h, polygon));
66 cellQueue.push(new Cell(cell.x + h, cell.y + h, h, polygon));
71 console.log('num probes: ' + numProbes);
72 console.log('best distance: ' + bestCell.d);
75 return [bestCell.x, bestCell.y];
78 function compareMax(a, b) {
82 function Cell(x, y, h, polygon) {
83 this.x = x; // cell center x
84 this.y = y; // cell center y
85 this.h = h; // half the cell size
86 this.d = pointToPolygonDist(x, y, polygon); // distance from cell center to polygon
87 this.max = this.d + this.h * Math.SQRT2; // max distance to polygon within a cell
90 // signed distance from point to polygon outline (negative if point is outside)
91 function pointToPolygonDist(x, y, polygon) {
93 var minDistSq = Infinity;
95 for (var k = 0; k < polygon.length; k++) {
96 var ring = polygon[k];
98 for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) {
102 if ((a[1] > y !== b[1] > y) &&
103 (x < (b[0] - a[0]) * (y - a[1]) / (b[1] - a[1]) + a[0])) inside = !inside;
105 minDistSq = Math.min(minDistSq, getSegDistSq(x, y, a, b));
109 return (inside ? 1 : -1) * Math.sqrt(minDistSq);
112 // get polygon centroid
113 function getCentroidCell(polygon) {
117 var points = polygon[0];
119 for (var i = 0, len = points.length, j = len - 1; i < len; j = i++) {
122 var f = a[0] * b[1] - b[0] * a[1];
123 x += (a[0] + b[0]) * f;
124 y += (a[1] + b[1]) * f;
127 if (area === 0) return new Cell(points[0][0], points[0][1], 0, polygon);
128 return new Cell(x / area, y / area, 0, polygon);
131 // get squared distance from a point to a segment
132 function getSegDistSq(px, py, a, b) {
139 if (dx !== 0 || dy !== 0) {
141 var t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);
156 return dx * dx + dy * dy;
159 },{"tinyqueue":226}],2:[function(require,module,exports){
161 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
163 * Redistribution and use in source and binary forms, with or without
164 * modification, are permitted provided that the following conditions
166 * 1. Redistributions of source code must retain the above copyright
167 * notice, this list of conditions and the following disclaimer.
168 * 2. Redistributions in binary form must reproduce the above copyright
169 * notice, this list of conditions and the following disclaimer in the
170 * documentation and/or other materials provided with the distribution.
172 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
173 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
174 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
175 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
176 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
177 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
178 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
179 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
180 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
181 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
182 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
185 * http://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/UnitBezier.h
188 module.exports = UnitBezier;
190 function UnitBezier(p1x, p1y, p2x, p2y) {
191 // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).
193 this.bx = 3.0 * (p2x - p1x) - this.cx;
194 this.ax = 1.0 - this.cx - this.bx;
197 this.by = 3.0 * (p2y - p1y) - this.cy;
198 this.ay = 1.0 - this.cy - this.by;
206 UnitBezier.prototype.sampleCurveX = function(t) {
207 // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.
208 return ((this.ax * t + this.bx) * t + this.cx) * t;
211 UnitBezier.prototype.sampleCurveY = function(t) {
212 return ((this.ay * t + this.by) * t + this.cy) * t;
215 UnitBezier.prototype.sampleCurveDerivativeX = function(t) {
216 return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx;
219 UnitBezier.prototype.solveCurveX = function(x, epsilon) {
220 if (typeof epsilon === 'undefined') epsilon = 1e-6;
222 var t0, t1, t2, x2, i;
224 // First try a few iterations of Newton's method -- normally very fast.
225 for (t2 = x, i = 0; i < 8; i++) {
227 x2 = this.sampleCurveX(t2) - x;
228 if (Math.abs(x2) < epsilon) return t2;
230 var d2 = this.sampleCurveDerivativeX(t2);
231 if (Math.abs(d2) < 1e-6) break;
236 // Fall back to the bisection method for reliability.
241 if (t2 < t0) return t0;
242 if (t2 > t1) return t1;
246 x2 = this.sampleCurveX(t2);
247 if (Math.abs(x2 - x) < epsilon) return t2;
255 t2 = (t1 - t0) * 0.5 + t0;
262 UnitBezier.prototype.solve = function(x, epsilon) {
263 return this.sampleCurveY(this.solveCurveX(x, epsilon));
266 },{}],3:[function(require,module,exports){
269 exports.byteLength = byteLength
270 exports.toByteArray = toByteArray
271 exports.fromByteArray = fromByteArray
275 var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
277 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
278 for (var i = 0, len = code.length; i < len; ++i) {
280 revLookup[code.charCodeAt(i)] = i
283 revLookup['-'.charCodeAt(0)] = 62
284 revLookup['_'.charCodeAt(0)] = 63
286 function placeHoldersCount (b64) {
289 throw new Error('Invalid string. Length must be a multiple of 4')
292 // the number of equal signs (place holders)
293 // if there are two placeholders, than the two characters before it
294 // represent one byte
295 // if there is only one, then the three characters before it represent 2 bytes
296 // this is just a cheap hack to not do indexOf twice
297 return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
300 function byteLength (b64) {
301 // base64 is 4/3 + up to two characters of the original data
302 return (b64.length * 3 / 4) - placeHoldersCount(b64)
305 function toByteArray (b64) {
306 var i, l, tmp, placeHolders, arr
308 placeHolders = placeHoldersCount(b64)
310 arr = new Arr((len * 3 / 4) - placeHolders)
312 // if there are placeholders, only get up to the last complete 4 chars
313 l = placeHolders > 0 ? len - 4 : len
317 for (i = 0; i < l; i += 4) {
318 tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
319 arr[L++] = (tmp >> 16) & 0xFF
320 arr[L++] = (tmp >> 8) & 0xFF
321 arr[L++] = tmp & 0xFF
324 if (placeHolders === 2) {
325 tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
326 arr[L++] = tmp & 0xFF
327 } else if (placeHolders === 1) {
328 tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
329 arr[L++] = (tmp >> 8) & 0xFF
330 arr[L++] = tmp & 0xFF
336 function tripletToBase64 (num) {
337 return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
340 function encodeChunk (uint8, start, end) {
343 for (var i = start; i < end; i += 3) {
344 tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
345 output.push(tripletToBase64(tmp))
347 return output.join('')
350 function fromByteArray (uint8) {
352 var len = uint8.length
353 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
356 var maxChunkLength = 16383 // must be multiple of 3
358 // go through the array every three bytes, we'll deal with trailing stuff later
359 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
360 parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
363 // pad the end with zeros, but make sure to not forget the extra bytes
364 if (extraBytes === 1) {
366 output += lookup[tmp >> 2]
367 output += lookup[(tmp << 4) & 0x3F]
369 } else if (extraBytes === 2) {
370 tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
371 output += lookup[tmp >> 10]
372 output += lookup[(tmp >> 4) & 0x3F]
373 output += lookup[(tmp << 2) & 0x3F]
379 return parts.join('')
382 },{}],4:[function(require,module,exports){
384 },{}],5:[function(require,module,exports){
386 * Cross-Browser Split 1.1.1
387 * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
388 * Available under the MIT License
389 * ECMAScript compliant, uniform cross-browser split method
393 * Splits a string into an array of strings using a regex or string separator. Matches of the
394 * separator are not included in the result array. However, if `separator` is a regex that contains
395 * capturing groups, backreferences are spliced into the result each time `separator` is matched.
396 * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
398 * @param {String} str String to split.
399 * @param {RegExp|String} separator Regex or string to use for separating the string.
400 * @param {Number} [limit] Maximum number of items to include in the result array.
401 * @returns {Array} Array of substrings.
405 * split('a b c d', ' ');
406 * // -> ['a', 'b', 'c', 'd']
409 * split('a b c d', ' ', 2);
412 * // Backreferences in result array
413 * split('..word1 word2..', /([a-z]+)(\d+)/i);
414 * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
416 module.exports = (function split(undef) {
418 var nativeSplit = String.prototype.split,
419 compliantExecNpcg = /()??/.exec("")[1] === undef,
420 // NPCG: nonparticipating capturing group
423 self = function(str, separator, limit) {
424 // If `separator` is not a regex, use `nativeSplit`
425 if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
426 return nativeSplit.call(str, separator, limit);
429 flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6
430 (separator.sticky ? "y" : ""),
433 // Make `global` and avoid `lastIndex` issues by working with a copy
434 separator = new RegExp(separator.source, flags + "g"),
435 separator2, match, lastIndex, lastLength;
436 str += ""; // Type-convert
437 if (!compliantExecNpcg) {
438 // Doesn't need flags gy, but they don't hurt
439 separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
441 /* Values for `limit`, per the spec:
442 * If undefined: 4294967295 // Math.pow(2, 32) - 1
443 * If 0, Infinity, or NaN: 0
444 * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
445 * If negative number: 4294967296 - Math.floor(Math.abs(limit))
446 * If other: Type-convert, then use the above rules
448 limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1
449 limit >>> 0; // ToUint32(limit)
450 while (match = separator.exec(str)) {
451 // `separator.lastIndex` is not reliable cross-browser
452 lastIndex = match.index + match[0].length;
453 if (lastIndex > lastLastIndex) {
454 output.push(str.slice(lastLastIndex, match.index));
455 // Fix browsers whose `exec` methods don't consistently return `undefined` for
456 // nonparticipating capturing groups
457 if (!compliantExecNpcg && match.length > 1) {
458 match[0].replace(separator2, function() {
459 for (var i = 1; i < arguments.length - 2; i++) {
460 if (arguments[i] === undef) {
466 if (match.length > 1 && match.index < str.length) {
467 Array.prototype.push.apply(output, match.slice(1));
469 lastLength = match[0].length;
470 lastLastIndex = lastIndex;
471 if (output.length >= limit) {
475 if (separator.lastIndex === match.index) {
476 separator.lastIndex++; // Avoid an infinite loop
479 if (lastLastIndex === str.length) {
480 if (lastLength || !separator.test("")) {
484 output.push(str.slice(lastLastIndex));
486 return output.length > limit ? output.slice(0, limit) : output;
492 },{}],6:[function(require,module,exports){
493 // shim for using process in browser
494 var process = module.exports = {};
496 // cached from whatever global is present so that test runners that stub it
497 // don't break things. But we need to wrap it in a try catch in case it is
498 // wrapped in strict mode code which doesn't define any globals. It's inside a
499 // function because try/catches deoptimize in certain engines.
501 var cachedSetTimeout;
502 var cachedClearTimeout;
504 function defaultSetTimout() {
505 throw new Error('setTimeout has not been defined');
507 function defaultClearTimeout () {
508 throw new Error('clearTimeout has not been defined');
512 if (typeof setTimeout === 'function') {
513 cachedSetTimeout = setTimeout;
515 cachedSetTimeout = defaultSetTimout;
518 cachedSetTimeout = defaultSetTimout;
521 if (typeof clearTimeout === 'function') {
522 cachedClearTimeout = clearTimeout;
524 cachedClearTimeout = defaultClearTimeout;
527 cachedClearTimeout = defaultClearTimeout;
530 function runTimeout(fun) {
531 if (cachedSetTimeout === setTimeout) {
532 //normal enviroments in sane situations
533 return setTimeout(fun, 0);
535 // if setTimeout wasn't available but was latter defined
536 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
537 cachedSetTimeout = setTimeout;
538 return setTimeout(fun, 0);
541 // when when somebody has screwed with setTimeout but no I.E. maddness
542 return cachedSetTimeout(fun, 0);
545 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
546 return cachedSetTimeout.call(null, fun, 0);
548 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
549 return cachedSetTimeout.call(this, fun, 0);
555 function runClearTimeout(marker) {
556 if (cachedClearTimeout === clearTimeout) {
557 //normal enviroments in sane situations
558 return clearTimeout(marker);
560 // if clearTimeout wasn't available but was latter defined
561 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
562 cachedClearTimeout = clearTimeout;
563 return clearTimeout(marker);
566 // when when somebody has screwed with setTimeout but no I.E. maddness
567 return cachedClearTimeout(marker);
570 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
571 return cachedClearTimeout.call(null, marker);
573 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
574 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
575 return cachedClearTimeout.call(this, marker);
583 var draining = false;
587 function cleanUpNextTick() {
588 if (!draining || !currentQueue) {
592 if (currentQueue.length) {
593 queue = currentQueue.concat(queue);
602 function drainQueue() {
606 var timeout = runTimeout(cleanUpNextTick);
609 var len = queue.length;
611 currentQueue = queue;
613 while (++queueIndex < len) {
615 currentQueue[queueIndex].run();
623 runClearTimeout(timeout);
626 process.nextTick = function (fun) {
627 var args = new Array(arguments.length - 1);
628 if (arguments.length > 1) {
629 for (var i = 1; i < arguments.length; i++) {
630 args[i - 1] = arguments[i];
633 queue.push(new Item(fun, args));
634 if (queue.length === 1 && !draining) {
635 runTimeout(drainQueue);
639 // v8 likes predictible objects
640 function Item(fun, array) {
644 Item.prototype.run = function () {
645 this.fun.apply(null, this.array);
647 process.title = 'browser';
648 process.browser = true;
651 process.version = ''; // empty string to avoid regexp issues
652 process.versions = {};
657 process.addListener = noop;
660 process.removeListener = noop;
661 process.removeAllListeners = noop;
663 process.prependListener = noop;
664 process.prependOnceListener = noop;
666 process.listeners = function (name) { return [] }
668 process.binding = function (name) {
669 throw new Error('process.binding is not supported');
672 process.cwd = function () { return '/' };
673 process.chdir = function (dir) {
674 throw new Error('process.chdir is not supported');
676 process.umask = function() { return 0; };
678 },{}],7:[function(require,module,exports){
680 * The buffer module from node.js, for the browser.
682 * @author Feross Aboukhadijeh <https://feross.org>
685 /* eslint-disable no-proto */
689 var base64 = require('base64-js')
690 var ieee754 = require('ieee754')
692 exports.Buffer = Buffer
693 exports.SlowBuffer = SlowBuffer
694 exports.INSPECT_MAX_BYTES = 50
696 var K_MAX_LENGTH = 0x7fffffff
697 exports.kMaxLength = K_MAX_LENGTH
700 * If `Buffer.TYPED_ARRAY_SUPPORT`:
701 * === true Use Uint8Array implementation (fastest)
702 * === false Print warning and recommend using `buffer` v4.x which has an Object
703 * implementation (most compatible, even IE6)
705 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
706 * Opera 11.6+, iOS 4.2+.
708 * We report that the browser does not support typed arrays if the are not subclassable
709 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
710 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
711 * for __proto__ and has a buggy typed array implementation.
713 Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
715 if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
716 typeof console.error === 'function') {
718 'This browser lacks typed array (Uint8Array) support which is required by ' +
719 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
723 function typedArraySupport () {
724 // Can typed array instances can be augmented?
726 var arr = new Uint8Array(1)
727 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
728 return arr.foo() === 42
734 function createBuffer (length) {
735 if (length > K_MAX_LENGTH) {
736 throw new RangeError('Invalid typed array length')
738 // Return an augmented `Uint8Array` instance
739 var buf = new Uint8Array(length)
740 buf.__proto__ = Buffer.prototype
745 * The Buffer constructor returns instances of `Uint8Array` that have their
746 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
747 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
748 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
749 * returns a single octet.
751 * The `Uint8Array` prototype remains unmodified.
754 function Buffer (arg, encodingOrOffset, length) {
756 if (typeof arg === 'number') {
757 if (typeof encodingOrOffset === 'string') {
759 'If encoding is specified then the first argument must be a string'
762 return allocUnsafe(arg)
764 return from(arg, encodingOrOffset, length)
767 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
768 if (typeof Symbol !== 'undefined' && Symbol.species &&
769 Buffer[Symbol.species] === Buffer) {
770 Object.defineProperty(Buffer, Symbol.species, {
778 Buffer.poolSize = 8192 // not used by this implementation
780 function from (value, encodingOrOffset, length) {
781 if (typeof value === 'number') {
782 throw new TypeError('"value" argument must not be a number')
785 if (isArrayBuffer(value)) {
786 return fromArrayBuffer(value, encodingOrOffset, length)
789 if (typeof value === 'string') {
790 return fromString(value, encodingOrOffset)
793 return fromObject(value)
797 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
798 * if value is a number.
799 * Buffer.from(str[, encoding])
801 * Buffer.from(buffer)
802 * Buffer.from(arrayBuffer[, byteOffset[, length]])
804 Buffer.from = function (value, encodingOrOffset, length) {
805 return from(value, encodingOrOffset, length)
808 // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
809 // https://github.com/feross/buffer/pull/148
810 Buffer.prototype.__proto__ = Uint8Array.prototype
811 Buffer.__proto__ = Uint8Array
813 function assertSize (size) {
814 if (typeof size !== 'number') {
815 throw new TypeError('"size" argument must be a number')
816 } else if (size < 0) {
817 throw new RangeError('"size" argument must not be negative')
821 function alloc (size, fill, encoding) {
824 return createBuffer(size)
826 if (fill !== undefined) {
827 // Only pay attention to encoding if it's a string. This
828 // prevents accidentally sending in a number that would
829 // be interpretted as a start offset.
830 return typeof encoding === 'string'
831 ? createBuffer(size).fill(fill, encoding)
832 : createBuffer(size).fill(fill)
834 return createBuffer(size)
838 * Creates a new filled Buffer instance.
839 * alloc(size[, fill[, encoding]])
841 Buffer.alloc = function (size, fill, encoding) {
842 return alloc(size, fill, encoding)
845 function allocUnsafe (size) {
847 return createBuffer(size < 0 ? 0 : checked(size) | 0)
851 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
853 Buffer.allocUnsafe = function (size) {
854 return allocUnsafe(size)
857 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
859 Buffer.allocUnsafeSlow = function (size) {
860 return allocUnsafe(size)
863 function fromString (string, encoding) {
864 if (typeof encoding !== 'string' || encoding === '') {
868 if (!Buffer.isEncoding(encoding)) {
869 throw new TypeError('"encoding" must be a valid string encoding')
872 var length = byteLength(string, encoding) | 0
873 var buf = createBuffer(length)
875 var actual = buf.write(string, encoding)
877 if (actual !== length) {
878 // Writing a hex string, for example, that contains invalid characters will
879 // cause everything after the first invalid character to be ignored. (e.g.
880 // 'abxxcd' will be treated as 'ab')
881 buf = buf.slice(0, actual)
887 function fromArrayLike (array) {
888 var length = array.length < 0 ? 0 : checked(array.length) | 0
889 var buf = createBuffer(length)
890 for (var i = 0; i < length; i += 1) {
891 buf[i] = array[i] & 255
896 function fromArrayBuffer (array, byteOffset, length) {
897 if (byteOffset < 0 || array.byteLength < byteOffset) {
898 throw new RangeError('\'offset\' is out of bounds')
901 if (array.byteLength < byteOffset + (length || 0)) {
902 throw new RangeError('\'length\' is out of bounds')
906 if (byteOffset === undefined && length === undefined) {
907 buf = new Uint8Array(array)
908 } else if (length === undefined) {
909 buf = new Uint8Array(array, byteOffset)
911 buf = new Uint8Array(array, byteOffset, length)
914 // Return an augmented `Uint8Array` instance
915 buf.__proto__ = Buffer.prototype
919 function fromObject (obj) {
920 if (Buffer.isBuffer(obj)) {
921 var len = checked(obj.length) | 0
922 var buf = createBuffer(len)
924 if (buf.length === 0) {
928 obj.copy(buf, 0, 0, len)
933 if (isArrayBufferView(obj) || 'length' in obj) {
934 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
935 return createBuffer(0)
937 return fromArrayLike(obj)
940 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
941 return fromArrayLike(obj.data)
945 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
948 function checked (length) {
949 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
950 // length is NaN (which is otherwise coerced to zero.)
951 if (length >= K_MAX_LENGTH) {
952 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
953 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
958 function SlowBuffer (length) {
959 if (+length != length) { // eslint-disable-line eqeqeq
962 return Buffer.alloc(+length)
965 Buffer.isBuffer = function isBuffer (b) {
966 return b != null && b._isBuffer === true
969 Buffer.compare = function compare (a, b) {
970 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
971 throw new TypeError('Arguments must be Buffers')
974 if (a === b) return 0
979 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
992 Buffer.isEncoding = function isEncoding (encoding) {
993 switch (String(encoding).toLowerCase()) {
1011 Buffer.concat = function concat (list, length) {
1012 if (!Array.isArray(list)) {
1013 throw new TypeError('"list" argument must be an Array of Buffers')
1016 if (list.length === 0) {
1017 return Buffer.alloc(0)
1021 if (length === undefined) {
1023 for (i = 0; i < list.length; ++i) {
1024 length += list[i].length
1028 var buffer = Buffer.allocUnsafe(length)
1030 for (i = 0; i < list.length; ++i) {
1032 if (!Buffer.isBuffer(buf)) {
1033 throw new TypeError('"list" argument must be an Array of Buffers')
1035 buf.copy(buffer, pos)
1041 function byteLength (string, encoding) {
1042 if (Buffer.isBuffer(string)) {
1043 return string.length
1045 if (isArrayBufferView(string) || isArrayBuffer(string)) {
1046 return string.byteLength
1048 if (typeof string !== 'string') {
1049 string = '' + string
1052 var len = string.length
1053 if (len === 0) return 0
1055 // Use a for loop to avoid recursion
1056 var loweredCase = false
1066 return utf8ToBytes(string).length
1075 return base64ToBytes(string).length
1077 if (loweredCase) return utf8ToBytes(string).length // assume utf8
1078 encoding = ('' + encoding).toLowerCase()
1083 Buffer.byteLength = byteLength
1085 function slowToString (encoding, start, end) {
1086 var loweredCase = false
1088 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
1089 // property of a typed array.
1091 // This behaves neither like String nor Uint8Array in that we set start/end
1092 // to their upper/lower bounds if the value passed is out of range.
1093 // undefined is handled specially as per ECMA-262 6th Edition,
1094 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
1095 if (start === undefined || start < 0) {
1098 // Return early if start > this.length. Done here to prevent potential uint32
1099 // coercion fail below.
1100 if (start > this.length) {
1104 if (end === undefined || end > this.length) {
1112 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
1120 if (!encoding) encoding = 'utf8'
1125 return hexSlice(this, start, end)
1129 return utf8Slice(this, start, end)
1132 return asciiSlice(this, start, end)
1136 return latin1Slice(this, start, end)
1139 return base64Slice(this, start, end)
1145 return utf16leSlice(this, start, end)
1148 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1149 encoding = (encoding + '').toLowerCase()
1155 // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
1156 // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
1157 // reliably in a browserify context because there could be multiple different
1158 // copies of the 'buffer' package in use. This method works even for Buffer
1159 // instances that were created from another copy of the `buffer` package.
1160 // See: https://github.com/feross/buffer/issues/154
1161 Buffer.prototype._isBuffer = true
1163 function swap (b, n, m) {
1169 Buffer.prototype.swap16 = function swap16 () {
1170 var len = this.length
1171 if (len % 2 !== 0) {
1172 throw new RangeError('Buffer size must be a multiple of 16-bits')
1174 for (var i = 0; i < len; i += 2) {
1175 swap(this, i, i + 1)
1180 Buffer.prototype.swap32 = function swap32 () {
1181 var len = this.length
1182 if (len % 4 !== 0) {
1183 throw new RangeError('Buffer size must be a multiple of 32-bits')
1185 for (var i = 0; i < len; i += 4) {
1186 swap(this, i, i + 3)
1187 swap(this, i + 1, i + 2)
1192 Buffer.prototype.swap64 = function swap64 () {
1193 var len = this.length
1194 if (len % 8 !== 0) {
1195 throw new RangeError('Buffer size must be a multiple of 64-bits')
1197 for (var i = 0; i < len; i += 8) {
1198 swap(this, i, i + 7)
1199 swap(this, i + 1, i + 6)
1200 swap(this, i + 2, i + 5)
1201 swap(this, i + 3, i + 4)
1206 Buffer.prototype.toString = function toString () {
1207 var length = this.length
1208 if (length === 0) return ''
1209 if (arguments.length === 0) return utf8Slice(this, 0, length)
1210 return slowToString.apply(this, arguments)
1213 Buffer.prototype.equals = function equals (b) {
1214 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
1215 if (this === b) return true
1216 return Buffer.compare(this, b) === 0
1219 Buffer.prototype.inspect = function inspect () {
1221 var max = exports.INSPECT_MAX_BYTES
1222 if (this.length > 0) {
1223 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
1224 if (this.length > max) str += ' ... '
1226 return '<Buffer ' + str + '>'
1229 Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
1230 if (!Buffer.isBuffer(target)) {
1231 throw new TypeError('Argument must be a Buffer')
1234 if (start === undefined) {
1237 if (end === undefined) {
1238 end = target ? target.length : 0
1240 if (thisStart === undefined) {
1243 if (thisEnd === undefined) {
1244 thisEnd = this.length
1247 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1248 throw new RangeError('out of range index')
1251 if (thisStart >= thisEnd && start >= end) {
1254 if (thisStart >= thisEnd) {
1266 if (this === target) return 0
1268 var x = thisEnd - thisStart
1270 var len = Math.min(x, y)
1272 var thisCopy = this.slice(thisStart, thisEnd)
1273 var targetCopy = target.slice(start, end)
1275 for (var i = 0; i < len; ++i) {
1276 if (thisCopy[i] !== targetCopy[i]) {
1283 if (x < y) return -1
1288 // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1289 // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1292 // - buffer - a Buffer to search
1293 // - val - a string, Buffer, or number
1294 // - byteOffset - an index into `buffer`; will be clamped to an int32
1295 // - encoding - an optional encoding, relevant is val is a string
1296 // - dir - true for indexOf, false for lastIndexOf
1297 function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
1298 // Empty buffer means no match
1299 if (buffer.length === 0) return -1
1301 // Normalize byteOffset
1302 if (typeof byteOffset === 'string') {
1303 encoding = byteOffset
1305 } else if (byteOffset > 0x7fffffff) {
1306 byteOffset = 0x7fffffff
1307 } else if (byteOffset < -0x80000000) {
1308 byteOffset = -0x80000000
1310 byteOffset = +byteOffset // Coerce to Number.
1311 if (numberIsNaN(byteOffset)) {
1312 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1313 byteOffset = dir ? 0 : (buffer.length - 1)
1316 // Normalize byteOffset: negative offsets start from the end of the buffer
1317 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
1318 if (byteOffset >= buffer.length) {
1320 else byteOffset = buffer.length - 1
1321 } else if (byteOffset < 0) {
1322 if (dir) byteOffset = 0
1327 if (typeof val === 'string') {
1328 val = Buffer.from(val, encoding)
1331 // Finally, search either indexOf (if dir is true) or lastIndexOf
1332 if (Buffer.isBuffer(val)) {
1333 // Special case: looking for empty string/buffer always fails
1334 if (val.length === 0) {
1337 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1338 } else if (typeof val === 'number') {
1339 val = val & 0xFF // Search for a byte value [0-255]
1340 if (typeof Uint8Array.prototype.indexOf === 'function') {
1342 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1344 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1347 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
1350 throw new TypeError('val must be string, number or Buffer')
1353 function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1355 var arrLength = arr.length
1356 var valLength = val.length
1358 if (encoding !== undefined) {
1359 encoding = String(encoding).toLowerCase()
1360 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1361 encoding === 'utf16le' || encoding === 'utf-16le') {
1362 if (arr.length < 2 || val.length < 2) {
1372 function read (buf, i) {
1373 if (indexSize === 1) {
1376 return buf.readUInt16BE(i * indexSize)
1383 for (i = byteOffset; i < arrLength; i++) {
1384 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1385 if (foundIndex === -1) foundIndex = i
1386 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1388 if (foundIndex !== -1) i -= i - foundIndex
1393 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
1394 for (i = byteOffset; i >= 0; i--) {
1396 for (var j = 0; j < valLength; j++) {
1397 if (read(arr, i + j) !== read(val, j)) {
1409 Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1410 return this.indexOf(val, byteOffset, encoding) !== -1
1413 Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1414 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1417 Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1418 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1421 function hexWrite (buf, string, offset, length) {
1422 offset = Number(offset) || 0
1423 var remaining = buf.length - offset
1427 length = Number(length)
1428 if (length > remaining) {
1433 // must be an even number of digits
1434 var strLen = string.length
1435 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
1437 if (length > strLen / 2) {
1440 for (var i = 0; i < length; ++i) {
1441 var parsed = parseInt(string.substr(i * 2, 2), 16)
1442 if (numberIsNaN(parsed)) return i
1443 buf[offset + i] = parsed
1448 function utf8Write (buf, string, offset, length) {
1449 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1452 function asciiWrite (buf, string, offset, length) {
1453 return blitBuffer(asciiToBytes(string), buf, offset, length)
1456 function latin1Write (buf, string, offset, length) {
1457 return asciiWrite(buf, string, offset, length)
1460 function base64Write (buf, string, offset, length) {
1461 return blitBuffer(base64ToBytes(string), buf, offset, length)
1464 function ucs2Write (buf, string, offset, length) {
1465 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1468 Buffer.prototype.write = function write (string, offset, length, encoding) {
1469 // Buffer#write(string)
1470 if (offset === undefined) {
1472 length = this.length
1474 // Buffer#write(string, encoding)
1475 } else if (length === undefined && typeof offset === 'string') {
1477 length = this.length
1479 // Buffer#write(string, offset[, length][, encoding])
1480 } else if (isFinite(offset)) {
1481 offset = offset >>> 0
1482 if (isFinite(length)) {
1483 length = length >>> 0
1484 if (encoding === undefined) encoding = 'utf8'
1491 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1495 var remaining = this.length - offset
1496 if (length === undefined || length > remaining) length = remaining
1498 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1499 throw new RangeError('Attempt to write outside buffer bounds')
1502 if (!encoding) encoding = 'utf8'
1504 var loweredCase = false
1508 return hexWrite(this, string, offset, length)
1512 return utf8Write(this, string, offset, length)
1515 return asciiWrite(this, string, offset, length)
1519 return latin1Write(this, string, offset, length)
1522 // Warning: maxLength not taken into account in base64Write
1523 return base64Write(this, string, offset, length)
1529 return ucs2Write(this, string, offset, length)
1532 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1533 encoding = ('' + encoding).toLowerCase()
1539 Buffer.prototype.toJSON = function toJSON () {
1542 data: Array.prototype.slice.call(this._arr || this, 0)
1546 function base64Slice (buf, start, end) {
1547 if (start === 0 && end === buf.length) {
1548 return base64.fromByteArray(buf)
1550 return base64.fromByteArray(buf.slice(start, end))
1554 function utf8Slice (buf, start, end) {
1555 end = Math.min(buf.length, end)
1560 var firstByte = buf[i]
1561 var codePoint = null
1562 var bytesPerSequence = (firstByte > 0xEF) ? 4
1563 : (firstByte > 0xDF) ? 3
1564 : (firstByte > 0xBF) ? 2
1567 if (i + bytesPerSequence <= end) {
1568 var secondByte, thirdByte, fourthByte, tempCodePoint
1570 switch (bytesPerSequence) {
1572 if (firstByte < 0x80) {
1573 codePoint = firstByte
1577 secondByte = buf[i + 1]
1578 if ((secondByte & 0xC0) === 0x80) {
1579 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1580 if (tempCodePoint > 0x7F) {
1581 codePoint = tempCodePoint
1586 secondByte = buf[i + 1]
1587 thirdByte = buf[i + 2]
1588 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1589 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1590 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1591 codePoint = tempCodePoint
1596 secondByte = buf[i + 1]
1597 thirdByte = buf[i + 2]
1598 fourthByte = buf[i + 3]
1599 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1600 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1601 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1602 codePoint = tempCodePoint
1608 if (codePoint === null) {
1609 // we did not generate a valid codePoint so insert a
1610 // replacement char (U+FFFD) and advance only 1 byte
1612 bytesPerSequence = 1
1613 } else if (codePoint > 0xFFFF) {
1614 // encode to utf16 (surrogate pair dance)
1615 codePoint -= 0x10000
1616 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1617 codePoint = 0xDC00 | codePoint & 0x3FF
1621 i += bytesPerSequence
1624 return decodeCodePointsArray(res)
1627 // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1628 // the lowest limit is Chrome, with 0x10000 args.
1629 // We go 1 magnitude less, for safety
1630 var MAX_ARGUMENTS_LENGTH = 0x1000
1632 function decodeCodePointsArray (codePoints) {
1633 var len = codePoints.length
1634 if (len <= MAX_ARGUMENTS_LENGTH) {
1635 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1638 // Decode in chunks to avoid "call stack size exceeded".
1642 res += String.fromCharCode.apply(
1644 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1650 function asciiSlice (buf, start, end) {
1652 end = Math.min(buf.length, end)
1654 for (var i = start; i < end; ++i) {
1655 ret += String.fromCharCode(buf[i] & 0x7F)
1660 function latin1Slice (buf, start, end) {
1662 end = Math.min(buf.length, end)
1664 for (var i = start; i < end; ++i) {
1665 ret += String.fromCharCode(buf[i])
1670 function hexSlice (buf, start, end) {
1671 var len = buf.length
1673 if (!start || start < 0) start = 0
1674 if (!end || end < 0 || end > len) end = len
1677 for (var i = start; i < end; ++i) {
1678 out += toHex(buf[i])
1683 function utf16leSlice (buf, start, end) {
1684 var bytes = buf.slice(start, end)
1686 for (var i = 0; i < bytes.length; i += 2) {
1687 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
1692 Buffer.prototype.slice = function slice (start, end) {
1693 var len = this.length
1695 end = end === undefined ? len : ~~end
1699 if (start < 0) start = 0
1700 } else if (start > len) {
1706 if (end < 0) end = 0
1707 } else if (end > len) {
1711 if (end < start) end = start
1713 var newBuf = this.subarray(start, end)
1714 // Return an augmented `Uint8Array` instance
1715 newBuf.__proto__ = Buffer.prototype
1720 * Need to make sure that buffer isn't trying to write out of bounds.
1722 function checkOffset (offset, ext, length) {
1723 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1724 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1727 Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1728 offset = offset >>> 0
1729 byteLength = byteLength >>> 0
1730 if (!noAssert) checkOffset(offset, byteLength, this.length)
1732 var val = this[offset]
1735 while (++i < byteLength && (mul *= 0x100)) {
1736 val += this[offset + i] * mul
1742 Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1743 offset = offset >>> 0
1744 byteLength = byteLength >>> 0
1746 checkOffset(offset, byteLength, this.length)
1749 var val = this[offset + --byteLength]
1751 while (byteLength > 0 && (mul *= 0x100)) {
1752 val += this[offset + --byteLength] * mul
1758 Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1759 offset = offset >>> 0
1760 if (!noAssert) checkOffset(offset, 1, this.length)
1764 Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1765 offset = offset >>> 0
1766 if (!noAssert) checkOffset(offset, 2, this.length)
1767 return this[offset] | (this[offset + 1] << 8)
1770 Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1771 offset = offset >>> 0
1772 if (!noAssert) checkOffset(offset, 2, this.length)
1773 return (this[offset] << 8) | this[offset + 1]
1776 Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1777 offset = offset >>> 0
1778 if (!noAssert) checkOffset(offset, 4, this.length)
1780 return ((this[offset]) |
1781 (this[offset + 1] << 8) |
1782 (this[offset + 2] << 16)) +
1783 (this[offset + 3] * 0x1000000)
1786 Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1787 offset = offset >>> 0
1788 if (!noAssert) checkOffset(offset, 4, this.length)
1790 return (this[offset] * 0x1000000) +
1791 ((this[offset + 1] << 16) |
1792 (this[offset + 2] << 8) |
1796 Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1797 offset = offset >>> 0
1798 byteLength = byteLength >>> 0
1799 if (!noAssert) checkOffset(offset, byteLength, this.length)
1801 var val = this[offset]
1804 while (++i < byteLength && (mul *= 0x100)) {
1805 val += this[offset + i] * mul
1809 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1814 Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1815 offset = offset >>> 0
1816 byteLength = byteLength >>> 0
1817 if (!noAssert) checkOffset(offset, byteLength, this.length)
1821 var val = this[offset + --i]
1822 while (i > 0 && (mul *= 0x100)) {
1823 val += this[offset + --i] * mul
1827 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1832 Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1833 offset = offset >>> 0
1834 if (!noAssert) checkOffset(offset, 1, this.length)
1835 if (!(this[offset] & 0x80)) return (this[offset])
1836 return ((0xff - this[offset] + 1) * -1)
1839 Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1840 offset = offset >>> 0
1841 if (!noAssert) checkOffset(offset, 2, this.length)
1842 var val = this[offset] | (this[offset + 1] << 8)
1843 return (val & 0x8000) ? val | 0xFFFF0000 : val
1846 Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1847 offset = offset >>> 0
1848 if (!noAssert) checkOffset(offset, 2, this.length)
1849 var val = this[offset + 1] | (this[offset] << 8)
1850 return (val & 0x8000) ? val | 0xFFFF0000 : val
1853 Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1854 offset = offset >>> 0
1855 if (!noAssert) checkOffset(offset, 4, this.length)
1857 return (this[offset]) |
1858 (this[offset + 1] << 8) |
1859 (this[offset + 2] << 16) |
1860 (this[offset + 3] << 24)
1863 Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1864 offset = offset >>> 0
1865 if (!noAssert) checkOffset(offset, 4, this.length)
1867 return (this[offset] << 24) |
1868 (this[offset + 1] << 16) |
1869 (this[offset + 2] << 8) |
1873 Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1874 offset = offset >>> 0
1875 if (!noAssert) checkOffset(offset, 4, this.length)
1876 return ieee754.read(this, offset, true, 23, 4)
1879 Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1880 offset = offset >>> 0
1881 if (!noAssert) checkOffset(offset, 4, this.length)
1882 return ieee754.read(this, offset, false, 23, 4)
1885 Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1886 offset = offset >>> 0
1887 if (!noAssert) checkOffset(offset, 8, this.length)
1888 return ieee754.read(this, offset, true, 52, 8)
1891 Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1892 offset = offset >>> 0
1893 if (!noAssert) checkOffset(offset, 8, this.length)
1894 return ieee754.read(this, offset, false, 52, 8)
1897 function checkInt (buf, value, offset, ext, max, min) {
1898 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1899 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1900 if (offset + ext > buf.length) throw new RangeError('Index out of range')
1903 Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1905 offset = offset >>> 0
1906 byteLength = byteLength >>> 0
1908 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1909 checkInt(this, value, offset, byteLength, maxBytes, 0)
1914 this[offset] = value & 0xFF
1915 while (++i < byteLength && (mul *= 0x100)) {
1916 this[offset + i] = (value / mul) & 0xFF
1919 return offset + byteLength
1922 Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1924 offset = offset >>> 0
1925 byteLength = byteLength >>> 0
1927 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1928 checkInt(this, value, offset, byteLength, maxBytes, 0)
1931 var i = byteLength - 1
1933 this[offset + i] = value & 0xFF
1934 while (--i >= 0 && (mul *= 0x100)) {
1935 this[offset + i] = (value / mul) & 0xFF
1938 return offset + byteLength
1941 Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1943 offset = offset >>> 0
1944 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1945 this[offset] = (value & 0xff)
1949 Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1951 offset = offset >>> 0
1952 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1953 this[offset] = (value & 0xff)
1954 this[offset + 1] = (value >>> 8)
1958 Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1960 offset = offset >>> 0
1961 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1962 this[offset] = (value >>> 8)
1963 this[offset + 1] = (value & 0xff)
1967 Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1969 offset = offset >>> 0
1970 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1971 this[offset + 3] = (value >>> 24)
1972 this[offset + 2] = (value >>> 16)
1973 this[offset + 1] = (value >>> 8)
1974 this[offset] = (value & 0xff)
1978 Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1980 offset = offset >>> 0
1981 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1982 this[offset] = (value >>> 24)
1983 this[offset + 1] = (value >>> 16)
1984 this[offset + 2] = (value >>> 8)
1985 this[offset + 3] = (value & 0xff)
1989 Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1991 offset = offset >>> 0
1993 var limit = Math.pow(2, (8 * byteLength) - 1)
1995 checkInt(this, value, offset, byteLength, limit - 1, -limit)
2001 this[offset] = value & 0xFF
2002 while (++i < byteLength && (mul *= 0x100)) {
2003 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
2006 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
2009 return offset + byteLength
2012 Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
2014 offset = offset >>> 0
2016 var limit = Math.pow(2, (8 * byteLength) - 1)
2018 checkInt(this, value, offset, byteLength, limit - 1, -limit)
2021 var i = byteLength - 1
2024 this[offset + i] = value & 0xFF
2025 while (--i >= 0 && (mul *= 0x100)) {
2026 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
2029 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
2032 return offset + byteLength
2035 Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
2037 offset = offset >>> 0
2038 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
2039 if (value < 0) value = 0xff + value + 1
2040 this[offset] = (value & 0xff)
2044 Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
2046 offset = offset >>> 0
2047 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
2048 this[offset] = (value & 0xff)
2049 this[offset + 1] = (value >>> 8)
2053 Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
2055 offset = offset >>> 0
2056 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
2057 this[offset] = (value >>> 8)
2058 this[offset + 1] = (value & 0xff)
2062 Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
2064 offset = offset >>> 0
2065 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
2066 this[offset] = (value & 0xff)
2067 this[offset + 1] = (value >>> 8)
2068 this[offset + 2] = (value >>> 16)
2069 this[offset + 3] = (value >>> 24)
2073 Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
2075 offset = offset >>> 0
2076 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
2077 if (value < 0) value = 0xffffffff + value + 1
2078 this[offset] = (value >>> 24)
2079 this[offset + 1] = (value >>> 16)
2080 this[offset + 2] = (value >>> 8)
2081 this[offset + 3] = (value & 0xff)
2085 function checkIEEE754 (buf, value, offset, ext, max, min) {
2086 if (offset + ext > buf.length) throw new RangeError('Index out of range')
2087 if (offset < 0) throw new RangeError('Index out of range')
2090 function writeFloat (buf, value, offset, littleEndian, noAssert) {
2092 offset = offset >>> 0
2094 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
2096 ieee754.write(buf, value, offset, littleEndian, 23, 4)
2100 Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
2101 return writeFloat(this, value, offset, true, noAssert)
2104 Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
2105 return writeFloat(this, value, offset, false, noAssert)
2108 function writeDouble (buf, value, offset, littleEndian, noAssert) {
2110 offset = offset >>> 0
2112 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
2114 ieee754.write(buf, value, offset, littleEndian, 52, 8)
2118 Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
2119 return writeDouble(this, value, offset, true, noAssert)
2122 Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
2123 return writeDouble(this, value, offset, false, noAssert)
2126 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
2127 Buffer.prototype.copy = function copy (target, targetStart, start, end) {
2128 if (!start) start = 0
2129 if (!end && end !== 0) end = this.length
2130 if (targetStart >= target.length) targetStart = target.length
2131 if (!targetStart) targetStart = 0
2132 if (end > 0 && end < start) end = start
2134 // Copy 0 bytes; we're done
2135 if (end === start) return 0
2136 if (target.length === 0 || this.length === 0) return 0
2138 // Fatal error conditions
2139 if (targetStart < 0) {
2140 throw new RangeError('targetStart out of bounds')
2142 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
2143 if (end < 0) throw new RangeError('sourceEnd out of bounds')
2146 if (end > this.length) end = this.length
2147 if (target.length - targetStart < end - start) {
2148 end = target.length - targetStart + start
2151 var len = end - start
2154 if (this === target && start < targetStart && targetStart < end) {
2155 // descending copy from end
2156 for (i = len - 1; i >= 0; --i) {
2157 target[i + targetStart] = this[i + start]
2159 } else if (len < 1000) {
2160 // ascending copy from start
2161 for (i = 0; i < len; ++i) {
2162 target[i + targetStart] = this[i + start]
2165 Uint8Array.prototype.set.call(
2167 this.subarray(start, start + len),
2176 // buffer.fill(number[, offset[, end]])
2177 // buffer.fill(buffer[, offset[, end]])
2178 // buffer.fill(string[, offset[, end]][, encoding])
2179 Buffer.prototype.fill = function fill (val, start, end, encoding) {
2180 // Handle string cases:
2181 if (typeof val === 'string') {
2182 if (typeof start === 'string') {
2186 } else if (typeof end === 'string') {
2190 if (val.length === 1) {
2191 var code = val.charCodeAt(0)
2196 if (encoding !== undefined && typeof encoding !== 'string') {
2197 throw new TypeError('encoding must be a string')
2199 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
2200 throw new TypeError('Unknown encoding: ' + encoding)
2202 } else if (typeof val === 'number') {
2206 // Invalid ranges are not set to a default, so can range check early.
2207 if (start < 0 || this.length < start || this.length < end) {
2208 throw new RangeError('Out of range index')
2216 end = end === undefined ? this.length : end >>> 0
2221 if (typeof val === 'number') {
2222 for (i = start; i < end; ++i) {
2226 var bytes = Buffer.isBuffer(val)
2228 : new Buffer(val, encoding)
2229 var len = bytes.length
2230 for (i = 0; i < end - start; ++i) {
2231 this[i + start] = bytes[i % len]
2241 var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
2243 function base64clean (str) {
2244 // Node strips out invalid characters like \n and \t from the string, base64-js does not
2245 str = str.trim().replace(INVALID_BASE64_RE, '')
2246 // Node converts strings with length < 2 to ''
2247 if (str.length < 2) return ''
2248 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2249 while (str.length % 4 !== 0) {
2255 function toHex (n) {
2256 if (n < 16) return '0' + n.toString(16)
2257 return n.toString(16)
2260 function utf8ToBytes (string, units) {
2261 units = units || Infinity
2263 var length = string.length
2264 var leadSurrogate = null
2267 for (var i = 0; i < length; ++i) {
2268 codePoint = string.charCodeAt(i)
2270 // is surrogate component
2271 if (codePoint > 0xD7FF && codePoint < 0xE000) {
2272 // last char was a lead
2273 if (!leadSurrogate) {
2275 if (codePoint > 0xDBFF) {
2277 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2279 } else if (i + 1 === length) {
2281 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2286 leadSurrogate = codePoint
2292 if (codePoint < 0xDC00) {
2293 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2294 leadSurrogate = codePoint
2298 // valid surrogate pair
2299 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
2300 } else if (leadSurrogate) {
2301 // valid bmp char, but last char was a lead
2302 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2305 leadSurrogate = null
2308 if (codePoint < 0x80) {
2309 if ((units -= 1) < 0) break
2310 bytes.push(codePoint)
2311 } else if (codePoint < 0x800) {
2312 if ((units -= 2) < 0) break
2314 codePoint >> 0x6 | 0xC0,
2315 codePoint & 0x3F | 0x80
2317 } else if (codePoint < 0x10000) {
2318 if ((units -= 3) < 0) break
2320 codePoint >> 0xC | 0xE0,
2321 codePoint >> 0x6 & 0x3F | 0x80,
2322 codePoint & 0x3F | 0x80
2324 } else if (codePoint < 0x110000) {
2325 if ((units -= 4) < 0) break
2327 codePoint >> 0x12 | 0xF0,
2328 codePoint >> 0xC & 0x3F | 0x80,
2329 codePoint >> 0x6 & 0x3F | 0x80,
2330 codePoint & 0x3F | 0x80
2333 throw new Error('Invalid code point')
2340 function asciiToBytes (str) {
2342 for (var i = 0; i < str.length; ++i) {
2343 // Node's code seems to be doing this and not & 0x7F..
2344 byteArray.push(str.charCodeAt(i) & 0xFF)
2349 function utf16leToBytes (str, units) {
2352 for (var i = 0; i < str.length; ++i) {
2353 if ((units -= 2) < 0) break
2355 c = str.charCodeAt(i)
2365 function base64ToBytes (str) {
2366 return base64.toByteArray(base64clean(str))
2369 function blitBuffer (src, dst, offset, length) {
2370 for (var i = 0; i < length; ++i) {
2371 if ((i + offset >= dst.length) || (i >= src.length)) break
2372 dst[i + offset] = src[i]
2377 // ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
2378 // but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
2379 function isArrayBuffer (obj) {
2380 return obj instanceof ArrayBuffer ||
2381 (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
2382 typeof obj.byteLength === 'number')
2385 // Node 0.10 supports `ArrayBuffer` but lacks `ArrayBuffer.isView`
2386 function isArrayBufferView (obj) {
2387 return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj)
2390 function numberIsNaN (obj) {
2391 return obj !== obj // eslint-disable-line no-self-compare
2394 },{"base64-js":3,"ieee754":17}],8:[function(require,module,exports){
2397 module.exports = earcut;
2398 module.exports.default = earcut;
2400 function earcut(data, holeIndices, dim) {
2404 var hasHoles = holeIndices && holeIndices.length,
2405 outerLen = hasHoles ? holeIndices[0] * dim : data.length,
2406 outerNode = linkedList(data, 0, outerLen, dim, true),
2409 if (!outerNode) return triangles;
2411 var minX, minY, maxX, maxY, x, y, invSize;
2413 if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
2415 // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
2416 if (data.length > 80 * dim) {
2417 minX = maxX = data[0];
2418 minY = maxY = data[1];
2420 for (var i = dim; i < outerLen; i += dim) {
2423 if (x < minX) minX = x;
2424 if (y < minY) minY = y;
2425 if (x > maxX) maxX = x;
2426 if (y > maxY) maxY = y;
2429 // minX, minY and invSize are later used to transform coords into integers for z-order calculation
2430 invSize = Math.max(maxX - minX, maxY - minY);
2431 invSize = invSize !== 0 ? 1 / invSize : 0;
2434 earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
2439 // create a circular doubly linked list from polygon points in the specified winding order
2440 function linkedList(data, start, end, dim, clockwise) {
2443 if (clockwise === (signedArea(data, start, end, dim) > 0)) {
2444 for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
2446 for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
2449 if (last && equals(last, last.next)) {
2457 // eliminate colinear or duplicate points
2458 function filterPoints(start, end) {
2459 if (!start) return start;
2460 if (!end) end = start;
2467 if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
2470 if (p === p.next) break;
2476 } while (again || p !== end);
2481 // main ear slicing loop which triangulates a polygon (given as a linked list)
2482 function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
2485 // interlink polygon nodes in z-order
2486 if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
2491 // iterate through ears, slicing them one by one
2492 while (ear.prev !== ear.next) {
2496 if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
2497 // cut off the triangle
2498 triangles.push(prev.i / dim);
2499 triangles.push(ear.i / dim);
2500 triangles.push(next.i / dim);
2504 // skipping the next vertice leads to less sliver triangles
2513 // if we looped through the whole remaining polygon and can't find any more ears
2515 // try filtering points and slicing again
2517 earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
2519 // if this didn't work, try curing all small self-intersections locally
2520 } else if (pass === 1) {
2521 ear = cureLocalIntersections(ear, triangles, dim);
2522 earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
2524 // as a last resort, try splitting the remaining polygon into two
2525 } else if (pass === 2) {
2526 splitEarcut(ear, triangles, dim, minX, minY, invSize);
2534 // check whether a polygon node forms a valid ear with adjacent nodes
2535 function isEar(ear) {
2540 if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
2542 // now make sure we don't have other points inside the potential ear
2543 var p = ear.next.next;
2545 while (p !== ear.prev) {
2546 if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2547 area(p.prev, p, p.next) >= 0) return false;
2554 function isEarHashed(ear, minX, minY, invSize) {
2559 if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
2561 // triangle bbox; min & max are calculated like this for speed
2562 var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x),
2563 minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y),
2564 maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x),
2565 maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y);
2567 // z-order range for the current triangle bbox;
2568 var minZ = zOrder(minTX, minTY, minX, minY, invSize),
2569 maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
2574 // look for points inside the triangle in both directions
2575 while (p && p.z >= minZ && n && n.z <= maxZ) {
2576 if (p !== ear.prev && p !== ear.next &&
2577 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2578 area(p.prev, p, p.next) >= 0) return false;
2581 if (n !== ear.prev && n !== ear.next &&
2582 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
2583 area(n.prev, n, n.next) >= 0) return false;
2587 // look for remaining points in decreasing z-order
2588 while (p && p.z >= minZ) {
2589 if (p !== ear.prev && p !== ear.next &&
2590 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2591 area(p.prev, p, p.next) >= 0) return false;
2595 // look for remaining points in increasing z-order
2596 while (n && n.z <= maxZ) {
2597 if (n !== ear.prev && n !== ear.next &&
2598 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
2599 area(n.prev, n, n.next) >= 0) return false;
2606 // go through all polygon nodes and cure small local self-intersections
2607 function cureLocalIntersections(start, triangles, dim) {
2613 if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
2615 triangles.push(a.i / dim);
2616 triangles.push(p.i / dim);
2617 triangles.push(b.i / dim);
2619 // remove two nodes involved
2626 } while (p !== start);
2631 // try splitting polygon into two and triangulate them independently
2632 function splitEarcut(start, triangles, dim, minX, minY, invSize) {
2633 // look for a valid diagonal that divides the polygon into two
2636 var b = a.next.next;
2637 while (b !== a.prev) {
2638 if (a.i !== b.i && isValidDiagonal(a, b)) {
2639 // split the polygon in two by the diagonal
2640 var c = splitPolygon(a, b);
2642 // filter colinear points around the cuts
2643 a = filterPoints(a, a.next);
2644 c = filterPoints(c, c.next);
2646 // run earcut on each half
2647 earcutLinked(a, triangles, dim, minX, minY, invSize);
2648 earcutLinked(c, triangles, dim, minX, minY, invSize);
2654 } while (a !== start);
2657 // link every hole into the outer loop, producing a single-ring polygon without holes
2658 function eliminateHoles(data, holeIndices, outerNode, dim) {
2660 i, len, start, end, list;
2662 for (i = 0, len = holeIndices.length; i < len; i++) {
2663 start = holeIndices[i] * dim;
2664 end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
2665 list = linkedList(data, start, end, dim, false);
2666 if (list === list.next) list.steiner = true;
2667 queue.push(getLeftmost(list));
2670 queue.sort(compareX);
2672 // process holes from left to right
2673 for (i = 0; i < queue.length; i++) {
2674 eliminateHole(queue[i], outerNode);
2675 outerNode = filterPoints(outerNode, outerNode.next);
2681 function compareX(a, b) {
2685 // find a bridge between vertices that connects hole with an outer ring and and link it
2686 function eliminateHole(hole, outerNode) {
2687 outerNode = findHoleBridge(hole, outerNode);
2689 var b = splitPolygon(outerNode, hole);
2690 filterPoints(b, b.next);
2694 // David Eberly's algorithm for finding a bridge between hole and outer polygon
2695 function findHoleBridge(hole, outerNode) {
2702 // find a segment intersected by a ray from the hole's leftmost point to the left;
2703 // segment's endpoint with lesser x will be potential connection point
2705 if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
2706 var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
2707 if (x <= hx && x > qx) {
2710 if (hy === p.y) return p;
2711 if (hy === p.next.y) return p.next;
2713 m = p.x < p.next.x ? p : p.next;
2717 } while (p !== outerNode);
2719 if (!m) return null;
2721 if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint
2723 // look for points inside the triangle of hole point, segment intersection and endpoint;
2724 // if there are no points found, we have a valid connection;
2725 // otherwise choose the point of the minimum angle with the ray as connection point
2735 while (p !== stop) {
2736 if (hx >= p.x && p.x >= mx && hx !== p.x &&
2737 pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
2739 tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
2741 if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) {
2753 // interlink polygon nodes in z-order
2754 function indexCurve(start, minX, minY, invSize) {
2757 if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize);
2761 } while (p !== start);
2763 p.prevZ.nextZ = null;
2769 // Simon Tatham's linked list merge sort algorithm
2770 // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
2771 function sortLinked(list) {
2772 var i, p, q, e, tail, numMerges, pSize, qSize,
2785 for (i = 0; i < inSize; i++) {
2792 while (pSize > 0 || (qSize > 0 && q)) {
2794 if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
2804 if (tail) tail.nextZ = e;
2817 } while (numMerges > 1);
2822 // z-order of a point given coords and inverse of the longer side of data bbox
2823 function zOrder(x, y, minX, minY, invSize) {
2824 // coords are transformed into non-negative 15-bit integer range
2825 x = 32767 * (x - minX) * invSize;
2826 y = 32767 * (y - minY) * invSize;
2828 x = (x | (x << 8)) & 0x00FF00FF;
2829 x = (x | (x << 4)) & 0x0F0F0F0F;
2830 x = (x | (x << 2)) & 0x33333333;
2831 x = (x | (x << 1)) & 0x55555555;
2833 y = (y | (y << 8)) & 0x00FF00FF;
2834 y = (y | (y << 4)) & 0x0F0F0F0F;
2835 y = (y | (y << 2)) & 0x33333333;
2836 y = (y | (y << 1)) & 0x55555555;
2838 return x | (y << 1);
2841 // find the leftmost node of a polygon ring
2842 function getLeftmost(start) {
2846 if (p.x < leftmost.x) leftmost = p;
2848 } while (p !== start);
2853 // check if a point lies within a convex triangle
2854 function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
2855 return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
2856 (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
2857 (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
2860 // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
2861 function isValidDiagonal(a, b) {
2862 return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) &&
2863 locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b);
2866 // signed area of a triangle
2867 function area(p, q, r) {
2868 return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
2871 // check if two points are equal
2872 function equals(p1, p2) {
2873 return p1.x === p2.x && p1.y === p2.y;
2876 // check if two segments intersect
2877 function intersects(p1, q1, p2, q2) {
2878 if ((equals(p1, q1) && equals(p2, q2)) ||
2879 (equals(p1, q2) && equals(p2, q1))) return true;
2880 return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 &&
2881 area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
2884 // check if a polygon diagonal intersects any polygon segments
2885 function intersectsPolygon(a, b) {
2888 if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
2889 intersects(p, p.next, a, b)) return true;
2896 // check if a polygon diagonal is locally inside the polygon
2897 function locallyInside(a, b) {
2898 return area(a.prev, a, a.next) < 0 ?
2899 area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
2900 area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
2903 // check if the middle point of a polygon diagonal is inside the polygon
2904 function middleInside(a, b) {
2907 px = (a.x + b.x) / 2,
2908 py = (a.y + b.y) / 2;
2910 if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
2911 (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
2919 // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
2920 // if one belongs to the outer ring and another to a hole, it merges it into a single ring
2921 function splitPolygon(a, b) {
2922 var a2 = new Node(a.i, a.x, a.y),
2923 b2 = new Node(b.i, b.x, b.y),
2942 // create a node and optionally link it with previous one (in a circular doubly linked list)
2943 function insertNode(i, x, y, last) {
2944 var p = new Node(i, x, y);
2959 function removeNode(p) {
2960 p.next.prev = p.prev;
2961 p.prev.next = p.next;
2963 if (p.prevZ) p.prevZ.nextZ = p.nextZ;
2964 if (p.nextZ) p.nextZ.prevZ = p.prevZ;
2967 function Node(i, x, y) {
2968 // vertice index in coordinates array
2971 // vertex coordinates
2975 // previous and next vertice nodes in a polygon ring
2979 // z-order curve value
2982 // previous and next nodes in z-order
2986 // indicates whether this is a steiner point
2987 this.steiner = false;
2990 // return a percentage difference between the polygon area and its triangulation area;
2991 // used to verify correctness of triangulation
2992 earcut.deviation = function (data, holeIndices, dim, triangles) {
2993 var hasHoles = holeIndices && holeIndices.length;
2994 var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
2996 var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
2998 for (var i = 0, len = holeIndices.length; i < len; i++) {
2999 var start = holeIndices[i] * dim;
3000 var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
3001 polygonArea -= Math.abs(signedArea(data, start, end, dim));
3005 var trianglesArea = 0;
3006 for (i = 0; i < triangles.length; i += 3) {
3007 var a = triangles[i] * dim;
3008 var b = triangles[i + 1] * dim;
3009 var c = triangles[i + 2] * dim;
3010 trianglesArea += Math.abs(
3011 (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
3012 (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
3015 return polygonArea === 0 && trianglesArea === 0 ? 0 :
3016 Math.abs((trianglesArea - polygonArea) / polygonArea);
3019 function signedArea(data, start, end, dim) {
3021 for (var i = start, j = end - dim; i < end; i += dim) {
3022 sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
3028 // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
3029 earcut.flatten = function (data) {
3030 var dim = data[0][0].length,
3031 result = {vertices: [], holes: [], dimensions: dim},
3034 for (var i = 0; i < data.length; i++) {
3035 for (var j = 0; j < data[i].length; j++) {
3036 for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
3039 holeIndex += data[i - 1].length;
3040 result.holes.push(holeIndex);
3046 },{}],9:[function(require,module,exports){
3049 var OneVersionConstraint = require('individual/one-version');
3051 var MY_VERSION = '7';
3052 OneVersionConstraint('ev-store', MY_VERSION);
3054 var hashKey = '__EV_STORE_KEY@' + MY_VERSION;
3056 module.exports = EvStore;
3058 function EvStore(elem) {
3059 var hash = elem[hashKey];
3062 hash = elem[hashKey] = {};
3068 },{"individual/one-version":19}],10:[function(require,module,exports){
3070 var request = require('./request');
3071 var buildQueryObject = require('./buildQueryObject');
3072 var isArray = Array.isArray;
3074 function simpleExtend(obj, obj2) {
3076 for (prop in obj2) {
3077 obj[prop] = obj2[prop];
3082 function XMLHttpSource(jsongUrl, config) {
3083 this._jsongUrl = jsongUrl;
3084 if (typeof config === 'number') {
3090 this._config = simpleExtend({
3096 XMLHttpSource.prototype = {
3097 // because javascript
3098 constructor: XMLHttpSource,
3100 * buildQueryObject helper
3102 buildQueryObject: buildQueryObject,
3105 * @inheritDoc DataSource#get
3107 get: function httpSourceGet(pathSet) {
3109 var queryObject = this.buildQueryObject(this._jsongUrl, method, {
3113 var config = simpleExtend(queryObject, this._config);
3114 // pass context for onBeforeRequest callback
3116 return request(method, config, context);
3120 * @inheritDoc DataSource#set
3122 set: function httpSourceSet(jsongEnv) {
3123 var method = 'POST';
3124 var queryObject = this.buildQueryObject(this._jsongUrl, method, {
3125 jsonGraph: jsongEnv,
3128 var config = simpleExtend(queryObject, this._config);
3129 config.headers["Content-Type"] = "application/x-www-form-urlencoded";
3131 // pass context for onBeforeRequest callback
3133 return request(method, config, context);
3138 * @inheritDoc DataSource#call
3140 call: function httpSourceCall(callPath, args, pathSuffix, paths) {
3141 // arguments defaults
3143 pathSuffix = pathSuffix || [];
3144 paths = paths || [];
3146 var method = 'POST';
3148 queryData.push('method=call');
3149 queryData.push('callPath=' + encodeURIComponent(JSON.stringify(callPath)));
3150 queryData.push('arguments=' + encodeURIComponent(JSON.stringify(args)));
3151 queryData.push('pathSuffixes=' + encodeURIComponent(JSON.stringify(pathSuffix)));
3152 queryData.push('paths=' + encodeURIComponent(JSON.stringify(paths)));
3154 var queryObject = this.buildQueryObject(this._jsongUrl, method, queryData.join('&'));
3155 var config = simpleExtend(queryObject, this._config);
3156 config.headers["Content-Type"] = "application/x-www-form-urlencoded";
3158 // pass context for onBeforeRequest callback
3160 return request(method, config, context);
3164 XMLHttpSource.XMLHttpSource = XMLHttpSource;
3165 XMLHttpSource['default'] = XMLHttpSource;
3167 module.exports = XMLHttpSource;
3169 },{"./buildQueryObject":11,"./request":14}],11:[function(require,module,exports){
3171 module.exports = function buildQueryObject(url, method, queryData) {
3174 var data = {url: url};
3175 var isQueryParamUrl = url.indexOf('?') !== -1;
3176 var startUrl = (isQueryParamUrl) ? '&' : '?';
3178 if (typeof queryData === 'string') {
3179 qData.push(queryData);
3182 keys = Object.keys(queryData);
3183 keys.forEach(function (k) {
3184 var value = (typeof queryData[k] === 'object') ? JSON.stringify(queryData[k]) : queryData[k];
3185 qData.push(k + '=' + encodeURIComponent(value));
3189 if (method === 'GET') {
3190 data.url += startUrl + qData.join('&');
3192 data.data = qData.join('&');
3198 },{}],12:[function(require,module,exports){
3201 // Get CORS support even for older IE
3202 module.exports = function getCORSRequest() {
3203 var xhr = new global.XMLHttpRequest();
3204 if ('withCredentials' in xhr) {
3206 } else if (!!global.XDomainRequest) {
3207 return new XDomainRequest();
3209 throw new Error('CORS is not supported by your browser');
3213 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3215 },{}],13:[function(require,module,exports){
3218 module.exports = function getXMLHttpRequest() {
3222 if (global.XMLHttpRequest) {
3223 return new global.XMLHttpRequest();
3226 progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
3227 for (i = 0; i < 3; i++) {
3229 progId = progIds[i];
3230 if (new global.ActiveXObject(progId)) {
3235 return new global.ActiveXObject(progId);
3237 throw new Error('XMLHttpRequest is not supported by your browser');
3242 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3244 },{}],14:[function(require,module,exports){
3246 var getXMLHttpRequest = require('./getXMLHttpRequest');
3247 var getCORSRequest = require('./getCORSRequest');
3248 var hasOwnProp = Object.prototype.hasOwnProperty;
3250 var noop = function() {};
3252 function Observable() {}
3254 Observable.create = function(subscribe) {
3255 var o = new Observable();
3257 o.subscribe = function(onNext, onError, onCompleted) {
3262 if (typeof onNext === 'function') {
3265 onError: (onError || noop),
3266 onCompleted: (onCompleted || noop)
3272 disposable = subscribe(observer);
3274 if (typeof disposable === 'function') {
3286 function request(method, options, context) {
3287 return Observable.create(function requestObserver(observer) {
3290 method: method || 'GET',
3294 responseType: 'json'
3303 for (prop in options) {
3304 if (hasOwnProp.call(options, prop)) {
3305 config[prop] = options[prop];
3309 // Add request with Headers
3310 if (!config.crossDomain && !config.headers['X-Requested-With']) {
3311 config.headers['X-Requested-With'] = 'XMLHttpRequest';
3314 // allow the user to mutate the config open
3315 if (context.onBeforeRequest != null) {
3316 context.onBeforeRequest(config);
3321 xhr = config.crossDomain ? getCORSRequest() : getXMLHttpRequest();
3323 observer.onError(err);
3326 // Takes the url and opens the connection
3328 xhr.open(config.method, config.url, config.async, config.user, config.password);
3330 xhr.open(config.method, config.url, config.async);
3333 // Sets timeout information
3334 xhr.timeout = config.timeout;
3336 // Anything but explicit false results in true.
3337 xhr.withCredentials = config.withCredentials !== false;
3339 // Fills the request headers
3340 headers = config.headers;
3341 for (header in headers) {
3342 if (hasOwnProp.call(headers, header)) {
3343 xhr.setRequestHeader(header, headers[header]);
3347 if (config.responseType) {
3349 xhr.responseType = config.responseType;
3351 // WebKit added support for the json responseType value on 09/03/2013
3352 // https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are
3353 // known to throw when setting the value "json" as the response type. Other older
3354 // browsers implementing the responseType
3356 // The json response type can be ignored if not supported, because JSON payloads are
3357 // parsed on the client-side regardless.
3358 if (config.responseType !== 'json') {
3364 xhr.onreadystatechange = function onreadystatechange(e) {
3366 if (xhr.readyState === 4) {
3369 onXhrLoad(observer, xhr, e);
3375 xhr.ontimeout = function ontimeout(e) {
3378 onXhrError(observer, xhr, 'timeout error', e);
3383 xhr.send(config.data);
3386 observer.onError(e);
3389 return function dispose() {
3390 // Doesn't work in IE9
3391 if (!isDone && xhr.readyState !== 4) {
3400 * General handling of ultimate failure (after appropriate retries)
3402 function _handleXhrError(observer, textStatus, errorThrown) {
3403 // IE9: cross-domain request may be considered errors
3405 errorThrown = new Error(textStatus);
3408 observer.onError(errorThrown);
3411 function onXhrLoad(observer, xhr, e) {
3416 // If there's no observer, the request has been (or is being) cancelled.
3417 if (xhr && observer) {
3418 responseType = xhr.responseType;
3419 // responseText is the old-school way of retrieving response (supported by IE8 & 9)
3420 // response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
3421 responseData = ('response' in xhr) ? xhr.response : xhr.responseText;
3423 // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
3424 var status = (xhr.status === 1223) ? 204 : xhr.status;
3426 if (status >= 200 && status <= 399) {
3428 if (responseType !== 'json') {
3429 responseData = JSON.parse(responseData || '');
3431 if (typeof responseData === 'string') {
3432 responseData = JSON.parse(responseData || '');
3435 _handleXhrError(observer, 'invalid json', e);
3437 observer.onNext(responseData);
3438 observer.onCompleted();
3441 } else if (status === 401 || status === 403 || status === 407) {
3443 return _handleXhrError(observer, responseData);
3445 } else if (status === 410) {
3447 return _handleXhrError(observer, responseData);
3449 } else if (status === 408 || status === 504) {
3451 return _handleXhrError(observer, responseData);
3455 return _handleXhrError(observer, responseData || ('Response code ' + status));
3461 function onXhrError(observer, xhr, status, e) {
3462 _handleXhrError(observer, status || xhr.statusText || 'request error', e);
3465 module.exports = request;
3467 },{"./getCORSRequest":12,"./getXMLHttpRequest":13}],15:[function(require,module,exports){
3469 !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.falcor=t()}}(function(){var t;return function e(t,n,r){function o(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var p=n[s]={exports:{}};t[s][0].call(p.exports,function(e){var n=t[s][1][e];return o(n?n:e)},p,p.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(t,e,n){var r=t(32),o=t(130);r.atom=o.atom,r.ref=o.ref,r.error=o.error,r.pathValue=o.pathValue,r.HttpDataSource=t(125),e.exports=r},{125:125,130:130,32:32}],2:[function(t,e,n){function r(t){var e=t||{};this._root=e._root||new o(e),this._path=e.path||e._path||[],this._scheduler=e.scheduler||e._scheduler||new l,this._source=e.source||e._source,this._request=e.request||e._request||new s(this,this._scheduler),this._ID=N++,"number"==typeof e.maxSize?this._maxSize=e.maxSize:this._maxSize=e._maxSize||r.prototype._maxSize,"number"==typeof e.collectRatio?this._collectRatio=e.collectRatio:this._collectRatio=e._collectRatio||r.prototype._collectRatio,(e.boxed||e.hasOwnProperty("_boxed"))&&(this._boxed=e.boxed||e._boxed),(e.materialized||e.hasOwnProperty("_materialized"))&&(this._materialized=e.materialized||e._materialized),"boolean"==typeof e.treatErrorsAsValues?this._treatErrorsAsValues=e.treatErrorsAsValues:e.hasOwnProperty("_treatErrorsAsValues")&&(this._treatErrorsAsValues=e._treatErrorsAsValues),e.cache&&this.setCache(e.cache)}var o=t(4),i=t(3),s=t(55),u=t(64),a=t(65),c=t(61),p=t(63),h=t(73),f=t(75),l=t(74),d=t(81),v=t(84),y=t(49),b=t(134),m=t(88),g=t(100),w=t(96),x=t(102),_=t(98),S=t(99),E=t(77),C=t(76),A=t(130),N=0,k=t(116),O=function(){},P=t(14),j=t(19),D={pathValue:!0,pathSyntax:!0,json:!0,jsonGraph:!0},q=t(72);e.exports=r,r.ref=A.ref,r.atom=A.atom,r.error=A.error,r.pathValue=A.pathValue,r.prototype.constructor=r,r.prototype._materialized=!1,r.prototype._boxed=!1,r.prototype._progressive=!1,r.prototype._treatErrorsAsValues=!1,r.prototype._maxSize=Math.pow(2,53)-1,r.prototype._collectRatio=.75,r.prototype.get=t(71),r.prototype._getWithPaths=t(70),r.prototype.set=function(){var t=k(arguments,D,"set");return t!==!0?new u(function(e){e.onError(t)}):this._set.apply(this,arguments)},r.prototype.preload=function(){var t=k(arguments,q,"preload");if(t!==!0)return new u(function(e){e.onError(t)});var e=Array.prototype.slice.call(arguments),n=this;return new u(function(t){return n.get.apply(n,e).subscribe(function(){},function(e){t.onError(e)},function(){t.onCompleted()})})},r.prototype._set=function(){var t,e=-1,n=arguments.length,r=arguments[n-1];for(w(r)?n-=1:r=void 0,t=new Array(n);++e<n;)t[e]=arguments[e];return a.create(this,t,r)},r.prototype.call=function(){var t,e=-1,n=arguments.length;for(t=new Array(n);++e<n;){var r=arguments[e];t[e]=r;var o=typeof r;if(e>1&&!Array.isArray(r)||0===e&&!Array.isArray(r)&&"string"!==o||1===e&&!Array.isArray(r)&&!x(r))return new u(function(t){t.onError(new Error("Invalid argument"))})}return c.create(this,t)},r.prototype.invalidate=function(){var t,e=-1,n=arguments.length,r=arguments[n-1];for(t=new Array(n);++e<n;)if(t[e]=b.fromPath(arguments[e]),"object"!=typeof t[e])throw new Error("Invalid argument");p.create(this,t,r).subscribe(O,function(t){throw t})},r.prototype.deref=t(5),r.prototype.getValue=t(16),r.prototype.setValue=t(79),r.prototype._getValueSync=t(24),r.prototype._setValueSync=t(80),r.prototype._derefSync=t(6),r.prototype.setCache=function(t){var e=this._root.cache;if(t!==e){var n=this._root,r=this._path;this._path=[],this._root.cache={},"undefined"!=typeof e&&y(n,n.expired,m(e),0),S(t)?C(this,[t]):_(t)?E(this,[t]):g(t)&&E(this,[{json:t}]),this._path=r}else"undefined"==typeof e&&(this._root.cache={});return this},r.prototype.getCache=function(){var t=v(arguments);if(0===t.length)return P(this._root.cache);var e=[{}],n=this._path;return j.getWithPathsAsJSONGraph(this,t,e),this._path=n,e[0].jsonGraph},r.prototype.getVersion=function(t){var e=t&&b.fromPath(t)||[];if(Array.isArray(e)===!1)throw new Error("Model#getVersion must be called with an Array path.");return this._path.length&&(e=this._path.concat(e)),this._getVersion(this,e)},r.prototype._syncCheck=function(t){if(Boolean(this._source)&&this._root.syncRefCount<=0&&this._root.unsafeMode===!1)throw new Error("Model#"+t+" may only be called within the context of a request selector.");return!0},r.prototype._clone=function(t){var e=new r(this);for(var n in t){var o=t[n];"delete"===o?delete e[n]:e[n]=o}return e.setCache=void 0,e},r.prototype.batch=function(t){var e=t;"number"==typeof e?e=new f(Math.round(Math.abs(e))):e&&e.schedule||(e=new h);var n=this._clone();return n._request=new s(n,e),n},r.prototype.unbatch=function(){var t=this._clone();return t._request=new s(t,new l),t},r.prototype.treatErrorsAsValues=function(){return this._clone({_treatErrorsAsValues:!0})},r.prototype.asDataSource=function(){return new i(this)},r.prototype._materialize=function(){return this._clone({_materialized:!0})},r.prototype._dematerialize=function(){return this._clone({_materialized:"delete"})},r.prototype.boxValues=function(){return this._clone({_boxed:!0})},r.prototype.unboxValues=function(){return this._clone({_boxed:"delete"})},r.prototype.withoutDataSource=function(){return this._clone({_source:"delete"})},r.prototype.toJSON=function(){return{$type:"ref",value:this._path}},r.prototype.getPath=function(){return d(this._path)},r.prototype._getBoundValue=t(13),r.prototype._getVersion=t(18),r.prototype._getValueSync=t(17),r.prototype._getPathValuesAsPathMap=j.getWithPathsAsPathMap,r.prototype._getPathValuesAsJSONG=j.getWithPathsAsJSONGraph,r.prototype._setPathValuesAsJSON=t(78),r.prototype._setPathValuesAsJSONG=t(78),r.prototype._setPathValuesAsPathMap=t(78),r.prototype._setPathValuesAsValues=t(78),r.prototype._setPathMapsAsJSON=t(77),r.prototype._setPathMapsAsJSONG=t(77),r.prototype._setPathMapsAsPathMap=t(77),r.prototype._setPathMapsAsValues=t(77),r.prototype._setJSONGsAsJSON=t(76),r.prototype._setJSONGsAsJSONG=t(76),r.prototype._setJSONGsAsPathMap=t(76),r.prototype._setJSONGsAsValues=t(76),r.prototype._setCache=t(77),r.prototype._invalidatePathValuesAsJSON=t(48),r.prototype._invalidatePathMapsAsJSON=t(47)},{100:100,102:102,116:116,13:13,130:130,134:134,14:14,16:16,17:17,18:18,19:19,24:24,3:3,4:4,47:47,48:48,49:49,5:5,55:55,6:6,61:61,63:63,64:64,65:65,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,84:84,88:88,96:96,98:98,99:99}],3:[function(t,e,n){function r(t){this._model=t._materialize().treatErrorsAsValues()}r.prototype.get=function(t){return this._model.get.apply(this._model,t)._toJSONG()},r.prototype.set=function(t){return this._model.set(t)._toJSONG()},r.prototype.call=function(t,e,n,r){var o=[t,e,n].concat(r);return this._model.call.apply(this._model,o)._toJSONG()},e.exports=r},{}],4:[function(t,e,n){function r(t){var e=t||{};this.syncRefCount=0,this.expired=e.expired||[],this.unsafeMode=e.unsafeMode||!1,this.collectionScheduler=e.collectionScheduler||new s,this.cache={},o(e.comparator)&&(this.comparator=e.comparator),o(e.errorSelector)&&(this.errorSelector=e.errorSelector),o(e.onChange)&&(this.onChange=e.onChange)}var o=t(96),i=t(91),s=t(74);r.prototype.errorSelector=function(t,e){return e},r.prototype.comparator=function(t,e){return i(t,"value")&&i(e,"value")?t.value===e.value&&t.$type===e.$type&&t.$expires===e.$expires:t===e},e.exports=r},{74:74,91:91,96:96}],5:[function(t,e,n){function r(t,e){var n,r=!1;try{++t._root.syncRefCount,n=t._derefSync(e)}catch(i){n=i,r=!0}finally{--t._root.syncRefCount}return r?o.Observable["throw"](n):o.Observable["return"](n)}var o=t(159),i=t(134);e.exports=function(t){for(var e=this,n=-1,s=arguments.length-1,u=new Array(s),a=i.fromPath(t);++n<s;)u[n]=i.fromPath(arguments[n+1]);if(0===s)throw new Error("Model#deref requires at least one value path.");return o.Observable.defer(function(){return r(e,a)}).flatMap(function(t){if(Boolean(t)){if(s>0){var n=o.Observable.of(t);return t.get.apply(t,u)["catch"](o.Observable.empty()).concat(n).last().flatMap(function(){return r(e,a)}).filter(function(t){return t})}return o.Observable["return"](t)}if(s>0){var i=u.map(function(t){return a.concat(t)});return e.get.apply(e,i).concat(o.Observable.defer(function(){return r(e,a)})).last().filter(function(t){return t})}return o.Observable.empty()})}},{134:134,159:159}],6:[function(t,e,n){var r=t(134),o=t(13),i=t(8),s=t(118);e.exports=function(t){var e=r.fromPath(t);if(!Array.isArray(e))throw new Error("Model#derefSync must be called with an Array path.");var n=o(this,this._path.concat(e),!1),u=n.path,a=n.value,c=n.found;if(c&&void 0!==a&&(a.$type!==s||void 0!==a.value)){if(a.$type)throw new i;return this._clone({_path:u})}}},{118:118,13:13,134:134,8:8}],7:[function(t,e,n){function r(){this.message=r.message,this.stack=(new Error).stack}r.prototype=new Error,r.prototype.name="BoundJSONGraphModelError",r.message="It is not legal to use the JSON Graph format from a bound Model. JSON Graph format can only be used from a root model.",e.exports=r},{}],8:[function(t,e,n){function r(t,e){this.message=i,this.stack=(new Error).stack,this.boundPath=t,this.shortedPath=e}var o="InvalidModelError",i="The boundPath of the model is not valid since a value or error was found before the path end.";r.prototype=new Error,r.prototype.name=o,r.message=i,e.exports=r},{}],9:[function(t,e,n){function r(t){this.message="An exception was thrown when making a request.",this.stack=(new Error).stack,this.innerError=t}var o="InvalidSourceError";r.prototype=new Error,r.prototype.name=o,r.is=function(t){return t&&t.name===o},e.exports=r},{}],10:[function(t,e,n){function r(){this.message="The allowed number of retries have been exceeded.",this.stack=(new Error).stack}var o="MaxRetryExceededError";r.prototype=new Error,r.prototype.name=o,r.is=function(t){return t&&t.name===o},e.exports=r},{}],11:[function(t,e,n){function r(t,e,n,r,o,h,f){for(var l,d,v=n,y=o,b=r,m=0;;){if(0===m&&b[c]?(m=y.length,d=b[c]):(l=y[m++],d=v[l]),d){var g=d.$type,w=g&&d.value||d;if(m<y.length){if(g){v=d;break}v=d;continue}if(v=d,g&&u(d))break;if(b[c]||i(b,d),g===a){f?s(t,d,h,null,null,null,y,y.length,f):p(t,d),m=0,y=w,b=d,v=e;continue}break}v=void 0;break}if(m<y.length&&void 0!==v){for(var x=[],_=0;m>_;_++)x[_]=y[_];y=x}return[v,y]}var o=t(26),i=o.create,s=t(22),u=t(27),a=t(120),c=t(33),p=t(29).promote;e.exports=r},{120:120,22:22,26:26,27:27,29:29,33:33}],12:[function(t,e,n){var r=t(15),o=t(8),i=t(7);e.exports=function(t,e){return function(n,s,u){var a,c,p,h=u[0],f={values:u,optimizedPaths:[]},l=n._root.cache,d=n._path,v=l,y=d.length,b=[];if(y){if(e)return{criticalError:new i};if(v=r(n,d),v.$type)return{criticalError:new o(d,d)};for(a=[],c=0;y>c;++c)a[c]=d[c]}else a=[],y=0;for(c=0,p=s.length;p>c;c++)t(n,l,v,s[c],0,h,f,b,a,y,e);return f}}},{15:15,7:7,8:8}],13:[function(t,e,n){var r=t(17),o=t(8);e.exports=function(t,e,n){var i,s,u,a,c,p=e,h=e;for(i=t._boxed,n=t._materialized,s=t._treatErrorsAsValues,t._boxed=!0,t._materialized=void 0===n||n,t._treatErrorsAsValues=!0,u=r(t,p.concat(null),!0),t._boxed=i,t._materialized=n,t._treatErrorsAsValues=s,p=u.optimizedPath,a=u.shorted,c=u.found,u=u.value;p.length&&null===p[p.length-1];)p.pop();if(c&&a)throw new o(h,p);return{path:p,value:u,shorted:a,found:c}}},{17:17,8:8}],14:[function(t,e,n){function r(t){var e,n,r,o={},i=Object.keys(t);for(n=0,r=i.length;r>n;n++)e=i[n],s(e)||(o[e]=t[e]);return o}function o(t,e,n){Object.keys(t).filter(function(e){return!s(e)&&t[e]}).forEach(function(n){var s=t[n],u=e[n];if(u||(u=e[n]={}),s.$type){var a,c=s.value&&"object"==typeof s.value,p=!t[i];return a=c||p?r(s):s.value,void(e[n]=a)}o(s,u,n)})}var i=t(37),s=t(97);e.exports=function(t){var e={};return o(t,e),e}},{37:37,97:97}],15:[function(t,e,n){e.exports=function(t,e){for(var n=t._root.cache,r=-1,o=e.length;++r<o&&n&&!n.$type;)n=n[e[r]];return n}},{}],16:[function(t,e,n){var r=t(64),o=t(134);e.exports=function(t){for(var e=o.fromPath(t),n=0,i=e.length;++n<i;)if("object"==typeof e[n])return new r(function(t){t.onError(new Error("Paths must be simple paths"))});var s=this;return new r(function(t){return s.get(e).subscribe(function(n){for(var r=n.json,o=-1,i=e.length;r&&++o<i;)r=r[e[o]];t.onNext(r)},function(e){t.onError(e)},function(){t.onCompleted()})})}},{134:134,64:64}],17:[function(t,e,n){var r=t(11),o=t(25),i=t(27),s=t(29).promote,u=t(120),a=t(118),c=t(119);e.exports=function(t,e,n){for(var p,h,f,l,d,v=t._root.cache,y=e.length,b=[],m=!1,g=!1,w=0,x=v,_=v,S=v,E=!0,C=!1;x&&y>w;){if(p=e[w++],null!==p&&(x=_[p],b[b.length]=p),!x){S=void 0,m=!0,E=!1;break}if(f=x.$type,f===a&&void 0===x.value){S=void 0,E=!1,m=y>w;break}if(y>w){if(f===u){if(i(x)){C=!0,S=void 0,E=!1;break}if(l=r(t,v,v,x,x.value),d=l[0],!d){S=void 0,x=void 0,E=!1;break}f=d.$type,x=d,b=l[1].slice(0)}if(f)break}else S=x;_=x}if(y>w&&!C){for(h=w;y>h;++h)if(null!==e[w]){g=!0;break}for(g?(m=!0,S=void 0):S=x,h=w;y>h;++h)null!==e[h]&&(b[b.length]=e[h])}if(S&&f&&(i(S)?S=void 0:s(t,S)),S&&f===c&&!t._treatErrorsAsValues)throw{path:w===y?e:e.slice(0,w),value:S.value};return S&&t._boxed?S=Boolean(f)&&!n?o(S):S:!S&&t._materialized?S={$type:a}:S&&(S=S.value),{value:S,shorted:m,optimizedPath:b,found:E}}},{11:11,118:118,119:119,120:120,25:25,27:27,29:29}],18:[function(t,e,n){var r=t(46);e.exports=function(t,e){var n=t._getValueSync({_boxed:!0,_root:t._root,_treatErrorsAsValues:t._treatErrorsAsValues},e,!0).value,o=n&&n[r];return null==o?-1:o}},{46:46}],19:[function(t,e,n){var r=t(12),o=t(31),i=r(o,!1),s=r(o,!0);e.exports={getValueSync:t(17),getBoundValue:t(13),getWithPathsAsPathMap:i,getWithPathsAsJSONGraph:s}},{12:12,13:13,17:17,31:31}],20:[function(t,e,n){var r=t(29),o=t(25),i=r.promote;e.exports=function(t,e,n,r,s){var u=e.value;s.errors||(s.errors=[]),t._boxed&&(u=o(e)),s.errors.push({path:r.slice(0,n+1),value:u}),i(t,e)}},{25:25,29:29}],21:[function(t,e,n){function r(t,e,n,r,o,i,s){s.requestedMissingPaths.push(r.slice(0,n).concat(e)),s.optimizedMissingPaths.push(o.slice(0,i).concat(e))}var o=t(30),i=o.fastCopy;e.exports=function(t,e,n,o,s,u,a){var c;o.requestedMissingPaths||(o.requestedMissingPaths=[],o.optimizedMissingPaths=[]),c=n<e.length?i(e,n):[],r(t,c,n,s,u,a,o)}},{30:30}],22:[function(t,e,n){var r=t(29),o=t(25),i=r.promote,s=t(120),u=t(118),a=t(119),c=t(37);e.exports=function(t,e,n,r,p,h,f,l,d,v){if(n){var y,b,m,g,w,x,_,S,E=!1;if(e&&i(t,e),e&&void 0!==e.value||(E=t._materialized),E)S={$type:u};else if(t._boxed)S=o(e);else if(e.$type===s||e.$type===a)S=d?o(e):e.value;else if(d){var C=e.value&&"object"==typeof e.value,A=!e[c];S=C||A?o(e):e.value}else S=e.value;if(p&&(p.hasValue=!0),d){for(w=n.jsonGraph,w||(w=n.jsonGraph={},n.paths=[]),y=0,b=l-1;b>y;y++)g=f[y],w[g]||(w[g]={}),w=w[g];g=f[y],w[g]=E?{$type:u}:S,h&&n.paths.push(h.slice(0,r))}else if(0===r)n.json=S;else{for(w=n.json,w||(w=n.json={}),y=0;r-1>y;y++)m=h[y],w[m]||(w[m]={}),x=w,_=m,w=w[m];m=h[y],null!==m?w[m]=S:x[_]=S}}}},{118:118,119:119,120:120,25:25,29:29,37:37}],23:[function(t,e,n){var r=t(27),o=t(26),i=t(29),s=o.remove,u=i.splice,a=t(119),c=t(20),p=t(22),h=t(21),f=t(28),l=t(35);e.exports=function(t,e,n,o,i,d,v,y,b,m,g){var w=e&&e.$type,x=e&&void 0===e.value;return e&&w?void(r(e)?(e[l]||(u(t,e),s(e)),h(t,n,o,d,v,y,b)):w===a?(g&&(v[o]=null),m||t._treatErrorsAsValues?p(t,e,i,o,d,v,y,b,m,g):c(t,e,o,v,d)):(g&&(v[o]=null),(!x||x&&t._materialized)&&p(t,e,i,o,d,v,y,b,m,g))):void(f(t)?p(t,e,i,o,d,v,y,b,m,g):h(t,n,o,d,v,y,b))}},{119:119,20:20,21:21,22:22,26:26,27:27,28:28,29:29,35:35}],24:[function(t,e,n){var r=t(134);e.exports=function(t){var e=r.fromPath(t);if(Array.isArray(e)===!1)throw new Error("Model#getValueSync must be called with an Array path.");return this._path.length&&(e=this._path.concat(e)),this._syncCheck("getValueSync")&&this._getValueSync(this,e).value}},{134:134}],25:[function(t,e,n){var r=t(40);e.exports=function(t){var e,n,o,i=Object.keys(t);for(e={},n=0,o=i.length;o>n;n++){var s=i[n];s[0]!==r&&(e[s]=t[s])}return e}},{40:40}],26:[function(t,e,n){function r(t,e){var n=e[a]||0;e[i+n]=t,e[a]=n+1,t[u]=n,t[s]=e}function o(t){var e=t[s];if(e){for(var n=t[u],r=e[a];r>n;)e[i+n]=e[i+n+1],++n;e[a]=r-1,t[s]=void 0,t[u]=void 0}}var i=t(43),s=t(33),u=t(42),a=t(44);e.exports={create:r,remove:o}},{33:33,42:42,43:43,44:44}],27:[function(t,e,n){var r=t(106);e.exports=function(t){var e=void 0===t.$expires&&-1||t.$expires;return-1!==e&&1!==e&&(0===e||e<r())}},{106:106}],28:[function(t,e,n){e.exports=function(t){return t._materialized&&!t._source}},{}],29:[function(t,e,n){function r(t,e){var n=t._root,r=n[i];if(r!==e){var o=e[a],s=e[u];s&&(s[a]=o),o&&(o[u]=s),e[a]=void 0,n[i]=e,e[u]=r,r[a]=e}}function o(t,e){var n=t._root,r=e[a],o=e[u];o&&(o[a]=r),r&&(r[u]=o),e[a]=void 0,e===n[i]&&(n[i]=void 0),e===n[s]&&(n[s]=void 0),e[c]=!0,n.expired.push(e)}var i=t(34),s=t(45),u=t(38),a=t(41),c=t(35);e.exports={promote:r,splice:o}},{34:34,35:35,38:38,41:41,45:45}],30:[function(t,e,n){function r(t,e){var n,r,o,i=[];for(r=0,o=e||0,n=t.length;n>o;r++,o++)i[r]=t[o];return i}function o(t,e){var n,r,o,i=[];for(n=0,r=t.length;r>n;n++)i[n]=t[n];for(o=0,r=e.length;r>o;o++)null!==e[o]&&(i[n++]=e[o]);return i}function i(t,e){var n,r,o,i=[];for(n=0,r=t.length;r>n;n++)i[n]=t[n];for(o=0,r=e.length;r>o;o++)i[n++]=e[o];return i}e.exports={fastCat:i,fastCatSkipNulls:o,fastCopy:r}},{}],31:[function(t,e,n){var r=t(11),o=t(23),i=t(27),s=t(143).iterateKeySet,u=t(120),a=t(29).promote;e.exports=function c(t,e,n,p,h,f,l,d,v,y,b,m){var g=m,w=v;if(!n||n&&n.$type||h===p.length)return void o(t,n,p,h,f,l,d,w,y,b,g);var x,_;x=p[h];var S="object"==typeof x,E=h+1,C=!1,A=x;if(S&&(C={},A=s(x,C)),void 0!==A||!C.done){var N=y+1;do{g=!1;var k;null===A?k=n:(k=n[A],w[y]=A,d[h]=A);var O=w,P=N;if(k){var j=k.$type,D=j&&k.value||k;if(E<p.length&&j&&j===u&&!i(k)){b&&o(t,k,p,E,f,l,null,w,P,b,g),a(t,k);var q=r(t,e,e,k,D,f,b);g=!0,k=q[0];var R=q[1];for(O=[],P=R.length,_=0;P>_;++_)O[_]=R[_]}}c(t,e,k,p,E,f,l,d,O,P,b,g),C&&!C.done&&(A=s(x,C))}while(C&&!C.done)}}},{11:11,120:120,143:143,23:23,27:27,29:29}],32:[function(t,e,n){"use strict";function r(t){return new r.Model(t)}"function"==typeof Promise?r.Promise=Promise:r.Promise=t(151),e.exports=r,r.Model=t(2)},{151:151,2:2}],33:[function(t,e,n){e.exports=t(40)+"context"},{40:40}],34:[function(t,e,n){e.exports=t(40)+"head"},{40:40}],35:[function(t,e,n){e.exports=t(40)+"invalidated"},{40:40}],36:[function(t,e,n){e.exports=t(40)+"key"},{40:40}],37:[function(t,e,n){e.exports="$modelCreated"},{}],38:[function(t,e,n){e.exports=t(40)+"next"},{40:40}],39:[function(t,e,n){e.exports=t(40)+"parent"},{40:40}],40:[function(t,e,n){e.exports=String.fromCharCode(30)},{}],41:[function(t,e,n){e.exports=t(40)+"prev"},{40:40}],42:[function(t,e,n){e.exports=t(40)+"ref-index"},{40:40}],43:[function(t,e,n){e.exports=t(40)+"ref"},{40:40}],44:[function(t,e,n){e.exports=t(40)+"refs-length"},{40:40}],45:[function(t,e,n){e.exports=t(40)+"tail"},{40:40}],46:[function(t,e,n){e.exports=t(40)+"version"},{40:40}],47:[function(t,e,n){function r(t,e,n,o,s,u,c,p,h,f){if(!_(t)&&!t.$type)for(var l in t)if(l[0]!==a&&"$"!==l[0]&&m(t,l)){var d=t[l],v=g(d)&&!d.$type,y=i(n,o,s,l,d,v,!1,u,c,p,h,f),w=y[0],x=y[1];w&&(v?r(d,e+1,n,x,w,u,c,p,h,f):A(w,x,l,p)&&C(x,b(w),p,u))}}function o(t,e,n,r,o,s,a,h){if(w(n))return S(n,o,s),[void 0,e];y(s,n);var d=n,v=n.value,b=e;if(n=n[p],null!=n)b=n[c]||e;else{var m=0,g=v.length-1;b=n=e;do{var x=v[m],E=g>m,C=i(e,b,n,x,t,E,!0,r,o,s,a,h);if(n=C[0],_(n))return C;b=C[1]}while(m++<g);if(d[p]!==n){var A=n[l]||0;n[l]=A+1,n[u+A]=d,d[p]=n,d[f]=A}}return[n,b]}function i(t,e,n,r,i,u,a,c,p,h,f,l){for(var v=n.$type;v===d;){var y=o(i,t,n,c,p,h,f,l);if(n=y[0],_(n))return y;e=y[1],v=n&&n.$type}if(void 0!==v)return[n,e];if(null==r){if(u)throw new Error("`null` is not allowed in branch key positions.");n&&(r=n[s])}else e=n,n=e[r];return[n,e]}var s=t(36),u=t(43),a=t(40),c=t(39),p=t(33),h=t(46),f=t(42),l=t(44),d=t(120),v=t(13),y=t(50),b=t(88),m=t(91),g=t(100),w=t(95),x=t(96),_=t(102),S=t(86),E=t(92),C=t(115),A=t(109);e.exports=function(t,e){for(var n=t._root,o=n,i=n.expired,s=E(),u=n._comparator,a=n._errorSelector,p=t._path,f=n.cache,l=p.length?v(t,p).value:f,d=l[c]||f,y=f[h],b=-1,m=e.length;++b<m;){var g=e[b];r(g.json,0,f,d,l,s,i,o,u,a)}var w=f[h],_=n.onChange;x(_)&&y!==w&&_()}},{100:100,102:102,109:109,115:115,120:120,13:13,33:33,36:36,39:39,40:40,42:42,43:43,44:44,46:46,50:50,86:86,88:88,91:91,92:92,95:95,96:96}],48:[function(t,e,n){function r(t,e,n,o,s,u,a,c){var p={},h=e<t.length-1,f=t[e],l=x(f,p);do{var d=i(n,o,s,l,h,!1,u,a,c),v=d[0],b=d[1];v&&(h?r(t,e+1,n,b,v,u,a,c):E(v,b,l,c)&&S(b,y(v),c,u)),l=x(f,p)}while(!p.done)}function o(t,e,n,r,o){if(b(e))return w(e,r,o),[void 0,t];v(o,e);var s=e,p=e.value,l=t;if(e=e[c],null!=e)l=e[a]||t;else{var d=0,y=p.length-1;l=e=t;do{var m=p[d],x=y>d,_=i(t,l,e,m,x,!0,n,r,o);if(e=_[0],g(e))return _;l=_[1]}while(d++<y);if(s[c]!==e){var S=e[f]||0;e[f]=S+1,e[u+S]=s,s[c]=e,s[h]=S}}return[e,l]}function i(t,e,n,r,i,u,a,c,p){for(var h=n.$type;h===l;){var f=o(t,n,a,c,p);if(n=f[0],g(n))return f;e=f[1],h=n.$type}if(void 0!==h)return[n,e];if(null==r){if(i)throw new Error("`null` is not allowed in branch key positions.");n&&(r=n[s])}else e=n,n=e[r];return[n,e]}var s=t(36),u=t(43),a=t(39),c=t(33),p=t(46),h=t(42),f=t(44),l=t(120),d=t(13),v=t(50),y=t(88),b=t(95),m=t(96),g=t(102),w=t(86),x=t(143).iterateKeySet,_=t(92),S=t(115),E=t(109);e.exports=function(t,e){for(var n=t._root,o=n,i=n.expired,s=_(),u=t._path,c=n.cache,h=u.length?d(t,u).value:c,f=h[a]||c,l=c[p],v=-1,y=e.length;++v<y;){var b=e[v];r(b,0,c,f,h,s,i,o)}var g=c[p],w=n.onChange;m(w)&&l!==g&&w()}},{102:102,109:109,115:115,120:120,13:13,143:143,33:33,36:36,39:39,42:42,43:43,44:44,46:46,50:50,86:86,88:88,92:92,95:95,96:96}],49:[function(t,e,n){var r=t(36),o=t(39),i=t(34),s=t(45),u=t(38),a=t(41),c=t(108),p=t(115);e.exports=function(t,e,n,h,f,l){var d=n,v=f;"number"!=typeof v&&(v=.75);var y,b,m,g="number"==typeof l,w=h*v;for(b=e.pop();b;)m=b.$size||0,d-=m,g===!0?p(b,m,t,l):(y=b[o])&&c(b,y,b[r],t),b=e.pop();if(d>=h){var x=t[s];for(b=x;d>=w&&b;)x=x[a],m=b.$size||0,d-=m,g===!0&&p(b,m,t,l),b=x;t[s]=t[a]=b,null==b?t[i]=t[u]=void 0:b[u]=void 0}}},{108:108,115:115,34:34,36:36,38:38,39:39,41:41,45:45}],50:[function(t,e,n){var r=t(121),o=t(34),i=t(45),s=t(38),u=t(41),a=t(100);e.exports=function(t,e){if(a(e)&&e.$expires!==r){var n=t[o],c=t[i],p=e[s],h=e[u];e!==n&&(null!=p&&"object"==typeof p&&(p[u]=h),null!=h&&"object"==typeof h&&(h[s]=p),p=n,null!=n&&"object"==typeof n&&(n[u]=e),t[o]=t[s]=n=e,n[s]=p,n[u]=void 0),null!=c&&e!==c||(t[i]=t[u]=c=h||e)}return e}},{100:100,121:121,34:34,38:38,41:41,45:45}],51:[function(t,e,n){var r=t(34),o=t(45),i=t(38),s=t(41);e.exports=function(t,e){var n=t[r],u=t[o],a=e[i],c=e[s];null!=a&&"object"==typeof a&&(a[s]=c),null!=c&&"object"==typeof c&&(c[i]=a),e===n&&(t[r]=t[i]=a),e===u&&(t[o]=t[s]=c),e[i]=e[s]=void 0,n=u=a=c=void 0}},{34:34,38:38,41:41,45:45}],52:[function(t,e,n){function r(t,e){var n=!1;return function(){if(!n&&!t._disposed){n=!0,t._callbacks[e]=null,t._optimizedPaths[e]=[],t._requestedPaths[e]=[];var r=--t._count;0!==r||t.sent||(t._disposable.dispose(),t.requestQueue.removeRequest(t))}}}function o(t){for(var e=[],n=-1,r=0,o=t.length;o>r;++r)for(var i=t[r],s=0,u=i.length;u>s;++s)e[++n]=i[s];return e}var i=t(59),s=t(60),u=0,a=t(57).GetRequest,c=t(76),p=t(78),h=t(119),f=[],l=function(t,e){this.sent=!1,this.scheduled=!1,this.requestQueue=e,this.id=++u,this.type=a,this._scheduler=t,this._pathMap={},this._optimizedPaths=[],this._requestedPaths=[],this._callbacks=[],this._count=0,this._disposable=null,this._collapsed=null,this._disposed=!1};l.prototype={batch:function(t,e,n){var o=this,i=o._optimizedPaths,u=o._requestedPaths,a=o._callbacks,c=i.length;return i[c]=e,u[c]=t,a[c]=n,++o._count,o.scheduled||(o.scheduled=!0,o._disposable=o._scheduler.schedule(function(){s(o,i,function(t,e){if(o.requestQueue.removeRequest(o),o._disposed=!0,o._count){o._merge(u,t,e);for(var n=0,r=a.length;r>n;++n){var i=a[n];i&&i(t,e)}}})})),r(o,c)},add:function(t,e,n){var o,s,u=this,a=i(t,e,u._pathMap);a?(s=a[2],o=a[1]):(s=t,o=e);var c=!1,p=!1;if(o.length<e.length){c=!0;var h=u._callbacks.length;u._callbacks[h]=n,u._requestedPaths[h]=a[0],u._optimizedPaths[h]=[],++u._count,p=r(u,h)}return[c,s,o,p]},_merge:function(t,e,n){var r=this,i=r.requestQueue.model,s=i._root,u=s.errorSelector,a=s.comparator,l=i._path;i._path=f;var d=o(t);if(e){var v=e;v instanceof Error&&(v={message:v.message}),v.$type||(v={$type:h,value:v});var y=d.map(function(t){return{path:t,value:v}});p(i,y,null,u,a)}else c(i,[{paths:d,jsonGraph:n.jsonGraph}],null,u,a);i._path=l}},e.exports=l},{119:119,57:57,59:59,60:60,76:76,78:78}],53:[function(t,e,n){function r(){this.length=0,this.pending=!1,this.pathmaps=[],s.call(this,this._subscribe)}var o=t(159),i=o.Observer,s=o.Observable,u=o.Disposable,a=o.SerialDisposable,c=o.CompositeDisposable,p=t(9),h=t(143),f=h.iterateKeySet;r.create=function(t,e,n){var r=new this;return r.queue=t,r.model=e,r.index=n,r},r.prototype=Object.create(s.prototype),r.prototype.constructor=r,r.prototype.insertPath=function(t,e,n,r,o){var i=r||0,s=o||t.length-1,u=n||this.pathmaps[s+1]||(this.pathmaps[s+1]=Object.create(null));if(void 0===u||null===u)return!1;var a,c,p=t[i],h={};a=f(p,h);do{if(c=u[a],s>i){if(null==c){if(e)return!1;c=u[a]=Object.create(null)}if(this.insertPath(t,e,c,i+1,s)===!1)return!1}else u[a]=(c||0)+1,this.length+=1;h.done||(a=f(p,h))}while(!h.done);return!0},r.prototype.removePath=function(t,e,n,r){var o=n||0,i=r||t.length-1,s=e||this.pathmaps[i+1];if(void 0===s||null===s)return!0;var u,a,c=0,p=t[o],h={};u=f(p,h);do if(a=s[u],void 0!==a&&null!==a){if(i>o){c+=this.removePath(t,a,o+1,i);var l=void 0;for(l in a)break;void 0===l&&delete s[u]}else a=s[u]=(a||1)-1,0===a&&delete s[u],c+=1,this.length-=1;h.done||(u=f(p,h))}while(!h.done);return c},r.prototype.getSourceObserver=function(t){var e=this;return i.create(function(n){n.jsonGraph=n.jsonGraph||n.jsong||n.values||n.value,n.index=e.index,t.onNext(n)},function(e){t.onError(e)},function(){t.onCompleted()})},r.prototype._subscribe=function(t){var e=this,n=this.queue;e.pending=!0;var r=!1,o=new a,i=u.create(function(){r||(r=!0,n&&n._remove(e))}),s=new c(o,i);try{o.setDisposable(this.model._source[this.method](this.getSourceArgs()).subscribe(this.getSourceObserver(t)))}catch(h){throw new p(h)}return s},e.exports=r},{143:143,159:159,9:9}],54:[function(t,e,n){function r(t,e){this.total=0,this.model=t,this.requests=[],this.scheduler=e}var o=t(58),i=t(40),s=t(90),u=t(100),a=t(143);r.prototype.set=function(t){return t.paths=a.collapse(t.paths),o.create(this.model,t)},r.prototype._remove=function(t){var e=this.requests,n=e.indexOf(t);-1!==n&&e.splice(n,1)},r.prototype.distributePaths=function(t,e,n){var r,o,i=this.model,s=-1,u=t.length,a=-1,c=e.length,p=[];t:for(;++s<u;){var h=t[s];for(a=-1;++a<c;)if(o=e[a],o.insertPath(h,o.pending)){p[a]=o;continue t}r||(r=n.create(this,i,this.total++),e[a]=r,p[c++]=r),r.insertPath(h,!1)}var f=[],l=-1;for(a=-1;++a<c;)o=p[a],null!=o&&(f[++l]=o);return f},r.prototype.mergeJSONGraphs=function(t,e){var n=0,r=[],o=[],a=[],c=t.index,p=e.index;t.index=Math.max(c,p),r[-1]=t.jsonGraph||{},o[-1]=e.jsonGraph||{};t:for(;n>-1;){for(var h=r[n-1],f=o[n-1],l=a[n-1]||(a[n-1]=Object.keys(f));l.length>0;){var d=l.pop();if(d[0]!==i)if(h.hasOwnProperty(d)){var v=h[d],y=s(v),b=f[d],m=s(b);if(u(v)&&u(b)&&!y&&!m){r[n]=v,o[n]=b,n+=1;continue t}p>c&&(h[d]=b)}else h[d]=f[d]}n-=1}return t},e.exports=r},{100:100,143:143,40:40,58:58,90:90}],55:[function(t,e,n){function r(t,e){this.model=t,this.scheduler=e,this.requests=this._requests=[]}var o=t(54),i=t(56);r.prototype.get=i.prototype.get,r.prototype.removeRequest=i.prototype.removeRequest,r.prototype.set=o.prototype.set,r.prototype.call=o.prototype.call,e.exports=r},{54:54,56:56}],56:[function(t,e,n){function r(t,e){this.model=t,this.scheduler=e,this.requests=this._requests=[]}var o=t(57),i=t(52);r.prototype={setScheduler:function(t){this.scheduler=t},get:function(t,e,n){function r(){v||(--h,0===h&&n())}var s,u,a,c=this,p=[],h=0,f=c._requests,l=e,d=t,v=!1;for(s=0,u=f.length;u>s;++s)if(a=f[s],a.type===o.GetRequest){if(a.sent){var y=a.add(d,l,r);y[0]&&(d=y[1],l=y[2],p[p.length]=y[3],++h)}else a.batch(d,l,r),l=[],d=[],++h;if(!l.length)break}if(l.length){a=new i(c.scheduler,c),f[f.length]=a,++h;var b=a.batch(d,l,r);p[p.length]=b}return function(){if(!v&&0!==h){v=!0;for(var t=p.length,e=0;t>e;++e)p[e]()}}},removeRequest:function(t){for(var e=this._requests,n=e.length;--n>=0;)if(e[n].id===t.id){e.splice(n,1);break}}},e.exports=r},{52:52,57:57}],57:[function(t,e,n){e.exports={GetRequest:"GET"}},{}],58:[function(t,e,n){function r(){s.call(this)}var o=t(159),i=o.Observer,s=t(53),u=t(83),a=t(76),c=t(78),p=new Array(0);r.create=function(t,e){var n=new r;return n.model=t,n.jsonGraphEnvelope=e,n},r.prototype=Object.create(s.prototype),r.prototype.constructor=r,r.prototype.method="set",r.prototype.insertPath=function(){return!1},r.prototype.removePath=function(){return 0},r.prototype.getSourceArgs=function(){return this.jsonGraphEnvelope},r.prototype.getSourceObserver=function(t){var e=this.model,n=e._path,r=this.jsonGraphEnvelope.paths,o=e._root,h=o.errorSelector,f=o.comparator;return s.prototype.getSourceObserver.call(this,i.create(function(o){e._path=p;var i=a(e,[{paths:r,jsonGraph:o.jsonGraph}],null,h,f);o.paths=i[1],e._path=n,t.onNext(o)},function(o){e._path=p,c(e,u(r,function(t){return{path:t,value:o}}),null,h,f),e._path=n,t.onError(o)},function(){t.onCompleted()}))},e.exports=r},{159:159,53:53,76:76,78:78,83:83}],59:[function(t,e,n){var r=t(143).hasIntersection,o=t(84);e.exports=function(t,e,n){for(var i=[],s=[],u=[],a=-1,c=-1,p=!1,h=0,f=e.length;f>h;++h){var l=e[h],d=n[l.length];d&&r(d,l,0)?(!p&&h>0&&(s=o(t,0,h),i=o(e,0,h)),u[++a]=t[h],p=!0):p&&(i[++c]=l,s[c]=t[h])}return p?[u,i,s]:null}},{143:143,84:84}],60:[function(t,e,n){var r=t(143),o=r.toTree,i=r.toPaths;e.exports=function(t,e,n){if(0===t._count)return void t.requestQueue.removeRequest(t);t.sent=!0,t.scheduled=!1;for(var r=t._pathMap,s=Object.keys(e),u=0,a=s.length;a>u;++u)for(var c=e[u],p=0,h=c.length;h>p;++p){var f=c[p],l=f.length;if(r[l]){var d=r[l];d[d.length]=f}else r[l]=[f]}for(var v=Object.keys(r),y=0,b=v.length;b>y;++y){var m=v[y];r[m]=o(r[m])}var g,w=t._collasped=i(r);t.requestQueue.model._source.get(w).subscribe(function(t){g=t},function(t){n(t,g)},function(){n(null,g)})}},{143:143}],61:[function(t,e,n){function r(t){u.call(this,t||i)}function o(t){return s.Observable.defer(function(){return t})}function i(t){function e(t){function e(t,e){if(Boolean(e.invalidated))t.invalidations.push(t.localThisPath.concat(e.path));else{var n=e.path,r=e.value;Boolean(r)&&"object"==typeof r&&r.$type===f?t.references.push({path:i(n),value:e.value}):t.values.push({path:i(n),value:e.value})}return t}function n(t){var e=t.values.concat(t.references);return e.length>0?o(g.set.apply(g,e)._toJSONG()).map(function(e){return{results:t,envelope:e}}):u["return"]({results:t,envelope:{jsonGraph:{},paths:[]}})}function r(t){var e,n=t.envelope,r=t.results,c=r.values,p=r.references,h=r.invalidations,f=c.map(a).map(i),l=p.reduce(s,[]),d=b.map(i),v=l.concat(d);return e=v.length>0?o(m.get.apply(m,f.concat(v))._toJSONG()):u["return"](n),e.doAction(function(t){t.invalidated=h})}function s(t,e){var n=e.path;return t.push.apply(t,y.map(function(t){return n.concat(t)})),t}function a(t){return t.path}var c=t&&t.localFn;if("function"==typeof c){var p=t.model,h=p._path,l=c.apply(p,v).reduce(e,{values:[],references:[],invalidations:[],localThisPath:h}).flatMap(n).flatMap(r);return u["return"](l)}return u.empty()}function n(t){function e(t){var e=t.invalidated;return e&&e.length&&m.invalidate.apply(m,e),t}return t&&"object"==typeof t?s.Observable.defer(function(){
3470 var e;try{e=t.call(x,v,y,b)}catch(n){e=u["throw"](new p(n))}return e}).map(e):u.empty()}function r(t){return o(g.set(t)).reduce(function(t){return t},null).map(function(){return{invalidated:t.invalidated,paths:t.paths.map(function(t){return t.slice(w.length)})}})}function i(t){return _.concat(t)}var c=this.args,l=this.model,d=h.fromPath(c[0]),v=c[1]||[],y=(c[2]||[]).map(h.fromPath),b=(c[3]||[]).map(h.fromPath),m=l._clone({_path:[]}),g=m.withoutDataSource(),w=l._path,x=w.concat(d),_=x.slice(0,-1),S=o(l.withoutDataSource().get(d)).map(function(t){for(var e=t.json,n=-1,r=d.length;e&&++n<r;)e=e[d[n]];var o=m._derefSync(_).boxValues();return{model:o,localFn:e}}).flatMap(e).defaultIfEmpty(n(l._source)).mergeAll().flatMap(r),E=new a;return E.add(S.subscribe(function(e){var n=e.paths,r=e.invalidated,i=l.get.apply(l,n);"AsJSONG"===t.outputFormat&&(i=o(i._toJSONG()).doAction(function(t){t.invalidated=r})),E.add(i.subscribe(t))},function(e){t.onError(e)})),E}var s=t(159)&&t(158),u=s.Observable,a=s.CompositeDisposable,c=t(64),p=t(9),h=t(134),f=t(120);r.create=c.create,r.prototype=Object.create(u.prototype),r.prototype.constructor=r,r.prototype.invokeSourceRequest=function(t){return this},r.prototype.ensureCollect=function(t){return this},r.prototype.initialize=function(){return this},e.exports=r},{120:120,134:134,158:158,159:159,64:64,9:9}],62:[function(t,e,n){function r(t){i.call(this,t)}var o=t(159),i=o.Observable,s=t(64),u=t(134),a=t(88),c=t(49),p=t(81),h=t(46),f=Array.isArray,l=t(101),d=t(98),v=t(99);r.create=s.create,r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype.subscribeCount=0,r.prototype.subscribeLimit=10,r.prototype.initialize=function(){for(var t,e,n=this.model,r=this.outputFormat||"AsPathMap",o=this.isProgressive,i=[{}],s=[],a=this.args,c=-1,h=a.length;++c<h;){var y,b=a[c];f(b)||"string"==typeof b?(b=u.fromPath(b),y="PathValues"):l(b)?(b.path=u.fromPath(b.path),y="PathValues"):v(b)?y="JSONGs":d(b)&&(y="PathMaps"),e!==y&&(e=y,t={inputType:y,arguments:[]},s.push(t),t.values=i),t.arguments.push(b)}return this.boundPath=p(n._path),this.groups=s,this.outputFormat=r,this.isProgressive=o,this.isCompleted=!1,this.isMaster=null==n._source,this.values=i,this},r.prototype.invokeSourceRequest=function(t){return this},r.prototype.ensureCollect=function(t){var e=this["finally"](function(){var e=t._root,n=e.cache;e.collectionScheduler.schedule(function(){c(e,e.expired,a(n),t._maxSize,t._collectRatio,n[h])})});return new this.constructor(function(t){return e.subscribe(t)})},e.exports=r},{101:101,134:134,159:159,46:46,49:49,64:64,81:81,88:88,98:98,99:99}],63:[function(t,e,n){function r(t){u.call(this,t||o)}function o(t){for(var e=this.model,n=this.method,r=this.groups,o=-1,i=r.length;++o<i;){var u=r[o],a=u.inputType,c=u.arguments;if(c.length>0){var p="_"+n+a+"AsJSON",h=e[p];h(e,c)}}return t.onCompleted(),s.empty}var i=t(159),s=i.Disposable,u=t(62);r.create=u.create,r.prototype=Object.create(u.prototype),r.prototype.method="invalidate",r.prototype.constructor=r,e.exports=r},{159:159,62:62}],64:[function(t,e,n){function r(t){this._subscribe=t}function o(t){var e=this.model,n=new this.type;return n.model=e,n.args=this.args,n.outputFormat=t.outputFormat||"AsPathMap",n.isProgressive=t.isProgressive||!1,n.subscribeCount=0,n.subscribeLimit=t.retryLimit||10,n.initialize().invokeSourceRequest(e).ensureCollect(e).subscribe(t)}var i=t(32),s=t(159)&&t(158),u=s.Observable,a=t(84),c=t(105),p={outputFormat:{value:"AsJSONG"}},h={isProgressive:{value:!0}};r.create=function(t,e){var n=new r(o);return n.args=e,n.type=this,n.model=t,n},r.prototype=Object.create(u.prototype),r.prototype.constructor=r,r.prototype._mixin=function(){var t=this,e=a(arguments);return new t.constructor(function(n){return t.subscribe(e.reduce(function(t,e){return Object.create(t,e)},n))})},r.prototype._toJSONG=function(){return this._mixin(p)},r.prototype.progressively=function(){return this._mixin(h)},r.prototype.subscribe=function(t,e,n){var r=t;r&&"object"==typeof r||(r={onNext:t||c,onError:e||c,onCompleted:n||c});var o=this._subscribe(r);switch(typeof o){case"function":return{dispose:o};case"object":return o||{dispose:c};default:return{dispose:c}}},r.prototype.then=function(t,e){var n=this;return new i.Promise(function(t,e){var r,o=!1;n.toArray().subscribe(function(t){r=t.length<=1?t[0]:t},function(t){o=!0,e(t)},function(){o===!1&&t(r)})}).then(t,e)},e.exports=r},{105:105,158:158,159:159,32:32,84:84}],65:[function(t,e,n){function r(t){l.call(this,t||o)}function o(t){return this.isCompleted?s.call(this,t):i.call(this,t)}function i(t){if(this.subscribeCount++>this.subscribeLimit)return t.onError("Loop kill switch thrown."),h.empty;for(var e=[],n=[],r=this.model,o=this.isMaster,i=r._root,c=this.outputFormat,p=i.errorSelector,f=this.method,l=this.groups,d=-1,y=l.length;++d<y;){var b=l[d],m=b.inputType,g=b.arguments;if(g.length>0){var w="_"+f+m+c,x=r[w],_=x(r,g,null,p);n.push.apply(n,_[1]),"PathValues"===m?e.push.apply(e,g.map(u)):"JSONGs"===m?e.push.apply(e,v(g,a)):e.push.apply(e,_[0])}}return this.requestedPaths=e,o?(this.isCompleted=!0,s.call(this,t)):void t.onError({method:f,optimizedPaths:n,invokeSourceRequest:!0})}function s(t){var e=new f(this.model,this.requestedPaths);return"AsJSONG"===this.outputFormat&&(e=e._toJSONG()),this.isProgressive&&(e=e.progressively()),e.subscribe(t)}function u(t){return t.path}function a(t){return t.paths}var c=t(159),p=c.Observable,h=c.Disposable,f=t(67),l=t(62),d=t(9),v=t(82),y=new Array(0);r.create=l.create,r.prototype=Object.create(l.prototype),r.prototype.method="set",r.prototype.constructor=r,r.prototype.invokeSourceRequest=function(t){var e=this,n=this["catch"](function(r){var o;if(r&&r.invokeSourceRequest===!0){var i={},s=t._path,u=r.optimizedPaths;t._path=y,t._getPathValuesAsJSONG(t._materialize().withoutDataSource(),u,[i]),t._path=s,o=t._request.set(i)["do"](function(t){e.isCompleted=u.length===t.paths.length},function(){e.isCompleted=!0}).materialize().flatMap(function(t){if("C"===t.kind)return p.empty();if("E"===t.kind){var e=t.exception;if(d.is(e))return p["throw"](t.exception)}return n})}else o=p["throw"](r);return o});return new this.constructor(function(t){return n.subscribe(t)})},e.exports=r},{159:159,62:62,67:67,82:82,9:9}],66:[function(t,e,n){var r=function(t){this.disposed=!1,this.currentDisposable=t};r.prototype={dispose:function(){if(!this.disposed&&this.currentDisposable){this.disposed=!0;var t=this.currentDisposable;t.dispose?t.dispose():t()}}},e.exports=r},{}],67:[function(t,e,n){var r=t(64),o=t(68),i=t(69),s={dispose:function(){}},u=t(159).Observable,a=e.exports=function(t,e,n,r){this.model=t,this.currentRemainingPaths=e,this.isJSONGraph=n||!1,this.isProgressive=r||!1};a.prototype=Object.create(u.prototype),a.prototype.subscribe=r.prototype.subscribe,a.prototype.then=r.prototype.then,a.prototype._toJSONG=function(){return new a(this.model,this.currentRemainingPaths,!0,this.isProgressive)},a.prototype.progressively=function(){return new a(this.model,this.currentRemainingPaths,this.isJSONGraph,!0)},a.prototype._subscribe=function(t){var e=[{}],n=[],r=t.isJSONG=this.isJSONGraph,u=this.isProgressive,a=o(this.model,this.currentRemainingPaths,t,u,r,e,n);return a?i(this,this.model,a,t,e,n,1):s}},{159:159,64:64,68:68,69:69}],68:[function(t,e,n){var r=t(19),o=r.getWithPathsAsJSONGraph,i=r.getWithPathsAsPathMap;e.exports=function(t,e,n,r,s,u,a){var c;if(c=s?o(t,e,u):i(t,e,u),c.criticalError)return n.onError(c.criticalError),null;var p=c.hasValue,h=!c.requestedMissingPaths||!t._source,f=u[0].json||u[0].jsonGraph;if(c.errors)for(var l=c.errors,d=a.length,v=0,y=l.length;y>v;++v,++d)a[d]=l[v];if(p&&r||f&&h)try{++t._root.syncRefCount,n.onNext(u[0])}catch(b){throw b}finally{--t._root.syncRefCount}return h?(a.length?n.onError(a):n.onCompleted(),null):c}},{19:19}],69:[function(t,e,n){var r=t(68),o=t(10),i=t(30).fastCat,s=t(49),u=t(88),a=t(66),c=t(46);e.exports=function p(t,e,n,h,f,l,d){if(10===d)throw new o;var v=e._request,y=n.requestedMissingPaths,b=n.optimizedMissingPaths,m=new a,g=[],w=e._path;if(w.length)for(var x=0,_=y.length;_>x;++x)g[x]=i(w,y[x]);else g=y;var S=v.get(g,b,function(){var n=r(e,y,h,t.isProgressive,t.isJSONGraph,f,l);if(n)m.currentDisposable=p(t,e,n,h,f,l,d+1);else{var o=e._root,i=o.cache,a=i[c];s(o,o.expired,u(i),e._maxSize,e._collectRatio,a)}});return m.currentDisposable=S,m}},{10:10,30:30,46:46,49:49,66:66,68:68,88:88}],70:[function(t,e,n){var r=t(67);e.exports=function(t){return new r(this,t)}},{67:67}],71:[function(t,e,n){var r=t(134),o=t(64),i=t(72),s=t(116),u=t(67);e.exports=function(){var t=s(arguments,i,"get");if(t!==!0)return new o(function(e){e.onError(t)});var e=r.fromPathsOrPathValues(arguments);return new u(this,e)}},{116:116,134:134,64:64,67:67,72:72}],72:[function(t,e,n){e.exports={path:!0,pathSyntax:!0}},{}],73:[function(t,e,n){function r(){}var o=t(123),i=t(159),s=i.Disposable;r.prototype.schedule=function(t){return o(t),s.empty},r.prototype.scheduleWithState=function(t,e){var n=this;return o(function(){e(n,t)}),s.empty},e.exports=r},{123:123,159:159}],74:[function(t,e,n){function r(){}var o=t(159),i=o.Disposable;r.prototype.schedule=function(t){return t(),i.empty},r.prototype.scheduleWithState=function(t,e){return e(this,t),i.empty},e.exports=r},{159:159}],75:[function(t,e,n){function r(t){this.delay=t}var o=t(159),i=o.Disposable;r.prototype.schedule=function(t){var e=setTimeout(t,this.delay);return i.create(function(){void 0!==e&&(clearTimeout(e),e=void 0)})},r.prototype.scheduleWithState=function(t,e){var n=this,r=setTimeout(function(){e(n,t)},this.delay);return i.create(function(){void 0!==r&&(clearTimeout(r),r=void 0)})},e.exports=r},{159:159}],76:[function(t,e,n){function r(t,e,n,o,s,u,a,c,p,h,f,d,v,y,b,g,w){for(var x={},_=e<t.length-1,S=t[e],E=m(S,x),C=d.index;;){f.depth=e;var A=i(n,o,s,u,a,c,E,_,!1,f,d,v,y,b,g,w);f[e]=E,f.index=e,d[d.index++]=E;var N=A[0],k=A[1];if(N&&(_?r(t,e+1,n,k,N,u,A[3],A[2],p,h,f,d,v,y,b,g,w):(l(b,N),p.push(f.slice(0,f.index+1)),h.push(d.slice(0,d.index)))),E=m(S,x),x.done)break;d.index=C}}function o(t,e,n,r,o,s,c,f,v,m,g){var w=e.value;if(s.splice(0,s.length),s.push.apply(s,w),d(e))return s.index=w.length,b(e,f,v),[void 0,t,r,n];l(v,e);var x=0,_=e,S=w.length-1,E=e=t,C=r=n;do{var A=w[x],N=S>x,k=i(t,E,e,n,C,r,A,N,!0,o,s,c,f,v,m,g);if(e=k[0],y(e))return s.index=x,k;E=k[1],r=k[2],C=k[3]}while(x++<S);if(s.index=x,_[a]!==e){var O=e[h]||0;e[h]=O+1,e[u+O]=_,_[a]=e,_[p]=O}return[e,E,r,C]}function i(t,e,n,r,i,u,a,c,p,h,l,d,v,b,m,g){for(var x=n.$type;x===f;){var _=o(t,n,r,u,h,l,d,v,b,m,g);if(n=_[0],y(n))return _;e=_[1],u=_[2],i=_[3],x=n.$type}if(void 0!==x)return[n,e,u,i];if(null==a){if(c)throw new Error("`null` is not allowed in branch key positions.");n&&(a=n[s])}else e=n,i=u,n=e[a],u=i&&i[a];return n=w(e,n,u,a,h,l,d,v,b,m,g),[n,e,u,i]}var s=t(36),u=t(43),a=t(33),c=t(46),p=t(42),h=t(44),f=t(120),l=t(50),d=t(94),v=t(96),y=t(102),b=t(86),m=t(143).iterateKeySet,g=t(92),w=t(103);e.exports=function(t,e,n,o,i){for(var s=t._root,u=s,a=s.expired,p=g(),h=s.cache,f=h[c],l=[],d=[],y=[],b=[],m=-1,w=e.length;++m<w;)for(var x=e[m],_=x.paths,S=x.jsonGraph,E=-1,C=_.length;++E<C;){var A=_[E];d.index=0,r(A,0,h,h,h,S,S,S,y,b,l,d,p,a,u,i,o)}var N=h[c],k=s.onChange;return v(k)&&f!==N&&k(),[y,b]}},{102:102,103:103,120:120,143:143,33:33,36:36,42:42,43:43,44:44,46:46,50:50,86:86,92:92,94:94,96:96}],77:[function(t,e,n){function r(t,e,n,o,u,a,c,p,h,f,l,d,v,y){var b=s(t);if(b&&b.length)for(var g=0,x=b.length,_=h.index;;){var S=b[g],E=t[S],C=w(E)&&!E.$type;p.depth=e;var A=i(n,o,u,S,E,C,!1,p,h,f,l,d,v,y);p[e]=S,p.index=e,h[h.index++]=S;var N=A[0],k=A[1];if(N&&(C?r(E,e+1,n,k,N,a,c,p,h,f,l,d,v,y):(m(d,N),a.push(p.slice(0,p.index+1)),c.push(h.slice(0,h.index)))),++g>=x)break;h.index=_}}function o(t,e,n,r,o,s,u,c,f,v){var y=n.value;if(o.splice(0,o.length),o.push.apply(o,y),x(n))return o.index=y.length,E(n,u,c),[void 0,e];m(c,n);var b=n,g=e;if(n=n[h],null!=n)g=n[p]||e,o.index=y.length;else{var w=0,_=y.length-1;g=n=e;do{var C=y[w],A=_>w,N=i(e,g,n,C,t,A,!0,r,o,s,u,c,f,v);if(n=N[0],S(n))return o.index=w,N;g=N[1]}while(w++<_);if(o.index=w,b[h]!==n){var k=n[d]||0;n[d]=k+1,n[a+k]=b,b[h]=n,b[l]=k}}return[n,g]}function i(t,e,n,r,i,s,a,c,p,h,f,l,d,y){for(var b=n.$type;b===v;){var m=o(i,t,n,c,p,h,f,l,d,y);if(n=m[0],S(n))return m;e=m[1],b=n&&n.$type}if(void 0!==b)return[n,e];if(null==r){if(s)throw new Error("`null` is not allowed in branch key positions.");n&&(r=n[u])}else e=n,n=e[r];return n=A(e,n,r,i,s,a,c,p,h,f,l,d,y),[n,e]}function s(t){if(w(t)&&!t.$type){var e=[],n=0;b(t)&&(e[n++]="length");for(var r in t)r[0]!==c&&"$"!==r[0]&&g(t,r)&&(e[n++]=r);return e}}var u=t(36),a=t(43),c=t(40),p=t(39),h=t(33),f=t(46),l=t(42),d=t(44),v=t(120),y=t(13),b=Array.isArray,m=t(50),g=t(91),w=t(100),x=t(95),_=t(96),S=t(102),E=t(86),C=t(92),A=t(104);e.exports=function(t,e,n,o,i){for(var s=t._root,u=s,a=s.expired,c=C(),h=t._path,l=s.cache,d=h.length?y(t,h).value:l,v=d[p]||l,b=l[f],m=[],g=[],w=[],x=h.length,S=-1,E=e.length;++S<E;){var A=e[S],N=h.slice(0);N.index=x,r(A.json,0,l,v,d,g,w,m,N,c,a,u,i,o)}var k=l[f],O=s.onChange;return _(O)&&b!==k&&O(),[g,w]}},{100:100,102:102,104:104,120:120,13:13,33:33,36:36,39:39,40:40,42:42,43:43,44:44,46:46,50:50,86:86,91:91,92:92,95:95,96:96}],78:[function(t,e,n){function r(t,e,n,o,s,u,a,c,p,h,f,l,d,y,b){for(var m={},g=n<e.length-1,x=e[n],_=w(x,m),S=h.index;;){p.depth=n;var E=i(o,s,u,_,t,g,!1,p,h,f,l,d,y,b);p[n]=_,p.index=n,h[h.index++]=_;var C=E[0],A=E[1];if(C&&(g?r(t,e,n+1,o,A,C,a,c,p,h,f,l,d,y,b):(v(d,C),a.push(p.slice(0,p.index+1)),c.push(h.slice(0,h.index)))),_=w(x,m),m.done)break;h.index=S}}function o(t,e,n,r,o,s,p,l,d,b){var w=n.value;if(o.splice(0,o.length),o.push.apply(o,w),y(n))return o.index=w.length,g(n,p,l),[void 0,e];v(l,n);var x=n,_=e;if(n=n[c],null!=n)_=n[a]||e,o.index=w.length;else{var S=0,E=w.length-1;_=n=e;do{var C=w[S],A=E>S,N=i(e,_,n,C,t,A,!0,r,o,s,p,l,d,b);if(n=N[0],m(n))return o.index=S,N;_=N[1]}while(S++<E);if(o.index=S,x[c]!==n){var k=n[f]||0;n[f]=k+1,n[u+k]=x,x[c]=n,x[h]=k}}return[n,_]}function i(t,e,n,r,i,u,a,c,p,h,f,d,v,y){for(var b=n.$type;b===l;){var g=o(i,t,n,c,p,h,f,d,v,y);if(n=g[0],m(n))return g;e=g[1],b=n.$type}if(void 0!==b)return[n,e];if(null==r){if(u)throw new Error("`null` is not allowed in branch key positions.");n&&(r=n[s])}else e=n,n=e[r];return n=_(e,n,r,i,u,a,c,p,h,f,d,v,y),[n,e]}var s=t(36),u=t(43),a=t(39),c=t(33),p=t(46),h=t(42),f=t(44),l=t(120),d=t(13),v=t(50),y=t(95),b=t(96),m=t(102),g=t(86),w=t(143).iterateKeySet,x=t(92),_=t(104);e.exports=function(t,e,n,o,i){for(var s=t._root,u=s,c=s.expired,h=x(),f=t._path,l=s.cache,v=f.length?d(t,f).value:l,y=v[a]||l,m=l[p],g=[],w=[],_=[],S=f.length,E=-1,C=e.length;++E<C;){var A=e[E],N=A.path,k=A.value,O=f.slice(0);O.index=S,r(k,N,0,l,y,v,w,_,g,O,h,c,u,i,o)}var P=l[p],j=s.onChange;return b(j)&&m!==P&&j(),[w,_]}},{102:102,104:104,120:120,13:13,143:143,33:33,36:36,39:39,42:42,43:43,44:44,46:46,50:50,86:86,92:92,95:95,96:96}],79:[function(t,e,n){var r=t(130),o=t(64),i=t(101);e.exports=function(t,e){for(var n=i(t)?t:r.pathValue(t,e),s=0,u=n.path,a=u.length;++s<a;)if("object"==typeof u[s])return new o(function(t){t.onError(new Error("Paths must be simple paths"))});var c=this;return new o(function(t){return c._set(n).subscribe(function(e){for(var n=e.json,r=-1,o=u.length;n&&++r<o;)n=n[u[r]];t.onNext(n)},function(e){t.onError(e)},function(){t.onCompleted()})})}},{101:101,130:130,64:64}],80:[function(t,e,n){var r=t(134),o=t(101),i=t(78);e.exports=function(t,e,n,s){var u=r.fromPath(t),a=e,c=n,p=s;if(o(u)?(p=c,c=a,a=u):a={path:u,value:a},o(a)===!1)throw new Error("Model#setValueSync must be called with an Array path.");return"function"!=typeof c&&(c=this._root._errorSelector),"function"!=typeof p&&(p=this._root._comparator),this._syncCheck("setValueSync")?(i(this,[a]),this._getValueSync(this,a.path).value):void 0}},{101:101,134:134,78:78}],81:[function(t,e,n){e.exports=function(t){if(!t)return t;for(var e=-1,n=t.length,r=[];++e<n;)r[e]=t[e];return r}},{}],82:[function(t,e,n){e.exports=function(t,e){for(var n=-1,r=-1,o=t.length,i=[];++r<o;)for(var s=e(t[r],r,t),u=-1,a=s.length;++u<a;)i[++n]=s[u];return i}},{}],83:[function(t,e,n){e.exports=function(t,e){for(var n=-1,r=t.length,o=new Array(r);++n<r;)o[n]=e(t[n],n,t);return o}},{}],84:[function(t,e,n){e.exports=function(t,e,n){var r=e||0,o=-1,i=t.length-r;0>i&&(i=0),n>0&&i>n&&(i=n);for(var s=new Array(i);++o<i;)s[o]=t[o+r];return s}},{}],85:[function(t,e,n){var r=t(40),o=t(91),i=Array.isArray,s=t(100);e.exports=function(t){var e=t;if(s(e)){e=i(t)?[]:{};var n=t;for(var u in n)u[0]!==r&&o(n,u)&&(e[u]=n[u])}return e}},{100:100,40:40,91:91}],86:[function(t,e,n){var r=t(51),o=t(35);e.exports=function(t,e,n){return t[o]||(t[o]=!0,e.push(t),r(n,t)),t}},{35:35,51:51}],87:[function(t,e,n){var r=t(100);e.exports=function(t){return r(t)&&t.$expires||void 0}},{100:100}],88:[function(t,e,n){var r=t(100);e.exports=function(t){return r(t)&&t.$size||0}},{100:100}],89:[function(t,e,n){var r=t(100);e.exports=function(t){return r(t)&&t.$timestamp||void 0}},{100:100}],90:[function(t,e,n){var r=t(100);e.exports=function(t,e){var n=r(t)&&t.$type||void 0;return e&&n?"branch":n}},{100:100}],91:[function(t,e,n){var r=t(100),o=Object.prototype.hasOwnProperty;e.exports=function(t,e){return r(t)&&o.call(t,e)}},{100:100}],92:[function(t,e,n){var r=1;e.exports=function(){return r++}},{}],93:[function(t,e,n){var r=t(36),o=t(39),i=t(46);e.exports=function(t,e,n,s){return t[r]=n,t[o]=e,t[i]=s,e[n]=t,t}},{36:36,39:39,46:46}],94:[function(t,e,n){var r=t(106),o=t(122),i=t(121);e.exports=function(t){var e=t.$expires;return null!=e&&e!==i&&e!==o&&e<r()}},{106:106,121:121,122:122}],95:[function(t,e,n){var r=t(106),o=t(122),i=t(121);e.exports=function(t){var e=t.$expires;return null!=e&&e!==i&&(e===o||e<r())}},{106:106,121:121,122:122}],96:[function(t,e,n){var r="function";e.exports=function(t){return Boolean(t)&&typeof t===r}},{}],97:[function(t,e,n){var r=t(40);e.exports=function(t){return"$size"===t||t&&t.charAt(0)===r}},{40:40}],98:[function(t,e,n){var r=t(100);e.exports=function(t){return r(t)&&"json"in t}},{100:100}],99:[function(t,e,n){var r=Array.isArray,o=t(100);e.exports=function(t){return o(t)&&r(t.paths)&&(o(t.jsonGraph)||o(t.jsong)||o(t.json)||o(t.values)||o(t.value))}},{100:100}],100:[function(t,e,n){var r="object";e.exports=function(t){return null!==t&&typeof t===r}},{}],101:[function(t,e,n){var r=Array.isArray,o=t(100);e.exports=function(t){return o(t)&&(r(t.path)||"string"==typeof t.path)}},{100:100}],102:[function(t,e,n){var r="object";e.exports=function(t){return null==t||typeof t!==r}},{}],103:[function(t,e,n){var r=t(36),o=t(39),i=t(120),s=t(119),u=t(88),a=t(89),c=t(100),p=t(95),h=t(96),f=t(50),l=t(117),d=t(93),v=t(86),y=t(110),b=t(115),m=t(107);e.exports=function(t,e,n,g,w,x,_,S,E,C,A){var N,k,O,P,j,D,q;if(e===n){if(null===n)return e=l(n,void 0,n),t=b(t,-e.$size,E,_),e=d(e,t,g),f(E,e),e;if(void 0===n)return n;if(P=c(e),P&&(k=e.$type,null==k))return null==e[o]&&(e[r]=g,e[o]=t),e}else P=c(e),P&&(k=e.$type);if(k!==i){if(j=c(n),j&&(O=n.$type),P&&!k&&(null==n||j&&!O))return e}else{if(null==n)return p(e)?void v(e,S,E):e;if(j=c(n),j&&(O=n.$type,O===i))if(e===n){if(null!=e[o])return e}else if(D=e.$timestamp,q=n.$timestamp,!p(e)&&!p(n)&&D>q)return}if(k&&j&&!O)return d(y(e,n,t,g,E),t,g);if(O||!j){if(O===s&&h(A)&&(n=A(m(w,g),n)),O&&e===n)null==e[o]&&(e=l(e,k,e.value),t=b(t,-e.$size,E,_),e=d(e,t,g,_));else{var R=!0;!k&&P||(R=a(n)<a(e)==!1,(k||O)&&h(C)&&(R=!C(e,n,x.slice(0,x.index)))),R&&(n=l(n,O,O?n.value:n),N=u(e)-u(n),e=y(e,n,t,g,E),t=b(t,N,E,_),e=d(e,t,g,_))}p(e)?v(e,S,E):f(E,e)}else null==e&&(e=d(n,t,g));return e}},{100:100,107:107,110:110,115:115,117:117,119:119,120:120,36:36,39:39,50:50,86:86,88:88,89:89,93:93,95:95,96:96}],104:[function(t,e,n){var r=t(120),o=t(119),i=t(90),s=t(88),u=t(89),a=t(95),c=t(102),p=t(96),h=t(117),f=t(86),l=t(93),d=t(110),v=t(115),y=t(114),b=t(107);e.exports=function(t,e,n,m,g,w,x,_,S,E,C,A,N){var k=i(e,w);if(g||w)k&&a(e)&&(k="expired",f(e,E,C)),(k&&k!==r||c(e))&&(e=d(e,{},t,n,C),e=l(e,t,n,S),e=y(e,S));else{var O=m,P=i(O),j=u(O)<u(e)==!1;if((k||P)&&p(A)&&(j=!A(e,O,_.slice(0,_.index))),j){P===o&&p(N)&&(O=N(b(x,n),O)),O=h(O,P,P?O.value:O);var D=s(e)-s(O);e=d(e,O,t,n,C),t=v(t,D,C,S),e=l(e,t,n,S)}}return e}},{102:102,107:107,110:110,114:114,115:115,117:117,119:119,120:120,86:86,88:88,89:89,90:90,93:93,95:95,96:96}],105:[function(t,e,n){e.exports=function(){}},{}],106:[function(t,e,n){e.exports=Date.now},{}],107:[function(t,e,n){e.exports=function(t,e){var n=t.slice(0,t.depth);return n[n.length]=e,n}},{}],108:[function(t,e,n){var r=t(120),o=t(39),i=t(51),s=t(100),u=t(112),a=t(113);e.exports=function(t,e,n,c){if(s(t)){var p=t.$type;return Boolean(p)&&(p===r&&a(t),i(c,t)),u(t),e[n]=t[o]=void 0,!0}return!1}},{100:100,112:112,113:113,120:120,39:39,51:51}],109:[function(t,e,n){var r=t(91),o=t(40),i=t(108);e.exports=function s(t,e,n,u){if(i(t,e,n,u)){if(null==t.$type)for(var a in t)a[0]!==o&&"$"!==a[0]&&r(t,a)&&s(t[a],t,a,u);return!0}return!1}},{108:108,40:40,91:91}],110:[function(t,e,n){var r=t(100),o=t(111),i=t(109);e.exports=function(t,e,n,s,u){return t===e?t:(r(t)&&(o(t,e),i(t,n,s,u)),n[s]=e,e)}},{100:100,109:109,111:111}],111:[function(t,e,n){var r=t(43),o=t(33),i=t(44);e.exports=function(t,e){for(var n=t[i]||0,s=e[i]||0,u=-1;++u<n;){var a=t[r+u];void 0!==a&&(a[o]=e,e[r+(s+u)]=a,t[r+u]=void 0)}return e[i]=n+s,t[i]=void 0,e}},{33:33,43:43,44:44}],112:[function(t,e,n){var r=t(43),o=t(33),i=t(42),s=t(44);e.exports=function(t){for(var e=-1,n=t[s]||0;++e<n;){var u=t[r+e];null!=u&&(u[o]=u[i]=t[r+e]=void 0)}return t[s]=void 0,t}},{33:33,42:42,43:43,44:44}],113:[function(t,e,n){var r=t(43),o=t(33),i=t(42),s=t(44);e.exports=function(t){var e=t[o];if(e){for(var n=(t[i]||0)-1,u=(e[s]||0)-1;++n<=u;)e[r+n]=e[r+(n+1)];e[s]=u,t[i]=t[o]=e=void 0}return t}},{33:33,42:42,43:43,44:44}],114:[function(t,e,n){var r=t(43),o=t(39),i=t(46),s=t(44);e.exports=function(t,e){var n=[t],u=0;do{var a=n[u--];if(a&&a[i]!==e){a[i]=e,n[u++]=a[o];for(var c=-1,p=a[s]||0;++c<p;)n[u++]=a[r+c]}}while(u>-1);return t}},{39:39,43:43,44:44,46:46}],115:[function(t,e,n){var r=t(36),o=t(46),i=t(39),s=t(108),u=t(114);e.exports=function(t,e,n,a){var c=t;do{var p=c[i],h=c.$size=(c.$size||0)-e;0>=h&&null!=p?s(c,p,c[r],n):c[o]!==a&&u(c,a),c=p}while(c);return t}},{108:108,114:114,36:36,39:39,46:46}],116:[function(t,e,n){var r=Array.isArray,o=t(101),i=t(99),s=t(98),u=t(134);e.exports=function(t,e,n){for(var a=0,c=t.length;c>a;++a){var p=t[a],h=!1;if(r(p)&&e.path?h=!0:"string"==typeof p&&e.pathSyntax?h=!0:o(p)&&e.pathValue?(p.path=u.fromPath(p.path),h=!0):i(p)&&e.jsonGraph?h=!0:s(p)&&e.json?h=!0:"function"==typeof p&&a+1===c&&e.selector&&(h=!0),!h)return new Error("Unrecognized argument "+typeof p+" ["+String(p)+"] to Model#"+n)}return!0}},{101:101,134:134,98:98,99:99}],117:[function(t,e,n){var r=t(130),o=r.atom,i=t(106),s=t(122),u=t(37),a=50,c=t(85),p=Array.isArray,h=t(88),f=t(87);e.exports=function(t,e,n){var r=0,l=t,d=e;if(d?(l=c(l),r=h(l),l.$type=d):(l=o(n),d=l.$type,l[u]=!0),null==n)r=a+1;else if(null==r||0>=r)switch(typeof n){case"object":r=p(n)?a+n.length:a+1;break;case"string":r=a+n.length;break;default:r=a+1}var v=f(l);return"number"==typeof v&&s>v&&(l.$expires=i()+-1*v),l.$size=r,l}},{106:106,122:122,130:130,37:37,85:85,87:87,88:88}],118:[function(t,e,n){e.exports="atom"},{}],119:[function(t,e,n){e.exports="error"},{}],120:[function(t,e,n){e.exports="ref"},{}],121:[function(t,e,n){e.exports=1},{}],122:[function(t,e,n){e.exports=0},{}],123:[function(t,e,n){"use strict";function r(){if(a.length)throw a.shift()}function o(t){var e;e=u.length?u.pop():new i,e.task=t,s(e)}function i(){this.task=null}var s=t(124),u=[],a=[],c=s.makeRequestCallFromTimer(r);e.exports=o,i.prototype.call=function(){try{this.task.call()}catch(t){o.onerror?o.onerror(t):(a.push(t),c())}finally{this.task=null,u[u.length]=this}}},{124:124}],124:[function(t,e,n){(function(t){"use strict";function n(t){u.length||(s(),a=!0),u[u.length]=t}function r(){for(;c<u.length;){var t=c;if(c+=1,u[t].call(),c>p){for(var e=0,n=u.length-c;n>e;e++)u[e]=u[e+c];u.length-=c,c=0}}u.length=0,c=0,a=!1}function o(t){var e=1,n=new h(t),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(){e=-e,r.data=e}}function i(t){return function(){function e(){clearTimeout(n),clearInterval(r),t()}var n=setTimeout(e,0),r=setInterval(e,50)}}e.exports=n;var s,u=[],a=!1,c=0,p=1024,h=t.MutationObserver||t.WebKitMutationObserver;s="function"==typeof h?o(r):i(r),n.requestFlush=s,n.makeRequestCallFromTimer=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],125:[function(t,e,n){"use strict";function r(t,e){var n;for(n in e)t[n]=e[n];return t}function o(t,e){if(this._jsongUrl=t,"number"==typeof e){var n={timeout:e};e=n}this._config=r({timeout:15e3,headers:{}},e||{})}var i=t(129),s=t(126);Array.isArray;o.prototype={constructor:o,buildQueryObject:s,get:function(t){var e="GET",n=this.buildQueryObject(this._jsongUrl,e,{paths:t,method:"get"}),o=r(n,this._config),s=this;return i(e,o,s)},set:function(t){var e="POST",n=this.buildQueryObject(this._jsongUrl,e,{jsonGraph:t,method:"set"}),o=r(n,this._config);o.headers["Content-Type"]="application/x-www-form-urlencoded";var s=this;return i(e,o,s)},call:function(t,e,n,o){e=e||[],n=n||[],o=o||[];var s="POST",u=[];u.push("method=call"),u.push("callPath="+encodeURIComponent(JSON.stringify(t))),u.push("arguments="+encodeURIComponent(JSON.stringify(e))),u.push("pathSuffixes="+encodeURIComponent(JSON.stringify(n))),u.push("paths="+encodeURIComponent(JSON.stringify(o)));var a=this.buildQueryObject(this._jsongUrl,s,u.join("&")),c=r(a,this._config);c.headers["Content-Type"]="application/x-www-form-urlencoded";var p=this;return i(s,c,p)}},o.XMLHttpSource=o,o["default"]=o,e.exports=o},{126:126,129:129}],126:[function(t,e,n){"use strict";e.exports=function(t,e,n){var r,o=[],i={url:t},s=-1!==t.indexOf("?"),u=s?"&":"?";return"string"==typeof n?o.push(n):(r=Object.keys(n),r.forEach(function(t){var e="object"==typeof n[t]?JSON.stringify(n[t]):n[t];o.push(t+"="+encodeURIComponent(e))})),"GET"===e?i.url+=u+o.join("&"):i.data=o.join("&"),i}},{}],127:[function(t,e,n){(function(t){"use strict";e.exports=function(){var e=new t.XMLHttpRequest;if("withCredentials"in e)return e;if(t.XDomainRequest)return new XDomainRequest;throw new Error("CORS is not supported by your browser")}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],128:[function(t,e,n){(function(t){"use strict";e.exports=function(){var e,n,r;if(t.XMLHttpRequest)return new t.XMLHttpRequest;try{for(n=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],r=0;3>r;r++)try{if(e=n[r],new t.ActiveXObject(e))break}catch(o){}return new t.ActiveXObject(e)}catch(o){throw new Error("XMLHttpRequest is not supported by your browser")}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],129:[function(t,e,n){"use strict";function r(){}function o(t,e,n){return r.create(function(r){var o,i,h,f,l,d={method:t||"GET",crossDomain:!1,async:!0,headers:{},responseType:"json"};for(l in e)p.call(e,l)&&(d[l]=e[l]);d.crossDomain||d.headers["X-Requested-With"]||(d.headers["X-Requested-With"]="XMLHttpRequest"),null!=n.onBeforeRequest&&n.onBeforeRequest(d);try{o=d.crossDomain?c():a()}catch(v){r.onError(v)}try{d.user?o.open(d.method,d.url,d.async,d.user,d.password):o.open(d.method,d.url,d.async),o.timeout=d.timeout,o.withCredentials=d.withCredentials!==!1,h=d.headers;for(f in h)p.call(h,f)&&o.setRequestHeader(f,h[f]);if(d.responseType)try{o.responseType=d.responseType}catch(y){if("json"!==d.responseType)throw y}o.onreadystatechange=function(t){4===o.readyState&&(i||(i=!0,s(r,o,t)))},o.ontimeout=function(t){i||(i=!0,u(r,o,"timeout error",t))},o.send(d.data)}catch(y){r.onError(y)}return function(){i||4===o.readyState||(i=!0,o.abort())}})}function i(t,e,n){n||(n=new Error(e)),t.onError(n)}function s(t,e,n){var r,o;if(e&&t){o=e.responseType,r="response"in e?e.response:e.responseText;var s=1223===e.status?204:e.status;if(s>=200&&399>=s){try{"json"!==o&&(r=JSON.parse(r||"")),"string"==typeof r&&(r=JSON.parse(r||""))}catch(n){i(t,"invalid json",n)}return t.onNext(r),void t.onCompleted()}return 401===s||403===s||407===s?i(t,r):410===s?i(t,r):408===s||504===s?i(t,r):i(t,r||"Response code "+s)}}function u(t,e,n,r){i(t,n||e.statusText||"request error",r)}var a=t(128),c=t(127),p=Object.prototype.hasOwnProperty,h=function(){};r.create=function(t){var e=new r;return e.subscribe=function(e,n,r){var o,i;return o="function"==typeof e?{onNext:e,onError:n||h,onCompleted:r||h}:e,i=t(o),"function"==typeof i?{dispose:i}:i},e},e.exports=o},{127:127,128:128}],130:[function(t,e,n){function r(t,e,n){var r=Object.create(null);if(null!=n){for(var o in n)r[o]=n[o];return r.$type=t,r.value=e,r}return{$type:t,value:e}}var o=t(134);e.exports={ref:function(t,e){return r("ref",o.fromPath(t),e)},atom:function(t,e){return r("atom",t,e)},undefined:function(){return r("atom")},error:function(t,e){return r("error",t,e)},pathValue:function(t,e){return{path:o.fromPath(t),value:e}},pathInvalidation:function(t){return{path:o.fromPath(t),invalidated:!0}}}},{134:134}],131:[function(t,e,n){e.exports={integers:"integers",ranges:"ranges",keys:"keys"}},{}],132:[function(t,e,n){var r={token:"token",dotSeparator:".",commaSeparator:",",openingBracket:"[",closingBracket:"]",openingBrace:"{",closingBrace:"}",escape:"\\",space:" ",colon:":",quote:"quote",unknown:"unknown"};e.exports=r},{}],133:[function(t,e,n){e.exports={indexer:{nested:"Indexers cannot be nested.",needQuotes:"unquoted indexers must be numeric.",empty:"cannot have empty indexers.",leadingDot:"Indexers cannot have leading dots.",leadingComma:"Indexers cannot have leading comma.",requiresComma:"Indexers require commas between indexer args.",routedTokens:"Only one token can be used per indexer when specifying routed tokens."},range:{precedingNaN:"ranges must be preceded by numbers.",suceedingNaN:"ranges must be suceeded by numbers."},routed:{invalid:"Invalid routed token. only integers|ranges|keys are supported."},quote:{empty:"cannot have empty quoted keys.",illegalEscape:"Invalid escape character. Only quotes are escapable."},unexpectedToken:"Unexpected token.",invalidIdentifier:"Invalid Identifier.",invalidPath:"Please provide a valid path.",throwError:function(t,e,n){if(n)throw t+" -- "+e.parseString+" with next token: "+n;throw t+" -- "+e.parseString}}},{}],134:[function(t,e,n){var r=t(140),o=t(135),i=t(131),s=function(t,e){return o(new r(t,e))};e.exports=s,s.fromPathsOrPathValues=function(t,e){if(!t)return[];for(var n=[],r=0,o=t.length;o>r;r++)"string"==typeof t[r]?n[r]=s(t[r],e):"string"==typeof t[r].path?n[r]={path:s(t[r].path,e),value:t[r].value}:n[r]=t[r];return n},s.fromPath=function(t,e){return t?"string"==typeof t?s(t,e):t:[]},s.RoutedTokens=i},{131:131,135:135,140:140}],135:[function(t,e,n){var r=t(132),o=t(133),i=t(136);e.exports=function(t){for(var e=t.next(),n={},s=[];!e.done;){switch(e.type){case r.token:var u=+e.token[0];isNaN(u)||o.throwError(o.invalidIdentifier,t),s[s.length]=e.token;break;case r.dotSeparator:0===s.length&&o.throwError(o.unexpectedToken,t);break;case r.space:break;case r.openingBracket:i(t,e,n,s);break;default:o.throwError(o.unexpectedToken,t)}e=t.next()}return 0===s.length&&o.throwError(o.invalidPath,t),s}},{132:132,133:133,136:136}],136:[function(t,e,n){var r=t(132),o=t(133),i=o.indexer,s=t(138),u=t(137),a=t(139);e.exports=function(t,e,n,c){var p=t.next(),h=!1,f=1,l=!1;for(n.indexer=[];!p.done;){switch(p.type){case r.token:case r.quote:n.indexer.length===f&&o.throwError(i.requiresComma,t)}switch(p.type){case r.openingBrace:l=!0,a(t,p,n,c);break;case r.token:var d=+p.token;isNaN(d)&&o.throwError(i.needQuotes,t),n.indexer[n.indexer.length]=d;break;case r.dotSeparator:n.indexer.length||o.throwError(i.leadingDot,t),s(t,p,n,c);
3471 break;case r.space:break;case r.closingBracket:h=!0;break;case r.quote:u(t,p,n,c);break;case r.openingBracket:o.throwError(i.nested,t);break;case r.commaSeparator:++f;break;default:o.throwError(o.unexpectedToken,t)}if(h)break;p=t.next()}0===n.indexer.length&&o.throwError(i.empty,t),n.indexer.length>1&&l&&o.throwError(i.routedTokens,t),1===n.indexer.length&&(n.indexer=n.indexer[0]),c[c.length]=n.indexer,n.indexer=void 0}},{132:132,133:133,137:137,138:138,139:139}],137:[function(t,e,n){var r=t(132),o=t(133),i=o.quote;e.exports=function(t,e,n,s){for(var u=t.next(),a="",c=e.token,p=!1,h=!1;!u.done;){switch(u.type){case r.token:case r.space:case r.dotSeparator:case r.commaSeparator:case r.openingBracket:case r.closingBracket:case r.openingBrace:case r.closingBrace:p&&o.throwError(i.illegalEscape,t),a+=u.token;break;case r.quote:p?(a+=u.token,p=!1):u.token!==c?a+=u.token:h=!0;break;case r.escape:p=!0;break;default:o.throwError(o.unexpectedToken,t)}if(h)break;u=t.next()}0===a.length&&o.throwError(i.empty,t),n.indexer[n.indexer.length]=a}},{132:132,133:133}],138:[function(t,e,n){var r=t(140),o=t(132),i=t(133);e.exports=function(t,e,n,s){var u,a=t.peek(),c=1,p=!1,h=!0,f=n.indexer.length-1,l=r.toNumber(n.indexer[f]);for(isNaN(l)&&i.throwError(i.range.precedingNaN,t);!p&&!a.done;){switch(a.type){case o.dotSeparator:3===c&&i.throwError(i.unexpectedToken,t),++c,3===c&&(h=!1);break;case o.token:u=r.toNumber(t.next().token),isNaN(u)&&i.throwError(i.range.suceedingNaN,t),p=!0;break;default:p=!0}if(p)break;t.next(),a=t.peek()}n.indexer[f]={from:l,to:h?u:u-1}}},{132:132,133:133,140:140}],139:[function(t,e,n){var r=t(132),o=t(131),i=t(133),s=i.routed;e.exports=function(t,e,n,u){var a=t.next(),c=!1,p="";switch(a.token){case o.integers:case o.ranges:case o.keys:break;default:i.throwError(s.invalid,t)}var h=t.next();if(h.type===r.colon&&(c=!0,h=t.next(),h.type!==r.token&&i.throwError(s.invalid,t),p=h.token,h=t.next()),h.type===r.closingBrace){var f={type:a.token,named:c,name:p};n.indexer[n.indexer.length]=f}else i.throwError(s.invalid,t)}},{131:131,132:132,133:133}],140:[function(t,e,n){function r(t,e,n){return{token:t,done:n,type:e}}function o(t,e,n){var o,g=!1,w="",x=n?m:b;do{if(o=e+1>=t.length)break;var _=t[e+1];if(void 0===_||-1!==x.indexOf(_)){if(w.length)break;++e;var S;switch(_){case s:S=i.dotSeparator;break;case u:S=i.commaSeparator;break;case a:S=i.openingBracket;break;case c:S=i.closingBracket;break;case p:S=i.openingBrace;break;case h:S=i.closingBrace;break;case y:S=i.space;break;case d:case v:S=i.quote;break;case l:S=i.escape;break;case f:S=i.colon;break;default:S=i.unknown}g=r(_,S,!1);break}w+=_,++e}while(!o);return!g&&w.length&&(g=r(w,i.token,!1)),g||(g={done:!0}),{token:g,idx:e}}var i=t(132),s=".",u=",",a="[",c="]",p="{",h="}",f=":",l="\\",d='"',v="'",y=" ",b="\\'\"[]., ",m="\\{}'\"[]., :",g=e.exports=function(t,e){this._string=t,this._idx=-1,this._extended=e,this.parseString=""};g.prototype={next:function(){var t=this._nextToken?this._nextToken:o(this._string,this._idx,this._extended);return this._idx=t.idx,this._nextToken=!1,this.parseString+=t.token.token,t.token},peek:function(){var t=this._nextToken?this._nextToken:o(this._string,this._idx,this._extended);return this._nextToken=t,t.token}},g.toNumber=function(t){return isNaN(+t)?NaN:+t}},{132:132}],141:[function(t,e,n){var r=t(147),o=t(148);e.exports=function(t){var e=t.reduce(function(t,e){var n=e.length;return t[n]||(t[n]=[]),t[n].push(e),t},{});return Object.keys(e).forEach(function(t){e[t]=o(e[t])}),r(e)}},{147:147,148:148}],142:[function(t,e,n){var r=t(144);e.exports=function o(t,e,n){for(var i=t,s=!0;s&&n<e.length;++n){var u=e[n],a=typeof u;if(u&&"object"===a){var c={},p=r(u,c),h=n+1;do{var f=i[p];s=void 0!==f,s&&(s=o(f,e,h)),p=r(u,c)}while(s&&!c.done);break}i=i[u],s=void 0!==i}return s}},{144:144}],143:[function(t,e,n){e.exports={iterateKeySet:t(144),toTree:t(148),toTreeWithUnion:t(149),pathsComplementFromTree:t(146),pathsComplementFromLengthTree:t(145),hasIntersection:t(142),toPaths:t(147),collapse:t(141)}},{141:141,142:142,144:144,145:145,146:146,147:147,148:148,149:149}],144:[function(t,e,n){function r(t,e){var n=e.from=t.from||0,r=e.to=t.to||"number"==typeof t.length&&e.from+t.length-1||0;e.rangeOffset=e.from,e.loaded=!0,n>r&&(e.empty=!0)}function o(t,e){e.done=!1;var n=e.isObject=!(!t||"object"!=typeof t);e.isArray=n&&i(t),e.arrayOffset=0}var i=Array.isArray;e.exports=function(t,e){if(void 0===e.isArray&&o(t,e),e.isArray){var n;do{e.loaded&&e.rangeOffset>e.to&&(++e.arrayOffset,e.loaded=!1);var i=e.arrayOffset,s=t.length;if(i>=s){e.done=!0;break}var u=t[e.arrayOffset],a=typeof u;if("object"===a){if(e.loaded||r(u,e),e.empty)continue;n=e.rangeOffset++}else++e.arrayOffset,n=u}while(void 0===n);return n}return e.isObject?(e.loaded||r(t,e),e.rangeOffset>e.to?void(e.done=!0):e.rangeOffset++):(e.done=!0,t)}},{}],145:[function(t,e,n){var r=t(142);e.exports=function(t,e){for(var n=[],o=-1,i=0,s=t.length;s>i;++i){var u=t[i];r(e[u.length],u,0)||(n[++o]=u)}return n}},{142:142}],146:[function(t,e,n){var r=t(142);e.exports=function(t,e){for(var n=[],o=-1,i=0,s=t.length;s>i;++i)r(e,t[i],0)||(n[++o]=t[i]);return n}},{142:142}],147:[function(t,e,n){function r(t){return null!==t&&typeof t===f}function o(t,e,n){var r,i,s,u,h,f,l,d,v,y,b,m,g,w,x=c(String(e)),_=Object.create(null),S=[],E=-1,C=0,A=[],N=0;if(u=[],h=-1,n-1>e){for(f=a(t,u);++h<f;)r=u[h],i=o(t[r],e+1,n),s=i.code,_[s]?i=_[s]:(S[C++]=s,i=_[s]={keys:[],sets:i.sets}),x=c(x+r+s),p(r)&&i.keys.push(parseInt(r,10))||i.keys.push(r);for(;++E<C;)if(r=S[E],i=_[r],u=i.keys,f=u.length,f>0)for(l=i.sets,d=-1,v=l.length,g=u[0];++d<v;){for(y=l[d],b=-1,m=y.length,w=new Array(m+1),w[0]=f>1&&u||g;++b<m;)w[b+1]=y[b];A[N++]=w}}else for(f=a(t,u),f>1?A[N++]=[u]:A[N++]=u;++h<f;)x=c(x+u[h]);return{code:x,sets:A}}function i(t){for(var e=-1,n=t.length;++e<n;){var r=t[e];h(r)&&(t[e]=s(r))}return t}function s(t){for(var e=-1,n=t.length-1,r=n>0;++e<=n;){var o=t[e];if(!p(o)){r=!1;break}t[e]=parseInt(o,10)}if(r===!0){t.sort(u);var i=t[0],s=t[n];if(n>=s-i)return{from:i,to:s}}return t}function u(t,e){return t-e}function a(t,e,n){var r=0;for(var o in t)e[r++]=o;return r>1&&e.sort(n),r}function c(t){for(var e=5381,n=-1,r=t.length;++n<r;)e=(e<<5)+e+t.charCodeAt(n);return String(e)}function p(t){return!h(t)&&t-parseFloat(t)+1>=0}var h=Array.isArray,f="object";e.exports=function(t){var e,n=[],s=0;for(var u in t)if(p(u)&&r(e=t[u]))for(var a=o(e,0,parseInt(u,10)).sets,c=-1,h=a.length;++c<h;)n[s++]=i(a[c]);return n}},{}],148:[function(t,e,n){function r(t,e,n){var i,s=e[n],u={},a=n+1;i=o(s,u);do{var c=t[i];c||(a===e.length?t[i]=null:c=t[i]={}),a<e.length&&r(c,e,a),u.done||(i=o(s,u))}while(!u.done)}var o=t(144);Array.isArray;e.exports=function(t){return t.reduce(function(t,e){return r(t,e,0),t},{})}},{144:144}],149:[function(t,e,n){},{}],150:[function(t,e,n){function r(){p=!1,u.length?c=u.concat(c):h=-1,c.length&&o()}function o(){if(!p){var t=setTimeout(r);p=!0;for(var e=c.length;e;){for(u=c,c=[];++h<e;)u&&u[h].run();h=-1,e=c.length}u=null,p=!1,clearTimeout(t)}}function i(t,e){this.fun=t,this.array=e}function s(){}var u,a=e.exports={},c=[],p=!1,h=-1;a.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new i(t,e)),1!==c.length||p||setTimeout(o,0)},i.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=s,a.addListener=s,a.once=s,a.off=s,a.removeListener=s,a.removeAllListeners=s,a.emit=s,a.binding=function(t){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(t){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},{}],151:[function(t,e,n){"use strict";e.exports=t(156)},{156:156}],152:[function(t,e,n){"use strict";function r(){}function o(t){try{return t.then}catch(e){return y=e,b}}function i(t,e){try{return t(e)}catch(n){return y=n,b}}function s(t,e,n){try{t(e,n)}catch(r){return y=r,b}}function u(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._37=0,this._12=null,this._59=[],t!==r&&d(t,this)}function a(t,e,n){return new t.constructor(function(o,i){var s=new u(r);s.then(o,i),c(t,new l(e,n,s))})}function c(t,e){for(;3===t._37;)t=t._12;return 0===t._37?void t._59.push(e):void v(function(){var n=1===t._37?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._37?p(e.promise,t._12):h(e.promise,t._12));var r=i(n,t._12);r===b?h(e.promise,y):p(e.promise,r)})}function p(t,e){if(e===t)return h(t,new TypeError("A promise cannot be resolved with itself."));if(e&&("object"==typeof e||"function"==typeof e)){var n=o(e);if(n===b)return h(t,y);if(n===t.then&&e instanceof u)return t._37=3,t._12=e,void f(t);if("function"==typeof n)return void d(n.bind(e),t)}t._37=1,t._12=e,f(t)}function h(t,e){t._37=2,t._12=e,f(t)}function f(t){for(var e=0;e<t._59.length;e++)c(t,t._59[e]);t._59=null}function l(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function d(t,e){var n=!1,r=s(t,function(t){n||(n=!0,p(e,t))},function(t){n||(n=!0,h(e,t))});n||r!==b||(n=!0,h(e,y))}var v=t(124),y=null,b={};e.exports=u,u._99=r,u.prototype.then=function(t,e){if(this.constructor!==u)return a(this,t,e);var n=new u(r);return c(this,new l(t,e,n)),n}},{124:124}],153:[function(t,e,n){"use strict";var r=t(152);e.exports=r,r.prototype.done=function(t,e){var n=arguments.length?this.then.apply(this,arguments):this;n.then(null,function(t){setTimeout(function(){throw t},0)})}},{152:152}],154:[function(t,e,n){"use strict";function r(t){var e=new o(o._99);return e._37=1,e._12=t,e}var o=t(152);e.exports=o;var i=r(!0),s=r(!1),u=r(null),a=r(void 0),c=r(0),p=r("");o.resolve=function(t){if(t instanceof o)return t;if(null===t)return u;if(void 0===t)return a;if(t===!0)return i;if(t===!1)return s;if(0===t)return c;if(""===t)return p;if("object"==typeof t||"function"==typeof t)try{var e=t.then;if("function"==typeof e)return new o(e.bind(t))}catch(n){return new o(function(t,e){e(n)})}return r(t)},o.all=function(t){var e=Array.prototype.slice.call(t);return new o(function(t,n){function r(s,u){if(u&&("object"==typeof u||"function"==typeof u)){if(u instanceof o&&u.then===o.prototype.then){for(;3===u._37;)u=u._12;return 1===u._37?r(s,u._12):(2===u._37&&n(u._12),void u.then(function(t){r(s,t)},n))}var a=u.then;if("function"==typeof a){var c=new o(a.bind(u));return void c.then(function(t){r(s,t)},n)}}e[s]=u,0===--i&&t(e)}if(0===e.length)return t([]);for(var i=e.length,s=0;s<e.length;s++)r(s,e[s])})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){t.forEach(function(t){o.resolve(t).then(e,n)})})},o.prototype["catch"]=function(t){return this.then(null,t)}},{152:152}],155:[function(t,e,n){"use strict";var r=t(152);e.exports=r,r.prototype["finally"]=function(t){return this.then(function(e){return r.resolve(t()).then(function(){return e})},function(e){return r.resolve(t()).then(function(){throw e})})}},{152:152}],156:[function(t,e,n){"use strict";e.exports=t(152),t(153),t(155),t(154),t(157)},{152:152,153:153,154:154,155:155,157:157}],157:[function(t,e,n){"use strict";var r=t(152),o=t(123);e.exports=r,r.denodeify=function(t,e){return e=e||1/0,function(){var n=this,o=Array.prototype.slice.call(arguments,0,e>0?e:0);return new r(function(e,r){o.push(function(t,n){t?r(t):e(n)});var i=t.apply(n,o);!i||"object"!=typeof i&&"function"!=typeof i||"function"!=typeof i.then||e(i)})}},r.nodeify=function(t){return function(){var e=Array.prototype.slice.call(arguments),n="function"==typeof e[e.length-1]?e.pop():null,i=this;try{return t.apply(this,arguments).nodeify(n,i)}catch(s){if(null===n||"undefined"==typeof n)return new r(function(t,e){e(s)});o(function(){n.call(i,s)})}}},r.prototype.nodeify=function(t,e){return"function"!=typeof t?this:void this.then(function(n){o(function(){t.call(e,null,n)})},function(n){o(function(){t.call(e,n)})})}},{123:123,152:152}],158:[function(e,n,r){(function(o){(function(i){var s={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},u=s[typeof window]&&window||this,a=s[typeof r]&&r&&!r.nodeType&&r,c=s[typeof n]&&n&&!n.nodeType&&n,p=(c&&c.exports===a&&a,s[typeof o]&&o);!p||p.global!==p&&p.window!==p||(u=p),"function"==typeof t&&t.amd?t(["rx"],function(t,e){return i(u,e,t)}):"object"==typeof n&&n&&n.exports===a?n.exports=i(u,n.exports,e(159)):u.Rx=i(u,{},u.Rx)}).call(this,function(t,e,n,r){function o(){try{return l.apply(this,arguments)}catch(t){return M.e=t,M}}function i(t){if(!E(t))throw new TypeError("fn must be a function");return l=t,o}function s(t,e,n){return new b(function(r){var o=!1,i=null,s=[];return t.subscribe(function(t){var u,a;try{a=e(t)}catch(c){return void r.onError(c)}if(u=0,o)try{u=n(a,i)}catch(p){return void r.onError(p)}else o=!0,i=a;u>0&&(i=a,s=[]),u>=0&&s.push(t)},function(t){r.onError(t)},function(){r.onNext(s),r.onCompleted()})},t)}function u(t){if(0===t.length)throw new D;return t[0]}function a(t,e,n,r){if(0>e)throw new R;return new b(function(o){var i=e;return t.subscribe(function(t){0===i--&&(o.onNext(t),o.onCompleted())},function(t){o.onError(t)},function(){n?(o.onNext(r),o.onCompleted()):o.onError(new R)})},t)}function c(t,e,n){return new b(function(r){var o=n,i=!1;return t.subscribe(function(t){i?r.onError(new Error("Sequence contains more than one element")):(o=t,i=!0)},function(t){r.onError(t)},function(){i||e?(r.onNext(o),r.onCompleted()):r.onError(new D)})},t)}function p(t,e,n){return new b(function(r){return t.subscribe(function(t){r.onNext(t),r.onCompleted()},function(t){r.onError(t)},function(){e?(r.onNext(n),r.onCompleted()):r.onError(new D)})},t)}function h(t,e,n){return new b(function(r){var o=n,i=!1;return t.subscribe(function(t){o=t,i=!0},function(t){r.onError(t)},function(){i||e?(r.onNext(o),r.onCompleted()):r.onError(new D)})},t)}function f(t,e,n,o){var i=j(e,n,3);return new b(function(e){var n=0;return t.subscribe(function(r){var s;try{s=i(r,n,t)}catch(u){return void e.onError(u)}s?(e.onNext(o?n:r),e.onCompleted()):n++},function(t){e.onError(t)},function(){e.onNext(o?-1:r),e.onCompleted()})},t)}var l,d=n.Observable,v=d.prototype,y=n.CompositeDisposable,b=n.AnonymousObservable,m=n.Disposable.empty,g=(n.internals.isEqual,n.helpers),w=g.not,x=g.defaultComparer,_=g.identity,S=g.defaultSubComparer,E=g.isFunction,C=g.isPromise,A=g.isArrayLike,N=g.isIterable,k=n.internals.inherits,O=d.fromPromise,P=d.from,j=n.internals.bindCallback,D=n.EmptyError,q=n.ObservableBase,R=n.ArgumentOutOfRangeError,M={e:{}};v.aggregate=function(){var t,e,n=!1,r=this;return 2===arguments.length?(n=!0,e=arguments[0],t=arguments[1]):t=arguments[0],new b(function(o){var i,s,u;return r.subscribe(function(r){!u&&(u=!0);try{i?s=t(s,r):(s=n?t(e,r):r,i=!0)}catch(a){return o.onError(a)}},function(t){o.onError(t)},function(){u&&o.onNext(s),!u&&n&&o.onNext(e),!u&&!n&&o.onError(new D),o.onCompleted()})},r)};var T=function(t){function e(e,n,r,o){this.source=e,this.acc=n,this.hasSeed=r,this.seed=o,t.call(this)}function n(t,e){this.o=t,this.acc=e.acc,this.hasSeed=e.hasSeed,this.seed=e.seed,this.hasAccumulation=!1,this.result=null,this.hasValue=!1,this.isStopped=!1}return k(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t,this))},n.prototype.onNext=function(t){this.isStopped||(!this.hasValue&&(this.hasValue=!0),this.hasAccumulation?this.result=i(this.acc)(this.result,t):(this.result=this.hasSeed?i(this.acc)(this.seed,t):t,this.hasAccumulation=!0),this.result===M&&this.o.onError(this.result.e))},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.hasValue&&this.o.onNext(this.result),!this.hasValue&&this.hasSeed&&this.o.onNext(this.seed),!this.hasValue&&!this.hasSeed&&this.o.onError(new D),this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(q);return v.reduce=function(t){var e=!1;if(2===arguments.length){e=!0;var n=arguments[1]}return new T(this,t,e,n)},v.some=function(t,e){var n=this;return t?n.filter(t,e).some():new b(function(t){return n.subscribe(function(){t.onNext(!0),t.onCompleted()},function(e){t.onError(e)},function(){t.onNext(!1),t.onCompleted()})},n)},v.any=function(){return this.some.apply(this,arguments)},v.isEmpty=function(){return this.any().map(w)},v.every=function(t,e){return this.filter(function(e){return!t(e)},e).some().map(w)},v.all=function(){return this.every.apply(this,arguments)},v.includes=function(t,e){function n(t,e){return 0===t&&0===e||t===e||isNaN(t)&&isNaN(e)}var r=this;return new b(function(o){var i=0,s=+e||0;return Math.abs(s)===1/0&&(s=0),0>s?(o.onNext(!1),o.onCompleted(),m):r.subscribe(function(e){i++>=s&&n(e,t)&&(o.onNext(!0),o.onCompleted())},function(t){o.onError(t)},function(){o.onNext(!1),o.onCompleted()})},this)},v.contains=function(t,e){v.includes(t,e)},v.count=function(t,e){return t?this.filter(t,e).count():this.reduce(function(t){return t+1},0)},v.indexOf=function(t,e){var n=this;return new b(function(r){var o=0,i=+e||0;return Math.abs(i)===1/0&&(i=0),0>i?(r.onNext(-1),r.onCompleted(),m):n.subscribe(function(e){o>=i&&e===t&&(r.onNext(o),r.onCompleted()),o++},function(t){r.onError(t)},function(){r.onNext(-1),r.onCompleted()})},n)},v.sum=function(t,e){return t&&E(t)?this.map(t,e).sum():this.reduce(function(t,e){return t+e},0)},v.minBy=function(t,e){return e||(e=S),s(this,t,function(t,n){return-1*e(t,n)})},v.min=function(t){return this.minBy(_,t).map(function(t){return u(t)})},v.maxBy=function(t,e){return e||(e=S),s(this,t,e)},v.max=function(t){return this.maxBy(_,t).map(function(t){return u(t)})},v.average=function(t,e){return t&&E(t)?this.map(t,e).average():this.reduce(function(t,e){return{sum:t.sum+e,count:t.count+1}},{sum:0,count:0}).map(function(t){if(0===t.count)throw new D;return t.sum/t.count})},v.sequenceEqual=function(t,e){var n=this;return e||(e=x),new b(function(r){var o=!1,i=!1,s=[],u=[],a=n.subscribe(function(t){var n,o;if(u.length>0){o=u.shift();try{n=e(o,t)}catch(a){return void r.onError(a)}n||(r.onNext(!1),r.onCompleted())}else i?(r.onNext(!1),r.onCompleted()):s.push(t)},function(t){r.onError(t)},function(){o=!0,0===s.length&&(u.length>0?(r.onNext(!1),r.onCompleted()):i&&(r.onNext(!0),r.onCompleted()))});(A(t)||N(t))&&(t=P(t)),C(t)&&(t=O(t));var c=t.subscribe(function(t){var n;if(s.length>0){var i=s.shift();try{n=e(i,t)}catch(a){return void r.onError(a)}n||(r.onNext(!1),r.onCompleted())}else o?(r.onNext(!1),r.onCompleted()):u.push(t)},function(t){r.onError(t)},function(){i=!0,0===u.length&&(s.length>0?(r.onNext(!1),r.onCompleted()):o&&(r.onNext(!0),r.onCompleted()))});return new y(a,c)},n)},v.elementAt=function(t){return a(this,t,!1)},v.elementAtOrDefault=function(t,e){return a(this,t,!0,e)},v.single=function(t,e){return t&&E(t)?this.where(t,e).single():c(this,!1)},v.singleOrDefault=function(t,e,n){return t&&E(t)?this.filter(t,n).singleOrDefault(null,e):c(this,!0,e)},v.first=function(t,e){return t?this.where(t,e).first():p(this,!1)},v.firstOrDefault=function(t,e,n){return t?this.where(t).firstOrDefault(null,e):p(this,!0,e)},v.last=function(t,e){return t?this.where(t,e).last():h(this,!1)},v.lastOrDefault=function(t,e,n){return t?this.where(t,n).lastOrDefault(null,e):h(this,!0,e)},v.find=function(t,e){return f(this,t,e,!1)},v.findIndex=function(t,e){return f(this,t,e,!0)},v.toSet=function(){if("undefined"==typeof t.Set)throw new TypeError;var e=this;return new b(function(n){var r=new t.Set;return e.subscribe(function(t){r.add(t)},function(t){n.onError(t)},function(){n.onNext(r),n.onCompleted()})},e)},v.toMap=function(e,n){if("undefined"==typeof t.Map)throw new TypeError;var r=this;return new b(function(o){var i=new t.Map;return r.subscribe(function(t){var r;try{r=e(t)}catch(s){return void o.onError(s)}var u=t;if(n)try{u=n(t)}catch(s){return void o.onError(s)}i.set(r,u)},function(t){o.onError(t)},function(){o.onNext(i),o.onCompleted()})},r)},n})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{159:159}],159:[function(e,n,r){(function(e,o){(function(i){function u(t){for(var e=[],n=0,r=t.length;r>n;n++)e.push(t[n]);return e}function a(t,e){if(ct&&e.stack&&"object"==typeof t&&null!==t&&t.stack&&-1===t.stack.indexOf(lt)){for(var n=[],r=e;r;r=r.source)r.stack&&n.unshift(r.stack);n.unshift(t.stack);var o=n.join("\n"+lt+"\n");t.stack=c(o)}}function c(t){for(var e=t.split("\n"),n=[],r=0,o=e.length;o>r;r++){var i=e[r];p(i)||h(i)||!i||n.push(i)}return n.join("\n")}function p(t){var e=l(t);if(!e)return!1;var n=e[0],r=e[1];return n===ht&&r>=ft&&$n>=r}function h(t){return-1!==t.indexOf("(module.js:")||-1!==t.indexOf("(node.js:")}function f(){if(ct)try{throw new Error}catch(t){var e=t.stack.split("\n"),n=e[0].indexOf("@")>0?e[1]:e[2],r=l(n);if(!r)return;return ht=r[0],r[1]}}function l(t){var e=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(t);if(e)return[e[1],Number(e[2])];var n=/at ([^ ]+):(\d+):(?:\d+)$/.exec(t);if(n)return[n[1],Number(n[2])];var r=/.*@(.+):(\d+)$/.exec(t);return r?[r[1],Number(r[2])]:void 0}function d(t){var e=[];if(!Ht(t))return e;Ut.nonEnumArgs&&t.length&&Xt(t)&&(t=Yt.call(t));var n=Ut.enumPrototypes&&"function"==typeof t,r=Ut.enumErrorProps&&(t===Jt||t instanceof Error);for(var o in t)n&&"prototype"==o||r&&("message"==o||"name"==o)||e.push(o);if(Ut.nonEnumShadows&&t!==It){var i=t.constructor,s=-1,u=kt;if(t===(i&&i.prototype))var a=t===Lt?$t:t===Jt?qt:Wt.call(t),c=Ft[a];for(;++s<u;)o=Nt[s],c&&c[o]||!zt.call(t,o)||e.push(o)}return e}function v(t,e,n){for(var r=-1,o=n(t),i=o.length;++r<i;){var s=o[r];if(e(t[s],s,t)===!1)break}return t}function y(t,e){return v(t,e,d)}function b(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}function m(t,e,n,r){if(t===e)return 0!==t||1/t==1/e;var o=typeof t,i=typeof e;if(t===t&&(null==t||null==e||"function"!=o&&"object"!=o&&"function"!=i&&"object"!=i))return!1;var s=Wt.call(t),u=Wt.call(e);if(s==Ot&&(s=Tt),u==Ot&&(u=Tt),s!=u)return!1;switch(s){case jt:case Dt:return+t==+e;case Mt:return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case Vt:case $t:return t==String(e)}var a=s==Pt;if(!a){if(s!=Tt||!Ut.nodeClass&&(b(t)||b(e)))return!1;var c=!Ut.argsObject&&Xt(t)?Object:t.constructor,p=!Ut.argsObject&&Xt(e)?Object:e.constructor;if(!(c==p||zt.call(t,"constructor")&&zt.call(e,"constructor")||at(c)&&c instanceof c&&at(p)&&p instanceof p||!("constructor"in t&&"constructor"in e)))return!1}n||(n=[]),r||(r=[]);for(var h=n.length;h--;)if(n[h]==t)return r[h]==e;var f=0,l=!0;if(n.push(t),r.push(e),a){if(h=t.length,f=e.length,l=f==h)for(;f--;){var d=e[f];if(!(l=m(t[f],d,n,r)))break}}else y(e,function(e,o,i){return zt.call(i,o)?(f++,l=zt.call(t,o)&&m(t[o],e,n,r)):void 0}),l&&y(t,function(t,e,n){return zt.call(n,e)?l=--f>-1:void 0});return n.pop(),r.pop(),l}function g(t,e){for(var n=new Array(t),r=0;t>r;r++)n[r]=e();return n}function w(){try{return Qt.apply(this,arguments)}catch(t){return ne.e=t,ne}}function x(t){if(!at(t))throw new TypeError("fn must be a function");return Qt=t,w}function _(t){throw t}function S(t,e){this.id=t,this.value=e}function E(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function C(t,e){e.isDisposed||(e.isDisposed=!0,e.disposable.dispose())}function A(t){this._s=s}function N(t){this._s=s,this._l=s.length,this._i=0}function k(t){this._a=t}function O(t){this._a=t,this._l=q(t),this._i=0}function P(t){return"number"==typeof t&&X.isFinite(t)}function j(t){var e,n=t[xt];if(!n&&"string"==typeof t)return e=new A(t),e[xt]();if(!n&&t.length!==i)return e=new k(t),e[xt]();if(!n)throw new TypeError("Object is not iterable");return t[xt]()}function D(t){var e=+t;return 0===e?e:isNaN(e)?e:0>e?-1:1}function q(t){var e=+t.length;return isNaN(e)?0:0!==e&&P(e)?(e=D(e)*Math.floor(Math.abs(e)),0>=e?0:e>en?en:e):e}function R(t,e){this.observer=t,this.parent=e}function M(t,e){return me(t)||(t=_e),new rn(e,t)}function T(t,e){this.observer=t,this.parent=e}function V(t,e){this.observer=t,this.parent=e}function $(t,e){return new qn(function(n){var r=new fe,o=new le;return o.setDisposable(r),r.setDisposable(t.subscribe(function(t){n.onNext(t)},function(t){try{var r=e(t)}catch(i){return n.onError(i)}ut(r)&&(r=Xe(r));var s=new fe;o.setDisposable(s),s.setDisposable(r.subscribe(n))},function(t){n.onCompleted(t)})),o},t)}function W(){return!1}function z(t,e){var n=this;return new qn(function(r){var o=0,i=t.length;return n.subscribe(function(n){if(i>o){var s=t[o++],u=x(e)(n,s);if(u===ne)return r.onError(u.e);r.onNext(u)}else r.onCompleted()},function(t){r.onError(t)},function(){r.onCompleted()})},n)}function W(){return!1}function G(){return[]}function W(){return!1}function J(){return[]}function I(t,e){this.observer=t,this.accumulator=e.accumulator,this.hasSeed=e.hasSeed,this.seed=e.seed,this.hasAccumulation=!1,this.accumulation=null,this.hasValue=!1,this.isStopped=!1}function L(t,e,n){var r=At(e,n,3);return t.map(function(e,n){var o=r(e,n,t);return ut(o)&&(o=Xe(o)),(Et(o)||St(o))&&(o=nn(o)),o}).concatAll()}function B(t,e,n){for(var r=0,o=t.length;o>r;r++)if(n(t[r],e))return r;return-1}function F(t){this.comparer=t,this.set=[]}function U(t,e,n){var r=At(e,n,3);return t.map(function(e,n){var o=r(e,n,t);return ut(o)&&(o=Xe(o)),(Et(o)||St(o))&&(o=nn(o)),o}).mergeAll()}var H={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},X=H[typeof window]&&window||this,Q=H[typeof r]&&r&&!r.nodeType&&r,K=H[typeof n]&&n&&!n.nodeType&&n,Y=K&&K.exports===Q&&Q,Z=H[typeof o]&&o;!Z||Z.global!==Z&&Z.window!==Z||(X=Z);var tt={internals:{},config:{Promise:X.Promise},helpers:{}},et=tt.helpers.noop=function(){},nt=(tt.helpers.notDefined=function(t){return"undefined"==typeof t},tt.helpers.identity=function(t){return t}),rt=(tt.helpers.pluck=function(t){return function(e){return e[t]}},tt.helpers.just=function(t){return function(){return t}},tt.helpers.defaultNow=Date.now),ot=tt.helpers.defaultComparer=function(t,e){return Kt(t,e)},it=tt.helpers.defaultSubComparer=function(t,e){return t>e?1:e>t?-1:0},st=(tt.helpers.defaultKeySerializer=function(t){return t.toString()},tt.helpers.defaultError=function(t){throw t}),ut=tt.helpers.isPromise=function(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then},at=(tt.helpers.asArray=function(){return Array.prototype.slice.call(arguments)},tt.helpers.not=function(t){return!t},tt.helpers.isFunction=function(){var t=function(t){return"function"==typeof t||!1};return t(/x/)&&(t=function(t){return"function"==typeof t&&"[object Function]"==Wt.call(t)}),t}());tt.config.longStackSupport=!1;var ct=!1;try{throw new Error}catch(pt){ct=!!pt.stack}var ht,ft=f(),lt="From previous event:",dt=tt.EmptyError=function(){this.message="Sequence contains no elements.",Error.call(this)};dt.prototype=Error.prototype;var vt=tt.ObjectDisposedError=function(){this.message="Object has been disposed",Error.call(this)};vt.prototype=Error.prototype;var yt=tt.ArgumentOutOfRangeError=function(){this.message="Argument out of range",Error.call(this)};yt.prototype=Error.prototype;var bt=tt.NotSupportedError=function(t){this.message=t||"This operation is not supported",Error.call(this)};bt.prototype=Error.prototype;var mt=tt.NotImplementedError=function(t){this.message=t||"This operation is not implemented",Error.call(this)};mt.prototype=Error.prototype;var gt=tt.helpers.notImplemented=function(){throw new mt},wt=tt.helpers.notSupported=function(){throw new bt},xt="function"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";X.Set&&"function"==typeof(new X.Set)["@@iterator"]&&(xt="@@iterator");var _t=tt.doneEnumerator={done:!0,value:i},St=tt.helpers.isIterable=function(t){return t[xt]!==i},Et=tt.helpers.isArrayLike=function(t){return t&&t.length!==i};tt.helpers.iterator=xt;var Ct,At=tt.internals.bindCallback=function(t,e,n){if("undefined"==typeof e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}},Nt=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],kt=Nt.length,Ot="[object Arguments]",Pt="[object Array]",jt="[object Boolean]",Dt="[object Date]",qt="[object Error]",Rt="[object Function]",Mt="[object Number]",Tt="[object Object]",Vt="[object RegExp]",$t="[object String]",Wt=Object.prototype.toString,zt=Object.prototype.hasOwnProperty,Gt=Wt.call(arguments)==Ot,Jt=Error.prototype,It=Object.prototype,Lt=String.prototype,Bt=It.propertyIsEnumerable;try{Ct=!(Wt.call(document)==Tt&&!({toString:0}+""))}catch(pt){Ct=!0}var Ft={};Ft[Pt]=Ft[Dt]=Ft[Mt]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},Ft[jt]=Ft[$t]={constructor:!0,toString:!0,valueOf:!0},Ft[qt]=Ft[Rt]=Ft[Vt]={constructor:!0,toString:!0},Ft[Tt]={constructor:!0};var Ut={};!function(){var t=function(){this.x=1},e=[];t.prototype={valueOf:1,y:1};for(var n in new t)e.push(n);for(n in arguments);Ut.enumErrorProps=Bt.call(Jt,"message")||Bt.call(Jt,"name"),Ut.enumPrototypes=Bt.call(t,"prototype"),Ut.nonEnumArgs=0!=n,Ut.nonEnumShadows=!/valueOf/.test(e)}(1);var Ht=tt.internals.isObject=function(t){var e=typeof t;return t&&("function"==e||"object"==e)||!1},Xt=function(t){return t&&"object"==typeof t?Wt.call(t)==Ot:!1};Gt||(Xt=function(t){return t&&"object"==typeof t?zt.call(t,"callee"):!1});var Qt,Kt=tt.internals.isEqual=function(t,e){return m(t,e,[],[])},Yt=({}.hasOwnProperty,Array.prototype.slice),Zt=this.inherits=tt.internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},te=tt.internals.addProperties=function(t){for(var e=[],n=1,r=arguments.length;r>n;n++)e.push(arguments[n]);for(var o=0,i=e.length;i>o;o++){var s=e[o];for(var u in s)t[u]=s[u]}},ee=tt.internals.addRef=function(t,e){return new qn(function(n){return new ie(e.getDisposable(),t.subscribe(n))})},ne={e:{}};S.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var re=tt.internals.PriorityQueue=function(t){this.items=new Array(t),this.length=0},oe=re.prototype;oe.isHigherPriority=function(t,e){return this.items[t].compareTo(this.items[e])<0},oe.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},oe.heapify=function(t){if(+t||(t=0),!(t>=this.length||0>t)){var e=2*t+1,n=2*t+2,r=t;if(e<this.length&&this.isHigherPriority(e,r)&&(r=e),n<this.length&&this.isHigherPriority(n,r)&&(r=n),r!==t){var o=this.items[t];this.items[t]=this.items[r],this.items[r]=o,this.heapify(r)}}},oe.peek=function(){return this.items[0].value},oe.removeAt=function(t){this.items[t]=this.items[--this.length],this.items[this.length]=i,this.heapify()},oe.dequeue=function(){var t=this.peek();return this.removeAt(0),t},oe.enqueue=function(t){var e=this.length++;this.items[e]=new S(re.count++,t),this.percolate(e)},oe.remove=function(t){for(var e=0;e<this.length;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},re.count=0;var ie=tt.CompositeDisposable=function(){var t,e,n=[];if(Array.isArray(arguments[0]))n=arguments[0],e=n.length;else for(e=arguments.length,n=new Array(e),t=0;e>t;t++)n[t]=arguments[t];for(t=0;e>t;t++)if(!pe(n[t]))throw new TypeError("Not a disposable");this.disposables=n,this.isDisposed=!1,this.length=n.length},se=ie.prototype;se.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},se.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},se.dispose=function(){
3472 if(!this.isDisposed){this.isDisposed=!0;for(var t=this.disposables.length,e=new Array(t),n=0;t>n;n++)e[n]=this.disposables[n];for(this.disposables=[],this.length=0,n=0;t>n;n++)e[n].dispose()}};var ue=tt.Disposable=function(t){this.isDisposed=!1,this.action=t||et};ue.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var ae=ue.create=function(t){return new ue(t)},ce=ue.empty={dispose:et},pe=ue.isDisposable=function(t){return t&&at(t.dispose)},he=ue.checkDisposed=function(t){if(t.isDisposed)throw new vt},fe=tt.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null};fe.prototype.getDisposable=function(){return this.current},fe.prototype.setDisposable=function(t){if(this.current)throw new Error("Disposable has already been assigned");var e=this.isDisposed;!e&&(this.current=t),e&&t&&t.dispose()},fe.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.current;this.current=null}t&&t.dispose()};var le=tt.SerialDisposable=function(){this.isDisposed=!1,this.current=null};le.prototype.getDisposable=function(){return this.current},le.prototype.setDisposable=function(t){var e=this.isDisposed;if(!e){var n=this.current;this.current=t}n&&n.dispose(),e&&t&&t.dispose()},le.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.current;this.current=null}t&&t.dispose()};var de=tt.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?ce:new t(this)},e}();E.prototype.dispose=function(){this.scheduler.scheduleWithState(this,C)};var ve=tt.internals.ScheduledItem=function(t,e,n,r,o){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=o||it,this.disposable=new fe};ve.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},ve.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},ve.prototype.isCancelled=function(){return this.disposable.isDisposed},ve.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var ye=tt.Scheduler=function(){function t(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function e(t,e){return e(),ce}t.isScheduler=function(e){return e instanceof t};var n=t.prototype;return n.schedule=function(t){return this._schedule(t,e)},n.scheduleWithState=function(t,e){return this._schedule(t,e)},n.scheduleWithRelative=function(t,n){return this._scheduleRelative(n,t,e)},n.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},n.scheduleWithAbsolute=function(t,n){return this._scheduleAbsolute(n,t,e)},n.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},t.now=rt,t.normalize=function(t){return 0>t&&(t=0),t},t}(),be=ye.normalize,me=ye.isScheduler;!function(t){function e(t,e){function n(e){o(e,function(e){var r=!1,o=!1,s=t.scheduleWithState(e,function(t,e){return r?i.remove(s):o=!0,n(e),ce});o||(i.add(s),r=!0)})}var r=e[0],o=e[1],i=new ie;return n(r),i}function n(t,e,n){function r(e){i(e,function(e,o){var i=!1,u=!1,a=t[n](e,o,function(t,e){return i?s.remove(a):u=!0,r(e),ce});u||(s.add(a),i=!0)})}var o=e[0],i=e[1],s=new ie;return r(o),s}function r(t,e){t(function(n){e(t,n)})}t.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,r)},t.scheduleRecursiveWithState=function(t,n){return this.scheduleWithState([t,n],e)},t.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,r)},t.scheduleRecursiveWithRelativeAndState=function(t,e,r){return this._scheduleRelative([t,r],e,function(t,e){return n(t,e,"scheduleWithRelativeAndState")})},t.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,r)},t.scheduleRecursiveWithAbsoluteAndState=function(t,e,r){return this._scheduleAbsolute([t,r],e,function(t,e){return n(t,e,"scheduleWithAbsoluteAndState")})}}(ye.prototype),function(t){ye.prototype.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,e)},ye.prototype.schedulePeriodicWithState=function(t,e,n){if("undefined"==typeof X.setInterval)throw new bt;e=be(e);var r=t,o=X.setInterval(function(){r=n(r)},e);return ae(function(){X.clearInterval(o)})}}(ye.prototype),function(t){t.catchError=t["catch"]=function(t){return new Ae(this,t)}}(ye.prototype);var ge,we,xe=(tt.internals.SchedulePeriodicRecursive=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,r){this._scheduler=t,this._state=e,this._period=n,this._action=r}return e.prototype.start=function(){var e=new fe;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}(),ye.immediate=function(){function t(t,e){return e(this,t)}return new ye(rt,t,wt,wt)}()),_e=ye.currentThread=function(){function t(){for(;n.length>0;){var t=n.dequeue();!t.isCancelled()&&t.invoke()}}function e(e,r){var o=new ve(this,e,r,this.now());if(n)n.enqueue(o);else{n=new re(4),n.enqueue(o);var i=x(t)();if(n=null,i===ne)return _(i.e)}return o.disposable}var n,r=new ye(rt,e,wt,wt);return r.scheduleRequired=function(){return!n},r}(),Se=function(){var t,e=et;if(X.setTimeout)t=X.setTimeout,e=X.clearTimeout;else{if(!X.WScript)throw new bt;t=function(t,e){X.WScript.Sleep(e),t()}}return{setTimeout:t,clearTimeout:e}}(),Ee=Se.setTimeout,Ce=Se.clearTimeout;!function(){function t(e){if(s)Ee(function(){t(e)},0);else{var n=i[e];if(n){s=!0;var r=x(n)();if(we(e),s=!1,r===ne)return _(r.e)}}}function n(){if(!X.postMessage||X.importScripts)return!1;var t=!1,e=X.onmessage;return X.onmessage=function(){t=!0},X.postMessage("","*"),X.onmessage=e,t}function r(e){"string"==typeof e.data&&e.data.substring(0,c.length)===c&&t(e.data.substring(c.length))}var o=1,i={},s=!1;we=function(t){delete i[t]};var u=RegExp("^"+String(Wt).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),a="function"==typeof(a=Z&&Y&&Z.setImmediate)&&!u.test(a)&&a;if(at(a))ge=function(e){var n=o++;return i[n]=e,a(function(){t(n)}),n};else if("undefined"!=typeof e&&"[object process]"==={}.toString.call(e))ge=function(n){var r=o++;return i[r]=n,e.nextTick(function(){t(r)}),r};else if(n()){var c="ms.rx.schedule"+Math.random();X.addEventListener?X.addEventListener("message",r,!1):X.attachEvent?X.attachEvent("onmessage",r):X.onmessage=r,ge=function(t){var e=o++;return i[e]=t,X.postMessage(c+currentId,"*"),e}}else if(X.MessageChannel){var p=new X.MessageChannel;p.port1.onmessage=function(e){t(e.data)},ge=function(t){var e=o++;return i[e]=t,p.port2.postMessage(e),e}}else ge="document"in X&&"onreadystatechange"in X.document.createElement("script")?function(e){var n=X.document.createElement("script"),r=o++;return i[r]=e,n.onreadystatechange=function(){t(r),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},X.document.documentElement.appendChild(n),r}:function(e){var n=o++;return i[n]=e,Ee(function(){t(n)},0),n}}();var Ae=(ye.timeout=ye["default"]=function(){function t(t,e){var n=this,r=new fe,o=ge(function(){!r.isDisposed&&r.setDisposable(e(n,t))});return new ie(r,ae(function(){we(o)}))}function e(t,e,n){var r=this,o=ye.normalize(e),i=new fe;if(0===o)return r.scheduleWithState(t,n);var s=Ee(function(){!i.isDisposed&&i.setDisposable(n(r,t))},o);return new ie(i,ae(function(){Ce(s)}))}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new ye(rt,t,e,n)}(),function(t){function e(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function n(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function r(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function o(o,i){this._scheduler=o,this._handler=i,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,this._scheduler.now.bind(this._scheduler),e,n,r)}return Zt(o,t),o.prototype._clone=function(t){return new o(t,this._handler)},o.prototype._wrap=function(t){var e=this;return function(n,r){try{return t(e._getRecursiveWrapper(n),r)}catch(o){if(!e._handler(o))throw o;return ce}}},o.prototype._getRecursiveWrapper=function(t){if(this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},o.prototype.schedulePeriodicWithState=function(t,e,n){var r=this,o=!1,i=new fe;return i.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(o)return null;try{return n(t)}catch(e){if(o=!0,!r._handler(e))throw e;return i.dispose(),null}})),i},o}(ye)),Ne=tt.Notification=function(){function t(t,e,n,r,o,i){this.kind=t,this.value=e,this.exception=n,this._accept=r,this._acceptObservable=o,this.toString=i}return t.prototype.accept=function(t,e,n){return t&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},t.prototype.toObservable=function(t){var e=this;return me(t)||(t=xe),new qn(function(n){return t.scheduleWithState(e,function(t,e){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},t}(),ke=Ne.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(r){return new Ne("N",r,null,t,e,n)}}(),Oe=Ne.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(r){return new Ne("E",null,r,t,e,n)}}(),Pe=Ne.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){return new Ne("C",null,null,t,e,n)}}(),je=tt.Observer=function(){};je.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},je.prototype.asObserver=function(){return new Me(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},je.prototype.checked=function(){return new Te(this)};var De=je.create=function(t,e,n){return t||(t=et),e||(e=st),n||(n=et),new Me(t,e,n)};je.fromNotifier=function(t,e){return new Me(function(n){return t.call(e,ke(n))},function(n){return t.call(e,Oe(n))},function(){return t.call(e,Pe())})},je.prototype.notifyOn=function(t){return new $e(t,this)},je.prototype.makeSafe=function(t){return new AnonymousSafeObserver(this._onNext,this._onError,this._onCompleted,t)};var qe,Re=tt.internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return Zt(e,t),e.prototype.next=gt,e.prototype.error=gt,e.prototype.completed=gt,e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.error(t),!0)},e}(je),Me=tt.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return Zt(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(Re),Te=function(t){function e(e){t.call(this),this._observer=e,this._state=0}Zt(e,t);var n=e.prototype;return n.onNext=function(t){this.checkAccess();var e=x(this._observer.onNext).call(this._observer,t);this._state=0,e===ne&&_(e.e)},n.onError=function(t){this.checkAccess();var e=x(this._observer.onError).call(this._observer,t);this._state=2,e===ne&&_(e.e)},n.onCompleted=function(){this.checkAccess();var t=x(this._observer.onCompleted).call(this._observer);this._state=2,t===ne&&_(t.e)},n.checkAccess=function(){if(1===this._state)throw new Error("Re-entrancy detected");if(2===this._state)throw new Error("Observer completed");0===this._state&&(this._state=1)},e}(je),Ve=tt.internals.ScheduledObserver=function(t){function e(e,n){t.call(this),this.scheduler=e,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new le}return Zt(e,t),e.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},e.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},e.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},e.prototype.ensureActive=function(){var t=!1,e=this;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(t){var n;if(!(e.queue.length>0))return void(e.isAcquired=!1);n=e.queue.shift();try{n()}catch(r){throw e.queue=[],e.hasFaulted=!0,r}t()}))},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},e}(Re),$e=function(t){function e(e,n,r){t.call(this,e,n),this._cancel=r}return Zt(e,t),e.prototype.next=function(e){t.prototype.next.call(this,e),this.ensureActive()},e.prototype.error=function(e){t.prototype.error.call(this,e),this.ensureActive()},e.prototype.completed=function(){t.prototype.completed.call(this),this.ensureActive()},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._cancel&&this._cancel.dispose(),this._cancel=null},e}(Ve),We=tt.Observable=function(){function t(t){if(tt.config.longStackSupport&&ct){try{throw new Error}catch(e){this.stack=e.stack.substring(e.stack.indexOf("\n")+1)}var n=this;this._subscribe=function(e){var r=e.onError.bind(e);return e.onError=function(t){a(t,n),r(t)},t.call(n,e)}}else this._subscribe=t}return qe=t.prototype,qe.subscribe=qe.forEach=function(t,e,n){return this._subscribe("object"==typeof t?t:De(t,e,n))},qe.subscribeOnNext=function(t,e){return this._subscribe(De("undefined"!=typeof e?function(n){t.call(e,n)}:t))},qe.subscribeOnError=function(t,e){return this._subscribe(De(null,"undefined"!=typeof e?function(n){t.call(e,n)}:t))},qe.subscribeOnCompleted=function(t,e){return this._subscribe(De(null,null,"undefined"!=typeof e?function(){t.call(e)}:t))},t}(),ze=tt.ObservableBase=function(t){function e(t){return t&&at(t.dispose)?t:at(t)?ae(t):ce}function n(t,n){var r=n[0],o=n[1],i=x(o.subscribeCore).call(o,r);return i!==ne||r.fail(ne.e)?void r.setDisposable(e(i)):_(ne.e)}function r(t){var e=new Rn(t),r=[e,this];return _e.scheduleRequired()?_e.scheduleWithState(r,n):n(null,r),e}function o(){t.call(this,r)}return Zt(o,t),o.prototype.subscribeCore=gt,o}(We),Ge=tt.internals.Enumerable=function(){},Je=function(t){function e(e){this.sources=e,t.call(this)}function n(t,e,n){this.o=t,this.s=e,this.e=n,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){var e,r=new le,o=xe.scheduleRecursiveWithState(this.sources[xt](),function(o,i){if(!e){var s=x(o.next).call(o);if(s===ne)return t.onError(s.e);if(s.done)return t.onCompleted();var u=s.value;ut(u)&&(u=Xe(u));var a=new fe;r.setDisposable(a),a.setDisposable(u.subscribe(new n(t,i,o)))}});return new ie(r,o,ae(function(){e=!0}))},n.prototype.onNext=function(t){this.isStopped||this.o.onNext(t)},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.s(this.e))},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);Ge.prototype.concat=function(){return new Je(this)};var Ie=function(t){function e(e){this.sources=e,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e,n=this.sources[xt](),r=new le,o=xe.scheduleRecursiveWithState(null,function(o,i){if(!e){var s=x(n.next).call(n);if(s===ne)return t.onError(s.e);if(s.done)return null!==o?t.onError(o):t.onCompleted();var u=s.value;ut(u)&&(u=Xe(u));var a=new fe;r.setDisposable(a),a.setDisposable(u.subscribe(function(e){t.onNext(e)},i,function(){t.onCompleted()}))}});return new ie(r,o,ae(function(){e=!0}))},e}(ze);Ge.prototype.catchError=function(){return new Ie(this)},Ge.prototype.catchErrorWhen=function(t){var e=this;return new qn(function(n){var r,o,i=new Tn,s=new Tn,u=t(i),a=u.subscribe(s),c=e[xt](),p=new le,h=xe.scheduleRecursive(function(t){if(!r){var e=x(c.next).call(c);if(e===ne)return n.onError(e.e);if(e.done)return void(o?n.onError(o):n.onCompleted());var u=e.value;ut(u)&&(u=Xe(u));var a=new fe,h=new fe;p.setDisposable(new ie(h,a)),a.setDisposable(u.subscribe(function(t){n.onNext(t)},function(e){h.setDisposable(s.subscribe(t,function(t){n.onError(t)},function(){n.onCompleted()})),i.onNext(e)},function(){n.onCompleted()}))}});return new ie(a,p,h,ae(function(){r=!0}))})};var Le=function(t){function e(t,e){this.v=t,this.c=null==e?-1:e}function n(t){this.v=t.v,this.l=t.c}return Zt(e,t),e.prototype[xt]=function(){return new n(this)},n.prototype.next=function(){return 0===this.l?_t:(this.l>0&&this.l--,{done:!1,value:this.v})},e}(Ge),Be=Ge.repeat=function(t,e){return new Le(t,e)},Fe=function(t){function e(t,e,n){this.s=t,this.fn=e?At(e,n,3):null}function n(t){this.i=-1,this.s=t.s,this.l=this.s.length,this.fn=t.fn}return Zt(e,t),e.prototype[xt]=function(){return new n(this)},n.prototype.next=function(){return++this.i<this.l?{done:!1,value:this.fn?this.fn(this.s[this.i],this.i,this.s):this.s[this.i]}:_t},e}(Ge),Ue=Ge.of=function(t,e,n){return new Fe(t,e,n)};qe.observeOn=function(t){var e=this;return new qn(function(n){return e.subscribe(new $e(t,n))},e)},qe.subscribeOn=function(t){var e=this;return new qn(function(n){var r=new fe,o=new le;return o.setDisposable(r),r.setDisposable(t.schedule(function(){o.setDisposable(new E(t,e.subscribe(n)))})),o},e)};var He=function(t){function e(e){this.p=e,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.p.then(function(e){t.onNext(e),t.onCompleted()},function(e){t.onError(e)}),ce},e}(ze),Xe=We.fromPromise=function(t){return new He(t)};qe.toPromise=function(t){if(t||(t=tt.config.Promise),!t)throw new bt("Promise type not provided nor in Rx.config.Promise");var e=this;return new t(function(t,n){var r,o=!1;e.subscribe(function(t){r=t,o=!0},n,function(){o&&t(r)})})};var Qe=function(t){function e(e){this.source=e,t.call(this)}function n(t){this.o=t,this.a=[],this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t))},n.prototype.onNext=function(t){this.isStopped||this.a.push(t)},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onNext(this.a),this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe.toArray=function(){return new Qe(this)},We.create=We.createWithDisposable=function(t,e){return new qn(t,e)};var Ke=(We.defer=function(t){return new qn(function(e){var n;try{n=t()}catch(r){return dn(r).subscribe(e)}return ut(n)&&(n=Xe(n)),n.subscribe(e)})},function(t){function e(e){this.scheduler=e,t.call(this)}function n(t,e){this.observer=t,this.parent=e}function r(t,e){e.onCompleted()}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new n(t,this);return e.run()},n.prototype.run=function(){return this.parent.scheduler.scheduleWithState(this.observer,r)},e}(ze)),Ye=We.empty=function(t){return me(t)||(t=xe),new Ke(t)},Ze=function(t){function e(e,n,r){this.iterable=e,this.mapper=n,this.scheduler=r,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new tn(t,this);return e.run()},e}(ze),tn=function(){function t(t,e){this.observer=t,this.parent=e}return t.prototype.run=function(){function t(t,e){try{var i=n.next()}catch(s){return r.onError(s)}if(i.done)return r.onCompleted();var u=i.value;if(o)try{u=o(u,t)}catch(s){return r.onError(s)}r.onNext(u),e(t+1)}var e=Object(this.parent.iterable),n=j(e),r=this.observer,o=this.parent.mapper;return this.parent.scheduler.scheduleRecursiveWithState(0,t)},t}(),en=Math.pow(2,53)-1;A.prototype[xt]=function(){return new N(this._s)},N.prototype[xt]=function(){return this},N.prototype.next=function(){return this._i<this._l?{done:!1,value:this._s.charAt(this._i++)}:_t},k.prototype[xt]=function(){return new O(this._a)},O.prototype[xt]=function(){return this},O.prototype.next=function(){return this._i<this._l?{done:!1,value:this._a[this._i++]}:_t};var nn=We.from=function(t,e,n,r){if(null==t)throw new Error("iterable cannot be null.");if(e&&!at(e))throw new Error("mapFn when provided must be a function");if(e)var o=At(e,n,2);return me(r)||(r=_e),new Ze(t,o,r)},rn=function(t){function e(e,n){this.args=e,this.scheduler=n,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new R(t,this);return e.run()},e}(ze);R.prototype.run=function(){function t(t,o){r>t?(e.onNext(n[t]),o(t+1)):e.onCompleted()}var e=this.observer,n=this.parent.args,r=n.length;return this.parent.scheduler.scheduleRecursiveWithState(0,t)};var on=We.fromArray=function(t,e){return me(e)||(e=_e),new rn(t,e)};We.generate=function(t,e,n,r,o){return me(o)||(o=_e),new qn(function(i){var s=!0;return o.scheduleRecursiveWithState(t,function(t,o){var u,a;try{s?s=!1:t=n(t),u=e(t),u&&(a=r(t))}catch(c){return i.onError(c)}u?(i.onNext(a),o(t)):i.onCompleted()})})};var sn=function(t){function e(){t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){return ce},e}(ze),un=We.never=function(){return new sn};We.of=function(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];return new rn(e,_e)},We.ofWithScheduler=function(t){for(var e=arguments.length,n=new Array(e-1),r=1;e>r;r++)n[r-1]=arguments[r];return new rn(n,t)};var an=function(t){function e(e,n){this.obj=e,this.keys=Object.keys(e),this.scheduler=n,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new T(t,this);return e.run()},e}(ze);T.prototype.run=function(){function t(t,i){if(o>t){var s=r[t];e.onNext([s,n[s]]),i(t+1)}else e.onCompleted()}var e=this.observer,n=this.parent.obj,r=this.parent.keys,o=r.length;return this.parent.scheduler.scheduleRecursiveWithState(0,t)},We.pairs=function(t,e){return e||(e=_e),new an(t,e)};var cn=function(t){function e(e,n,r){this.start=e,this.rangeCount=n,this.scheduler=r,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new pn(t,this);return e.run()},e}(ze),pn=function(){function t(t,e){this.observer=t,this.parent=e}return t.prototype.run=function(){function t(t,o){n>t?(r.onNext(e+t),o(t+1)):r.onCompleted()}var e=this.parent.start,n=this.parent.rangeCount,r=this.observer;return this.parent.scheduler.scheduleRecursiveWithState(0,t)},t}();We.range=function(t,e,n){return me(n)||(n=_e),new cn(t,e,n)};var hn=function(t){function e(e,n,r){this.value=e,this.repeatCount=null==n?-1:n,this.scheduler=r,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new V(t,this);return e.run()},e}(ze);V.prototype.run=function(){function t(t,r){return(-1===t||t>0)&&(e.onNext(n),t>0&&t--),0===t?e.onCompleted():void r(t)}var e=this.observer,n=this.parent.value;return this.parent.scheduler.scheduleRecursiveWithState(this.parent.repeatCount,t)},We.repeat=function(t,e,n){return me(n)||(n=_e),new hn(t,e,n)};var fn=function(t){function e(e,n){this.value=e,this.scheduler=n,t.call(this)}function n(t,e){this.observer=t,this.parent=e}function r(t,e){var n=e[0],r=e[1];r.onNext(n),r.onCompleted()}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new n(t,this);return e.run()},n.prototype.run=function(){return this.parent.scheduler.scheduleWithState([this.parent.value,this.observer],r)},e}(ze),ln=(We["return"]=We.just=We.returnValue=function(t,e){return me(e)||(e=xe),new fn(t,e)},function(t){function e(e,n){this.error=e,this.scheduler=n,t.call(this)}function n(t,e){this.o=t,this.p=e}function r(t,e){var n=e[0],r=e[1];r.onError(n)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new n(t,this);return e.run()},n.prototype.run=function(){return this.p.scheduler.scheduleWithState([this.p.error,this.o],r)},e}(ze)),dn=We["throw"]=We.throwError=We.throwException=function(t,e){return me(e)||(e=xe),new ln(t,e)};We.using=function(t,e){return new qn(function(n){var r,o,i=ce;try{r=t(),r&&(i=r),o=e(r)}catch(s){return new ie(dn(s).subscribe(n),i)}return new ie(o.subscribe(n),i)})},qe.amb=function(t){var e=this;return new qn(function(n){function r(){i||(i=s,c.dispose())}function o(){i||(i=u,a.dispose())}var i,s="L",u="R",a=new fe,c=new fe;return ut(t)&&(t=Xe(t)),a.setDisposable(e.subscribe(function(t){r(),i===s&&n.onNext(t)},function(t){r(),i===s&&n.onError(t)},function(){r(),i===s&&n.onCompleted()})),c.setDisposable(t.subscribe(function(t){o(),i===u&&n.onNext(t)},function(t){o(),i===u&&n.onError(t)},function(){o(),i===u&&n.onCompleted()})),new ie(a,c)})},We.amb=function(){function t(t,e){return t.amb(e)}var e=un(),n=[];if(Array.isArray(arguments[0]))n=arguments[0];else for(var r=0,o=arguments.length;o>r;r++)n.push(arguments[r]);for(var r=0,o=n.length;o>r;r++)e=t(e,n[r]);return e},qe["catch"]=qe.catchError=qe.catchException=function(t){return"function"==typeof t?$(this,t):vn([this,t])};var vn=We.catchError=We["catch"]=We.catchException=function(){var t=[];if(Array.isArray(arguments[0]))t=arguments[0];else for(var e=0,n=arguments.length;n>e;e++)t.push(arguments[e]);return Ue(t).catchError()};qe.combineLatest=function(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];return Array.isArray(e[0])?e[0].unshift(this):e.unshift(this),yn.apply(this,e)};var yn=We.combineLatest=function(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=e.pop();return Array.isArray(e[0])&&(e=e[0]),new qn(function(t){function n(e){if(u[e]=!0,a||(a=u.every(nt))){try{var n=r.apply(null,p)}catch(o){return t.onError(o)}t.onNext(n)}else c.filter(function(t,n){return n!==e}).every(nt)&&t.onCompleted()}function o(e){c[e]=!0,c.every(nt)&&t.onCompleted()}for(var i=e.length,s=function(){return!1},u=g(i,s),a=!1,c=g(i,s),p=new Array(i),h=new Array(i),f=0;i>f;f++)!function(r){var i=e[r],s=new fe;ut(i)&&(i=Xe(i)),s.setDisposable(i.subscribe(function(t){p[r]=t,n(r)},function(e){t.onError(e)},function(){o(r)})),h[r]=s}(f);return new ie(h)},this)};qe.concat=function(){for(var t=[],e=0,n=arguments.length;n>e;e++)t.push(arguments[e]);return t.unshift(this),mn.apply(null,t)};var bn=function(t){function e(e){this.sources=e,t.call(this)}function n(t,e){this.sources=t,this.o=e}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new n(this.sources,t);return e.run()},n.prototype.run=function(){var t,e=new le,n=this.sources,r=n.length,o=this.o,i=xe.scheduleRecursiveWithState(0,function(i,s){if(!t){if(i===r)return o.onCompleted();var u=n[i];ut(u)&&(u=Xe(u));var a=new fe;e.setDisposable(a),a.setDisposable(u.subscribe(function(t){o.onNext(t)},function(t){o.onError(t)},function(){s(i+1)}))}});return new ie(e,i,ae(function(){t=!0}))},e}(ze),mn=We.concat=function(){var t;if(Array.isArray(arguments[0]))t=arguments[0];else{t=new Array(arguments.length);for(var e=0,n=arguments.length;n>e;e++)t[e]=arguments[e]}return new bn(t)};qe.concatAll=qe.concatObservable=function(){return this.merge(1)};var gn=function(t){function e(e,n){this.source=e,this.maxConcurrent=n,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new ie;return e.add(this.source.subscribe(new wn(t,this.maxConcurrent,e))),e},e}(ze),wn=function(){function t(t,e,n){this.o=t,this.max=e,this.g=n,this.done=!1,this.q=[],this.activeCount=0,this.isStopped=!1}function e(t,e){this.parent=t,this.sad=e,this.isStopped=!1}return t.prototype.handleSubscribe=function(t){var n=new fe;this.g.add(n),ut(t)&&(t=Xe(t)),n.setDisposable(t.subscribe(new e(this,n)))},t.prototype.onNext=function(t){this.isStopped||(this.activeCount<this.max?(this.activeCount++,this.handleSubscribe(t)):this.q.push(t))},t.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},t.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.done=!0,0===this.activeCount&&this.o.onCompleted())},t.prototype.dispose=function(){this.isStopped=!0},t.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e.prototype.onNext=function(t){this.isStopped||this.parent.o.onNext(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.parent.o.onError(t))},e.prototype.onCompleted=function(){if(!this.isStopped){this.isStopped=!0;var t=this.parent;t.g.remove(this.sad),t.q.length>0?t.handleSubscribe(t.q.shift()):(t.activeCount--,t.done&&0===t.activeCount&&t.o.onCompleted())}},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(t),!0)},t}();qe.merge=function(t){return"number"!=typeof t?xn(this,t):new gn(this,t)};var xn=We.merge=function(){var t,e,n=[],r=arguments.length;if(arguments[0])if(me(arguments[0]))for(t=arguments[0],e=1;r>e;e++)n.push(arguments[e]);else for(t=xe,e=0;r>e;e++)n.push(arguments[e]);else for(t=xe,e=1;r>e;e++)n.push(arguments[e]);return Array.isArray(n[0])&&(n=n[0]),M(t,n).mergeAll()},_n=tt.CompositeError=function(t){this.name="NotImplementedError",this.innerErrors=t,this.message="This contains multiple errors. Check the innerErrors",Error.call(this)};_n.prototype=Error.prototype,We.mergeDelayError=function(){var t;if(Array.isArray(arguments[0]))t=arguments[0];else{var e=arguments.length;t=new Array(e);for(var n=0;e>n;n++)t[n]=arguments[n]}var r=M(null,t);return new qn(function(t){function e(){0===s.length?t.onCompleted():1===s.length?t.onError(s[0]):t.onError(new _n(s))}var n=new ie,o=new fe,i=!1,s=[];return n.add(o),o.setDisposable(r.subscribe(function(r){var o=new fe;n.add(o),ut(r)&&(r=Xe(r)),o.setDisposable(r.subscribe(function(e){t.onNext(e)},function(t){s.push(t),n.remove(o),i&&1===n.length&&e()},function(){n.remove(o),i&&1===n.length&&e()}))},function(t){s.push(t),i=!0,1===n.length&&e()},function(){i=!0,1===n.length&&e()})),n})};var Sn=function(t){function e(e){this.source=e,t.call(this)}function n(t,e){this.o=t,this.g=e,this.isStopped=!1,this.done=!1}function r(t,e,n){this.parent=t,this.g=e,this.sad=n,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new ie,r=new fe;return e.add(r),r.setDisposable(this.source.subscribe(new n(t,e))),e},n.prototype.onNext=function(t){if(!this.isStopped){var e=new fe;this.g.add(e),ut(t)&&(t=Xe(t)),e.setDisposable(t.subscribe(new r(this,this.g,e)))}},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.done=!0,1===this.g.length&&this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},r.prototype.onNext=function(t){this.isStopped||this.parent.o.onNext(t)},r.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.parent.o.onError(t))},r.prototype.onCompleted=function(){if(!this.isStopped){var t=this.parent;this.isStopped=!0,t.g.remove(this.sad),t.done&&1===t.g.length&&t.o.onCompleted()}},r.prototype.dispose=function(){this.isStopped=!0},r.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(t),!0)},e}(ze);qe.mergeAll=qe.mergeObservable=function(){
3473 return new Sn(this)},qe.onErrorResumeNext=function(t){if(!t)throw new Error("Second observable is required");return En([this,t])};var En=We.onErrorResumeNext=function(){var t=[];if(Array.isArray(arguments[0]))t=arguments[0];else for(var e=0,n=arguments.length;n>e;e++)t.push(arguments[e]);return new qn(function(e){var n=0,r=new le,o=xe.scheduleRecursive(function(o){var i,s;n<t.length?(i=t[n++],ut(i)&&(i=Xe(i)),s=new fe,r.setDisposable(s),s.setDisposable(i.subscribe(e.onNext.bind(e),o,o))):e.onCompleted()});return new ie(r,o)})};qe.skipUntil=function(t){var e=this;return new qn(function(n){var r=!1,o=new ie(e.subscribe(function(t){r&&n.onNext(t)},function(t){n.onError(t)},function(){r&&n.onCompleted()}));ut(t)&&(t=Xe(t));var i=new fe;return o.add(i),i.setDisposable(t.subscribe(function(){r=!0,i.dispose()},function(t){n.onError(t)},function(){i.dispose()})),o},e)};var Cn=function(t){function e(e){this.source=e,t.call(this)}function n(t,e){this.o=t,this.inner=e,this.stopped=!1,this.latest=0,this.hasLatest=!1,this.isStopped=!1}function r(t,e){this.parent=t,this.id=e,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new le,r=this.source.subscribe(new n(t,e));return new ie(r,e)},n.prototype.onNext=function(t){if(!this.isStopped){var e=new fe,n=++this.latest;this.hasLatest=!0,this.inner.setDisposable(e),ut(t)&&(t=Xe(t)),e.setDisposable(t.subscribe(new r(this,n)))}},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.stopped=!0,!this.hasLatest&&this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},r.prototype.onNext=function(t){this.isStopped||this.parent.latest===this.id&&this.parent.o.onNext(t)},r.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.parent.latest===this.id&&this.parent.o.onError(t))},r.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.parent.latest===this.id&&(this.parent.hasLatest=!1,this.parent.isStopped&&this.parent.o.onCompleted()))},r.prototype.dispose=function(){this.isStopped=!0},r.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(t),!0)},e}(ze);qe["switch"]=qe.switchLatest=function(){return new Cn(this)};var An=function(t){function e(e,n){this.source=e,this.other=ut(n)?Xe(n):n,t.call(this)}function n(t){this.o=t,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return new ie(this.source.subscribe(t),this.other.subscribe(new n(t)))},n.prototype.onNext=function(t){this.isStopped||this.o.onCompleted()},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){!this.isStopped&&(this.isStopped=!0)},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe.takeUntil=function(t){return new An(this,t)},qe.withLatestFrom=function(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=e.pop(),o=this;return Array.isArray(e[0])&&(e=e[0]),new qn(function(t){for(var n=e.length,i=g(n,W),s=!1,u=new Array(n),a=new Array(n+1),c=0;n>c;c++)!function(n){var r=e[n],o=new fe;ut(r)&&(r=Xe(r)),o.setDisposable(r.subscribe(function(t){u[n]=t,i[n]=!0,s=i.every(nt)},function(e){t.onError(e)},et)),a[n]=o}(c);var p=new fe;return p.setDisposable(o.subscribe(function(e){var n=[e].concat(u);if(s){var o=x(r).apply(null,n);return o===ne?t.onError(o.e):void t.onNext(o)}},function(e){t.onError(e)},function(){t.onCompleted()})),a[n]=p,new ie(a)},this)},qe.zip=function(){if(Array.isArray(arguments[0]))return z.apply(this,arguments);for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=this,o=e.pop();return e.unshift(r),new qn(function(t){for(var n=e.length,i=g(n,G),s=g(n,W),u=new Array(n),a=0;n>a;a++)!function(n){var a=e[n],c=new fe;ut(a)&&(a=Xe(a)),c.setDisposable(a.subscribe(function(e){if(i[n].push(e),i.every(function(t){return t.length>0})){var u=i.map(function(t){return t.shift()}),a=x(o).apply(r,u);if(a===ne)return t.onError(a.e);t.onNext(a)}else s.filter(function(t,e){return e!==n}).every(nt)&&t.onCompleted()},function(e){t.onError(e)},function(){s[n]=!0,s.every(nt)&&t.onCompleted()})),u[n]=c}(a);return new ie(u)},r)},We.zip=function(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=e.shift();return r.zip.apply(r,e)},We.zipArray=function(){var t;if(Array.isArray(arguments[0]))t=arguments[0];else{var e=arguments.length;t=new Array(e);for(var n=0;e>n;n++)t[n]=arguments[n]}return new qn(function(e){for(var n=t.length,r=g(n,J),o=g(n,W),i=new Array(n),s=0;n>s;s++)!function(n){i[n]=new fe,i[n].setDisposable(t[n].subscribe(function(t){if(r[n].push(t),r.every(function(t){return t.length>0})){var i=r.map(function(t){return t.shift()});e.onNext(i)}else if(o.filter(function(t,e){return e!==n}).every(nt))return e.onCompleted()},function(t){e.onError(t)},function(){o[n]=!0,o.every(nt)&&e.onCompleted()}))}(s);return new ie(i)})},qe.asObservable=function(){var t=this;return new qn(function(e){return t.subscribe(e)},t)},qe.bufferWithCount=function(t,e){return"number"!=typeof e&&(e=t),this.windowWithCount(t,e).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},qe.dematerialize=function(){var t=this;return new qn(function(e){return t.subscribe(function(t){return t.accept(e)},function(t){e.onError(t)},function(){e.onCompleted()})},this)},qe.distinctUntilChanged=function(t,e){var n=this;return e||(e=ot),new qn(function(r){var o,i=!1;return n.subscribe(function(n){var s=n;if(t&&(s=x(t)(n),s===ne))return r.onError(s.e);if(i){var u=x(e)(o,s);if(u===ne)return r.onError(u.e)}i&&u||(i=!0,o=s,r.onNext(n))},function(t){r.onError(t)},function(){r.onCompleted()})},this)};var Nn=function(t){function e(e,n,r,o){this.source=e,this.t=!n||at(n)?De(n||et,r||et,o||et):n,t.call(this)}function n(t,e){this.o=t,this.t=e,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t,this.t))},n.prototype.onNext=function(t){if(!this.isStopped){var e=x(this.t.onNext).call(this.t,t);e===ne&&this.o.onError(e.e),this.o.onNext(t)}},n.prototype.onError=function(t){if(!this.isStopped){this.isStopped=!0;var e=x(this.t.onError).call(this.t,t);if(e===ne)return this.o.onError(e.e);this.o.onError(t)}},n.prototype.onCompleted=function(){if(!this.isStopped){this.isStopped=!0;var t=x(this.t.onCompleted).call(this.t);if(t===ne)return this.o.onError(t.e);this.o.onCompleted()}},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe["do"]=qe.tap=qe.doAction=function(t,e,n){return new Nn(this,t,e,n)},qe.doOnNext=qe.tapOnNext=function(t,e){return this.tap("undefined"!=typeof e?function(n){t.call(e,n)}:t)},qe.doOnError=qe.tapOnError=function(t,e){return this.tap(et,"undefined"!=typeof e?function(n){t.call(e,n)}:t)},qe.doOnCompleted=qe.tapOnCompleted=function(t,e){return this.tap(et,null,"undefined"!=typeof e?function(){t.call(e)}:t)},qe["finally"]=qe.ensure=function(t){var e=this;return new qn(function(n){var r;try{r=e.subscribe(n)}catch(o){throw t(),o}return ae(function(){try{r.dispose()}catch(e){throw e}finally{t()}})},this)},qe.finallyAction=function(t){return this.ensure(t)};var kn=function(t){function e(e){this.source=e,t.call(this)}function n(t){this.o=t,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t))},n.prototype.onNext=et,n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(t),!0)},e}(ze);qe.ignoreElements=function(){return new kn(this)},qe.materialize=function(){var t=this;return new qn(function(e){return t.subscribe(function(t){e.onNext(ke(t))},function(t){e.onNext(Oe(t)),e.onCompleted()},function(){e.onNext(Pe()),e.onCompleted()})},t)},qe.repeat=function(t){return Be(this,t).concat()},qe.retry=function(t){return Be(this,t).catchError()},qe.retryWhen=function(t){return Be(this).catchErrorWhen(t)};var On=function(t){function e(e,n,r,o){this.source=e,this.accumulator=n,this.hasSeed=r,this.seed=o,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new I(t,this))},e}(ze);I.prototype.onNext=function(t){if(!this.isStopped){!this.hasValue&&(this.hasValue=!0);try{this.hasAccumulation?this.accumulation=this.accumulator(this.accumulation,t):(this.accumulation=this.hasSeed?this.accumulator(this.seed,t):t,this.hasAccumulation=!0)}catch(e){return this.observer.onError(e)}this.observer.onNext(this.accumulation)}},I.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.observer.onError(t))},I.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,!this.hasValue&&this.hasSeed&&this.observer.onNext(this.seed),this.observer.onCompleted())},I.prototype.dispose=function(){this.isStopped=!0},I.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(t),!0)},qe.scan=function(){var t,e,n=!1;return 2===arguments.length?(n=!0,t=arguments[0],e=arguments[1]):e=arguments[0],new On(this,e,n,t)},qe.skipLast=function(t){if(0>t)throw new yt;var e=this;return new qn(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&n.onNext(r.shift())},function(t){n.onError(t)},function(){n.onCompleted()})},e)},qe.startWith=function(){var t,e=0;arguments.length&&me(arguments[0])?(t=arguments[0],e=1):t=xe;for(var n=[],r=e,o=arguments.length;o>r;r++)n.push(arguments[r]);return Ue([on(n,t),this]).concat()},qe.takeLast=function(t){if(0>t)throw new yt;var e=this;return new qn(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},function(t){n.onError(t)},function(){for(;r.length>0;)n.onNext(r.shift());n.onCompleted()})},e)},qe.takeLastBuffer=function(t){var e=this;return new qn(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},function(t){n.onError(t)},function(){n.onNext(r),n.onCompleted()})},e)},qe.windowWithCount=function(t,e){var n=this;if(+t||(t=0),Math.abs(t)===1/0&&(t=0),0>=t)throw new yt;if(null==e&&(e=t),+e||(e=0),Math.abs(e)===1/0&&(e=0),0>=e)throw new yt;return new qn(function(r){function o(){var t=new Tn;a.push(t),r.onNext(ee(t,s))}var i=new fe,s=new de(i),u=0,a=[];return o(),i.setDisposable(n.subscribe(function(n){for(var r=0,i=a.length;i>r;r++)a[r].onNext(n);var s=u-t+1;s>=0&&s%e===0&&a.shift().onCompleted(),++u%e===0&&o()},function(t){for(;a.length>0;)a.shift().onError(t);r.onError(t)},function(){for(;a.length>0;)a.shift().onCompleted();r.onCompleted()})),s},n)},qe.selectConcat=qe.concatMap=function(t,e,n){return at(t)&&at(e)?this.concatMap(function(n,r){var o=t(n,r);return ut(o)&&(o=Xe(o)),(Et(o)||St(o))&&(o=nn(o)),o.map(function(t,o){return e(n,t,r,o)})}):at(t)?L(this,t,n):L(this,function(){return t})},qe.concatMapObserver=qe.selectConcatObserver=function(t,e,n,r){var o=this,i=At(t,r,2),s=At(e,r,1),u=At(n,r,0);return new qn(function(t){var e=0;return o.subscribe(function(n){var r;try{r=i(n,e++)}catch(o){return void t.onError(o)}ut(r)&&(r=Xe(r)),t.onNext(r)},function(e){var n;try{n=s(e)}catch(r){return void t.onError(r)}ut(n)&&(n=Xe(n)),t.onNext(n),t.onCompleted()},function(){var e;try{e=u()}catch(n){return void t.onError(n)}ut(e)&&(e=Xe(e)),t.onNext(e),t.onCompleted()})},this).concatAll()},qe.defaultIfEmpty=function(t){var e=this;return t===i&&(t=null),new qn(function(n){var r=!1;return e.subscribe(function(t){r=!0,n.onNext(t)},function(t){n.onError(t)},function(){!r&&n.onNext(t),n.onCompleted()})},e)},F.prototype.push=function(t){var e=-1===B(this.set,t,this.comparer);return e&&this.set.push(t),e},qe.distinct=function(t,e){var n=this;return e||(e=ot),new qn(function(r){var o=new F(e);return n.subscribe(function(e){var n=e;if(t)try{n=t(e)}catch(i){return void r.onError(i)}o.push(n)&&r.onNext(e)},function(t){r.onError(t)},function(){r.onCompleted()})},this)};var Pn=function(t){function e(e,n,r){this.source=e,this.selector=At(n,r,3),t.call(this)}function n(t,e){return function(n,r,o){return t.call(this,e.selector(n,r,o),r,o)}}function r(t,e,n){this.o=t,this.selector=e,this.source=n,this.i=0,this.isStopped=!1}return Zt(e,t),e.prototype.internalMap=function(t,r){return new e(this.source,n(t,this),r)},e.prototype.subscribeCore=function(t){return this.source.subscribe(new r(t,this.selector,this))},r.prototype.onNext=function(t){if(!this.isStopped){var e=x(this.selector)(t,this.i++,this.source);return e===ne?this.o.onError(e.e):void this.o.onNext(e)}},r.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},r.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},r.prototype.dispose=function(){this.isStopped=!0},r.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe.map=qe.select=function(t,e){var n="function"==typeof t?t:function(){return t};return this instanceof Pn?this.internalMap(n,e):new Pn(this,n,e)},qe.pluck=function(){var t=arguments,e=arguments.length;if(0===e)throw new Error("List of properties cannot be empty.");return this.map(function(n){for(var r=n,o=0;e>o;o++){var s=r[t[o]];if("undefined"==typeof s)return i;r=s}return r})},qe.flatMapObserver=qe.selectManyObserver=function(t,e,n,r){var o=this;return new qn(function(i){var s=0;return o.subscribe(function(e){var n;try{n=t.call(r,e,s++)}catch(o){return void i.onError(o)}ut(n)&&(n=Xe(n)),i.onNext(n)},function(t){var n;try{n=e.call(r,t)}catch(o){return void i.onError(o)}ut(n)&&(n=Xe(n)),i.onNext(n),i.onCompleted()},function(){var t;try{t=n.call(r)}catch(e){return void i.onError(e)}ut(t)&&(t=Xe(t)),i.onNext(t),i.onCompleted()})},o).mergeAll()},qe.selectMany=qe.flatMap=function(t,e,n){return at(t)&&at(e)?this.flatMap(function(n,r){var o=t(n,r);return ut(o)&&(o=Xe(o)),(Et(o)||St(o))&&(o=nn(o)),o.map(function(t,o){return e(n,t,r,o)})},n):at(t)?U(this,t,n):U(this,function(){return t})},qe.selectSwitch=qe.flatMapLatest=qe.switchMap=function(t,e){return this.select(t,e).switchLatest()};var jn=function(t){function e(e,n){this.source=e,this.skipCount=n,t.call(this)}function n(t,e){this.c=e,this.r=e,this.o=t,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t,this.skipCount))},n.prototype.onNext=function(t){this.isStopped||(this.r<=0?this.o.onNext(t):this.r--)},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe.skip=function(t){if(0>t)throw new yt;return new jn(this,t)},qe.skipWhile=function(t,e){var n=this,r=At(t,e,3);return new qn(function(t){var e=0,o=!1;return n.subscribe(function(i){if(!o)try{o=!r(i,e++,n)}catch(s){return void t.onError(s)}o&&t.onNext(i)},function(e){t.onError(e)},function(){t.onCompleted()})},n)},qe.take=function(t,e){if(0>t)throw new yt;if(0===t)return Ye(e);var n=this;return new qn(function(e){var r=t;return n.subscribe(function(t){r-- >0&&(e.onNext(t),0>=r&&e.onCompleted())},function(t){e.onError(t)},function(){e.onCompleted()})},n)},qe.takeWhile=function(t,e){var n=this,r=At(t,e,3);return new qn(function(t){var e=0,o=!0;return n.subscribe(function(i){if(o){try{o=r(i,e++,n)}catch(s){return void t.onError(s)}o?t.onNext(i):t.onCompleted()}},function(e){t.onError(e)},function(){t.onCompleted()})},n)};var Dn=function(t){function e(e,n,r){this.source=e,this.predicate=At(n,r,3),t.call(this)}function n(t,e){return function(n,r,o){return e.predicate(n,r,o)&&t.call(this,n,r,o)}}function r(t,e,n){this.o=t,this.predicate=e,this.source=n,this.i=0,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new r(t,this.predicate,this))},e.prototype.internalFilter=function(t,r){return new e(this.source,n(t,this),r)},r.prototype.onNext=function(t){if(!this.isStopped){var e=x(this.predicate)(t,this.i++,this.source);return e===ne?this.o.onError(e.e):void(e&&this.o.onNext(t))}},r.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},r.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},r.prototype.dispose=function(){this.isStopped=!0},r.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe.filter=qe.where=function(t,e){return this instanceof Dn?this.internalFilter(t,e):new Dn(this,t,e)},qe.transduce=function(t){function e(t){return{"@@transducer/init":function(){return t},"@@transducer/step":function(t,e){return t.onNext(e)},"@@transducer/result":function(t){return t.onCompleted()}}}var n=this;return new qn(function(r){var o=t(e(r));return n.subscribe(function(t){try{o["@@transducer/step"](r,t)}catch(e){r.onError(e)}},function(t){r.onError(t)},function(){o["@@transducer/result"](r)})},n)};var qn=tt.AnonymousObservable=function(t){function e(t){return t&&at(t.dispose)?t:at(t)?ae(t):ce}function n(t,n){var r=n[0],o=n[1],i=x(o)(r);return i!==ne||r.fail(ne.e)?void r.setDisposable(e(i)):_(ne.e)}function r(e,r){function o(t){var r=new Rn(t),o=[r,e];return _e.scheduleRequired()?_e.scheduleWithState(o,n):n(null,o),r}this.source=r,t.call(this,o)}return Zt(r,t),r}(We),Rn=function(t){function e(e){t.call(this),this.observer=e,this.m=new fe}Zt(e,t);var n=e.prototype;return n.next=function(t){var e=x(this.observer.onNext).call(this.observer,t);e===ne&&(this.dispose(),_(e.e))},n.error=function(t){var e=x(this.observer.onError).call(this.observer,t);this.dispose(),e===ne&&_(e.e)},n.completed=function(){var t=x(this.observer.onCompleted).call(this.observer);this.dispose(),t===ne&&_(t.e)},n.setDisposable=function(t){this.m.setDisposable(t)},n.getDisposable=function(){return this.m.getDisposable()},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(Re),Mn=function(t,e){this.subject=t,this.observer=e};Mn.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var Tn=tt.Subject=function(t){function e(t){return he(this),this.isStopped?this.hasError?(t.onError(this.error),ce):(t.onCompleted(),ce):(this.observers.push(t),new Mn(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[],this.hasError=!1}return Zt(n,t),te(n.prototype,je.prototype,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(he(this),!this.isStopped){this.isStopped=!0;for(var t=0,e=u(this.observers),n=e.length;n>t;t++)e[t].onCompleted();this.observers.length=0}},onError:function(t){if(he(this),!this.isStopped){this.isStopped=!0,this.error=t,this.hasError=!0;for(var e=0,n=u(this.observers),r=n.length;r>e;e++)n[e].onError(t);this.observers.length=0}},onNext:function(t){if(he(this),!this.isStopped)for(var e=0,n=u(this.observers),r=n.length;r>e;e++)n[e].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),n.create=function(t,e){return new Vn(t,e)},n}(We),Vn=(tt.AsyncSubject=function(t){function e(t){return he(this),this.isStopped?(this.hasError?t.onError(this.error):this.hasValue?(t.onNext(this.value),t.onCompleted()):t.onCompleted(),ce):(this.observers.push(t),new Mn(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.hasValue=!1,this.observers=[],this.hasError=!1}return Zt(n,t),te(n.prototype,je,{hasObservers:function(){return he(this),this.observers.length>0},onCompleted:function(){var t,e;if(he(this),!this.isStopped){this.isStopped=!0;var n=u(this.observers),e=n.length;if(this.hasValue)for(t=0;e>t;t++){var r=n[t];r.onNext(this.value),r.onCompleted()}else for(t=0;e>t;t++)n[t].onCompleted();this.observers.length=0}},onError:function(t){if(he(this),!this.isStopped){this.isStopped=!0,this.hasError=!0,this.error=t;for(var e=0,n=u(this.observers),r=n.length;r>e;e++)n[e].onError(t);this.observers.length=0}},onNext:function(t){he(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),n}(We),tt.AnonymousSubject=function(t){function e(t){return this.observable.subscribe(t)}function n(n,r){this.observer=n,this.observable=r,t.call(this,e)}return Zt(n,t),te(n.prototype,je.prototype,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(We));"function"==typeof t&&"object"==typeof t.amd&&t.amd?(X.Rx=tt,t(function(){return tt})):Q&&K?Y?(K.exports=tt).Rx=tt:Q.Rx=tt:X.Rx=tt;var $n=f()}).call(this)}).call(this,e(150),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{150:150}]},{},[1])(1)});
3474 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3476 },{}],16:[function(require,module,exports){
3478 var topLevel = typeof global !== 'undefined' ? global :
3479 typeof window !== 'undefined' ? window : {}
3480 var minDoc = require('min-document');
3484 if (typeof document !== 'undefined') {
3487 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
3490 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
3494 module.exports = doccy;
3496 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3498 },{"min-document":4}],17:[function(require,module,exports){
3499 exports.read = function (buffer, offset, isLE, mLen, nBytes) {
3501 var eLen = nBytes * 8 - mLen - 1
3502 var eMax = (1 << eLen) - 1
3503 var eBias = eMax >> 1
3505 var i = isLE ? (nBytes - 1) : 0
3506 var d = isLE ? -1 : 1
3507 var s = buffer[offset + i]
3511 e = s & ((1 << (-nBits)) - 1)
3514 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
3516 m = e & ((1 << (-nBits)) - 1)
3519 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
3523 } else if (e === eMax) {
3524 return m ? NaN : ((s ? -1 : 1) * Infinity)
3526 m = m + Math.pow(2, mLen)
3529 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
3532 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
3534 var eLen = nBytes * 8 - mLen - 1
3535 var eMax = (1 << eLen) - 1
3536 var eBias = eMax >> 1
3537 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
3538 var i = isLE ? 0 : (nBytes - 1)
3539 var d = isLE ? 1 : -1
3540 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
3542 value = Math.abs(value)
3544 if (isNaN(value) || value === Infinity) {
3545 m = isNaN(value) ? 1 : 0
3548 e = Math.floor(Math.log(value) / Math.LN2)
3549 if (value * (c = Math.pow(2, -e)) < 1) {
3553 if (e + eBias >= 1) {
3556 value += rt * Math.pow(2, 1 - eBias)
3558 if (value * c >= 2) {
3563 if (e + eBias >= eMax) {
3566 } else if (e + eBias >= 1) {
3567 m = (value * c - 1) * Math.pow(2, mLen)
3570 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
3575 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
3579 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
3581 buffer[offset + i - d] |= s * 128
3584 },{}],18:[function(require,module,exports){
3588 /*global window, global*/
3590 var root = typeof window !== 'undefined' ?
3591 window : typeof global !== 'undefined' ?
3594 module.exports = Individual;
3596 function Individual(key, value) {
3606 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3608 },{}],19:[function(require,module,exports){
3611 var Individual = require('./index.js');
3613 module.exports = OneVersion;
3615 function OneVersion(moduleName, version, defaultValue) {
3616 var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName;
3617 var enforceKey = key + '_ENFORCE_SINGLETON';
3619 var versionValue = Individual(enforceKey, version);
3621 if (versionValue !== version) {
3622 throw new Error('Can only have one copy of ' +
3623 moduleName + '.\n' +
3624 'You already have version ' + versionValue +
3626 'This means you cannot install version ' + version);
3629 return Individual(key, defaultValue);
3632 },{"./index.js":18}],20:[function(require,module,exports){
3635 module.exports = function isObject(x) {
3636 return typeof x === "object" && x !== null;
3639 },{}],21:[function(require,module,exports){
3640 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3641 /* Geohash encoding/decoding and associated functions (c) Chris Veness 2014-2016 / MIT Licence */
3642 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3648 * Geohash encode, decode, bounds, neighbours.
3654 /* (Geohash-specific) Base32 map */
3655 Geohash.base32 = '0123456789bcdefghjkmnpqrstuvwxyz';
3658 * Encodes latitude/longitude to geohash, either to specified precision or to automatically
3659 * evaluated precision.
3661 * @param {number} lat - Latitude in degrees.
3662 * @param {number} lon - Longitude in degrees.
3663 * @param {number} [precision] - Number of characters in resulting geohash.
3664 * @returns {string} Geohash of supplied latitude/longitude.
3665 * @throws Invalid geohash.
3668 * var geohash = Geohash.encode(52.205, 0.119, 7); // geohash: 'u120fxw'
3670 Geohash.encode = function(lat, lon, precision) {
3672 if (typeof precision == 'undefined') {
3673 // refine geohash until it matches precision of supplied lat/lon
3674 for (var p=1; p<=12; p++) {
3675 var hash = Geohash.encode(lat, lon, p);
3676 var posn = Geohash.decode(hash);
3677 if (posn.lat==lat && posn.lon==lon) return hash;
3679 precision = 12; // set to maximum
3684 precision = Number(precision);
3686 if (isNaN(lat) || isNaN(lon) || isNaN(precision)) throw new Error('Invalid geohash');
3688 var idx = 0; // index into base32 map
3689 var bit = 0; // each char holds 5 bits
3693 var latMin = -90, latMax = 90;
3694 var lonMin = -180, lonMax = 180;
3696 while (geohash.length < precision) {
3698 // bisect E-W longitude
3699 var lonMid = (lonMin + lonMax) / 2;
3700 if (lon >= lonMid) {
3708 // bisect N-S latitude
3709 var latMid = (latMin + latMax) / 2;
3710 if (lat >= latMid) {
3721 // 5 bits gives us a character: append it and start over
3722 geohash += Geohash.base32.charAt(idx);
3733 * Decode geohash to latitude/longitude (location is approximate centre of geohash cell,
3734 * to reasonable precision).
3736 * @param {string} geohash - Geohash string to be converted to latitude/longitude.
3737 * @returns {{lat:number, lon:number}} (Center of) geohashed location.
3738 * @throws Invalid geohash.
3741 * var latlon = Geohash.decode('u120fxw'); // latlon: { lat: 52.205, lon: 0.1188 }
3743 Geohash.decode = function(geohash) {
3745 var bounds = Geohash.bounds(geohash); // <-- the hard work
3746 // now just determine the centre of the cell...
3748 var latMin = bounds.sw.lat, lonMin = bounds.sw.lon;
3749 var latMax = bounds.ne.lat, lonMax = bounds.ne.lon;
3752 var lat = (latMin + latMax)/2;
3753 var lon = (lonMin + lonMax)/2;
3755 // round to close to centre without excessive precision: ⌊2-log10(Δ°)⌋ decimal places
3756 lat = lat.toFixed(Math.floor(2-Math.log(latMax-latMin)/Math.LN10));
3757 lon = lon.toFixed(Math.floor(2-Math.log(lonMax-lonMin)/Math.LN10));
3759 return { lat: Number(lat), lon: Number(lon) };
3764 * Returns SW/NE latitude/longitude bounds of specified geohash.
3766 * @param {string} geohash - Cell that bounds are required of.
3767 * @returns {{sw: {lat: number, lon: number}, ne: {lat: number, lon: number}}}
3768 * @throws Invalid geohash.
3770 Geohash.bounds = function(geohash) {
3771 if (geohash.length === 0) throw new Error('Invalid geohash');
3773 geohash = geohash.toLowerCase();
3776 var latMin = -90, latMax = 90;
3777 var lonMin = -180, lonMax = 180;
3779 for (var i=0; i<geohash.length; i++) {
3780 var chr = geohash.charAt(i);
3781 var idx = Geohash.base32.indexOf(chr);
3782 if (idx == -1) throw new Error('Invalid geohash');
3784 for (var n=4; n>=0; n--) {
3785 var bitN = idx >> n & 1;
3788 var lonMid = (lonMin+lonMax) / 2;
3796 var latMid = (latMin+latMax) / 2;
3808 sw: { lat: latMin, lon: lonMin },
3809 ne: { lat: latMax, lon: lonMax },
3817 * Determines adjacent cell in given direction.
3819 * @param geohash - Cell to which adjacent cell is required.
3820 * @param direction - Direction from geohash (N/S/E/W).
3821 * @returns {string} Geocode of adjacent cell.
3822 * @throws Invalid geohash.
3824 Geohash.adjacent = function(geohash, direction) {
3825 // based on github.com/davetroy/geohash-js
3827 geohash = geohash.toLowerCase();
3828 direction = direction.toLowerCase();
3830 if (geohash.length === 0) throw new Error('Invalid geohash');
3831 if ('nsew'.indexOf(direction) == -1) throw new Error('Invalid direction');
3834 n: [ 'p0r21436x8zb9dcf5h7kjnmqesgutwvy', 'bc01fg45238967deuvhjyznpkmstqrwx' ],
3835 s: [ '14365h7k9dcfesgujnmqp0r2twvyx8zb', '238967debc01fg45kmstqrwxuvhjyznp' ],
3836 e: [ 'bc01fg45238967deuvhjyznpkmstqrwx', 'p0r21436x8zb9dcf5h7kjnmqesgutwvy' ],
3837 w: [ '238967debc01fg45kmstqrwxuvhjyznp', '14365h7k9dcfesgujnmqp0r2twvyx8zb' ],
3840 n: [ 'prxz', 'bcfguvyz' ],
3841 s: [ '028b', '0145hjnp' ],
3842 e: [ 'bcfguvyz', 'prxz' ],
3843 w: [ '0145hjnp', '028b' ],
3846 var lastCh = geohash.slice(-1); // last character of hash
3847 var parent = geohash.slice(0, -1); // hash without last character
3849 var type = geohash.length % 2;
3851 // check for edge-cases which don't share common prefix
3852 if (border[direction][type].indexOf(lastCh) != -1 && parent !== '') {
3853 parent = Geohash.adjacent(parent, direction);
3856 // append letter for direction to parent
3857 return parent + Geohash.base32.charAt(neighbour[direction][type].indexOf(lastCh));
3862 * Returns all 8 adjacent cells to specified geohash.
3864 * @param {string} geohash - Geohash neighbours are required of.
3865 * @returns {{n,ne,e,se,s,sw,w,nw: string}}
3866 * @throws Invalid geohash.
3868 Geohash.neighbours = function(geohash) {
3870 'n': Geohash.adjacent(geohash, 'n'),
3871 'ne': Geohash.adjacent(Geohash.adjacent(geohash, 'n'), 'e'),
3872 'e': Geohash.adjacent(geohash, 'e'),
3873 'se': Geohash.adjacent(Geohash.adjacent(geohash, 's'), 'e'),
3874 's': Geohash.adjacent(geohash, 's'),
3875 'sw': Geohash.adjacent(Geohash.adjacent(geohash, 's'), 'w'),
3876 'w': Geohash.adjacent(geohash, 'w'),
3877 'nw': Geohash.adjacent(Geohash.adjacent(geohash, 'n'), 'w'),
3882 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3883 if (typeof module != 'undefined' && module.exports) module.exports = Geohash; // CommonJS, node.js
3885 },{}],22:[function(require,module,exports){
3886 (function (process){
3887 // Copyright Joyent, Inc. and other Node contributors.
3889 // Permission is hereby granted, free of charge, to any person obtaining a
3890 // copy of this software and associated documentation files (the
3891 // "Software"), to deal in the Software without restriction, including
3892 // without limitation the rights to use, copy, modify, merge, publish,
3893 // distribute, sublicense, and/or sell copies of the Software, and to permit
3894 // persons to whom the Software is furnished to do so, subject to the
3895 // following conditions:
3897 // The above copyright notice and this permission notice shall be included
3898 // in all copies or substantial portions of the Software.
3900 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3901 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3902 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3903 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3904 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3905 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3906 // USE OR OTHER DEALINGS IN THE SOFTWARE.
3908 // resolves . and .. elements in a path array with directory names there
3909 // must be no slashes, empty elements, or device names (c:\) in the array
3910 // (so also no leading and trailing slashes - it does not distinguish
3911 // relative and absolute paths)
3912 function normalizeArray(parts, allowAboveRoot) {
3913 // if the path tries to go above the root, `up` ends up > 0
3915 for (var i = parts.length - 1; i >= 0; i--) {
3916 var last = parts[i];
3919 } else if (last === '..') {
3928 // if the path is allowed to go above the root, restore leading ..s
3929 if (allowAboveRoot) {
3931 parts.unshift('..');
3938 // Split a filename into [root, dir, basename, ext], unix version
3939 // 'root' is just a slash, or nothing.
3941 /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
3942 var splitPath = function(filename) {
3943 return splitPathRe.exec(filename).slice(1);
3946 // path.resolve([from ...], to)
3948 exports.resolve = function() {
3949 var resolvedPath = '',
3950 resolvedAbsolute = false;
3952 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
3953 var path = (i >= 0) ? arguments[i] : process.cwd();
3955 // Skip empty and invalid entries
3956 if (typeof path !== 'string') {
3957 throw new TypeError('Arguments to path.resolve must be strings');
3962 resolvedPath = path + '/' + resolvedPath;
3963 resolvedAbsolute = path.charAt(0) === '/';
3966 // At this point the path should be resolved to a full absolute path, but
3967 // handle relative paths to be safe (might happen when process.cwd() fails)
3969 // Normalize the path
3970 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
3972 }), !resolvedAbsolute).join('/');
3974 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
3977 // path.normalize(path)
3979 exports.normalize = function(path) {
3980 var isAbsolute = exports.isAbsolute(path),
3981 trailingSlash = substr(path, -1) === '/';
3983 // Normalize the path
3984 path = normalizeArray(filter(path.split('/'), function(p) {
3986 }), !isAbsolute).join('/');
3988 if (!path && !isAbsolute) {
3991 if (path && trailingSlash) {
3995 return (isAbsolute ? '/' : '') + path;
3999 exports.isAbsolute = function(path) {
4000 return path.charAt(0) === '/';
4004 exports.join = function() {
4005 var paths = Array.prototype.slice.call(arguments, 0);
4006 return exports.normalize(filter(paths, function(p, index) {
4007 if (typeof p !== 'string') {
4008 throw new TypeError('Arguments to path.join must be strings');
4015 // path.relative(from, to)
4017 exports.relative = function(from, to) {
4018 from = exports.resolve(from).substr(1);
4019 to = exports.resolve(to).substr(1);
4021 function trim(arr) {
4023 for (; start < arr.length; start++) {
4024 if (arr[start] !== '') break;
4027 var end = arr.length - 1;
4028 for (; end >= 0; end--) {
4029 if (arr[end] !== '') break;
4032 if (start > end) return [];
4033 return arr.slice(start, end - start + 1);
4036 var fromParts = trim(from.split('/'));
4037 var toParts = trim(to.split('/'));
4039 var length = Math.min(fromParts.length, toParts.length);
4040 var samePartsLength = length;
4041 for (var i = 0; i < length; i++) {
4042 if (fromParts[i] !== toParts[i]) {
4043 samePartsLength = i;
4048 var outputParts = [];
4049 for (var i = samePartsLength; i < fromParts.length; i++) {
4050 outputParts.push('..');
4053 outputParts = outputParts.concat(toParts.slice(samePartsLength));
4055 return outputParts.join('/');
4059 exports.delimiter = ':';
4061 exports.dirname = function(path) {
4062 var result = splitPath(path),
4066 if (!root && !dir) {
4067 // No dirname whatsoever
4072 // It has a dirname, strip trailing slash
4073 dir = dir.substr(0, dir.length - 1);
4080 exports.basename = function(path, ext) {
4081 var f = splitPath(path)[2];
4082 // TODO: make this comparison case-insensitive on windows?
4083 if (ext && f.substr(-1 * ext.length) === ext) {
4084 f = f.substr(0, f.length - ext.length);
4090 exports.extname = function(path) {
4091 return splitPath(path)[3];
4094 function filter (xs, f) {
4095 if (xs.filter) return xs.filter(f);
4097 for (var i = 0; i < xs.length; i++) {
4098 if (f(xs[i], i, xs)) res.push(xs[i]);
4103 // String.prototype.substr - negative index don't work in IE8
4104 var substr = 'ab'.substr(-1) === 'b'
4105 ? function (str, start, len) { return str.substr(start, len) }
4106 : function (str, start, len) {
4107 if (start < 0) start = str.length + start;
4108 return str.substr(start, len);
4112 }).call(this,require('_process'))
4114 },{"_process":6}],23:[function(require,module,exports){
4117 module.exports = Pbf;
4119 var ieee754 = require('ieee754');
4122 this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
4125 this.length = this.buf.length;
4128 Pbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum
4129 Pbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64
4130 Pbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields
4131 Pbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32
4133 var SHIFT_LEFT_32 = (1 << 16) * (1 << 16),
4134 SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
4138 destroy: function() {
4142 // === READING =================================================================
4144 readFields: function(readField, result, end) {
4145 end = end || this.length;
4147 while (this.pos < end) {
4148 var val = this.readVarint(),
4150 startPos = this.pos;
4152 this.type = val & 0x7;
4153 readField(tag, result, this);
4155 if (this.pos === startPos) this.skip(val);
4160 readMessage: function(readField, result) {
4161 return this.readFields(readField, result, this.readVarint() + this.pos);
4164 readFixed32: function() {
4165 var val = readUInt32(this.buf, this.pos);
4170 readSFixed32: function() {
4171 var val = readInt32(this.buf, this.pos);
4176 // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
4178 readFixed64: function() {
4179 var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
4184 readSFixed64: function() {
4185 var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
4190 readFloat: function() {
4191 var val = ieee754.read(this.buf, this.pos, true, 23, 4);
4196 readDouble: function() {
4197 var val = ieee754.read(this.buf, this.pos, true, 52, 8);
4202 readVarint: function(isSigned) {
4206 b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;
4207 b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;
4208 b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;
4209 b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;
4210 b = buf[this.pos]; val |= (b & 0x0f) << 28;
4212 return readVarintRemainder(val, isSigned, this);
4215 readVarint64: function() { // for compatibility with v2.0.1
4216 return this.readVarint(true);
4219 readSVarint: function() {
4220 var num = this.readVarint();
4221 return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding
4224 readBoolean: function() {
4225 return Boolean(this.readVarint());
4228 readString: function() {
4229 var end = this.readVarint() + this.pos,
4230 str = readUtf8(this.buf, this.pos, end);
4235 readBytes: function() {
4236 var end = this.readVarint() + this.pos,
4237 buffer = this.buf.subarray(this.pos, end);
4242 // verbose for performance reasons; doesn't affect gzipped size
4244 readPackedVarint: function(arr, isSigned) {
4245 var end = readPackedEnd(this);
4247 while (this.pos < end) arr.push(this.readVarint(isSigned));
4250 readPackedSVarint: function(arr) {
4251 var end = readPackedEnd(this);
4253 while (this.pos < end) arr.push(this.readSVarint());
4256 readPackedBoolean: function(arr) {
4257 var end = readPackedEnd(this);
4259 while (this.pos < end) arr.push(this.readBoolean());
4262 readPackedFloat: function(arr) {
4263 var end = readPackedEnd(this);
4265 while (this.pos < end) arr.push(this.readFloat());
4268 readPackedDouble: function(arr) {
4269 var end = readPackedEnd(this);
4271 while (this.pos < end) arr.push(this.readDouble());
4274 readPackedFixed32: function(arr) {
4275 var end = readPackedEnd(this);
4277 while (this.pos < end) arr.push(this.readFixed32());
4280 readPackedSFixed32: function(arr) {
4281 var end = readPackedEnd(this);
4283 while (this.pos < end) arr.push(this.readSFixed32());
4286 readPackedFixed64: function(arr) {
4287 var end = readPackedEnd(this);
4289 while (this.pos < end) arr.push(this.readFixed64());
4292 readPackedSFixed64: function(arr) {
4293 var end = readPackedEnd(this);
4295 while (this.pos < end) arr.push(this.readSFixed64());
4299 skip: function(val) {
4300 var type = val & 0x7;
4301 if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}
4302 else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;
4303 else if (type === Pbf.Fixed32) this.pos += 4;
4304 else if (type === Pbf.Fixed64) this.pos += 8;
4305 else throw new Error('Unimplemented type: ' + type);
4308 // === WRITING =================================================================
4310 writeTag: function(tag, type) {
4311 this.writeVarint((tag << 3) | type);
4314 realloc: function(min) {
4315 var length = this.length || 16;
4317 while (length < this.pos + min) length *= 2;
4319 if (length !== this.length) {
4320 var buf = new Uint8Array(length);
4323 this.length = length;
4327 finish: function() {
4328 this.length = this.pos;
4330 return this.buf.subarray(0, this.length);
4333 writeFixed32: function(val) {
4335 writeInt32(this.buf, val, this.pos);
4339 writeSFixed32: function(val) {
4341 writeInt32(this.buf, val, this.pos);
4345 writeFixed64: function(val) {
4347 writeInt32(this.buf, val & -1, this.pos);
4348 writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
4352 writeSFixed64: function(val) {
4354 writeInt32(this.buf, val & -1, this.pos);
4355 writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
4359 writeVarint: function(val) {
4362 if (val > 0xfffffff || val < 0) {
4363 writeBigVarint(val, this);
4369 this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
4370 this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
4371 this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
4372 this.buf[this.pos++] = (val >>> 7) & 0x7f;
4375 writeSVarint: function(val) {
4376 this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
4379 writeBoolean: function(val) {
4380 this.writeVarint(Boolean(val));
4383 writeString: function(str) {
4385 this.realloc(str.length * 4);
4387 this.pos++; // reserve 1 byte for short string length
4389 var startPos = this.pos;
4390 // write the string directly to the buffer and see how much was written
4391 this.pos = writeUtf8(this.buf, str, this.pos);
4392 var len = this.pos - startPos;
4394 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
4396 // finally, write the message length in the reserved place and restore the position
4397 this.pos = startPos - 1;
4398 this.writeVarint(len);
4402 writeFloat: function(val) {
4404 ieee754.write(this.buf, val, this.pos, true, 23, 4);
4408 writeDouble: function(val) {
4410 ieee754.write(this.buf, val, this.pos, true, 52, 8);
4414 writeBytes: function(buffer) {
4415 var len = buffer.length;
4416 this.writeVarint(len);
4418 for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];
4421 writeRawMessage: function(fn, obj) {
4422 this.pos++; // reserve 1 byte for short message length
4424 // write the message directly to the buffer and see how much was written
4425 var startPos = this.pos;
4427 var len = this.pos - startPos;
4429 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
4431 // finally, write the message length in the reserved place and restore the position
4432 this.pos = startPos - 1;
4433 this.writeVarint(len);
4437 writeMessage: function(tag, fn, obj) {
4438 this.writeTag(tag, Pbf.Bytes);
4439 this.writeRawMessage(fn, obj);
4442 writePackedVarint: function(tag, arr) { this.writeMessage(tag, writePackedVarint, arr); },
4443 writePackedSVarint: function(tag, arr) { this.writeMessage(tag, writePackedSVarint, arr); },
4444 writePackedBoolean: function(tag, arr) { this.writeMessage(tag, writePackedBoolean, arr); },
4445 writePackedFloat: function(tag, arr) { this.writeMessage(tag, writePackedFloat, arr); },
4446 writePackedDouble: function(tag, arr) { this.writeMessage(tag, writePackedDouble, arr); },
4447 writePackedFixed32: function(tag, arr) { this.writeMessage(tag, writePackedFixed32, arr); },
4448 writePackedSFixed32: function(tag, arr) { this.writeMessage(tag, writePackedSFixed32, arr); },
4449 writePackedFixed64: function(tag, arr) { this.writeMessage(tag, writePackedFixed64, arr); },
4450 writePackedSFixed64: function(tag, arr) { this.writeMessage(tag, writePackedSFixed64, arr); },
4452 writeBytesField: function(tag, buffer) {
4453 this.writeTag(tag, Pbf.Bytes);
4454 this.writeBytes(buffer);
4456 writeFixed32Field: function(tag, val) {
4457 this.writeTag(tag, Pbf.Fixed32);
4458 this.writeFixed32(val);
4460 writeSFixed32Field: function(tag, val) {
4461 this.writeTag(tag, Pbf.Fixed32);
4462 this.writeSFixed32(val);
4464 writeFixed64Field: function(tag, val) {
4465 this.writeTag(tag, Pbf.Fixed64);
4466 this.writeFixed64(val);
4468 writeSFixed64Field: function(tag, val) {
4469 this.writeTag(tag, Pbf.Fixed64);
4470 this.writeSFixed64(val);
4472 writeVarintField: function(tag, val) {
4473 this.writeTag(tag, Pbf.Varint);
4474 this.writeVarint(val);
4476 writeSVarintField: function(tag, val) {
4477 this.writeTag(tag, Pbf.Varint);
4478 this.writeSVarint(val);
4480 writeStringField: function(tag, str) {
4481 this.writeTag(tag, Pbf.Bytes);
4482 this.writeString(str);
4484 writeFloatField: function(tag, val) {
4485 this.writeTag(tag, Pbf.Fixed32);
4486 this.writeFloat(val);
4488 writeDoubleField: function(tag, val) {
4489 this.writeTag(tag, Pbf.Fixed64);
4490 this.writeDouble(val);
4492 writeBooleanField: function(tag, val) {
4493 this.writeVarintField(tag, Boolean(val));
4497 function readVarintRemainder(l, s, p) {
4501 b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);
4502 b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);
4503 b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);
4504 b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);
4505 b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);
4506 b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);
4508 throw new Error('Expected varint not more than 10 bytes');
4511 function readPackedEnd(pbf) {
4512 return pbf.type === Pbf.Bytes ?
4513 pbf.readVarint() + pbf.pos : pbf.pos + 1;
4516 function toNum(low, high, isSigned) {
4518 return high * 0x100000000 + (low >>> 0);
4521 return ((high >>> 0) * 0x100000000) + (low >>> 0);
4524 function writeBigVarint(val, pbf) {
4528 low = (val % 0x100000000) | 0;
4529 high = (val / 0x100000000) | 0;
4531 low = ~(-val % 0x100000000);
4532 high = ~(-val / 0x100000000);
4534 if (low ^ 0xffffffff) {
4535 low = (low + 1) | 0;
4538 high = (high + 1) | 0;
4542 if (val >= 0x10000000000000000 || val < -0x10000000000000000) {
4543 throw new Error('Given varint doesn\'t fit into 10 bytes');
4548 writeBigVarintLow(low, high, pbf);
4549 writeBigVarintHigh(high, pbf);
4552 function writeBigVarintLow(low, high, pbf) {
4553 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
4554 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
4555 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
4556 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
4557 pbf.buf[pbf.pos] = low & 0x7f;
4560 function writeBigVarintHigh(high, pbf) {
4561 var lsb = (high & 0x07) << 4;
4563 pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;
4564 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
4565 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
4566 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
4567 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
4568 pbf.buf[pbf.pos++] = high & 0x7f;
4571 function makeRoomForExtraLength(startPos, len, pbf) {
4574 len <= 0x1fffff ? 2 :
4575 len <= 0xfffffff ? 3 : Math.ceil(Math.log(len) / (Math.LN2 * 7));
4577 // if 1 byte isn't enough for encoding message length, shift the data to the right
4578 pbf.realloc(extraLen);
4579 for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];
4582 function writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }
4583 function writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }
4584 function writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }
4585 function writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }
4586 function writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }
4587 function writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }
4588 function writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }
4589 function writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }
4590 function writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }
4592 // Buffer code below from https://github.com/feross/buffer, MIT-licensed
4594 function readUInt32(buf, pos) {
4595 return ((buf[pos]) |
4596 (buf[pos + 1] << 8) |
4597 (buf[pos + 2] << 16)) +
4598 (buf[pos + 3] * 0x1000000);
4601 function writeInt32(buf, val, pos) {
4603 buf[pos + 1] = (val >>> 8);
4604 buf[pos + 2] = (val >>> 16);
4605 buf[pos + 3] = (val >>> 24);
4608 function readInt32(buf, pos) {
4609 return ((buf[pos]) |
4610 (buf[pos + 1] << 8) |
4611 (buf[pos + 2] << 16)) +
4612 (buf[pos + 3] << 24);
4615 function readUtf8(buf, pos, end) {
4621 var c = null; // codepoint
4622 var bytesPerSequence =
4627 if (i + bytesPerSequence > end) break;
4631 if (bytesPerSequence === 1) {
4635 } else if (bytesPerSequence === 2) {
4637 if ((b1 & 0xC0) === 0x80) {
4638 c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);
4643 } else if (bytesPerSequence === 3) {
4646 if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {
4647 c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);
4648 if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {
4652 } else if (bytesPerSequence === 4) {
4656 if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
4657 c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);
4658 if (c <= 0xFFFF || c >= 0x110000) {
4666 bytesPerSequence = 1;
4668 } else if (c > 0xFFFF) {
4670 str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);
4671 c = 0xDC00 | c & 0x3FF;
4674 str += String.fromCharCode(c);
4675 i += bytesPerSequence;
4681 function writeUtf8(buf, str, pos) {
4682 for (var i = 0, c, lead; i < str.length; i++) {
4683 c = str.charCodeAt(i); // code point
4685 if (c > 0xD7FF && c < 0xE000) {
4694 c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;
4698 if (c > 0xDBFF || (i + 1 === str.length)) {
4718 buf[pos++] = c >> 0x6 | 0xC0;
4721 buf[pos++] = c >> 0xC | 0xE0;
4723 buf[pos++] = c >> 0x12 | 0xF0;
4724 buf[pos++] = c >> 0xC & 0x3F | 0x80;
4726 buf[pos++] = c >> 0x6 & 0x3F | 0x80;
4728 buf[pos++] = c & 0x3F | 0x80;
4734 },{"ieee754":17}],24:[function(require,module,exports){
4735 (function (global, factory) {
4736 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4737 typeof define === 'function' && define.amd ? define(factory) :
4738 (global.quickselect = factory());
4739 }(this, (function () { 'use strict';
4741 function quickselect(arr, k, left, right, compare) {
4742 quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
4745 function quickselectStep(arr, k, left, right, compare) {
4747 while (right > left) {
4748 if (right - left > 600) {
4749 var n = right - left + 1;
4750 var m = k - left + 1;
4751 var z = Math.log(n);
4752 var s = 0.5 * Math.exp(2 * z / 3);
4753 var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
4754 var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
4755 var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
4756 quickselectStep(arr, k, newLeft, newRight, compare);
4764 if (compare(arr[right], t) > 0) swap(arr, left, right);
4770 while (compare(arr[i], t) < 0) i++;
4771 while (compare(arr[j], t) > 0) j--;
4774 if (compare(arr[left], t) === 0) swap(arr, left, j);
4777 swap(arr, j, right);
4780 if (j <= k) left = j + 1;
4781 if (k <= j) right = j - 1;
4785 function swap(arr, i, j) {
4791 function defaultCompare(a, b) {
4792 return a < b ? -1 : a > b ? 1 : 0;
4799 },{}],25:[function(require,module,exports){
4802 module.exports = rbush;
4803 module.exports.default = rbush;
4805 var quickselect = require('quickselect');
4807 function rbush(maxEntries, format) {
4808 if (!(this instanceof rbush)) return new rbush(maxEntries, format);
4810 // max entries in a node is 9 by default; min node fill is 40% for best performance
4811 this._maxEntries = Math.max(4, maxEntries || 9);
4812 this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
4815 this._initFormat(format);
4824 return this._all(this.data, []);
4827 search: function (bbox) {
4829 var node = this.data,
4831 toBBox = this.toBBox;
4833 if (!intersects(bbox, node)) return result;
4835 var nodesToSearch = [],
4836 i, len, child, childBBox;
4839 for (i = 0, len = node.children.length; i < len; i++) {
4841 child = node.children[i];
4842 childBBox = node.leaf ? toBBox(child) : child;
4844 if (intersects(bbox, childBBox)) {
4845 if (node.leaf) result.push(child);
4846 else if (contains(bbox, childBBox)) this._all(child, result);
4847 else nodesToSearch.push(child);
4850 node = nodesToSearch.pop();
4856 collides: function (bbox) {
4858 var node = this.data,
4859 toBBox = this.toBBox;
4861 if (!intersects(bbox, node)) return false;
4863 var nodesToSearch = [],
4864 i, len, child, childBBox;
4867 for (i = 0, len = node.children.length; i < len; i++) {
4869 child = node.children[i];
4870 childBBox = node.leaf ? toBBox(child) : child;
4872 if (intersects(bbox, childBBox)) {
4873 if (node.leaf || contains(bbox, childBBox)) return true;
4874 nodesToSearch.push(child);
4877 node = nodesToSearch.pop();
4883 load: function (data) {
4884 if (!(data && data.length)) return this;
4886 if (data.length < this._minEntries) {
4887 for (var i = 0, len = data.length; i < len; i++) {
4888 this.insert(data[i]);
4893 // recursively build the tree with the given data from scratch using OMT algorithm
4894 var node = this._build(data.slice(), 0, data.length - 1, 0);
4896 if (!this.data.children.length) {
4897 // save as is if tree is empty
4900 } else if (this.data.height === node.height) {
4901 // split root if trees have the same height
4902 this._splitRoot(this.data, node);
4905 if (this.data.height < node.height) {
4906 // swap trees if inserted one is bigger
4907 var tmpNode = this.data;
4912 // insert the small tree into the large tree at appropriate level
4913 this._insert(node, this.data.height - node.height - 1, true);
4919 insert: function (item) {
4920 if (item) this._insert(item, this.data.height - 1);
4924 clear: function () {
4925 this.data = createNode([]);
4929 remove: function (item, equalsFn) {
4930 if (!item) return this;
4932 var node = this.data,
4933 bbox = this.toBBox(item),
4936 i, parent, index, goingUp;
4938 // depth-first iterative tree traversal
4939 while (node || path.length) {
4941 if (!node) { // go up
4943 parent = path[path.length - 1];
4948 if (node.leaf) { // check current node
4949 index = findItem(item, node.children, equalsFn);
4952 // item found, remove the item and condense tree upwards
4953 node.children.splice(index, 1);
4955 this._condense(path);
4960 if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
4965 node = node.children[0];
4967 } else if (parent) { // go right
4969 node = parent.children[i];
4972 } else node = null; // nothing found
4978 toBBox: function (item) { return item; },
4980 compareMinX: compareNodeMinX,
4981 compareMinY: compareNodeMinY,
4983 toJSON: function () { return this.data; },
4985 fromJSON: function (data) {
4990 _all: function (node, result) {
4991 var nodesToSearch = [];
4993 if (node.leaf) result.push.apply(result, node.children);
4994 else nodesToSearch.push.apply(nodesToSearch, node.children);
4996 node = nodesToSearch.pop();
5001 _build: function (items, left, right, height) {
5003 var N = right - left + 1,
5004 M = this._maxEntries,
5008 // reached leaf level; return leaf
5009 node = createNode(items.slice(left, right + 1));
5010 calcBBox(node, this.toBBox);
5015 // target height of the bulk-loaded tree
5016 height = Math.ceil(Math.log(N) / Math.log(M));
5018 // target number of root entries to maximize storage utilization
5019 M = Math.ceil(N / Math.pow(M, height - 1));
5022 node = createNode([]);
5024 node.height = height;
5026 // split the items into M mostly square tiles
5028 var N2 = Math.ceil(N / M),
5029 N1 = N2 * Math.ceil(Math.sqrt(M)),
5030 i, j, right2, right3;
5032 multiSelect(items, left, right, N1, this.compareMinX);
5034 for (i = left; i <= right; i += N1) {
5036 right2 = Math.min(i + N1 - 1, right);
5038 multiSelect(items, i, right2, N2, this.compareMinY);
5040 for (j = i; j <= right2; j += N2) {
5042 right3 = Math.min(j + N2 - 1, right2);
5044 // pack each entry recursively
5045 node.children.push(this._build(items, j, right3, height - 1));
5049 calcBBox(node, this.toBBox);
5054 _chooseSubtree: function (bbox, node, level, path) {
5056 var i, len, child, targetNode, area, enlargement, minArea, minEnlargement;
5061 if (node.leaf || path.length - 1 === level) break;
5063 minArea = minEnlargement = Infinity;
5065 for (i = 0, len = node.children.length; i < len; i++) {
5066 child = node.children[i];
5067 area = bboxArea(child);
5068 enlargement = enlargedArea(bbox, child) - area;
5070 // choose entry with the least area enlargement
5071 if (enlargement < minEnlargement) {
5072 minEnlargement = enlargement;
5073 minArea = area < minArea ? area : minArea;
5076 } else if (enlargement === minEnlargement) {
5077 // otherwise choose one with the smallest area
5078 if (area < minArea) {
5085 node = targetNode || node.children[0];
5091 _insert: function (item, level, isNode) {
5093 var toBBox = this.toBBox,
5094 bbox = isNode ? item : toBBox(item),
5097 // find the best node for accommodating the item, saving all nodes along the path too
5098 var node = this._chooseSubtree(bbox, this.data, level, insertPath);
5100 // put the item into the node
5101 node.children.push(item);
5104 // split on node overflow; propagate upwards if necessary
5105 while (level >= 0) {
5106 if (insertPath[level].children.length > this._maxEntries) {
5107 this._split(insertPath, level);
5112 // adjust bboxes along the insertion path
5113 this._adjustParentBBoxes(bbox, insertPath, level);
5116 // split overflowed node into two
5117 _split: function (insertPath, level) {
5119 var node = insertPath[level],
5120 M = node.children.length,
5121 m = this._minEntries;
5123 this._chooseSplitAxis(node, m, M);
5125 var splitIndex = this._chooseSplitIndex(node, m, M);
5127 var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
5128 newNode.height = node.height;
5129 newNode.leaf = node.leaf;
5131 calcBBox(node, this.toBBox);
5132 calcBBox(newNode, this.toBBox);
5134 if (level) insertPath[level - 1].children.push(newNode);
5135 else this._splitRoot(node, newNode);
5138 _splitRoot: function (node, newNode) {
5140 this.data = createNode([node, newNode]);
5141 this.data.height = node.height + 1;
5142 this.data.leaf = false;
5143 calcBBox(this.data, this.toBBox);
5146 _chooseSplitIndex: function (node, m, M) {
5148 var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index;
5150 minOverlap = minArea = Infinity;
5152 for (i = m; i <= M - m; i++) {
5153 bbox1 = distBBox(node, 0, i, this.toBBox);
5154 bbox2 = distBBox(node, i, M, this.toBBox);
5156 overlap = intersectionArea(bbox1, bbox2);
5157 area = bboxArea(bbox1) + bboxArea(bbox2);
5159 // choose distribution with minimum overlap
5160 if (overlap < minOverlap) {
5161 minOverlap = overlap;
5164 minArea = area < minArea ? area : minArea;
5166 } else if (overlap === minOverlap) {
5167 // otherwise choose distribution with minimum area
5168 if (area < minArea) {
5178 // sorts node children by the best axis for split
5179 _chooseSplitAxis: function (node, m, M) {
5181 var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX,
5182 compareMinY = node.leaf ? this.compareMinY : compareNodeMinY,
5183 xMargin = this._allDistMargin(node, m, M, compareMinX),
5184 yMargin = this._allDistMargin(node, m, M, compareMinY);
5186 // if total distributions margin value is minimal for x, sort by minX,
5187 // otherwise it's already sorted by minY
5188 if (xMargin < yMargin) node.children.sort(compareMinX);
5191 // total margin of all possible split distributions where each node is at least m full
5192 _allDistMargin: function (node, m, M, compare) {
5194 node.children.sort(compare);
5196 var toBBox = this.toBBox,
5197 leftBBox = distBBox(node, 0, m, toBBox),
5198 rightBBox = distBBox(node, M - m, M, toBBox),
5199 margin = bboxMargin(leftBBox) + bboxMargin(rightBBox),
5202 for (i = m; i < M - m; i++) {
5203 child = node.children[i];
5204 extend(leftBBox, node.leaf ? toBBox(child) : child);
5205 margin += bboxMargin(leftBBox);
5208 for (i = M - m - 1; i >= m; i--) {
5209 child = node.children[i];
5210 extend(rightBBox, node.leaf ? toBBox(child) : child);
5211 margin += bboxMargin(rightBBox);
5217 _adjustParentBBoxes: function (bbox, path, level) {
5218 // adjust bboxes along the given tree path
5219 for (var i = level; i >= 0; i--) {
5220 extend(path[i], bbox);
5224 _condense: function (path) {
5225 // go through the path, removing empty nodes and updating bboxes
5226 for (var i = path.length - 1, siblings; i >= 0; i--) {
5227 if (path[i].children.length === 0) {
5229 siblings = path[i - 1].children;
5230 siblings.splice(siblings.indexOf(path[i]), 1);
5232 } else this.clear();
5234 } else calcBBox(path[i], this.toBBox);
5238 _initFormat: function (format) {
5239 // data format (minX, minY, maxX, maxY accessors)
5241 // uses eval-type function compilation instead of just accepting a toBBox function
5242 // because the algorithms are very sensitive to sorting functions performance,
5243 // so they should be dead simple and without inner calls
5245 var compareArr = ['return a', ' - b', ';'];
5247 this.compareMinX = new Function('a', 'b', compareArr.join(format[0]));
5248 this.compareMinY = new Function('a', 'b', compareArr.join(format[1]));
5250 this.toBBox = new Function('a',
5251 'return {minX: a' + format[0] +
5252 ', minY: a' + format[1] +
5253 ', maxX: a' + format[2] +
5254 ', maxY: a' + format[3] + '};');
5258 function findItem(item, items, equalsFn) {
5259 if (!equalsFn) return items.indexOf(item);
5261 for (var i = 0; i < items.length; i++) {
5262 if (equalsFn(item, items[i])) return i;
5267 // calculate node's bbox from bboxes of its children
5268 function calcBBox(node, toBBox) {
5269 distBBox(node, 0, node.children.length, toBBox, node);
5272 // min bounding rectangle of node children from k to p-1
5273 function distBBox(node, k, p, toBBox, destNode) {
5274 if (!destNode) destNode = createNode(null);
5275 destNode.minX = Infinity;
5276 destNode.minY = Infinity;
5277 destNode.maxX = -Infinity;
5278 destNode.maxY = -Infinity;
5280 for (var i = k, child; i < p; i++) {
5281 child = node.children[i];
5282 extend(destNode, node.leaf ? toBBox(child) : child);
5288 function extend(a, b) {
5289 a.minX = Math.min(a.minX, b.minX);
5290 a.minY = Math.min(a.minY, b.minY);
5291 a.maxX = Math.max(a.maxX, b.maxX);
5292 a.maxY = Math.max(a.maxY, b.maxY);
5296 function compareNodeMinX(a, b) { return a.minX - b.minX; }
5297 function compareNodeMinY(a, b) { return a.minY - b.minY; }
5299 function bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }
5300 function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }
5302 function enlargedArea(a, b) {
5303 return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *
5304 (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
5307 function intersectionArea(a, b) {
5308 var minX = Math.max(a.minX, b.minX),
5309 minY = Math.max(a.minY, b.minY),
5310 maxX = Math.min(a.maxX, b.maxX),
5311 maxY = Math.min(a.maxY, b.maxY);
5313 return Math.max(0, maxX - minX) *
5314 Math.max(0, maxY - minY);
5317 function contains(a, b) {
5318 return a.minX <= b.minX &&
5324 function intersects(a, b) {
5325 return b.minX <= a.maxX &&
5331 function createNode(children) {
5343 // sort an array so that items come in groups of n unsorted items, with groups sorted between each other;
5344 // combines selection algorithm with binary divide & conquer approach
5346 function multiSelect(arr, left, right, n, compare) {
5347 var stack = [left, right],
5350 while (stack.length) {
5351 right = stack.pop();
5354 if (right - left <= n) continue;
5356 mid = left + Math.ceil((right - left) / n / 2) * n;
5357 quickselect(arr, mid, left, right, compare);
5359 stack.push(left, mid, mid, right);
5363 },{"quickselect":24}],26:[function(require,module,exports){
5365 Object.defineProperty(exports, "__esModule", { value: true });
5366 var Observable_1 = require("./internal/Observable");
5367 exports.Observable = Observable_1.Observable;
5368 var ConnectableObservable_1 = require("./internal/observable/ConnectableObservable");
5369 exports.ConnectableObservable = ConnectableObservable_1.ConnectableObservable;
5370 var groupBy_1 = require("./internal/operators/groupBy");
5371 exports.GroupedObservable = groupBy_1.GroupedObservable;
5372 var observable_1 = require("./internal/symbol/observable");
5373 exports.observable = observable_1.observable;
5374 var Subject_1 = require("./internal/Subject");
5375 exports.Subject = Subject_1.Subject;
5376 var BehaviorSubject_1 = require("./internal/BehaviorSubject");
5377 exports.BehaviorSubject = BehaviorSubject_1.BehaviorSubject;
5378 var ReplaySubject_1 = require("./internal/ReplaySubject");
5379 exports.ReplaySubject = ReplaySubject_1.ReplaySubject;
5380 var AsyncSubject_1 = require("./internal/AsyncSubject");
5381 exports.AsyncSubject = AsyncSubject_1.AsyncSubject;
5382 var asap_1 = require("./internal/scheduler/asap");
5383 exports.asapScheduler = asap_1.asap;
5384 var async_1 = require("./internal/scheduler/async");
5385 exports.asyncScheduler = async_1.async;
5386 var queue_1 = require("./internal/scheduler/queue");
5387 exports.queueScheduler = queue_1.queue;
5388 var animationFrame_1 = require("./internal/scheduler/animationFrame");
5389 exports.animationFrameScheduler = animationFrame_1.animationFrame;
5390 var VirtualTimeScheduler_1 = require("./internal/scheduler/VirtualTimeScheduler");
5391 exports.VirtualTimeScheduler = VirtualTimeScheduler_1.VirtualTimeScheduler;
5392 exports.VirtualAction = VirtualTimeScheduler_1.VirtualAction;
5393 var Scheduler_1 = require("./internal/Scheduler");
5394 exports.Scheduler = Scheduler_1.Scheduler;
5395 var Subscription_1 = require("./internal/Subscription");
5396 exports.Subscription = Subscription_1.Subscription;
5397 var Subscriber_1 = require("./internal/Subscriber");
5398 exports.Subscriber = Subscriber_1.Subscriber;
5399 var Notification_1 = require("./internal/Notification");
5400 exports.Notification = Notification_1.Notification;
5401 var pipe_1 = require("./internal/util/pipe");
5402 exports.pipe = pipe_1.pipe;
5403 var noop_1 = require("./internal/util/noop");
5404 exports.noop = noop_1.noop;
5405 var identity_1 = require("./internal/util/identity");
5406 exports.identity = identity_1.identity;
5407 var isObservable_1 = require("./internal/util/isObservable");
5408 exports.isObservable = isObservable_1.isObservable;
5409 var ArgumentOutOfRangeError_1 = require("./internal/util/ArgumentOutOfRangeError");
5410 exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
5411 var EmptyError_1 = require("./internal/util/EmptyError");
5412 exports.EmptyError = EmptyError_1.EmptyError;
5413 var ObjectUnsubscribedError_1 = require("./internal/util/ObjectUnsubscribedError");
5414 exports.ObjectUnsubscribedError = ObjectUnsubscribedError_1.ObjectUnsubscribedError;
5415 var UnsubscriptionError_1 = require("./internal/util/UnsubscriptionError");
5416 exports.UnsubscriptionError = UnsubscriptionError_1.UnsubscriptionError;
5417 var TimeoutError_1 = require("./internal/util/TimeoutError");
5418 exports.TimeoutError = TimeoutError_1.TimeoutError;
5419 var bindCallback_1 = require("./internal/observable/bindCallback");
5420 exports.bindCallback = bindCallback_1.bindCallback;
5421 var bindNodeCallback_1 = require("./internal/observable/bindNodeCallback");
5422 exports.bindNodeCallback = bindNodeCallback_1.bindNodeCallback;
5423 var combineLatest_1 = require("./internal/observable/combineLatest");
5424 exports.combineLatest = combineLatest_1.combineLatest;
5425 var concat_1 = require("./internal/observable/concat");
5426 exports.concat = concat_1.concat;
5427 var defer_1 = require("./internal/observable/defer");
5428 exports.defer = defer_1.defer;
5429 var empty_1 = require("./internal/observable/empty");
5430 exports.empty = empty_1.empty;
5431 var forkJoin_1 = require("./internal/observable/forkJoin");
5432 exports.forkJoin = forkJoin_1.forkJoin;
5433 var from_1 = require("./internal/observable/from");
5434 exports.from = from_1.from;
5435 var fromEvent_1 = require("./internal/observable/fromEvent");
5436 exports.fromEvent = fromEvent_1.fromEvent;
5437 var fromEventPattern_1 = require("./internal/observable/fromEventPattern");
5438 exports.fromEventPattern = fromEventPattern_1.fromEventPattern;
5439 var generate_1 = require("./internal/observable/generate");
5440 exports.generate = generate_1.generate;
5441 var iif_1 = require("./internal/observable/iif");
5442 exports.iif = iif_1.iif;
5443 var interval_1 = require("./internal/observable/interval");
5444 exports.interval = interval_1.interval;
5445 var merge_1 = require("./internal/observable/merge");
5446 exports.merge = merge_1.merge;
5447 var never_1 = require("./internal/observable/never");
5448 exports.never = never_1.never;
5449 var of_1 = require("./internal/observable/of");
5450 exports.of = of_1.of;
5451 var onErrorResumeNext_1 = require("./internal/observable/onErrorResumeNext");
5452 exports.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext;
5453 var pairs_1 = require("./internal/observable/pairs");
5454 exports.pairs = pairs_1.pairs;
5455 var race_1 = require("./internal/observable/race");
5456 exports.race = race_1.race;
5457 var range_1 = require("./internal/observable/range");
5458 exports.range = range_1.range;
5459 var throwError_1 = require("./internal/observable/throwError");
5460 exports.throwError = throwError_1.throwError;
5461 var timer_1 = require("./internal/observable/timer");
5462 exports.timer = timer_1.timer;
5463 var using_1 = require("./internal/observable/using");
5464 exports.using = using_1.using;
5465 var zip_1 = require("./internal/observable/zip");
5466 exports.zip = zip_1.zip;
5467 var empty_2 = require("./internal/observable/empty");
5468 exports.EMPTY = empty_2.EMPTY;
5469 var never_2 = require("./internal/observable/never");
5470 exports.NEVER = never_2.NEVER;
5471 var config_1 = require("./internal/config");
5472 exports.config = config_1.config;
5474 },{"./internal/AsyncSubject":27,"./internal/BehaviorSubject":28,"./internal/Notification":30,"./internal/Observable":31,"./internal/ReplaySubject":34,"./internal/Scheduler":35,"./internal/Subject":36,"./internal/Subscriber":38,"./internal/Subscription":39,"./internal/config":40,"./internal/observable/ConnectableObservable":41,"./internal/observable/bindCallback":43,"./internal/observable/bindNodeCallback":44,"./internal/observable/combineLatest":45,"./internal/observable/concat":46,"./internal/observable/defer":47,"./internal/observable/empty":48,"./internal/observable/forkJoin":49,"./internal/observable/from":50,"./internal/observable/fromEvent":52,"./internal/observable/fromEventPattern":53,"./internal/observable/generate":57,"./internal/observable/iif":58,"./internal/observable/interval":59,"./internal/observable/merge":60,"./internal/observable/never":61,"./internal/observable/of":62,"./internal/observable/onErrorResumeNext":63,"./internal/observable/pairs":64,"./internal/observable/race":65,"./internal/observable/range":66,"./internal/observable/throwError":68,"./internal/observable/timer":69,"./internal/observable/using":70,"./internal/observable/zip":71,"./internal/operators/groupBy":107,"./internal/scheduler/VirtualTimeScheduler":184,"./internal/scheduler/animationFrame":185,"./internal/scheduler/asap":186,"./internal/scheduler/async":187,"./internal/scheduler/queue":188,"./internal/symbol/observable":190,"./internal/util/ArgumentOutOfRangeError":192,"./internal/util/EmptyError":193,"./internal/util/ObjectUnsubscribedError":195,"./internal/util/TimeoutError":196,"./internal/util/UnsubscriptionError":197,"./internal/util/identity":201,"./internal/util/isObservable":210,"./internal/util/noop":213,"./internal/util/pipe":215}],27:[function(require,module,exports){
5476 var __extends = (this && this.__extends) || (function () {
5477 var extendStatics = function (d, b) {
5478 extendStatics = Object.setPrototypeOf ||
5479 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5480 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5481 return extendStatics(d, b);
5483 return function (d, b) {
5484 extendStatics(d, b);
5485 function __() { this.constructor = d; }
5486 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5489 Object.defineProperty(exports, "__esModule", { value: true });
5490 var Subject_1 = require("./Subject");
5491 var Subscription_1 = require("./Subscription");
5492 var AsyncSubject = (function (_super) {
5493 __extends(AsyncSubject, _super);
5494 function AsyncSubject() {
5495 var _this = _super !== null && _super.apply(this, arguments) || this;
5497 _this.hasNext = false;
5498 _this.hasCompleted = false;
5501 AsyncSubject.prototype._subscribe = function (subscriber) {
5502 if (this.hasError) {
5503 subscriber.error(this.thrownError);
5504 return Subscription_1.Subscription.EMPTY;
5506 else if (this.hasCompleted && this.hasNext) {
5507 subscriber.next(this.value);
5508 subscriber.complete();
5509 return Subscription_1.Subscription.EMPTY;
5511 return _super.prototype._subscribe.call(this, subscriber);
5513 AsyncSubject.prototype.next = function (value) {
5514 if (!this.hasCompleted) {
5516 this.hasNext = true;
5519 AsyncSubject.prototype.error = function (error) {
5520 if (!this.hasCompleted) {
5521 _super.prototype.error.call(this, error);
5524 AsyncSubject.prototype.complete = function () {
5525 this.hasCompleted = true;
5527 _super.prototype.next.call(this, this.value);
5529 _super.prototype.complete.call(this);
5531 return AsyncSubject;
5532 }(Subject_1.Subject));
5533 exports.AsyncSubject = AsyncSubject;
5535 },{"./Subject":36,"./Subscription":39}],28:[function(require,module,exports){
5537 var __extends = (this && this.__extends) || (function () {
5538 var extendStatics = function (d, b) {
5539 extendStatics = Object.setPrototypeOf ||
5540 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5541 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5542 return extendStatics(d, b);
5544 return function (d, b) {
5545 extendStatics(d, b);
5546 function __() { this.constructor = d; }
5547 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5550 Object.defineProperty(exports, "__esModule", { value: true });
5551 var Subject_1 = require("./Subject");
5552 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
5553 var BehaviorSubject = (function (_super) {
5554 __extends(BehaviorSubject, _super);
5555 function BehaviorSubject(_value) {
5556 var _this = _super.call(this) || this;
5557 _this._value = _value;
5560 Object.defineProperty(BehaviorSubject.prototype, "value", {
5562 return this.getValue();
5567 BehaviorSubject.prototype._subscribe = function (subscriber) {
5568 var subscription = _super.prototype._subscribe.call(this, subscriber);
5569 if (subscription && !subscription.closed) {
5570 subscriber.next(this._value);
5572 return subscription;
5574 BehaviorSubject.prototype.getValue = function () {
5575 if (this.hasError) {
5576 throw this.thrownError;
5578 else if (this.closed) {
5579 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
5585 BehaviorSubject.prototype.next = function (value) {
5586 _super.prototype.next.call(this, this._value = value);
5588 return BehaviorSubject;
5589 }(Subject_1.Subject));
5590 exports.BehaviorSubject = BehaviorSubject;
5592 },{"./Subject":36,"./util/ObjectUnsubscribedError":195}],29:[function(require,module,exports){
5594 var __extends = (this && this.__extends) || (function () {
5595 var extendStatics = function (d, b) {
5596 extendStatics = Object.setPrototypeOf ||
5597 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5598 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5599 return extendStatics(d, b);
5601 return function (d, b) {
5602 extendStatics(d, b);
5603 function __() { this.constructor = d; }
5604 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5607 Object.defineProperty(exports, "__esModule", { value: true });
5608 var Subscriber_1 = require("./Subscriber");
5609 var InnerSubscriber = (function (_super) {
5610 __extends(InnerSubscriber, _super);
5611 function InnerSubscriber(parent, outerValue, outerIndex) {
5612 var _this = _super.call(this) || this;
5613 _this.parent = parent;
5614 _this.outerValue = outerValue;
5615 _this.outerIndex = outerIndex;
5619 InnerSubscriber.prototype._next = function (value) {
5620 this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
5622 InnerSubscriber.prototype._error = function (error) {
5623 this.parent.notifyError(error, this);
5626 InnerSubscriber.prototype._complete = function () {
5627 this.parent.notifyComplete(this);
5630 return InnerSubscriber;
5631 }(Subscriber_1.Subscriber));
5632 exports.InnerSubscriber = InnerSubscriber;
5634 },{"./Subscriber":38}],30:[function(require,module,exports){
5636 Object.defineProperty(exports, "__esModule", { value: true });
5637 var empty_1 = require("./observable/empty");
5638 var of_1 = require("./observable/of");
5639 var throwError_1 = require("./observable/throwError");
5640 var Notification = (function () {
5641 function Notification(kind, value, error) {
5645 this.hasValue = kind === 'N';
5647 Notification.prototype.observe = function (observer) {
5648 switch (this.kind) {
5650 return observer.next && observer.next(this.value);
5652 return observer.error && observer.error(this.error);
5654 return observer.complete && observer.complete();
5657 Notification.prototype.do = function (next, error, complete) {
5658 var kind = this.kind;
5661 return next && next(this.value);
5663 return error && error(this.error);
5665 return complete && complete();
5668 Notification.prototype.accept = function (nextOrObserver, error, complete) {
5669 if (nextOrObserver && typeof nextOrObserver.next === 'function') {
5670 return this.observe(nextOrObserver);
5673 return this.do(nextOrObserver, error, complete);
5676 Notification.prototype.toObservable = function () {
5677 var kind = this.kind;
5680 return of_1.of(this.value);
5682 return throwError_1.throwError(this.error);
5684 return empty_1.empty();
5686 throw new Error('unexpected notification kind value');
5688 Notification.createNext = function (value) {
5689 if (typeof value !== 'undefined') {
5690 return new Notification('N', value);
5692 return Notification.undefinedValueNotification;
5694 Notification.createError = function (err) {
5695 return new Notification('E', undefined, err);
5697 Notification.createComplete = function () {
5698 return Notification.completeNotification;
5700 Notification.completeNotification = new Notification('C');
5701 Notification.undefinedValueNotification = new Notification('N', undefined);
5702 return Notification;
5704 exports.Notification = Notification;
5706 },{"./observable/empty":48,"./observable/of":62,"./observable/throwError":68}],31:[function(require,module,exports){
5708 Object.defineProperty(exports, "__esModule", { value: true });
5709 var canReportError_1 = require("./util/canReportError");
5710 var toSubscriber_1 = require("./util/toSubscriber");
5711 var observable_1 = require("../internal/symbol/observable");
5712 var pipe_1 = require("./util/pipe");
5713 var config_1 = require("./config");
5714 var Observable = (function () {
5715 function Observable(subscribe) {
5716 this._isScalar = false;
5718 this._subscribe = subscribe;
5721 Observable.prototype.lift = function (operator) {
5722 var observable = new Observable();
5723 observable.source = this;
5724 observable.operator = operator;
5727 Observable.prototype.subscribe = function (observerOrNext, error, complete) {
5728 var operator = this.operator;
5729 var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
5731 operator.call(sink, this.source);
5734 sink.add(this.source || (config_1.config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
5735 this._subscribe(sink) :
5736 this._trySubscribe(sink));
5738 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
5739 if (sink.syncErrorThrowable) {
5740 sink.syncErrorThrowable = false;
5741 if (sink.syncErrorThrown) {
5742 throw sink.syncErrorValue;
5748 Observable.prototype._trySubscribe = function (sink) {
5750 return this._subscribe(sink);
5753 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
5754 sink.syncErrorThrown = true;
5755 sink.syncErrorValue = err;
5757 if (canReportError_1.canReportError(sink)) {
5765 Observable.prototype.forEach = function (next, promiseCtor) {
5767 promiseCtor = getPromiseCtor(promiseCtor);
5768 return new promiseCtor(function (resolve, reject) {
5770 subscription = _this.subscribe(function (value) {
5777 subscription.unsubscribe();
5780 }, reject, resolve);
5783 Observable.prototype._subscribe = function (subscriber) {
5784 var source = this.source;
5785 return source && source.subscribe(subscriber);
5787 Observable.prototype[observable_1.observable] = function () {
5790 Observable.prototype.pipe = function () {
5791 var operations = [];
5792 for (var _i = 0; _i < arguments.length; _i++) {
5793 operations[_i] = arguments[_i];
5795 if (operations.length === 0) {
5798 return pipe_1.pipeFromArray(operations)(this);
5800 Observable.prototype.toPromise = function (promiseCtor) {
5802 promiseCtor = getPromiseCtor(promiseCtor);
5803 return new promiseCtor(function (resolve, reject) {
5805 _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
5808 Observable.create = function (subscribe) {
5809 return new Observable(subscribe);
5813 exports.Observable = Observable;
5814 function getPromiseCtor(promiseCtor) {
5816 promiseCtor = config_1.config.Promise || Promise;
5819 throw new Error('no Promise impl found');
5824 },{"../internal/symbol/observable":190,"./config":40,"./util/canReportError":198,"./util/pipe":215,"./util/toSubscriber":222}],32:[function(require,module,exports){
5826 Object.defineProperty(exports, "__esModule", { value: true });
5827 var config_1 = require("./config");
5828 var hostReportError_1 = require("./util/hostReportError");
5831 next: function (value) { },
5832 error: function (err) {
5833 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
5837 hostReportError_1.hostReportError(err);
5840 complete: function () { }
5843 },{"./config":40,"./util/hostReportError":200}],33:[function(require,module,exports){
5845 var __extends = (this && this.__extends) || (function () {
5846 var extendStatics = function (d, b) {
5847 extendStatics = Object.setPrototypeOf ||
5848 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5849 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5850 return extendStatics(d, b);
5852 return function (d, b) {
5853 extendStatics(d, b);
5854 function __() { this.constructor = d; }
5855 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5858 Object.defineProperty(exports, "__esModule", { value: true });
5859 var Subscriber_1 = require("./Subscriber");
5860 var OuterSubscriber = (function (_super) {
5861 __extends(OuterSubscriber, _super);
5862 function OuterSubscriber() {
5863 return _super !== null && _super.apply(this, arguments) || this;
5865 OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
5866 this.destination.next(innerValue);
5868 OuterSubscriber.prototype.notifyError = function (error, innerSub) {
5869 this.destination.error(error);
5871 OuterSubscriber.prototype.notifyComplete = function (innerSub) {
5872 this.destination.complete();
5874 return OuterSubscriber;
5875 }(Subscriber_1.Subscriber));
5876 exports.OuterSubscriber = OuterSubscriber;
5878 },{"./Subscriber":38}],34:[function(require,module,exports){
5880 var __extends = (this && this.__extends) || (function () {
5881 var extendStatics = function (d, b) {
5882 extendStatics = Object.setPrototypeOf ||
5883 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5884 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5885 return extendStatics(d, b);
5887 return function (d, b) {
5888 extendStatics(d, b);
5889 function __() { this.constructor = d; }
5890 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5893 Object.defineProperty(exports, "__esModule", { value: true });
5894 var Subject_1 = require("./Subject");
5895 var queue_1 = require("./scheduler/queue");
5896 var Subscription_1 = require("./Subscription");
5897 var observeOn_1 = require("./operators/observeOn");
5898 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
5899 var SubjectSubscription_1 = require("./SubjectSubscription");
5900 var ReplaySubject = (function (_super) {
5901 __extends(ReplaySubject, _super);
5902 function ReplaySubject(bufferSize, windowTime, scheduler) {
5903 if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
5904 if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
5905 var _this = _super.call(this) || this;
5906 _this.scheduler = scheduler;
5908 _this._infiniteTimeWindow = false;
5909 _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
5910 _this._windowTime = windowTime < 1 ? 1 : windowTime;
5911 if (windowTime === Number.POSITIVE_INFINITY) {
5912 _this._infiniteTimeWindow = true;
5913 _this.next = _this.nextInfiniteTimeWindow;
5916 _this.next = _this.nextTimeWindow;
5920 ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
5921 var _events = this._events;
5922 _events.push(value);
5923 if (_events.length > this._bufferSize) {
5926 _super.prototype.next.call(this, value);
5928 ReplaySubject.prototype.nextTimeWindow = function (value) {
5929 this._events.push(new ReplayEvent(this._getNow(), value));
5930 this._trimBufferThenGetEvents();
5931 _super.prototype.next.call(this, value);
5933 ReplaySubject.prototype._subscribe = function (subscriber) {
5934 var _infiniteTimeWindow = this._infiniteTimeWindow;
5935 var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
5936 var scheduler = this.scheduler;
5937 var len = _events.length;
5940 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
5942 else if (this.isStopped || this.hasError) {
5943 subscription = Subscription_1.Subscription.EMPTY;
5946 this.observers.push(subscriber);
5947 subscription = new SubjectSubscription_1.SubjectSubscription(this, subscriber);
5950 subscriber.add(subscriber = new observeOn_1.ObserveOnSubscriber(subscriber, scheduler));
5952 if (_infiniteTimeWindow) {
5953 for (var i = 0; i < len && !subscriber.closed; i++) {
5954 subscriber.next(_events[i]);
5958 for (var i = 0; i < len && !subscriber.closed; i++) {
5959 subscriber.next(_events[i].value);
5962 if (this.hasError) {
5963 subscriber.error(this.thrownError);
5965 else if (this.isStopped) {
5966 subscriber.complete();
5968 return subscription;
5970 ReplaySubject.prototype._getNow = function () {
5971 return (this.scheduler || queue_1.queue).now();
5973 ReplaySubject.prototype._trimBufferThenGetEvents = function () {
5974 var now = this._getNow();
5975 var _bufferSize = this._bufferSize;
5976 var _windowTime = this._windowTime;
5977 var _events = this._events;
5978 var eventsCount = _events.length;
5979 var spliceCount = 0;
5980 while (spliceCount < eventsCount) {
5981 if ((now - _events[spliceCount].time) < _windowTime) {
5986 if (eventsCount > _bufferSize) {
5987 spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
5989 if (spliceCount > 0) {
5990 _events.splice(0, spliceCount);
5994 return ReplaySubject;
5995 }(Subject_1.Subject));
5996 exports.ReplaySubject = ReplaySubject;
5997 var ReplayEvent = (function () {
5998 function ReplayEvent(time, value) {
6005 },{"./Subject":36,"./SubjectSubscription":37,"./Subscription":39,"./operators/observeOn":122,"./scheduler/queue":188,"./util/ObjectUnsubscribedError":195}],35:[function(require,module,exports){
6007 Object.defineProperty(exports, "__esModule", { value: true });
6008 var Scheduler = (function () {
6009 function Scheduler(SchedulerAction, now) {
6010 if (now === void 0) { now = Scheduler.now; }
6011 this.SchedulerAction = SchedulerAction;
6014 Scheduler.prototype.schedule = function (work, delay, state) {
6015 if (delay === void 0) { delay = 0; }
6016 return new this.SchedulerAction(this, work).schedule(state, delay);
6018 Scheduler.now = function () { return Date.now(); };
6021 exports.Scheduler = Scheduler;
6023 },{}],36:[function(require,module,exports){
6025 var __extends = (this && this.__extends) || (function () {
6026 var extendStatics = function (d, b) {
6027 extendStatics = Object.setPrototypeOf ||
6028 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6029 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6030 return extendStatics(d, b);
6032 return function (d, b) {
6033 extendStatics(d, b);
6034 function __() { this.constructor = d; }
6035 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6038 Object.defineProperty(exports, "__esModule", { value: true });
6039 var Observable_1 = require("./Observable");
6040 var Subscriber_1 = require("./Subscriber");
6041 var Subscription_1 = require("./Subscription");
6042 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
6043 var SubjectSubscription_1 = require("./SubjectSubscription");
6044 var rxSubscriber_1 = require("../internal/symbol/rxSubscriber");
6045 var SubjectSubscriber = (function (_super) {
6046 __extends(SubjectSubscriber, _super);
6047 function SubjectSubscriber(destination) {
6048 var _this = _super.call(this, destination) || this;
6049 _this.destination = destination;
6052 return SubjectSubscriber;
6053 }(Subscriber_1.Subscriber));
6054 exports.SubjectSubscriber = SubjectSubscriber;
6055 var Subject = (function (_super) {
6056 __extends(Subject, _super);
6057 function Subject() {
6058 var _this = _super.call(this) || this;
6059 _this.observers = [];
6060 _this.closed = false;
6061 _this.isStopped = false;
6062 _this.hasError = false;
6063 _this.thrownError = null;
6066 Subject.prototype[rxSubscriber_1.rxSubscriber] = function () {
6067 return new SubjectSubscriber(this);
6069 Subject.prototype.lift = function (operator) {
6070 var subject = new AnonymousSubject(this, this);
6071 subject.operator = operator;
6074 Subject.prototype.next = function (value) {
6076 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
6078 if (!this.isStopped) {
6079 var observers = this.observers;
6080 var len = observers.length;
6081 var copy = observers.slice();
6082 for (var i = 0; i < len; i++) {
6083 copy[i].next(value);
6087 Subject.prototype.error = function (err) {
6089 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
6091 this.hasError = true;
6092 this.thrownError = err;
6093 this.isStopped = true;
6094 var observers = this.observers;
6095 var len = observers.length;
6096 var copy = observers.slice();
6097 for (var i = 0; i < len; i++) {
6100 this.observers.length = 0;
6102 Subject.prototype.complete = function () {
6104 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
6106 this.isStopped = true;
6107 var observers = this.observers;
6108 var len = observers.length;
6109 var copy = observers.slice();
6110 for (var i = 0; i < len; i++) {
6113 this.observers.length = 0;
6115 Subject.prototype.unsubscribe = function () {
6116 this.isStopped = true;
6118 this.observers = null;
6120 Subject.prototype._trySubscribe = function (subscriber) {
6122 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
6125 return _super.prototype._trySubscribe.call(this, subscriber);
6128 Subject.prototype._subscribe = function (subscriber) {
6130 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
6132 else if (this.hasError) {
6133 subscriber.error(this.thrownError);
6134 return Subscription_1.Subscription.EMPTY;
6136 else if (this.isStopped) {
6137 subscriber.complete();
6138 return Subscription_1.Subscription.EMPTY;
6141 this.observers.push(subscriber);
6142 return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
6145 Subject.prototype.asObservable = function () {
6146 var observable = new Observable_1.Observable();
6147 observable.source = this;
6150 Subject.create = function (destination, source) {
6151 return new AnonymousSubject(destination, source);
6154 }(Observable_1.Observable));
6155 exports.Subject = Subject;
6156 var AnonymousSubject = (function (_super) {
6157 __extends(AnonymousSubject, _super);
6158 function AnonymousSubject(destination, source) {
6159 var _this = _super.call(this) || this;
6160 _this.destination = destination;
6161 _this.source = source;
6164 AnonymousSubject.prototype.next = function (value) {
6165 var destination = this.destination;
6166 if (destination && destination.next) {
6167 destination.next(value);
6170 AnonymousSubject.prototype.error = function (err) {
6171 var destination = this.destination;
6172 if (destination && destination.error) {
6173 this.destination.error(err);
6176 AnonymousSubject.prototype.complete = function () {
6177 var destination = this.destination;
6178 if (destination && destination.complete) {
6179 this.destination.complete();
6182 AnonymousSubject.prototype._subscribe = function (subscriber) {
6183 var source = this.source;
6185 return this.source.subscribe(subscriber);
6188 return Subscription_1.Subscription.EMPTY;
6191 return AnonymousSubject;
6193 exports.AnonymousSubject = AnonymousSubject;
6195 },{"../internal/symbol/rxSubscriber":191,"./Observable":31,"./SubjectSubscription":37,"./Subscriber":38,"./Subscription":39,"./util/ObjectUnsubscribedError":195}],37:[function(require,module,exports){
6197 var __extends = (this && this.__extends) || (function () {
6198 var extendStatics = function (d, b) {
6199 extendStatics = Object.setPrototypeOf ||
6200 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6201 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6202 return extendStatics(d, b);
6204 return function (d, b) {
6205 extendStatics(d, b);
6206 function __() { this.constructor = d; }
6207 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6210 Object.defineProperty(exports, "__esModule", { value: true });
6211 var Subscription_1 = require("./Subscription");
6212 var SubjectSubscription = (function (_super) {
6213 __extends(SubjectSubscription, _super);
6214 function SubjectSubscription(subject, subscriber) {
6215 var _this = _super.call(this) || this;
6216 _this.subject = subject;
6217 _this.subscriber = subscriber;
6218 _this.closed = false;
6221 SubjectSubscription.prototype.unsubscribe = function () {
6226 var subject = this.subject;
6227 var observers = subject.observers;
6228 this.subject = null;
6229 if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
6232 var subscriberIndex = observers.indexOf(this.subscriber);
6233 if (subscriberIndex !== -1) {
6234 observers.splice(subscriberIndex, 1);
6237 return SubjectSubscription;
6238 }(Subscription_1.Subscription));
6239 exports.SubjectSubscription = SubjectSubscription;
6241 },{"./Subscription":39}],38:[function(require,module,exports){
6243 var __extends = (this && this.__extends) || (function () {
6244 var extendStatics = function (d, b) {
6245 extendStatics = Object.setPrototypeOf ||
6246 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6247 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6248 return extendStatics(d, b);
6250 return function (d, b) {
6251 extendStatics(d, b);
6252 function __() { this.constructor = d; }
6253 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6256 Object.defineProperty(exports, "__esModule", { value: true });
6257 var isFunction_1 = require("./util/isFunction");
6258 var Observer_1 = require("./Observer");
6259 var Subscription_1 = require("./Subscription");
6260 var rxSubscriber_1 = require("../internal/symbol/rxSubscriber");
6261 var config_1 = require("./config");
6262 var hostReportError_1 = require("./util/hostReportError");
6263 var Subscriber = (function (_super) {
6264 __extends(Subscriber, _super);
6265 function Subscriber(destinationOrNext, error, complete) {
6266 var _this = _super.call(this) || this;
6267 _this.syncErrorValue = null;
6268 _this.syncErrorThrown = false;
6269 _this.syncErrorThrowable = false;
6270 _this.isStopped = false;
6271 _this._parentSubscription = null;
6272 switch (arguments.length) {
6274 _this.destination = Observer_1.empty;
6277 if (!destinationOrNext) {
6278 _this.destination = Observer_1.empty;
6281 if (typeof destinationOrNext === 'object') {
6282 if (destinationOrNext instanceof Subscriber) {
6283 _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
6284 _this.destination = destinationOrNext;
6285 destinationOrNext.add(_this);
6288 _this.syncErrorThrowable = true;
6289 _this.destination = new SafeSubscriber(_this, destinationOrNext);
6294 _this.syncErrorThrowable = true;
6295 _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
6300 Subscriber.prototype[rxSubscriber_1.rxSubscriber] = function () { return this; };
6301 Subscriber.create = function (next, error, complete) {
6302 var subscriber = new Subscriber(next, error, complete);
6303 subscriber.syncErrorThrowable = false;
6306 Subscriber.prototype.next = function (value) {
6307 if (!this.isStopped) {
6311 Subscriber.prototype.error = function (err) {
6312 if (!this.isStopped) {
6313 this.isStopped = true;
6317 Subscriber.prototype.complete = function () {
6318 if (!this.isStopped) {
6319 this.isStopped = true;
6323 Subscriber.prototype.unsubscribe = function () {
6327 this.isStopped = true;
6328 _super.prototype.unsubscribe.call(this);
6330 Subscriber.prototype._next = function (value) {
6331 this.destination.next(value);
6333 Subscriber.prototype._error = function (err) {
6334 this.destination.error(err);
6337 Subscriber.prototype._complete = function () {
6338 this.destination.complete();
6341 Subscriber.prototype._unsubscribeAndRecycle = function () {
6342 var _a = this, _parent = _a._parent, _parents = _a._parents;
6343 this._parent = null;
6344 this._parents = null;
6346 this.closed = false;
6347 this.isStopped = false;
6348 this._parent = _parent;
6349 this._parents = _parents;
6350 this._parentSubscription = null;
6354 }(Subscription_1.Subscription));
6355 exports.Subscriber = Subscriber;
6356 var SafeSubscriber = (function (_super) {
6357 __extends(SafeSubscriber, _super);
6358 function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
6359 var _this = _super.call(this) || this;
6360 _this._parentSubscriber = _parentSubscriber;
6362 var context = _this;
6363 if (isFunction_1.isFunction(observerOrNext)) {
6364 next = observerOrNext;
6366 else if (observerOrNext) {
6367 next = observerOrNext.next;
6368 error = observerOrNext.error;
6369 complete = observerOrNext.complete;
6370 if (observerOrNext !== Observer_1.empty) {
6371 context = Object.create(observerOrNext);
6372 if (isFunction_1.isFunction(context.unsubscribe)) {
6373 _this.add(context.unsubscribe.bind(context));
6375 context.unsubscribe = _this.unsubscribe.bind(_this);
6378 _this._context = context;
6380 _this._error = error;
6381 _this._complete = complete;
6384 SafeSubscriber.prototype.next = function (value) {
6385 if (!this.isStopped && this._next) {
6386 var _parentSubscriber = this._parentSubscriber;
6387 if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
6388 this.__tryOrUnsub(this._next, value);
6390 else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
6395 SafeSubscriber.prototype.error = function (err) {
6396 if (!this.isStopped) {
6397 var _parentSubscriber = this._parentSubscriber;
6398 var useDeprecatedSynchronousErrorHandling = config_1.config.useDeprecatedSynchronousErrorHandling;
6400 if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
6401 this.__tryOrUnsub(this._error, err);
6405 this.__tryOrSetError(_parentSubscriber, this._error, err);
6409 else if (!_parentSubscriber.syncErrorThrowable) {
6411 if (useDeprecatedSynchronousErrorHandling) {
6414 hostReportError_1.hostReportError(err);
6417 if (useDeprecatedSynchronousErrorHandling) {
6418 _parentSubscriber.syncErrorValue = err;
6419 _parentSubscriber.syncErrorThrown = true;
6422 hostReportError_1.hostReportError(err);
6428 SafeSubscriber.prototype.complete = function () {
6430 if (!this.isStopped) {
6431 var _parentSubscriber = this._parentSubscriber;
6432 if (this._complete) {
6433 var wrappedComplete = function () { return _this._complete.call(_this._context); };
6434 if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
6435 this.__tryOrUnsub(wrappedComplete);
6439 this.__tryOrSetError(_parentSubscriber, wrappedComplete);
6448 SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
6450 fn.call(this._context, value);
6454 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
6458 hostReportError_1.hostReportError(err);
6462 SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
6463 if (!config_1.config.useDeprecatedSynchronousErrorHandling) {
6464 throw new Error('bad call');
6467 fn.call(this._context, value);
6470 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
6471 parent.syncErrorValue = err;
6472 parent.syncErrorThrown = true;
6476 hostReportError_1.hostReportError(err);
6482 SafeSubscriber.prototype._unsubscribe = function () {
6483 var _parentSubscriber = this._parentSubscriber;
6484 this._context = null;
6485 this._parentSubscriber = null;
6486 _parentSubscriber.unsubscribe();
6488 return SafeSubscriber;
6490 exports.SafeSubscriber = SafeSubscriber;
6492 },{"../internal/symbol/rxSubscriber":191,"./Observer":32,"./Subscription":39,"./config":40,"./util/hostReportError":200,"./util/isFunction":205}],39:[function(require,module,exports){
6494 Object.defineProperty(exports, "__esModule", { value: true });
6495 var isArray_1 = require("./util/isArray");
6496 var isObject_1 = require("./util/isObject");
6497 var isFunction_1 = require("./util/isFunction");
6498 var tryCatch_1 = require("./util/tryCatch");
6499 var errorObject_1 = require("./util/errorObject");
6500 var UnsubscriptionError_1 = require("./util/UnsubscriptionError");
6501 var Subscription = (function () {
6502 function Subscription(unsubscribe) {
6503 this.closed = false;
6504 this._parent = null;
6505 this._parents = null;
6506 this._subscriptions = null;
6508 this._unsubscribe = unsubscribe;
6511 Subscription.prototype.unsubscribe = function () {
6512 var hasErrors = false;
6517 var _a = this, _parent = _a._parent, _parents = _a._parents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
6519 this._parent = null;
6520 this._parents = null;
6521 this._subscriptions = null;
6523 var len = _parents ? _parents.length : 0;
6525 _parent.remove(this);
6526 _parent = ++index < len && _parents[index] || null;
6528 if (isFunction_1.isFunction(_unsubscribe)) {
6529 var trial = tryCatch_1.tryCatch(_unsubscribe).call(this);
6530 if (trial === errorObject_1.errorObject) {
6532 errors = errors || (errorObject_1.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ?
6533 flattenUnsubscriptionErrors(errorObject_1.errorObject.e.errors) : [errorObject_1.errorObject.e]);
6536 if (isArray_1.isArray(_subscriptions)) {
6538 len = _subscriptions.length;
6539 while (++index < len) {
6540 var sub = _subscriptions[index];
6541 if (isObject_1.isObject(sub)) {
6542 var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub);
6543 if (trial === errorObject_1.errorObject) {
6545 errors = errors || [];
6546 var err = errorObject_1.errorObject.e;
6547 if (err instanceof UnsubscriptionError_1.UnsubscriptionError) {
6548 errors = errors.concat(flattenUnsubscriptionErrors(err.errors));
6558 throw new UnsubscriptionError_1.UnsubscriptionError(errors);
6561 Subscription.prototype.add = function (teardown) {
6562 if (!teardown || (teardown === Subscription.EMPTY)) {
6563 return Subscription.EMPTY;
6565 if (teardown === this) {
6568 var subscription = teardown;
6569 switch (typeof teardown) {
6571 subscription = new Subscription(teardown);
6573 if (subscription.closed || typeof subscription.unsubscribe !== 'function') {
6574 return subscription;
6576 else if (this.closed) {
6577 subscription.unsubscribe();
6578 return subscription;
6580 else if (typeof subscription._addParent !== 'function') {
6581 var tmp = subscription;
6582 subscription = new Subscription();
6583 subscription._subscriptions = [tmp];
6587 throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
6589 var subscriptions = this._subscriptions || (this._subscriptions = []);
6590 subscriptions.push(subscription);
6591 subscription._addParent(this);
6592 return subscription;
6594 Subscription.prototype.remove = function (subscription) {
6595 var subscriptions = this._subscriptions;
6596 if (subscriptions) {
6597 var subscriptionIndex = subscriptions.indexOf(subscription);
6598 if (subscriptionIndex !== -1) {
6599 subscriptions.splice(subscriptionIndex, 1);
6603 Subscription.prototype._addParent = function (parent) {
6604 var _a = this, _parent = _a._parent, _parents = _a._parents;
6605 if (!_parent || _parent === parent) {
6606 this._parent = parent;
6608 else if (!_parents) {
6609 this._parents = [parent];
6611 else if (_parents.indexOf(parent) === -1) {
6612 _parents.push(parent);
6615 Subscription.EMPTY = (function (empty) {
6616 empty.closed = true;
6618 }(new Subscription()));
6619 return Subscription;
6621 exports.Subscription = Subscription;
6622 function flattenUnsubscriptionErrors(errors) {
6623 return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []);
6626 },{"./util/UnsubscriptionError":197,"./util/errorObject":199,"./util/isArray":202,"./util/isFunction":205,"./util/isObject":209,"./util/tryCatch":223}],40:[function(require,module,exports){
6628 Object.defineProperty(exports, "__esModule", { value: true });
6629 var _enable_super_gross_mode_that_will_cause_bad_things = false;
6632 set useDeprecatedSynchronousErrorHandling(value) {
6634 var error = new Error();
6635 console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
6637 else if (_enable_super_gross_mode_that_will_cause_bad_things) {
6638 console.log('RxJS: Back to a better error behavior. Thank you. <3');
6640 _enable_super_gross_mode_that_will_cause_bad_things = value;
6642 get useDeprecatedSynchronousErrorHandling() {
6643 return _enable_super_gross_mode_that_will_cause_bad_things;
6647 },{}],41:[function(require,module,exports){
6649 var __extends = (this && this.__extends) || (function () {
6650 var extendStatics = function (d, b) {
6651 extendStatics = Object.setPrototypeOf ||
6652 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6653 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6654 return extendStatics(d, b);
6656 return function (d, b) {
6657 extendStatics(d, b);
6658 function __() { this.constructor = d; }
6659 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6662 Object.defineProperty(exports, "__esModule", { value: true });
6663 var Subject_1 = require("../Subject");
6664 var Observable_1 = require("../Observable");
6665 var Subscriber_1 = require("../Subscriber");
6666 var Subscription_1 = require("../Subscription");
6667 var refCount_1 = require("../operators/refCount");
6668 var ConnectableObservable = (function (_super) {
6669 __extends(ConnectableObservable, _super);
6670 function ConnectableObservable(source, subjectFactory) {
6671 var _this = _super.call(this) || this;
6672 _this.source = source;
6673 _this.subjectFactory = subjectFactory;
6674 _this._refCount = 0;
6675 _this._isComplete = false;
6678 ConnectableObservable.prototype._subscribe = function (subscriber) {
6679 return this.getSubject().subscribe(subscriber);
6681 ConnectableObservable.prototype.getSubject = function () {
6682 var subject = this._subject;
6683 if (!subject || subject.isStopped) {
6684 this._subject = this.subjectFactory();
6686 return this._subject;
6688 ConnectableObservable.prototype.connect = function () {
6689 var connection = this._connection;
6691 this._isComplete = false;
6692 connection = this._connection = new Subscription_1.Subscription();
6693 connection.add(this.source
6694 .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
6695 if (connection.closed) {
6696 this._connection = null;
6697 connection = Subscription_1.Subscription.EMPTY;
6700 this._connection = connection;
6705 ConnectableObservable.prototype.refCount = function () {
6706 return refCount_1.refCount()(this);
6708 return ConnectableObservable;
6709 }(Observable_1.Observable));
6710 exports.ConnectableObservable = ConnectableObservable;
6711 var connectableProto = ConnectableObservable.prototype;
6712 exports.connectableObservableDescriptor = {
6713 operator: { value: null },
6714 _refCount: { value: 0, writable: true },
6715 _subject: { value: null, writable: true },
6716 _connection: { value: null, writable: true },
6717 _subscribe: { value: connectableProto._subscribe },
6718 _isComplete: { value: connectableProto._isComplete, writable: true },
6719 getSubject: { value: connectableProto.getSubject },
6720 connect: { value: connectableProto.connect },
6721 refCount: { value: connectableProto.refCount }
6723 var ConnectableSubscriber = (function (_super) {
6724 __extends(ConnectableSubscriber, _super);
6725 function ConnectableSubscriber(destination, connectable) {
6726 var _this = _super.call(this, destination) || this;
6727 _this.connectable = connectable;
6730 ConnectableSubscriber.prototype._error = function (err) {
6731 this._unsubscribe();
6732 _super.prototype._error.call(this, err);
6734 ConnectableSubscriber.prototype._complete = function () {
6735 this.connectable._isComplete = true;
6736 this._unsubscribe();
6737 _super.prototype._complete.call(this);
6739 ConnectableSubscriber.prototype._unsubscribe = function () {
6740 var connectable = this.connectable;
6742 this.connectable = null;
6743 var connection = connectable._connection;
6744 connectable._refCount = 0;
6745 connectable._subject = null;
6746 connectable._connection = null;
6748 connection.unsubscribe();
6752 return ConnectableSubscriber;
6753 }(Subject_1.SubjectSubscriber));
6754 var RefCountOperator = (function () {
6755 function RefCountOperator(connectable) {
6756 this.connectable = connectable;
6758 RefCountOperator.prototype.call = function (subscriber, source) {
6759 var connectable = this.connectable;
6760 connectable._refCount++;
6761 var refCounter = new RefCountSubscriber(subscriber, connectable);
6762 var subscription = source.subscribe(refCounter);
6763 if (!refCounter.closed) {
6764 refCounter.connection = connectable.connect();
6766 return subscription;
6768 return RefCountOperator;
6770 var RefCountSubscriber = (function (_super) {
6771 __extends(RefCountSubscriber, _super);
6772 function RefCountSubscriber(destination, connectable) {
6773 var _this = _super.call(this, destination) || this;
6774 _this.connectable = connectable;
6777 RefCountSubscriber.prototype._unsubscribe = function () {
6778 var connectable = this.connectable;
6780 this.connection = null;
6783 this.connectable = null;
6784 var refCount = connectable._refCount;
6785 if (refCount <= 0) {
6786 this.connection = null;
6789 connectable._refCount = refCount - 1;
6791 this.connection = null;
6794 var connection = this.connection;
6795 var sharedConnection = connectable._connection;
6796 this.connection = null;
6797 if (sharedConnection && (!connection || sharedConnection === connection)) {
6798 sharedConnection.unsubscribe();
6801 return RefCountSubscriber;
6802 }(Subscriber_1.Subscriber));
6804 },{"../Observable":31,"../Subject":36,"../Subscriber":38,"../Subscription":39,"../operators/refCount":133}],42:[function(require,module,exports){
6806 var __extends = (this && this.__extends) || (function () {
6807 var extendStatics = function (d, b) {
6808 extendStatics = Object.setPrototypeOf ||
6809 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6810 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6811 return extendStatics(d, b);
6813 return function (d, b) {
6814 extendStatics(d, b);
6815 function __() { this.constructor = d; }
6816 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6819 Object.defineProperty(exports, "__esModule", { value: true });
6820 var Observable_1 = require("../Observable");
6821 var asap_1 = require("../scheduler/asap");
6822 var isNumeric_1 = require("../util/isNumeric");
6823 var SubscribeOnObservable = (function (_super) {
6824 __extends(SubscribeOnObservable, _super);
6825 function SubscribeOnObservable(source, delayTime, scheduler) {
6826 if (delayTime === void 0) { delayTime = 0; }
6827 if (scheduler === void 0) { scheduler = asap_1.asap; }
6828 var _this = _super.call(this) || this;
6829 _this.source = source;
6830 _this.delayTime = delayTime;
6831 _this.scheduler = scheduler;
6832 if (!isNumeric_1.isNumeric(delayTime) || delayTime < 0) {
6833 _this.delayTime = 0;
6835 if (!scheduler || typeof scheduler.schedule !== 'function') {
6836 _this.scheduler = asap_1.asap;
6840 SubscribeOnObservable.create = function (source, delay, scheduler) {
6841 if (delay === void 0) { delay = 0; }
6842 if (scheduler === void 0) { scheduler = asap_1.asap; }
6843 return new SubscribeOnObservable(source, delay, scheduler);
6845 SubscribeOnObservable.dispatch = function (arg) {
6846 var source = arg.source, subscriber = arg.subscriber;
6847 return this.add(source.subscribe(subscriber));
6849 SubscribeOnObservable.prototype._subscribe = function (subscriber) {
6850 var delay = this.delayTime;
6851 var source = this.source;
6852 var scheduler = this.scheduler;
6853 return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
6854 source: source, subscriber: subscriber
6857 return SubscribeOnObservable;
6858 }(Observable_1.Observable));
6859 exports.SubscribeOnObservable = SubscribeOnObservable;
6861 },{"../Observable":31,"../scheduler/asap":186,"../util/isNumeric":208}],43:[function(require,module,exports){
6863 Object.defineProperty(exports, "__esModule", { value: true });
6864 var Observable_1 = require("../Observable");
6865 var AsyncSubject_1 = require("../AsyncSubject");
6866 var map_1 = require("../operators/map");
6867 var canReportError_1 = require("../util/canReportError");
6868 var isArray_1 = require("../util/isArray");
6869 var isScheduler_1 = require("../util/isScheduler");
6870 function bindCallback(callbackFunc, resultSelector, scheduler) {
6871 if (resultSelector) {
6872 if (isScheduler_1.isScheduler(resultSelector)) {
6873 scheduler = resultSelector;
6876 return function () {
6878 for (var _i = 0; _i < arguments.length; _i++) {
6879 args[_i] = arguments[_i];
6881 return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
6885 return function () {
6887 for (var _i = 0; _i < arguments.length; _i++) {
6888 args[_i] = arguments[_i];
6895 callbackFunc: callbackFunc,
6896 scheduler: scheduler,
6898 return new Observable_1.Observable(function (subscriber) {
6901 subject = new AsyncSubject_1.AsyncSubject();
6902 var handler = function () {
6904 for (var _i = 0; _i < arguments.length; _i++) {
6905 innerArgs[_i] = arguments[_i];
6907 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
6911 callbackFunc.apply(context, args.concat([handler]));
6914 if (canReportError_1.canReportError(subject)) {
6922 return subject.subscribe(subscriber);
6926 args: args, subscriber: subscriber, params: params,
6928 return scheduler.schedule(dispatch, 0, state);
6933 exports.bindCallback = bindCallback;
6934 function dispatch(state) {
6937 var args = state.args, subscriber = state.subscriber, params = state.params;
6938 var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
6939 var subject = params.subject;
6941 subject = params.subject = new AsyncSubject_1.AsyncSubject();
6942 var handler = function () {
6944 for (var _i = 0; _i < arguments.length; _i++) {
6945 innerArgs[_i] = arguments[_i];
6947 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
6948 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
6951 callbackFunc.apply(context, args.concat([handler]));
6957 this.add(subject.subscribe(subscriber));
6959 function dispatchNext(state) {
6960 var value = state.value, subject = state.subject;
6961 subject.next(value);
6964 function dispatchError(state) {
6965 var err = state.err, subject = state.subject;
6969 },{"../AsyncSubject":27,"../Observable":31,"../operators/map":111,"../util/canReportError":198,"../util/isArray":202,"../util/isScheduler":212}],44:[function(require,module,exports){
6971 Object.defineProperty(exports, "__esModule", { value: true });
6972 var Observable_1 = require("../Observable");
6973 var AsyncSubject_1 = require("../AsyncSubject");
6974 var map_1 = require("../operators/map");
6975 var canReportError_1 = require("../util/canReportError");
6976 var isScheduler_1 = require("../util/isScheduler");
6977 var isArray_1 = require("../util/isArray");
6978 function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
6979 if (resultSelector) {
6980 if (isScheduler_1.isScheduler(resultSelector)) {
6981 scheduler = resultSelector;
6984 return function () {
6986 for (var _i = 0; _i < arguments.length; _i++) {
6987 args[_i] = arguments[_i];
6989 return bindNodeCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
6993 return function () {
6995 for (var _i = 0; _i < arguments.length; _i++) {
6996 args[_i] = arguments[_i];
7001 callbackFunc: callbackFunc,
7002 scheduler: scheduler,
7005 return new Observable_1.Observable(function (subscriber) {
7006 var context = params.context;
7007 var subject = params.subject;
7010 subject = params.subject = new AsyncSubject_1.AsyncSubject();
7011 var handler = function () {
7013 for (var _i = 0; _i < arguments.length; _i++) {
7014 innerArgs[_i] = arguments[_i];
7016 var err = innerArgs.shift();
7021 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
7025 callbackFunc.apply(context, args.concat([handler]));
7028 if (canReportError_1.canReportError(subject)) {
7036 return subject.subscribe(subscriber);
7039 return scheduler.schedule(dispatch, 0, { params: params, subscriber: subscriber, context: context });
7044 exports.bindNodeCallback = bindNodeCallback;
7045 function dispatch(state) {
7047 var params = state.params, subscriber = state.subscriber, context = state.context;
7048 var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
7049 var subject = params.subject;
7051 subject = params.subject = new AsyncSubject_1.AsyncSubject();
7052 var handler = function () {
7054 for (var _i = 0; _i < arguments.length; _i++) {
7055 innerArgs[_i] = arguments[_i];
7057 var err = innerArgs.shift();
7059 _this.add(scheduler.schedule(dispatchError, 0, { err: err, subject: subject }));
7062 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
7063 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
7067 callbackFunc.apply(context, args.concat([handler]));
7070 this.add(scheduler.schedule(dispatchError, 0, { err: err, subject: subject }));
7073 this.add(subject.subscribe(subscriber));
7075 function dispatchNext(arg) {
7076 var value = arg.value, subject = arg.subject;
7077 subject.next(value);
7080 function dispatchError(arg) {
7081 var err = arg.err, subject = arg.subject;
7085 },{"../AsyncSubject":27,"../Observable":31,"../operators/map":111,"../util/canReportError":198,"../util/isArray":202,"../util/isScheduler":212}],45:[function(require,module,exports){
7087 var __extends = (this && this.__extends) || (function () {
7088 var extendStatics = function (d, b) {
7089 extendStatics = Object.setPrototypeOf ||
7090 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7091 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7092 return extendStatics(d, b);
7094 return function (d, b) {
7095 extendStatics(d, b);
7096 function __() { this.constructor = d; }
7097 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7100 Object.defineProperty(exports, "__esModule", { value: true });
7101 var isScheduler_1 = require("../util/isScheduler");
7102 var isArray_1 = require("../util/isArray");
7103 var OuterSubscriber_1 = require("../OuterSubscriber");
7104 var subscribeToResult_1 = require("../util/subscribeToResult");
7105 var fromArray_1 = require("./fromArray");
7107 function combineLatest() {
7108 var observables = [];
7109 for (var _i = 0; _i < arguments.length; _i++) {
7110 observables[_i] = arguments[_i];
7112 var resultSelector = null;
7113 var scheduler = null;
7114 if (isScheduler_1.isScheduler(observables[observables.length - 1])) {
7115 scheduler = observables.pop();
7117 if (typeof observables[observables.length - 1] === 'function') {
7118 resultSelector = observables.pop();
7120 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
7121 observables = observables[0];
7123 return fromArray_1.fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
7125 exports.combineLatest = combineLatest;
7126 var CombineLatestOperator = (function () {
7127 function CombineLatestOperator(resultSelector) {
7128 this.resultSelector = resultSelector;
7130 CombineLatestOperator.prototype.call = function (subscriber, source) {
7131 return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
7133 return CombineLatestOperator;
7135 exports.CombineLatestOperator = CombineLatestOperator;
7136 var CombineLatestSubscriber = (function (_super) {
7137 __extends(CombineLatestSubscriber, _super);
7138 function CombineLatestSubscriber(destination, resultSelector) {
7139 var _this = _super.call(this, destination) || this;
7140 _this.resultSelector = resultSelector;
7143 _this.observables = [];
7146 CombineLatestSubscriber.prototype._next = function (observable) {
7147 this.values.push(NONE);
7148 this.observables.push(observable);
7150 CombineLatestSubscriber.prototype._complete = function () {
7151 var observables = this.observables;
7152 var len = observables.length;
7154 this.destination.complete();
7158 this.toRespond = len;
7159 for (var i = 0; i < len; i++) {
7160 var observable = observables[i];
7161 this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i));
7165 CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
7166 if ((this.active -= 1) === 0) {
7167 this.destination.complete();
7170 CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7171 var values = this.values;
7172 var oldVal = values[outerIndex];
7173 var toRespond = !this.toRespond
7175 : oldVal === NONE ? --this.toRespond : this.toRespond;
7176 values[outerIndex] = innerValue;
7177 if (toRespond === 0) {
7178 if (this.resultSelector) {
7179 this._tryResultSelector(values);
7182 this.destination.next(values.slice());
7186 CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
7189 result = this.resultSelector.apply(this, values);
7192 this.destination.error(err);
7195 this.destination.next(result);
7197 return CombineLatestSubscriber;
7198 }(OuterSubscriber_1.OuterSubscriber));
7199 exports.CombineLatestSubscriber = CombineLatestSubscriber;
7201 },{"../OuterSubscriber":33,"../util/isArray":202,"../util/isScheduler":212,"../util/subscribeToResult":221,"./fromArray":51}],46:[function(require,module,exports){
7203 Object.defineProperty(exports, "__esModule", { value: true });
7204 var isScheduler_1 = require("../util/isScheduler");
7205 var of_1 = require("./of");
7206 var from_1 = require("./from");
7207 var concatAll_1 = require("../operators/concatAll");
7209 var observables = [];
7210 for (var _i = 0; _i < arguments.length; _i++) {
7211 observables[_i] = arguments[_i];
7213 if (observables.length === 1 || (observables.length === 2 && isScheduler_1.isScheduler(observables[1]))) {
7214 return from_1.from(observables[0]);
7216 return concatAll_1.concatAll()(of_1.of.apply(void 0, observables));
7218 exports.concat = concat;
7220 },{"../operators/concatAll":83,"../util/isScheduler":212,"./from":50,"./of":62}],47:[function(require,module,exports){
7222 Object.defineProperty(exports, "__esModule", { value: true });
7223 var Observable_1 = require("../Observable");
7224 var from_1 = require("./from");
7225 var empty_1 = require("./empty");
7226 function defer(observableFactory) {
7227 return new Observable_1.Observable(function (subscriber) {
7230 input = observableFactory();
7233 subscriber.error(err);
7236 var source = input ? from_1.from(input) : empty_1.empty();
7237 return source.subscribe(subscriber);
7240 exports.defer = defer;
7242 },{"../Observable":31,"./empty":48,"./from":50}],48:[function(require,module,exports){
7244 Object.defineProperty(exports, "__esModule", { value: true });
7245 var Observable_1 = require("../Observable");
7246 exports.EMPTY = new Observable_1.Observable(function (subscriber) { return subscriber.complete(); });
7247 function empty(scheduler) {
7248 return scheduler ? emptyScheduled(scheduler) : exports.EMPTY;
7250 exports.empty = empty;
7251 function emptyScheduled(scheduler) {
7252 return new Observable_1.Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
7254 exports.emptyScheduled = emptyScheduled;
7256 },{"../Observable":31}],49:[function(require,module,exports){
7258 var __extends = (this && this.__extends) || (function () {
7259 var extendStatics = function (d, b) {
7260 extendStatics = Object.setPrototypeOf ||
7261 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7262 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7263 return extendStatics(d, b);
7265 return function (d, b) {
7266 extendStatics(d, b);
7267 function __() { this.constructor = d; }
7268 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7271 Object.defineProperty(exports, "__esModule", { value: true });
7272 var Observable_1 = require("../Observable");
7273 var isArray_1 = require("../util/isArray");
7274 var empty_1 = require("./empty");
7275 var subscribeToResult_1 = require("../util/subscribeToResult");
7276 var OuterSubscriber_1 = require("../OuterSubscriber");
7277 var map_1 = require("../operators/map");
7278 function forkJoin() {
7280 for (var _i = 0; _i < arguments.length; _i++) {
7281 sources[_i] = arguments[_i];
7284 if (typeof sources[sources.length - 1] === 'function') {
7285 resultSelector = sources.pop();
7287 if (sources.length === 1 && isArray_1.isArray(sources[0])) {
7288 sources = sources[0];
7290 if (sources.length === 0) {
7291 return empty_1.EMPTY;
7293 if (resultSelector) {
7294 return forkJoin(sources).pipe(map_1.map(function (args) { return resultSelector.apply(void 0, args); }));
7296 return new Observable_1.Observable(function (subscriber) {
7297 return new ForkJoinSubscriber(subscriber, sources);
7300 exports.forkJoin = forkJoin;
7301 var ForkJoinSubscriber = (function (_super) {
7302 __extends(ForkJoinSubscriber, _super);
7303 function ForkJoinSubscriber(destination, sources) {
7304 var _this = _super.call(this, destination) || this;
7305 _this.sources = sources;
7306 _this.completed = 0;
7307 _this.haveValues = 0;
7308 var len = sources.length;
7309 _this.values = new Array(len);
7310 for (var i = 0; i < len; i++) {
7311 var source = sources[i];
7312 var innerSubscription = subscribeToResult_1.subscribeToResult(_this, source, null, i);
7313 if (innerSubscription) {
7314 _this.add(innerSubscription);
7319 ForkJoinSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7320 this.values[outerIndex] = innerValue;
7321 if (!innerSub._hasValue) {
7322 innerSub._hasValue = true;
7326 ForkJoinSubscriber.prototype.notifyComplete = function (innerSub) {
7327 var _a = this, destination = _a.destination, haveValues = _a.haveValues, values = _a.values;
7328 var len = values.length;
7329 if (!innerSub._hasValue) {
7330 destination.complete();
7334 if (this.completed !== len) {
7337 if (haveValues === len) {
7338 destination.next(values);
7340 destination.complete();
7342 return ForkJoinSubscriber;
7343 }(OuterSubscriber_1.OuterSubscriber));
7345 },{"../Observable":31,"../OuterSubscriber":33,"../operators/map":111,"../util/isArray":202,"../util/subscribeToResult":221,"./empty":48}],50:[function(require,module,exports){
7347 Object.defineProperty(exports, "__esModule", { value: true });
7348 var Observable_1 = require("../Observable");
7349 var isPromise_1 = require("../util/isPromise");
7350 var isArrayLike_1 = require("../util/isArrayLike");
7351 var isInteropObservable_1 = require("../util/isInteropObservable");
7352 var isIterable_1 = require("../util/isIterable");
7353 var fromArray_1 = require("./fromArray");
7354 var fromPromise_1 = require("./fromPromise");
7355 var fromIterable_1 = require("./fromIterable");
7356 var fromObservable_1 = require("./fromObservable");
7357 var subscribeTo_1 = require("../util/subscribeTo");
7358 function from(input, scheduler) {
7360 if (input instanceof Observable_1.Observable) {
7363 return new Observable_1.Observable(subscribeTo_1.subscribeTo(input));
7365 if (input != null) {
7366 if (isInteropObservable_1.isInteropObservable(input)) {
7367 return fromObservable_1.fromObservable(input, scheduler);
7369 else if (isPromise_1.isPromise(input)) {
7370 return fromPromise_1.fromPromise(input, scheduler);
7372 else if (isArrayLike_1.isArrayLike(input)) {
7373 return fromArray_1.fromArray(input, scheduler);
7375 else if (isIterable_1.isIterable(input) || typeof input === 'string') {
7376 return fromIterable_1.fromIterable(input, scheduler);
7379 throw new TypeError((input !== null && typeof input || input) + ' is not observable');
7381 exports.from = from;
7383 },{"../Observable":31,"../util/isArrayLike":203,"../util/isInteropObservable":206,"../util/isIterable":207,"../util/isPromise":211,"../util/subscribeTo":216,"./fromArray":51,"./fromIterable":54,"./fromObservable":55,"./fromPromise":56}],51:[function(require,module,exports){
7385 Object.defineProperty(exports, "__esModule", { value: true });
7386 var Observable_1 = require("../Observable");
7387 var Subscription_1 = require("../Subscription");
7388 var subscribeToArray_1 = require("../util/subscribeToArray");
7389 function fromArray(input, scheduler) {
7391 return new Observable_1.Observable(subscribeToArray_1.subscribeToArray(input));
7394 return new Observable_1.Observable(function (subscriber) {
7395 var sub = new Subscription_1.Subscription();
7397 sub.add(scheduler.schedule(function () {
7398 if (i === input.length) {
7399 subscriber.complete();
7402 subscriber.next(input[i++]);
7403 if (!subscriber.closed) {
7404 sub.add(this.schedule());
7411 exports.fromArray = fromArray;
7413 },{"../Observable":31,"../Subscription":39,"../util/subscribeToArray":217}],52:[function(require,module,exports){
7415 Object.defineProperty(exports, "__esModule", { value: true });
7416 var Observable_1 = require("../Observable");
7417 var isArray_1 = require("../util/isArray");
7418 var isFunction_1 = require("../util/isFunction");
7419 var map_1 = require("../operators/map");
7420 var toString = Object.prototype.toString;
7421 function fromEvent(target, eventName, options, resultSelector) {
7422 if (isFunction_1.isFunction(options)) {
7423 resultSelector = options;
7424 options = undefined;
7426 if (resultSelector) {
7427 return fromEvent(target, eventName, options).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
7429 return new Observable_1.Observable(function (subscriber) {
7430 function handler(e) {
7431 if (arguments.length > 1) {
7432 subscriber.next(Array.prototype.slice.call(arguments));
7438 setupSubscription(target, eventName, handler, subscriber, options);
7441 exports.fromEvent = fromEvent;
7442 function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
7444 if (isEventTarget(sourceObj)) {
7445 var source_1 = sourceObj;
7446 sourceObj.addEventListener(eventName, handler, options);
7447 unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
7449 else if (isJQueryStyleEventEmitter(sourceObj)) {
7450 var source_2 = sourceObj;
7451 sourceObj.on(eventName, handler);
7452 unsubscribe = function () { return source_2.off(eventName, handler); };
7454 else if (isNodeStyleEventEmitter(sourceObj)) {
7455 var source_3 = sourceObj;
7456 sourceObj.addListener(eventName, handler);
7457 unsubscribe = function () { return source_3.removeListener(eventName, handler); };
7459 else if (sourceObj && sourceObj.length) {
7460 for (var i = 0, len = sourceObj.length; i < len; i++) {
7461 setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
7465 throw new TypeError('Invalid event target');
7467 subscriber.add(unsubscribe);
7469 function isNodeStyleEventEmitter(sourceObj) {
7470 return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
7472 function isJQueryStyleEventEmitter(sourceObj) {
7473 return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
7475 function isEventTarget(sourceObj) {
7476 return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
7479 },{"../Observable":31,"../operators/map":111,"../util/isArray":202,"../util/isFunction":205}],53:[function(require,module,exports){
7481 Object.defineProperty(exports, "__esModule", { value: true });
7482 var Observable_1 = require("../Observable");
7483 var isArray_1 = require("../util/isArray");
7484 var isFunction_1 = require("../util/isFunction");
7485 var map_1 = require("../operators/map");
7486 function fromEventPattern(addHandler, removeHandler, resultSelector) {
7487 if (resultSelector) {
7488 return fromEventPattern(addHandler, removeHandler).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
7490 return new Observable_1.Observable(function (subscriber) {
7491 var handler = function () {
7493 for (var _i = 0; _i < arguments.length; _i++) {
7494 e[_i] = arguments[_i];
7496 return subscriber.next(e.length === 1 ? e[0] : e);
7500 retValue = addHandler(handler);
7503 subscriber.error(err);
7506 if (!isFunction_1.isFunction(removeHandler)) {
7509 return function () { return removeHandler(handler, retValue); };
7512 exports.fromEventPattern = fromEventPattern;
7514 },{"../Observable":31,"../operators/map":111,"../util/isArray":202,"../util/isFunction":205}],54:[function(require,module,exports){
7516 Object.defineProperty(exports, "__esModule", { value: true });
7517 var Observable_1 = require("../Observable");
7518 var Subscription_1 = require("../Subscription");
7519 var iterator_1 = require("../symbol/iterator");
7520 var subscribeToIterable_1 = require("../util/subscribeToIterable");
7521 function fromIterable(input, scheduler) {
7523 throw new Error('Iterable cannot be null');
7526 return new Observable_1.Observable(subscribeToIterable_1.subscribeToIterable(input));
7529 return new Observable_1.Observable(function (subscriber) {
7530 var sub = new Subscription_1.Subscription();
7532 sub.add(function () {
7533 if (iterator && typeof iterator.return === 'function') {
7537 sub.add(scheduler.schedule(function () {
7538 iterator = input[iterator_1.iterator]();
7539 sub.add(scheduler.schedule(function () {
7540 if (subscriber.closed) {
7546 var result = iterator.next();
7547 value = result.value;
7551 subscriber.error(err);
7555 subscriber.complete();
7558 subscriber.next(value);
7567 exports.fromIterable = fromIterable;
7569 },{"../Observable":31,"../Subscription":39,"../symbol/iterator":189,"../util/subscribeToIterable":218}],55:[function(require,module,exports){
7571 Object.defineProperty(exports, "__esModule", { value: true });
7572 var Observable_1 = require("../Observable");
7573 var Subscription_1 = require("../Subscription");
7574 var observable_1 = require("../symbol/observable");
7575 var subscribeToObservable_1 = require("../util/subscribeToObservable");
7576 function fromObservable(input, scheduler) {
7578 return new Observable_1.Observable(subscribeToObservable_1.subscribeToObservable(input));
7581 return new Observable_1.Observable(function (subscriber) {
7582 var sub = new Subscription_1.Subscription();
7583 sub.add(scheduler.schedule(function () {
7584 var observable = input[observable_1.observable]();
7585 sub.add(observable.subscribe({
7586 next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
7587 error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
7588 complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
7595 exports.fromObservable = fromObservable;
7597 },{"../Observable":31,"../Subscription":39,"../symbol/observable":190,"../util/subscribeToObservable":219}],56:[function(require,module,exports){
7599 Object.defineProperty(exports, "__esModule", { value: true });
7600 var Observable_1 = require("../Observable");
7601 var Subscription_1 = require("../Subscription");
7602 var subscribeToPromise_1 = require("../util/subscribeToPromise");
7603 function fromPromise(input, scheduler) {
7605 return new Observable_1.Observable(subscribeToPromise_1.subscribeToPromise(input));
7608 return new Observable_1.Observable(function (subscriber) {
7609 var sub = new Subscription_1.Subscription();
7610 sub.add(scheduler.schedule(function () { return input.then(function (value) {
7611 sub.add(scheduler.schedule(function () {
7612 subscriber.next(value);
7613 sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
7616 sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
7622 exports.fromPromise = fromPromise;
7624 },{"../Observable":31,"../Subscription":39,"../util/subscribeToPromise":220}],57:[function(require,module,exports){
7626 Object.defineProperty(exports, "__esModule", { value: true });
7627 var Observable_1 = require("../Observable");
7628 var identity_1 = require("../util/identity");
7629 var isScheduler_1 = require("../util/isScheduler");
7630 function generate(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
7633 if (arguments.length == 1) {
7634 var options = initialStateOrOptions;
7635 initialState = options.initialState;
7636 condition = options.condition;
7637 iterate = options.iterate;
7638 resultSelector = options.resultSelector || identity_1.identity;
7639 scheduler = options.scheduler;
7641 else if (resultSelectorOrObservable === undefined || isScheduler_1.isScheduler(resultSelectorOrObservable)) {
7642 initialState = initialStateOrOptions;
7643 resultSelector = identity_1.identity;
7644 scheduler = resultSelectorOrObservable;
7647 initialState = initialStateOrOptions;
7648 resultSelector = resultSelectorOrObservable;
7650 return new Observable_1.Observable(function (subscriber) {
7651 var state = initialState;
7653 return scheduler.schedule(dispatch, 0, {
7654 subscriber: subscriber,
7656 condition: condition,
7657 resultSelector: resultSelector,
7663 var conditionResult = void 0;
7665 conditionResult = condition(state);
7668 subscriber.error(err);
7671 if (!conditionResult) {
7672 subscriber.complete();
7678 value = resultSelector(state);
7681 subscriber.error(err);
7684 subscriber.next(value);
7685 if (subscriber.closed) {
7689 state = iterate(state);
7692 subscriber.error(err);
7699 exports.generate = generate;
7700 function dispatch(state) {
7701 var subscriber = state.subscriber, condition = state.condition;
7702 if (subscriber.closed) {
7705 if (state.needIterate) {
7707 state.state = state.iterate(state.state);
7710 subscriber.error(err);
7715 state.needIterate = true;
7718 var conditionResult = void 0;
7720 conditionResult = condition(state.state);
7723 subscriber.error(err);
7726 if (!conditionResult) {
7727 subscriber.complete();
7730 if (subscriber.closed) {
7736 value = state.resultSelector(state.state);
7739 subscriber.error(err);
7742 if (subscriber.closed) {
7745 subscriber.next(value);
7746 if (subscriber.closed) {
7749 return this.schedule(state);
7752 },{"../Observable":31,"../util/identity":201,"../util/isScheduler":212}],58:[function(require,module,exports){
7754 Object.defineProperty(exports, "__esModule", { value: true });
7755 var defer_1 = require("./defer");
7756 var empty_1 = require("./empty");
7757 function iif(condition, trueResult, falseResult) {
7758 if (trueResult === void 0) { trueResult = empty_1.EMPTY; }
7759 if (falseResult === void 0) { falseResult = empty_1.EMPTY; }
7760 return defer_1.defer(function () { return condition() ? trueResult : falseResult; });
7764 },{"./defer":47,"./empty":48}],59:[function(require,module,exports){
7766 Object.defineProperty(exports, "__esModule", { value: true });
7767 var Observable_1 = require("../Observable");
7768 var async_1 = require("../scheduler/async");
7769 var isNumeric_1 = require("../util/isNumeric");
7770 function interval(period, scheduler) {
7771 if (period === void 0) { period = 0; }
7772 if (scheduler === void 0) { scheduler = async_1.async; }
7773 if (!isNumeric_1.isNumeric(period) || period < 0) {
7776 if (!scheduler || typeof scheduler.schedule !== 'function') {
7777 scheduler = async_1.async;
7779 return new Observable_1.Observable(function (subscriber) {
7780 subscriber.add(scheduler.schedule(dispatch, period, { subscriber: subscriber, counter: 0, period: period }));
7784 exports.interval = interval;
7785 function dispatch(state) {
7786 var subscriber = state.subscriber, counter = state.counter, period = state.period;
7787 subscriber.next(counter);
7788 this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
7791 },{"../Observable":31,"../scheduler/async":187,"../util/isNumeric":208}],60:[function(require,module,exports){
7793 Object.defineProperty(exports, "__esModule", { value: true });
7794 var Observable_1 = require("../Observable");
7795 var isScheduler_1 = require("../util/isScheduler");
7796 var mergeAll_1 = require("../operators/mergeAll");
7797 var fromArray_1 = require("./fromArray");
7799 var observables = [];
7800 for (var _i = 0; _i < arguments.length; _i++) {
7801 observables[_i] = arguments[_i];
7803 var concurrent = Number.POSITIVE_INFINITY;
7804 var scheduler = null;
7805 var last = observables[observables.length - 1];
7806 if (isScheduler_1.isScheduler(last)) {
7807 scheduler = observables.pop();
7808 if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
7809 concurrent = observables.pop();
7812 else if (typeof last === 'number') {
7813 concurrent = observables.pop();
7815 if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) {
7816 return observables[0];
7818 return mergeAll_1.mergeAll(concurrent)(fromArray_1.fromArray(observables, scheduler));
7820 exports.merge = merge;
7822 },{"../Observable":31,"../operators/mergeAll":116,"../util/isScheduler":212,"./fromArray":51}],61:[function(require,module,exports){
7824 Object.defineProperty(exports, "__esModule", { value: true });
7825 var Observable_1 = require("../Observable");
7826 var noop_1 = require("../util/noop");
7827 exports.NEVER = new Observable_1.Observable(noop_1.noop);
7829 return exports.NEVER;
7831 exports.never = never;
7833 },{"../Observable":31,"../util/noop":213}],62:[function(require,module,exports){
7835 Object.defineProperty(exports, "__esModule", { value: true });
7836 var isScheduler_1 = require("../util/isScheduler");
7837 var fromArray_1 = require("./fromArray");
7838 var empty_1 = require("./empty");
7839 var scalar_1 = require("./scalar");
7842 for (var _i = 0; _i < arguments.length; _i++) {
7843 args[_i] = arguments[_i];
7845 var scheduler = args[args.length - 1];
7846 if (isScheduler_1.isScheduler(scheduler)) {
7850 scheduler = undefined;
7852 switch (args.length) {
7854 return empty_1.empty(scheduler);
7856 return scheduler ? fromArray_1.fromArray(args, scheduler) : scalar_1.scalar(args[0]);
7858 return fromArray_1.fromArray(args, scheduler);
7863 },{"../util/isScheduler":212,"./empty":48,"./fromArray":51,"./scalar":67}],63:[function(require,module,exports){
7865 Object.defineProperty(exports, "__esModule", { value: true });
7866 var Observable_1 = require("../Observable");
7867 var from_1 = require("./from");
7868 var isArray_1 = require("../util/isArray");
7869 var empty_1 = require("./empty");
7870 function onErrorResumeNext() {
7872 for (var _i = 0; _i < arguments.length; _i++) {
7873 sources[_i] = arguments[_i];
7875 if (sources.length === 0) {
7876 return empty_1.EMPTY;
7878 var first = sources[0], remainder = sources.slice(1);
7879 if (sources.length === 1 && isArray_1.isArray(first)) {
7880 return onErrorResumeNext.apply(void 0, first);
7882 return new Observable_1.Observable(function (subscriber) {
7883 var subNext = function () { return subscriber.add(onErrorResumeNext.apply(void 0, remainder).subscribe(subscriber)); };
7884 return from_1.from(first).subscribe({
7885 next: function (value) { subscriber.next(value); },
7891 exports.onErrorResumeNext = onErrorResumeNext;
7893 },{"../Observable":31,"../util/isArray":202,"./empty":48,"./from":50}],64:[function(require,module,exports){
7895 Object.defineProperty(exports, "__esModule", { value: true });
7896 var Observable_1 = require("../Observable");
7897 var Subscription_1 = require("../Subscription");
7898 function pairs(obj, scheduler) {
7900 return new Observable_1.Observable(function (subscriber) {
7901 var keys = Object.keys(obj);
7902 for (var i = 0; i < keys.length && !subscriber.closed; i++) {
7904 if (obj.hasOwnProperty(key)) {
7905 subscriber.next([key, obj[key]]);
7908 subscriber.complete();
7912 return new Observable_1.Observable(function (subscriber) {
7913 var keys = Object.keys(obj);
7914 var subscription = new Subscription_1.Subscription();
7915 subscription.add(scheduler.schedule(dispatch, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
7916 return subscription;
7920 exports.pairs = pairs;
7921 function dispatch(state) {
7922 var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
7923 if (!subscriber.closed) {
7924 if (index < keys.length) {
7925 var key = keys[index];
7926 subscriber.next([key, obj[key]]);
7927 subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
7930 subscriber.complete();
7934 exports.dispatch = dispatch;
7936 },{"../Observable":31,"../Subscription":39}],65:[function(require,module,exports){
7938 var __extends = (this && this.__extends) || (function () {
7939 var extendStatics = function (d, b) {
7940 extendStatics = Object.setPrototypeOf ||
7941 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7942 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7943 return extendStatics(d, b);
7945 return function (d, b) {
7946 extendStatics(d, b);
7947 function __() { this.constructor = d; }
7948 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7951 Object.defineProperty(exports, "__esModule", { value: true });
7952 var isArray_1 = require("../util/isArray");
7953 var fromArray_1 = require("./fromArray");
7954 var OuterSubscriber_1 = require("../OuterSubscriber");
7955 var subscribeToResult_1 = require("../util/subscribeToResult");
7957 var observables = [];
7958 for (var _i = 0; _i < arguments.length; _i++) {
7959 observables[_i] = arguments[_i];
7961 if (observables.length === 1) {
7962 if (isArray_1.isArray(observables[0])) {
7963 observables = observables[0];
7966 return observables[0];
7969 return fromArray_1.fromArray(observables, undefined).lift(new RaceOperator());
7971 exports.race = race;
7972 var RaceOperator = (function () {
7973 function RaceOperator() {
7975 RaceOperator.prototype.call = function (subscriber, source) {
7976 return source.subscribe(new RaceSubscriber(subscriber));
7978 return RaceOperator;
7980 exports.RaceOperator = RaceOperator;
7981 var RaceSubscriber = (function (_super) {
7982 __extends(RaceSubscriber, _super);
7983 function RaceSubscriber(destination) {
7984 var _this = _super.call(this, destination) || this;
7985 _this.hasFirst = false;
7986 _this.observables = [];
7987 _this.subscriptions = [];
7990 RaceSubscriber.prototype._next = function (observable) {
7991 this.observables.push(observable);
7993 RaceSubscriber.prototype._complete = function () {
7994 var observables = this.observables;
7995 var len = observables.length;
7997 this.destination.complete();
8000 for (var i = 0; i < len && !this.hasFirst; i++) {
8001 var observable = observables[i];
8002 var subscription = subscribeToResult_1.subscribeToResult(this, observable, observable, i);
8003 if (this.subscriptions) {
8004 this.subscriptions.push(subscription);
8006 this.add(subscription);
8008 this.observables = null;
8011 RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
8012 if (!this.hasFirst) {
8013 this.hasFirst = true;
8014 for (var i = 0; i < this.subscriptions.length; i++) {
8015 if (i !== outerIndex) {
8016 var subscription = this.subscriptions[i];
8017 subscription.unsubscribe();
8018 this.remove(subscription);
8021 this.subscriptions = null;
8023 this.destination.next(innerValue);
8025 return RaceSubscriber;
8026 }(OuterSubscriber_1.OuterSubscriber));
8027 exports.RaceSubscriber = RaceSubscriber;
8029 },{"../OuterSubscriber":33,"../util/isArray":202,"../util/subscribeToResult":221,"./fromArray":51}],66:[function(require,module,exports){
8031 Object.defineProperty(exports, "__esModule", { value: true });
8032 var Observable_1 = require("../Observable");
8033 function range(start, count, scheduler) {
8034 if (start === void 0) { start = 0; }
8035 if (count === void 0) { count = 0; }
8036 return new Observable_1.Observable(function (subscriber) {
8038 var current = start;
8040 return scheduler.schedule(dispatch, 0, {
8041 index: index, count: count, start: start, subscriber: subscriber
8046 if (index++ >= count) {
8047 subscriber.complete();
8050 subscriber.next(current++);
8051 if (subscriber.closed) {
8059 exports.range = range;
8060 function dispatch(state) {
8061 var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
8062 if (index >= count) {
8063 subscriber.complete();
8066 subscriber.next(start);
8067 if (subscriber.closed) {
8070 state.index = index + 1;
8071 state.start = start + 1;
8072 this.schedule(state);
8074 exports.dispatch = dispatch;
8076 },{"../Observable":31}],67:[function(require,module,exports){
8078 Object.defineProperty(exports, "__esModule", { value: true });
8079 var Observable_1 = require("../Observable");
8080 function scalar(value) {
8081 var result = new Observable_1.Observable(function (subscriber) {
8082 subscriber.next(value);
8083 subscriber.complete();
8085 result._isScalar = true;
8086 result.value = value;
8089 exports.scalar = scalar;
8091 },{"../Observable":31}],68:[function(require,module,exports){
8093 Object.defineProperty(exports, "__esModule", { value: true });
8094 var Observable_1 = require("../Observable");
8095 function throwError(error, scheduler) {
8097 return new Observable_1.Observable(function (subscriber) { return subscriber.error(error); });
8100 return new Observable_1.Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });
8103 exports.throwError = throwError;
8104 function dispatch(_a) {
8105 var error = _a.error, subscriber = _a.subscriber;
8106 subscriber.error(error);
8109 },{"../Observable":31}],69:[function(require,module,exports){
8111 Object.defineProperty(exports, "__esModule", { value: true });
8112 var Observable_1 = require("../Observable");
8113 var async_1 = require("../scheduler/async");
8114 var isNumeric_1 = require("../util/isNumeric");
8115 var isScheduler_1 = require("../util/isScheduler");
8116 function timer(dueTime, periodOrScheduler, scheduler) {
8117 if (dueTime === void 0) { dueTime = 0; }
8119 if (isNumeric_1.isNumeric(periodOrScheduler)) {
8120 period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
8122 else if (isScheduler_1.isScheduler(periodOrScheduler)) {
8123 scheduler = periodOrScheduler;
8125 if (!isScheduler_1.isScheduler(scheduler)) {
8126 scheduler = async_1.async;
8128 return new Observable_1.Observable(function (subscriber) {
8129 var due = isNumeric_1.isNumeric(dueTime)
8131 : (+dueTime - scheduler.now());
8132 return scheduler.schedule(dispatch, due, {
8133 index: 0, period: period, subscriber: subscriber
8137 exports.timer = timer;
8138 function dispatch(state) {
8139 var index = state.index, period = state.period, subscriber = state.subscriber;
8140 subscriber.next(index);
8141 if (subscriber.closed) {
8144 else if (period === -1) {
8145 return subscriber.complete();
8147 state.index = index + 1;
8148 this.schedule(state, period);
8151 },{"../Observable":31,"../scheduler/async":187,"../util/isNumeric":208,"../util/isScheduler":212}],70:[function(require,module,exports){
8153 Object.defineProperty(exports, "__esModule", { value: true });
8154 var Observable_1 = require("../Observable");
8155 var from_1 = require("./from");
8156 var empty_1 = require("./empty");
8157 function using(resourceFactory, observableFactory) {
8158 return new Observable_1.Observable(function (subscriber) {
8161 resource = resourceFactory();
8164 subscriber.error(err);
8169 result = observableFactory(resource);
8172 subscriber.error(err);
8175 var source = result ? from_1.from(result) : empty_1.EMPTY;
8176 var subscription = source.subscribe(subscriber);
8177 return function () {
8178 subscription.unsubscribe();
8180 resource.unsubscribe();
8185 exports.using = using;
8187 },{"../Observable":31,"./empty":48,"./from":50}],71:[function(require,module,exports){
8189 var __extends = (this && this.__extends) || (function () {
8190 var extendStatics = function (d, b) {
8191 extendStatics = Object.setPrototypeOf ||
8192 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8193 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8194 return extendStatics(d, b);
8196 return function (d, b) {
8197 extendStatics(d, b);
8198 function __() { this.constructor = d; }
8199 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8202 Object.defineProperty(exports, "__esModule", { value: true });
8203 var fromArray_1 = require("./fromArray");
8204 var isArray_1 = require("../util/isArray");
8205 var Subscriber_1 = require("../Subscriber");
8206 var OuterSubscriber_1 = require("../OuterSubscriber");
8207 var subscribeToResult_1 = require("../util/subscribeToResult");
8208 var iterator_1 = require("../../internal/symbol/iterator");
8210 var observables = [];
8211 for (var _i = 0; _i < arguments.length; _i++) {
8212 observables[_i] = arguments[_i];
8214 var resultSelector = observables[observables.length - 1];
8215 if (typeof resultSelector === 'function') {
8218 return fromArray_1.fromArray(observables, undefined).lift(new ZipOperator(resultSelector));
8221 var ZipOperator = (function () {
8222 function ZipOperator(resultSelector) {
8223 this.resultSelector = resultSelector;
8225 ZipOperator.prototype.call = function (subscriber, source) {
8226 return source.subscribe(new ZipSubscriber(subscriber, this.resultSelector));
8230 exports.ZipOperator = ZipOperator;
8231 var ZipSubscriber = (function (_super) {
8232 __extends(ZipSubscriber, _super);
8233 function ZipSubscriber(destination, resultSelector, values) {
8234 if (values === void 0) { values = Object.create(null); }
8235 var _this = _super.call(this, destination) || this;
8236 _this.iterators = [];
8238 _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : null;
8239 _this.values = values;
8242 ZipSubscriber.prototype._next = function (value) {
8243 var iterators = this.iterators;
8244 if (isArray_1.isArray(value)) {
8245 iterators.push(new StaticArrayIterator(value));
8247 else if (typeof value[iterator_1.iterator] === 'function') {
8248 iterators.push(new StaticIterator(value[iterator_1.iterator]()));
8251 iterators.push(new ZipBufferIterator(this.destination, this, value));
8254 ZipSubscriber.prototype._complete = function () {
8255 var iterators = this.iterators;
8256 var len = iterators.length;
8259 this.destination.complete();
8263 for (var i = 0; i < len; i++) {
8264 var iterator = iterators[i];
8265 if (iterator.stillUnsubscribed) {
8266 var destination = this.destination;
8267 destination.add(iterator.subscribe(iterator, i));
8274 ZipSubscriber.prototype.notifyInactive = function () {
8276 if (this.active === 0) {
8277 this.destination.complete();
8280 ZipSubscriber.prototype.checkIterators = function () {
8281 var iterators = this.iterators;
8282 var len = iterators.length;
8283 var destination = this.destination;
8284 for (var i = 0; i < len; i++) {
8285 var iterator = iterators[i];
8286 if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) {
8290 var shouldComplete = false;
8292 for (var i = 0; i < len; i++) {
8293 var iterator = iterators[i];
8294 var result = iterator.next();
8295 if (iterator.hasCompleted()) {
8296 shouldComplete = true;
8299 destination.complete();
8302 args.push(result.value);
8304 if (this.resultSelector) {
8305 this._tryresultSelector(args);
8308 destination.next(args);
8310 if (shouldComplete) {
8311 destination.complete();
8314 ZipSubscriber.prototype._tryresultSelector = function (args) {
8317 result = this.resultSelector.apply(this, args);
8320 this.destination.error(err);
8323 this.destination.next(result);
8325 return ZipSubscriber;
8326 }(Subscriber_1.Subscriber));
8327 exports.ZipSubscriber = ZipSubscriber;
8328 var StaticIterator = (function () {
8329 function StaticIterator(iterator) {
8330 this.iterator = iterator;
8331 this.nextResult = iterator.next();
8333 StaticIterator.prototype.hasValue = function () {
8336 StaticIterator.prototype.next = function () {
8337 var result = this.nextResult;
8338 this.nextResult = this.iterator.next();
8341 StaticIterator.prototype.hasCompleted = function () {
8342 var nextResult = this.nextResult;
8343 return nextResult && nextResult.done;
8345 return StaticIterator;
8347 var StaticArrayIterator = (function () {
8348 function StaticArrayIterator(array) {
8352 this.length = array.length;
8354 StaticArrayIterator.prototype[iterator_1.iterator] = function () {
8357 StaticArrayIterator.prototype.next = function (value) {
8358 var i = this.index++;
8359 var array = this.array;
8360 return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
8362 StaticArrayIterator.prototype.hasValue = function () {
8363 return this.array.length > this.index;
8365 StaticArrayIterator.prototype.hasCompleted = function () {
8366 return this.array.length === this.index;
8368 return StaticArrayIterator;
8370 var ZipBufferIterator = (function (_super) {
8371 __extends(ZipBufferIterator, _super);
8372 function ZipBufferIterator(destination, parent, observable) {
8373 var _this = _super.call(this, destination) || this;
8374 _this.parent = parent;
8375 _this.observable = observable;
8376 _this.stillUnsubscribed = true;
8378 _this.isComplete = false;
8381 ZipBufferIterator.prototype[iterator_1.iterator] = function () {
8384 ZipBufferIterator.prototype.next = function () {
8385 var buffer = this.buffer;
8386 if (buffer.length === 0 && this.isComplete) {
8387 return { value: null, done: true };
8390 return { value: buffer.shift(), done: false };
8393 ZipBufferIterator.prototype.hasValue = function () {
8394 return this.buffer.length > 0;
8396 ZipBufferIterator.prototype.hasCompleted = function () {
8397 return this.buffer.length === 0 && this.isComplete;
8399 ZipBufferIterator.prototype.notifyComplete = function () {
8400 if (this.buffer.length > 0) {
8401 this.isComplete = true;
8402 this.parent.notifyInactive();
8405 this.destination.complete();
8408 ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
8409 this.buffer.push(innerValue);
8410 this.parent.checkIterators();
8412 ZipBufferIterator.prototype.subscribe = function (value, index) {
8413 return subscribeToResult_1.subscribeToResult(this, this.observable, this, index);
8415 return ZipBufferIterator;
8416 }(OuterSubscriber_1.OuterSubscriber));
8418 },{"../../internal/symbol/iterator":189,"../OuterSubscriber":33,"../Subscriber":38,"../util/isArray":202,"../util/subscribeToResult":221,"./fromArray":51}],72:[function(require,module,exports){
8420 var __extends = (this && this.__extends) || (function () {
8421 var extendStatics = function (d, b) {
8422 extendStatics = Object.setPrototypeOf ||
8423 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8424 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8425 return extendStatics(d, b);
8427 return function (d, b) {
8428 extendStatics(d, b);
8429 function __() { this.constructor = d; }
8430 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8433 Object.defineProperty(exports, "__esModule", { value: true });
8434 var tryCatch_1 = require("../util/tryCatch");
8435 var errorObject_1 = require("../util/errorObject");
8436 var OuterSubscriber_1 = require("../OuterSubscriber");
8437 var subscribeToResult_1 = require("../util/subscribeToResult");
8438 function audit(durationSelector) {
8439 return function auditOperatorFunction(source) {
8440 return source.lift(new AuditOperator(durationSelector));
8443 exports.audit = audit;
8444 var AuditOperator = (function () {
8445 function AuditOperator(durationSelector) {
8446 this.durationSelector = durationSelector;
8448 AuditOperator.prototype.call = function (subscriber, source) {
8449 return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
8451 return AuditOperator;
8453 var AuditSubscriber = (function (_super) {
8454 __extends(AuditSubscriber, _super);
8455 function AuditSubscriber(destination, durationSelector) {
8456 var _this = _super.call(this, destination) || this;
8457 _this.durationSelector = durationSelector;
8458 _this.hasValue = false;
8461 AuditSubscriber.prototype._next = function (value) {
8463 this.hasValue = true;
8464 if (!this.throttled) {
8465 var duration = tryCatch_1.tryCatch(this.durationSelector)(value);
8466 if (duration === errorObject_1.errorObject) {
8467 this.destination.error(errorObject_1.errorObject.e);
8470 var innerSubscription = subscribeToResult_1.subscribeToResult(this, duration);
8471 if (!innerSubscription || innerSubscription.closed) {
8472 this.clearThrottle();
8475 this.add(this.throttled = innerSubscription);
8480 AuditSubscriber.prototype.clearThrottle = function () {
8481 var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
8483 this.remove(throttled);
8484 this.throttled = null;
8485 throttled.unsubscribe();
8489 this.hasValue = false;
8490 this.destination.next(value);
8493 AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
8494 this.clearThrottle();
8496 AuditSubscriber.prototype.notifyComplete = function () {
8497 this.clearThrottle();
8499 return AuditSubscriber;
8500 }(OuterSubscriber_1.OuterSubscriber));
8502 },{"../OuterSubscriber":33,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],73:[function(require,module,exports){
8504 Object.defineProperty(exports, "__esModule", { value: true });
8505 var async_1 = require("../scheduler/async");
8506 var audit_1 = require("./audit");
8507 var timer_1 = require("../observable/timer");
8508 function auditTime(duration, scheduler) {
8509 if (scheduler === void 0) { scheduler = async_1.async; }
8510 return audit_1.audit(function () { return timer_1.timer(duration, scheduler); });
8512 exports.auditTime = auditTime;
8514 },{"../observable/timer":69,"../scheduler/async":187,"./audit":72}],74:[function(require,module,exports){
8516 var __extends = (this && this.__extends) || (function () {
8517 var extendStatics = function (d, b) {
8518 extendStatics = Object.setPrototypeOf ||
8519 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8520 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8521 return extendStatics(d, b);
8523 return function (d, b) {
8524 extendStatics(d, b);
8525 function __() { this.constructor = d; }
8526 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8529 Object.defineProperty(exports, "__esModule", { value: true });
8530 var OuterSubscriber_1 = require("../OuterSubscriber");
8531 var subscribeToResult_1 = require("../util/subscribeToResult");
8532 function buffer(closingNotifier) {
8533 return function bufferOperatorFunction(source) {
8534 return source.lift(new BufferOperator(closingNotifier));
8537 exports.buffer = buffer;
8538 var BufferOperator = (function () {
8539 function BufferOperator(closingNotifier) {
8540 this.closingNotifier = closingNotifier;
8542 BufferOperator.prototype.call = function (subscriber, source) {
8543 return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
8545 return BufferOperator;
8547 var BufferSubscriber = (function (_super) {
8548 __extends(BufferSubscriber, _super);
8549 function BufferSubscriber(destination, closingNotifier) {
8550 var _this = _super.call(this, destination) || this;
8552 _this.add(subscribeToResult_1.subscribeToResult(_this, closingNotifier));
8555 BufferSubscriber.prototype._next = function (value) {
8556 this.buffer.push(value);
8558 BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
8559 var buffer = this.buffer;
8561 this.destination.next(buffer);
8563 return BufferSubscriber;
8564 }(OuterSubscriber_1.OuterSubscriber));
8566 },{"../OuterSubscriber":33,"../util/subscribeToResult":221}],75:[function(require,module,exports){
8568 var __extends = (this && this.__extends) || (function () {
8569 var extendStatics = function (d, b) {
8570 extendStatics = Object.setPrototypeOf ||
8571 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8572 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8573 return extendStatics(d, b);
8575 return function (d, b) {
8576 extendStatics(d, b);
8577 function __() { this.constructor = d; }
8578 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8581 Object.defineProperty(exports, "__esModule", { value: true });
8582 var Subscriber_1 = require("../Subscriber");
8583 function bufferCount(bufferSize, startBufferEvery) {
8584 if (startBufferEvery === void 0) { startBufferEvery = null; }
8585 return function bufferCountOperatorFunction(source) {
8586 return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
8589 exports.bufferCount = bufferCount;
8590 var BufferCountOperator = (function () {
8591 function BufferCountOperator(bufferSize, startBufferEvery) {
8592 this.bufferSize = bufferSize;
8593 this.startBufferEvery = startBufferEvery;
8594 if (!startBufferEvery || bufferSize === startBufferEvery) {
8595 this.subscriberClass = BufferCountSubscriber;
8598 this.subscriberClass = BufferSkipCountSubscriber;
8601 BufferCountOperator.prototype.call = function (subscriber, source) {
8602 return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
8604 return BufferCountOperator;
8606 var BufferCountSubscriber = (function (_super) {
8607 __extends(BufferCountSubscriber, _super);
8608 function BufferCountSubscriber(destination, bufferSize) {
8609 var _this = _super.call(this, destination) || this;
8610 _this.bufferSize = bufferSize;
8614 BufferCountSubscriber.prototype._next = function (value) {
8615 var buffer = this.buffer;
8617 if (buffer.length == this.bufferSize) {
8618 this.destination.next(buffer);
8622 BufferCountSubscriber.prototype._complete = function () {
8623 var buffer = this.buffer;
8624 if (buffer.length > 0) {
8625 this.destination.next(buffer);
8627 _super.prototype._complete.call(this);
8629 return BufferCountSubscriber;
8630 }(Subscriber_1.Subscriber));
8631 var BufferSkipCountSubscriber = (function (_super) {
8632 __extends(BufferSkipCountSubscriber, _super);
8633 function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
8634 var _this = _super.call(this, destination) || this;
8635 _this.bufferSize = bufferSize;
8636 _this.startBufferEvery = startBufferEvery;
8641 BufferSkipCountSubscriber.prototype._next = function (value) {
8642 var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
8644 if (count % startBufferEvery === 0) {
8647 for (var i = buffers.length; i--;) {
8648 var buffer = buffers[i];
8650 if (buffer.length === bufferSize) {
8651 buffers.splice(i, 1);
8652 this.destination.next(buffer);
8656 BufferSkipCountSubscriber.prototype._complete = function () {
8657 var _a = this, buffers = _a.buffers, destination = _a.destination;
8658 while (buffers.length > 0) {
8659 var buffer = buffers.shift();
8660 if (buffer.length > 0) {
8661 destination.next(buffer);
8664 _super.prototype._complete.call(this);
8666 return BufferSkipCountSubscriber;
8667 }(Subscriber_1.Subscriber));
8669 },{"../Subscriber":38}],76:[function(require,module,exports){
8671 var __extends = (this && this.__extends) || (function () {
8672 var extendStatics = function (d, b) {
8673 extendStatics = Object.setPrototypeOf ||
8674 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8675 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8676 return extendStatics(d, b);
8678 return function (d, b) {
8679 extendStatics(d, b);
8680 function __() { this.constructor = d; }
8681 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8684 Object.defineProperty(exports, "__esModule", { value: true });
8685 var async_1 = require("../scheduler/async");
8686 var Subscriber_1 = require("../Subscriber");
8687 var isScheduler_1 = require("../util/isScheduler");
8688 function bufferTime(bufferTimeSpan) {
8689 var length = arguments.length;
8690 var scheduler = async_1.async;
8691 if (isScheduler_1.isScheduler(arguments[arguments.length - 1])) {
8692 scheduler = arguments[arguments.length - 1];
8695 var bufferCreationInterval = null;
8697 bufferCreationInterval = arguments[1];
8699 var maxBufferSize = Number.POSITIVE_INFINITY;
8701 maxBufferSize = arguments[2];
8703 return function bufferTimeOperatorFunction(source) {
8704 return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
8707 exports.bufferTime = bufferTime;
8708 var BufferTimeOperator = (function () {
8709 function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
8710 this.bufferTimeSpan = bufferTimeSpan;
8711 this.bufferCreationInterval = bufferCreationInterval;
8712 this.maxBufferSize = maxBufferSize;
8713 this.scheduler = scheduler;
8715 BufferTimeOperator.prototype.call = function (subscriber, source) {
8716 return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
8718 return BufferTimeOperator;
8720 var Context = (function () {
8721 function Context() {
8726 var BufferTimeSubscriber = (function (_super) {
8727 __extends(BufferTimeSubscriber, _super);
8728 function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
8729 var _this = _super.call(this, destination) || this;
8730 _this.bufferTimeSpan = bufferTimeSpan;
8731 _this.bufferCreationInterval = bufferCreationInterval;
8732 _this.maxBufferSize = maxBufferSize;
8733 _this.scheduler = scheduler;
8734 _this.contexts = [];
8735 var context = _this.openContext();
8736 _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
8737 if (_this.timespanOnly) {
8738 var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
8739 _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
8742 var closeState = { subscriber: _this, context: context };
8743 var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
8744 _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
8745 _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
8749 BufferTimeSubscriber.prototype._next = function (value) {
8750 var contexts = this.contexts;
8751 var len = contexts.length;
8752 var filledBufferContext;
8753 for (var i = 0; i < len; i++) {
8754 var context_1 = contexts[i];
8755 var buffer = context_1.buffer;
8757 if (buffer.length == this.maxBufferSize) {
8758 filledBufferContext = context_1;
8761 if (filledBufferContext) {
8762 this.onBufferFull(filledBufferContext);
8765 BufferTimeSubscriber.prototype._error = function (err) {
8766 this.contexts.length = 0;
8767 _super.prototype._error.call(this, err);
8769 BufferTimeSubscriber.prototype._complete = function () {
8770 var _a = this, contexts = _a.contexts, destination = _a.destination;
8771 while (contexts.length > 0) {
8772 var context_2 = contexts.shift();
8773 destination.next(context_2.buffer);
8775 _super.prototype._complete.call(this);
8777 BufferTimeSubscriber.prototype._unsubscribe = function () {
8778 this.contexts = null;
8780 BufferTimeSubscriber.prototype.onBufferFull = function (context) {
8781 this.closeContext(context);
8782 var closeAction = context.closeAction;
8783 closeAction.unsubscribe();
8784 this.remove(closeAction);
8785 if (!this.closed && this.timespanOnly) {
8786 context = this.openContext();
8787 var bufferTimeSpan = this.bufferTimeSpan;
8788 var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
8789 this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
8792 BufferTimeSubscriber.prototype.openContext = function () {
8793 var context = new Context();
8794 this.contexts.push(context);
8797 BufferTimeSubscriber.prototype.closeContext = function (context) {
8798 this.destination.next(context.buffer);
8799 var contexts = this.contexts;
8800 var spliceIndex = contexts ? contexts.indexOf(context) : -1;
8801 if (spliceIndex >= 0) {
8802 contexts.splice(contexts.indexOf(context), 1);
8805 return BufferTimeSubscriber;
8806 }(Subscriber_1.Subscriber));
8807 function dispatchBufferTimeSpanOnly(state) {
8808 var subscriber = state.subscriber;
8809 var prevContext = state.context;
8811 subscriber.closeContext(prevContext);
8813 if (!subscriber.closed) {
8814 state.context = subscriber.openContext();
8815 state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
8818 function dispatchBufferCreation(state) {
8819 var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
8820 var context = subscriber.openContext();
8822 if (!subscriber.closed) {
8823 subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
8824 action.schedule(state, bufferCreationInterval);
8827 function dispatchBufferClose(arg) {
8828 var subscriber = arg.subscriber, context = arg.context;
8829 subscriber.closeContext(context);
8832 },{"../Subscriber":38,"../scheduler/async":187,"../util/isScheduler":212}],77:[function(require,module,exports){
8834 var __extends = (this && this.__extends) || (function () {
8835 var extendStatics = function (d, b) {
8836 extendStatics = Object.setPrototypeOf ||
8837 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8838 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8839 return extendStatics(d, b);
8841 return function (d, b) {
8842 extendStatics(d, b);
8843 function __() { this.constructor = d; }
8844 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8847 Object.defineProperty(exports, "__esModule", { value: true });
8848 var Subscription_1 = require("../Subscription");
8849 var subscribeToResult_1 = require("../util/subscribeToResult");
8850 var OuterSubscriber_1 = require("../OuterSubscriber");
8851 function bufferToggle(openings, closingSelector) {
8852 return function bufferToggleOperatorFunction(source) {
8853 return source.lift(new BufferToggleOperator(openings, closingSelector));
8856 exports.bufferToggle = bufferToggle;
8857 var BufferToggleOperator = (function () {
8858 function BufferToggleOperator(openings, closingSelector) {
8859 this.openings = openings;
8860 this.closingSelector = closingSelector;
8862 BufferToggleOperator.prototype.call = function (subscriber, source) {
8863 return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
8865 return BufferToggleOperator;
8867 var BufferToggleSubscriber = (function (_super) {
8868 __extends(BufferToggleSubscriber, _super);
8869 function BufferToggleSubscriber(destination, openings, closingSelector) {
8870 var _this = _super.call(this, destination) || this;
8871 _this.openings = openings;
8872 _this.closingSelector = closingSelector;
8873 _this.contexts = [];
8874 _this.add(subscribeToResult_1.subscribeToResult(_this, openings));
8877 BufferToggleSubscriber.prototype._next = function (value) {
8878 var contexts = this.contexts;
8879 var len = contexts.length;
8880 for (var i = 0; i < len; i++) {
8881 contexts[i].buffer.push(value);
8884 BufferToggleSubscriber.prototype._error = function (err) {
8885 var contexts = this.contexts;
8886 while (contexts.length > 0) {
8887 var context_1 = contexts.shift();
8888 context_1.subscription.unsubscribe();
8889 context_1.buffer = null;
8890 context_1.subscription = null;
8892 this.contexts = null;
8893 _super.prototype._error.call(this, err);
8895 BufferToggleSubscriber.prototype._complete = function () {
8896 var contexts = this.contexts;
8897 while (contexts.length > 0) {
8898 var context_2 = contexts.shift();
8899 this.destination.next(context_2.buffer);
8900 context_2.subscription.unsubscribe();
8901 context_2.buffer = null;
8902 context_2.subscription = null;
8904 this.contexts = null;
8905 _super.prototype._complete.call(this);
8907 BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
8908 outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
8910 BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
8911 this.closeBuffer(innerSub.context);
8913 BufferToggleSubscriber.prototype.openBuffer = function (value) {
8915 var closingSelector = this.closingSelector;
8916 var closingNotifier = closingSelector.call(this, value);
8917 if (closingNotifier) {
8918 this.trySubscribe(closingNotifier);
8925 BufferToggleSubscriber.prototype.closeBuffer = function (context) {
8926 var contexts = this.contexts;
8927 if (contexts && context) {
8928 var buffer = context.buffer, subscription = context.subscription;
8929 this.destination.next(buffer);
8930 contexts.splice(contexts.indexOf(context), 1);
8931 this.remove(subscription);
8932 subscription.unsubscribe();
8935 BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
8936 var contexts = this.contexts;
8938 var subscription = new Subscription_1.Subscription();
8939 var context = { buffer: buffer, subscription: subscription };
8940 contexts.push(context);
8941 var innerSubscription = subscribeToResult_1.subscribeToResult(this, closingNotifier, context);
8942 if (!innerSubscription || innerSubscription.closed) {
8943 this.closeBuffer(context);
8946 innerSubscription.context = context;
8947 this.add(innerSubscription);
8948 subscription.add(innerSubscription);
8951 return BufferToggleSubscriber;
8952 }(OuterSubscriber_1.OuterSubscriber));
8954 },{"../OuterSubscriber":33,"../Subscription":39,"../util/subscribeToResult":221}],78:[function(require,module,exports){
8956 var __extends = (this && this.__extends) || (function () {
8957 var extendStatics = function (d, b) {
8958 extendStatics = Object.setPrototypeOf ||
8959 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8960 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8961 return extendStatics(d, b);
8963 return function (d, b) {
8964 extendStatics(d, b);
8965 function __() { this.constructor = d; }
8966 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8969 Object.defineProperty(exports, "__esModule", { value: true });
8970 var Subscription_1 = require("../Subscription");
8971 var tryCatch_1 = require("../util/tryCatch");
8972 var errorObject_1 = require("../util/errorObject");
8973 var OuterSubscriber_1 = require("../OuterSubscriber");
8974 var subscribeToResult_1 = require("../util/subscribeToResult");
8975 function bufferWhen(closingSelector) {
8976 return function (source) {
8977 return source.lift(new BufferWhenOperator(closingSelector));
8980 exports.bufferWhen = bufferWhen;
8981 var BufferWhenOperator = (function () {
8982 function BufferWhenOperator(closingSelector) {
8983 this.closingSelector = closingSelector;
8985 BufferWhenOperator.prototype.call = function (subscriber, source) {
8986 return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
8988 return BufferWhenOperator;
8990 var BufferWhenSubscriber = (function (_super) {
8991 __extends(BufferWhenSubscriber, _super);
8992 function BufferWhenSubscriber(destination, closingSelector) {
8993 var _this = _super.call(this, destination) || this;
8994 _this.closingSelector = closingSelector;
8995 _this.subscribing = false;
8999 BufferWhenSubscriber.prototype._next = function (value) {
9000 this.buffer.push(value);
9002 BufferWhenSubscriber.prototype._complete = function () {
9003 var buffer = this.buffer;
9005 this.destination.next(buffer);
9007 _super.prototype._complete.call(this);
9009 BufferWhenSubscriber.prototype._unsubscribe = function () {
9011 this.subscribing = false;
9013 BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
9016 BufferWhenSubscriber.prototype.notifyComplete = function () {
9017 if (this.subscribing) {
9024 BufferWhenSubscriber.prototype.openBuffer = function () {
9025 var closingSubscription = this.closingSubscription;
9026 if (closingSubscription) {
9027 this.remove(closingSubscription);
9028 closingSubscription.unsubscribe();
9030 var buffer = this.buffer;
9032 this.destination.next(buffer);
9035 var closingNotifier = tryCatch_1.tryCatch(this.closingSelector)();
9036 if (closingNotifier === errorObject_1.errorObject) {
9037 this.error(errorObject_1.errorObject.e);
9040 closingSubscription = new Subscription_1.Subscription();
9041 this.closingSubscription = closingSubscription;
9042 this.add(closingSubscription);
9043 this.subscribing = true;
9044 closingSubscription.add(subscribeToResult_1.subscribeToResult(this, closingNotifier));
9045 this.subscribing = false;
9048 return BufferWhenSubscriber;
9049 }(OuterSubscriber_1.OuterSubscriber));
9051 },{"../OuterSubscriber":33,"../Subscription":39,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],79:[function(require,module,exports){
9053 var __extends = (this && this.__extends) || (function () {
9054 var extendStatics = function (d, b) {
9055 extendStatics = Object.setPrototypeOf ||
9056 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9057 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9058 return extendStatics(d, b);
9060 return function (d, b) {
9061 extendStatics(d, b);
9062 function __() { this.constructor = d; }
9063 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9066 Object.defineProperty(exports, "__esModule", { value: true });
9067 var OuterSubscriber_1 = require("../OuterSubscriber");
9068 var InnerSubscriber_1 = require("../InnerSubscriber");
9069 var subscribeToResult_1 = require("../util/subscribeToResult");
9070 function catchError(selector) {
9071 return function catchErrorOperatorFunction(source) {
9072 var operator = new CatchOperator(selector);
9073 var caught = source.lift(operator);
9074 return (operator.caught = caught);
9077 exports.catchError = catchError;
9078 var CatchOperator = (function () {
9079 function CatchOperator(selector) {
9080 this.selector = selector;
9082 CatchOperator.prototype.call = function (subscriber, source) {
9083 return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
9085 return CatchOperator;
9087 var CatchSubscriber = (function (_super) {
9088 __extends(CatchSubscriber, _super);
9089 function CatchSubscriber(destination, selector, caught) {
9090 var _this = _super.call(this, destination) || this;
9091 _this.selector = selector;
9092 _this.caught = caught;
9095 CatchSubscriber.prototype.error = function (err) {
9096 if (!this.isStopped) {
9097 var result = void 0;
9099 result = this.selector(err, this.caught);
9102 _super.prototype.error.call(this, err2);
9105 this._unsubscribeAndRecycle();
9106 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
9107 this.add(innerSubscriber);
9108 subscribeToResult_1.subscribeToResult(this, result, undefined, undefined, innerSubscriber);
9111 return CatchSubscriber;
9112 }(OuterSubscriber_1.OuterSubscriber));
9114 },{"../InnerSubscriber":29,"../OuterSubscriber":33,"../util/subscribeToResult":221}],80:[function(require,module,exports){
9116 Object.defineProperty(exports, "__esModule", { value: true });
9117 var combineLatest_1 = require("../observable/combineLatest");
9118 function combineAll(project) {
9119 return function (source) { return source.lift(new combineLatest_1.CombineLatestOperator(project)); };
9121 exports.combineAll = combineAll;
9123 },{"../observable/combineLatest":45}],81:[function(require,module,exports){
9125 Object.defineProperty(exports, "__esModule", { value: true });
9126 var isArray_1 = require("../util/isArray");
9127 var combineLatest_1 = require("../observable/combineLatest");
9128 var from_1 = require("../observable/from");
9130 function combineLatest() {
9131 var observables = [];
9132 for (var _i = 0; _i < arguments.length; _i++) {
9133 observables[_i] = arguments[_i];
9136 if (typeof observables[observables.length - 1] === 'function') {
9137 project = observables.pop();
9139 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
9140 observables = observables[0].slice();
9142 return function (source) { return source.lift.call(from_1.from([source].concat(observables)), new combineLatest_1.CombineLatestOperator(project)); };
9144 exports.combineLatest = combineLatest;
9146 },{"../observable/combineLatest":45,"../observable/from":50,"../util/isArray":202}],82:[function(require,module,exports){
9148 Object.defineProperty(exports, "__esModule", { value: true });
9149 var concat_1 = require("../observable/concat");
9151 var observables = [];
9152 for (var _i = 0; _i < arguments.length; _i++) {
9153 observables[_i] = arguments[_i];
9155 return function (source) { return source.lift.call(concat_1.concat.apply(void 0, [source].concat(observables))); };
9157 exports.concat = concat;
9159 },{"../observable/concat":46}],83:[function(require,module,exports){
9161 Object.defineProperty(exports, "__esModule", { value: true });
9162 var mergeAll_1 = require("./mergeAll");
9163 function concatAll() {
9164 return mergeAll_1.mergeAll(1);
9166 exports.concatAll = concatAll;
9168 },{"./mergeAll":116}],84:[function(require,module,exports){
9170 Object.defineProperty(exports, "__esModule", { value: true });
9171 var mergeMap_1 = require("./mergeMap");
9172 function concatMap(project, resultSelector) {
9173 return mergeMap_1.mergeMap(project, resultSelector, 1);
9175 exports.concatMap = concatMap;
9177 },{"./mergeMap":117}],85:[function(require,module,exports){
9179 Object.defineProperty(exports, "__esModule", { value: true });
9180 var concatMap_1 = require("./concatMap");
9181 function concatMapTo(innerObservable, resultSelector) {
9182 return concatMap_1.concatMap(function () { return innerObservable; }, resultSelector);
9184 exports.concatMapTo = concatMapTo;
9186 },{"./concatMap":84}],86:[function(require,module,exports){
9188 var __extends = (this && this.__extends) || (function () {
9189 var extendStatics = function (d, b) {
9190 extendStatics = Object.setPrototypeOf ||
9191 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9192 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9193 return extendStatics(d, b);
9195 return function (d, b) {
9196 extendStatics(d, b);
9197 function __() { this.constructor = d; }
9198 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9201 Object.defineProperty(exports, "__esModule", { value: true });
9202 var Subscriber_1 = require("../Subscriber");
9203 function count(predicate) {
9204 return function (source) { return source.lift(new CountOperator(predicate, source)); };
9206 exports.count = count;
9207 var CountOperator = (function () {
9208 function CountOperator(predicate, source) {
9209 this.predicate = predicate;
9210 this.source = source;
9212 CountOperator.prototype.call = function (subscriber, source) {
9213 return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
9215 return CountOperator;
9217 var CountSubscriber = (function (_super) {
9218 __extends(CountSubscriber, _super);
9219 function CountSubscriber(destination, predicate, source) {
9220 var _this = _super.call(this, destination) || this;
9221 _this.predicate = predicate;
9222 _this.source = source;
9227 CountSubscriber.prototype._next = function (value) {
9228 if (this.predicate) {
9229 this._tryPredicate(value);
9235 CountSubscriber.prototype._tryPredicate = function (value) {
9238 result = this.predicate(value, this.index++, this.source);
9241 this.destination.error(err);
9248 CountSubscriber.prototype._complete = function () {
9249 this.destination.next(this.count);
9250 this.destination.complete();
9252 return CountSubscriber;
9253 }(Subscriber_1.Subscriber));
9255 },{"../Subscriber":38}],87:[function(require,module,exports){
9257 var __extends = (this && this.__extends) || (function () {
9258 var extendStatics = function (d, b) {
9259 extendStatics = Object.setPrototypeOf ||
9260 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9261 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9262 return extendStatics(d, b);
9264 return function (d, b) {
9265 extendStatics(d, b);
9266 function __() { this.constructor = d; }
9267 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9270 Object.defineProperty(exports, "__esModule", { value: true });
9271 var OuterSubscriber_1 = require("../OuterSubscriber");
9272 var subscribeToResult_1 = require("../util/subscribeToResult");
9273 function debounce(durationSelector) {
9274 return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
9276 exports.debounce = debounce;
9277 var DebounceOperator = (function () {
9278 function DebounceOperator(durationSelector) {
9279 this.durationSelector = durationSelector;
9281 DebounceOperator.prototype.call = function (subscriber, source) {
9282 return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
9284 return DebounceOperator;
9286 var DebounceSubscriber = (function (_super) {
9287 __extends(DebounceSubscriber, _super);
9288 function DebounceSubscriber(destination, durationSelector) {
9289 var _this = _super.call(this, destination) || this;
9290 _this.durationSelector = durationSelector;
9291 _this.hasValue = false;
9292 _this.durationSubscription = null;
9295 DebounceSubscriber.prototype._next = function (value) {
9297 var result = this.durationSelector.call(this, value);
9299 this._tryNext(value, result);
9303 this.destination.error(err);
9306 DebounceSubscriber.prototype._complete = function () {
9308 this.destination.complete();
9310 DebounceSubscriber.prototype._tryNext = function (value, duration) {
9311 var subscription = this.durationSubscription;
9313 this.hasValue = true;
9315 subscription.unsubscribe();
9316 this.remove(subscription);
9318 subscription = subscribeToResult_1.subscribeToResult(this, duration);
9319 if (subscription && !subscription.closed) {
9320 this.add(this.durationSubscription = subscription);
9323 DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
9326 DebounceSubscriber.prototype.notifyComplete = function () {
9329 DebounceSubscriber.prototype.emitValue = function () {
9330 if (this.hasValue) {
9331 var value = this.value;
9332 var subscription = this.durationSubscription;
9334 this.durationSubscription = null;
9335 subscription.unsubscribe();
9336 this.remove(subscription);
9339 this.hasValue = false;
9340 _super.prototype._next.call(this, value);
9343 return DebounceSubscriber;
9344 }(OuterSubscriber_1.OuterSubscriber));
9346 },{"../OuterSubscriber":33,"../util/subscribeToResult":221}],88:[function(require,module,exports){
9348 var __extends = (this && this.__extends) || (function () {
9349 var extendStatics = function (d, b) {
9350 extendStatics = Object.setPrototypeOf ||
9351 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9352 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9353 return extendStatics(d, b);
9355 return function (d, b) {
9356 extendStatics(d, b);
9357 function __() { this.constructor = d; }
9358 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9361 Object.defineProperty(exports, "__esModule", { value: true });
9362 var Subscriber_1 = require("../Subscriber");
9363 var async_1 = require("../scheduler/async");
9364 function debounceTime(dueTime, scheduler) {
9365 if (scheduler === void 0) { scheduler = async_1.async; }
9366 return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
9368 exports.debounceTime = debounceTime;
9369 var DebounceTimeOperator = (function () {
9370 function DebounceTimeOperator(dueTime, scheduler) {
9371 this.dueTime = dueTime;
9372 this.scheduler = scheduler;
9374 DebounceTimeOperator.prototype.call = function (subscriber, source) {
9375 return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
9377 return DebounceTimeOperator;
9379 var DebounceTimeSubscriber = (function (_super) {
9380 __extends(DebounceTimeSubscriber, _super);
9381 function DebounceTimeSubscriber(destination, dueTime, scheduler) {
9382 var _this = _super.call(this, destination) || this;
9383 _this.dueTime = dueTime;
9384 _this.scheduler = scheduler;
9385 _this.debouncedSubscription = null;
9386 _this.lastValue = null;
9387 _this.hasValue = false;
9390 DebounceTimeSubscriber.prototype._next = function (value) {
9391 this.clearDebounce();
9392 this.lastValue = value;
9393 this.hasValue = true;
9394 this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this));
9396 DebounceTimeSubscriber.prototype._complete = function () {
9397 this.debouncedNext();
9398 this.destination.complete();
9400 DebounceTimeSubscriber.prototype.debouncedNext = function () {
9401 this.clearDebounce();
9402 if (this.hasValue) {
9403 var lastValue = this.lastValue;
9404 this.lastValue = null;
9405 this.hasValue = false;
9406 this.destination.next(lastValue);
9409 DebounceTimeSubscriber.prototype.clearDebounce = function () {
9410 var debouncedSubscription = this.debouncedSubscription;
9411 if (debouncedSubscription !== null) {
9412 this.remove(debouncedSubscription);
9413 debouncedSubscription.unsubscribe();
9414 this.debouncedSubscription = null;
9417 return DebounceTimeSubscriber;
9418 }(Subscriber_1.Subscriber));
9419 function dispatchNext(subscriber) {
9420 subscriber.debouncedNext();
9423 },{"../Subscriber":38,"../scheduler/async":187}],89:[function(require,module,exports){
9425 var __extends = (this && this.__extends) || (function () {
9426 var extendStatics = function (d, b) {
9427 extendStatics = Object.setPrototypeOf ||
9428 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9429 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9430 return extendStatics(d, b);
9432 return function (d, b) {
9433 extendStatics(d, b);
9434 function __() { this.constructor = d; }
9435 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9438 Object.defineProperty(exports, "__esModule", { value: true });
9439 var Subscriber_1 = require("../Subscriber");
9440 function defaultIfEmpty(defaultValue) {
9441 if (defaultValue === void 0) { defaultValue = null; }
9442 return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
9444 exports.defaultIfEmpty = defaultIfEmpty;
9445 var DefaultIfEmptyOperator = (function () {
9446 function DefaultIfEmptyOperator(defaultValue) {
9447 this.defaultValue = defaultValue;
9449 DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
9450 return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
9452 return DefaultIfEmptyOperator;
9454 var DefaultIfEmptySubscriber = (function (_super) {
9455 __extends(DefaultIfEmptySubscriber, _super);
9456 function DefaultIfEmptySubscriber(destination, defaultValue) {
9457 var _this = _super.call(this, destination) || this;
9458 _this.defaultValue = defaultValue;
9459 _this.isEmpty = true;
9462 DefaultIfEmptySubscriber.prototype._next = function (value) {
9463 this.isEmpty = false;
9464 this.destination.next(value);
9466 DefaultIfEmptySubscriber.prototype._complete = function () {
9468 this.destination.next(this.defaultValue);
9470 this.destination.complete();
9472 return DefaultIfEmptySubscriber;
9473 }(Subscriber_1.Subscriber));
9475 },{"../Subscriber":38}],90:[function(require,module,exports){
9477 var __extends = (this && this.__extends) || (function () {
9478 var extendStatics = function (d, b) {
9479 extendStatics = Object.setPrototypeOf ||
9480 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9481 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9482 return extendStatics(d, b);
9484 return function (d, b) {
9485 extendStatics(d, b);
9486 function __() { this.constructor = d; }
9487 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9490 Object.defineProperty(exports, "__esModule", { value: true });
9491 var async_1 = require("../scheduler/async");
9492 var isDate_1 = require("../util/isDate");
9493 var Subscriber_1 = require("../Subscriber");
9494 var Notification_1 = require("../Notification");
9495 function delay(delay, scheduler) {
9496 if (scheduler === void 0) { scheduler = async_1.async; }
9497 var absoluteDelay = isDate_1.isDate(delay);
9498 var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
9499 return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
9501 exports.delay = delay;
9502 var DelayOperator = (function () {
9503 function DelayOperator(delay, scheduler) {
9505 this.scheduler = scheduler;
9507 DelayOperator.prototype.call = function (subscriber, source) {
9508 return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
9510 return DelayOperator;
9512 var DelaySubscriber = (function (_super) {
9513 __extends(DelaySubscriber, _super);
9514 function DelaySubscriber(destination, delay, scheduler) {
9515 var _this = _super.call(this, destination) || this;
9516 _this.delay = delay;
9517 _this.scheduler = scheduler;
9519 _this.active = false;
9520 _this.errored = false;
9523 DelaySubscriber.dispatch = function (state) {
9524 var source = state.source;
9525 var queue = source.queue;
9526 var scheduler = state.scheduler;
9527 var destination = state.destination;
9528 while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
9529 queue.shift().notification.observe(destination);
9531 if (queue.length > 0) {
9532 var delay_1 = Math.max(0, queue[0].time - scheduler.now());
9533 this.schedule(state, delay_1);
9537 source.active = false;
9540 DelaySubscriber.prototype._schedule = function (scheduler) {
9542 var destination = this.destination;
9543 destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
9544 source: this, destination: this.destination, scheduler: scheduler
9547 DelaySubscriber.prototype.scheduleNotification = function (notification) {
9548 if (this.errored === true) {
9551 var scheduler = this.scheduler;
9552 var message = new DelayMessage(scheduler.now() + this.delay, notification);
9553 this.queue.push(message);
9554 if (this.active === false) {
9555 this._schedule(scheduler);
9558 DelaySubscriber.prototype._next = function (value) {
9559 this.scheduleNotification(Notification_1.Notification.createNext(value));
9561 DelaySubscriber.prototype._error = function (err) {
9562 this.errored = true;
9564 this.destination.error(err);
9567 DelaySubscriber.prototype._complete = function () {
9568 this.scheduleNotification(Notification_1.Notification.createComplete());
9571 return DelaySubscriber;
9572 }(Subscriber_1.Subscriber));
9573 var DelayMessage = (function () {
9574 function DelayMessage(time, notification) {
9576 this.notification = notification;
9578 return DelayMessage;
9581 },{"../Notification":30,"../Subscriber":38,"../scheduler/async":187,"../util/isDate":204}],91:[function(require,module,exports){
9583 var __extends = (this && this.__extends) || (function () {
9584 var extendStatics = function (d, b) {
9585 extendStatics = Object.setPrototypeOf ||
9586 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9587 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9588 return extendStatics(d, b);
9590 return function (d, b) {
9591 extendStatics(d, b);
9592 function __() { this.constructor = d; }
9593 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9596 Object.defineProperty(exports, "__esModule", { value: true });
9597 var Subscriber_1 = require("../Subscriber");
9598 var Observable_1 = require("../Observable");
9599 var OuterSubscriber_1 = require("../OuterSubscriber");
9600 var subscribeToResult_1 = require("../util/subscribeToResult");
9601 function delayWhen(delayDurationSelector, subscriptionDelay) {
9602 if (subscriptionDelay) {
9603 return function (source) {
9604 return new SubscriptionDelayObservable(source, subscriptionDelay)
9605 .lift(new DelayWhenOperator(delayDurationSelector));
9608 return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
9610 exports.delayWhen = delayWhen;
9611 var DelayWhenOperator = (function () {
9612 function DelayWhenOperator(delayDurationSelector) {
9613 this.delayDurationSelector = delayDurationSelector;
9615 DelayWhenOperator.prototype.call = function (subscriber, source) {
9616 return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
9618 return DelayWhenOperator;
9620 var DelayWhenSubscriber = (function (_super) {
9621 __extends(DelayWhenSubscriber, _super);
9622 function DelayWhenSubscriber(destination, delayDurationSelector) {
9623 var _this = _super.call(this, destination) || this;
9624 _this.delayDurationSelector = delayDurationSelector;
9625 _this.completed = false;
9626 _this.delayNotifierSubscriptions = [];
9630 DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
9631 this.destination.next(outerValue);
9632 this.removeSubscription(innerSub);
9635 DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
9638 DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
9639 var value = this.removeSubscription(innerSub);
9641 this.destination.next(value);
9645 DelayWhenSubscriber.prototype._next = function (value) {
9646 var index = this.index++;
9648 var delayNotifier = this.delayDurationSelector(value, index);
9649 if (delayNotifier) {
9650 this.tryDelay(delayNotifier, value);
9654 this.destination.error(err);
9657 DelayWhenSubscriber.prototype._complete = function () {
9658 this.completed = true;
9662 DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
9663 subscription.unsubscribe();
9664 var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
9665 if (subscriptionIdx !== -1) {
9666 this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
9668 return subscription.outerValue;
9670 DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
9671 var notifierSubscription = subscribeToResult_1.subscribeToResult(this, delayNotifier, value);
9672 if (notifierSubscription && !notifierSubscription.closed) {
9673 var destination = this.destination;
9674 destination.add(notifierSubscription);
9675 this.delayNotifierSubscriptions.push(notifierSubscription);
9678 DelayWhenSubscriber.prototype.tryComplete = function () {
9679 if (this.completed && this.delayNotifierSubscriptions.length === 0) {
9680 this.destination.complete();
9683 return DelayWhenSubscriber;
9684 }(OuterSubscriber_1.OuterSubscriber));
9685 var SubscriptionDelayObservable = (function (_super) {
9686 __extends(SubscriptionDelayObservable, _super);
9687 function SubscriptionDelayObservable(source, subscriptionDelay) {
9688 var _this = _super.call(this) || this;
9689 _this.source = source;
9690 _this.subscriptionDelay = subscriptionDelay;
9693 SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
9694 this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
9696 return SubscriptionDelayObservable;
9697 }(Observable_1.Observable));
9698 var SubscriptionDelaySubscriber = (function (_super) {
9699 __extends(SubscriptionDelaySubscriber, _super);
9700 function SubscriptionDelaySubscriber(parent, source) {
9701 var _this = _super.call(this) || this;
9702 _this.parent = parent;
9703 _this.source = source;
9704 _this.sourceSubscribed = false;
9707 SubscriptionDelaySubscriber.prototype._next = function (unused) {
9708 this.subscribeToSource();
9710 SubscriptionDelaySubscriber.prototype._error = function (err) {
9712 this.parent.error(err);
9714 SubscriptionDelaySubscriber.prototype._complete = function () {
9716 this.subscribeToSource();
9718 SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
9719 if (!this.sourceSubscribed) {
9720 this.sourceSubscribed = true;
9722 this.source.subscribe(this.parent);
9725 return SubscriptionDelaySubscriber;
9726 }(Subscriber_1.Subscriber));
9728 },{"../Observable":31,"../OuterSubscriber":33,"../Subscriber":38,"../util/subscribeToResult":221}],92:[function(require,module,exports){
9730 var __extends = (this && this.__extends) || (function () {
9731 var extendStatics = function (d, b) {
9732 extendStatics = Object.setPrototypeOf ||
9733 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9734 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9735 return extendStatics(d, b);
9737 return function (d, b) {
9738 extendStatics(d, b);
9739 function __() { this.constructor = d; }
9740 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9743 Object.defineProperty(exports, "__esModule", { value: true });
9744 var Subscriber_1 = require("../Subscriber");
9745 function dematerialize() {
9746 return function dematerializeOperatorFunction(source) {
9747 return source.lift(new DeMaterializeOperator());
9750 exports.dematerialize = dematerialize;
9751 var DeMaterializeOperator = (function () {
9752 function DeMaterializeOperator() {
9754 DeMaterializeOperator.prototype.call = function (subscriber, source) {
9755 return source.subscribe(new DeMaterializeSubscriber(subscriber));
9757 return DeMaterializeOperator;
9759 var DeMaterializeSubscriber = (function (_super) {
9760 __extends(DeMaterializeSubscriber, _super);
9761 function DeMaterializeSubscriber(destination) {
9762 return _super.call(this, destination) || this;
9764 DeMaterializeSubscriber.prototype._next = function (value) {
9765 value.observe(this.destination);
9767 return DeMaterializeSubscriber;
9768 }(Subscriber_1.Subscriber));
9770 },{"../Subscriber":38}],93:[function(require,module,exports){
9772 var __extends = (this && this.__extends) || (function () {
9773 var extendStatics = function (d, b) {
9774 extendStatics = Object.setPrototypeOf ||
9775 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9776 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9777 return extendStatics(d, b);
9779 return function (d, b) {
9780 extendStatics(d, b);
9781 function __() { this.constructor = d; }
9782 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9785 Object.defineProperty(exports, "__esModule", { value: true });
9786 var OuterSubscriber_1 = require("../OuterSubscriber");
9787 var subscribeToResult_1 = require("../util/subscribeToResult");
9788 function distinct(keySelector, flushes) {
9789 return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
9791 exports.distinct = distinct;
9792 var DistinctOperator = (function () {
9793 function DistinctOperator(keySelector, flushes) {
9794 this.keySelector = keySelector;
9795 this.flushes = flushes;
9797 DistinctOperator.prototype.call = function (subscriber, source) {
9798 return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
9800 return DistinctOperator;
9802 var DistinctSubscriber = (function (_super) {
9803 __extends(DistinctSubscriber, _super);
9804 function DistinctSubscriber(destination, keySelector, flushes) {
9805 var _this = _super.call(this, destination) || this;
9806 _this.keySelector = keySelector;
9807 _this.values = new Set();
9809 _this.add(subscribeToResult_1.subscribeToResult(_this, flushes));
9813 DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
9814 this.values.clear();
9816 DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
9819 DistinctSubscriber.prototype._next = function (value) {
9820 if (this.keySelector) {
9821 this._useKeySelector(value);
9824 this._finalizeNext(value, value);
9827 DistinctSubscriber.prototype._useKeySelector = function (value) {
9829 var destination = this.destination;
9831 key = this.keySelector(value);
9834 destination.error(err);
9837 this._finalizeNext(key, value);
9839 DistinctSubscriber.prototype._finalizeNext = function (key, value) {
9840 var values = this.values;
9841 if (!values.has(key)) {
9843 this.destination.next(value);
9846 return DistinctSubscriber;
9847 }(OuterSubscriber_1.OuterSubscriber));
9848 exports.DistinctSubscriber = DistinctSubscriber;
9850 },{"../OuterSubscriber":33,"../util/subscribeToResult":221}],94:[function(require,module,exports){
9852 var __extends = (this && this.__extends) || (function () {
9853 var extendStatics = function (d, b) {
9854 extendStatics = Object.setPrototypeOf ||
9855 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9856 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9857 return extendStatics(d, b);
9859 return function (d, b) {
9860 extendStatics(d, b);
9861 function __() { this.constructor = d; }
9862 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9865 Object.defineProperty(exports, "__esModule", { value: true });
9866 var Subscriber_1 = require("../Subscriber");
9867 var tryCatch_1 = require("../util/tryCatch");
9868 var errorObject_1 = require("../util/errorObject");
9869 function distinctUntilChanged(compare, keySelector) {
9870 return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
9872 exports.distinctUntilChanged = distinctUntilChanged;
9873 var DistinctUntilChangedOperator = (function () {
9874 function DistinctUntilChangedOperator(compare, keySelector) {
9875 this.compare = compare;
9876 this.keySelector = keySelector;
9878 DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
9879 return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
9881 return DistinctUntilChangedOperator;
9883 var DistinctUntilChangedSubscriber = (function (_super) {
9884 __extends(DistinctUntilChangedSubscriber, _super);
9885 function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
9886 var _this = _super.call(this, destination) || this;
9887 _this.keySelector = keySelector;
9888 _this.hasKey = false;
9889 if (typeof compare === 'function') {
9890 _this.compare = compare;
9894 DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
9897 DistinctUntilChangedSubscriber.prototype._next = function (value) {
9898 var keySelector = this.keySelector;
9901 key = tryCatch_1.tryCatch(this.keySelector)(value);
9902 if (key === errorObject_1.errorObject) {
9903 return this.destination.error(errorObject_1.errorObject.e);
9908 result = tryCatch_1.tryCatch(this.compare)(this.key, key);
9909 if (result === errorObject_1.errorObject) {
9910 return this.destination.error(errorObject_1.errorObject.e);
9916 if (Boolean(result) === false) {
9918 this.destination.next(value);
9921 return DistinctUntilChangedSubscriber;
9922 }(Subscriber_1.Subscriber));
9924 },{"../Subscriber":38,"../util/errorObject":199,"../util/tryCatch":223}],95:[function(require,module,exports){
9926 Object.defineProperty(exports, "__esModule", { value: true });
9927 var distinctUntilChanged_1 = require("./distinctUntilChanged");
9928 function distinctUntilKeyChanged(key, compare) {
9929 return distinctUntilChanged_1.distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
9931 exports.distinctUntilKeyChanged = distinctUntilKeyChanged;
9933 },{"./distinctUntilChanged":94}],96:[function(require,module,exports){
9935 Object.defineProperty(exports, "__esModule", { value: true });
9936 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
9937 var filter_1 = require("./filter");
9938 var throwIfEmpty_1 = require("./throwIfEmpty");
9939 var defaultIfEmpty_1 = require("./defaultIfEmpty");
9940 var take_1 = require("./take");
9941 function elementAt(index, defaultValue) {
9943 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError();
9945 var hasDefaultValue = arguments.length >= 2;
9946 return function (source) { return source.pipe(filter_1.filter(function (v, i) { return i === index; }), take_1.take(1), hasDefaultValue
9947 ? defaultIfEmpty_1.defaultIfEmpty(defaultValue)
9948 : throwIfEmpty_1.throwIfEmpty(function () { return new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError(); })); };
9950 exports.elementAt = elementAt;
9952 },{"../util/ArgumentOutOfRangeError":192,"./defaultIfEmpty":89,"./filter":102,"./take":154,"./throwIfEmpty":161}],97:[function(require,module,exports){
9954 Object.defineProperty(exports, "__esModule", { value: true });
9955 var fromArray_1 = require("../observable/fromArray");
9956 var scalar_1 = require("../observable/scalar");
9957 var empty_1 = require("../observable/empty");
9958 var concat_1 = require("../observable/concat");
9959 var isScheduler_1 = require("../util/isScheduler");
9960 function endWith() {
9962 for (var _i = 0; _i < arguments.length; _i++) {
9963 array[_i] = arguments[_i];
9965 return function (source) {
9966 var scheduler = array[array.length - 1];
9967 if (isScheduler_1.isScheduler(scheduler)) {
9973 var len = array.length;
9974 if (len === 1 && !scheduler) {
9975 return concat_1.concat(source, scalar_1.scalar(array[0]));
9978 return concat_1.concat(source, fromArray_1.fromArray(array, scheduler));
9981 return concat_1.concat(source, empty_1.empty(scheduler));
9985 exports.endWith = endWith;
9987 },{"../observable/concat":46,"../observable/empty":48,"../observable/fromArray":51,"../observable/scalar":67,"../util/isScheduler":212}],98:[function(require,module,exports){
9989 var __extends = (this && this.__extends) || (function () {
9990 var extendStatics = function (d, b) {
9991 extendStatics = Object.setPrototypeOf ||
9992 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9993 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9994 return extendStatics(d, b);
9996 return function (d, b) {
9997 extendStatics(d, b);
9998 function __() { this.constructor = d; }
9999 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10002 Object.defineProperty(exports, "__esModule", { value: true });
10003 var Subscriber_1 = require("../Subscriber");
10004 function every(predicate, thisArg) {
10005 return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
10007 exports.every = every;
10008 var EveryOperator = (function () {
10009 function EveryOperator(predicate, thisArg, source) {
10010 this.predicate = predicate;
10011 this.thisArg = thisArg;
10012 this.source = source;
10014 EveryOperator.prototype.call = function (observer, source) {
10015 return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
10017 return EveryOperator;
10019 var EverySubscriber = (function (_super) {
10020 __extends(EverySubscriber, _super);
10021 function EverySubscriber(destination, predicate, thisArg, source) {
10022 var _this = _super.call(this, destination) || this;
10023 _this.predicate = predicate;
10024 _this.thisArg = thisArg;
10025 _this.source = source;
10027 _this.thisArg = thisArg || _this;
10030 EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
10031 this.destination.next(everyValueMatch);
10032 this.destination.complete();
10034 EverySubscriber.prototype._next = function (value) {
10035 var result = false;
10037 result = this.predicate.call(this.thisArg, value, this.index++, this.source);
10040 this.destination.error(err);
10044 this.notifyComplete(false);
10047 EverySubscriber.prototype._complete = function () {
10048 this.notifyComplete(true);
10050 return EverySubscriber;
10051 }(Subscriber_1.Subscriber));
10053 },{"../Subscriber":38}],99:[function(require,module,exports){
10055 var __extends = (this && this.__extends) || (function () {
10056 var extendStatics = function (d, b) {
10057 extendStatics = Object.setPrototypeOf ||
10058 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10059 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10060 return extendStatics(d, b);
10062 return function (d, b) {
10063 extendStatics(d, b);
10064 function __() { this.constructor = d; }
10065 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10068 Object.defineProperty(exports, "__esModule", { value: true });
10069 var OuterSubscriber_1 = require("../OuterSubscriber");
10070 var subscribeToResult_1 = require("../util/subscribeToResult");
10071 function exhaust() {
10072 return function (source) { return source.lift(new SwitchFirstOperator()); };
10074 exports.exhaust = exhaust;
10075 var SwitchFirstOperator = (function () {
10076 function SwitchFirstOperator() {
10078 SwitchFirstOperator.prototype.call = function (subscriber, source) {
10079 return source.subscribe(new SwitchFirstSubscriber(subscriber));
10081 return SwitchFirstOperator;
10083 var SwitchFirstSubscriber = (function (_super) {
10084 __extends(SwitchFirstSubscriber, _super);
10085 function SwitchFirstSubscriber(destination) {
10086 var _this = _super.call(this, destination) || this;
10087 _this.hasCompleted = false;
10088 _this.hasSubscription = false;
10091 SwitchFirstSubscriber.prototype._next = function (value) {
10092 if (!this.hasSubscription) {
10093 this.hasSubscription = true;
10094 this.add(subscribeToResult_1.subscribeToResult(this, value));
10097 SwitchFirstSubscriber.prototype._complete = function () {
10098 this.hasCompleted = true;
10099 if (!this.hasSubscription) {
10100 this.destination.complete();
10103 SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
10104 this.remove(innerSub);
10105 this.hasSubscription = false;
10106 if (this.hasCompleted) {
10107 this.destination.complete();
10110 return SwitchFirstSubscriber;
10111 }(OuterSubscriber_1.OuterSubscriber));
10113 },{"../OuterSubscriber":33,"../util/subscribeToResult":221}],100:[function(require,module,exports){
10115 var __extends = (this && this.__extends) || (function () {
10116 var extendStatics = function (d, b) {
10117 extendStatics = Object.setPrototypeOf ||
10118 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10119 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10120 return extendStatics(d, b);
10122 return function (d, b) {
10123 extendStatics(d, b);
10124 function __() { this.constructor = d; }
10125 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10128 Object.defineProperty(exports, "__esModule", { value: true });
10129 var OuterSubscriber_1 = require("../OuterSubscriber");
10130 var InnerSubscriber_1 = require("../InnerSubscriber");
10131 var subscribeToResult_1 = require("../util/subscribeToResult");
10132 var map_1 = require("./map");
10133 var from_1 = require("../observable/from");
10134 function exhaustMap(project, resultSelector) {
10135 if (resultSelector) {
10136 return function (source) { return source.pipe(exhaustMap(function (a, i) { return from_1.from(project(a, i)).pipe(map_1.map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
10138 return function (source) {
10139 return source.lift(new ExhauseMapOperator(project));
10142 exports.exhaustMap = exhaustMap;
10143 var ExhauseMapOperator = (function () {
10144 function ExhauseMapOperator(project) {
10145 this.project = project;
10147 ExhauseMapOperator.prototype.call = function (subscriber, source) {
10148 return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
10150 return ExhauseMapOperator;
10152 var ExhaustMapSubscriber = (function (_super) {
10153 __extends(ExhaustMapSubscriber, _super);
10154 function ExhaustMapSubscriber(destination, project) {
10155 var _this = _super.call(this, destination) || this;
10156 _this.project = project;
10157 _this.hasSubscription = false;
10158 _this.hasCompleted = false;
10162 ExhaustMapSubscriber.prototype._next = function (value) {
10163 if (!this.hasSubscription) {
10164 this.tryNext(value);
10167 ExhaustMapSubscriber.prototype.tryNext = function (value) {
10169 var index = this.index++;
10171 result = this.project(value, index);
10174 this.destination.error(err);
10177 this.hasSubscription = true;
10178 this._innerSub(result, value, index);
10180 ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
10181 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
10182 var destination = this.destination;
10183 destination.add(innerSubscriber);
10184 subscribeToResult_1.subscribeToResult(this, result, value, index, innerSubscriber);
10186 ExhaustMapSubscriber.prototype._complete = function () {
10187 this.hasCompleted = true;
10188 if (!this.hasSubscription) {
10189 this.destination.complete();
10191 this.unsubscribe();
10193 ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10194 this.destination.next(innerValue);
10196 ExhaustMapSubscriber.prototype.notifyError = function (err) {
10197 this.destination.error(err);
10199 ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
10200 var destination = this.destination;
10201 destination.remove(innerSub);
10202 this.hasSubscription = false;
10203 if (this.hasCompleted) {
10204 this.destination.complete();
10207 return ExhaustMapSubscriber;
10208 }(OuterSubscriber_1.OuterSubscriber));
10210 },{"../InnerSubscriber":29,"../OuterSubscriber":33,"../observable/from":50,"../util/subscribeToResult":221,"./map":111}],101:[function(require,module,exports){
10212 var __extends = (this && this.__extends) || (function () {
10213 var extendStatics = function (d, b) {
10214 extendStatics = Object.setPrototypeOf ||
10215 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10216 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10217 return extendStatics(d, b);
10219 return function (d, b) {
10220 extendStatics(d, b);
10221 function __() { this.constructor = d; }
10222 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10225 Object.defineProperty(exports, "__esModule", { value: true });
10226 var tryCatch_1 = require("../util/tryCatch");
10227 var errorObject_1 = require("../util/errorObject");
10228 var OuterSubscriber_1 = require("../OuterSubscriber");
10229 var subscribeToResult_1 = require("../util/subscribeToResult");
10230 function expand(project, concurrent, scheduler) {
10231 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
10232 if (scheduler === void 0) { scheduler = undefined; }
10233 concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
10234 return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
10236 exports.expand = expand;
10237 var ExpandOperator = (function () {
10238 function ExpandOperator(project, concurrent, scheduler) {
10239 this.project = project;
10240 this.concurrent = concurrent;
10241 this.scheduler = scheduler;
10243 ExpandOperator.prototype.call = function (subscriber, source) {
10244 return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
10246 return ExpandOperator;
10248 exports.ExpandOperator = ExpandOperator;
10249 var ExpandSubscriber = (function (_super) {
10250 __extends(ExpandSubscriber, _super);
10251 function ExpandSubscriber(destination, project, concurrent, scheduler) {
10252 var _this = _super.call(this, destination) || this;
10253 _this.project = project;
10254 _this.concurrent = concurrent;
10255 _this.scheduler = scheduler;
10258 _this.hasCompleted = false;
10259 if (concurrent < Number.POSITIVE_INFINITY) {
10264 ExpandSubscriber.dispatch = function (arg) {
10265 var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
10266 subscriber.subscribeToProjection(result, value, index);
10268 ExpandSubscriber.prototype._next = function (value) {
10269 var destination = this.destination;
10270 if (destination.closed) {
10274 var index = this.index++;
10275 if (this.active < this.concurrent) {
10276 destination.next(value);
10277 var result = tryCatch_1.tryCatch(this.project)(value, index);
10278 if (result === errorObject_1.errorObject) {
10279 destination.error(errorObject_1.errorObject.e);
10281 else if (!this.scheduler) {
10282 this.subscribeToProjection(result, value, index);
10285 var state = { subscriber: this, result: result, value: value, index: index };
10286 var destination_1 = this.destination;
10287 destination_1.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
10291 this.buffer.push(value);
10294 ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
10296 var destination = this.destination;
10297 destination.add(subscribeToResult_1.subscribeToResult(this, result, value, index));
10299 ExpandSubscriber.prototype._complete = function () {
10300 this.hasCompleted = true;
10301 if (this.hasCompleted && this.active === 0) {
10302 this.destination.complete();
10304 this.unsubscribe();
10306 ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10307 this._next(innerValue);
10309 ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
10310 var buffer = this.buffer;
10311 var destination = this.destination;
10312 destination.remove(innerSub);
10314 if (buffer && buffer.length > 0) {
10315 this._next(buffer.shift());
10317 if (this.hasCompleted && this.active === 0) {
10318 this.destination.complete();
10321 return ExpandSubscriber;
10322 }(OuterSubscriber_1.OuterSubscriber));
10323 exports.ExpandSubscriber = ExpandSubscriber;
10325 },{"../OuterSubscriber":33,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],102:[function(require,module,exports){
10327 var __extends = (this && this.__extends) || (function () {
10328 var extendStatics = function (d, b) {
10329 extendStatics = Object.setPrototypeOf ||
10330 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10331 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10332 return extendStatics(d, b);
10334 return function (d, b) {
10335 extendStatics(d, b);
10336 function __() { this.constructor = d; }
10337 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10340 Object.defineProperty(exports, "__esModule", { value: true });
10341 var Subscriber_1 = require("../Subscriber");
10342 function filter(predicate, thisArg) {
10343 return function filterOperatorFunction(source) {
10344 return source.lift(new FilterOperator(predicate, thisArg));
10347 exports.filter = filter;
10348 var FilterOperator = (function () {
10349 function FilterOperator(predicate, thisArg) {
10350 this.predicate = predicate;
10351 this.thisArg = thisArg;
10353 FilterOperator.prototype.call = function (subscriber, source) {
10354 return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
10356 return FilterOperator;
10358 var FilterSubscriber = (function (_super) {
10359 __extends(FilterSubscriber, _super);
10360 function FilterSubscriber(destination, predicate, thisArg) {
10361 var _this = _super.call(this, destination) || this;
10362 _this.predicate = predicate;
10363 _this.thisArg = thisArg;
10367 FilterSubscriber.prototype._next = function (value) {
10370 result = this.predicate.call(this.thisArg, value, this.count++);
10373 this.destination.error(err);
10377 this.destination.next(value);
10380 return FilterSubscriber;
10381 }(Subscriber_1.Subscriber));
10383 },{"../Subscriber":38}],103:[function(require,module,exports){
10385 var __extends = (this && this.__extends) || (function () {
10386 var extendStatics = function (d, b) {
10387 extendStatics = Object.setPrototypeOf ||
10388 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10389 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10390 return extendStatics(d, b);
10392 return function (d, b) {
10393 extendStatics(d, b);
10394 function __() { this.constructor = d; }
10395 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10398 Object.defineProperty(exports, "__esModule", { value: true });
10399 var Subscriber_1 = require("../Subscriber");
10400 var Subscription_1 = require("../Subscription");
10401 function finalize(callback) {
10402 return function (source) { return source.lift(new FinallyOperator(callback)); };
10404 exports.finalize = finalize;
10405 var FinallyOperator = (function () {
10406 function FinallyOperator(callback) {
10407 this.callback = callback;
10409 FinallyOperator.prototype.call = function (subscriber, source) {
10410 return source.subscribe(new FinallySubscriber(subscriber, this.callback));
10412 return FinallyOperator;
10414 var FinallySubscriber = (function (_super) {
10415 __extends(FinallySubscriber, _super);
10416 function FinallySubscriber(destination, callback) {
10417 var _this = _super.call(this, destination) || this;
10418 _this.add(new Subscription_1.Subscription(callback));
10421 return FinallySubscriber;
10422 }(Subscriber_1.Subscriber));
10424 },{"../Subscriber":38,"../Subscription":39}],104:[function(require,module,exports){
10426 var __extends = (this && this.__extends) || (function () {
10427 var extendStatics = function (d, b) {
10428 extendStatics = Object.setPrototypeOf ||
10429 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10430 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10431 return extendStatics(d, b);
10433 return function (d, b) {
10434 extendStatics(d, b);
10435 function __() { this.constructor = d; }
10436 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10439 Object.defineProperty(exports, "__esModule", { value: true });
10440 var Subscriber_1 = require("../Subscriber");
10441 function find(predicate, thisArg) {
10442 if (typeof predicate !== 'function') {
10443 throw new TypeError('predicate is not a function');
10445 return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
10447 exports.find = find;
10448 var FindValueOperator = (function () {
10449 function FindValueOperator(predicate, source, yieldIndex, thisArg) {
10450 this.predicate = predicate;
10451 this.source = source;
10452 this.yieldIndex = yieldIndex;
10453 this.thisArg = thisArg;
10455 FindValueOperator.prototype.call = function (observer, source) {
10456 return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
10458 return FindValueOperator;
10460 exports.FindValueOperator = FindValueOperator;
10461 var FindValueSubscriber = (function (_super) {
10462 __extends(FindValueSubscriber, _super);
10463 function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
10464 var _this = _super.call(this, destination) || this;
10465 _this.predicate = predicate;
10466 _this.source = source;
10467 _this.yieldIndex = yieldIndex;
10468 _this.thisArg = thisArg;
10472 FindValueSubscriber.prototype.notifyComplete = function (value) {
10473 var destination = this.destination;
10474 destination.next(value);
10475 destination.complete();
10476 this.unsubscribe();
10478 FindValueSubscriber.prototype._next = function (value) {
10479 var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
10480 var index = this.index++;
10482 var result = predicate.call(thisArg || this, value, index, this.source);
10484 this.notifyComplete(this.yieldIndex ? index : value);
10488 this.destination.error(err);
10491 FindValueSubscriber.prototype._complete = function () {
10492 this.notifyComplete(this.yieldIndex ? -1 : undefined);
10494 return FindValueSubscriber;
10495 }(Subscriber_1.Subscriber));
10496 exports.FindValueSubscriber = FindValueSubscriber;
10498 },{"../Subscriber":38}],105:[function(require,module,exports){
10500 Object.defineProperty(exports, "__esModule", { value: true });
10501 var find_1 = require("../operators/find");
10502 function findIndex(predicate, thisArg) {
10503 return function (source) { return source.lift(new find_1.FindValueOperator(predicate, source, true, thisArg)); };
10505 exports.findIndex = findIndex;
10507 },{"../operators/find":104}],106:[function(require,module,exports){
10509 Object.defineProperty(exports, "__esModule", { value: true });
10510 var EmptyError_1 = require("../util/EmptyError");
10511 var filter_1 = require("./filter");
10512 var take_1 = require("./take");
10513 var defaultIfEmpty_1 = require("./defaultIfEmpty");
10514 var throwIfEmpty_1 = require("./throwIfEmpty");
10515 var identity_1 = require("../util/identity");
10516 function first(predicate, defaultValue) {
10517 var hasDefaultValue = arguments.length >= 2;
10518 return function (source) { return source.pipe(predicate ? filter_1.filter(function (v, i) { return predicate(v, i, source); }) : identity_1.identity, take_1.take(1), hasDefaultValue ? defaultIfEmpty_1.defaultIfEmpty(defaultValue) : throwIfEmpty_1.throwIfEmpty(function () { return new EmptyError_1.EmptyError(); })); };
10520 exports.first = first;
10522 },{"../util/EmptyError":193,"../util/identity":201,"./defaultIfEmpty":89,"./filter":102,"./take":154,"./throwIfEmpty":161}],107:[function(require,module,exports){
10524 var __extends = (this && this.__extends) || (function () {
10525 var extendStatics = function (d, b) {
10526 extendStatics = Object.setPrototypeOf ||
10527 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10528 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10529 return extendStatics(d, b);
10531 return function (d, b) {
10532 extendStatics(d, b);
10533 function __() { this.constructor = d; }
10534 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10537 Object.defineProperty(exports, "__esModule", { value: true });
10538 var Subscriber_1 = require("../Subscriber");
10539 var Subscription_1 = require("../Subscription");
10540 var Observable_1 = require("../Observable");
10541 var Subject_1 = require("../Subject");
10542 function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
10543 return function (source) {
10544 return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
10547 exports.groupBy = groupBy;
10548 var GroupByOperator = (function () {
10549 function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
10550 this.keySelector = keySelector;
10551 this.elementSelector = elementSelector;
10552 this.durationSelector = durationSelector;
10553 this.subjectSelector = subjectSelector;
10555 GroupByOperator.prototype.call = function (subscriber, source) {
10556 return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
10558 return GroupByOperator;
10560 var GroupBySubscriber = (function (_super) {
10561 __extends(GroupBySubscriber, _super);
10562 function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
10563 var _this = _super.call(this, destination) || this;
10564 _this.keySelector = keySelector;
10565 _this.elementSelector = elementSelector;
10566 _this.durationSelector = durationSelector;
10567 _this.subjectSelector = subjectSelector;
10568 _this.groups = null;
10569 _this.attemptedToUnsubscribe = false;
10573 GroupBySubscriber.prototype._next = function (value) {
10576 key = this.keySelector(value);
10582 this._group(value, key);
10584 GroupBySubscriber.prototype._group = function (value, key) {
10585 var groups = this.groups;
10587 groups = this.groups = new Map();
10589 var group = groups.get(key);
10591 if (this.elementSelector) {
10593 element = this.elementSelector(value);
10603 group = (this.subjectSelector ? this.subjectSelector() : new Subject_1.Subject());
10604 groups.set(key, group);
10605 var groupedObservable = new GroupedObservable(key, group, this);
10606 this.destination.next(groupedObservable);
10607 if (this.durationSelector) {
10608 var duration = void 0;
10610 duration = this.durationSelector(new GroupedObservable(key, group));
10616 this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
10619 if (!group.closed) {
10620 group.next(element);
10623 GroupBySubscriber.prototype._error = function (err) {
10624 var groups = this.groups;
10626 groups.forEach(function (group, key) {
10631 this.destination.error(err);
10633 GroupBySubscriber.prototype._complete = function () {
10634 var groups = this.groups;
10636 groups.forEach(function (group, key) {
10641 this.destination.complete();
10643 GroupBySubscriber.prototype.removeGroup = function (key) {
10644 this.groups.delete(key);
10646 GroupBySubscriber.prototype.unsubscribe = function () {
10647 if (!this.closed) {
10648 this.attemptedToUnsubscribe = true;
10649 if (this.count === 0) {
10650 _super.prototype.unsubscribe.call(this);
10654 return GroupBySubscriber;
10655 }(Subscriber_1.Subscriber));
10656 var GroupDurationSubscriber = (function (_super) {
10657 __extends(GroupDurationSubscriber, _super);
10658 function GroupDurationSubscriber(key, group, parent) {
10659 var _this = _super.call(this, group) || this;
10661 _this.group = group;
10662 _this.parent = parent;
10665 GroupDurationSubscriber.prototype._next = function (value) {
10668 GroupDurationSubscriber.prototype._unsubscribe = function () {
10669 var _a = this, parent = _a.parent, key = _a.key;
10670 this.key = this.parent = null;
10672 parent.removeGroup(key);
10675 return GroupDurationSubscriber;
10676 }(Subscriber_1.Subscriber));
10677 var GroupedObservable = (function (_super) {
10678 __extends(GroupedObservable, _super);
10679 function GroupedObservable(key, groupSubject, refCountSubscription) {
10680 var _this = _super.call(this) || this;
10682 _this.groupSubject = groupSubject;
10683 _this.refCountSubscription = refCountSubscription;
10686 GroupedObservable.prototype._subscribe = function (subscriber) {
10687 var subscription = new Subscription_1.Subscription();
10688 var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
10689 if (refCountSubscription && !refCountSubscription.closed) {
10690 subscription.add(new InnerRefCountSubscription(refCountSubscription));
10692 subscription.add(groupSubject.subscribe(subscriber));
10693 return subscription;
10695 return GroupedObservable;
10696 }(Observable_1.Observable));
10697 exports.GroupedObservable = GroupedObservable;
10698 var InnerRefCountSubscription = (function (_super) {
10699 __extends(InnerRefCountSubscription, _super);
10700 function InnerRefCountSubscription(parent) {
10701 var _this = _super.call(this) || this;
10702 _this.parent = parent;
10706 InnerRefCountSubscription.prototype.unsubscribe = function () {
10707 var parent = this.parent;
10708 if (!parent.closed && !this.closed) {
10709 _super.prototype.unsubscribe.call(this);
10711 if (parent.count === 0 && parent.attemptedToUnsubscribe) {
10712 parent.unsubscribe();
10716 return InnerRefCountSubscription;
10717 }(Subscription_1.Subscription));
10719 },{"../Observable":31,"../Subject":36,"../Subscriber":38,"../Subscription":39}],108:[function(require,module,exports){
10721 var __extends = (this && this.__extends) || (function () {
10722 var extendStatics = function (d, b) {
10723 extendStatics = Object.setPrototypeOf ||
10724 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10725 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10726 return extendStatics(d, b);
10728 return function (d, b) {
10729 extendStatics(d, b);
10730 function __() { this.constructor = d; }
10731 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10734 Object.defineProperty(exports, "__esModule", { value: true });
10735 var Subscriber_1 = require("../Subscriber");
10736 function ignoreElements() {
10737 return function ignoreElementsOperatorFunction(source) {
10738 return source.lift(new IgnoreElementsOperator());
10741 exports.ignoreElements = ignoreElements;
10742 var IgnoreElementsOperator = (function () {
10743 function IgnoreElementsOperator() {
10745 IgnoreElementsOperator.prototype.call = function (subscriber, source) {
10746 return source.subscribe(new IgnoreElementsSubscriber(subscriber));
10748 return IgnoreElementsOperator;
10750 var IgnoreElementsSubscriber = (function (_super) {
10751 __extends(IgnoreElementsSubscriber, _super);
10752 function IgnoreElementsSubscriber() {
10753 return _super !== null && _super.apply(this, arguments) || this;
10755 IgnoreElementsSubscriber.prototype._next = function (unused) {
10757 return IgnoreElementsSubscriber;
10758 }(Subscriber_1.Subscriber));
10760 },{"../Subscriber":38}],109:[function(require,module,exports){
10762 var __extends = (this && this.__extends) || (function () {
10763 var extendStatics = function (d, b) {
10764 extendStatics = Object.setPrototypeOf ||
10765 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10766 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10767 return extendStatics(d, b);
10769 return function (d, b) {
10770 extendStatics(d, b);
10771 function __() { this.constructor = d; }
10772 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10775 Object.defineProperty(exports, "__esModule", { value: true });
10776 var Subscriber_1 = require("../Subscriber");
10777 function isEmpty() {
10778 return function (source) { return source.lift(new IsEmptyOperator()); };
10780 exports.isEmpty = isEmpty;
10781 var IsEmptyOperator = (function () {
10782 function IsEmptyOperator() {
10784 IsEmptyOperator.prototype.call = function (observer, source) {
10785 return source.subscribe(new IsEmptySubscriber(observer));
10787 return IsEmptyOperator;
10789 var IsEmptySubscriber = (function (_super) {
10790 __extends(IsEmptySubscriber, _super);
10791 function IsEmptySubscriber(destination) {
10792 return _super.call(this, destination) || this;
10794 IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
10795 var destination = this.destination;
10796 destination.next(isEmpty);
10797 destination.complete();
10799 IsEmptySubscriber.prototype._next = function (value) {
10800 this.notifyComplete(false);
10802 IsEmptySubscriber.prototype._complete = function () {
10803 this.notifyComplete(true);
10805 return IsEmptySubscriber;
10806 }(Subscriber_1.Subscriber));
10808 },{"../Subscriber":38}],110:[function(require,module,exports){
10810 Object.defineProperty(exports, "__esModule", { value: true });
10811 var EmptyError_1 = require("../util/EmptyError");
10812 var filter_1 = require("./filter");
10813 var takeLast_1 = require("./takeLast");
10814 var throwIfEmpty_1 = require("./throwIfEmpty");
10815 var defaultIfEmpty_1 = require("./defaultIfEmpty");
10816 var identity_1 = require("../util/identity");
10817 function last(predicate, defaultValue) {
10818 var hasDefaultValue = arguments.length >= 2;
10819 return function (source) { return source.pipe(predicate ? filter_1.filter(function (v, i) { return predicate(v, i, source); }) : identity_1.identity, takeLast_1.takeLast(1), hasDefaultValue ? defaultIfEmpty_1.defaultIfEmpty(defaultValue) : throwIfEmpty_1.throwIfEmpty(function () { return new EmptyError_1.EmptyError(); })); };
10821 exports.last = last;
10823 },{"../util/EmptyError":193,"../util/identity":201,"./defaultIfEmpty":89,"./filter":102,"./takeLast":155,"./throwIfEmpty":161}],111:[function(require,module,exports){
10825 var __extends = (this && this.__extends) || (function () {
10826 var extendStatics = function (d, b) {
10827 extendStatics = Object.setPrototypeOf ||
10828 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10829 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10830 return extendStatics(d, b);
10832 return function (d, b) {
10833 extendStatics(d, b);
10834 function __() { this.constructor = d; }
10835 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10838 Object.defineProperty(exports, "__esModule", { value: true });
10839 var Subscriber_1 = require("../Subscriber");
10840 function map(project, thisArg) {
10841 return function mapOperation(source) {
10842 if (typeof project !== 'function') {
10843 throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
10845 return source.lift(new MapOperator(project, thisArg));
10849 var MapOperator = (function () {
10850 function MapOperator(project, thisArg) {
10851 this.project = project;
10852 this.thisArg = thisArg;
10854 MapOperator.prototype.call = function (subscriber, source) {
10855 return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
10857 return MapOperator;
10859 exports.MapOperator = MapOperator;
10860 var MapSubscriber = (function (_super) {
10861 __extends(MapSubscriber, _super);
10862 function MapSubscriber(destination, project, thisArg) {
10863 var _this = _super.call(this, destination) || this;
10864 _this.project = project;
10866 _this.thisArg = thisArg || _this;
10869 MapSubscriber.prototype._next = function (value) {
10872 result = this.project.call(this.thisArg, value, this.count++);
10875 this.destination.error(err);
10878 this.destination.next(result);
10880 return MapSubscriber;
10881 }(Subscriber_1.Subscriber));
10883 },{"../Subscriber":38}],112:[function(require,module,exports){
10885 var __extends = (this && this.__extends) || (function () {
10886 var extendStatics = function (d, b) {
10887 extendStatics = Object.setPrototypeOf ||
10888 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10889 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10890 return extendStatics(d, b);
10892 return function (d, b) {
10893 extendStatics(d, b);
10894 function __() { this.constructor = d; }
10895 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10898 Object.defineProperty(exports, "__esModule", { value: true });
10899 var Subscriber_1 = require("../Subscriber");
10900 function mapTo(value) {
10901 return function (source) { return source.lift(new MapToOperator(value)); };
10903 exports.mapTo = mapTo;
10904 var MapToOperator = (function () {
10905 function MapToOperator(value) {
10906 this.value = value;
10908 MapToOperator.prototype.call = function (subscriber, source) {
10909 return source.subscribe(new MapToSubscriber(subscriber, this.value));
10911 return MapToOperator;
10913 var MapToSubscriber = (function (_super) {
10914 __extends(MapToSubscriber, _super);
10915 function MapToSubscriber(destination, value) {
10916 var _this = _super.call(this, destination) || this;
10917 _this.value = value;
10920 MapToSubscriber.prototype._next = function (x) {
10921 this.destination.next(this.value);
10923 return MapToSubscriber;
10924 }(Subscriber_1.Subscriber));
10926 },{"../Subscriber":38}],113:[function(require,module,exports){
10928 var __extends = (this && this.__extends) || (function () {
10929 var extendStatics = function (d, b) {
10930 extendStatics = Object.setPrototypeOf ||
10931 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10932 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10933 return extendStatics(d, b);
10935 return function (d, b) {
10936 extendStatics(d, b);
10937 function __() { this.constructor = d; }
10938 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10941 Object.defineProperty(exports, "__esModule", { value: true });
10942 var Subscriber_1 = require("../Subscriber");
10943 var Notification_1 = require("../Notification");
10944 function materialize() {
10945 return function materializeOperatorFunction(source) {
10946 return source.lift(new MaterializeOperator());
10949 exports.materialize = materialize;
10950 var MaterializeOperator = (function () {
10951 function MaterializeOperator() {
10953 MaterializeOperator.prototype.call = function (subscriber, source) {
10954 return source.subscribe(new MaterializeSubscriber(subscriber));
10956 return MaterializeOperator;
10958 var MaterializeSubscriber = (function (_super) {
10959 __extends(MaterializeSubscriber, _super);
10960 function MaterializeSubscriber(destination) {
10961 return _super.call(this, destination) || this;
10963 MaterializeSubscriber.prototype._next = function (value) {
10964 this.destination.next(Notification_1.Notification.createNext(value));
10966 MaterializeSubscriber.prototype._error = function (err) {
10967 var destination = this.destination;
10968 destination.next(Notification_1.Notification.createError(err));
10969 destination.complete();
10971 MaterializeSubscriber.prototype._complete = function () {
10972 var destination = this.destination;
10973 destination.next(Notification_1.Notification.createComplete());
10974 destination.complete();
10976 return MaterializeSubscriber;
10977 }(Subscriber_1.Subscriber));
10979 },{"../Notification":30,"../Subscriber":38}],114:[function(require,module,exports){
10981 Object.defineProperty(exports, "__esModule", { value: true });
10982 var reduce_1 = require("./reduce");
10983 function max(comparer) {
10984 var max = (typeof comparer === 'function')
10985 ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
10986 : function (x, y) { return x > y ? x : y; };
10987 return reduce_1.reduce(max);
10991 },{"./reduce":132}],115:[function(require,module,exports){
10993 Object.defineProperty(exports, "__esModule", { value: true });
10994 var merge_1 = require("../observable/merge");
10996 var observables = [];
10997 for (var _i = 0; _i < arguments.length; _i++) {
10998 observables[_i] = arguments[_i];
11000 return function (source) { return source.lift.call(merge_1.merge.apply(void 0, [source].concat(observables))); };
11002 exports.merge = merge;
11004 },{"../observable/merge":60}],116:[function(require,module,exports){
11006 Object.defineProperty(exports, "__esModule", { value: true });
11007 var mergeMap_1 = require("./mergeMap");
11008 var identity_1 = require("../util/identity");
11009 function mergeAll(concurrent) {
11010 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
11011 return mergeMap_1.mergeMap(identity_1.identity, concurrent);
11013 exports.mergeAll = mergeAll;
11015 },{"../util/identity":201,"./mergeMap":117}],117:[function(require,module,exports){
11017 var __extends = (this && this.__extends) || (function () {
11018 var extendStatics = function (d, b) {
11019 extendStatics = Object.setPrototypeOf ||
11020 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11021 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11022 return extendStatics(d, b);
11024 return function (d, b) {
11025 extendStatics(d, b);
11026 function __() { this.constructor = d; }
11027 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11030 Object.defineProperty(exports, "__esModule", { value: true });
11031 var subscribeToResult_1 = require("../util/subscribeToResult");
11032 var OuterSubscriber_1 = require("../OuterSubscriber");
11033 var InnerSubscriber_1 = require("../InnerSubscriber");
11034 var map_1 = require("./map");
11035 var from_1 = require("../observable/from");
11036 function mergeMap(project, resultSelector, concurrent) {
11037 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
11038 if (typeof resultSelector === 'function') {
11039 return function (source) { return source.pipe(mergeMap(function (a, i) { return from_1.from(project(a, i)).pipe(map_1.map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };
11041 else if (typeof resultSelector === 'number') {
11042 concurrent = resultSelector;
11044 return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
11046 exports.mergeMap = mergeMap;
11047 var MergeMapOperator = (function () {
11048 function MergeMapOperator(project, concurrent) {
11049 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
11050 this.project = project;
11051 this.concurrent = concurrent;
11053 MergeMapOperator.prototype.call = function (observer, source) {
11054 return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
11056 return MergeMapOperator;
11058 exports.MergeMapOperator = MergeMapOperator;
11059 var MergeMapSubscriber = (function (_super) {
11060 __extends(MergeMapSubscriber, _super);
11061 function MergeMapSubscriber(destination, project, concurrent) {
11062 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
11063 var _this = _super.call(this, destination) || this;
11064 _this.project = project;
11065 _this.concurrent = concurrent;
11066 _this.hasCompleted = false;
11072 MergeMapSubscriber.prototype._next = function (value) {
11073 if (this.active < this.concurrent) {
11074 this._tryNext(value);
11077 this.buffer.push(value);
11080 MergeMapSubscriber.prototype._tryNext = function (value) {
11082 var index = this.index++;
11084 result = this.project(value, index);
11087 this.destination.error(err);
11091 this._innerSub(result, value, index);
11093 MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
11094 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
11095 var destination = this.destination;
11096 destination.add(innerSubscriber);
11097 subscribeToResult_1.subscribeToResult(this, ish, value, index, innerSubscriber);
11099 MergeMapSubscriber.prototype._complete = function () {
11100 this.hasCompleted = true;
11101 if (this.active === 0 && this.buffer.length === 0) {
11102 this.destination.complete();
11104 this.unsubscribe();
11106 MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11107 this.destination.next(innerValue);
11109 MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
11110 var buffer = this.buffer;
11111 this.remove(innerSub);
11113 if (buffer.length > 0) {
11114 this._next(buffer.shift());
11116 else if (this.active === 0 && this.hasCompleted) {
11117 this.destination.complete();
11120 return MergeMapSubscriber;
11121 }(OuterSubscriber_1.OuterSubscriber));
11122 exports.MergeMapSubscriber = MergeMapSubscriber;
11124 },{"../InnerSubscriber":29,"../OuterSubscriber":33,"../observable/from":50,"../util/subscribeToResult":221,"./map":111}],118:[function(require,module,exports){
11126 Object.defineProperty(exports, "__esModule", { value: true });
11127 var mergeMap_1 = require("./mergeMap");
11128 function mergeMapTo(innerObservable, resultSelector, concurrent) {
11129 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
11130 if (typeof resultSelector === 'function') {
11131 return mergeMap_1.mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
11133 if (typeof resultSelector === 'number') {
11134 concurrent = resultSelector;
11136 return mergeMap_1.mergeMap(function () { return innerObservable; }, concurrent);
11138 exports.mergeMapTo = mergeMapTo;
11140 },{"./mergeMap":117}],119:[function(require,module,exports){
11142 var __extends = (this && this.__extends) || (function () {
11143 var extendStatics = function (d, b) {
11144 extendStatics = Object.setPrototypeOf ||
11145 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11146 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11147 return extendStatics(d, b);
11149 return function (d, b) {
11150 extendStatics(d, b);
11151 function __() { this.constructor = d; }
11152 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11155 Object.defineProperty(exports, "__esModule", { value: true });
11156 var tryCatch_1 = require("../util/tryCatch");
11157 var errorObject_1 = require("../util/errorObject");
11158 var subscribeToResult_1 = require("../util/subscribeToResult");
11159 var OuterSubscriber_1 = require("../OuterSubscriber");
11160 var InnerSubscriber_1 = require("../InnerSubscriber");
11161 function mergeScan(accumulator, seed, concurrent) {
11162 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
11163 return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
11165 exports.mergeScan = mergeScan;
11166 var MergeScanOperator = (function () {
11167 function MergeScanOperator(accumulator, seed, concurrent) {
11168 this.accumulator = accumulator;
11170 this.concurrent = concurrent;
11172 MergeScanOperator.prototype.call = function (subscriber, source) {
11173 return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
11175 return MergeScanOperator;
11177 exports.MergeScanOperator = MergeScanOperator;
11178 var MergeScanSubscriber = (function (_super) {
11179 __extends(MergeScanSubscriber, _super);
11180 function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
11181 var _this = _super.call(this, destination) || this;
11182 _this.accumulator = accumulator;
11184 _this.concurrent = concurrent;
11185 _this.hasValue = false;
11186 _this.hasCompleted = false;
11192 MergeScanSubscriber.prototype._next = function (value) {
11193 if (this.active < this.concurrent) {
11194 var index = this.index++;
11195 var ish = tryCatch_1.tryCatch(this.accumulator)(this.acc, value);
11196 var destination = this.destination;
11197 if (ish === errorObject_1.errorObject) {
11198 destination.error(errorObject_1.errorObject.e);
11202 this._innerSub(ish, value, index);
11206 this.buffer.push(value);
11209 MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
11210 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
11211 var destination = this.destination;
11212 destination.add(innerSubscriber);
11213 subscribeToResult_1.subscribeToResult(this, ish, value, index, innerSubscriber);
11215 MergeScanSubscriber.prototype._complete = function () {
11216 this.hasCompleted = true;
11217 if (this.active === 0 && this.buffer.length === 0) {
11218 if (this.hasValue === false) {
11219 this.destination.next(this.acc);
11221 this.destination.complete();
11223 this.unsubscribe();
11225 MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11226 var destination = this.destination;
11227 this.acc = innerValue;
11228 this.hasValue = true;
11229 destination.next(innerValue);
11231 MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
11232 var buffer = this.buffer;
11233 var destination = this.destination;
11234 destination.remove(innerSub);
11236 if (buffer.length > 0) {
11237 this._next(buffer.shift());
11239 else if (this.active === 0 && this.hasCompleted) {
11240 if (this.hasValue === false) {
11241 this.destination.next(this.acc);
11243 this.destination.complete();
11246 return MergeScanSubscriber;
11247 }(OuterSubscriber_1.OuterSubscriber));
11248 exports.MergeScanSubscriber = MergeScanSubscriber;
11250 },{"../InnerSubscriber":29,"../OuterSubscriber":33,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],120:[function(require,module,exports){
11252 Object.defineProperty(exports, "__esModule", { value: true });
11253 var reduce_1 = require("./reduce");
11254 function min(comparer) {
11255 var min = (typeof comparer === 'function')
11256 ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
11257 : function (x, y) { return x < y ? x : y; };
11258 return reduce_1.reduce(min);
11262 },{"./reduce":132}],121:[function(require,module,exports){
11264 Object.defineProperty(exports, "__esModule", { value: true });
11265 var ConnectableObservable_1 = require("../observable/ConnectableObservable");
11266 function multicast(subjectOrSubjectFactory, selector) {
11267 return function multicastOperatorFunction(source) {
11268 var subjectFactory;
11269 if (typeof subjectOrSubjectFactory === 'function') {
11270 subjectFactory = subjectOrSubjectFactory;
11273 subjectFactory = function subjectFactory() {
11274 return subjectOrSubjectFactory;
11277 if (typeof selector === 'function') {
11278 return source.lift(new MulticastOperator(subjectFactory, selector));
11280 var connectable = Object.create(source, ConnectableObservable_1.connectableObservableDescriptor);
11281 connectable.source = source;
11282 connectable.subjectFactory = subjectFactory;
11283 return connectable;
11286 exports.multicast = multicast;
11287 var MulticastOperator = (function () {
11288 function MulticastOperator(subjectFactory, selector) {
11289 this.subjectFactory = subjectFactory;
11290 this.selector = selector;
11292 MulticastOperator.prototype.call = function (subscriber, source) {
11293 var selector = this.selector;
11294 var subject = this.subjectFactory();
11295 var subscription = selector(subject).subscribe(subscriber);
11296 subscription.add(source.subscribe(subject));
11297 return subscription;
11299 return MulticastOperator;
11301 exports.MulticastOperator = MulticastOperator;
11303 },{"../observable/ConnectableObservable":41}],122:[function(require,module,exports){
11305 var __extends = (this && this.__extends) || (function () {
11306 var extendStatics = function (d, b) {
11307 extendStatics = Object.setPrototypeOf ||
11308 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11309 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11310 return extendStatics(d, b);
11312 return function (d, b) {
11313 extendStatics(d, b);
11314 function __() { this.constructor = d; }
11315 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11318 Object.defineProperty(exports, "__esModule", { value: true });
11319 var Subscriber_1 = require("../Subscriber");
11320 var Notification_1 = require("../Notification");
11321 function observeOn(scheduler, delay) {
11322 if (delay === void 0) { delay = 0; }
11323 return function observeOnOperatorFunction(source) {
11324 return source.lift(new ObserveOnOperator(scheduler, delay));
11327 exports.observeOn = observeOn;
11328 var ObserveOnOperator = (function () {
11329 function ObserveOnOperator(scheduler, delay) {
11330 if (delay === void 0) { delay = 0; }
11331 this.scheduler = scheduler;
11332 this.delay = delay;
11334 ObserveOnOperator.prototype.call = function (subscriber, source) {
11335 return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
11337 return ObserveOnOperator;
11339 exports.ObserveOnOperator = ObserveOnOperator;
11340 var ObserveOnSubscriber = (function (_super) {
11341 __extends(ObserveOnSubscriber, _super);
11342 function ObserveOnSubscriber(destination, scheduler, delay) {
11343 if (delay === void 0) { delay = 0; }
11344 var _this = _super.call(this, destination) || this;
11345 _this.scheduler = scheduler;
11346 _this.delay = delay;
11349 ObserveOnSubscriber.dispatch = function (arg) {
11350 var notification = arg.notification, destination = arg.destination;
11351 notification.observe(destination);
11352 this.unsubscribe();
11354 ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
11355 var destination = this.destination;
11356 destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
11358 ObserveOnSubscriber.prototype._next = function (value) {
11359 this.scheduleMessage(Notification_1.Notification.createNext(value));
11361 ObserveOnSubscriber.prototype._error = function (err) {
11362 this.scheduleMessage(Notification_1.Notification.createError(err));
11363 this.unsubscribe();
11365 ObserveOnSubscriber.prototype._complete = function () {
11366 this.scheduleMessage(Notification_1.Notification.createComplete());
11367 this.unsubscribe();
11369 return ObserveOnSubscriber;
11370 }(Subscriber_1.Subscriber));
11371 exports.ObserveOnSubscriber = ObserveOnSubscriber;
11372 var ObserveOnMessage = (function () {
11373 function ObserveOnMessage(notification, destination) {
11374 this.notification = notification;
11375 this.destination = destination;
11377 return ObserveOnMessage;
11379 exports.ObserveOnMessage = ObserveOnMessage;
11381 },{"../Notification":30,"../Subscriber":38}],123:[function(require,module,exports){
11383 var __extends = (this && this.__extends) || (function () {
11384 var extendStatics = function (d, b) {
11385 extendStatics = Object.setPrototypeOf ||
11386 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11387 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11388 return extendStatics(d, b);
11390 return function (d, b) {
11391 extendStatics(d, b);
11392 function __() { this.constructor = d; }
11393 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11396 Object.defineProperty(exports, "__esModule", { value: true });
11397 var from_1 = require("../observable/from");
11398 var isArray_1 = require("../util/isArray");
11399 var OuterSubscriber_1 = require("../OuterSubscriber");
11400 var InnerSubscriber_1 = require("../InnerSubscriber");
11401 var subscribeToResult_1 = require("../util/subscribeToResult");
11402 function onErrorResumeNext() {
11403 var nextSources = [];
11404 for (var _i = 0; _i < arguments.length; _i++) {
11405 nextSources[_i] = arguments[_i];
11407 if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) {
11408 nextSources = nextSources[0];
11410 return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
11412 exports.onErrorResumeNext = onErrorResumeNext;
11413 function onErrorResumeNextStatic() {
11414 var nextSources = [];
11415 for (var _i = 0; _i < arguments.length; _i++) {
11416 nextSources[_i] = arguments[_i];
11419 if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) {
11420 nextSources = nextSources[0];
11422 source = nextSources.shift();
11423 return from_1.from(source, null).lift(new OnErrorResumeNextOperator(nextSources));
11425 exports.onErrorResumeNextStatic = onErrorResumeNextStatic;
11426 var OnErrorResumeNextOperator = (function () {
11427 function OnErrorResumeNextOperator(nextSources) {
11428 this.nextSources = nextSources;
11430 OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
11431 return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
11433 return OnErrorResumeNextOperator;
11435 var OnErrorResumeNextSubscriber = (function (_super) {
11436 __extends(OnErrorResumeNextSubscriber, _super);
11437 function OnErrorResumeNextSubscriber(destination, nextSources) {
11438 var _this = _super.call(this, destination) || this;
11439 _this.destination = destination;
11440 _this.nextSources = nextSources;
11443 OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) {
11444 this.subscribeToNextSource();
11446 OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) {
11447 this.subscribeToNextSource();
11449 OnErrorResumeNextSubscriber.prototype._error = function (err) {
11450 this.subscribeToNextSource();
11451 this.unsubscribe();
11453 OnErrorResumeNextSubscriber.prototype._complete = function () {
11454 this.subscribeToNextSource();
11455 this.unsubscribe();
11457 OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
11458 var next = this.nextSources.shift();
11460 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
11461 var destination = this.destination;
11462 destination.add(innerSubscriber);
11463 subscribeToResult_1.subscribeToResult(this, next, undefined, undefined, innerSubscriber);
11466 this.destination.complete();
11469 return OnErrorResumeNextSubscriber;
11470 }(OuterSubscriber_1.OuterSubscriber));
11472 },{"../InnerSubscriber":29,"../OuterSubscriber":33,"../observable/from":50,"../util/isArray":202,"../util/subscribeToResult":221}],124:[function(require,module,exports){
11474 var __extends = (this && this.__extends) || (function () {
11475 var extendStatics = function (d, b) {
11476 extendStatics = Object.setPrototypeOf ||
11477 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11478 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11479 return extendStatics(d, b);
11481 return function (d, b) {
11482 extendStatics(d, b);
11483 function __() { this.constructor = d; }
11484 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11487 Object.defineProperty(exports, "__esModule", { value: true });
11488 var Subscriber_1 = require("../Subscriber");
11489 function pairwise() {
11490 return function (source) { return source.lift(new PairwiseOperator()); };
11492 exports.pairwise = pairwise;
11493 var PairwiseOperator = (function () {
11494 function PairwiseOperator() {
11496 PairwiseOperator.prototype.call = function (subscriber, source) {
11497 return source.subscribe(new PairwiseSubscriber(subscriber));
11499 return PairwiseOperator;
11501 var PairwiseSubscriber = (function (_super) {
11502 __extends(PairwiseSubscriber, _super);
11503 function PairwiseSubscriber(destination) {
11504 var _this = _super.call(this, destination) || this;
11505 _this.hasPrev = false;
11508 PairwiseSubscriber.prototype._next = function (value) {
11509 if (this.hasPrev) {
11510 this.destination.next([this.prev, value]);
11513 this.hasPrev = true;
11517 return PairwiseSubscriber;
11518 }(Subscriber_1.Subscriber));
11520 },{"../Subscriber":38}],125:[function(require,module,exports){
11522 Object.defineProperty(exports, "__esModule", { value: true });
11523 var not_1 = require("../util/not");
11524 var filter_1 = require("./filter");
11525 function partition(predicate, thisArg) {
11526 return function (source) { return [
11527 filter_1.filter(predicate, thisArg)(source),
11528 filter_1.filter(not_1.not(predicate, thisArg))(source)
11531 exports.partition = partition;
11533 },{"../util/not":214,"./filter":102}],126:[function(require,module,exports){
11535 Object.defineProperty(exports, "__esModule", { value: true });
11536 var map_1 = require("./map");
11538 var properties = [];
11539 for (var _i = 0; _i < arguments.length; _i++) {
11540 properties[_i] = arguments[_i];
11542 var length = properties.length;
11543 if (length === 0) {
11544 throw new Error('list of properties cannot be empty.');
11546 return function (source) { return map_1.map(plucker(properties, length))(source); };
11548 exports.pluck = pluck;
11549 function plucker(props, length) {
11550 var mapper = function (x) {
11551 var currentProp = x;
11552 for (var i = 0; i < length; i++) {
11553 var p = currentProp[props[i]];
11554 if (typeof p !== 'undefined') {
11561 return currentProp;
11566 },{"./map":111}],127:[function(require,module,exports){
11568 Object.defineProperty(exports, "__esModule", { value: true });
11569 var Subject_1 = require("../Subject");
11570 var multicast_1 = require("./multicast");
11571 function publish(selector) {
11573 multicast_1.multicast(function () { return new Subject_1.Subject(); }, selector) :
11574 multicast_1.multicast(new Subject_1.Subject());
11576 exports.publish = publish;
11578 },{"../Subject":36,"./multicast":121}],128:[function(require,module,exports){
11580 Object.defineProperty(exports, "__esModule", { value: true });
11581 var BehaviorSubject_1 = require("../BehaviorSubject");
11582 var multicast_1 = require("./multicast");
11583 function publishBehavior(value) {
11584 return function (source) { return multicast_1.multicast(new BehaviorSubject_1.BehaviorSubject(value))(source); };
11586 exports.publishBehavior = publishBehavior;
11588 },{"../BehaviorSubject":28,"./multicast":121}],129:[function(require,module,exports){
11590 Object.defineProperty(exports, "__esModule", { value: true });
11591 var AsyncSubject_1 = require("../AsyncSubject");
11592 var multicast_1 = require("./multicast");
11593 function publishLast() {
11594 return function (source) { return multicast_1.multicast(new AsyncSubject_1.AsyncSubject())(source); };
11596 exports.publishLast = publishLast;
11598 },{"../AsyncSubject":27,"./multicast":121}],130:[function(require,module,exports){
11600 Object.defineProperty(exports, "__esModule", { value: true });
11601 var ReplaySubject_1 = require("../ReplaySubject");
11602 var multicast_1 = require("./multicast");
11603 function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
11604 if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
11605 scheduler = selectorOrScheduler;
11607 var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
11608 var subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler);
11609 return function (source) { return multicast_1.multicast(function () { return subject; }, selector)(source); };
11611 exports.publishReplay = publishReplay;
11613 },{"../ReplaySubject":34,"./multicast":121}],131:[function(require,module,exports){
11615 Object.defineProperty(exports, "__esModule", { value: true });
11616 var isArray_1 = require("../util/isArray");
11617 var race_1 = require("../observable/race");
11619 var observables = [];
11620 for (var _i = 0; _i < arguments.length; _i++) {
11621 observables[_i] = arguments[_i];
11623 return function raceOperatorFunction(source) {
11624 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
11625 observables = observables[0];
11627 return source.lift.call(race_1.race.apply(void 0, [source].concat(observables)));
11630 exports.race = race;
11632 },{"../observable/race":65,"../util/isArray":202}],132:[function(require,module,exports){
11634 Object.defineProperty(exports, "__esModule", { value: true });
11635 var scan_1 = require("./scan");
11636 var takeLast_1 = require("./takeLast");
11637 var defaultIfEmpty_1 = require("./defaultIfEmpty");
11638 var pipe_1 = require("../util/pipe");
11639 function reduce(accumulator, seed) {
11640 if (arguments.length >= 2) {
11641 return function reduceOperatorFunctionWithSeed(source) {
11642 return pipe_1.pipe(scan_1.scan(accumulator, seed), takeLast_1.takeLast(1), defaultIfEmpty_1.defaultIfEmpty(seed))(source);
11645 return function reduceOperatorFunction(source) {
11646 return pipe_1.pipe(scan_1.scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast_1.takeLast(1))(source);
11649 exports.reduce = reduce;
11651 },{"../util/pipe":215,"./defaultIfEmpty":89,"./scan":140,"./takeLast":155}],133:[function(require,module,exports){
11653 var __extends = (this && this.__extends) || (function () {
11654 var extendStatics = function (d, b) {
11655 extendStatics = Object.setPrototypeOf ||
11656 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11657 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11658 return extendStatics(d, b);
11660 return function (d, b) {
11661 extendStatics(d, b);
11662 function __() { this.constructor = d; }
11663 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11666 Object.defineProperty(exports, "__esModule", { value: true });
11667 var Subscriber_1 = require("../Subscriber");
11668 function refCount() {
11669 return function refCountOperatorFunction(source) {
11670 return source.lift(new RefCountOperator(source));
11673 exports.refCount = refCount;
11674 var RefCountOperator = (function () {
11675 function RefCountOperator(connectable) {
11676 this.connectable = connectable;
11678 RefCountOperator.prototype.call = function (subscriber, source) {
11679 var connectable = this.connectable;
11680 connectable._refCount++;
11681 var refCounter = new RefCountSubscriber(subscriber, connectable);
11682 var subscription = source.subscribe(refCounter);
11683 if (!refCounter.closed) {
11684 refCounter.connection = connectable.connect();
11686 return subscription;
11688 return RefCountOperator;
11690 var RefCountSubscriber = (function (_super) {
11691 __extends(RefCountSubscriber, _super);
11692 function RefCountSubscriber(destination, connectable) {
11693 var _this = _super.call(this, destination) || this;
11694 _this.connectable = connectable;
11697 RefCountSubscriber.prototype._unsubscribe = function () {
11698 var connectable = this.connectable;
11699 if (!connectable) {
11700 this.connection = null;
11703 this.connectable = null;
11704 var refCount = connectable._refCount;
11705 if (refCount <= 0) {
11706 this.connection = null;
11709 connectable._refCount = refCount - 1;
11710 if (refCount > 1) {
11711 this.connection = null;
11714 var connection = this.connection;
11715 var sharedConnection = connectable._connection;
11716 this.connection = null;
11717 if (sharedConnection && (!connection || sharedConnection === connection)) {
11718 sharedConnection.unsubscribe();
11721 return RefCountSubscriber;
11722 }(Subscriber_1.Subscriber));
11724 },{"../Subscriber":38}],134:[function(require,module,exports){
11726 var __extends = (this && this.__extends) || (function () {
11727 var extendStatics = function (d, b) {
11728 extendStatics = Object.setPrototypeOf ||
11729 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11730 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11731 return extendStatics(d, b);
11733 return function (d, b) {
11734 extendStatics(d, b);
11735 function __() { this.constructor = d; }
11736 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11739 Object.defineProperty(exports, "__esModule", { value: true });
11740 var Subscriber_1 = require("../Subscriber");
11741 var empty_1 = require("../observable/empty");
11742 function repeat(count) {
11743 if (count === void 0) { count = -1; }
11744 return function (source) {
11746 return empty_1.empty();
11748 else if (count < 0) {
11749 return source.lift(new RepeatOperator(-1, source));
11752 return source.lift(new RepeatOperator(count - 1, source));
11756 exports.repeat = repeat;
11757 var RepeatOperator = (function () {
11758 function RepeatOperator(count, source) {
11759 this.count = count;
11760 this.source = source;
11762 RepeatOperator.prototype.call = function (subscriber, source) {
11763 return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
11765 return RepeatOperator;
11767 var RepeatSubscriber = (function (_super) {
11768 __extends(RepeatSubscriber, _super);
11769 function RepeatSubscriber(destination, count, source) {
11770 var _this = _super.call(this, destination) || this;
11771 _this.count = count;
11772 _this.source = source;
11775 RepeatSubscriber.prototype.complete = function () {
11776 if (!this.isStopped) {
11777 var _a = this, source = _a.source, count = _a.count;
11779 return _super.prototype.complete.call(this);
11781 else if (count > -1) {
11782 this.count = count - 1;
11784 source.subscribe(this._unsubscribeAndRecycle());
11787 return RepeatSubscriber;
11788 }(Subscriber_1.Subscriber));
11790 },{"../Subscriber":38,"../observable/empty":48}],135:[function(require,module,exports){
11792 var __extends = (this && this.__extends) || (function () {
11793 var extendStatics = function (d, b) {
11794 extendStatics = Object.setPrototypeOf ||
11795 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11796 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11797 return extendStatics(d, b);
11799 return function (d, b) {
11800 extendStatics(d, b);
11801 function __() { this.constructor = d; }
11802 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11805 Object.defineProperty(exports, "__esModule", { value: true });
11806 var Subject_1 = require("../Subject");
11807 var tryCatch_1 = require("../util/tryCatch");
11808 var errorObject_1 = require("../util/errorObject");
11809 var OuterSubscriber_1 = require("../OuterSubscriber");
11810 var subscribeToResult_1 = require("../util/subscribeToResult");
11811 function repeatWhen(notifier) {
11812 return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
11814 exports.repeatWhen = repeatWhen;
11815 var RepeatWhenOperator = (function () {
11816 function RepeatWhenOperator(notifier) {
11817 this.notifier = notifier;
11819 RepeatWhenOperator.prototype.call = function (subscriber, source) {
11820 return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
11822 return RepeatWhenOperator;
11824 var RepeatWhenSubscriber = (function (_super) {
11825 __extends(RepeatWhenSubscriber, _super);
11826 function RepeatWhenSubscriber(destination, notifier, source) {
11827 var _this = _super.call(this, destination) || this;
11828 _this.notifier = notifier;
11829 _this.source = source;
11830 _this.sourceIsBeingSubscribedTo = true;
11833 RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11834 this.sourceIsBeingSubscribedTo = true;
11835 this.source.subscribe(this);
11837 RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) {
11838 if (this.sourceIsBeingSubscribedTo === false) {
11839 return _super.prototype.complete.call(this);
11842 RepeatWhenSubscriber.prototype.complete = function () {
11843 this.sourceIsBeingSubscribedTo = false;
11844 if (!this.isStopped) {
11845 if (!this.retries) {
11846 this.subscribeToRetries();
11848 if (!this.retriesSubscription || this.retriesSubscription.closed) {
11849 return _super.prototype.complete.call(this);
11851 this._unsubscribeAndRecycle();
11852 this.notifications.next();
11855 RepeatWhenSubscriber.prototype._unsubscribe = function () {
11856 var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
11857 if (notifications) {
11858 notifications.unsubscribe();
11859 this.notifications = null;
11861 if (retriesSubscription) {
11862 retriesSubscription.unsubscribe();
11863 this.retriesSubscription = null;
11865 this.retries = null;
11867 RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
11868 var _unsubscribe = this._unsubscribe;
11869 this._unsubscribe = null;
11870 _super.prototype._unsubscribeAndRecycle.call(this);
11871 this._unsubscribe = _unsubscribe;
11874 RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
11875 this.notifications = new Subject_1.Subject();
11876 var retries = tryCatch_1.tryCatch(this.notifier)(this.notifications);
11877 if (retries === errorObject_1.errorObject) {
11878 return _super.prototype.complete.call(this);
11880 this.retries = retries;
11881 this.retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries);
11883 return RepeatWhenSubscriber;
11884 }(OuterSubscriber_1.OuterSubscriber));
11886 },{"../OuterSubscriber":33,"../Subject":36,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],136:[function(require,module,exports){
11888 var __extends = (this && this.__extends) || (function () {
11889 var extendStatics = function (d, b) {
11890 extendStatics = Object.setPrototypeOf ||
11891 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11892 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11893 return extendStatics(d, b);
11895 return function (d, b) {
11896 extendStatics(d, b);
11897 function __() { this.constructor = d; }
11898 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11901 Object.defineProperty(exports, "__esModule", { value: true });
11902 var Subscriber_1 = require("../Subscriber");
11903 function retry(count) {
11904 if (count === void 0) { count = -1; }
11905 return function (source) { return source.lift(new RetryOperator(count, source)); };
11907 exports.retry = retry;
11908 var RetryOperator = (function () {
11909 function RetryOperator(count, source) {
11910 this.count = count;
11911 this.source = source;
11913 RetryOperator.prototype.call = function (subscriber, source) {
11914 return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
11916 return RetryOperator;
11918 var RetrySubscriber = (function (_super) {
11919 __extends(RetrySubscriber, _super);
11920 function RetrySubscriber(destination, count, source) {
11921 var _this = _super.call(this, destination) || this;
11922 _this.count = count;
11923 _this.source = source;
11926 RetrySubscriber.prototype.error = function (err) {
11927 if (!this.isStopped) {
11928 var _a = this, source = _a.source, count = _a.count;
11930 return _super.prototype.error.call(this, err);
11932 else if (count > -1) {
11933 this.count = count - 1;
11935 source.subscribe(this._unsubscribeAndRecycle());
11938 return RetrySubscriber;
11939 }(Subscriber_1.Subscriber));
11941 },{"../Subscriber":38}],137:[function(require,module,exports){
11943 var __extends = (this && this.__extends) || (function () {
11944 var extendStatics = function (d, b) {
11945 extendStatics = Object.setPrototypeOf ||
11946 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11947 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11948 return extendStatics(d, b);
11950 return function (d, b) {
11951 extendStatics(d, b);
11952 function __() { this.constructor = d; }
11953 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11956 Object.defineProperty(exports, "__esModule", { value: true });
11957 var Subject_1 = require("../Subject");
11958 var tryCatch_1 = require("../util/tryCatch");
11959 var errorObject_1 = require("../util/errorObject");
11960 var OuterSubscriber_1 = require("../OuterSubscriber");
11961 var subscribeToResult_1 = require("../util/subscribeToResult");
11962 function retryWhen(notifier) {
11963 return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
11965 exports.retryWhen = retryWhen;
11966 var RetryWhenOperator = (function () {
11967 function RetryWhenOperator(notifier, source) {
11968 this.notifier = notifier;
11969 this.source = source;
11971 RetryWhenOperator.prototype.call = function (subscriber, source) {
11972 return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
11974 return RetryWhenOperator;
11976 var RetryWhenSubscriber = (function (_super) {
11977 __extends(RetryWhenSubscriber, _super);
11978 function RetryWhenSubscriber(destination, notifier, source) {
11979 var _this = _super.call(this, destination) || this;
11980 _this.notifier = notifier;
11981 _this.source = source;
11984 RetryWhenSubscriber.prototype.error = function (err) {
11985 if (!this.isStopped) {
11986 var errors = this.errors;
11987 var retries = this.retries;
11988 var retriesSubscription = this.retriesSubscription;
11990 errors = new Subject_1.Subject();
11991 retries = tryCatch_1.tryCatch(this.notifier)(errors);
11992 if (retries === errorObject_1.errorObject) {
11993 return _super.prototype.error.call(this, errorObject_1.errorObject.e);
11995 retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries);
11998 this.errors = null;
11999 this.retriesSubscription = null;
12001 this._unsubscribeAndRecycle();
12002 this.errors = errors;
12003 this.retries = retries;
12004 this.retriesSubscription = retriesSubscription;
12008 RetryWhenSubscriber.prototype._unsubscribe = function () {
12009 var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
12011 errors.unsubscribe();
12012 this.errors = null;
12014 if (retriesSubscription) {
12015 retriesSubscription.unsubscribe();
12016 this.retriesSubscription = null;
12018 this.retries = null;
12020 RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
12021 var _unsubscribe = this._unsubscribe;
12022 this._unsubscribe = null;
12023 this._unsubscribeAndRecycle();
12024 this._unsubscribe = _unsubscribe;
12025 this.source.subscribe(this);
12027 return RetryWhenSubscriber;
12028 }(OuterSubscriber_1.OuterSubscriber));
12030 },{"../OuterSubscriber":33,"../Subject":36,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],138:[function(require,module,exports){
12032 var __extends = (this && this.__extends) || (function () {
12033 var extendStatics = function (d, b) {
12034 extendStatics = Object.setPrototypeOf ||
12035 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12036 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12037 return extendStatics(d, b);
12039 return function (d, b) {
12040 extendStatics(d, b);
12041 function __() { this.constructor = d; }
12042 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12045 Object.defineProperty(exports, "__esModule", { value: true });
12046 var OuterSubscriber_1 = require("../OuterSubscriber");
12047 var subscribeToResult_1 = require("../util/subscribeToResult");
12048 function sample(notifier) {
12049 return function (source) { return source.lift(new SampleOperator(notifier)); };
12051 exports.sample = sample;
12052 var SampleOperator = (function () {
12053 function SampleOperator(notifier) {
12054 this.notifier = notifier;
12056 SampleOperator.prototype.call = function (subscriber, source) {
12057 var sampleSubscriber = new SampleSubscriber(subscriber);
12058 var subscription = source.subscribe(sampleSubscriber);
12059 subscription.add(subscribeToResult_1.subscribeToResult(sampleSubscriber, this.notifier));
12060 return subscription;
12062 return SampleOperator;
12064 var SampleSubscriber = (function (_super) {
12065 __extends(SampleSubscriber, _super);
12066 function SampleSubscriber() {
12067 var _this = _super !== null && _super.apply(this, arguments) || this;
12068 _this.hasValue = false;
12071 SampleSubscriber.prototype._next = function (value) {
12072 this.value = value;
12073 this.hasValue = true;
12075 SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
12078 SampleSubscriber.prototype.notifyComplete = function () {
12081 SampleSubscriber.prototype.emitValue = function () {
12082 if (this.hasValue) {
12083 this.hasValue = false;
12084 this.destination.next(this.value);
12087 return SampleSubscriber;
12088 }(OuterSubscriber_1.OuterSubscriber));
12090 },{"../OuterSubscriber":33,"../util/subscribeToResult":221}],139:[function(require,module,exports){
12092 var __extends = (this && this.__extends) || (function () {
12093 var extendStatics = function (d, b) {
12094 extendStatics = Object.setPrototypeOf ||
12095 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12096 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12097 return extendStatics(d, b);
12099 return function (d, b) {
12100 extendStatics(d, b);
12101 function __() { this.constructor = d; }
12102 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12105 Object.defineProperty(exports, "__esModule", { value: true });
12106 var Subscriber_1 = require("../Subscriber");
12107 var async_1 = require("../scheduler/async");
12108 function sampleTime(period, scheduler) {
12109 if (scheduler === void 0) { scheduler = async_1.async; }
12110 return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
12112 exports.sampleTime = sampleTime;
12113 var SampleTimeOperator = (function () {
12114 function SampleTimeOperator(period, scheduler) {
12115 this.period = period;
12116 this.scheduler = scheduler;
12118 SampleTimeOperator.prototype.call = function (subscriber, source) {
12119 return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
12121 return SampleTimeOperator;
12123 var SampleTimeSubscriber = (function (_super) {
12124 __extends(SampleTimeSubscriber, _super);
12125 function SampleTimeSubscriber(destination, period, scheduler) {
12126 var _this = _super.call(this, destination) || this;
12127 _this.period = period;
12128 _this.scheduler = scheduler;
12129 _this.hasValue = false;
12130 _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
12133 SampleTimeSubscriber.prototype._next = function (value) {
12134 this.lastValue = value;
12135 this.hasValue = true;
12137 SampleTimeSubscriber.prototype.notifyNext = function () {
12138 if (this.hasValue) {
12139 this.hasValue = false;
12140 this.destination.next(this.lastValue);
12143 return SampleTimeSubscriber;
12144 }(Subscriber_1.Subscriber));
12145 function dispatchNotification(state) {
12146 var subscriber = state.subscriber, period = state.period;
12147 subscriber.notifyNext();
12148 this.schedule(state, period);
12151 },{"../Subscriber":38,"../scheduler/async":187}],140:[function(require,module,exports){
12153 var __extends = (this && this.__extends) || (function () {
12154 var extendStatics = function (d, b) {
12155 extendStatics = Object.setPrototypeOf ||
12156 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12157 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12158 return extendStatics(d, b);
12160 return function (d, b) {
12161 extendStatics(d, b);
12162 function __() { this.constructor = d; }
12163 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12166 Object.defineProperty(exports, "__esModule", { value: true });
12167 var Subscriber_1 = require("../Subscriber");
12168 function scan(accumulator, seed) {
12169 var hasSeed = false;
12170 if (arguments.length >= 2) {
12173 return function scanOperatorFunction(source) {
12174 return source.lift(new ScanOperator(accumulator, seed, hasSeed));
12177 exports.scan = scan;
12178 var ScanOperator = (function () {
12179 function ScanOperator(accumulator, seed, hasSeed) {
12180 if (hasSeed === void 0) { hasSeed = false; }
12181 this.accumulator = accumulator;
12183 this.hasSeed = hasSeed;
12185 ScanOperator.prototype.call = function (subscriber, source) {
12186 return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
12188 return ScanOperator;
12190 var ScanSubscriber = (function (_super) {
12191 __extends(ScanSubscriber, _super);
12192 function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
12193 var _this = _super.call(this, destination) || this;
12194 _this.accumulator = accumulator;
12195 _this._seed = _seed;
12196 _this.hasSeed = hasSeed;
12200 Object.defineProperty(ScanSubscriber.prototype, "seed", {
12204 set: function (value) {
12205 this.hasSeed = true;
12206 this._seed = value;
12211 ScanSubscriber.prototype._next = function (value) {
12212 if (!this.hasSeed) {
12214 this.destination.next(value);
12217 return this._tryNext(value);
12220 ScanSubscriber.prototype._tryNext = function (value) {
12221 var index = this.index++;
12224 result = this.accumulator(this.seed, value, index);
12227 this.destination.error(err);
12229 this.seed = result;
12230 this.destination.next(result);
12232 return ScanSubscriber;
12233 }(Subscriber_1.Subscriber));
12235 },{"../Subscriber":38}],141:[function(require,module,exports){
12237 var __extends = (this && this.__extends) || (function () {
12238 var extendStatics = function (d, b) {
12239 extendStatics = Object.setPrototypeOf ||
12240 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12241 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12242 return extendStatics(d, b);
12244 return function (d, b) {
12245 extendStatics(d, b);
12246 function __() { this.constructor = d; }
12247 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12250 Object.defineProperty(exports, "__esModule", { value: true });
12251 var Subscriber_1 = require("../Subscriber");
12252 var tryCatch_1 = require("../util/tryCatch");
12253 var errorObject_1 = require("../util/errorObject");
12254 function sequenceEqual(compareTo, comparor) {
12255 return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparor)); };
12257 exports.sequenceEqual = sequenceEqual;
12258 var SequenceEqualOperator = (function () {
12259 function SequenceEqualOperator(compareTo, comparor) {
12260 this.compareTo = compareTo;
12261 this.comparor = comparor;
12263 SequenceEqualOperator.prototype.call = function (subscriber, source) {
12264 return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparor));
12266 return SequenceEqualOperator;
12268 exports.SequenceEqualOperator = SequenceEqualOperator;
12269 var SequenceEqualSubscriber = (function (_super) {
12270 __extends(SequenceEqualSubscriber, _super);
12271 function SequenceEqualSubscriber(destination, compareTo, comparor) {
12272 var _this = _super.call(this, destination) || this;
12273 _this.compareTo = compareTo;
12274 _this.comparor = comparor;
12277 _this._oneComplete = false;
12278 _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
12281 SequenceEqualSubscriber.prototype._next = function (value) {
12282 if (this._oneComplete && this._b.length === 0) {
12286 this._a.push(value);
12287 this.checkValues();
12290 SequenceEqualSubscriber.prototype._complete = function () {
12291 if (this._oneComplete) {
12292 this.emit(this._a.length === 0 && this._b.length === 0);
12295 this._oneComplete = true;
12297 this.unsubscribe();
12299 SequenceEqualSubscriber.prototype.checkValues = function () {
12300 var _c = this, _a = _c._a, _b = _c._b, comparor = _c.comparor;
12301 while (_a.length > 0 && _b.length > 0) {
12302 var a = _a.shift();
12303 var b = _b.shift();
12304 var areEqual = false;
12306 areEqual = tryCatch_1.tryCatch(comparor)(a, b);
12307 if (areEqual === errorObject_1.errorObject) {
12308 this.destination.error(errorObject_1.errorObject.e);
12312 areEqual = a === b;
12319 SequenceEqualSubscriber.prototype.emit = function (value) {
12320 var destination = this.destination;
12321 destination.next(value);
12322 destination.complete();
12324 SequenceEqualSubscriber.prototype.nextB = function (value) {
12325 if (this._oneComplete && this._a.length === 0) {
12329 this._b.push(value);
12330 this.checkValues();
12333 SequenceEqualSubscriber.prototype.completeB = function () {
12334 if (this._oneComplete) {
12335 this.emit(this._a.length === 0 && this._b.length === 0);
12338 this._oneComplete = true;
12341 return SequenceEqualSubscriber;
12342 }(Subscriber_1.Subscriber));
12343 exports.SequenceEqualSubscriber = SequenceEqualSubscriber;
12344 var SequenceEqualCompareToSubscriber = (function (_super) {
12345 __extends(SequenceEqualCompareToSubscriber, _super);
12346 function SequenceEqualCompareToSubscriber(destination, parent) {
12347 var _this = _super.call(this, destination) || this;
12348 _this.parent = parent;
12351 SequenceEqualCompareToSubscriber.prototype._next = function (value) {
12352 this.parent.nextB(value);
12354 SequenceEqualCompareToSubscriber.prototype._error = function (err) {
12355 this.parent.error(err);
12356 this.unsubscribe();
12358 SequenceEqualCompareToSubscriber.prototype._complete = function () {
12359 this.parent.completeB();
12360 this.unsubscribe();
12362 return SequenceEqualCompareToSubscriber;
12363 }(Subscriber_1.Subscriber));
12365 },{"../Subscriber":38,"../util/errorObject":199,"../util/tryCatch":223}],142:[function(require,module,exports){
12367 Object.defineProperty(exports, "__esModule", { value: true });
12368 var multicast_1 = require("./multicast");
12369 var refCount_1 = require("./refCount");
12370 var Subject_1 = require("../Subject");
12371 function shareSubjectFactory() {
12372 return new Subject_1.Subject();
12375 return function (source) { return refCount_1.refCount()(multicast_1.multicast(shareSubjectFactory)(source)); };
12377 exports.share = share;
12379 },{"../Subject":36,"./multicast":121,"./refCount":133}],143:[function(require,module,exports){
12381 Object.defineProperty(exports, "__esModule", { value: true });
12382 var ReplaySubject_1 = require("../ReplaySubject");
12383 function shareReplay(bufferSize, windowTime, scheduler) {
12384 if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
12385 if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
12386 return function (source) { return source.lift(shareReplayOperator(bufferSize, windowTime, scheduler)); };
12388 exports.shareReplay = shareReplay;
12389 function shareReplayOperator(bufferSize, windowTime, scheduler) {
12393 var hasError = false;
12394 var isComplete = false;
12395 return function shareReplayOperation(source) {
12397 if (!subject || hasError) {
12399 subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler);
12400 subscription = source.subscribe({
12401 next: function (value) { subject.next(value); },
12402 error: function (err) {
12404 subject.error(err);
12406 complete: function () {
12408 subject.complete();
12412 var innerSub = subject.subscribe(this);
12413 return function () {
12415 innerSub.unsubscribe();
12416 if (subscription && refCount === 0 && isComplete) {
12417 subscription.unsubscribe();
12423 },{"../ReplaySubject":34}],144:[function(require,module,exports){
12425 var __extends = (this && this.__extends) || (function () {
12426 var extendStatics = function (d, b) {
12427 extendStatics = Object.setPrototypeOf ||
12428 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12429 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12430 return extendStatics(d, b);
12432 return function (d, b) {
12433 extendStatics(d, b);
12434 function __() { this.constructor = d; }
12435 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12438 Object.defineProperty(exports, "__esModule", { value: true });
12439 var Subscriber_1 = require("../Subscriber");
12440 var EmptyError_1 = require("../util/EmptyError");
12441 function single(predicate) {
12442 return function (source) { return source.lift(new SingleOperator(predicate, source)); };
12444 exports.single = single;
12445 var SingleOperator = (function () {
12446 function SingleOperator(predicate, source) {
12447 this.predicate = predicate;
12448 this.source = source;
12450 SingleOperator.prototype.call = function (subscriber, source) {
12451 return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source));
12453 return SingleOperator;
12455 var SingleSubscriber = (function (_super) {
12456 __extends(SingleSubscriber, _super);
12457 function SingleSubscriber(destination, predicate, source) {
12458 var _this = _super.call(this, destination) || this;
12459 _this.predicate = predicate;
12460 _this.source = source;
12461 _this.seenValue = false;
12465 SingleSubscriber.prototype.applySingleValue = function (value) {
12466 if (this.seenValue) {
12467 this.destination.error('Sequence contains more than one element');
12470 this.seenValue = true;
12471 this.singleValue = value;
12474 SingleSubscriber.prototype._next = function (value) {
12475 var index = this.index++;
12476 if (this.predicate) {
12477 this.tryNext(value, index);
12480 this.applySingleValue(value);
12483 SingleSubscriber.prototype.tryNext = function (value, index) {
12485 if (this.predicate(value, index, this.source)) {
12486 this.applySingleValue(value);
12490 this.destination.error(err);
12493 SingleSubscriber.prototype._complete = function () {
12494 var destination = this.destination;
12495 if (this.index > 0) {
12496 destination.next(this.seenValue ? this.singleValue : undefined);
12497 destination.complete();
12500 destination.error(new EmptyError_1.EmptyError);
12503 return SingleSubscriber;
12504 }(Subscriber_1.Subscriber));
12506 },{"../Subscriber":38,"../util/EmptyError":193}],145:[function(require,module,exports){
12508 var __extends = (this && this.__extends) || (function () {
12509 var extendStatics = function (d, b) {
12510 extendStatics = Object.setPrototypeOf ||
12511 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12512 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12513 return extendStatics(d, b);
12515 return function (d, b) {
12516 extendStatics(d, b);
12517 function __() { this.constructor = d; }
12518 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12521 Object.defineProperty(exports, "__esModule", { value: true });
12522 var Subscriber_1 = require("../Subscriber");
12523 function skip(count) {
12524 return function (source) { return source.lift(new SkipOperator(count)); };
12526 exports.skip = skip;
12527 var SkipOperator = (function () {
12528 function SkipOperator(total) {
12529 this.total = total;
12531 SkipOperator.prototype.call = function (subscriber, source) {
12532 return source.subscribe(new SkipSubscriber(subscriber, this.total));
12534 return SkipOperator;
12536 var SkipSubscriber = (function (_super) {
12537 __extends(SkipSubscriber, _super);
12538 function SkipSubscriber(destination, total) {
12539 var _this = _super.call(this, destination) || this;
12540 _this.total = total;
12544 SkipSubscriber.prototype._next = function (x) {
12545 if (++this.count > this.total) {
12546 this.destination.next(x);
12549 return SkipSubscriber;
12550 }(Subscriber_1.Subscriber));
12552 },{"../Subscriber":38}],146:[function(require,module,exports){
12554 var __extends = (this && this.__extends) || (function () {
12555 var extendStatics = function (d, b) {
12556 extendStatics = Object.setPrototypeOf ||
12557 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12558 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12559 return extendStatics(d, b);
12561 return function (d, b) {
12562 extendStatics(d, b);
12563 function __() { this.constructor = d; }
12564 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12567 Object.defineProperty(exports, "__esModule", { value: true });
12568 var Subscriber_1 = require("../Subscriber");
12569 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
12570 function skipLast(count) {
12571 return function (source) { return source.lift(new SkipLastOperator(count)); };
12573 exports.skipLast = skipLast;
12574 var SkipLastOperator = (function () {
12575 function SkipLastOperator(_skipCount) {
12576 this._skipCount = _skipCount;
12577 if (this._skipCount < 0) {
12578 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
12581 SkipLastOperator.prototype.call = function (subscriber, source) {
12582 if (this._skipCount === 0) {
12583 return source.subscribe(new Subscriber_1.Subscriber(subscriber));
12586 return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
12589 return SkipLastOperator;
12591 var SkipLastSubscriber = (function (_super) {
12592 __extends(SkipLastSubscriber, _super);
12593 function SkipLastSubscriber(destination, _skipCount) {
12594 var _this = _super.call(this, destination) || this;
12595 _this._skipCount = _skipCount;
12597 _this._ring = new Array(_skipCount);
12600 SkipLastSubscriber.prototype._next = function (value) {
12601 var skipCount = this._skipCount;
12602 var count = this._count++;
12603 if (count < skipCount) {
12604 this._ring[count] = value;
12607 var currentIndex = count % skipCount;
12608 var ring = this._ring;
12609 var oldValue = ring[currentIndex];
12610 ring[currentIndex] = value;
12611 this.destination.next(oldValue);
12614 return SkipLastSubscriber;
12615 }(Subscriber_1.Subscriber));
12617 },{"../Subscriber":38,"../util/ArgumentOutOfRangeError":192}],147:[function(require,module,exports){
12619 var __extends = (this && this.__extends) || (function () {
12620 var extendStatics = function (d, b) {
12621 extendStatics = Object.setPrototypeOf ||
12622 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12623 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12624 return extendStatics(d, b);
12626 return function (d, b) {
12627 extendStatics(d, b);
12628 function __() { this.constructor = d; }
12629 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12632 Object.defineProperty(exports, "__esModule", { value: true });
12633 var OuterSubscriber_1 = require("../OuterSubscriber");
12634 var InnerSubscriber_1 = require("../InnerSubscriber");
12635 var subscribeToResult_1 = require("../util/subscribeToResult");
12636 function skipUntil(notifier) {
12637 return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
12639 exports.skipUntil = skipUntil;
12640 var SkipUntilOperator = (function () {
12641 function SkipUntilOperator(notifier) {
12642 this.notifier = notifier;
12644 SkipUntilOperator.prototype.call = function (destination, source) {
12645 return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
12647 return SkipUntilOperator;
12649 var SkipUntilSubscriber = (function (_super) {
12650 __extends(SkipUntilSubscriber, _super);
12651 function SkipUntilSubscriber(destination, notifier) {
12652 var _this = _super.call(this, destination) || this;
12653 _this.hasValue = false;
12654 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(_this, undefined, undefined);
12655 _this.add(innerSubscriber);
12656 _this.innerSubscription = innerSubscriber;
12657 subscribeToResult_1.subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
12660 SkipUntilSubscriber.prototype._next = function (value) {
12661 if (this.hasValue) {
12662 _super.prototype._next.call(this, value);
12665 SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
12666 this.hasValue = true;
12667 if (this.innerSubscription) {
12668 this.innerSubscription.unsubscribe();
12671 SkipUntilSubscriber.prototype.notifyComplete = function () {
12673 return SkipUntilSubscriber;
12674 }(OuterSubscriber_1.OuterSubscriber));
12676 },{"../InnerSubscriber":29,"../OuterSubscriber":33,"../util/subscribeToResult":221}],148:[function(require,module,exports){
12678 var __extends = (this && this.__extends) || (function () {
12679 var extendStatics = function (d, b) {
12680 extendStatics = Object.setPrototypeOf ||
12681 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12682 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12683 return extendStatics(d, b);
12685 return function (d, b) {
12686 extendStatics(d, b);
12687 function __() { this.constructor = d; }
12688 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12691 Object.defineProperty(exports, "__esModule", { value: true });
12692 var Subscriber_1 = require("../Subscriber");
12693 function skipWhile(predicate) {
12694 return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
12696 exports.skipWhile = skipWhile;
12697 var SkipWhileOperator = (function () {
12698 function SkipWhileOperator(predicate) {
12699 this.predicate = predicate;
12701 SkipWhileOperator.prototype.call = function (subscriber, source) {
12702 return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
12704 return SkipWhileOperator;
12706 var SkipWhileSubscriber = (function (_super) {
12707 __extends(SkipWhileSubscriber, _super);
12708 function SkipWhileSubscriber(destination, predicate) {
12709 var _this = _super.call(this, destination) || this;
12710 _this.predicate = predicate;
12711 _this.skipping = true;
12715 SkipWhileSubscriber.prototype._next = function (value) {
12716 var destination = this.destination;
12717 if (this.skipping) {
12718 this.tryCallPredicate(value);
12720 if (!this.skipping) {
12721 destination.next(value);
12724 SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
12726 var result = this.predicate(value, this.index++);
12727 this.skipping = Boolean(result);
12730 this.destination.error(err);
12733 return SkipWhileSubscriber;
12734 }(Subscriber_1.Subscriber));
12736 },{"../Subscriber":38}],149:[function(require,module,exports){
12738 Object.defineProperty(exports, "__esModule", { value: true });
12739 var fromArray_1 = require("../observable/fromArray");
12740 var scalar_1 = require("../observable/scalar");
12741 var empty_1 = require("../observable/empty");
12742 var concat_1 = require("../observable/concat");
12743 var isScheduler_1 = require("../util/isScheduler");
12744 function startWith() {
12746 for (var _i = 0; _i < arguments.length; _i++) {
12747 array[_i] = arguments[_i];
12749 return function (source) {
12750 var scheduler = array[array.length - 1];
12751 if (isScheduler_1.isScheduler(scheduler)) {
12757 var len = array.length;
12758 if (len === 1 && !scheduler) {
12759 return concat_1.concat(scalar_1.scalar(array[0]), source);
12761 else if (len > 0) {
12762 return concat_1.concat(fromArray_1.fromArray(array, scheduler), source);
12765 return concat_1.concat(empty_1.empty(scheduler), source);
12769 exports.startWith = startWith;
12771 },{"../observable/concat":46,"../observable/empty":48,"../observable/fromArray":51,"../observable/scalar":67,"../util/isScheduler":212}],150:[function(require,module,exports){
12773 Object.defineProperty(exports, "__esModule", { value: true });
12774 var SubscribeOnObservable_1 = require("../observable/SubscribeOnObservable");
12775 function subscribeOn(scheduler, delay) {
12776 if (delay === void 0) { delay = 0; }
12777 return function subscribeOnOperatorFunction(source) {
12778 return source.lift(new SubscribeOnOperator(scheduler, delay));
12781 exports.subscribeOn = subscribeOn;
12782 var SubscribeOnOperator = (function () {
12783 function SubscribeOnOperator(scheduler, delay) {
12784 this.scheduler = scheduler;
12785 this.delay = delay;
12787 SubscribeOnOperator.prototype.call = function (subscriber, source) {
12788 return new SubscribeOnObservable_1.SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
12790 return SubscribeOnOperator;
12793 },{"../observable/SubscribeOnObservable":42}],151:[function(require,module,exports){
12795 Object.defineProperty(exports, "__esModule", { value: true });
12796 var switchMap_1 = require("./switchMap");
12797 var identity_1 = require("../util/identity");
12798 function switchAll() {
12799 return switchMap_1.switchMap(identity_1.identity);
12801 exports.switchAll = switchAll;
12803 },{"../util/identity":201,"./switchMap":152}],152:[function(require,module,exports){
12805 var __extends = (this && this.__extends) || (function () {
12806 var extendStatics = function (d, b) {
12807 extendStatics = Object.setPrototypeOf ||
12808 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12809 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12810 return extendStatics(d, b);
12812 return function (d, b) {
12813 extendStatics(d, b);
12814 function __() { this.constructor = d; }
12815 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12818 Object.defineProperty(exports, "__esModule", { value: true });
12819 var OuterSubscriber_1 = require("../OuterSubscriber");
12820 var InnerSubscriber_1 = require("../InnerSubscriber");
12821 var subscribeToResult_1 = require("../util/subscribeToResult");
12822 var map_1 = require("./map");
12823 var from_1 = require("../observable/from");
12824 function switchMap(project, resultSelector) {
12825 if (typeof resultSelector === 'function') {
12826 return function (source) { return source.pipe(switchMap(function (a, i) { return from_1.from(project(a, i)).pipe(map_1.map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
12828 return function (source) { return source.lift(new SwitchMapOperator(project)); };
12830 exports.switchMap = switchMap;
12831 var SwitchMapOperator = (function () {
12832 function SwitchMapOperator(project) {
12833 this.project = project;
12835 SwitchMapOperator.prototype.call = function (subscriber, source) {
12836 return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
12838 return SwitchMapOperator;
12840 var SwitchMapSubscriber = (function (_super) {
12841 __extends(SwitchMapSubscriber, _super);
12842 function SwitchMapSubscriber(destination, project) {
12843 var _this = _super.call(this, destination) || this;
12844 _this.project = project;
12848 SwitchMapSubscriber.prototype._next = function (value) {
12850 var index = this.index++;
12852 result = this.project(value, index);
12855 this.destination.error(error);
12858 this._innerSub(result, value, index);
12860 SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
12861 var innerSubscription = this.innerSubscription;
12862 if (innerSubscription) {
12863 innerSubscription.unsubscribe();
12865 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
12866 var destination = this.destination;
12867 destination.add(innerSubscriber);
12868 this.innerSubscription = subscribeToResult_1.subscribeToResult(this, result, value, index, innerSubscriber);
12870 SwitchMapSubscriber.prototype._complete = function () {
12871 var innerSubscription = this.innerSubscription;
12872 if (!innerSubscription || innerSubscription.closed) {
12873 _super.prototype._complete.call(this);
12875 this.unsubscribe();
12877 SwitchMapSubscriber.prototype._unsubscribe = function () {
12878 this.innerSubscription = null;
12880 SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
12881 var destination = this.destination;
12882 destination.remove(innerSub);
12883 this.innerSubscription = null;
12884 if (this.isStopped) {
12885 _super.prototype._complete.call(this);
12888 SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
12889 this.destination.next(innerValue);
12891 return SwitchMapSubscriber;
12892 }(OuterSubscriber_1.OuterSubscriber));
12894 },{"../InnerSubscriber":29,"../OuterSubscriber":33,"../observable/from":50,"../util/subscribeToResult":221,"./map":111}],153:[function(require,module,exports){
12896 Object.defineProperty(exports, "__esModule", { value: true });
12897 var switchMap_1 = require("./switchMap");
12898 function switchMapTo(innerObservable, resultSelector) {
12899 return resultSelector ? switchMap_1.switchMap(function () { return innerObservable; }, resultSelector) : switchMap_1.switchMap(function () { return innerObservable; });
12901 exports.switchMapTo = switchMapTo;
12903 },{"./switchMap":152}],154:[function(require,module,exports){
12905 var __extends = (this && this.__extends) || (function () {
12906 var extendStatics = function (d, b) {
12907 extendStatics = Object.setPrototypeOf ||
12908 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12909 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12910 return extendStatics(d, b);
12912 return function (d, b) {
12913 extendStatics(d, b);
12914 function __() { this.constructor = d; }
12915 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12918 Object.defineProperty(exports, "__esModule", { value: true });
12919 var Subscriber_1 = require("../Subscriber");
12920 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
12921 var empty_1 = require("../observable/empty");
12922 function take(count) {
12923 return function (source) {
12925 return empty_1.empty();
12928 return source.lift(new TakeOperator(count));
12932 exports.take = take;
12933 var TakeOperator = (function () {
12934 function TakeOperator(total) {
12935 this.total = total;
12936 if (this.total < 0) {
12937 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
12940 TakeOperator.prototype.call = function (subscriber, source) {
12941 return source.subscribe(new TakeSubscriber(subscriber, this.total));
12943 return TakeOperator;
12945 var TakeSubscriber = (function (_super) {
12946 __extends(TakeSubscriber, _super);
12947 function TakeSubscriber(destination, total) {
12948 var _this = _super.call(this, destination) || this;
12949 _this.total = total;
12953 TakeSubscriber.prototype._next = function (value) {
12954 var total = this.total;
12955 var count = ++this.count;
12956 if (count <= total) {
12957 this.destination.next(value);
12958 if (count === total) {
12959 this.destination.complete();
12960 this.unsubscribe();
12964 return TakeSubscriber;
12965 }(Subscriber_1.Subscriber));
12967 },{"../Subscriber":38,"../observable/empty":48,"../util/ArgumentOutOfRangeError":192}],155:[function(require,module,exports){
12969 var __extends = (this && this.__extends) || (function () {
12970 var extendStatics = function (d, b) {
12971 extendStatics = Object.setPrototypeOf ||
12972 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12973 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12974 return extendStatics(d, b);
12976 return function (d, b) {
12977 extendStatics(d, b);
12978 function __() { this.constructor = d; }
12979 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12982 Object.defineProperty(exports, "__esModule", { value: true });
12983 var Subscriber_1 = require("../Subscriber");
12984 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
12985 var empty_1 = require("../observable/empty");
12986 function takeLast(count) {
12987 return function takeLastOperatorFunction(source) {
12989 return empty_1.empty();
12992 return source.lift(new TakeLastOperator(count));
12996 exports.takeLast = takeLast;
12997 var TakeLastOperator = (function () {
12998 function TakeLastOperator(total) {
12999 this.total = total;
13000 if (this.total < 0) {
13001 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
13004 TakeLastOperator.prototype.call = function (subscriber, source) {
13005 return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
13007 return TakeLastOperator;
13009 var TakeLastSubscriber = (function (_super) {
13010 __extends(TakeLastSubscriber, _super);
13011 function TakeLastSubscriber(destination, total) {
13012 var _this = _super.call(this, destination) || this;
13013 _this.total = total;
13014 _this.ring = new Array();
13018 TakeLastSubscriber.prototype._next = function (value) {
13019 var ring = this.ring;
13020 var total = this.total;
13021 var count = this.count++;
13022 if (ring.length < total) {
13026 var index = count % total;
13027 ring[index] = value;
13030 TakeLastSubscriber.prototype._complete = function () {
13031 var destination = this.destination;
13032 var count = this.count;
13034 var total = this.count >= this.total ? this.total : this.count;
13035 var ring = this.ring;
13036 for (var i = 0; i < total; i++) {
13037 var idx = (count++) % total;
13038 destination.next(ring[idx]);
13041 destination.complete();
13043 return TakeLastSubscriber;
13044 }(Subscriber_1.Subscriber));
13046 },{"../Subscriber":38,"../observable/empty":48,"../util/ArgumentOutOfRangeError":192}],156:[function(require,module,exports){
13048 var __extends = (this && this.__extends) || (function () {
13049 var extendStatics = function (d, b) {
13050 extendStatics = Object.setPrototypeOf ||
13051 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13052 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13053 return extendStatics(d, b);
13055 return function (d, b) {
13056 extendStatics(d, b);
13057 function __() { this.constructor = d; }
13058 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13061 Object.defineProperty(exports, "__esModule", { value: true });
13062 var OuterSubscriber_1 = require("../OuterSubscriber");
13063 var subscribeToResult_1 = require("../util/subscribeToResult");
13064 function takeUntil(notifier) {
13065 return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
13067 exports.takeUntil = takeUntil;
13068 var TakeUntilOperator = (function () {
13069 function TakeUntilOperator(notifier) {
13070 this.notifier = notifier;
13072 TakeUntilOperator.prototype.call = function (subscriber, source) {
13073 var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
13074 var notifierSubscription = subscribeToResult_1.subscribeToResult(takeUntilSubscriber, this.notifier);
13075 if (notifierSubscription && !takeUntilSubscriber.seenValue) {
13076 takeUntilSubscriber.add(notifierSubscription);
13077 return source.subscribe(takeUntilSubscriber);
13079 return takeUntilSubscriber;
13081 return TakeUntilOperator;
13083 var TakeUntilSubscriber = (function (_super) {
13084 __extends(TakeUntilSubscriber, _super);
13085 function TakeUntilSubscriber(destination) {
13086 var _this = _super.call(this, destination) || this;
13087 _this.seenValue = false;
13090 TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
13091 this.seenValue = true;
13094 TakeUntilSubscriber.prototype.notifyComplete = function () {
13096 return TakeUntilSubscriber;
13097 }(OuterSubscriber_1.OuterSubscriber));
13099 },{"../OuterSubscriber":33,"../util/subscribeToResult":221}],157:[function(require,module,exports){
13101 var __extends = (this && this.__extends) || (function () {
13102 var extendStatics = function (d, b) {
13103 extendStatics = Object.setPrototypeOf ||
13104 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13105 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13106 return extendStatics(d, b);
13108 return function (d, b) {
13109 extendStatics(d, b);
13110 function __() { this.constructor = d; }
13111 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13114 Object.defineProperty(exports, "__esModule", { value: true });
13115 var Subscriber_1 = require("../Subscriber");
13116 function takeWhile(predicate) {
13117 return function (source) { return source.lift(new TakeWhileOperator(predicate)); };
13119 exports.takeWhile = takeWhile;
13120 var TakeWhileOperator = (function () {
13121 function TakeWhileOperator(predicate) {
13122 this.predicate = predicate;
13124 TakeWhileOperator.prototype.call = function (subscriber, source) {
13125 return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate));
13127 return TakeWhileOperator;
13129 var TakeWhileSubscriber = (function (_super) {
13130 __extends(TakeWhileSubscriber, _super);
13131 function TakeWhileSubscriber(destination, predicate) {
13132 var _this = _super.call(this, destination) || this;
13133 _this.predicate = predicate;
13137 TakeWhileSubscriber.prototype._next = function (value) {
13138 var destination = this.destination;
13141 result = this.predicate(value, this.index++);
13144 destination.error(err);
13147 this.nextOrComplete(value, result);
13149 TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
13150 var destination = this.destination;
13151 if (Boolean(predicateResult)) {
13152 destination.next(value);
13155 destination.complete();
13158 return TakeWhileSubscriber;
13159 }(Subscriber_1.Subscriber));
13161 },{"../Subscriber":38}],158:[function(require,module,exports){
13163 var __extends = (this && this.__extends) || (function () {
13164 var extendStatics = function (d, b) {
13165 extendStatics = Object.setPrototypeOf ||
13166 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13167 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13168 return extendStatics(d, b);
13170 return function (d, b) {
13171 extendStatics(d, b);
13172 function __() { this.constructor = d; }
13173 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13176 Object.defineProperty(exports, "__esModule", { value: true });
13177 var Subscriber_1 = require("../Subscriber");
13178 var noop_1 = require("../util/noop");
13179 var isFunction_1 = require("../util/isFunction");
13180 function tap(nextOrObserver, error, complete) {
13181 return function tapOperatorFunction(source) {
13182 return source.lift(new DoOperator(nextOrObserver, error, complete));
13186 var DoOperator = (function () {
13187 function DoOperator(nextOrObserver, error, complete) {
13188 this.nextOrObserver = nextOrObserver;
13189 this.error = error;
13190 this.complete = complete;
13192 DoOperator.prototype.call = function (subscriber, source) {
13193 return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
13197 var TapSubscriber = (function (_super) {
13198 __extends(TapSubscriber, _super);
13199 function TapSubscriber(destination, observerOrNext, error, complete) {
13200 var _this = _super.call(this, destination) || this;
13201 _this._tapNext = noop_1.noop;
13202 _this._tapError = noop_1.noop;
13203 _this._tapComplete = noop_1.noop;
13204 _this._tapError = error || noop_1.noop;
13205 _this._tapComplete = complete || noop_1.noop;
13206 if (isFunction_1.isFunction(observerOrNext)) {
13207 _this._context = _this;
13208 _this._tapNext = observerOrNext;
13210 else if (observerOrNext) {
13211 _this._context = observerOrNext;
13212 _this._tapNext = observerOrNext.next || noop_1.noop;
13213 _this._tapError = observerOrNext.error || noop_1.noop;
13214 _this._tapComplete = observerOrNext.complete || noop_1.noop;
13218 TapSubscriber.prototype._next = function (value) {
13220 this._tapNext.call(this._context, value);
13223 this.destination.error(err);
13226 this.destination.next(value);
13228 TapSubscriber.prototype._error = function (err) {
13230 this._tapError.call(this._context, err);
13233 this.destination.error(err);
13236 this.destination.error(err);
13238 TapSubscriber.prototype._complete = function () {
13240 this._tapComplete.call(this._context);
13243 this.destination.error(err);
13246 return this.destination.complete();
13248 return TapSubscriber;
13249 }(Subscriber_1.Subscriber));
13251 },{"../Subscriber":38,"../util/isFunction":205,"../util/noop":213}],159:[function(require,module,exports){
13253 var __extends = (this && this.__extends) || (function () {
13254 var extendStatics = function (d, b) {
13255 extendStatics = Object.setPrototypeOf ||
13256 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13257 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13258 return extendStatics(d, b);
13260 return function (d, b) {
13261 extendStatics(d, b);
13262 function __() { this.constructor = d; }
13263 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13266 Object.defineProperty(exports, "__esModule", { value: true });
13267 var OuterSubscriber_1 = require("../OuterSubscriber");
13268 var subscribeToResult_1 = require("../util/subscribeToResult");
13269 exports.defaultThrottleConfig = {
13273 function throttle(durationSelector, config) {
13274 if (config === void 0) { config = exports.defaultThrottleConfig; }
13275 return function (source) { return source.lift(new ThrottleOperator(durationSelector, config.leading, config.trailing)); };
13277 exports.throttle = throttle;
13278 var ThrottleOperator = (function () {
13279 function ThrottleOperator(durationSelector, leading, trailing) {
13280 this.durationSelector = durationSelector;
13281 this.leading = leading;
13282 this.trailing = trailing;
13284 ThrottleOperator.prototype.call = function (subscriber, source) {
13285 return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
13287 return ThrottleOperator;
13289 var ThrottleSubscriber = (function (_super) {
13290 __extends(ThrottleSubscriber, _super);
13291 function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
13292 var _this = _super.call(this, destination) || this;
13293 _this.destination = destination;
13294 _this.durationSelector = durationSelector;
13295 _this._leading = _leading;
13296 _this._trailing = _trailing;
13297 _this._hasValue = false;
13300 ThrottleSubscriber.prototype._next = function (value) {
13301 this._hasValue = true;
13302 this._sendValue = value;
13303 if (!this._throttled) {
13304 if (this._leading) {
13308 this.throttle(value);
13312 ThrottleSubscriber.prototype.send = function () {
13313 var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
13315 this.destination.next(_sendValue);
13316 this.throttle(_sendValue);
13318 this._hasValue = false;
13319 this._sendValue = null;
13321 ThrottleSubscriber.prototype.throttle = function (value) {
13322 var duration = this.tryDurationSelector(value);
13324 this.add(this._throttled = subscribeToResult_1.subscribeToResult(this, duration));
13327 ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
13329 return this.durationSelector(value);
13332 this.destination.error(err);
13336 ThrottleSubscriber.prototype.throttlingDone = function () {
13337 var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
13339 _throttled.unsubscribe();
13341 this._throttled = null;
13346 ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
13347 this.throttlingDone();
13349 ThrottleSubscriber.prototype.notifyComplete = function () {
13350 this.throttlingDone();
13352 return ThrottleSubscriber;
13353 }(OuterSubscriber_1.OuterSubscriber));
13355 },{"../OuterSubscriber":33,"../util/subscribeToResult":221}],160:[function(require,module,exports){
13357 var __extends = (this && this.__extends) || (function () {
13358 var extendStatics = function (d, b) {
13359 extendStatics = Object.setPrototypeOf ||
13360 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13361 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13362 return extendStatics(d, b);
13364 return function (d, b) {
13365 extendStatics(d, b);
13366 function __() { this.constructor = d; }
13367 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13370 Object.defineProperty(exports, "__esModule", { value: true });
13371 var Subscriber_1 = require("../Subscriber");
13372 var async_1 = require("../scheduler/async");
13373 var throttle_1 = require("./throttle");
13374 function throttleTime(duration, scheduler, config) {
13375 if (scheduler === void 0) { scheduler = async_1.async; }
13376 if (config === void 0) { config = throttle_1.defaultThrottleConfig; }
13377 return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
13379 exports.throttleTime = throttleTime;
13380 var ThrottleTimeOperator = (function () {
13381 function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
13382 this.duration = duration;
13383 this.scheduler = scheduler;
13384 this.leading = leading;
13385 this.trailing = trailing;
13387 ThrottleTimeOperator.prototype.call = function (subscriber, source) {
13388 return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
13390 return ThrottleTimeOperator;
13392 var ThrottleTimeSubscriber = (function (_super) {
13393 __extends(ThrottleTimeSubscriber, _super);
13394 function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
13395 var _this = _super.call(this, destination) || this;
13396 _this.duration = duration;
13397 _this.scheduler = scheduler;
13398 _this.leading = leading;
13399 _this.trailing = trailing;
13400 _this._hasTrailingValue = false;
13401 _this._trailingValue = null;
13404 ThrottleTimeSubscriber.prototype._next = function (value) {
13405 if (this.throttled) {
13406 if (this.trailing) {
13407 this._trailingValue = value;
13408 this._hasTrailingValue = true;
13412 this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, { subscriber: this }));
13413 if (this.leading) {
13414 this.destination.next(value);
13418 ThrottleTimeSubscriber.prototype._complete = function () {
13419 if (this._hasTrailingValue) {
13420 this.destination.next(this._trailingValue);
13421 this.destination.complete();
13424 this.destination.complete();
13427 ThrottleTimeSubscriber.prototype.clearThrottle = function () {
13428 var throttled = this.throttled;
13430 if (this.trailing && this._hasTrailingValue) {
13431 this.destination.next(this._trailingValue);
13432 this._trailingValue = null;
13433 this._hasTrailingValue = false;
13435 throttled.unsubscribe();
13436 this.remove(throttled);
13437 this.throttled = null;
13440 return ThrottleTimeSubscriber;
13441 }(Subscriber_1.Subscriber));
13442 function dispatchNext(arg) {
13443 var subscriber = arg.subscriber;
13444 subscriber.clearThrottle();
13447 },{"../Subscriber":38,"../scheduler/async":187,"./throttle":159}],161:[function(require,module,exports){
13449 Object.defineProperty(exports, "__esModule", { value: true });
13450 var tap_1 = require("./tap");
13451 var EmptyError_1 = require("../util/EmptyError");
13452 exports.throwIfEmpty = function (errorFactory) {
13453 if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
13456 next: function () { this.hasValue = true; },
13457 complete: function () {
13458 if (!this.hasValue) {
13459 throw errorFactory();
13464 function defaultErrorFactory() {
13465 return new EmptyError_1.EmptyError();
13468 },{"../util/EmptyError":193,"./tap":158}],162:[function(require,module,exports){
13470 Object.defineProperty(exports, "__esModule", { value: true });
13471 var async_1 = require("../scheduler/async");
13472 var scan_1 = require("./scan");
13473 var defer_1 = require("../observable/defer");
13474 var map_1 = require("./map");
13475 function timeInterval(scheduler) {
13476 if (scheduler === void 0) { scheduler = async_1.async; }
13477 return function (source) { return defer_1.defer(function () {
13478 return source.pipe(scan_1.scan(function (_a, value) {
13479 var current = _a.current;
13480 return ({ value: value, current: scheduler.now(), last: current });
13481 }, { current: scheduler.now(), value: undefined, last: undefined }), map_1.map(function (_a) {
13482 var current = _a.current, last = _a.last, value = _a.value;
13483 return new TimeInterval(value, current - last);
13487 exports.timeInterval = timeInterval;
13488 var TimeInterval = (function () {
13489 function TimeInterval(value, interval) {
13490 this.value = value;
13491 this.interval = interval;
13493 return TimeInterval;
13495 exports.TimeInterval = TimeInterval;
13497 },{"../observable/defer":47,"../scheduler/async":187,"./map":111,"./scan":140}],163:[function(require,module,exports){
13499 Object.defineProperty(exports, "__esModule", { value: true });
13500 var async_1 = require("../scheduler/async");
13501 var TimeoutError_1 = require("../util/TimeoutError");
13502 var timeoutWith_1 = require("./timeoutWith");
13503 var throwError_1 = require("../observable/throwError");
13504 function timeout(due, scheduler) {
13505 if (scheduler === void 0) { scheduler = async_1.async; }
13506 return timeoutWith_1.timeoutWith(due, throwError_1.throwError(new TimeoutError_1.TimeoutError()), scheduler);
13508 exports.timeout = timeout;
13510 },{"../observable/throwError":68,"../scheduler/async":187,"../util/TimeoutError":196,"./timeoutWith":164}],164:[function(require,module,exports){
13512 var __extends = (this && this.__extends) || (function () {
13513 var extendStatics = function (d, b) {
13514 extendStatics = Object.setPrototypeOf ||
13515 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13516 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13517 return extendStatics(d, b);
13519 return function (d, b) {
13520 extendStatics(d, b);
13521 function __() { this.constructor = d; }
13522 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13525 Object.defineProperty(exports, "__esModule", { value: true });
13526 var async_1 = require("../scheduler/async");
13527 var isDate_1 = require("../util/isDate");
13528 var OuterSubscriber_1 = require("../OuterSubscriber");
13529 var subscribeToResult_1 = require("../util/subscribeToResult");
13530 function timeoutWith(due, withObservable, scheduler) {
13531 if (scheduler === void 0) { scheduler = async_1.async; }
13532 return function (source) {
13533 var absoluteTimeout = isDate_1.isDate(due);
13534 var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
13535 return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
13538 exports.timeoutWith = timeoutWith;
13539 var TimeoutWithOperator = (function () {
13540 function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
13541 this.waitFor = waitFor;
13542 this.absoluteTimeout = absoluteTimeout;
13543 this.withObservable = withObservable;
13544 this.scheduler = scheduler;
13546 TimeoutWithOperator.prototype.call = function (subscriber, source) {
13547 return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
13549 return TimeoutWithOperator;
13551 var TimeoutWithSubscriber = (function (_super) {
13552 __extends(TimeoutWithSubscriber, _super);
13553 function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
13554 var _this = _super.call(this, destination) || this;
13555 _this.absoluteTimeout = absoluteTimeout;
13556 _this.waitFor = waitFor;
13557 _this.withObservable = withObservable;
13558 _this.scheduler = scheduler;
13559 _this.action = null;
13560 _this.scheduleTimeout();
13563 TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
13564 var withObservable = subscriber.withObservable;
13565 subscriber._unsubscribeAndRecycle();
13566 subscriber.add(subscribeToResult_1.subscribeToResult(subscriber, withObservable));
13568 TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
13569 var action = this.action;
13571 this.action = action.schedule(this, this.waitFor);
13574 this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
13577 TimeoutWithSubscriber.prototype._next = function (value) {
13578 if (!this.absoluteTimeout) {
13579 this.scheduleTimeout();
13581 _super.prototype._next.call(this, value);
13583 TimeoutWithSubscriber.prototype._unsubscribe = function () {
13584 this.action = null;
13585 this.scheduler = null;
13586 this.withObservable = null;
13588 return TimeoutWithSubscriber;
13589 }(OuterSubscriber_1.OuterSubscriber));
13591 },{"../OuterSubscriber":33,"../scheduler/async":187,"../util/isDate":204,"../util/subscribeToResult":221}],165:[function(require,module,exports){
13593 Object.defineProperty(exports, "__esModule", { value: true });
13594 var async_1 = require("../scheduler/async");
13595 var map_1 = require("./map");
13596 function timestamp(scheduler) {
13597 if (scheduler === void 0) { scheduler = async_1.async; }
13598 return map_1.map(function (value) { return new Timestamp(value, scheduler.now()); });
13600 exports.timestamp = timestamp;
13601 var Timestamp = (function () {
13602 function Timestamp(value, timestamp) {
13603 this.value = value;
13604 this.timestamp = timestamp;
13608 exports.Timestamp = Timestamp;
13610 },{"../scheduler/async":187,"./map":111}],166:[function(require,module,exports){
13612 Object.defineProperty(exports, "__esModule", { value: true });
13613 var reduce_1 = require("./reduce");
13614 function toArrayReducer(arr, item, index) {
13621 function toArray() {
13622 return reduce_1.reduce(toArrayReducer, []);
13624 exports.toArray = toArray;
13626 },{"./reduce":132}],167:[function(require,module,exports){
13628 var __extends = (this && this.__extends) || (function () {
13629 var extendStatics = function (d, b) {
13630 extendStatics = Object.setPrototypeOf ||
13631 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13632 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13633 return extendStatics(d, b);
13635 return function (d, b) {
13636 extendStatics(d, b);
13637 function __() { this.constructor = d; }
13638 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13641 Object.defineProperty(exports, "__esModule", { value: true });
13642 var Subject_1 = require("../Subject");
13643 var OuterSubscriber_1 = require("../OuterSubscriber");
13644 var subscribeToResult_1 = require("../util/subscribeToResult");
13645 function window(windowBoundaries) {
13646 return function windowOperatorFunction(source) {
13647 return source.lift(new WindowOperator(windowBoundaries));
13650 exports.window = window;
13651 var WindowOperator = (function () {
13652 function WindowOperator(windowBoundaries) {
13653 this.windowBoundaries = windowBoundaries;
13655 WindowOperator.prototype.call = function (subscriber, source) {
13656 var windowSubscriber = new WindowSubscriber(subscriber);
13657 var sourceSubscription = source.subscribe(windowSubscriber);
13658 if (!sourceSubscription.closed) {
13659 windowSubscriber.add(subscribeToResult_1.subscribeToResult(windowSubscriber, this.windowBoundaries));
13661 return sourceSubscription;
13663 return WindowOperator;
13665 var WindowSubscriber = (function (_super) {
13666 __extends(WindowSubscriber, _super);
13667 function WindowSubscriber(destination) {
13668 var _this = _super.call(this, destination) || this;
13669 _this.window = new Subject_1.Subject();
13670 destination.next(_this.window);
13673 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
13676 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
13677 this._error(error);
13679 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
13682 WindowSubscriber.prototype._next = function (value) {
13683 this.window.next(value);
13685 WindowSubscriber.prototype._error = function (err) {
13686 this.window.error(err);
13687 this.destination.error(err);
13689 WindowSubscriber.prototype._complete = function () {
13690 this.window.complete();
13691 this.destination.complete();
13693 WindowSubscriber.prototype._unsubscribe = function () {
13694 this.window = null;
13696 WindowSubscriber.prototype.openWindow = function () {
13697 var prevWindow = this.window;
13699 prevWindow.complete();
13701 var destination = this.destination;
13702 var newWindow = this.window = new Subject_1.Subject();
13703 destination.next(newWindow);
13705 return WindowSubscriber;
13706 }(OuterSubscriber_1.OuterSubscriber));
13708 },{"../OuterSubscriber":33,"../Subject":36,"../util/subscribeToResult":221}],168:[function(require,module,exports){
13710 var __extends = (this && this.__extends) || (function () {
13711 var extendStatics = function (d, b) {
13712 extendStatics = Object.setPrototypeOf ||
13713 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13714 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13715 return extendStatics(d, b);
13717 return function (d, b) {
13718 extendStatics(d, b);
13719 function __() { this.constructor = d; }
13720 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13723 Object.defineProperty(exports, "__esModule", { value: true });
13724 var Subscriber_1 = require("../Subscriber");
13725 var Subject_1 = require("../Subject");
13726 function windowCount(windowSize, startWindowEvery) {
13727 if (startWindowEvery === void 0) { startWindowEvery = 0; }
13728 return function windowCountOperatorFunction(source) {
13729 return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
13732 exports.windowCount = windowCount;
13733 var WindowCountOperator = (function () {
13734 function WindowCountOperator(windowSize, startWindowEvery) {
13735 this.windowSize = windowSize;
13736 this.startWindowEvery = startWindowEvery;
13738 WindowCountOperator.prototype.call = function (subscriber, source) {
13739 return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
13741 return WindowCountOperator;
13743 var WindowCountSubscriber = (function (_super) {
13744 __extends(WindowCountSubscriber, _super);
13745 function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
13746 var _this = _super.call(this, destination) || this;
13747 _this.destination = destination;
13748 _this.windowSize = windowSize;
13749 _this.startWindowEvery = startWindowEvery;
13750 _this.windows = [new Subject_1.Subject()];
13752 destination.next(_this.windows[0]);
13755 WindowCountSubscriber.prototype._next = function (value) {
13756 var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
13757 var destination = this.destination;
13758 var windowSize = this.windowSize;
13759 var windows = this.windows;
13760 var len = windows.length;
13761 for (var i = 0; i < len && !this.closed; i++) {
13762 windows[i].next(value);
13764 var c = this.count - windowSize + 1;
13765 if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
13766 windows.shift().complete();
13768 if (++this.count % startWindowEvery === 0 && !this.closed) {
13769 var window_1 = new Subject_1.Subject();
13770 windows.push(window_1);
13771 destination.next(window_1);
13774 WindowCountSubscriber.prototype._error = function (err) {
13775 var windows = this.windows;
13777 while (windows.length > 0 && !this.closed) {
13778 windows.shift().error(err);
13781 this.destination.error(err);
13783 WindowCountSubscriber.prototype._complete = function () {
13784 var windows = this.windows;
13786 while (windows.length > 0 && !this.closed) {
13787 windows.shift().complete();
13790 this.destination.complete();
13792 WindowCountSubscriber.prototype._unsubscribe = function () {
13794 this.windows = null;
13796 return WindowCountSubscriber;
13797 }(Subscriber_1.Subscriber));
13799 },{"../Subject":36,"../Subscriber":38}],169:[function(require,module,exports){
13801 var __extends = (this && this.__extends) || (function () {
13802 var extendStatics = function (d, b) {
13803 extendStatics = Object.setPrototypeOf ||
13804 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13805 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13806 return extendStatics(d, b);
13808 return function (d, b) {
13809 extendStatics(d, b);
13810 function __() { this.constructor = d; }
13811 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13814 Object.defineProperty(exports, "__esModule", { value: true });
13815 var Subject_1 = require("../Subject");
13816 var async_1 = require("../scheduler/async");
13817 var Subscriber_1 = require("../Subscriber");
13818 var isNumeric_1 = require("../util/isNumeric");
13819 var isScheduler_1 = require("../util/isScheduler");
13820 function windowTime(windowTimeSpan) {
13821 var scheduler = async_1.async;
13822 var windowCreationInterval = null;
13823 var maxWindowSize = Number.POSITIVE_INFINITY;
13824 if (isScheduler_1.isScheduler(arguments[3])) {
13825 scheduler = arguments[3];
13827 if (isScheduler_1.isScheduler(arguments[2])) {
13828 scheduler = arguments[2];
13830 else if (isNumeric_1.isNumeric(arguments[2])) {
13831 maxWindowSize = arguments[2];
13833 if (isScheduler_1.isScheduler(arguments[1])) {
13834 scheduler = arguments[1];
13836 else if (isNumeric_1.isNumeric(arguments[1])) {
13837 windowCreationInterval = arguments[1];
13839 return function windowTimeOperatorFunction(source) {
13840 return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
13843 exports.windowTime = windowTime;
13844 var WindowTimeOperator = (function () {
13845 function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
13846 this.windowTimeSpan = windowTimeSpan;
13847 this.windowCreationInterval = windowCreationInterval;
13848 this.maxWindowSize = maxWindowSize;
13849 this.scheduler = scheduler;
13851 WindowTimeOperator.prototype.call = function (subscriber, source) {
13852 return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
13854 return WindowTimeOperator;
13856 var CountedSubject = (function (_super) {
13857 __extends(CountedSubject, _super);
13858 function CountedSubject() {
13859 var _this = _super !== null && _super.apply(this, arguments) || this;
13860 _this._numberOfNextedValues = 0;
13863 CountedSubject.prototype.next = function (value) {
13864 this._numberOfNextedValues++;
13865 _super.prototype.next.call(this, value);
13867 Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
13869 return this._numberOfNextedValues;
13874 return CountedSubject;
13875 }(Subject_1.Subject));
13876 var WindowTimeSubscriber = (function (_super) {
13877 __extends(WindowTimeSubscriber, _super);
13878 function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
13879 var _this = _super.call(this, destination) || this;
13880 _this.destination = destination;
13881 _this.windowTimeSpan = windowTimeSpan;
13882 _this.windowCreationInterval = windowCreationInterval;
13883 _this.maxWindowSize = maxWindowSize;
13884 _this.scheduler = scheduler;
13885 _this.windows = [];
13886 var window = _this.openWindow();
13887 if (windowCreationInterval !== null && windowCreationInterval >= 0) {
13888 var closeState = { subscriber: _this, window: window, context: null };
13889 var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
13890 _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
13891 _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
13894 var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
13895 _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
13899 WindowTimeSubscriber.prototype._next = function (value) {
13900 var windows = this.windows;
13901 var len = windows.length;
13902 for (var i = 0; i < len; i++) {
13903 var window_1 = windows[i];
13904 if (!window_1.closed) {
13905 window_1.next(value);
13906 if (window_1.numberOfNextedValues >= this.maxWindowSize) {
13907 this.closeWindow(window_1);
13912 WindowTimeSubscriber.prototype._error = function (err) {
13913 var windows = this.windows;
13914 while (windows.length > 0) {
13915 windows.shift().error(err);
13917 this.destination.error(err);
13919 WindowTimeSubscriber.prototype._complete = function () {
13920 var windows = this.windows;
13921 while (windows.length > 0) {
13922 var window_2 = windows.shift();
13923 if (!window_2.closed) {
13924 window_2.complete();
13927 this.destination.complete();
13929 WindowTimeSubscriber.prototype.openWindow = function () {
13930 var window = new CountedSubject();
13931 this.windows.push(window);
13932 var destination = this.destination;
13933 destination.next(window);
13936 WindowTimeSubscriber.prototype.closeWindow = function (window) {
13938 var windows = this.windows;
13939 windows.splice(windows.indexOf(window), 1);
13941 return WindowTimeSubscriber;
13942 }(Subscriber_1.Subscriber));
13943 function dispatchWindowTimeSpanOnly(state) {
13944 var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
13946 subscriber.closeWindow(window);
13948 state.window = subscriber.openWindow();
13949 this.schedule(state, windowTimeSpan);
13951 function dispatchWindowCreation(state) {
13952 var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
13953 var window = subscriber.openWindow();
13955 var context = { action: action, subscription: null };
13956 var timeSpanState = { subscriber: subscriber, window: window, context: context };
13957 context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
13958 action.add(context.subscription);
13959 action.schedule(state, windowCreationInterval);
13961 function dispatchWindowClose(state) {
13962 var subscriber = state.subscriber, window = state.window, context = state.context;
13963 if (context && context.action && context.subscription) {
13964 context.action.remove(context.subscription);
13966 subscriber.closeWindow(window);
13969 },{"../Subject":36,"../Subscriber":38,"../scheduler/async":187,"../util/isNumeric":208,"../util/isScheduler":212}],170:[function(require,module,exports){
13971 var __extends = (this && this.__extends) || (function () {
13972 var extendStatics = function (d, b) {
13973 extendStatics = Object.setPrototypeOf ||
13974 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13975 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13976 return extendStatics(d, b);
13978 return function (d, b) {
13979 extendStatics(d, b);
13980 function __() { this.constructor = d; }
13981 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13984 Object.defineProperty(exports, "__esModule", { value: true });
13985 var Subject_1 = require("../Subject");
13986 var Subscription_1 = require("../Subscription");
13987 var tryCatch_1 = require("../util/tryCatch");
13988 var errorObject_1 = require("../util/errorObject");
13989 var OuterSubscriber_1 = require("../OuterSubscriber");
13990 var subscribeToResult_1 = require("../util/subscribeToResult");
13991 function windowToggle(openings, closingSelector) {
13992 return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
13994 exports.windowToggle = windowToggle;
13995 var WindowToggleOperator = (function () {
13996 function WindowToggleOperator(openings, closingSelector) {
13997 this.openings = openings;
13998 this.closingSelector = closingSelector;
14000 WindowToggleOperator.prototype.call = function (subscriber, source) {
14001 return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
14003 return WindowToggleOperator;
14005 var WindowToggleSubscriber = (function (_super) {
14006 __extends(WindowToggleSubscriber, _super);
14007 function WindowToggleSubscriber(destination, openings, closingSelector) {
14008 var _this = _super.call(this, destination) || this;
14009 _this.openings = openings;
14010 _this.closingSelector = closingSelector;
14011 _this.contexts = [];
14012 _this.add(_this.openSubscription = subscribeToResult_1.subscribeToResult(_this, openings, openings));
14015 WindowToggleSubscriber.prototype._next = function (value) {
14016 var contexts = this.contexts;
14018 var len = contexts.length;
14019 for (var i = 0; i < len; i++) {
14020 contexts[i].window.next(value);
14024 WindowToggleSubscriber.prototype._error = function (err) {
14025 var contexts = this.contexts;
14026 this.contexts = null;
14028 var len = contexts.length;
14030 while (++index < len) {
14031 var context_1 = contexts[index];
14032 context_1.window.error(err);
14033 context_1.subscription.unsubscribe();
14036 _super.prototype._error.call(this, err);
14038 WindowToggleSubscriber.prototype._complete = function () {
14039 var contexts = this.contexts;
14040 this.contexts = null;
14042 var len = contexts.length;
14044 while (++index < len) {
14045 var context_2 = contexts[index];
14046 context_2.window.complete();
14047 context_2.subscription.unsubscribe();
14050 _super.prototype._complete.call(this);
14052 WindowToggleSubscriber.prototype._unsubscribe = function () {
14053 var contexts = this.contexts;
14054 this.contexts = null;
14056 var len = contexts.length;
14058 while (++index < len) {
14059 var context_3 = contexts[index];
14060 context_3.window.unsubscribe();
14061 context_3.subscription.unsubscribe();
14065 WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
14066 if (outerValue === this.openings) {
14067 var closingSelector = this.closingSelector;
14068 var closingNotifier = tryCatch_1.tryCatch(closingSelector)(innerValue);
14069 if (closingNotifier === errorObject_1.errorObject) {
14070 return this.error(errorObject_1.errorObject.e);
14073 var window_1 = new Subject_1.Subject();
14074 var subscription = new Subscription_1.Subscription();
14075 var context_4 = { window: window_1, subscription: subscription };
14076 this.contexts.push(context_4);
14077 var innerSubscription = subscribeToResult_1.subscribeToResult(this, closingNotifier, context_4);
14078 if (innerSubscription.closed) {
14079 this.closeWindow(this.contexts.length - 1);
14082 innerSubscription.context = context_4;
14083 subscription.add(innerSubscription);
14085 this.destination.next(window_1);
14089 this.closeWindow(this.contexts.indexOf(outerValue));
14092 WindowToggleSubscriber.prototype.notifyError = function (err) {
14095 WindowToggleSubscriber.prototype.notifyComplete = function (inner) {
14096 if (inner !== this.openSubscription) {
14097 this.closeWindow(this.contexts.indexOf(inner.context));
14100 WindowToggleSubscriber.prototype.closeWindow = function (index) {
14101 if (index === -1) {
14104 var contexts = this.contexts;
14105 var context = contexts[index];
14106 var window = context.window, subscription = context.subscription;
14107 contexts.splice(index, 1);
14109 subscription.unsubscribe();
14111 return WindowToggleSubscriber;
14112 }(OuterSubscriber_1.OuterSubscriber));
14114 },{"../OuterSubscriber":33,"../Subject":36,"../Subscription":39,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],171:[function(require,module,exports){
14116 var __extends = (this && this.__extends) || (function () {
14117 var extendStatics = function (d, b) {
14118 extendStatics = Object.setPrototypeOf ||
14119 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14120 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14121 return extendStatics(d, b);
14123 return function (d, b) {
14124 extendStatics(d, b);
14125 function __() { this.constructor = d; }
14126 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14129 Object.defineProperty(exports, "__esModule", { value: true });
14130 var Subject_1 = require("../Subject");
14131 var tryCatch_1 = require("../util/tryCatch");
14132 var errorObject_1 = require("../util/errorObject");
14133 var OuterSubscriber_1 = require("../OuterSubscriber");
14134 var subscribeToResult_1 = require("../util/subscribeToResult");
14135 function windowWhen(closingSelector) {
14136 return function windowWhenOperatorFunction(source) {
14137 return source.lift(new WindowOperator(closingSelector));
14140 exports.windowWhen = windowWhen;
14141 var WindowOperator = (function () {
14142 function WindowOperator(closingSelector) {
14143 this.closingSelector = closingSelector;
14145 WindowOperator.prototype.call = function (subscriber, source) {
14146 return source.subscribe(new WindowSubscriber(subscriber, this.closingSelector));
14148 return WindowOperator;
14150 var WindowSubscriber = (function (_super) {
14151 __extends(WindowSubscriber, _super);
14152 function WindowSubscriber(destination, closingSelector) {
14153 var _this = _super.call(this, destination) || this;
14154 _this.destination = destination;
14155 _this.closingSelector = closingSelector;
14156 _this.openWindow();
14159 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
14160 this.openWindow(innerSub);
14162 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
14163 this._error(error);
14165 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
14166 this.openWindow(innerSub);
14168 WindowSubscriber.prototype._next = function (value) {
14169 this.window.next(value);
14171 WindowSubscriber.prototype._error = function (err) {
14172 this.window.error(err);
14173 this.destination.error(err);
14174 this.unsubscribeClosingNotification();
14176 WindowSubscriber.prototype._complete = function () {
14177 this.window.complete();
14178 this.destination.complete();
14179 this.unsubscribeClosingNotification();
14181 WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
14182 if (this.closingNotification) {
14183 this.closingNotification.unsubscribe();
14186 WindowSubscriber.prototype.openWindow = function (innerSub) {
14187 if (innerSub === void 0) { innerSub = null; }
14189 this.remove(innerSub);
14190 innerSub.unsubscribe();
14192 var prevWindow = this.window;
14194 prevWindow.complete();
14196 var window = this.window = new Subject_1.Subject();
14197 this.destination.next(window);
14198 var closingNotifier = tryCatch_1.tryCatch(this.closingSelector)();
14199 if (closingNotifier === errorObject_1.errorObject) {
14200 var err = errorObject_1.errorObject.e;
14201 this.destination.error(err);
14202 this.window.error(err);
14205 this.add(this.closingNotification = subscribeToResult_1.subscribeToResult(this, closingNotifier));
14208 return WindowSubscriber;
14209 }(OuterSubscriber_1.OuterSubscriber));
14211 },{"../OuterSubscriber":33,"../Subject":36,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],172:[function(require,module,exports){
14213 var __extends = (this && this.__extends) || (function () {
14214 var extendStatics = function (d, b) {
14215 extendStatics = Object.setPrototypeOf ||
14216 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14217 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14218 return extendStatics(d, b);
14220 return function (d, b) {
14221 extendStatics(d, b);
14222 function __() { this.constructor = d; }
14223 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14226 Object.defineProperty(exports, "__esModule", { value: true });
14227 var OuterSubscriber_1 = require("../OuterSubscriber");
14228 var subscribeToResult_1 = require("../util/subscribeToResult");
14229 function withLatestFrom() {
14231 for (var _i = 0; _i < arguments.length; _i++) {
14232 args[_i] = arguments[_i];
14234 return function (source) {
14236 if (typeof args[args.length - 1] === 'function') {
14237 project = args.pop();
14239 var observables = args;
14240 return source.lift(new WithLatestFromOperator(observables, project));
14243 exports.withLatestFrom = withLatestFrom;
14244 var WithLatestFromOperator = (function () {
14245 function WithLatestFromOperator(observables, project) {
14246 this.observables = observables;
14247 this.project = project;
14249 WithLatestFromOperator.prototype.call = function (subscriber, source) {
14250 return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
14252 return WithLatestFromOperator;
14254 var WithLatestFromSubscriber = (function (_super) {
14255 __extends(WithLatestFromSubscriber, _super);
14256 function WithLatestFromSubscriber(destination, observables, project) {
14257 var _this = _super.call(this, destination) || this;
14258 _this.observables = observables;
14259 _this.project = project;
14260 _this.toRespond = [];
14261 var len = observables.length;
14262 _this.values = new Array(len);
14263 for (var i = 0; i < len; i++) {
14264 _this.toRespond.push(i);
14266 for (var i = 0; i < len; i++) {
14267 var observable = observables[i];
14268 _this.add(subscribeToResult_1.subscribeToResult(_this, observable, observable, i));
14272 WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
14273 this.values[outerIndex] = innerValue;
14274 var toRespond = this.toRespond;
14275 if (toRespond.length > 0) {
14276 var found = toRespond.indexOf(outerIndex);
14277 if (found !== -1) {
14278 toRespond.splice(found, 1);
14282 WithLatestFromSubscriber.prototype.notifyComplete = function () {
14284 WithLatestFromSubscriber.prototype._next = function (value) {
14285 if (this.toRespond.length === 0) {
14286 var args = [value].concat(this.values);
14287 if (this.project) {
14288 this._tryProject(args);
14291 this.destination.next(args);
14295 WithLatestFromSubscriber.prototype._tryProject = function (args) {
14298 result = this.project.apply(this, args);
14301 this.destination.error(err);
14304 this.destination.next(result);
14306 return WithLatestFromSubscriber;
14307 }(OuterSubscriber_1.OuterSubscriber));
14309 },{"../OuterSubscriber":33,"../util/subscribeToResult":221}],173:[function(require,module,exports){
14311 Object.defineProperty(exports, "__esModule", { value: true });
14312 var zip_1 = require("../observable/zip");
14314 var observables = [];
14315 for (var _i = 0; _i < arguments.length; _i++) {
14316 observables[_i] = arguments[_i];
14318 return function zipOperatorFunction(source) {
14319 return source.lift.call(zip_1.zip.apply(void 0, [source].concat(observables)));
14324 },{"../observable/zip":71}],174:[function(require,module,exports){
14326 Object.defineProperty(exports, "__esModule", { value: true });
14327 var zip_1 = require("../observable/zip");
14328 function zipAll(project) {
14329 return function (source) { return source.lift(new zip_1.ZipOperator(project)); };
14331 exports.zipAll = zipAll;
14333 },{"../observable/zip":71}],175:[function(require,module,exports){
14335 var __extends = (this && this.__extends) || (function () {
14336 var extendStatics = function (d, b) {
14337 extendStatics = Object.setPrototypeOf ||
14338 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14339 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14340 return extendStatics(d, b);
14342 return function (d, b) {
14343 extendStatics(d, b);
14344 function __() { this.constructor = d; }
14345 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14348 Object.defineProperty(exports, "__esModule", { value: true });
14349 var Subscription_1 = require("../Subscription");
14350 var Action = (function (_super) {
14351 __extends(Action, _super);
14352 function Action(scheduler, work) {
14353 return _super.call(this) || this;
14355 Action.prototype.schedule = function (state, delay) {
14356 if (delay === void 0) { delay = 0; }
14360 }(Subscription_1.Subscription));
14361 exports.Action = Action;
14363 },{"../Subscription":39}],176:[function(require,module,exports){
14365 var __extends = (this && this.__extends) || (function () {
14366 var extendStatics = function (d, b) {
14367 extendStatics = Object.setPrototypeOf ||
14368 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14369 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14370 return extendStatics(d, b);
14372 return function (d, b) {
14373 extendStatics(d, b);
14374 function __() { this.constructor = d; }
14375 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14378 Object.defineProperty(exports, "__esModule", { value: true });
14379 var AsyncAction_1 = require("./AsyncAction");
14380 var AnimationFrameAction = (function (_super) {
14381 __extends(AnimationFrameAction, _super);
14382 function AnimationFrameAction(scheduler, work) {
14383 var _this = _super.call(this, scheduler, work) || this;
14384 _this.scheduler = scheduler;
14388 AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
14389 if (delay === void 0) { delay = 0; }
14390 if (delay !== null && delay > 0) {
14391 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
14393 scheduler.actions.push(this);
14394 return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
14396 AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
14397 if (delay === void 0) { delay = 0; }
14398 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
14399 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
14401 if (scheduler.actions.length === 0) {
14402 cancelAnimationFrame(id);
14403 scheduler.scheduled = undefined;
14407 return AnimationFrameAction;
14408 }(AsyncAction_1.AsyncAction));
14409 exports.AnimationFrameAction = AnimationFrameAction;
14411 },{"./AsyncAction":180}],177:[function(require,module,exports){
14413 var __extends = (this && this.__extends) || (function () {
14414 var extendStatics = function (d, b) {
14415 extendStatics = Object.setPrototypeOf ||
14416 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14417 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14418 return extendStatics(d, b);
14420 return function (d, b) {
14421 extendStatics(d, b);
14422 function __() { this.constructor = d; }
14423 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14426 Object.defineProperty(exports, "__esModule", { value: true });
14427 var AsyncScheduler_1 = require("./AsyncScheduler");
14428 var AnimationFrameScheduler = (function (_super) {
14429 __extends(AnimationFrameScheduler, _super);
14430 function AnimationFrameScheduler() {
14431 return _super !== null && _super.apply(this, arguments) || this;
14433 AnimationFrameScheduler.prototype.flush = function (action) {
14434 this.active = true;
14435 this.scheduled = undefined;
14436 var actions = this.actions;
14439 var count = actions.length;
14440 action = action || actions.shift();
14442 if (error = action.execute(action.state, action.delay)) {
14445 } while (++index < count && (action = actions.shift()));
14446 this.active = false;
14448 while (++index < count && (action = actions.shift())) {
14449 action.unsubscribe();
14454 return AnimationFrameScheduler;
14455 }(AsyncScheduler_1.AsyncScheduler));
14456 exports.AnimationFrameScheduler = AnimationFrameScheduler;
14458 },{"./AsyncScheduler":181}],178:[function(require,module,exports){
14460 var __extends = (this && this.__extends) || (function () {
14461 var extendStatics = function (d, b) {
14462 extendStatics = Object.setPrototypeOf ||
14463 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14464 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14465 return extendStatics(d, b);
14467 return function (d, b) {
14468 extendStatics(d, b);
14469 function __() { this.constructor = d; }
14470 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14473 Object.defineProperty(exports, "__esModule", { value: true });
14474 var Immediate_1 = require("../util/Immediate");
14475 var AsyncAction_1 = require("./AsyncAction");
14476 var AsapAction = (function (_super) {
14477 __extends(AsapAction, _super);
14478 function AsapAction(scheduler, work) {
14479 var _this = _super.call(this, scheduler, work) || this;
14480 _this.scheduler = scheduler;
14484 AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
14485 if (delay === void 0) { delay = 0; }
14486 if (delay !== null && delay > 0) {
14487 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
14489 scheduler.actions.push(this);
14490 return scheduler.scheduled || (scheduler.scheduled = Immediate_1.Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
14492 AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
14493 if (delay === void 0) { delay = 0; }
14494 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
14495 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
14497 if (scheduler.actions.length === 0) {
14498 Immediate_1.Immediate.clearImmediate(id);
14499 scheduler.scheduled = undefined;
14504 }(AsyncAction_1.AsyncAction));
14505 exports.AsapAction = AsapAction;
14507 },{"../util/Immediate":194,"./AsyncAction":180}],179:[function(require,module,exports){
14509 var __extends = (this && this.__extends) || (function () {
14510 var extendStatics = function (d, b) {
14511 extendStatics = Object.setPrototypeOf ||
14512 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14513 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14514 return extendStatics(d, b);
14516 return function (d, b) {
14517 extendStatics(d, b);
14518 function __() { this.constructor = d; }
14519 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14522 Object.defineProperty(exports, "__esModule", { value: true });
14523 var AsyncScheduler_1 = require("./AsyncScheduler");
14524 var AsapScheduler = (function (_super) {
14525 __extends(AsapScheduler, _super);
14526 function AsapScheduler() {
14527 return _super !== null && _super.apply(this, arguments) || this;
14529 AsapScheduler.prototype.flush = function (action) {
14530 this.active = true;
14531 this.scheduled = undefined;
14532 var actions = this.actions;
14535 var count = actions.length;
14536 action = action || actions.shift();
14538 if (error = action.execute(action.state, action.delay)) {
14541 } while (++index < count && (action = actions.shift()));
14542 this.active = false;
14544 while (++index < count && (action = actions.shift())) {
14545 action.unsubscribe();
14550 return AsapScheduler;
14551 }(AsyncScheduler_1.AsyncScheduler));
14552 exports.AsapScheduler = AsapScheduler;
14554 },{"./AsyncScheduler":181}],180:[function(require,module,exports){
14556 var __extends = (this && this.__extends) || (function () {
14557 var extendStatics = function (d, b) {
14558 extendStatics = Object.setPrototypeOf ||
14559 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14560 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14561 return extendStatics(d, b);
14563 return function (d, b) {
14564 extendStatics(d, b);
14565 function __() { this.constructor = d; }
14566 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14569 Object.defineProperty(exports, "__esModule", { value: true });
14570 var Action_1 = require("./Action");
14571 var AsyncAction = (function (_super) {
14572 __extends(AsyncAction, _super);
14573 function AsyncAction(scheduler, work) {
14574 var _this = _super.call(this, scheduler, work) || this;
14575 _this.scheduler = scheduler;
14577 _this.pending = false;
14580 AsyncAction.prototype.schedule = function (state, delay) {
14581 if (delay === void 0) { delay = 0; }
14585 this.state = state;
14587 var scheduler = this.scheduler;
14589 this.id = this.recycleAsyncId(scheduler, id, delay);
14591 this.pending = true;
14592 this.delay = delay;
14593 this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
14596 AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
14597 if (delay === void 0) { delay = 0; }
14598 return setInterval(scheduler.flush.bind(scheduler, this), delay);
14600 AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
14601 if (delay === void 0) { delay = 0; }
14602 if (delay !== null && this.delay === delay && this.pending === false) {
14607 AsyncAction.prototype.execute = function (state, delay) {
14609 return new Error('executing a cancelled action');
14611 this.pending = false;
14612 var error = this._execute(state, delay);
14616 else if (this.pending === false && this.id != null) {
14617 this.id = this.recycleAsyncId(this.scheduler, this.id, null);
14620 AsyncAction.prototype._execute = function (state, delay) {
14621 var errored = false;
14622 var errorValue = undefined;
14628 errorValue = !!e && e || new Error(e);
14631 this.unsubscribe();
14635 AsyncAction.prototype._unsubscribe = function () {
14637 var scheduler = this.scheduler;
14638 var actions = scheduler.actions;
14639 var index = actions.indexOf(this);
14642 this.pending = false;
14643 this.scheduler = null;
14644 if (index !== -1) {
14645 actions.splice(index, 1);
14648 this.id = this.recycleAsyncId(scheduler, id, null);
14652 return AsyncAction;
14653 }(Action_1.Action));
14654 exports.AsyncAction = AsyncAction;
14656 },{"./Action":175}],181:[function(require,module,exports){
14658 var __extends = (this && this.__extends) || (function () {
14659 var extendStatics = function (d, b) {
14660 extendStatics = Object.setPrototypeOf ||
14661 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14662 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14663 return extendStatics(d, b);
14665 return function (d, b) {
14666 extendStatics(d, b);
14667 function __() { this.constructor = d; }
14668 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14671 Object.defineProperty(exports, "__esModule", { value: true });
14672 var Scheduler_1 = require("../Scheduler");
14673 var AsyncScheduler = (function (_super) {
14674 __extends(AsyncScheduler, _super);
14675 function AsyncScheduler(SchedulerAction, now) {
14676 if (now === void 0) { now = Scheduler_1.Scheduler.now; }
14677 var _this = _super.call(this, SchedulerAction, function () {
14678 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
14679 return AsyncScheduler.delegate.now();
14685 _this.actions = [];
14686 _this.active = false;
14687 _this.scheduled = undefined;
14690 AsyncScheduler.prototype.schedule = function (work, delay, state) {
14691 if (delay === void 0) { delay = 0; }
14692 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
14693 return AsyncScheduler.delegate.schedule(work, delay, state);
14696 return _super.prototype.schedule.call(this, work, delay, state);
14699 AsyncScheduler.prototype.flush = function (action) {
14700 var actions = this.actions;
14702 actions.push(action);
14706 this.active = true;
14708 if (error = action.execute(action.state, action.delay)) {
14711 } while (action = actions.shift());
14712 this.active = false;
14714 while (action = actions.shift()) {
14715 action.unsubscribe();
14720 return AsyncScheduler;
14721 }(Scheduler_1.Scheduler));
14722 exports.AsyncScheduler = AsyncScheduler;
14724 },{"../Scheduler":35}],182:[function(require,module,exports){
14726 var __extends = (this && this.__extends) || (function () {
14727 var extendStatics = function (d, b) {
14728 extendStatics = Object.setPrototypeOf ||
14729 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14730 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14731 return extendStatics(d, b);
14733 return function (d, b) {
14734 extendStatics(d, b);
14735 function __() { this.constructor = d; }
14736 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14739 Object.defineProperty(exports, "__esModule", { value: true });
14740 var AsyncAction_1 = require("./AsyncAction");
14741 var QueueAction = (function (_super) {
14742 __extends(QueueAction, _super);
14743 function QueueAction(scheduler, work) {
14744 var _this = _super.call(this, scheduler, work) || this;
14745 _this.scheduler = scheduler;
14749 QueueAction.prototype.schedule = function (state, delay) {
14750 if (delay === void 0) { delay = 0; }
14752 return _super.prototype.schedule.call(this, state, delay);
14754 this.delay = delay;
14755 this.state = state;
14756 this.scheduler.flush(this);
14759 QueueAction.prototype.execute = function (state, delay) {
14760 return (delay > 0 || this.closed) ?
14761 _super.prototype.execute.call(this, state, delay) :
14762 this._execute(state, delay);
14764 QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
14765 if (delay === void 0) { delay = 0; }
14766 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
14767 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
14769 return scheduler.flush(this);
14771 return QueueAction;
14772 }(AsyncAction_1.AsyncAction));
14773 exports.QueueAction = QueueAction;
14775 },{"./AsyncAction":180}],183:[function(require,module,exports){
14777 var __extends = (this && this.__extends) || (function () {
14778 var extendStatics = function (d, b) {
14779 extendStatics = Object.setPrototypeOf ||
14780 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14781 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14782 return extendStatics(d, b);
14784 return function (d, b) {
14785 extendStatics(d, b);
14786 function __() { this.constructor = d; }
14787 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14790 Object.defineProperty(exports, "__esModule", { value: true });
14791 var AsyncScheduler_1 = require("./AsyncScheduler");
14792 var QueueScheduler = (function (_super) {
14793 __extends(QueueScheduler, _super);
14794 function QueueScheduler() {
14795 return _super !== null && _super.apply(this, arguments) || this;
14797 return QueueScheduler;
14798 }(AsyncScheduler_1.AsyncScheduler));
14799 exports.QueueScheduler = QueueScheduler;
14801 },{"./AsyncScheduler":181}],184:[function(require,module,exports){
14803 var __extends = (this && this.__extends) || (function () {
14804 var extendStatics = function (d, b) {
14805 extendStatics = Object.setPrototypeOf ||
14806 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14807 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14808 return extendStatics(d, b);
14810 return function (d, b) {
14811 extendStatics(d, b);
14812 function __() { this.constructor = d; }
14813 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14816 Object.defineProperty(exports, "__esModule", { value: true });
14817 var AsyncAction_1 = require("./AsyncAction");
14818 var AsyncScheduler_1 = require("./AsyncScheduler");
14819 var VirtualTimeScheduler = (function (_super) {
14820 __extends(VirtualTimeScheduler, _super);
14821 function VirtualTimeScheduler(SchedulerAction, maxFrames) {
14822 if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
14823 if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
14824 var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
14825 _this.maxFrames = maxFrames;
14830 VirtualTimeScheduler.prototype.flush = function () {
14831 var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
14833 while ((action = actions.shift()) && (this.frame = action.delay) <= maxFrames) {
14834 if (error = action.execute(action.state, action.delay)) {
14839 while (action = actions.shift()) {
14840 action.unsubscribe();
14845 VirtualTimeScheduler.frameTimeFactor = 10;
14846 return VirtualTimeScheduler;
14847 }(AsyncScheduler_1.AsyncScheduler));
14848 exports.VirtualTimeScheduler = VirtualTimeScheduler;
14849 var VirtualAction = (function (_super) {
14850 __extends(VirtualAction, _super);
14851 function VirtualAction(scheduler, work, index) {
14852 if (index === void 0) { index = scheduler.index += 1; }
14853 var _this = _super.call(this, scheduler, work) || this;
14854 _this.scheduler = scheduler;
14856 _this.index = index;
14857 _this.active = true;
14858 _this.index = scheduler.index = index;
14861 VirtualAction.prototype.schedule = function (state, delay) {
14862 if (delay === void 0) { delay = 0; }
14864 return _super.prototype.schedule.call(this, state, delay);
14866 this.active = false;
14867 var action = new VirtualAction(this.scheduler, this.work);
14869 return action.schedule(state, delay);
14871 VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
14872 if (delay === void 0) { delay = 0; }
14873 this.delay = scheduler.frame + delay;
14874 var actions = scheduler.actions;
14875 actions.push(this);
14876 actions.sort(VirtualAction.sortActions);
14879 VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
14880 if (delay === void 0) { delay = 0; }
14883 VirtualAction.prototype._execute = function (state, delay) {
14884 if (this.active === true) {
14885 return _super.prototype._execute.call(this, state, delay);
14888 VirtualAction.sortActions = function (a, b) {
14889 if (a.delay === b.delay) {
14890 if (a.index === b.index) {
14893 else if (a.index > b.index) {
14900 else if (a.delay > b.delay) {
14907 return VirtualAction;
14908 }(AsyncAction_1.AsyncAction));
14909 exports.VirtualAction = VirtualAction;
14911 },{"./AsyncAction":180,"./AsyncScheduler":181}],185:[function(require,module,exports){
14913 Object.defineProperty(exports, "__esModule", { value: true });
14914 var AnimationFrameAction_1 = require("./AnimationFrameAction");
14915 var AnimationFrameScheduler_1 = require("./AnimationFrameScheduler");
14916 exports.animationFrame = new AnimationFrameScheduler_1.AnimationFrameScheduler(AnimationFrameAction_1.AnimationFrameAction);
14918 },{"./AnimationFrameAction":176,"./AnimationFrameScheduler":177}],186:[function(require,module,exports){
14920 Object.defineProperty(exports, "__esModule", { value: true });
14921 var AsapAction_1 = require("./AsapAction");
14922 var AsapScheduler_1 = require("./AsapScheduler");
14923 exports.asap = new AsapScheduler_1.AsapScheduler(AsapAction_1.AsapAction);
14925 },{"./AsapAction":178,"./AsapScheduler":179}],187:[function(require,module,exports){
14927 Object.defineProperty(exports, "__esModule", { value: true });
14928 var AsyncAction_1 = require("./AsyncAction");
14929 var AsyncScheduler_1 = require("./AsyncScheduler");
14930 exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction);
14932 },{"./AsyncAction":180,"./AsyncScheduler":181}],188:[function(require,module,exports){
14934 Object.defineProperty(exports, "__esModule", { value: true });
14935 var QueueAction_1 = require("./QueueAction");
14936 var QueueScheduler_1 = require("./QueueScheduler");
14937 exports.queue = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction);
14939 },{"./QueueAction":182,"./QueueScheduler":183}],189:[function(require,module,exports){
14941 Object.defineProperty(exports, "__esModule", { value: true });
14942 function getSymbolIterator() {
14943 if (typeof Symbol !== 'function' || !Symbol.iterator) {
14944 return '@@iterator';
14946 return Symbol.iterator;
14948 exports.getSymbolIterator = getSymbolIterator;
14949 exports.iterator = getSymbolIterator();
14950 exports.$$iterator = exports.iterator;
14952 },{}],190:[function(require,module,exports){
14954 Object.defineProperty(exports, "__esModule", { value: true });
14955 exports.observable = typeof Symbol === 'function' && Symbol.observable || '@@observable';
14957 },{}],191:[function(require,module,exports){
14959 Object.defineProperty(exports, "__esModule", { value: true });
14960 exports.rxSubscriber = typeof Symbol === 'function'
14961 ? Symbol('rxSubscriber')
14962 : '@@rxSubscriber_' + Math.random();
14963 exports.$$rxSubscriber = exports.rxSubscriber;
14965 },{}],192:[function(require,module,exports){
14967 Object.defineProperty(exports, "__esModule", { value: true });
14968 function ArgumentOutOfRangeErrorImpl() {
14970 this.message = 'argument out of range';
14971 this.name = 'ArgumentOutOfRangeError';
14974 ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
14975 exports.ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
14977 },{}],193:[function(require,module,exports){
14979 Object.defineProperty(exports, "__esModule", { value: true });
14980 function EmptyErrorImpl() {
14982 this.message = 'no elements in sequence';
14983 this.name = 'EmptyError';
14986 EmptyErrorImpl.prototype = Object.create(Error.prototype);
14987 exports.EmptyError = EmptyErrorImpl;
14989 },{}],194:[function(require,module,exports){
14991 Object.defineProperty(exports, "__esModule", { value: true });
14992 var nextHandle = 1;
14993 var tasksByHandle = {};
14994 function runIfPresent(handle) {
14995 var cb = tasksByHandle[handle];
15000 exports.Immediate = {
15001 setImmediate: function (cb) {
15002 var handle = nextHandle++;
15003 tasksByHandle[handle] = cb;
15004 Promise.resolve().then(function () { return runIfPresent(handle); });
15007 clearImmediate: function (handle) {
15008 delete tasksByHandle[handle];
15012 },{}],195:[function(require,module,exports){
15014 Object.defineProperty(exports, "__esModule", { value: true });
15015 function ObjectUnsubscribedErrorImpl() {
15017 this.message = 'object unsubscribed';
15018 this.name = 'ObjectUnsubscribedError';
15021 ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
15022 exports.ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
15024 },{}],196:[function(require,module,exports){
15026 Object.defineProperty(exports, "__esModule", { value: true });
15027 function TimeoutErrorImpl() {
15029 this.message = 'Timeout has occurred';
15030 this.name = 'TimeoutError';
15033 TimeoutErrorImpl.prototype = Object.create(Error.prototype);
15034 exports.TimeoutError = TimeoutErrorImpl;
15036 },{}],197:[function(require,module,exports){
15038 Object.defineProperty(exports, "__esModule", { value: true });
15039 function UnsubscriptionErrorImpl(errors) {
15041 this.message = errors ?
15042 errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
15043 this.name = 'UnsubscriptionError';
15044 this.errors = errors;
15047 UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
15048 exports.UnsubscriptionError = UnsubscriptionErrorImpl;
15050 },{}],198:[function(require,module,exports){
15052 Object.defineProperty(exports, "__esModule", { value: true });
15053 var Subscriber_1 = require("../Subscriber");
15054 function canReportError(observer) {
15056 var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
15057 if (closed_1 || isStopped) {
15060 else if (destination && destination instanceof Subscriber_1.Subscriber) {
15061 observer = destination;
15069 exports.canReportError = canReportError;
15071 },{"../Subscriber":38}],199:[function(require,module,exports){
15073 Object.defineProperty(exports, "__esModule", { value: true });
15074 exports.errorObject = { e: {} };
15076 },{}],200:[function(require,module,exports){
15078 Object.defineProperty(exports, "__esModule", { value: true });
15079 function hostReportError(err) {
15080 setTimeout(function () { throw err; });
15082 exports.hostReportError = hostReportError;
15084 },{}],201:[function(require,module,exports){
15086 Object.defineProperty(exports, "__esModule", { value: true });
15087 function identity(x) {
15090 exports.identity = identity;
15092 },{}],202:[function(require,module,exports){
15094 Object.defineProperty(exports, "__esModule", { value: true });
15095 exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
15097 },{}],203:[function(require,module,exports){
15099 Object.defineProperty(exports, "__esModule", { value: true });
15100 exports.isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
15102 },{}],204:[function(require,module,exports){
15104 Object.defineProperty(exports, "__esModule", { value: true });
15105 function isDate(value) {
15106 return value instanceof Date && !isNaN(+value);
15108 exports.isDate = isDate;
15110 },{}],205:[function(require,module,exports){
15112 Object.defineProperty(exports, "__esModule", { value: true });
15113 function isFunction(x) {
15114 return typeof x === 'function';
15116 exports.isFunction = isFunction;
15118 },{}],206:[function(require,module,exports){
15120 Object.defineProperty(exports, "__esModule", { value: true });
15121 var observable_1 = require("../symbol/observable");
15122 function isInteropObservable(input) {
15123 return input && typeof input[observable_1.observable] === 'function';
15125 exports.isInteropObservable = isInteropObservable;
15127 },{"../symbol/observable":190}],207:[function(require,module,exports){
15129 Object.defineProperty(exports, "__esModule", { value: true });
15130 var iterator_1 = require("../symbol/iterator");
15131 function isIterable(input) {
15132 return input && typeof input[iterator_1.iterator] === 'function';
15134 exports.isIterable = isIterable;
15136 },{"../symbol/iterator":189}],208:[function(require,module,exports){
15138 Object.defineProperty(exports, "__esModule", { value: true });
15139 var isArray_1 = require("./isArray");
15140 function isNumeric(val) {
15141 return !isArray_1.isArray(val) && (val - parseFloat(val) + 1) >= 0;
15143 exports.isNumeric = isNumeric;
15145 },{"./isArray":202}],209:[function(require,module,exports){
15147 Object.defineProperty(exports, "__esModule", { value: true });
15148 function isObject(x) {
15149 return x != null && typeof x === 'object';
15151 exports.isObject = isObject;
15153 },{}],210:[function(require,module,exports){
15155 Object.defineProperty(exports, "__esModule", { value: true });
15156 var Observable_1 = require("../Observable");
15157 function isObservable(obj) {
15158 return !!obj && (obj instanceof Observable_1.Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
15160 exports.isObservable = isObservable;
15162 },{"../Observable":31}],211:[function(require,module,exports){
15164 Object.defineProperty(exports, "__esModule", { value: true });
15165 function isPromise(value) {
15166 return value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
15168 exports.isPromise = isPromise;
15170 },{}],212:[function(require,module,exports){
15172 Object.defineProperty(exports, "__esModule", { value: true });
15173 function isScheduler(value) {
15174 return value && typeof value.schedule === 'function';
15176 exports.isScheduler = isScheduler;
15178 },{}],213:[function(require,module,exports){
15180 Object.defineProperty(exports, "__esModule", { value: true });
15181 function noop() { }
15182 exports.noop = noop;
15184 },{}],214:[function(require,module,exports){
15186 Object.defineProperty(exports, "__esModule", { value: true });
15187 function not(pred, thisArg) {
15188 function notPred() {
15189 return !(notPred.pred.apply(notPred.thisArg, arguments));
15191 notPred.pred = pred;
15192 notPred.thisArg = thisArg;
15197 },{}],215:[function(require,module,exports){
15199 Object.defineProperty(exports, "__esModule", { value: true });
15200 var noop_1 = require("./noop");
15203 for (var _i = 0; _i < arguments.length; _i++) {
15204 fns[_i] = arguments[_i];
15206 return pipeFromArray(fns);
15208 exports.pipe = pipe;
15209 function pipeFromArray(fns) {
15211 return noop_1.noop;
15213 if (fns.length === 1) {
15216 return function piped(input) {
15217 return fns.reduce(function (prev, fn) { return fn(prev); }, input);
15220 exports.pipeFromArray = pipeFromArray;
15222 },{"./noop":213}],216:[function(require,module,exports){
15224 Object.defineProperty(exports, "__esModule", { value: true });
15225 var Observable_1 = require("../Observable");
15226 var subscribeToArray_1 = require("./subscribeToArray");
15227 var subscribeToPromise_1 = require("./subscribeToPromise");
15228 var subscribeToIterable_1 = require("./subscribeToIterable");
15229 var subscribeToObservable_1 = require("./subscribeToObservable");
15230 var isArrayLike_1 = require("./isArrayLike");
15231 var isPromise_1 = require("./isPromise");
15232 var isObject_1 = require("./isObject");
15233 var iterator_1 = require("../symbol/iterator");
15234 var observable_1 = require("../symbol/observable");
15235 exports.subscribeTo = function (result) {
15236 if (result instanceof Observable_1.Observable) {
15237 return function (subscriber) {
15238 if (result._isScalar) {
15239 subscriber.next(result.value);
15240 subscriber.complete();
15244 return result.subscribe(subscriber);
15248 else if (result && typeof result[observable_1.observable] === 'function') {
15249 return subscribeToObservable_1.subscribeToObservable(result);
15251 else if (isArrayLike_1.isArrayLike(result)) {
15252 return subscribeToArray_1.subscribeToArray(result);
15254 else if (isPromise_1.isPromise(result)) {
15255 return subscribeToPromise_1.subscribeToPromise(result);
15257 else if (result && typeof result[iterator_1.iterator] === 'function') {
15258 return subscribeToIterable_1.subscribeToIterable(result);
15261 var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'";
15262 var msg = "You provided " + value + " where a stream was expected."
15263 + ' You can provide an Observable, Promise, Array, or Iterable.';
15264 throw new TypeError(msg);
15268 },{"../Observable":31,"../symbol/iterator":189,"../symbol/observable":190,"./isArrayLike":203,"./isObject":209,"./isPromise":211,"./subscribeToArray":217,"./subscribeToIterable":218,"./subscribeToObservable":219,"./subscribeToPromise":220}],217:[function(require,module,exports){
15270 Object.defineProperty(exports, "__esModule", { value: true });
15271 exports.subscribeToArray = function (array) { return function (subscriber) {
15272 for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
15273 subscriber.next(array[i]);
15275 if (!subscriber.closed) {
15276 subscriber.complete();
15280 },{}],218:[function(require,module,exports){
15282 Object.defineProperty(exports, "__esModule", { value: true });
15283 var iterator_1 = require("../symbol/iterator");
15284 exports.subscribeToIterable = function (iterable) { return function (subscriber) {
15285 var iterator = iterable[iterator_1.iterator]();
15287 var item = iterator.next();
15289 subscriber.complete();
15292 subscriber.next(item.value);
15293 if (subscriber.closed) {
15297 if (typeof iterator.return === 'function') {
15298 subscriber.add(function () {
15299 if (iterator.return) {
15307 },{"../symbol/iterator":189}],219:[function(require,module,exports){
15309 Object.defineProperty(exports, "__esModule", { value: true });
15310 var observable_1 = require("../symbol/observable");
15311 exports.subscribeToObservable = function (obj) { return function (subscriber) {
15312 var obs = obj[observable_1.observable]();
15313 if (typeof obs.subscribe !== 'function') {
15314 throw new TypeError('Provided object does not correctly implement Symbol.observable');
15317 return obs.subscribe(subscriber);
15321 },{"../symbol/observable":190}],220:[function(require,module,exports){
15323 Object.defineProperty(exports, "__esModule", { value: true });
15324 var hostReportError_1 = require("./hostReportError");
15325 exports.subscribeToPromise = function (promise) { return function (subscriber) {
15326 promise.then(function (value) {
15327 if (!subscriber.closed) {
15328 subscriber.next(value);
15329 subscriber.complete();
15331 }, function (err) { return subscriber.error(err); })
15332 .then(null, hostReportError_1.hostReportError);
15336 },{"./hostReportError":200}],221:[function(require,module,exports){
15338 Object.defineProperty(exports, "__esModule", { value: true });
15339 var InnerSubscriber_1 = require("../InnerSubscriber");
15340 var subscribeTo_1 = require("./subscribeTo");
15341 function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, destination) {
15342 if (destination === void 0) { destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
15343 if (destination.closed) {
15346 return subscribeTo_1.subscribeTo(result)(destination);
15348 exports.subscribeToResult = subscribeToResult;
15350 },{"../InnerSubscriber":29,"./subscribeTo":216}],222:[function(require,module,exports){
15352 Object.defineProperty(exports, "__esModule", { value: true });
15353 var Subscriber_1 = require("../Subscriber");
15354 var rxSubscriber_1 = require("../symbol/rxSubscriber");
15355 var Observer_1 = require("../Observer");
15356 function toSubscriber(nextOrObserver, error, complete) {
15357 if (nextOrObserver) {
15358 if (nextOrObserver instanceof Subscriber_1.Subscriber) {
15359 return nextOrObserver;
15361 if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
15362 return nextOrObserver[rxSubscriber_1.rxSubscriber]();
15365 if (!nextOrObserver && !error && !complete) {
15366 return new Subscriber_1.Subscriber(Observer_1.empty);
15368 return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
15370 exports.toSubscriber = toSubscriber;
15372 },{"../Observer":32,"../Subscriber":38,"../symbol/rxSubscriber":191}],223:[function(require,module,exports){
15374 Object.defineProperty(exports, "__esModule", { value: true });
15375 var errorObject_1 = require("./errorObject");
15376 var tryCatchTarget;
15377 function tryCatcher() {
15379 return tryCatchTarget.apply(this, arguments);
15382 errorObject_1.errorObject.e = e;
15383 return errorObject_1.errorObject;
15386 function tryCatch(fn) {
15387 tryCatchTarget = fn;
15390 exports.tryCatch = tryCatch;
15392 },{"./errorObject":199}],224:[function(require,module,exports){
15394 Object.defineProperty(exports, "__esModule", { value: true });
15395 var audit_1 = require("../internal/operators/audit");
15396 exports.audit = audit_1.audit;
15397 var auditTime_1 = require("../internal/operators/auditTime");
15398 exports.auditTime = auditTime_1.auditTime;
15399 var buffer_1 = require("../internal/operators/buffer");
15400 exports.buffer = buffer_1.buffer;
15401 var bufferCount_1 = require("../internal/operators/bufferCount");
15402 exports.bufferCount = bufferCount_1.bufferCount;
15403 var bufferTime_1 = require("../internal/operators/bufferTime");
15404 exports.bufferTime = bufferTime_1.bufferTime;
15405 var bufferToggle_1 = require("../internal/operators/bufferToggle");
15406 exports.bufferToggle = bufferToggle_1.bufferToggle;
15407 var bufferWhen_1 = require("../internal/operators/bufferWhen");
15408 exports.bufferWhen = bufferWhen_1.bufferWhen;
15409 var catchError_1 = require("../internal/operators/catchError");
15410 exports.catchError = catchError_1.catchError;
15411 var combineAll_1 = require("../internal/operators/combineAll");
15412 exports.combineAll = combineAll_1.combineAll;
15413 var combineLatest_1 = require("../internal/operators/combineLatest");
15414 exports.combineLatest = combineLatest_1.combineLatest;
15415 var concat_1 = require("../internal/operators/concat");
15416 exports.concat = concat_1.concat;
15417 var concatAll_1 = require("../internal/operators/concatAll");
15418 exports.concatAll = concatAll_1.concatAll;
15419 var concatMap_1 = require("../internal/operators/concatMap");
15420 exports.concatMap = concatMap_1.concatMap;
15421 var concatMapTo_1 = require("../internal/operators/concatMapTo");
15422 exports.concatMapTo = concatMapTo_1.concatMapTo;
15423 var count_1 = require("../internal/operators/count");
15424 exports.count = count_1.count;
15425 var debounce_1 = require("../internal/operators/debounce");
15426 exports.debounce = debounce_1.debounce;
15427 var debounceTime_1 = require("../internal/operators/debounceTime");
15428 exports.debounceTime = debounceTime_1.debounceTime;
15429 var defaultIfEmpty_1 = require("../internal/operators/defaultIfEmpty");
15430 exports.defaultIfEmpty = defaultIfEmpty_1.defaultIfEmpty;
15431 var delay_1 = require("../internal/operators/delay");
15432 exports.delay = delay_1.delay;
15433 var delayWhen_1 = require("../internal/operators/delayWhen");
15434 exports.delayWhen = delayWhen_1.delayWhen;
15435 var dematerialize_1 = require("../internal/operators/dematerialize");
15436 exports.dematerialize = dematerialize_1.dematerialize;
15437 var distinct_1 = require("../internal/operators/distinct");
15438 exports.distinct = distinct_1.distinct;
15439 var distinctUntilChanged_1 = require("../internal/operators/distinctUntilChanged");
15440 exports.distinctUntilChanged = distinctUntilChanged_1.distinctUntilChanged;
15441 var distinctUntilKeyChanged_1 = require("../internal/operators/distinctUntilKeyChanged");
15442 exports.distinctUntilKeyChanged = distinctUntilKeyChanged_1.distinctUntilKeyChanged;
15443 var elementAt_1 = require("../internal/operators/elementAt");
15444 exports.elementAt = elementAt_1.elementAt;
15445 var endWith_1 = require("../internal/operators/endWith");
15446 exports.endWith = endWith_1.endWith;
15447 var every_1 = require("../internal/operators/every");
15448 exports.every = every_1.every;
15449 var exhaust_1 = require("../internal/operators/exhaust");
15450 exports.exhaust = exhaust_1.exhaust;
15451 var exhaustMap_1 = require("../internal/operators/exhaustMap");
15452 exports.exhaustMap = exhaustMap_1.exhaustMap;
15453 var expand_1 = require("../internal/operators/expand");
15454 exports.expand = expand_1.expand;
15455 var filter_1 = require("../internal/operators/filter");
15456 exports.filter = filter_1.filter;
15457 var finalize_1 = require("../internal/operators/finalize");
15458 exports.finalize = finalize_1.finalize;
15459 var find_1 = require("../internal/operators/find");
15460 exports.find = find_1.find;
15461 var findIndex_1 = require("../internal/operators/findIndex");
15462 exports.findIndex = findIndex_1.findIndex;
15463 var first_1 = require("../internal/operators/first");
15464 exports.first = first_1.first;
15465 var groupBy_1 = require("../internal/operators/groupBy");
15466 exports.groupBy = groupBy_1.groupBy;
15467 var ignoreElements_1 = require("../internal/operators/ignoreElements");
15468 exports.ignoreElements = ignoreElements_1.ignoreElements;
15469 var isEmpty_1 = require("../internal/operators/isEmpty");
15470 exports.isEmpty = isEmpty_1.isEmpty;
15471 var last_1 = require("../internal/operators/last");
15472 exports.last = last_1.last;
15473 var map_1 = require("../internal/operators/map");
15474 exports.map = map_1.map;
15475 var mapTo_1 = require("../internal/operators/mapTo");
15476 exports.mapTo = mapTo_1.mapTo;
15477 var materialize_1 = require("../internal/operators/materialize");
15478 exports.materialize = materialize_1.materialize;
15479 var max_1 = require("../internal/operators/max");
15480 exports.max = max_1.max;
15481 var merge_1 = require("../internal/operators/merge");
15482 exports.merge = merge_1.merge;
15483 var mergeAll_1 = require("../internal/operators/mergeAll");
15484 exports.mergeAll = mergeAll_1.mergeAll;
15485 var mergeMap_1 = require("../internal/operators/mergeMap");
15486 exports.mergeMap = mergeMap_1.mergeMap;
15487 var mergeMap_2 = require("../internal/operators/mergeMap");
15488 exports.flatMap = mergeMap_2.mergeMap;
15489 var mergeMapTo_1 = require("../internal/operators/mergeMapTo");
15490 exports.mergeMapTo = mergeMapTo_1.mergeMapTo;
15491 var mergeScan_1 = require("../internal/operators/mergeScan");
15492 exports.mergeScan = mergeScan_1.mergeScan;
15493 var min_1 = require("../internal/operators/min");
15494 exports.min = min_1.min;
15495 var multicast_1 = require("../internal/operators/multicast");
15496 exports.multicast = multicast_1.multicast;
15497 var observeOn_1 = require("../internal/operators/observeOn");
15498 exports.observeOn = observeOn_1.observeOn;
15499 var onErrorResumeNext_1 = require("../internal/operators/onErrorResumeNext");
15500 exports.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext;
15501 var pairwise_1 = require("../internal/operators/pairwise");
15502 exports.pairwise = pairwise_1.pairwise;
15503 var partition_1 = require("../internal/operators/partition");
15504 exports.partition = partition_1.partition;
15505 var pluck_1 = require("../internal/operators/pluck");
15506 exports.pluck = pluck_1.pluck;
15507 var publish_1 = require("../internal/operators/publish");
15508 exports.publish = publish_1.publish;
15509 var publishBehavior_1 = require("../internal/operators/publishBehavior");
15510 exports.publishBehavior = publishBehavior_1.publishBehavior;
15511 var publishLast_1 = require("../internal/operators/publishLast");
15512 exports.publishLast = publishLast_1.publishLast;
15513 var publishReplay_1 = require("../internal/operators/publishReplay");
15514 exports.publishReplay = publishReplay_1.publishReplay;
15515 var race_1 = require("../internal/operators/race");
15516 exports.race = race_1.race;
15517 var reduce_1 = require("../internal/operators/reduce");
15518 exports.reduce = reduce_1.reduce;
15519 var repeat_1 = require("../internal/operators/repeat");
15520 exports.repeat = repeat_1.repeat;
15521 var repeatWhen_1 = require("../internal/operators/repeatWhen");
15522 exports.repeatWhen = repeatWhen_1.repeatWhen;
15523 var retry_1 = require("../internal/operators/retry");
15524 exports.retry = retry_1.retry;
15525 var retryWhen_1 = require("../internal/operators/retryWhen");
15526 exports.retryWhen = retryWhen_1.retryWhen;
15527 var refCount_1 = require("../internal/operators/refCount");
15528 exports.refCount = refCount_1.refCount;
15529 var sample_1 = require("../internal/operators/sample");
15530 exports.sample = sample_1.sample;
15531 var sampleTime_1 = require("../internal/operators/sampleTime");
15532 exports.sampleTime = sampleTime_1.sampleTime;
15533 var scan_1 = require("../internal/operators/scan");
15534 exports.scan = scan_1.scan;
15535 var sequenceEqual_1 = require("../internal/operators/sequenceEqual");
15536 exports.sequenceEqual = sequenceEqual_1.sequenceEqual;
15537 var share_1 = require("../internal/operators/share");
15538 exports.share = share_1.share;
15539 var shareReplay_1 = require("../internal/operators/shareReplay");
15540 exports.shareReplay = shareReplay_1.shareReplay;
15541 var single_1 = require("../internal/operators/single");
15542 exports.single = single_1.single;
15543 var skip_1 = require("../internal/operators/skip");
15544 exports.skip = skip_1.skip;
15545 var skipLast_1 = require("../internal/operators/skipLast");
15546 exports.skipLast = skipLast_1.skipLast;
15547 var skipUntil_1 = require("../internal/operators/skipUntil");
15548 exports.skipUntil = skipUntil_1.skipUntil;
15549 var skipWhile_1 = require("../internal/operators/skipWhile");
15550 exports.skipWhile = skipWhile_1.skipWhile;
15551 var startWith_1 = require("../internal/operators/startWith");
15552 exports.startWith = startWith_1.startWith;
15553 var subscribeOn_1 = require("../internal/operators/subscribeOn");
15554 exports.subscribeOn = subscribeOn_1.subscribeOn;
15555 var switchAll_1 = require("../internal/operators/switchAll");
15556 exports.switchAll = switchAll_1.switchAll;
15557 var switchMap_1 = require("../internal/operators/switchMap");
15558 exports.switchMap = switchMap_1.switchMap;
15559 var switchMapTo_1 = require("../internal/operators/switchMapTo");
15560 exports.switchMapTo = switchMapTo_1.switchMapTo;
15561 var take_1 = require("../internal/operators/take");
15562 exports.take = take_1.take;
15563 var takeLast_1 = require("../internal/operators/takeLast");
15564 exports.takeLast = takeLast_1.takeLast;
15565 var takeUntil_1 = require("../internal/operators/takeUntil");
15566 exports.takeUntil = takeUntil_1.takeUntil;
15567 var takeWhile_1 = require("../internal/operators/takeWhile");
15568 exports.takeWhile = takeWhile_1.takeWhile;
15569 var tap_1 = require("../internal/operators/tap");
15570 exports.tap = tap_1.tap;
15571 var throttle_1 = require("../internal/operators/throttle");
15572 exports.throttle = throttle_1.throttle;
15573 var throttleTime_1 = require("../internal/operators/throttleTime");
15574 exports.throttleTime = throttleTime_1.throttleTime;
15575 var throwIfEmpty_1 = require("../internal/operators/throwIfEmpty");
15576 exports.throwIfEmpty = throwIfEmpty_1.throwIfEmpty;
15577 var timeInterval_1 = require("../internal/operators/timeInterval");
15578 exports.timeInterval = timeInterval_1.timeInterval;
15579 var timeout_1 = require("../internal/operators/timeout");
15580 exports.timeout = timeout_1.timeout;
15581 var timeoutWith_1 = require("../internal/operators/timeoutWith");
15582 exports.timeoutWith = timeoutWith_1.timeoutWith;
15583 var timestamp_1 = require("../internal/operators/timestamp");
15584 exports.timestamp = timestamp_1.timestamp;
15585 var toArray_1 = require("../internal/operators/toArray");
15586 exports.toArray = toArray_1.toArray;
15587 var window_1 = require("../internal/operators/window");
15588 exports.window = window_1.window;
15589 var windowCount_1 = require("../internal/operators/windowCount");
15590 exports.windowCount = windowCount_1.windowCount;
15591 var windowTime_1 = require("../internal/operators/windowTime");
15592 exports.windowTime = windowTime_1.windowTime;
15593 var windowToggle_1 = require("../internal/operators/windowToggle");
15594 exports.windowToggle = windowToggle_1.windowToggle;
15595 var windowWhen_1 = require("../internal/operators/windowWhen");
15596 exports.windowWhen = windowWhen_1.windowWhen;
15597 var withLatestFrom_1 = require("../internal/operators/withLatestFrom");
15598 exports.withLatestFrom = withLatestFrom_1.withLatestFrom;
15599 var zip_1 = require("../internal/operators/zip");
15600 exports.zip = zip_1.zip;
15601 var zipAll_1 = require("../internal/operators/zipAll");
15602 exports.zipAll = zipAll_1.zipAll;
15604 },{"../internal/operators/audit":72,"../internal/operators/auditTime":73,"../internal/operators/buffer":74,"../internal/operators/bufferCount":75,"../internal/operators/bufferTime":76,"../internal/operators/bufferToggle":77,"../internal/operators/bufferWhen":78,"../internal/operators/catchError":79,"../internal/operators/combineAll":80,"../internal/operators/combineLatest":81,"../internal/operators/concat":82,"../internal/operators/concatAll":83,"../internal/operators/concatMap":84,"../internal/operators/concatMapTo":85,"../internal/operators/count":86,"../internal/operators/debounce":87,"../internal/operators/debounceTime":88,"../internal/operators/defaultIfEmpty":89,"../internal/operators/delay":90,"../internal/operators/delayWhen":91,"../internal/operators/dematerialize":92,"../internal/operators/distinct":93,"../internal/operators/distinctUntilChanged":94,"../internal/operators/distinctUntilKeyChanged":95,"../internal/operators/elementAt":96,"../internal/operators/endWith":97,"../internal/operators/every":98,"../internal/operators/exhaust":99,"../internal/operators/exhaustMap":100,"../internal/operators/expand":101,"../internal/operators/filter":102,"../internal/operators/finalize":103,"../internal/operators/find":104,"../internal/operators/findIndex":105,"../internal/operators/first":106,"../internal/operators/groupBy":107,"../internal/operators/ignoreElements":108,"../internal/operators/isEmpty":109,"../internal/operators/last":110,"../internal/operators/map":111,"../internal/operators/mapTo":112,"../internal/operators/materialize":113,"../internal/operators/max":114,"../internal/operators/merge":115,"../internal/operators/mergeAll":116,"../internal/operators/mergeMap":117,"../internal/operators/mergeMapTo":118,"../internal/operators/mergeScan":119,"../internal/operators/min":120,"../internal/operators/multicast":121,"../internal/operators/observeOn":122,"../internal/operators/onErrorResumeNext":123,"../internal/operators/pairwise":124,"../internal/operators/partition":125,"../internal/operators/pluck":126,"../internal/operators/publish":127,"../internal/operators/publishBehavior":128,"../internal/operators/publishLast":129,"../internal/operators/publishReplay":130,"../internal/operators/race":131,"../internal/operators/reduce":132,"../internal/operators/refCount":133,"../internal/operators/repeat":134,"../internal/operators/repeatWhen":135,"../internal/operators/retry":136,"../internal/operators/retryWhen":137,"../internal/operators/sample":138,"../internal/operators/sampleTime":139,"../internal/operators/scan":140,"../internal/operators/sequenceEqual":141,"../internal/operators/share":142,"../internal/operators/shareReplay":143,"../internal/operators/single":144,"../internal/operators/skip":145,"../internal/operators/skipLast":146,"../internal/operators/skipUntil":147,"../internal/operators/skipWhile":148,"../internal/operators/startWith":149,"../internal/operators/subscribeOn":150,"../internal/operators/switchAll":151,"../internal/operators/switchMap":152,"../internal/operators/switchMapTo":153,"../internal/operators/take":154,"../internal/operators/takeLast":155,"../internal/operators/takeUntil":156,"../internal/operators/takeWhile":157,"../internal/operators/tap":158,"../internal/operators/throttle":159,"../internal/operators/throttleTime":160,"../internal/operators/throwIfEmpty":161,"../internal/operators/timeInterval":162,"../internal/operators/timeout":163,"../internal/operators/timeoutWith":164,"../internal/operators/timestamp":165,"../internal/operators/toArray":166,"../internal/operators/window":167,"../internal/operators/windowCount":168,"../internal/operators/windowTime":169,"../internal/operators/windowToggle":170,"../internal/operators/windowWhen":171,"../internal/operators/withLatestFrom":172,"../internal/operators/zip":173,"../internal/operators/zipAll":174}],225:[function(require,module,exports){
15605 // threejs.org/license
15606 (function(l,ya){"object"===typeof exports&&"undefined"!==typeof module?ya(exports):"function"===typeof define&&define.amd?define(["exports"],ya):ya(l.THREE={})})(this,function(l){function ya(){}function z(a,b){this.x=a||0;this.y=b||0}function I(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function fa(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function p(a,
15607 b,c){this.x=a||0;this.y=b||0;this.z=c||0}function ra(){this.elements=[1,0,0,0,1,0,0,0,1];0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function T(a,b,c,d,e,f,g,h,k,m){Object.defineProperty(this,"id",{value:Ef++});this.uuid=H.generateUUID();this.name="";this.image=void 0!==a?a:T.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:T.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:1001;this.wrapT=void 0!==d?d:1001;this.magFilter=void 0!==
15608 e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==k?k:1;this.format=void 0!==g?g:1023;this.type=void 0!==h?h:1009;this.offset=new z(0,0);this.repeat=new z(1,1);this.center=new z(0,0);this.rotation=0;this.matrixAutoUpdate=!0;this.matrix=new ra;this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==m?m:3E3;this.version=0;this.onUpdate=null}function V(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function fb(a,
15609 b,c){this.width=a;this.height=b;this.scissor=new V(0,0,a,b);this.scissorTest=!1;this.viewport=new V(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=1006);this.texture=new T(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.texture.generateMipmaps=void 0!==c.generateMipmaps?c.generateMipmaps:!0;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?
15610 c.depthTexture:null}function Gb(a,b,c){fb.call(this,a,b,c);this.activeMipMapLevel=this.activeCubeFace=0}function gb(a,b,c,d,e,f,g,h,k,m,q,n){T.call(this,null,f,g,h,k,m,d,e,q,n);this.image={data:a,width:b,height:c};this.magFilter=void 0!==k?k:1003;this.minFilter=void 0!==m?m:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment=1}function Sa(a,b){this.min=void 0!==a?a:new p(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new p(-Infinity,-Infinity,-Infinity)}function Da(a,b){this.center=void 0!==
15611 a?a:new p;this.radius=void 0!==b?b:0}function Ma(a,b){this.normal=void 0!==a?a:new p(1,0,0);this.constant=void 0!==b?b:0}function md(a,b,c,d,e,f){this.planes=[void 0!==a?a:new Ma,void 0!==b?b:new Ma,void 0!==c?c:new Ma,void 0!==d?d:new Ma,void 0!==e?e:new Ma,void 0!==f?f:new Ma]}function G(a,b,c){return void 0===b&&void 0===c?this.set(a):this.setRGB(a,b,c)}function Qd(){function a(e,f){!1!==c&&(d(e,f),b.requestAnimationFrame(a))}var b=null,c=!1,d=null;return{start:function(){!0!==c&&null!==d&&(b.requestAnimationFrame(a),
15612 c=!0)},stop:function(){c=!1},setAnimationLoop:function(a){d=a},setContext:function(a){b=a}}}function Ff(a){function b(b,c){var d=b.array,e=b.dynamic?a.DYNAMIC_DRAW:a.STATIC_DRAW,h=a.createBuffer();a.bindBuffer(c,h);a.bufferData(c,d,e);b.onUploadCallback();c=a.FLOAT;d instanceof Float32Array?c=a.FLOAT:d instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):d instanceof Uint16Array?c=a.UNSIGNED_SHORT:d instanceof Int16Array?c=a.SHORT:d instanceof
15613 Uint32Array?c=a.UNSIGNED_INT:d instanceof Int32Array?c=a.INT:d instanceof Int8Array?c=a.BYTE:d instanceof Uint8Array&&(c=a.UNSIGNED_BYTE);return{buffer:h,type:c,bytesPerElement:d.BYTES_PER_ELEMENT,version:b.version}}var c=new WeakMap;return{get:function(a){a.isInterleavedBufferAttribute&&(a=a.data);return c.get(a)},remove:function(b){b.isInterleavedBufferAttribute&&(b=b.data);var d=c.get(b);d&&(a.deleteBuffer(d.buffer),c.delete(b))},update:function(d,e){d.isInterleavedBufferAttribute&&(d=d.data);
15614 var f=c.get(d);if(void 0===f)c.set(d,b(d,e));else if(f.version<d.version){var g=d,h=g.array,k=g.updateRange;a.bindBuffer(e,f.buffer);!1===g.dynamic?a.bufferData(e,h,a.STATIC_DRAW):-1===k.count?a.bufferSubData(e,0,h):0===k.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(a.bufferSubData(e,k.offset*h.BYTES_PER_ELEMENT,h.subarray(k.offset,k.offset+k.count)),k.count=
15615 -1);f.version=d.version}}}}function hb(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||hb.DefaultOrder}function Rd(){this.mask=1}function D(){Object.defineProperty(this,"id",{value:Gf++});this.uuid=H.generateUUID();this.name="";this.type="Object3D";this.parent=null;this.children=[];this.up=D.DefaultUp.clone();var a=new p,b=new hb,c=new fa,d=new p(1,1,1);b.onChange(function(){c.setFromEuler(b,!1)});c.onChange(function(){b.setFromQuaternion(c,void 0,!1)});Object.defineProperties(this,
15616 {position:{enumerable:!0,value:a},rotation:{enumerable:!0,value:b},quaternion:{enumerable:!0,value:c},scale:{enumerable:!0,value:d},modelViewMatrix:{value:new I},normalMatrix:{value:new ra}});this.matrix=new I;this.matrixWorld=new I;this.matrixAutoUpdate=D.DefaultMatrixAutoUpdate;this.matrixWorldNeedsUpdate=!1;this.layers=new Rd;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=0;this.userData={}}function Na(){D.call(this);this.type="Camera";this.matrixWorldInverse=
15617 new I;this.projectionMatrix=new I}function Hb(a,b,c,d,e,f){Na.call(this);this.type="OrthographicCamera";this.zoom=1;this.view=null;this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==e?e:.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()}function Ta(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d&&d.isVector3?d:new p;this.vertexNormals=Array.isArray(d)?d:[];this.color=e&&e.isColor?e:new G;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=void 0!==f?f:0}function R(){Object.defineProperty(this,
15618 "id",{value:Hf+=2});this.uuid=H.generateUUID();this.name="";this.type="Geometry";this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.verticesNeedUpdate=this.elementsNeedUpdate=!1}function Q(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
15619 this.name="";this.array=a;this.itemSize=b;this.count=void 0!==a?a.length/b:0;this.normalized=!0===c;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function oc(a,b,c){Q.call(this,new Int8Array(a),b,c)}function pc(a,b,c){Q.call(this,new Uint8Array(a),b,c)}function qc(a,b,c){Q.call(this,new Uint8ClampedArray(a),b,c)}function rc(a,b,c){Q.call(this,new Int16Array(a),b,c)}function ib(a,b,c){Q.call(this,new Uint16Array(a),b,c)}function sc(a,b,c){Q.call(this,new Int32Array(a),b,c)}function jb(a,
15620 b,c){Q.call(this,new Uint32Array(a),b,c)}function A(a,b,c){Q.call(this,new Float32Array(a),b,c)}function tc(a,b,c){Q.call(this,new Float64Array(a),b,c)}function Ee(){this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function Fe(a){if(0===a.length)return-Infinity;
15621 for(var b=a[0],c=1,d=a.length;c<d;++c)a[c]>b&&(b=a[c]);return b}function C(){Object.defineProperty(this,"id",{value:If+=2});this.uuid=H.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity};this.userData={}}function Ib(a,b,c,d,e,f){R.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,
15622 depthSegments:f};this.fromBufferGeometry(new kb(a,b,c,d,e,f));this.mergeVertices()}function kb(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,l,N,O,Jf){var r=f/N,v=g/O,P=f/2,y=g/2,w=l/2;g=N+1;var E=O+1,x=f=0,B,z,A=new p;for(z=0;z<E;z++){var D=z*v-y;for(B=0;B<g;B++)A[a]=(B*r-P)*d,A[b]=D*e,A[c]=w,m.push(A.x,A.y,A.z),A[a]=0,A[b]=0,A[c]=0<l?1:-1,q.push(A.x,A.y,A.z),n.push(B/N),n.push(1-z/O),f+=1}for(z=0;z<O;z++)for(B=0;B<N;B++)a=t+B+g*(z+1),b=t+(B+1)+g*(z+1),c=t+(B+1)+g*z,k.push(t+B+g*z,a,c),k.push(a,b,c),x+=
15623 6;h.addGroup(u,x,Jf);u+=x;t+=f}C.call(this);this.type="BoxBufferGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};var h=this;a=a||1;b=b||1;c=c||1;d=Math.floor(d)||1;e=Math.floor(e)||1;f=Math.floor(f)||1;var k=[],m=[],q=[],n=[],t=0,u=0;g("z","y","x",-1,-1,c,b,a,f,e,0);g("z","y","x",1,-1,c,b,-a,f,e,1);g("x","z","y",1,1,a,c,b,d,f,2);g("x","z","y",1,-1,a,c,-b,d,f,3);g("x","y","z",1,-1,a,b,c,d,e,4);g("x","y","z",-1,-1,a,b,-c,d,e,5);this.setIndex(k);this.addAttribute("position",
15624 new A(m,3));this.addAttribute("normal",new A(q,3));this.addAttribute("uv",new A(n,2))}function uc(a,b,c,d){R.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new lb(a,b,c,d));this.mergeVertices()}function lb(a,b,c,d){C.call(this);this.type="PlaneBufferGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};a=a||1;b=b||1;var e=a/2,f=b/2;c=Math.floor(c)||1;d=Math.floor(d)||1;var g=c+1,h=d+1,k=a/c,m=
15625 b/d,q=[],n=[],t=[],u=[];for(a=0;a<h;a++){var r=a*m-f;for(b=0;b<g;b++)n.push(b*k-e,-r,0),t.push(0,0,1),u.push(b/c),u.push(1-a/d)}for(a=0;a<d;a++)for(b=0;b<c;b++)e=b+g*(a+1),f=b+1+g*(a+1),h=b+1+g*a,q.push(b+g*a,e,h),q.push(e,f,h);this.setIndex(q);this.addAttribute("position",new A(n,3));this.addAttribute("normal",new A(t,3));this.addAttribute("uv",new A(u,2))}function J(){Object.defineProperty(this,"id",{value:Kf++});this.uuid=H.generateUUID();this.name="";this.type="Material";this.lights=this.fog=
15626 !0;this.blending=1;this.side=0;this.flatShading=!1;this.vertexColors=0;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=3;this.depthWrite=this.depthTest=!0;this.clippingPlanes=null;this.clipShadows=this.clipIntersection=!1;this.shadowSide=null;this.colorWrite=!0;this.precision=null;this.polygonOffset=!1;this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.dithering=!1;
15627 this.alphaTest=0;this.premultipliedAlpha=!1;this.overdraw=0;this.visible=!0;this.userData={};this.needsUpdate=!0}function da(a){J.call(this);this.type="MeshBasicMaterial";this.color=new G(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.lights=
15628 this.morphTargets=this.skinning=!1;this.setValues(a)}function ta(a){J.call(this);this.type="ShaderMaterial";this.defines={};this.uniforms={};this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";this.linewidth=1;this.wireframe=!1;this.wireframeLinewidth=1;this.morphNormals=this.morphTargets=this.skinning=this.clipping=this.lights=this.fog=!1;this.extensions=
15629 {derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]};this.index0AttributeName=void 0;this.uniformsNeedUpdate=!1;void 0!==a&&(void 0!==a.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(a))}function mb(a,b){this.origin=void 0!==a?a:new p;this.direction=void 0!==b?b:new p}function ja(a,b,c){this.a=void 0!==a?a:new p;this.b=void 0!==b?b:new p;this.c=
15630 void 0!==c?c:new p}function la(a,b){D.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new C;this.material=void 0!==b?b:new da({color:16777215*Math.random()});this.drawMode=0;this.updateMorphTargets()}function Lf(a,b,c,d){function e(a,c){b.buffers.color.setClear(a.r,a.g,a.b,c,d)}var f=new G(0),g=0,h,k,m;return{getClearColor:function(){return f},setClearColor:function(a,b){f.set(a);g=void 0!==b?b:1;e(f,g)},getClearAlpha:function(){return g},setClearAlpha:function(a){g=a;e(f,g)},render:function(b,
15631 d,t,u){d=d.background;null===d?e(f,g):d&&d.isColor&&(e(d,1),u=!0);(a.autoClear||u)&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil);d&&d.isCubeTexture?(void 0===m&&(m=new la(new kb(1,1,1),new ta({uniforms:nb.cube.uniforms,vertexShader:nb.cube.vertexShader,fragmentShader:nb.cube.fragmentShader,side:1,depthTest:!0,depthWrite:!1,fog:!1})),m.geometry.removeAttribute("normal"),m.geometry.removeAttribute("uv"),m.onBeforeRender=function(a,b,c){this.matrixWorld.copyPosition(c.matrixWorld)},
15632 c.update(m)),m.material.uniforms.tCube.value=d,b.push(m,m.geometry,m.material,0,null)):d&&d.isTexture&&(void 0===h&&(h=new Hb(-1,1,1,-1,0,1),k=new la(new lb(2,2),new da({depthTest:!1,depthWrite:!1,fog:!1})),c.update(k)),k.material.map=d,a.renderBufferDirect(h,null,k.geometry,k.material,k,null))}}}function Mf(a,b,c,d){var e;this.setMode=function(a){e=a};this.render=function(b,d){a.drawArrays(e,b,d);c.update(d,e)};this.renderInstances=function(f,g,h){if(d.isWebGL2)var k=a;else if(k=b.get("ANGLE_instanced_arrays"),
15633 null===k){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}k[d.isWebGL2?"drawArraysInstanced":"drawArraysInstancedANGLE"](e,g,h,f.maxInstancedCount);c.update(h,e,f.maxInstancedCount)}}function Nf(a,b,c){function d(b){if("highp"===b){if(0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision&&0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision)return"highp";b="mediump"}return"mediump"===
15634 b&&0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision&&0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision?"mediump":"lowp"}var e,f="undefined"!==typeof WebGL2RenderingContext&&a instanceof WebGL2RenderingContext,g=void 0!==c.precision?c.precision:"highp",h=d(g);h!==g&&(console.warn("THREE.WebGLRenderer:",g,"not supported, using",h,"instead."),g=h);c=!0===c.logarithmicDepthBuffer;h=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS);var k=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
15635 m=a.getParameter(a.MAX_TEXTURE_SIZE),q=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE),n=a.getParameter(a.MAX_VERTEX_ATTRIBS),t=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS),u=a.getParameter(a.MAX_VARYING_VECTORS),r=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS),l=0<k,y=f||!!b.get("OES_texture_float");return{isWebGL2:f,getMaxAnisotropy:function(){if(void 0!==e)return e;var c=b.get("EXT_texture_filter_anisotropic");return e=null!==c?a.getParameter(c.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:d,
15636 precision:g,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:k,maxTextureSize:m,maxCubemapSize:q,maxAttributes:n,maxVertexUniforms:t,maxVaryings:u,maxFragmentUniforms:r,vertexTextures:l,floatFragmentTextures:y,floatVertexTextures:l&&y}}function Of(){function a(){m.value!==d&&(m.value=d,m.needsUpdate=0<e);c.numPlanes=e;c.numIntersection=0}function b(a,b,d,e){var f=null!==a?a.length:0,g=null;if(0!==f){g=m.value;if(!0!==e||null===g){e=d+4*f;b=b.matrixWorldInverse;k.getNormalMatrix(b);if(null===
15637 g||g.length<e)g=new Float32Array(e);for(e=0;e!==f;++e,d+=4)h.copy(a[e]).applyMatrix4(b,k),h.normal.toArray(g,d),g[d+3]=h.constant}m.value=g;m.needsUpdate=!0}c.numPlanes=f;return g}var c=this,d=null,e=0,f=!1,g=!1,h=new Ma,k=new ra,m={value:null,needsUpdate:!1};this.uniform=m;this.numIntersection=this.numPlanes=0;this.init=function(a,c,g){var h=0!==a.length||c||0!==e||f;f=c;d=b(a,g,0);e=a.length;return h};this.beginShadows=function(){g=!0;b(null)};this.endShadows=function(){g=!1;a()};this.setState=
15638 function(c,h,k,u,r,l){if(!f||null===c||0===c.length||g&&!k)g?b(null):a();else{k=g?0:e;var n=4*k,q=r.clippingState||null;m.value=q;q=b(c,u,n,l);for(c=0;c!==n;++c)q[c]=d[c];r.clippingState=q;this.numIntersection=h?this.numPlanes:0;this.numPlanes+=k}}}function Pf(a){var b={};return{get:function(c){if(void 0!==b[c])return b[c];switch(c){case "WEBGL_depth_texture":var d=a.getExtension("WEBGL_depth_texture")||a.getExtension("MOZ_WEBGL_depth_texture")||a.getExtension("WEBKIT_WEBGL_depth_texture");break;
15639 case "EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":d=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
15640 break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported.");return b[c]=d}}}function Qf(a,b,c){function d(a){var h=a.target;a=e[h.id];null!==a.index&&b.remove(a.index);for(var g in a.attributes)b.remove(a.attributes[g]);h.removeEventListener("dispose",d);delete e[h.id];if(g=f[a.id])b.remove(g),delete f[a.id];c.memory.geometries--}var e={},f={};return{get:function(a,b){var f=e[b.id];if(f)return f;b.addEventListener("dispose",d);b.isBufferGeometry?
15641 f=b:b.isGeometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=(new C).setFromObject(a)),f=b._bufferGeometry);e[b.id]=f;c.memory.geometries++;return f},update:function(c){var d=c.index,e=c.attributes;null!==d&&b.update(d,a.ELEMENT_ARRAY_BUFFER);for(var f in e)b.update(e[f],a.ARRAY_BUFFER);c=c.morphAttributes;for(f in c){d=c[f];e=0;for(var g=d.length;e<g;e++)b.update(d[e],a.ARRAY_BUFFER)}},getWireframeAttribute:function(c){var d=f[c.id];if(d)return d;d=[];var e=c.index,g=c.attributes;if(null!==
15642 e){e=e.array;g=0;for(var q=e.length;g<q;g+=3){var n=e[g+0],t=e[g+1],u=e[g+2];d.push(n,t,t,u,u,n)}}else for(e=g.position.array,g=0,q=e.length/3-1;g<q;g+=3)n=g+0,t=g+1,u=g+2,d.push(n,t,t,u,u,n);d=new (65535<Fe(d)?jb:ib)(d,1);b.update(d,a.ELEMENT_ARRAY_BUFFER);return f[c.id]=d}}}function Rf(a,b,c,d){var e,f,g;this.setMode=function(a){e=a};this.setIndex=function(a){f=a.type;g=a.bytesPerElement};this.render=function(b,d){a.drawElements(e,d,f,b*g);c.update(d,e)};this.renderInstances=function(h,k,m){if(d.isWebGL2)var q=
15643 a;else if(q=b.get("ANGLE_instanced_arrays"),null===q){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}q[d.isWebGL2?"drawElementsInstanced":"drawElementsInstancedANGLE"](e,m,f,k*g,h.maxInstancedCount);c.update(m,e,h.maxInstancedCount)}}function Sf(a){var b={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:b,programs:null,autoReset:!0,reset:function(){b.frame++;
15644 b.calls=0;b.triangles=0;b.points=0;b.lines=0},update:function(c,d,e){e=e||1;b.calls++;switch(d){case a.TRIANGLES:b.triangles+=c/3*e;break;case a.TRIANGLE_STRIP:case a.TRIANGLE_FAN:b.triangles+=e*(c-2);break;case a.LINES:b.lines+=c/2*e;break;case a.LINE_STRIP:b.lines+=e*(c-1);break;case a.LINE_LOOP:b.lines+=e*c;break;case a.POINTS:b.points+=e*c;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",d)}}}}function Tf(a,b){return Math.abs(b[1])-Math.abs(a[1])}function Uf(a){var b={},c=new Float32Array(8);
15645 return{update:function(d,e,f,g){var h=d.morphTargetInfluences,k=h.length;d=b[e.id];if(void 0===d){d=[];for(var m=0;m<k;m++)d[m]=[m,0];b[e.id]=d}var q=f.morphTargets&&e.morphAttributes.position;f=f.morphNormals&&e.morphAttributes.normal;for(m=0;m<k;m++){var n=d[m];0!==n[1]&&(q&&e.removeAttribute("morphTarget"+m),f&&e.removeAttribute("morphNormal"+m))}for(m=0;m<k;m++)n=d[m],n[0]=m,n[1]=h[m];d.sort(Tf);for(m=0;8>m;m++){if(n=d[m])if(h=n[0],k=n[1]){q&&e.addAttribute("morphTarget"+m,q[h]);f&&e.addAttribute("morphNormal"+
15646 m,f[h]);c[m]=k;continue}c[m]=0}g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function Vf(a,b){var c={};return{update:function(d){var e=b.render.frame,f=d.geometry,g=a.get(d,f);c[g.id]!==e&&(f.isGeometry&&g.updateFromObject(d),a.update(g),c[g.id]=e);return g},dispose:function(){c={}}}}function Ua(a,b,c,d,e,f,g,h,k,m){a=void 0!==a?a:[];T.call(this,a,void 0!==b?b:301,c,d,e,f,g,h,k,m);this.flipY=!1}function Jb(a,b,c){var d=a[0];if(0>=d||0<d)return a;var e=b*c,f=Ge[e];void 0===f&&(f=new Float32Array(e),
15647 Ge[e]=f);if(0!==b)for(d.toArray(f,0),d=1,e=0;d!==b;++d)e+=c,a[d].toArray(f,e);return f}function ea(a,b){if(a.length!==b.length)return!1;for(var c=0,d=a.length;c<d;c++)if(a[c]!==b[c])return!1;return!0}function qa(a,b){for(var c=0,d=b.length;c<d;c++)a[c]=b[c]}function He(a,b){var c=Ie[b];void 0===c&&(c=new Int32Array(b),Ie[b]=c);for(var d=0;d!==b;++d)c[d]=a.allocTextureUnit();return c}function Wf(a,b){var c=this.cache;c[0]!==b&&(a.uniform1f(this.addr,b),c[0]=b)}function Xf(a,b){var c=this.cache;c[0]!==
15648 b&&(a.uniform1i(this.addr,b),c[0]=b)}function Yf(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y)a.uniform2f(this.addr,b.x,b.y),c[0]=b.x,c[1]=b.y}else ea(c,b)||(a.uniform2fv(this.addr,b),qa(c,b))}function Zf(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z)a.uniform3f(this.addr,b.x,b.y,b.z),c[0]=b.x,c[1]=b.y,c[2]=b.z}else if(void 0!==b.r){if(c[0]!==b.r||c[1]!==b.g||c[2]!==b.b)a.uniform3f(this.addr,b.r,b.g,b.b),c[0]=b.r,c[1]=b.g,c[2]=b.b}else ea(c,b)||(a.uniform3fv(this.addr,
15649 b),qa(c,b))}function $f(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z||c[3]!==b.w)a.uniform4f(this.addr,b.x,b.y,b.z,b.w),c[0]=b.x,c[1]=b.y,c[2]=b.z,c[3]=b.w}else ea(c,b)||(a.uniform4fv(this.addr,b),qa(c,b))}function ag(a,b){var c=this.cache,d=b.elements;void 0===d?ea(c,b)||(a.uniformMatrix2fv(this.addr,!1,b),qa(c,b)):ea(c,d)||(Je.set(d),a.uniformMatrix2fv(this.addr,!1,Je),qa(c,d))}function bg(a,b){var c=this.cache,d=b.elements;void 0===d?ea(c,b)||(a.uniformMatrix3fv(this.addr,
15650 !1,b),qa(c,b)):ea(c,d)||(Ke.set(d),a.uniformMatrix3fv(this.addr,!1,Ke),qa(c,d))}function cg(a,b){var c=this.cache,d=b.elements;void 0===d?ea(c,b)||(a.uniformMatrix4fv(this.addr,!1,b),qa(c,b)):ea(c,d)||(Le.set(d),a.uniformMatrix4fv(this.addr,!1,Le),qa(c,d))}function dg(a,b,c){var d=this.cache,e=c.allocTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture2D(b||Me,e)}function eg(a,b,c){var d=this.cache,e=c.allocTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTextureCube(b||
15651 Ne,e)}function Oe(a,b){var c=this.cache;ea(c,b)||(a.uniform2iv(this.addr,b),qa(c,b))}function Pe(a,b){var c=this.cache;ea(c,b)||(a.uniform3iv(this.addr,b),qa(c,b))}function Qe(a,b){var c=this.cache;ea(c,b)||(a.uniform4iv(this.addr,b),qa(c,b))}function fg(a){switch(a){case 5126:return Wf;case 35664:return Yf;case 35665:return Zf;case 35666:return $f;case 35674:return ag;case 35675:return bg;case 35676:return cg;case 35678:case 36198:return dg;case 35680:return eg;case 5124:case 35670:return Xf;case 35667:case 35671:return Oe;
15652 case 35668:case 35672:return Pe;case 35669:case 35673:return Qe}}function gg(a,b){var c=this.cache;ea(c,b)||(a.uniform1fv(this.addr,b),qa(c,b))}function hg(a,b){var c=this.cache;ea(c,b)||(a.uniform1iv(this.addr,b),qa(c,b))}function ig(a,b){var c=this.cache;b=Jb(b,this.size,2);ea(c,b)||(a.uniform2fv(this.addr,b),this.updateCache(b))}function jg(a,b){var c=this.cache;b=Jb(b,this.size,3);ea(c,b)||(a.uniform3fv(this.addr,b),this.updateCache(b))}function kg(a,b){var c=this.cache;b=Jb(b,this.size,4);ea(c,
15653 b)||(a.uniform4fv(this.addr,b),this.updateCache(b))}function lg(a,b){var c=this.cache;b=Jb(b,this.size,4);ea(c,b)||(a.uniformMatrix2fv(this.addr,!1,b),this.updateCache(b))}function mg(a,b){var c=this.cache;b=Jb(b,this.size,9);ea(c,b)||(a.uniformMatrix3fv(this.addr,!1,b),this.updateCache(b))}function ng(a,b){var c=this.cache;b=Jb(b,this.size,16);ea(c,b)||(a.uniformMatrix4fv(this.addr,!1,b),this.updateCache(b))}function og(a,b,c){var d=this.cache,e=b.length,f=He(c,e);!1===ea(d,f)&&(a.uniform1iv(this.addr,
15654 f),qa(d,f));for(a=0;a!==e;++a)c.setTexture2D(b[a]||Me,f[a])}function pg(a,b,c){var d=this.cache,e=b.length,f=He(c,e);!1===ea(d,f)&&(a.uniform1iv(this.addr,f),qa(d,f));for(a=0;a!==e;++a)c.setTextureCube(b[a]||Ne,f[a])}function qg(a){switch(a){case 5126:return gg;case 35664:return ig;case 35665:return jg;case 35666:return kg;case 35674:return lg;case 35675:return mg;case 35676:return ng;case 35678:return og;case 35680:return pg;case 5124:case 35670:return hg;case 35667:case 35671:return Oe;case 35668:case 35672:return Pe;
15655 case 35669:case 35673:return Qe}}function rg(a,b,c){this.id=a;this.addr=c;this.cache=[];this.setValue=fg(b.type)}function Re(a,b,c){this.id=a;this.addr=c;this.cache=[];this.size=b.size;this.setValue=qg(b.type)}function Se(a){this.id=a;this.seq=[];this.map={}}function Za(a,b,c){this.seq=[];this.map={};this.renderer=c;c=a.getProgramParameter(b,a.ACTIVE_UNIFORMS);for(var d=0;d<c;++d){var e=a.getActiveUniform(b,d),f=a.getUniformLocation(b,e.name),g=this,h=e.name,k=h.length;for(Vd.lastIndex=0;;){var m=
15656 Vd.exec(h),q=Vd.lastIndex,n=m[1],t=m[3];"]"===m[2]&&(n|=0);if(void 0===t||"["===t&&q+2===k){h=g;e=void 0===t?new rg(n,e,f):new Re(n,e,f);h.seq.push(e);h.map[e.id]=e;break}else t=g.map[n],void 0===t&&(t=new Se(n),n=g,g=t,n.seq.push(g),n.map[g.id]=g),g=t}}}function sg(a){a=a.split("\n");for(var b=0;b<a.length;b++)a[b]=b+1+": "+a[b];return a.join("\n")}function Te(a,b,c){var d=a.createShader(b);a.shaderSource(d,c);a.compileShader(d);!1===a.getShaderParameter(d,a.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile.");
15657 ""!==a.getShaderInfoLog(d)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",b===a.VERTEX_SHADER?"vertex":"fragment",a.getShaderInfoLog(d),sg(c));return d}function Ue(a){switch(a){case 3E3:return["Linear","( value )"];case 3001:return["sRGB","( value )"];case 3002:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw Error("unsupported encoding: "+
15658 a);}}function Wd(a,b){b=Ue(b);return"vec4 "+a+"( vec4 value ) { return "+b[0]+"ToLinear"+b[1]+"; }"}function tg(a,b){b=Ue(b);return"vec4 "+a+"( vec4 value ) { return LinearTo"+b[0]+b[1]+"; }"}function ug(a,b){switch(b){case 1:b="Linear";break;case 2:b="Reinhard";break;case 3:b="Uncharted2";break;case 4:b="OptimizedCineon";break;default:throw Error("unsupported toneMapping: "+b);}return"vec3 "+a+"( vec3 color ) { return "+b+"ToneMapping( color ); }"}function vg(a,b,c){a=a||{};return[a.derivatives||
15659 b.envMapCubeUV||b.bumpMap||b.normalMap&&!b.objectSpaceNormalMap||b.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(a.fragDepth||b.logarithmicDepthBuffer)&&c.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",a.drawBuffers&&c.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(a.shaderTextureLOD||b.envMap)&&c.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(vc).join("\n")}function wg(a){var b=[],c;for(c in a){var d=
15660 a[c];!1!==d&&b.push("#define "+c+" "+d)}return b.join("\n")}function vc(a){return""!==a}function Ve(a,b){return a.replace(/NUM_DIR_LIGHTS/g,b.numDirLights).replace(/NUM_SPOT_LIGHTS/g,b.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,b.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,b.numPointLights).replace(/NUM_HEMI_LIGHTS/g,b.numHemiLights)}function We(a,b){return a.replace(/NUM_CLIPPING_PLANES/g,b.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,b.numClippingPlanes-b.numClipIntersection)}function Xd(a){return a.replace(/^[ \t]*#include +<([\w\d./]+)>/gm,
15661 function(a,c){a=S[c];if(void 0===a)throw Error("Can not resolve #include <"+c+">");return Xd(a)})}function Xe(a){return a.replace(/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,c,d,e){a="";for(c=parseInt(c);c<parseInt(d);c++)a+=e.replace(/\[ i \]/g,"[ "+c+" ]");return a})}function xg(a,b,c,d,e,f,g){var h=a.context,k=d.defines,m=e.vertexShader,q=e.fragmentShader,n="SHADOWMAP_TYPE_BASIC";1===f.shadowMapType?n="SHADOWMAP_TYPE_PCF":2===f.shadowMapType&&
15662 (n="SHADOWMAP_TYPE_PCF_SOFT");var t="ENVMAP_TYPE_CUBE",u="ENVMAP_MODE_REFLECTION",r="ENVMAP_BLENDING_MULTIPLY";if(f.envMap){switch(d.envMap.mapping){case 301:case 302:t="ENVMAP_TYPE_CUBE";break;case 306:case 307:t="ENVMAP_TYPE_CUBE_UV";break;case 303:case 304:t="ENVMAP_TYPE_EQUIREC";break;case 305:t="ENVMAP_TYPE_SPHERE"}switch(d.envMap.mapping){case 302:case 304:u="ENVMAP_MODE_REFRACTION"}switch(d.combine){case 0:r="ENVMAP_BLENDING_MULTIPLY";break;case 1:r="ENVMAP_BLENDING_MIX";break;case 2:r="ENVMAP_BLENDING_ADD"}}var l=
15663 0<a.gammaFactor?a.gammaFactor:1,y=g.isWebGL2?"":vg(d.extensions,f,b),p=wg(k),w=h.createProgram();d.isRawShaderMaterial?(k=[p].filter(vc).join("\n"),0<k.length&&(k+="\n"),b=[y,p].filter(vc).join("\n"),0<b.length&&(b+="\n")):(k=["precision "+f.precision+" float;","precision "+f.precision+" int;","#define SHADER_NAME "+e.name,p,f.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+l,"#define MAX_BONES "+f.maxBones,f.useFog&&f.fog?"#define USE_FOG":"",f.useFog&&f.fogExp?"#define FOG_EXP2":
15664 "",f.map?"#define USE_MAP":"",f.envMap?"#define USE_ENVMAP":"",f.envMap?"#define "+u:"",f.lightMap?"#define USE_LIGHTMAP":"",f.aoMap?"#define USE_AOMAP":"",f.emissiveMap?"#define USE_EMISSIVEMAP":"",f.bumpMap?"#define USE_BUMPMAP":"",f.normalMap?"#define USE_NORMALMAP":"",f.normalMap&&f.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",f.displacementMap&&f.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",f.specularMap?"#define USE_SPECULARMAP":"",f.roughnessMap?"#define USE_ROUGHNESSMAP":
15665 "",f.metalnessMap?"#define USE_METALNESSMAP":"",f.alphaMap?"#define USE_ALPHAMAP":"",f.vertexColors?"#define USE_COLOR":"",f.flatShading?"#define FLAT_SHADED":"",f.skinning?"#define USE_SKINNING":"",f.useVertexTexture?"#define BONE_TEXTURE":"",f.morphTargets?"#define USE_MORPHTARGETS":"",f.morphNormals&&!1===f.flatShading?"#define USE_MORPHNORMALS":"",f.doubleSided?"#define DOUBLE_SIDED":"",f.flipSided?"#define FLIP_SIDED":"",f.shadowMapEnabled?"#define USE_SHADOWMAP":"",f.shadowMapEnabled?"#define "+
15666 n:"",f.sizeAttenuation?"#define USE_SIZEATTENUATION":"",f.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",f.logarithmicDepthBuffer&&(g.isWebGL2||b.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;",
15667 "#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif",
15668 "#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(vc).join("\n"),b=[y,"precision "+f.precision+" float;","precision "+f.precision+" int;","#define SHADER_NAME "+e.name,p,f.alphaTest?"#define ALPHATEST "+f.alphaTest+(f.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+l,f.useFog&&f.fog?"#define USE_FOG":"",f.useFog&&f.fogExp?"#define FOG_EXP2":"",f.map?"#define USE_MAP":"",f.envMap?"#define USE_ENVMAP":"",f.envMap?"#define "+t:"",f.envMap?"#define "+
15669 u:"",f.envMap?"#define "+r:"",f.lightMap?"#define USE_LIGHTMAP":"",f.aoMap?"#define USE_AOMAP":"",f.emissiveMap?"#define USE_EMISSIVEMAP":"",f.bumpMap?"#define USE_BUMPMAP":"",f.normalMap?"#define USE_NORMALMAP":"",f.normalMap&&f.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",f.specularMap?"#define USE_SPECULARMAP":"",f.roughnessMap?"#define USE_ROUGHNESSMAP":"",f.metalnessMap?"#define USE_METALNESSMAP":"",f.alphaMap?"#define USE_ALPHAMAP":"",f.vertexColors?"#define USE_COLOR":"",f.gradientMap?
15670 "#define USE_GRADIENTMAP":"",f.flatShading?"#define FLAT_SHADED":"",f.doubleSided?"#define DOUBLE_SIDED":"",f.flipSided?"#define FLIP_SIDED":"",f.shadowMapEnabled?"#define USE_SHADOWMAP":"",f.shadowMapEnabled?"#define "+n:"",f.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",f.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",f.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",f.logarithmicDepthBuffer&&(g.isWebGL2||b.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",f.envMap&&
15671 (g.isWebGL2||b.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",0!==f.toneMapping?"#define TONE_MAPPING":"",0!==f.toneMapping?S.tonemapping_pars_fragment:"",0!==f.toneMapping?ug("toneMapping",f.toneMapping):"",f.dithering?"#define DITHERING":"",f.outputEncoding||f.mapEncoding||f.envMapEncoding||f.emissiveMapEncoding?S.encodings_pars_fragment:"",f.mapEncoding?Wd("mapTexelToLinear",f.mapEncoding):"",f.envMapEncoding?Wd("envMapTexelToLinear",
15672 f.envMapEncoding):"",f.emissiveMapEncoding?Wd("emissiveMapTexelToLinear",f.emissiveMapEncoding):"",f.outputEncoding?tg("linearToOutputTexel",f.outputEncoding):"",f.depthPacking?"#define DEPTH_PACKING "+d.depthPacking:"","\n"].filter(vc).join("\n"));m=Xd(m);m=Ve(m,f);m=We(m,f);q=Xd(q);q=Ve(q,f);q=We(q,f);m=Xe(m);q=Xe(q);g.isWebGL2&&!d.isRawShaderMaterial&&(g=!1,n=/^\s*#version\s+300\s+es\s*\n/,d.isShaderMaterial&&null!==m.match(n)&&null!==q.match(n)&&(g=!0,m=m.replace(n,""),q=q.replace(n,"")),k="#version 300 es\n\n#define attribute in\n#define varying out\n#define texture2D texture\n"+
15673 k,b=["#version 300 es\n\n#define varying in",g?"":"out highp vec4 pc_fragColor;",g?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad"].join("\n")+
15674 "\n"+b);q=b+q;m=Te(h,h.VERTEX_SHADER,k+m);q=Te(h,h.FRAGMENT_SHADER,q);h.attachShader(w,m);h.attachShader(w,q);void 0!==d.index0AttributeName?h.bindAttribLocation(w,0,d.index0AttributeName):!0===f.morphTargets&&h.bindAttribLocation(w,0,"position");h.linkProgram(w);f=h.getProgramInfoLog(w).trim();g=h.getShaderInfoLog(m).trim();n=h.getShaderInfoLog(q).trim();u=t=!0;if(!1===h.getProgramParameter(w,h.LINK_STATUS))t=!1,console.error("THREE.WebGLProgram: shader error: ",h.getError(),"gl.VALIDATE_STATUS",
15675 h.getProgramParameter(w,h.VALIDATE_STATUS),"gl.getProgramInfoLog",f,g,n);else if(""!==f)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",f);else if(""===g||""===n)u=!1;u&&(this.diagnostics={runnable:t,material:d,programLog:f,vertexShader:{log:g,prefix:k},fragmentShader:{log:n,prefix:b}});h.deleteShader(m);h.deleteShader(q);var B;this.getUniforms=function(){void 0===B&&(B=new Za(h,w,a));return B};var E;this.getAttributes=function(){if(void 0===E){for(var a={},b=h.getProgramParameter(w,h.ACTIVE_ATTRIBUTES),
15676 c=0;c<b;c++){var d=h.getActiveAttrib(w,c).name;a[d]=h.getAttribLocation(w,d)}E=a}return E};this.destroy=function(){h.deleteProgram(w);this.program=void 0};Object.defineProperties(this,{uniforms:{get:function(){console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms().");return this.getUniforms()}},attributes:{get:function(){console.warn("THREE.WebGLProgram: .attributes is now .getAttributes().");return this.getAttributes()}}});this.name=e.name;this.id=yg++;this.code=c;this.usedTimes=1;this.program=
15677 w;this.vertexShader=m;this.fragmentShader=q;return this}function zg(a,b,c){function d(a,b){if(a)a.isTexture?c=a.encoding:a.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),c=a.texture.encoding);else var c=3E3;3E3===c&&b&&(c=3007);return c}var e=[],f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",
15678 MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},g="precision supportsVertexTextures map mapEncoding envMap envMapMode envMapEncoding lightMap aoMap emissiveMap emissiveMapEncoding bumpMap normalMap objectSpaceNormalMap displacementMap specularMap roughnessMap metalnessMap gradientMap alphaMap combine vertexColors fog useFog fogExp flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTargets maxMorphNormals premultipliedAlpha numDirLights numPointLights numSpotLights numHemiLights numRectAreaLights shadowMapEnabled shadowMapType toneMapping physicallyCorrectLights alphaTest doubleSided flipSided numClippingPlanes numClipIntersection depthPacking dithering".split(" ");
15679 this.getParameters=function(b,e,g,q,n,t,u){var h=f[b.type];if(u.isSkinnedMesh){var k=u.skeleton.bones;if(c.floatVertexTextures)k=1024;else{var m=Math.min(Math.floor((c.maxVertexUniforms-20)/4),k.length);m<k.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+k.length+" bones. This GPU supports "+m+"."),k=0):k=m}}else k=0;m=c.precision;null!==b.precision&&(m=c.getMaxPrecision(b.precision),m!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",m,"instead."));
15680 var l=a.getRenderTarget();return{shaderID:h,precision:m,supportsVertexTextures:c.vertexTextures,outputEncoding:d(l?l.texture:null,a.gammaOutput),map:!!b.map,mapEncoding:d(b.map,a.gammaInput),envMap:!!b.envMap,envMapMode:b.envMap&&b.envMap.mapping,envMapEncoding:d(b.envMap,a.gammaInput),envMapCubeUV:!!b.envMap&&(306===b.envMap.mapping||307===b.envMap.mapping),lightMap:!!b.lightMap,aoMap:!!b.aoMap,emissiveMap:!!b.emissiveMap,emissiveMapEncoding:d(b.emissiveMap,a.gammaInput),bumpMap:!!b.bumpMap,normalMap:!!b.normalMap,
15681 objectSpaceNormalMap:1===b.normalMapType,displacementMap:!!b.displacementMap,roughnessMap:!!b.roughnessMap,metalnessMap:!!b.metalnessMap,specularMap:!!b.specularMap,alphaMap:!!b.alphaMap,gradientMap:!!b.gradientMap,combine:b.combine,vertexColors:b.vertexColors,fog:!!q,useFog:b.fog,fogExp:q&&q.isFogExp2,flatShading:b.flatShading,sizeAttenuation:b.sizeAttenuation,logarithmicDepthBuffer:c.logarithmicDepthBuffer,skinning:b.skinning&&0<k,maxBones:k,useVertexTexture:c.floatVertexTextures,morphTargets:b.morphTargets,
15682 morphNormals:b.morphNormals,maxMorphTargets:a.maxMorphTargets,maxMorphNormals:a.maxMorphNormals,numDirLights:e.directional.length,numPointLights:e.point.length,numSpotLights:e.spot.length,numRectAreaLights:e.rectArea.length,numHemiLights:e.hemi.length,numClippingPlanes:n,numClipIntersection:t,dithering:b.dithering,shadowMapEnabled:a.shadowMap.enabled&&u.receiveShadow&&0<g.length,shadowMapType:a.shadowMap.type,toneMapping:a.toneMapping,physicallyCorrectLights:a.physicallyCorrectLights,premultipliedAlpha:b.premultipliedAlpha,
15683 alphaTest:b.alphaTest,doubleSided:2===b.side,flipSided:1===b.side,depthPacking:void 0!==b.depthPacking?b.depthPacking:!1}};this.getProgramCode=function(b,c){var d=[];c.shaderID?d.push(c.shaderID):(d.push(b.fragmentShader),d.push(b.vertexShader));if(void 0!==b.defines)for(var e in b.defines)d.push(e),d.push(b.defines[e]);for(e=0;e<g.length;e++)d.push(c[g[e]]);d.push(b.onBeforeCompile.toString());d.push(a.gammaOutput);return d.join()};this.acquireProgram=function(d,f,g,q){for(var h,k=0,m=e.length;k<
15684 m;k++){var r=e[k];if(r.code===q){h=r;++h.usedTimes;break}}void 0===h&&(h=new xg(a,b,q,d,f,g,c),e.push(h));return h};this.releaseProgram=function(a){if(0===--a.usedTimes){var b=e.indexOf(a);e[b]=e[e.length-1];e.pop();a.destroy()}};this.programs=e}function Ag(){var a=new WeakMap;return{get:function(b){var c=a.get(b);void 0===c&&(c={},a.set(b,c));return c},remove:function(b){a.delete(b)},update:function(b,c,d){a.get(b)[c]=d},dispose:function(){a=new WeakMap}}}function Bg(a,b){return a.renderOrder!==
15685 b.renderOrder?a.renderOrder-b.renderOrder:a.program&&b.program&&a.program!==b.program?a.program.id-b.program.id:a.material.id!==b.material.id?a.material.id-b.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function Cg(a,b){return a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function Dg(){var a=[],b=0,c=[],d=[];return{opaque:c,transparent:d,init:function(){b=0;c.length=0;d.length=0},push:function(e,f,g,h,k){var m=a[b];void 0===m?(m={id:e.id,object:e,geometry:f,material:g,
15686 program:g.program,renderOrder:e.renderOrder,z:h,group:k},a[b]=m):(m.id=e.id,m.object=e,m.geometry=f,m.material=g,m.program=g.program,m.renderOrder=e.renderOrder,m.z=h,m.group=k);(!0===g.transparent?d:c).push(m);b++},sort:function(){1<c.length&&c.sort(Bg);1<d.length&&d.sort(Cg)}}}function Eg(){var a={};return{get:function(b,c){b=b.id+","+c.id;c=a[b];void 0===c&&(c=new Dg,a[b]=c);return c},dispose:function(){a={}}}}function Fg(){var a={};return{get:function(b){if(void 0!==a[b.id])return a[b.id];switch(b.type){case "DirectionalLight":var c=
15687 {direction:new p,color:new G,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new z};break;case "SpotLight":c={position:new p,direction:new p,color:new G,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new z};break;case "PointLight":c={position:new p,color:new G,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new z,shadowCameraNear:1,shadowCameraFar:1E3};break;case "HemisphereLight":c={direction:new p,skyColor:new G,groundColor:new G};
15688 break;case "RectAreaLight":c={color:new G,position:new p,halfWidth:new p,halfHeight:new p}}return a[b.id]=c}}}function Gg(){var a=new Fg,b={id:Hg++,hash:{stateID:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,shadowsLength:-1},ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},c=new p,d=new I,e=new I;return{setup:function(f,
15689 g,h){var k=0,m=0,q=0,n=0,t=0,u=0,r=0,l=0;h=h.matrixWorldInverse;for(var y=0,p=f.length;y<p;y++){var w=f[y],B=w.color,E=w.intensity,P=w.distance,N=w.shadow&&w.shadow.map?w.shadow.map.texture:null;if(w.isAmbientLight)k+=B.r*E,m+=B.g*E,q+=B.b*E;else if(w.isDirectionalLight){var O=a.get(w);O.color.copy(w.color).multiplyScalar(w.intensity);O.direction.setFromMatrixPosition(w.matrixWorld);c.setFromMatrixPosition(w.target.matrixWorld);O.direction.sub(c);O.direction.transformDirection(h);if(O.shadow=w.castShadow)B=
15690 w.shadow,O.shadowBias=B.bias,O.shadowRadius=B.radius,O.shadowMapSize=B.mapSize;b.directionalShadowMap[n]=N;b.directionalShadowMatrix[n]=w.shadow.matrix;b.directional[n]=O;n++}else if(w.isSpotLight){O=a.get(w);O.position.setFromMatrixPosition(w.matrixWorld);O.position.applyMatrix4(h);O.color.copy(B).multiplyScalar(E);O.distance=P;O.direction.setFromMatrixPosition(w.matrixWorld);c.setFromMatrixPosition(w.target.matrixWorld);O.direction.sub(c);O.direction.transformDirection(h);O.coneCos=Math.cos(w.angle);
15691 O.penumbraCos=Math.cos(w.angle*(1-w.penumbra));O.decay=0===w.distance?0:w.decay;if(O.shadow=w.castShadow)B=w.shadow,O.shadowBias=B.bias,O.shadowRadius=B.radius,O.shadowMapSize=B.mapSize;b.spotShadowMap[u]=N;b.spotShadowMatrix[u]=w.shadow.matrix;b.spot[u]=O;u++}else if(w.isRectAreaLight)O=a.get(w),O.color.copy(B).multiplyScalar(E),O.position.setFromMatrixPosition(w.matrixWorld),O.position.applyMatrix4(h),e.identity(),d.copy(w.matrixWorld),d.premultiply(h),e.extractRotation(d),O.halfWidth.set(.5*w.width,
15692 0,0),O.halfHeight.set(0,.5*w.height,0),O.halfWidth.applyMatrix4(e),O.halfHeight.applyMatrix4(e),b.rectArea[r]=O,r++;else if(w.isPointLight){O=a.get(w);O.position.setFromMatrixPosition(w.matrixWorld);O.position.applyMatrix4(h);O.color.copy(w.color).multiplyScalar(w.intensity);O.distance=w.distance;O.decay=0===w.distance?0:w.decay;if(O.shadow=w.castShadow)B=w.shadow,O.shadowBias=B.bias,O.shadowRadius=B.radius,O.shadowMapSize=B.mapSize,O.shadowCameraNear=B.camera.near,O.shadowCameraFar=B.camera.far;
15693 b.pointShadowMap[t]=N;b.pointShadowMatrix[t]=w.shadow.matrix;b.point[t]=O;t++}else w.isHemisphereLight&&(O=a.get(w),O.direction.setFromMatrixPosition(w.matrixWorld),O.direction.transformDirection(h),O.direction.normalize(),O.skyColor.copy(w.color).multiplyScalar(E),O.groundColor.copy(w.groundColor).multiplyScalar(E),b.hemi[l]=O,l++)}b.ambient[0]=k;b.ambient[1]=m;b.ambient[2]=q;b.directional.length=n;b.spot.length=u;b.rectArea.length=r;b.point.length=t;b.hemi.length=l;b.hash.stateID=b.id;b.hash.directionalLength=
15694 n;b.hash.pointLength=t;b.hash.spotLength=u;b.hash.rectAreaLength=r;b.hash.hemiLength=l;b.hash.shadowsLength=g.length},state:b}}function Ye(){var a=new Gg,b=[],c=[];return{init:function(){b.length=0;c.length=0},state:{lightsArray:b,shadowsArray:c,lights:a},setupLights:function(d){a.setup(b,c,d)},pushLight:function(a){b.push(a)},pushShadow:function(a){c.push(a)}}}function Ig(){var a={};return{get:function(b,c){if(void 0===a[b.id]){var d=new Ye;a[b.id]={};a[b.id][c.id]=d}else void 0===a[b.id][c.id]?
15695 (d=new Ye,a[b.id][c.id]=d):d=a[b.id][c.id];return d},dispose:function(){a={}}}}function $a(a){J.call(this);this.type="MeshDepthMaterial";this.depthPacking=3200;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.lights=this.fog=!1;this.setValues(a)}function ab(a){J.call(this);this.type="MeshDistanceMaterial";this.referencePosition=new p;this.nearDistance=1;this.farDistance=
15696 1E3;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.lights=this.fog=!1;this.setValues(a)}function Ze(a,b,c){function d(b,c,d,e,f,g){var h=b.geometry;var k=n;var m=b.customDepthMaterial;d&&(k=t,m=b.customDistanceMaterial);m?k=m:(m=!1,c.morphTargets&&(h&&h.isBufferGeometry?m=h.morphAttributes&&h.morphAttributes.position&&0<h.morphAttributes.position.length:h&&h.isGeometry&&(m=h.morphTargets&&0<h.morphTargets.length)),
15697 b.isSkinnedMesh&&!1===c.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",b),b=b.isSkinnedMesh&&c.skinning,h=0,m&&(h|=1),b&&(h|=2),k=k[h]);a.localClippingEnabled&&!0===c.clipShadows&&0!==c.clippingPlanes.length&&(h=k.uuid,m=c.uuid,b=u[h],void 0===b&&(b={},u[h]=b),h=b[m],void 0===h&&(h=k.clone(),b[m]=h),k=h);k.visible=c.visible;k.wireframe=c.wireframe;k.side=null!=c.shadowSide?c.shadowSide:r[c.side];k.clipShadows=c.clipShadows;k.clippingPlanes=c.clippingPlanes;
15698 k.clipIntersection=c.clipIntersection;k.wireframeLinewidth=c.wireframeLinewidth;k.linewidth=c.linewidth;d&&k.isMeshDistanceMaterial&&(k.referencePosition.copy(e),k.nearDistance=f,k.farDistance=g);return k}function e(c,g,h,k){if(!1!==c.visible){if(c.layers.test(g.layers)&&(c.isMesh||c.isLine||c.isPoints)&&c.castShadow&&(!c.frustumCulled||f.intersectsObject(c))){c.modelViewMatrix.multiplyMatrices(h.matrixWorldInverse,c.matrixWorld);var m=b.update(c),n=c.material;if(Array.isArray(n))for(var t=m.groups,
15699 u=0,r=t.length;u<r;u++){var l=t[u],P=n[l.materialIndex];P&&P.visible&&(P=d(c,P,k,q,h.near,h.far),a.renderBufferDirect(h,null,m,P,c,l))}else n.visible&&(P=d(c,n,k,q,h.near,h.far),a.renderBufferDirect(h,null,m,P,c,null))}c=c.children;m=0;for(n=c.length;m<n;m++)e(c[m],g,h,k)}}var f=new md,g=new I,h=new z,k=new z(c,c),m=new p,q=new p,n=Array(4),t=Array(4),u={},r={0:1,1:0,2:2},l=[new p(1,0,0),new p(-1,0,0),new p(0,0,1),new p(0,0,-1),new p(0,1,0),new p(0,-1,0)],y=[new p(0,1,0),new p(0,1,0),new p(0,1,0),
15700 new p(0,1,0),new p(0,0,1),new p(0,0,-1)],x=[new V,new V,new V,new V,new V,new V];for(c=0;4!==c;++c){var w=0!==(c&1),B=0!==(c&2),E=new $a({depthPacking:3201,morphTargets:w,skinning:B});n[c]=E;w=new ab({morphTargets:w,skinning:B});t[c]=w}var P=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=1;this.render=function(b,c,d){if(!1!==P.enabled&&(!1!==P.autoUpdate||!1!==P.needsUpdate)&&0!==b.length){var n=a.state;n.disable(a.context.BLEND);n.buffers.color.setClear(1,1,1,1);n.buffers.depth.setTest(!0);
15701 n.setScissorTest(!1);for(var t,u=0,r=b.length;u<r;u++){var v=b[u];t=v.shadow;var p=v&&v.isPointLight;if(void 0===t)console.warn("THREE.WebGLShadowMap:",v,"has no shadow.");else{var w=t.camera;h.copy(t.mapSize);h.min(k);if(p){var N=h.x,E=h.y;x[0].set(2*N,E,N,E);x[1].set(0,E,N,E);x[2].set(3*N,E,N,E);x[3].set(N,E,N,E);x[4].set(3*N,0,N,E);x[5].set(N,0,N,E);h.x*=4;h.y*=2}null===t.map&&(t.map=new fb(h.x,h.y,{minFilter:1003,magFilter:1003,format:1023}),t.map.texture.name=v.name+".shadowMap",w.updateProjectionMatrix());
15702 t.isSpotLightShadow&&t.update(v);N=t.map;E=t.matrix;q.setFromMatrixPosition(v.matrixWorld);w.position.copy(q);p?(t=6,E.makeTranslation(-q.x,-q.y,-q.z)):(t=1,m.setFromMatrixPosition(v.target.matrixWorld),w.lookAt(m),w.updateMatrixWorld(),E.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),E.multiply(w.projectionMatrix),E.multiply(w.matrixWorldInverse));a.setRenderTarget(N);a.clear();for(v=0;v<t;v++)p&&(m.copy(w.position),m.add(l[v]),w.up.copy(y[v]),w.lookAt(m),w.updateMatrixWorld(),n.viewport(x[v])),g.multiplyMatrices(w.projectionMatrix,
15703 w.matrixWorldInverse),f.setFromMatrix(g),e(c,d,w,p)}}P.needsUpdate=!1}}}function Jg(a,b,c,d){function e(b,c,d){var e=new Uint8Array(4),f=a.createTexture();a.bindTexture(b,f);a.texParameteri(b,a.TEXTURE_MIN_FILTER,a.NEAREST);a.texParameteri(b,a.TEXTURE_MAG_FILTER,a.NEAREST);for(b=0;b<d;b++)a.texImage2D(c+b,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,e);return f}function f(c,e){x[c]=1;0===w[c]&&(a.enableVertexAttribArray(c),w[c]=1);B[c]!==e&&((d.isWebGL2?a:b.get("ANGLE_instanced_arrays"))[d.isWebGL2?"vertexAttribDivisor":
15704 "vertexAttribDivisorANGLE"](c,e),B[c]=e)}function g(b){!0!==E[b]&&(a.enable(b),E[b]=!0)}function h(b){!1!==E[b]&&(a.disable(b),E[b]=!1)}function k(b,d,e,f,k,m,n,q){0!==b?g(a.BLEND):h(a.BLEND);if(5!==b){if(b!==O||q!==C)switch(b){case 2:q?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ONE,a.ONE,a.ONE,a.ONE)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.SRC_ALPHA,a.ONE));break;case 3:q?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ZERO,a.ZERO,a.ONE_MINUS_SRC_COLOR,
15705 a.ONE_MINUS_SRC_ALPHA)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.ONE_MINUS_SRC_COLOR));break;case 4:q?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ZERO,a.SRC_COLOR,a.ZERO,a.SRC_ALPHA)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.SRC_COLOR));break;default:q?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA)):(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.SRC_ALPHA,
15706 a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA))}D=A=Ud=Td=Sd=z=null}else{k=k||d;m=m||e;n=n||f;if(d!==z||k!==Ud)a.blendEquationSeparate(c.convert(d),c.convert(k)),z=d,Ud=k;if(e!==Sd||f!==Td||m!==A||n!==D)a.blendFuncSeparate(c.convert(e),c.convert(f),c.convert(m),c.convert(n)),Sd=e,Td=f,A=m,D=n}O=b;C=q}function m(b){G!==b&&(b?a.frontFace(a.CW):a.frontFace(a.CCW),G=b)}function q(b){0!==b?(g(a.CULL_FACE),b!==K&&(1===b?a.cullFace(a.BACK):2===b?a.cullFace(a.FRONT):a.cullFace(a.FRONT_AND_BACK))):h(a.CULL_FACE);
15707 K=b}function n(b,c,d){if(b){if(g(a.POLYGON_OFFSET_FILL),R!==c||I!==d)a.polygonOffset(c,d),R=c,I=d}else h(a.POLYGON_OFFSET_FILL)}function t(b){void 0===b&&(b=a.TEXTURE0+J-1);Q!==b&&(a.activeTexture(b),Q=b)}var u=new function(){var b=!1,c=new V,d=null,e=new V(0,0,0,0);return{setMask:function(c){d===c||b||(a.colorMask(c,c,c,c),d=c)},setLocked:function(a){b=a},setClear:function(b,d,f,g,h){!0===h&&(b*=g,d*=g,f*=g);c.set(b,d,f,g);!1===e.equals(c)&&(a.clearColor(b,d,f,g),e.copy(c))},reset:function(){b=!1;
15708 d=null;e.set(-1,0,0,0)}}},r=new function(){var b=!1,c=null,d=null,e=null;return{setTest:function(b){b?g(a.DEPTH_TEST):h(a.DEPTH_TEST)},setMask:function(d){c===d||b||(a.depthMask(d),c=d)},setFunc:function(b){if(d!==b){if(b)switch(b){case 0:a.depthFunc(a.NEVER);break;case 1:a.depthFunc(a.ALWAYS);break;case 2:a.depthFunc(a.LESS);break;case 3:a.depthFunc(a.LEQUAL);break;case 4:a.depthFunc(a.EQUAL);break;case 5:a.depthFunc(a.GEQUAL);break;case 6:a.depthFunc(a.GREATER);break;case 7:a.depthFunc(a.NOTEQUAL);
15709 break;default:a.depthFunc(a.LEQUAL)}else a.depthFunc(a.LEQUAL);d=b}},setLocked:function(a){b=a},setClear:function(b){e!==b&&(a.clearDepth(b),e=b)},reset:function(){b=!1;e=d=c=null}}},l=new function(){var b=!1,c=null,d=null,e=null,f=null,k=null,m=null,n=null,q=null;return{setTest:function(b){b?g(a.STENCIL_TEST):h(a.STENCIL_TEST)},setMask:function(d){c===d||b||(a.stencilMask(d),c=d)},setFunc:function(b,c,g){if(d!==b||e!==c||f!==g)a.stencilFunc(b,c,g),d=b,e=c,f=g},setOp:function(b,c,d){if(k!==b||m!==
15710 c||n!==d)a.stencilOp(b,c,d),k=b,m=c,n=d},setLocked:function(a){b=a},setClear:function(b){q!==b&&(a.clearStencil(b),q=b)},reset:function(){b=!1;q=n=m=k=f=e=d=c=null}}},p=a.getParameter(a.MAX_VERTEX_ATTRIBS),x=new Uint8Array(p),w=new Uint8Array(p),B=new Uint8Array(p),E={},P=null,N=null,O=null,z=null,Sd=null,Td=null,Ud=null,A=null,D=null,C=!1,G=null,K=null,L=null,R=null,I=null,J=a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS),H=!1;p=0;p=a.getParameter(a.VERSION);-1!==p.indexOf("WebGL")?(p=parseFloat(/^WebGL ([0-9])/.exec(p)[1]),
15711 H=1<=p):-1!==p.indexOf("OpenGL ES")&&(p=parseFloat(/^OpenGL ES ([0-9])/.exec(p)[1]),H=2<=p);var Q=null,S={},Y=new V,W=new V,M={};M[a.TEXTURE_2D]=e(a.TEXTURE_2D,a.TEXTURE_2D,1);M[a.TEXTURE_CUBE_MAP]=e(a.TEXTURE_CUBE_MAP,a.TEXTURE_CUBE_MAP_POSITIVE_X,6);u.setClear(0,0,0,1);r.setClear(1);l.setClear(0);g(a.DEPTH_TEST);r.setFunc(3);m(!1);q(1);g(a.CULL_FACE);g(a.BLEND);k(1);return{buffers:{color:u,depth:r,stencil:l},initAttributes:function(){for(var a=0,b=x.length;a<b;a++)x[a]=0},enableAttribute:function(a){f(a,
15712 0)},enableAttributeAndDivisor:f,disableUnusedAttributes:function(){for(var b=0,c=w.length;b!==c;++b)w[b]!==x[b]&&(a.disableVertexAttribArray(b),w[b]=0)},enable:g,disable:h,getCompressedTextureFormats:function(){if(null===P&&(P=[],b.get("WEBGL_compressed_texture_pvrtc")||b.get("WEBGL_compressed_texture_s3tc")||b.get("WEBGL_compressed_texture_etc1")||b.get("WEBGL_compressed_texture_astc")))for(var c=a.getParameter(a.COMPRESSED_TEXTURE_FORMATS),d=0;d<c.length;d++)P.push(c[d]);return P},useProgram:function(b){return N!==
15713 b?(a.useProgram(b),N=b,!0):!1},setBlending:k,setMaterial:function(b,c){2===b.side?h(a.CULL_FACE):g(a.CULL_FACE);var d=1===b.side;c&&(d=!d);m(d);1===b.blending&&!1===b.transparent?k(0):k(b.blending,b.blendEquation,b.blendSrc,b.blendDst,b.blendEquationAlpha,b.blendSrcAlpha,b.blendDstAlpha,b.premultipliedAlpha);r.setFunc(b.depthFunc);r.setTest(b.depthTest);r.setMask(b.depthWrite);u.setMask(b.colorWrite);n(b.polygonOffset,b.polygonOffsetFactor,b.polygonOffsetUnits)},setFlipSided:m,setCullFace:q,setLineWidth:function(b){b!==
15714 L&&(H&&a.lineWidth(b),L=b)},setPolygonOffset:n,setScissorTest:function(b){b?g(a.SCISSOR_TEST):h(a.SCISSOR_TEST)},activeTexture:t,bindTexture:function(b,c){null===Q&&t();var d=S[Q];void 0===d&&(d={type:void 0,texture:void 0},S[Q]=d);if(d.type!==b||d.texture!==c)a.bindTexture(b,c||M[b]),d.type=b,d.texture=c},compressedTexImage2D:function(){try{a.compressedTexImage2D.apply(a,arguments)}catch(U){console.error("THREE.WebGLState:",U)}},texImage2D:function(){try{a.texImage2D.apply(a,arguments)}catch(U){console.error("THREE.WebGLState:",
15715 U)}},scissor:function(b){!1===Y.equals(b)&&(a.scissor(b.x,b.y,b.z,b.w),Y.copy(b))},viewport:function(b){!1===W.equals(b)&&(a.viewport(b.x,b.y,b.z,b.w),W.copy(b))},reset:function(){for(var b=0;b<w.length;b++)1===w[b]&&(a.disableVertexAttribArray(b),w[b]=0);E={};Q=P=null;S={};K=G=O=N=null;u.reset();r.reset();l.reset()}}}function Kg(a,b,c,d,e,f,g){function h(a,b){if(a.width>b||a.height>b){if("data"in a){console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+a.width+"x"+a.height+").");
15716 return}b/=Math.max(a.width,a.height);var c=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");c.width=Math.floor(a.width*b);c.height=Math.floor(a.height*b);c.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,c.width,c.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+c.width+"x"+c.height);return c}return a}function k(a){return H.isPowerOfTwo(a.width)&&H.isPowerOfTwo(a.height)}function m(a,b){return a.generateMipmaps&&b&&1003!==
15717 a.minFilter&&1006!==a.minFilter}function q(b,c,e,f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e,f))*Math.LOG2E}function n(b,c){if(!e.isWebGL2)return b;if(b===a.RGB){if(c===a.FLOAT)return a.RGB32F;if(c===a.HALF_FLOAT)return a.RGB16F;if(c===a.UNSIGNED_BYTE)return a.RGB8}if(b===a.RGBA){if(c===a.FLOAT)return a.RGBA32F;if(c===a.HALF_FLOAT)return a.RGBA16F;if(c===a.UNSIGNED_BYTE)return a.RGBA8}return b}function t(b){return 1003===b||1004===b||1005===b?a.NEAREST:a.LINEAR}function u(b){b=
15718 b.target;b.removeEventListener("dispose",u);a:{var c=d.get(b);if(b.image&&c.__image__webglTextureCube)a.deleteTexture(c.__image__webglTextureCube);else{if(void 0===c.__webglInit)break a;a.deleteTexture(c.__webglTexture)}d.remove(b)}b.isVideoTexture&&delete B[b.id];g.memory.textures--}function r(b){b=b.target;b.removeEventListener("dispose",r);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b.isWebGLRenderTargetCube)for(e=
15719 0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer);d.remove(b.texture);d.remove(b)}g.memory.textures--}function l(b,t){var r=d.get(b);if(b.isVideoTexture){var l=b.id,v=g.render.frame;B[l]!==v&&(B[l]=v,b.update())}if(0<b.version&&r.__version!==b.version)if(l=b.image,void 0===l)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");
15720 else if(!1===l.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{void 0===r.__webglInit&&(r.__webglInit=!0,b.addEventListener("dispose",u),r.__webglTexture=a.createTexture(),g.memory.textures++);c.activeTexture(a.TEXTURE0+t);c.bindTexture(a.TEXTURE_2D,r.__webglTexture);a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,b.flipY);a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha);a.pixelStorei(a.UNPACK_ALIGNMENT,b.unpackAlignment);t=h(b.image,e.maxTextureSize);
15721 (e.isWebGL2?0:1001!==b.wrapS||1001!==b.wrapT||1003!==b.minFilter&&1006!==b.minFilter)&&!1===k(t)&&(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageBitmap)&&(void 0===E&&(E=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),E.width=H.floorPowerOfTwo(t.width),E.height=H.floorPowerOfTwo(t.height),E.getContext("2d").drawImage(t,0,0,E.width,E.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+E.width+
15722 "x"+E.height),t=E);l=k(t);v=f.convert(b.format);var w=f.convert(b.type),y=n(v,w);p(a.TEXTURE_2D,b,l);var P=b.mipmaps;if(b.isDepthTexture){y=a.DEPTH_COMPONENT;if(1015===b.type){if(!e.isWebGL2)throw Error("Float Depth Texture only supported in WebGL2.0");y=a.DEPTH_COMPONENT32F}else e.isWebGL2&&(y=a.DEPTH_COMPONENT16);1026===b.format&&y===a.DEPTH_COMPONENT&&1012!==b.type&&1014!==b.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),b.type=
15723 1012,w=f.convert(b.type));1027===b.format&&(y=a.DEPTH_STENCIL,1020!==b.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),b.type=1020,w=f.convert(b.type)));c.texImage2D(a.TEXTURE_2D,0,y,t.width,t.height,0,v,w,null)}else if(b.isDataTexture)if(0<P.length&&l){for(var N=0,x=P.length;N<x;N++){var z=P[N];c.texImage2D(a.TEXTURE_2D,N,y,z.width,z.height,0,v,w,z.data)}b.generateMipmaps=!1;r.__maxMipLevel=P.length-1}else c.texImage2D(a.TEXTURE_2D,0,y,t.width,
15724 t.height,0,v,w,t.data),r.__maxMipLevel=0;else if(b.isCompressedTexture){N=0;for(x=P.length;N<x;N++)z=P[N],1023!==b.format&&1022!==b.format?-1<c.getCompressedTextureFormats().indexOf(v)?c.compressedTexImage2D(a.TEXTURE_2D,N,y,z.width,z.height,0,z.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):c.texImage2D(a.TEXTURE_2D,N,y,z.width,z.height,0,v,w,z.data);r.__maxMipLevel=P.length-1}else if(0<P.length&&l){N=0;for(x=P.length;N<x;N++)z=
15725 P[N],c.texImage2D(a.TEXTURE_2D,N,y,v,w,z);b.generateMipmaps=!1;r.__maxMipLevel=P.length-1}else c.texImage2D(a.TEXTURE_2D,0,y,v,w,t),r.__maxMipLevel=0;m(b,l)&&q(a.TEXTURE_2D,b,t.width,t.height);r.__version=b.version;if(b.onUpdate)b.onUpdate(b);return}c.activeTexture(a.TEXTURE0+t);c.bindTexture(a.TEXTURE_2D,r.__webglTexture)}function p(c,g,h){h?(a.texParameteri(c,a.TEXTURE_WRAP_S,f.convert(g.wrapS)),a.texParameteri(c,a.TEXTURE_WRAP_T,f.convert(g.wrapT)),a.texParameteri(c,a.TEXTURE_MAG_FILTER,f.convert(g.magFilter)),
15726 a.texParameteri(c,a.TEXTURE_MIN_FILTER,f.convert(g.minFilter))):(a.texParameteri(c,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(c,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),1001===g.wrapS&&1001===g.wrapT||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),a.texParameteri(c,a.TEXTURE_MAG_FILTER,t(g.magFilter)),a.texParameteri(c,a.TEXTURE_MIN_FILTER,t(g.minFilter)),1003!==g.minFilter&&1006!==g.minFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));
15727 !(h=b.get("EXT_texture_filter_anisotropic"))||1015===g.type&&null===b.get("OES_texture_float_linear")||1016===g.type&&null===(e.isWebGL2||b.get("OES_texture_half_float_linear"))||!(1<g.anisotropy||d.get(g).__currentAnisotropy)||(a.texParameterf(c,h.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,e.getMaxAnisotropy())),d.get(g).__currentAnisotropy=g.anisotropy)}function x(b,e,g,h){var k=f.convert(e.texture.format),m=f.convert(e.texture.type),q=n(k,m);c.texImage2D(h,0,q,e.width,e.height,0,k,m,null);
15728 a.bindFramebuffer(a.FRAMEBUFFER,b);a.framebufferTexture2D(a.FRAMEBUFFER,g,h,d.get(e.texture).__webglTexture,0);a.bindFramebuffer(a.FRAMEBUFFER,null)}function w(b,c){a.bindRenderbuffer(a.RENDERBUFFER,b);c.depthBuffer&&!c.stencilBuffer?(a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_COMPONENT16,c.width,c.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.RENDERBUFFER,b)):c.depthBuffer&&c.stencilBuffer?(a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_STENCIL,c.width,c.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,
15729 a.DEPTH_STENCIL_ATTACHMENT,a.RENDERBUFFER,b)):a.renderbufferStorage(a.RENDERBUFFER,a.RGBA4,c.width,c.height);a.bindRenderbuffer(a.RENDERBUFFER,null)}var B={},E;this.setTexture2D=l;this.setTextureCube=function(b,t){var r=d.get(b);if(6===b.image.length)if(0<b.version&&r.__version!==b.version){r.__image__webglTextureCube||(b.addEventListener("dispose",u),r.__image__webglTextureCube=a.createTexture(),g.memory.textures++);c.activeTexture(a.TEXTURE0+t);c.bindTexture(a.TEXTURE_CUBE_MAP,r.__image__webglTextureCube);
15730 a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,b.flipY);t=b&&b.isCompressedTexture;for(var l=b.image[0]&&b.image[0].isDataTexture,v=[],w=0;6>w;w++)v[w]=t||l?l?b.image[w].image:b.image[w]:h(b.image[w],e.maxCubemapSize);var y=v[0],E=k(y),P=f.convert(b.format),x=f.convert(b.type),N=n(P,x);p(a.TEXTURE_CUBE_MAP,b,E);for(w=0;6>w;w++)if(t)for(var B,z=v[w].mipmaps,A=0,D=z.length;A<D;A++)B=z[A],1023!==b.format&&1022!==b.format?-1<c.getCompressedTextureFormats().indexOf(P)?c.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+
15731 w,A,N,B.width,B.height,0,B.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):c.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+w,A,N,B.width,B.height,0,P,x,B.data);else l?c.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+w,0,N,v[w].width,v[w].height,0,P,x,v[w].data):c.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+w,0,N,P,x,v[w]);r.__maxMipLevel=t?z.length-1:0;m(b,E)&&q(a.TEXTURE_CUBE_MAP,b,y.width,y.height);r.__version=b.version;if(b.onUpdate)b.onUpdate(b)}else c.activeTexture(a.TEXTURE0+
15732 t),c.bindTexture(a.TEXTURE_CUBE_MAP,r.__image__webglTextureCube)};this.setTextureCubeDynamic=function(b,e){c.activeTexture(a.TEXTURE0+e);c.bindTexture(a.TEXTURE_CUBE_MAP,d.get(b).__webglTexture)};this.setupRenderTarget=function(b){var e=d.get(b),f=d.get(b.texture);b.addEventListener("dispose",r);f.__webglTexture=a.createTexture();g.memory.textures++;var h=!0===b.isWebGLRenderTargetCube,n=k(b);if(h){e.__webglFramebuffer=[];for(var t=0;6>t;t++)e.__webglFramebuffer[t]=a.createFramebuffer()}else e.__webglFramebuffer=
15733 a.createFramebuffer();if(h){c.bindTexture(a.TEXTURE_CUBE_MAP,f.__webglTexture);p(a.TEXTURE_CUBE_MAP,b.texture,n);for(t=0;6>t;t++)x(e.__webglFramebuffer[t],b,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+t);m(b.texture,n)&&q(a.TEXTURE_CUBE_MAP,b.texture,b.width,b.height);c.bindTexture(a.TEXTURE_CUBE_MAP,null)}else c.bindTexture(a.TEXTURE_2D,f.__webglTexture),p(a.TEXTURE_2D,b.texture,n),x(e.__webglFramebuffer,b,a.COLOR_ATTACHMENT0,a.TEXTURE_2D),m(b.texture,n)&&q(a.TEXTURE_2D,b.texture,b.width,b.height),
15734 c.bindTexture(a.TEXTURE_2D,null);if(b.depthBuffer){e=d.get(b);f=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(f)throw Error("target.depthTexture not supported in Cube render targets");if(b&&b.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported");a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&&
15735 b.depthTexture.image.width===b.width&&b.depthTexture.image.height===b.height||(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0);l(b.depthTexture,0);e=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.TEXTURE_2D,e,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.TEXTURE_2D,e,0);else throw Error("Unknown depthTexture format");
15736 }else if(f)for(e.__webglDepthbuffer=[],f=0;6>f;f++)a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer[f]),e.__webglDepthbuffer[f]=a.createRenderbuffer(),w(e.__webglDepthbuffer[f],b);else a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer),e.__webglDepthbuffer=a.createRenderbuffer(),w(e.__webglDepthbuffer,b);a.bindFramebuffer(a.FRAMEBUFFER,null)}};this.updateRenderTargetMipmap=function(b){var e=b.texture,f=k(b);if(m(e,f)){f=b.isWebGLRenderTargetCube?a.TEXTURE_CUBE_MAP:a.TEXTURE_2D;var g=d.get(e).__webglTexture;
15737 c.bindTexture(f,g);q(f,e,b.width,b.height);c.bindTexture(f,null)}}}function $e(a,b,c){return{convert:function(d){if(1E3===d)return a.REPEAT;if(1001===d)return a.CLAMP_TO_EDGE;if(1002===d)return a.MIRRORED_REPEAT;if(1003===d)return a.NEAREST;if(1004===d)return a.NEAREST_MIPMAP_NEAREST;if(1005===d)return a.NEAREST_MIPMAP_LINEAR;if(1006===d)return a.LINEAR;if(1007===d)return a.LINEAR_MIPMAP_NEAREST;if(1008===d)return a.LINEAR_MIPMAP_LINEAR;if(1009===d)return a.UNSIGNED_BYTE;if(1017===d)return a.UNSIGNED_SHORT_4_4_4_4;
15738 if(1018===d)return a.UNSIGNED_SHORT_5_5_5_1;if(1019===d)return a.UNSIGNED_SHORT_5_6_5;if(1010===d)return a.BYTE;if(1011===d)return a.SHORT;if(1012===d)return a.UNSIGNED_SHORT;if(1013===d)return a.INT;if(1014===d)return a.UNSIGNED_INT;if(1015===d)return a.FLOAT;if(1016===d){if(c.isWebGL2)return a.HALF_FLOAT;var e=b.get("OES_texture_half_float");if(null!==e)return e.HALF_FLOAT_OES}if(1021===d)return a.ALPHA;if(1022===d)return a.RGB;if(1023===d)return a.RGBA;if(1024===d)return a.LUMINANCE;if(1025===
15739 d)return a.LUMINANCE_ALPHA;if(1026===d)return a.DEPTH_COMPONENT;if(1027===d)return a.DEPTH_STENCIL;if(100===d)return a.FUNC_ADD;if(101===d)return a.FUNC_SUBTRACT;if(102===d)return a.FUNC_REVERSE_SUBTRACT;if(200===d)return a.ZERO;if(201===d)return a.ONE;if(202===d)return a.SRC_COLOR;if(203===d)return a.ONE_MINUS_SRC_COLOR;if(204===d)return a.SRC_ALPHA;if(205===d)return a.ONE_MINUS_SRC_ALPHA;if(206===d)return a.DST_ALPHA;if(207===d)return a.ONE_MINUS_DST_ALPHA;if(208===d)return a.DST_COLOR;if(209===
15740 d)return a.ONE_MINUS_DST_COLOR;if(210===d)return a.SRC_ALPHA_SATURATE;if(33776===d||33777===d||33778===d||33779===d)if(e=b.get("WEBGL_compressed_texture_s3tc"),null!==e){if(33776===d)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===d)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===d)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===d)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===d||35841===d||35842===d||35843===d)if(e=b.get("WEBGL_compressed_texture_pvrtc"),null!==e){if(35840===d)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
15741 if(35841===d)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===d)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===d)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===d&&(e=b.get("WEBGL_compressed_texture_etc1"),null!==e))return e.COMPRESSED_RGB_ETC1_WEBGL;if(37808===d||37809===d||37810===d||37811===d||37812===d||37813===d||37814===d||37815===d||37816===d||37817===d||37818===d||37819===d||37820===d||37821===d)if(e=b.get("WEBGL_compressed_texture_astc"),null!==e)return d;if(103===d||104===
15742 d){if(c.isWebGL2){if(103===d)return a.MIN;if(104===d)return a.MAX}e=b.get("EXT_blend_minmax");if(null!==e){if(103===d)return e.MIN_EXT;if(104===d)return e.MAX_EXT}}if(1020===d){if(c.isWebGL2)return a.UNSIGNED_INT_24_8;e=b.get("WEBGL_depth_texture");if(null!==e)return e.UNSIGNED_INT_24_8_WEBGL}return 0}}}function Kb(){D.call(this);this.type="Group"}function Z(a,b,c,d){Na.call(this);this.type="PerspectiveCamera";this.fov=void 0!==a?a:50;this.zoom=1;this.near=void 0!==c?c:.1;this.far=void 0!==d?d:2E3;
15743 this.focus=10;this.aspect=void 0!==b?b:1;this.view=null;this.filmGauge=35;this.filmOffset=0;this.updateProjectionMatrix()}function yc(a){Z.call(this);this.cameras=a||[]}function af(a){function b(){return null!==e&&!0===e.isPresenting}function c(){if(b()){var c=e.getEyeParameters("left"),f=c.renderWidth;c=c.renderHeight;x=a.getPixelRatio();y=a.getSize();a.setDrawingBufferSize(2*f,c,1);B.start()}else d.enabled&&(a.setDrawingBufferSize(y.width,y.height,x),B.stop())}var d=this,e=null,f=null,g=null,h=
15744 [],k=new I,m=new I;"undefined"!==typeof window&&"VRFrameData"in window&&(f=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange",c,!1));var q=new I,n=new fa,t=new p,u=new Z;u.bounds=new V(0,0,.5,1);u.layers.enable(1);var r=new Z;r.bounds=new V(.5,0,.5,1);r.layers.enable(2);var l=new yc([u,r]);l.layers.enable(1);l.layers.enable(2);var y,x,w=[];this.enabled=!1;this.userHeight=1.6;this.getController=function(a){var b=h[a];void 0===b&&(b=new Kb,b.matrixAutoUpdate=!1,b.visible=!1,h[a]=
15745 b);return b};this.getDevice=function(){return e};this.setDevice=function(a){void 0!==a&&(e=a);B.setContext(a)};this.setPoseTarget=function(a){void 0!==a&&(g=a)};this.getCamera=function(a){if(null===e)return a.position.set(0,d.userHeight,0),a;e.depthNear=a.near;e.depthFar=a.far;e.getFrameData(f);var b=e.stageParameters;b?k.fromArray(b.sittingToStandingTransform):k.makeTranslation(0,d.userHeight,0);b=f.pose;var c=null!==g?g:a;c.matrix.copy(k);c.matrix.decompose(c.position,c.quaternion,c.scale);null!==
15746 b.orientation&&(n.fromArray(b.orientation),c.quaternion.multiply(n));null!==b.position&&(n.setFromRotationMatrix(k),t.fromArray(b.position),t.applyQuaternion(n),c.position.add(t));c.updateMatrixWorld();if(!1===e.isPresenting)return a;u.near=a.near;r.near=a.near;u.far=a.far;r.far=a.far;l.matrixWorld.copy(a.matrixWorld);l.matrixWorldInverse.copy(a.matrixWorldInverse);u.matrixWorldInverse.fromArray(f.leftViewMatrix);r.matrixWorldInverse.fromArray(f.rightViewMatrix);m.getInverse(k);u.matrixWorldInverse.multiply(m);
15747 r.matrixWorldInverse.multiply(m);a=c.parent;null!==a&&(q.getInverse(a.matrixWorld),u.matrixWorldInverse.multiply(q),r.matrixWorldInverse.multiply(q));u.matrixWorld.getInverse(u.matrixWorldInverse);r.matrixWorld.getInverse(r.matrixWorldInverse);u.projectionMatrix.fromArray(f.leftProjectionMatrix);r.projectionMatrix.fromArray(f.rightProjectionMatrix);l.projectionMatrix.copy(u.projectionMatrix);a=e.getLayers();a.length&&(a=a[0],null!==a.leftBounds&&4===a.leftBounds.length&&u.bounds.fromArray(a.leftBounds),
15748 null!==a.rightBounds&&4===a.rightBounds.length&&r.bounds.fromArray(a.rightBounds));a:for(a=0;a<h.length;a++){b=h[a];b:{c=a;for(var v=navigator.getGamepads&&navigator.getGamepads(),p=0,y=0,x=v.length;p<x;p++){var E=v[p];if(E&&("Daydream Controller"===E.id||"Gear VR Controller"===E.id||"Oculus Go Controller"===E.id||"OpenVR Gamepad"===E.id||E.id.startsWith("Oculus Touch")||E.id.startsWith("Spatial Controller"))){if(y===c){c=E;break b}y++}}c=void 0}if(void 0!==c&&void 0!==c.pose){if(null===c.pose)break a;
15749 v=c.pose;!1===v.hasPosition&&b.position.set(.2,-.6,-.05);null!==v.position&&b.position.fromArray(v.position);null!==v.orientation&&b.quaternion.fromArray(v.orientation);b.matrix.compose(b.position,b.quaternion,b.scale);b.matrix.premultiply(k);b.matrix.decompose(b.position,b.quaternion,b.scale);b.matrixWorldNeedsUpdate=!0;b.visible=!0;v="Daydream Controller"===c.id?0:1;w[a]!==c.buttons[v].pressed&&(w[a]=c.buttons[v].pressed,!0===w[a]?b.dispatchEvent({type:"selectstart"}):(b.dispatchEvent({type:"selectend"}),
15750 b.dispatchEvent({type:"select"})))}else b.visible=!1}return l};this.getStandingMatrix=function(){return k};this.isPresenting=b;var B=new Qd;this.setAnimationLoop=function(a){B.setAnimationLoop(a)};this.submitFrame=function(){b()&&e.submitFrame()};this.dispose=function(){"undefined"!==typeof window&&window.removeEventListener("vrdisplaypresentchange",c)}}function Lg(a){function b(){return null!==h&&null!==k}function c(a){var b=q[n.indexOf(a.inputSource)];b&&b.dispatchEvent({type:a.type})}function d(){a.setFramebuffer(null);
15751 p.stop()}function e(a,b){null===b?a.matrixWorld.copy(a.matrix):a.matrixWorld.multiplyMatrices(b.matrixWorld,a.matrix);a.matrixWorldInverse.getInverse(a.matrixWorld)}var f=a.context,g=null,h=null,k=null,m=null,q=[],n=[],t=new Z;t.layers.enable(1);t.viewport=new V;var u=new Z;u.layers.enable(2);u.viewport=new V;var r=new yc([t,u]);r.layers.enable(1);r.layers.enable(2);this.enabled=!1;this.getController=function(a){var b=q[a];void 0===b&&(b=new Kb,b.matrixAutoUpdate=!1,b.visible=!1,q[a]=b);return b};
15752 this.getDevice=function(){return g};this.setDevice=function(a){void 0!==a&&(g=a);a instanceof XRDevice&&f.setCompatibleXRDevice(a)};this.setSession=function(b,e){h=b;null!==h&&(h.addEventListener("select",c),h.addEventListener("selectstart",c),h.addEventListener("selectend",c),h.addEventListener("end",d),h.baseLayer=new XRWebGLLayer(h,f),h.requestFrameOfReference(e.frameOfReferenceType).then(function(b){k=b;a.setFramebuffer(h.baseLayer.framebuffer);p.setContext(h);p.start()}),n=h.getInputSources(),
15753 h.addEventListener("inputsourceschange",function(){n=h.getInputSources();console.log(n)}))};this.getCamera=function(a){if(b()){var c=a.parent,d=r.cameras;e(r,c);for(var f=0;f<d.length;f++)e(d[f],c);a.matrixWorld.copy(r.matrixWorld);a=a.children;f=0;for(c=a.length;f<c;f++)a[f].updateMatrixWorld(!0);return r}return a};this.isPresenting=b;var l=null,p=new Qd;p.setAnimationLoop(function(a,b){m=b.getDevicePose(k);if(null!==m)for(var c=h.baseLayer,d=b.views,e=0;e<d.length;e++){var f=d[e],g=c.getViewport(f),
15754 t=m.getViewMatrix(f),u=r.cameras[e];u.matrix.fromArray(t).getInverse(u.matrix);u.projectionMatrix.fromArray(f.projectionMatrix);u.viewport.set(g.x,g.y,g.width,g.height);0===e&&(r.matrix.copy(u.matrix),r.projectionMatrix.copy(u.projectionMatrix))}for(e=0;e<q.length;e++){c=q[e];if(d=n[e])if(d=b.getInputPose(d,k),null!==d){c.matrix.elements=d.pointerMatrix;c.matrix.decompose(c.position,c.rotation,c.scale);c.visible=!0;continue}c.visible=!1}l&&l(a)});this.setAnimationLoop=function(a){l=a};this.dispose=
15755 function(){};this.getStandingMatrix=function(){console.warn("THREE.WebXRManager: getStandingMatrix() is no longer needed.");return new THREE.Matrix4};this.submitFrame=function(){}}function Zd(a){var b;function c(){ha=new Pf(F);ua=new Nf(F,ha,a);ua.isWebGL2||(ha.get("WEBGL_depth_texture"),ha.get("OES_texture_float"),ha.get("OES_texture_half_float"),ha.get("OES_texture_half_float_linear"),ha.get("OES_standard_derivatives"),ha.get("OES_element_index_uint"),ha.get("ANGLE_instanced_arrays"));ha.get("OES_texture_float_linear");
15756 da=new $e(F,ha,ua);ba=new Jg(F,ha,da,ua);ba.scissor(wc.copy(fa).multiplyScalar(U));ba.viewport(T.copy(od).multiplyScalar(U));ca=new Sf(F);Ba=new Ag;ia=new Kg(F,ha,ba,Ba,ua,da,ca);pa=new Ff(F);ra=new Qf(F,pa,ca);ma=new Vf(ra,ca);va=new Uf(F);la=new zg(C,ha,ua);sa=new Eg;na=new Ig;ka=new Lf(C,ba,ma,N);xa=new Mf(F,ha,ca,ua);ya=new Rf(F,ha,ca,ua);ca.programs=la.programs;C.context=F;C.capabilities=ua;C.extensions=ha;C.properties=Ba;C.renderLists=sa;C.state=ba;C.info=ca}function d(a){a.preventDefault();
15757 console.log("THREE.WebGLRenderer: Context Lost.");G=!0}function e(){console.log("THREE.WebGLRenderer: Context Restored.");G=!1;c()}function f(a){a=a.target;a.removeEventListener("dispose",f);g(a);Ba.remove(a)}function g(a){var b=Ba.get(a).program;a.program=void 0;void 0!==b&&la.releaseProgram(b)}function h(a,b){a.render(function(a){C.renderBufferImmediate(a,b)})}function k(a,b,c){if(!1!==a.visible){if(a.layers.test(b.layers))if(a.isLight)D.pushLight(a),a.castShadow&&D.pushShadow(a);else if(a.isSprite){if(!a.frustumCulled||
15758 oa.intersectsSprite(a)){c&&bb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(xc);var d=ma.update(a),e=a.material;A.push(a,d,e,bb.z,null)}}else if(a.isImmediateRenderObject)c&&bb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(xc),A.push(a,null,a.material,bb.z,null);else if(a.isMesh||a.isLine||a.isPoints)if(a.isSkinnedMesh&&a.skeleton.update(),!a.frustumCulled||oa.intersectsObject(a))if(c&&bb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(xc),d=ma.update(a),e=a.material,Array.isArray(e))for(var f=
15759 d.groups,g=0,h=f.length;g<h;g++){var m=f[g],n=e[m.materialIndex];n&&n.visible&&A.push(a,d,n,bb.z,m)}else e.visible&&A.push(a,d,e,bb.z,null);a=a.children;g=0;for(h=a.length;g<h;g++)k(a[g],b,c)}}function m(a,b,c,d){for(var e=0,f=a.length;e<f;e++){var g=a[e],h=g.object,k=g.geometry,m=void 0===d?g.material:d;g=g.group;if(c.isArrayCamera){W=c;for(var n=c.cameras,t=0,u=n.length;t<u;t++){var l=n[t];if(h.layers.test(l.layers)){if("viewport"in l)ba.viewport(T.copy(l.viewport));else{var r=l.bounds;ba.viewport(T.set(r.x*
15760 Z,r.y*M,r.z*Z,r.w*M).multiplyScalar(U))}q(h,b,l,k,m,g)}}}else W=null,q(h,b,c,k,m,g)}}function q(a,c,d,e,f,g){a.onBeforeRender(C,c,d,e,f,g);D=na.get(c,W||d);a.modelViewMatrix.multiplyMatrices(d.matrixWorldInverse,a.matrixWorld);a.normalMatrix.getNormalMatrix(a.modelViewMatrix);if(a.isImmediateRenderObject){ba.setMaterial(f);var k=t(d,c.fog,f,a);S=b=null;nd=!1;h(a,k)}else C.renderBufferDirect(d,c.fog,e,f,a,g);a.onAfterRender(C,c,d,e,f,g);D=na.get(c,W||d)}function n(a,b,c){var d=Ba.get(a),e=D.state.lights,
15761 h=d.lightsHash,k=e.state.hash;c=la.getParameters(a,e.state,D.state.shadowsArray,b,aa.numPlanes,aa.numIntersection,c);var m=la.getProgramCode(a,c),n=d.program,q=!0;if(void 0===n)a.addEventListener("dispose",f);else if(n.code!==m)g(a);else{if(h.stateID!==k.stateID||h.directionalLength!==k.directionalLength||h.pointLength!==k.pointLength||h.spotLength!==k.spotLength||h.rectAreaLength!==k.rectAreaLength||h.hemiLength!==k.hemiLength||h.shadowsLength!==k.shadowsLength)h.stateID=k.stateID,h.directionalLength=
15762 k.directionalLength,h.pointLength=k.pointLength,h.spotLength=k.spotLength,h.rectAreaLength=k.rectAreaLength,h.hemiLength=k.hemiLength,h.shadowsLength=k.shadowsLength;else if(void 0!==c.shaderID)return;q=!1}q&&(c.shaderID?(m=nb[c.shaderID],d.shader={name:a.type,uniforms:Aa.clone(m.uniforms),vertexShader:m.vertexShader,fragmentShader:m.fragmentShader}):d.shader={name:a.type,uniforms:a.uniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader},a.onBeforeCompile(d.shader,C),m=la.getProgramCode(a,
15763 c),n=la.acquireProgram(a,d.shader,c,m),d.program=n,a.program=n);c=n.getAttributes();if(a.morphTargets)for(m=a.numSupportedMorphTargets=0;m<C.maxMorphTargets;m++)0<=c["morphTarget"+m]&&a.numSupportedMorphTargets++;if(a.morphNormals)for(m=a.numSupportedMorphNormals=0;m<C.maxMorphNormals;m++)0<=c["morphNormal"+m]&&a.numSupportedMorphNormals++;c=d.shader.uniforms;if(!a.isShaderMaterial&&!a.isRawShaderMaterial||!0===a.clipping)d.numClippingPlanes=aa.numPlanes,d.numIntersection=aa.numIntersection,c.clippingPlanes=
15764 aa.uniform;d.fog=b;void 0===h&&(d.lightsHash=h={});h.stateID=k.stateID;h.directionalLength=k.directionalLength;h.pointLength=k.pointLength;h.spotLength=k.spotLength;h.rectAreaLength=k.rectAreaLength;h.hemiLength=k.hemiLength;h.shadowsLength=k.shadowsLength;a.lights&&(c.ambientLightColor.value=e.state.ambient,c.directionalLights.value=e.state.directional,c.spotLights.value=e.state.spot,c.rectAreaLights.value=e.state.rectArea,c.pointLights.value=e.state.point,c.hemisphereLights.value=e.state.hemi,c.directionalShadowMap.value=
15765 e.state.directionalShadowMap,c.directionalShadowMatrix.value=e.state.directionalShadowMatrix,c.spotShadowMap.value=e.state.spotShadowMap,c.spotShadowMatrix.value=e.state.spotShadowMatrix,c.pointShadowMap.value=e.state.pointShadowMap,c.pointShadowMatrix.value=e.state.pointShadowMatrix);a=d.program.getUniforms();a=Za.seqWithValue(a.seq,c);d.uniformsList=a}function t(a,b,c,d){X=0;var e=Ba.get(c),f=e.lightsHash,g=D.state.lights.state.hash;pd&&(Yd||a!==Y)&&aa.setState(c.clippingPlanes,c.clipIntersection,
15766 c.clipShadows,a,e,a===Y&&c.id===J);!1===c.needsUpdate&&(void 0===e.program?c.needsUpdate=!0:c.fog&&e.fog!==b?c.needsUpdate=!0:!c.lights||f.stateID===g.stateID&&f.directionalLength===g.directionalLength&&f.pointLength===g.pointLength&&f.spotLength===g.spotLength&&f.rectAreaLength===g.rectAreaLength&&f.hemiLength===g.hemiLength&&f.shadowsLength===g.shadowsLength?void 0===e.numClippingPlanes||e.numClippingPlanes===aa.numPlanes&&e.numIntersection===aa.numIntersection||(c.needsUpdate=!0):c.needsUpdate=
15767 !0);c.needsUpdate&&(n(c,b,d),c.needsUpdate=!1);var h=!1,k=!1,m=!1;f=e.program;g=f.getUniforms();var q=e.shader.uniforms;ba.useProgram(f.program)&&(m=k=h=!0);c.id!==J&&(J=c.id,k=!0);if(h||a!==Y){g.setValue(F,"projectionMatrix",a.projectionMatrix);ua.logarithmicDepthBuffer&&g.setValue(F,"logDepthBufFC",2/(Math.log(a.far+1)/Math.LN2));Y!==(W||a)&&(Y=W||a,m=k=!0);if(c.isShaderMaterial||c.isMeshPhongMaterial||c.isMeshStandardMaterial||c.envMap)h=g.map.cameraPosition,void 0!==h&&h.setValue(F,bb.setFromMatrixPosition(a.matrixWorld));
15768 (c.isMeshPhongMaterial||c.isMeshLambertMaterial||c.isMeshBasicMaterial||c.isMeshStandardMaterial||c.isShaderMaterial||c.skinning)&&g.setValue(F,"viewMatrix",a.matrixWorldInverse)}if(c.skinning&&(g.setOptional(F,d,"bindMatrix"),g.setOptional(F,d,"bindMatrixInverse"),a=d.skeleton))if(h=a.bones,ua.floatVertexTextures){if(void 0===a.boneTexture){h=Math.sqrt(4*h.length);h=H.ceilPowerOfTwo(h);h=Math.max(h,4);var t=new Float32Array(h*h*4);t.set(a.boneMatrices);var v=new gb(t,h,h,1023,1015);v.needsUpdate=
15769 !0;a.boneMatrices=t;a.boneTexture=v;a.boneTextureSize=h}g.setValue(F,"boneTexture",a.boneTexture);g.setValue(F,"boneTextureSize",a.boneTextureSize)}else g.setOptional(F,a,"boneMatrices");k&&(g.setValue(F,"toneMappingExposure",C.toneMappingExposure),g.setValue(F,"toneMappingWhitePoint",C.toneMappingWhitePoint),c.lights&&(k=m,q.ambientLightColor.needsUpdate=k,q.directionalLights.needsUpdate=k,q.pointLights.needsUpdate=k,q.spotLights.needsUpdate=k,q.rectAreaLights.needsUpdate=k,q.hemisphereLights.needsUpdate=
15770 k),b&&c.fog&&(q.fogColor.value=b.color,b.isFog?(q.fogNear.value=b.near,q.fogFar.value=b.far):b.isFogExp2&&(q.fogDensity.value=b.density)),c.isMeshBasicMaterial?u(q,c):c.isMeshLambertMaterial?(u(q,c),c.emissiveMap&&(q.emissiveMap.value=c.emissiveMap)):c.isMeshPhongMaterial?(u(q,c),c.isMeshToonMaterial?(r(q,c),c.gradientMap&&(q.gradientMap.value=c.gradientMap)):r(q,c)):c.isMeshStandardMaterial?(u(q,c),c.isMeshPhysicalMaterial?(l(q,c),q.reflectivity.value=c.reflectivity,q.clearCoat.value=c.clearCoat,
15771 q.clearCoatRoughness.value=c.clearCoatRoughness):l(q,c)):c.isMeshDepthMaterial?(u(q,c),c.displacementMap&&(q.displacementMap.value=c.displacementMap,q.displacementScale.value=c.displacementScale,q.displacementBias.value=c.displacementBias)):c.isMeshDistanceMaterial?(u(q,c),c.displacementMap&&(q.displacementMap.value=c.displacementMap,q.displacementScale.value=c.displacementScale,q.displacementBias.value=c.displacementBias),q.referencePosition.value.copy(c.referencePosition),q.nearDistance.value=c.nearDistance,
15772 q.farDistance.value=c.farDistance):c.isMeshNormalMaterial?(u(q,c),c.bumpMap&&(q.bumpMap.value=c.bumpMap,q.bumpScale.value=c.bumpScale,1===c.side&&(q.bumpScale.value*=-1)),c.normalMap&&(q.normalMap.value=c.normalMap,q.normalScale.value.copy(c.normalScale),1===c.side&&q.normalScale.value.negate()),c.displacementMap&&(q.displacementMap.value=c.displacementMap,q.displacementScale.value=c.displacementScale,q.displacementBias.value=c.displacementBias)):c.isLineBasicMaterial?(q.diffuse.value=c.color,q.opacity.value=
15773 c.opacity,c.isLineDashedMaterial&&(q.dashSize.value=c.dashSize,q.totalSize.value=c.dashSize+c.gapSize,q.scale.value=c.scale)):c.isPointsMaterial?(q.diffuse.value=c.color,q.opacity.value=c.opacity,q.size.value=c.size*U,q.scale.value=.5*M,q.map.value=c.map,null!==c.map&&(!0===c.map.matrixAutoUpdate&&c.map.updateMatrix(),q.uvTransform.value.copy(c.map.matrix))):c.isSpriteMaterial?(q.diffuse.value=c.color,q.opacity.value=c.opacity,q.rotation.value=c.rotation,q.map.value=c.map,null!==c.map&&(!0===c.map.matrixAutoUpdate&&
15774 c.map.updateMatrix(),q.uvTransform.value.copy(c.map.matrix))):c.isShadowMaterial&&(q.color.value=c.color,q.opacity.value=c.opacity),void 0!==q.ltc_1&&(q.ltc_1.value=K.LTC_1),void 0!==q.ltc_2&&(q.ltc_2.value=K.LTC_2),Za.upload(F,e.uniformsList,q,C));c.isShaderMaterial&&!0===c.uniformsNeedUpdate&&(Za.upload(F,e.uniformsList,q,C),c.uniformsNeedUpdate=!1);c.isSpriteMaterial&&g.setValue(F,"center",d.center);g.setValue(F,"modelViewMatrix",d.modelViewMatrix);g.setValue(F,"normalMatrix",d.normalMatrix);g.setValue(F,
15775 "modelMatrix",d.matrixWorld);return f}function u(a,b){a.opacity.value=b.opacity;b.color&&(a.diffuse.value=b.color);b.emissive&&a.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity);b.map&&(a.map.value=b.map);b.alphaMap&&(a.alphaMap.value=b.alphaMap);b.specularMap&&(a.specularMap.value=b.specularMap);b.envMap&&(a.envMap.value=b.envMap,a.flipEnvMap.value=b.envMap&&b.envMap.isCubeTexture?-1:1,a.reflectivity.value=b.reflectivity,a.refractionRatio.value=b.refractionRatio,a.maxMipLevel.value=
15776 Ba.get(b.envMap).__maxMipLevel);b.lightMap&&(a.lightMap.value=b.lightMap,a.lightMapIntensity.value=b.lightMapIntensity);b.aoMap&&(a.aoMap.value=b.aoMap,a.aoMapIntensity.value=b.aoMapIntensity);if(b.map)var c=b.map;else b.specularMap?c=b.specularMap:b.displacementMap?c=b.displacementMap:b.normalMap?c=b.normalMap:b.bumpMap?c=b.bumpMap:b.roughnessMap?c=b.roughnessMap:b.metalnessMap?c=b.metalnessMap:b.alphaMap?c=b.alphaMap:b.emissiveMap&&(c=b.emissiveMap);void 0!==c&&(c.isWebGLRenderTarget&&(c=c.texture),
15777 !0===c.matrixAutoUpdate&&c.updateMatrix(),a.uvTransform.value.copy(c.matrix))}function r(a,b){a.specular.value=b.specular;a.shininess.value=Math.max(b.shininess,1E-4);b.emissiveMap&&(a.emissiveMap.value=b.emissiveMap);b.bumpMap&&(a.bumpMap.value=b.bumpMap,a.bumpScale.value=b.bumpScale,1===b.side&&(a.bumpScale.value*=-1));b.normalMap&&(a.normalMap.value=b.normalMap,a.normalScale.value.copy(b.normalScale),1===b.side&&a.normalScale.value.negate());b.displacementMap&&(a.displacementMap.value=b.displacementMap,
15778 a.displacementScale.value=b.displacementScale,a.displacementBias.value=b.displacementBias)}function l(a,b){a.roughness.value=b.roughness;a.metalness.value=b.metalness;b.roughnessMap&&(a.roughnessMap.value=b.roughnessMap);b.metalnessMap&&(a.metalnessMap.value=b.metalnessMap);b.emissiveMap&&(a.emissiveMap.value=b.emissiveMap);b.bumpMap&&(a.bumpMap.value=b.bumpMap,a.bumpScale.value=b.bumpScale,1===b.side&&(a.bumpScale.value*=-1));b.normalMap&&(a.normalMap.value=b.normalMap,a.normalScale.value.copy(b.normalScale),
15779 1===b.side&&a.normalScale.value.negate());b.displacementMap&&(a.displacementMap.value=b.displacementMap,a.displacementScale.value=b.displacementScale,a.displacementBias.value=b.displacementBias);b.envMap&&(a.envMapIntensity.value=b.envMapIntensity)}console.log("THREE.WebGLRenderer","95");a=a||{};var y=void 0!==a.canvas?a.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),x=void 0!==a.context?a.context:null,w=void 0!==a.alpha?a.alpha:!1,B=void 0!==a.depth?a.depth:!0,E=void 0!==
15780 a.stencil?a.stencil:!0,P=void 0!==a.antialias?a.antialias:!1,N=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,O=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,z=void 0!==a.powerPreference?a.powerPreference:"default",A=null,D=null;this.domElement=y;this.context=null;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.clippingPlanes=[];this.localClippingEnabled=!1;this.gammaFactor=2;this.physicallyCorrectLights=this.gammaOutput=this.gammaInput=
15781 !1;this.toneMappingWhitePoint=this.toneMappingExposure=this.toneMapping=1;this.maxMorphTargets=8;this.maxMorphNormals=4;var C=this,G=!1,L=null,R=null,Q=null,J=-1;var S=b=null;var nd=!1;var Y=null,W=null,T=new V,wc=new V,ea=null,X=0,Z=y.width,M=y.height,U=1,od=new V(0,0,Z,M),fa=new V(0,0,Z,M),qa=!1,oa=new md,aa=new Of,pd=!1,Yd=!1,xc=new I,bb=new p;try{w={alpha:w,depth:B,stencil:E,antialias:P,premultipliedAlpha:N,preserveDrawingBuffer:O,powerPreference:z};y.addEventListener("webglcontextlost",d,!1);
15782 y.addEventListener("webglcontextrestored",e,!1);var F=x||y.getContext("webgl",w)||y.getContext("experimental-webgl",w);if(null===F){if(null!==y.getContext("webgl"))throw Error("Error creating WebGL context with your selected attributes.");throw Error("Error creating WebGL context.");}void 0===F.getShaderPrecisionFormat&&(F.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Mg){console.error("THREE.WebGLRenderer: "+Mg.message)}var ha,ua,ba,ca,Ba,ia,pa,ra,ma,la,sa,
15783 na,ka,va,xa,ya,da;c();var ja="xr"in navigator?new Lg(C):new af(C);this.vr=ja;var za=new Ze(C,ma,ua.maxTextureSize);this.shadowMap=za;this.getContext=function(){return F};this.getContextAttributes=function(){return F.getContextAttributes()};this.forceContextLoss=function(){var a=ha.get("WEBGL_lose_context");a&&a.loseContext()};this.forceContextRestore=function(){var a=ha.get("WEBGL_lose_context");a&&a.restoreContext()};this.getPixelRatio=function(){return U};this.setPixelRatio=function(a){void 0!==
15784 a&&(U=a,this.setSize(Z,M,!1))};this.getSize=function(){return{width:Z,height:M}};this.setSize=function(a,b,c){ja.isPresenting()?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(Z=a,M=b,y.width=a*U,y.height=b*U,!1!==c&&(y.style.width=a+"px",y.style.height=b+"px"),this.setViewport(0,0,a,b))};this.getDrawingBufferSize=function(){return{width:Z*U,height:M*U}};this.setDrawingBufferSize=function(a,b,c){Z=a;M=b;U=c;y.width=a*c;y.height=b*c;this.setViewport(0,0,a,b)};
15785 this.getCurrentViewport=function(){return T};this.setViewport=function(a,b,c,d){od.set(a,M-b-d,c,d);ba.viewport(T.copy(od).multiplyScalar(U))};this.setScissor=function(a,b,c,d){fa.set(a,M-b-d,c,d);ba.scissor(wc.copy(fa).multiplyScalar(U))};this.setScissorTest=function(a){ba.setScissorTest(qa=a)};this.getClearColor=function(){return ka.getClearColor()};this.setClearColor=function(){ka.setClearColor.apply(ka,arguments)};this.getClearAlpha=function(){return ka.getClearAlpha()};this.setClearAlpha=function(){ka.setClearAlpha.apply(ka,
15786 arguments)};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=F.COLOR_BUFFER_BIT;if(void 0===b||b)d|=F.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=F.STENCIL_BUFFER_BIT;F.clear(d)};this.clearColor=function(){this.clear(!0,!1,!1)};this.clearDepth=function(){this.clear(!1,!0,!1)};this.clearStencil=function(){this.clear(!1,!1,!0)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.dispose=function(){y.removeEventListener("webglcontextlost",d,!1);y.removeEventListener("webglcontextrestored",
15787 e,!1);sa.dispose();na.dispose();Ba.dispose();ma.dispose();ja.dispose();ta.stop()};this.renderBufferImmediate=function(a,b){ba.initAttributes();var c=Ba.get(a);a.hasPositions&&!c.position&&(c.position=F.createBuffer());a.hasNormals&&!c.normal&&(c.normal=F.createBuffer());a.hasUvs&&!c.uv&&(c.uv=F.createBuffer());a.hasColors&&!c.color&&(c.color=F.createBuffer());b=b.getAttributes();a.hasPositions&&(F.bindBuffer(F.ARRAY_BUFFER,c.position),F.bufferData(F.ARRAY_BUFFER,a.positionArray,F.DYNAMIC_DRAW),ba.enableAttribute(b.position),
15788 F.vertexAttribPointer(b.position,3,F.FLOAT,!1,0,0));a.hasNormals&&(F.bindBuffer(F.ARRAY_BUFFER,c.normal),F.bufferData(F.ARRAY_BUFFER,a.normalArray,F.DYNAMIC_DRAW),ba.enableAttribute(b.normal),F.vertexAttribPointer(b.normal,3,F.FLOAT,!1,0,0));a.hasUvs&&(F.bindBuffer(F.ARRAY_BUFFER,c.uv),F.bufferData(F.ARRAY_BUFFER,a.uvArray,F.DYNAMIC_DRAW),ba.enableAttribute(b.uv),F.vertexAttribPointer(b.uv,2,F.FLOAT,!1,0,0));a.hasColors&&(F.bindBuffer(F.ARRAY_BUFFER,c.color),F.bufferData(F.ARRAY_BUFFER,a.colorArray,
15789 F.DYNAMIC_DRAW),ba.enableAttribute(b.color),F.vertexAttribPointer(b.color,3,F.FLOAT,!1,0,0));ba.disableUnusedAttributes();F.drawArrays(F.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,c,d,e,f,g){var h=f.isMesh&&0>f.normalMatrix.determinant();ba.setMaterial(e,h);var k=t(a,c,e,f),m=!1;if(b!==d.id||S!==k.id||nd!==(!0===e.wireframe))b=d.id,S=k.id,nd=!0===e.wireframe,m=!0;f.morphTargetInfluences&&(va.update(f,d,e,k),m=!0);h=d.index;var q=d.attributes.position;c=1;!0===e.wireframe&&
15790 (h=ra.getWireframeAttribute(d),c=2);a=xa;if(null!==h){var n=pa.get(h);a=ya;a.setIndex(n)}if(m){if(d&&d.isInstancedBufferGeometry&!ua.isWebGL2&&null===ha.get("ANGLE_instanced_arrays"))console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");else{ba.initAttributes();m=d.attributes;k=k.getAttributes();var u=e.defaultAttributeValues;for(N in k){var l=k[N];if(0<=l){var r=m[N];if(void 0!==r){var v=r.normalized,
15791 p=r.itemSize,w=pa.get(r);if(void 0!==w){var y=w.buffer,E=w.type;w=w.bytesPerElement;if(r.isInterleavedBufferAttribute){var x=r.data,B=x.stride;r=r.offset;x&&x.isInstancedInterleavedBuffer?(ba.enableAttributeAndDivisor(l,x.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=x.meshPerAttribute*x.count)):ba.enableAttribute(l);F.bindBuffer(F.ARRAY_BUFFER,y);F.vertexAttribPointer(l,p,E,v,B*w,r*w)}else r.isInstancedBufferAttribute?(ba.enableAttributeAndDivisor(l,r.meshPerAttribute),void 0===
15792 d.maxInstancedCount&&(d.maxInstancedCount=r.meshPerAttribute*r.count)):ba.enableAttribute(l),F.bindBuffer(F.ARRAY_BUFFER,y),F.vertexAttribPointer(l,p,E,v,0,0)}}else if(void 0!==u&&(v=u[N],void 0!==v))switch(v.length){case 2:F.vertexAttrib2fv(l,v);break;case 3:F.vertexAttrib3fv(l,v);break;case 4:F.vertexAttrib4fv(l,v);break;default:F.vertexAttrib1fv(l,v)}}}ba.disableUnusedAttributes()}null!==h&&F.bindBuffer(F.ELEMENT_ARRAY_BUFFER,n.buffer)}n=Infinity;null!==h?n=h.count:void 0!==q&&(n=q.count);h=d.drawRange.start*
15793 c;q=null!==g?g.start*c:0;var N=Math.max(h,q);g=Math.max(0,Math.min(n,h+d.drawRange.count*c,q+(null!==g?g.count*c:Infinity))-1-N+1);if(0!==g){if(f.isMesh)if(!0===e.wireframe)ba.setLineWidth(e.wireframeLinewidth*(null===R?U:1)),a.setMode(F.LINES);else switch(f.drawMode){case 0:a.setMode(F.TRIANGLES);break;case 1:a.setMode(F.TRIANGLE_STRIP);break;case 2:a.setMode(F.TRIANGLE_FAN)}else f.isLine?(e=e.linewidth,void 0===e&&(e=1),ba.setLineWidth(e*(null===R?U:1)),f.isLineSegments?a.setMode(F.LINES):f.isLineLoop?
15794 a.setMode(F.LINE_LOOP):a.setMode(F.LINE_STRIP)):f.isPoints?a.setMode(F.POINTS):f.isSprite&&a.setMode(F.TRIANGLES);d&&d.isInstancedBufferGeometry?0<d.maxInstancedCount&&a.renderInstances(d,N,g):a.render(N,g)}};this.compile=function(a,b){D=na.get(a,b);D.init();a.traverse(function(a){a.isLight&&(D.pushLight(a),a.castShadow&&D.pushShadow(a))});D.setupLights(b);a.traverse(function(b){if(b.material)if(Array.isArray(b.material))for(var c=0;c<b.material.length;c++)n(b.material[c],a.fog,b);else n(b.material,
15795 a.fog,b)})};var wa=null,ta=new Qd;ta.setAnimationLoop(function(a){ja.isPresenting()||wa&&wa(a)});"undefined"!==typeof window&&ta.setContext(window);this.setAnimationLoop=function(a){wa=a;ja.setAnimationLoop(a);ta.start()};this.render=function(a,c,d,e){if(!c||!c.isCamera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else if(!G){S=b=null;nd=!1;J=-1;Y=null;!0===a.autoUpdate&&a.updateMatrixWorld();null===c.parent&&c.updateMatrixWorld();ja.enabled&&(c=ja.getCamera(c));
15796 D=na.get(a,c);D.init();a.onBeforeRender(C,a,c,d);xc.multiplyMatrices(c.projectionMatrix,c.matrixWorldInverse);oa.setFromMatrix(xc);Yd=this.localClippingEnabled;pd=aa.init(this.clippingPlanes,Yd,c);A=sa.get(a,c);A.init();k(a,c,C.sortObjects);!0===C.sortObjects&&A.sort();pd&&aa.beginShadows();za.render(D.state.shadowsArray,a,c);D.setupLights(c);pd&&aa.endShadows();this.info.autoReset&&this.info.reset();void 0===d&&(d=null);this.setRenderTarget(d);ka.render(A,a,c,e);e=A.opaque;var f=A.transparent;if(a.overrideMaterial){var g=
15797 a.overrideMaterial;e.length&&m(e,a,c,g);f.length&&m(f,a,c,g)}else e.length&&m(e,a,c),f.length&&m(f,a,c);d&&ia.updateRenderTargetMipmap(d);ba.buffers.depth.setTest(!0);ba.buffers.depth.setMask(!0);ba.buffers.color.setMask(!0);ba.setPolygonOffset(!1);a.onAfterRender(C,a,c);ja.enabled&&ja.submitFrame();D=A=null}};this.allocTextureUnit=function(){var a=X;a>=ua.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+a+" texture units while this GPU supports only "+ua.maxTextures);X+=1;return a};
15798 this.setTexture2D=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTarget&&(a||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);ia.setTexture2D(b,c)}}();this.setTexture=function(){var a=!1;return function(b,c){a||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),a=!0);ia.setTexture2D(b,c)}}();this.setTextureCube=function(){var a=!1;return function(b,c){b&&
15799 b.isWebGLRenderTargetCube&&(a||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);b&&b.isCubeTexture||Array.isArray(b.image)&&6===b.image.length?ia.setTextureCube(b,c):ia.setTextureCubeDynamic(b,c)}}();this.setFramebuffer=function(a){L=a};this.getRenderTarget=function(){return R};this.setRenderTarget=function(a){(R=a)&&void 0===Ba.get(a).__webglFramebuffer&&ia.setupRenderTarget(a);var b=L,c=!1;a?(b=
15800 Ba.get(a).__webglFramebuffer,a.isWebGLRenderTargetCube&&(b=b[a.activeCubeFace],c=!0),T.copy(a.viewport),wc.copy(a.scissor),ea=a.scissorTest):(T.copy(od).multiplyScalar(U),wc.copy(fa).multiplyScalar(U),ea=qa);Q!==b&&(F.bindFramebuffer(F.FRAMEBUFFER,b),Q=b);ba.viewport(T);ba.scissor(wc);ba.setScissorTest(ea);c&&(c=Ba.get(a.texture),F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,c.__webglTexture,a.activeMipMapLevel))};this.readRenderTargetPixels=
15801 function(a,b,c,d,e,f){if(a&&a.isWebGLRenderTarget){var g=Ba.get(a).__webglFramebuffer;if(g){var h=!1;g!==Q&&(F.bindFramebuffer(F.FRAMEBUFFER,g),h=!0);try{var k=a.texture,m=k.format,q=k.type;1023!==m&&da.convert(m)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===q||da.convert(q)===F.getParameter(F.IMPLEMENTATION_COLOR_READ_TYPE)||1015===q&&(ua.isWebGL2||ha.get("OES_texture_float")||
15802 ha.get("WEBGL_color_buffer_float"))||1016===q&&(ua.isWebGL2?ha.get("EXT_color_buffer_float"):ha.get("EXT_color_buffer_half_float"))?F.checkFramebufferStatus(F.FRAMEBUFFER)===F.FRAMEBUFFER_COMPLETE?0<=b&&b<=a.width-d&&0<=c&&c<=a.height-e&&F.readPixels(b,c,d,e,da.convert(m),da.convert(q),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&
15803 F.bindFramebuffer(F.FRAMEBUFFER,Q)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")};this.copyFramebufferToTexture=function(a,b,c){var d=b.image.width,e=b.image.height,f=da.convert(b.format);this.setTexture2D(b,0);F.copyTexImage2D(F.TEXTURE_2D,c||0,f,a.x,a.y,d,e,0)};this.copyTextureToTexture=function(a,b,c,d){var e=b.image.width,f=b.image.height,g=da.convert(c.format),h=da.convert(c.type);this.setTexture2D(c,0);b.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,
15804 d||0,a.x,a.y,e,f,g,h,b.image.data):F.texSubImage2D(F.TEXTURE_2D,d||0,a.x,a.y,g,h,b.image)}}function Lb(a,b){this.name="";this.color=new G(a);this.density=void 0!==b?b:2.5E-4}function Mb(a,b,c){this.name="";this.color=new G(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3}function qd(){D.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.background=null;this.autoUpdate=!0}function ob(a,b){this.array=a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.dynamic=!1;this.updateRange=
15805 {offset:0,count:-1};this.version=0}function zc(a,b,c,d){this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0===d}function cb(a){J.call(this);this.type="SpriteMaterial";this.color=new G(16777215);this.map=null;this.rotation=0;this.lights=!1;this.transparent=!0;this.setValues(a)}function Ac(a){D.call(this);this.type="Sprite";if(void 0===Nb){Nb=new C;var b=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]);b=new ob(b,5);Nb.setIndex([0,1,2,0,2,3]);Nb.addAttribute("position",
15806 new zc(b,3,0,!1));Nb.addAttribute("uv",new zc(b,2,3,!1))}this.geometry=Nb;this.material=void 0!==a?a:new cb;this.center=new z(.5,.5)}function Bc(){D.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Cc(a,b){a=a||[];this.bones=a.slice(0);this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton boneInverses is the wrong length."),
15807 this.boneInverses=[],a=0,b=this.bones.length;a<b;a++)this.boneInverses.push(new I)}function rd(){D.call(this);this.type="Bone"}function sd(a,b){la.call(this,a,b);this.type="SkinnedMesh";this.bindMode="attached";this.bindMatrix=new I;this.bindMatrixInverse=new I;a=this.initBones();a=new Cc(a);this.bind(a,this.matrixWorld);this.normalizeSkinWeights()}function Y(a){J.call(this);this.type="LineBasicMaterial";this.color=new G(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.lights=!1;
15808 this.setValues(a)}function sa(a,b,c){1===c&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.");D.call(this);this.type="Line";this.geometry=void 0!==a?a:new C;this.material=void 0!==b?b:new Y({color:16777215*Math.random()})}function W(a,b){sa.call(this,a,b);this.type="LineSegments"}function td(a,b){sa.call(this,a,b);this.type="LineLoop"}function Ea(a){J.call(this);this.type="PointsMaterial";this.color=new G(16777215);this.map=null;this.size=
15809 1;this.sizeAttenuation=!0;this.lights=this.morphTargets=!1;this.setValues(a)}function Ob(a,b){D.call(this);this.type="Points";this.geometry=void 0!==a?a:new C;this.material=void 0!==b?b:new Ea({color:16777215*Math.random()})}function $d(a,b,c,d,e,f,g,h,k){T.call(this,a,b,c,d,e,f,g,h,k);this.generateMipmaps=!1}function Pb(a,b,c,d,e,f,g,h,k,m,q,n){T.call(this,null,f,g,h,k,m,d,e,q,n);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function Dc(a,b,c,d,e,f,g,h,k){T.call(this,
15810 a,b,c,d,e,f,g,h,k);this.needsUpdate=!0}function Ec(a,b,c,d,e,f,g,h,k,m){m=void 0!==m?m:1026;if(1026!==m&&1027!==m)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===c&&1026===m&&(c=1012);void 0===c&&1027===m&&(c=1020);T.call(this,null,d,e,f,g,h,m,c,k);this.image={width:a,height:b};this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=this.flipY=!1}function Qb(a){C.call(this);this.type="WireframeGeometry";var b=
15811 [],c,d,e,f=[0,0],g={},h=["a","b","c"];if(a&&a.isGeometry){var k=a.faces;var m=0;for(d=k.length;m<d;m++){var q=k[m];for(c=0;3>c;c++){var n=q[h[c]];var t=q[h[(c+1)%3]];f[0]=Math.min(n,t);f[1]=Math.max(n,t);n=f[0]+","+f[1];void 0===g[n]&&(g[n]={index1:f[0],index2:f[1]})}}for(n in g)m=g[n],h=a.vertices[m.index1],b.push(h.x,h.y,h.z),h=a.vertices[m.index2],b.push(h.x,h.y,h.z)}else if(a&&a.isBufferGeometry)if(h=new p,null!==a.index){k=a.attributes.position;q=a.index;var u=a.groups;0===u.length&&(u=[{start:0,
15812 count:q.count,materialIndex:0}]);a=0;for(e=u.length;a<e;++a)for(m=u[a],c=m.start,d=m.count,m=c,d=c+d;m<d;m+=3)for(c=0;3>c;c++)n=q.getX(m+c),t=q.getX(m+(c+1)%3),f[0]=Math.min(n,t),f[1]=Math.max(n,t),n=f[0]+","+f[1],void 0===g[n]&&(g[n]={index1:f[0],index2:f[1]});for(n in g)m=g[n],h.fromBufferAttribute(k,m.index1),b.push(h.x,h.y,h.z),h.fromBufferAttribute(k,m.index2),b.push(h.x,h.y,h.z)}else for(k=a.attributes.position,m=0,d=k.count/3;m<d;m++)for(c=0;3>c;c++)g=3*m+c,h.fromBufferAttribute(k,g),b.push(h.x,
15813 h.y,h.z),g=3*m+(c+1)%3,h.fromBufferAttribute(k,g),b.push(h.x,h.y,h.z);this.addAttribute("position",new A(b,3))}function Fc(a,b,c){R.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new Rb(a,b,c));this.mergeVertices()}function Rb(a,b,c){C.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g=[],h=new p,k=new p,m=new p,q=new p,n=new p,t,u;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");
15814 var r=b+1;for(t=0;t<=c;t++){var l=t/c;for(u=0;u<=b;u++){var y=u/b;a(y,l,k);e.push(k.x,k.y,k.z);0<=y-1E-5?(a(y-1E-5,l,m),q.subVectors(k,m)):(a(y+1E-5,l,m),q.subVectors(m,k));0<=l-1E-5?(a(y,l-1E-5,m),n.subVectors(k,m)):(a(y,l+1E-5,m),n.subVectors(m,k));h.crossVectors(q,n).normalize();f.push(h.x,h.y,h.z);g.push(y,l)}}for(t=0;t<c;t++)for(u=0;u<b;u++)a=t*r+u+1,h=(t+1)*r+u+1,k=(t+1)*r+u,d.push(t*r+u,a,k),d.push(a,h,k);this.setIndex(d);this.addAttribute("position",new A(e,3));this.addAttribute("normal",
15815 new A(f,3));this.addAttribute("uv",new A(g,2))}function Gc(a,b,c,d){R.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};this.fromBufferGeometry(new na(a,b,c,d));this.mergeVertices()}function na(a,b,c,d){function e(a){h.push(a.x,a.y,a.z)}function f(b,c){b*=3;c.x=a[b+0];c.y=a[b+1];c.z=a[b+2]}function g(a,b,c,d){0>d&&1===a.x&&(k[b]=a.x-1);0===c.x&&0===c.z&&(k[b]=d/2/Math.PI+.5)}C.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a,
15816 indices:b,radius:c,detail:d};c=c||1;d=d||0;var h=[],k=[];(function(a){for(var c=new p,d=new p,g=new p,h=0;h<b.length;h+=3){f(b[h+0],c);f(b[h+1],d);f(b[h+2],g);var k,m,l=c,x=d,w=g,B=Math.pow(2,a),E=[];for(m=0;m<=B;m++){E[m]=[];var P=l.clone().lerp(w,m/B),N=x.clone().lerp(w,m/B),O=B-m;for(k=0;k<=O;k++)E[m][k]=0===k&&m===B?P:P.clone().lerp(N,k/O)}for(m=0;m<B;m++)for(k=0;k<2*(B-m)-1;k++)l=Math.floor(k/2),0===k%2?(e(E[m][l+1]),e(E[m+1][l]),e(E[m][l])):(e(E[m][l+1]),e(E[m+1][l+1]),e(E[m+1][l]))}})(d);(function(a){for(var b=
15817 new p,c=0;c<h.length;c+=3)b.x=h[c+0],b.y=h[c+1],b.z=h[c+2],b.normalize().multiplyScalar(a),h[c+0]=b.x,h[c+1]=b.y,h[c+2]=b.z})(c);(function(){for(var a=new p,b=0;b<h.length;b+=3)a.x=h[b+0],a.y=h[b+1],a.z=h[b+2],k.push(Math.atan2(a.z,-a.x)/2/Math.PI+.5,1-(Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+.5));a=new p;b=new p;for(var c=new p,d=new p,e=new z,f=new z,l=new z,y=0,x=0;y<h.length;y+=9,x+=6){a.set(h[y+0],h[y+1],h[y+2]);b.set(h[y+3],h[y+4],h[y+5]);c.set(h[y+6],h[y+7],h[y+8]);e.set(k[x+0],
15818 k[x+1]);f.set(k[x+2],k[x+3]);l.set(k[x+4],k[x+5]);d.copy(a).add(b).add(c).divideScalar(3);var w=Math.atan2(d.z,-d.x);g(e,x+0,a,w);g(f,x+2,b,w);g(l,x+4,c,w)}for(a=0;a<k.length;a+=6)b=k[a+0],c=k[a+2],d=k[a+4],e=Math.min(b,c,d),.9<Math.max(b,c,d)&&.1>e&&(.2>b&&(k[a+0]+=1),.2>c&&(k[a+2]+=1),.2>d&&(k[a+4]+=1))})();this.addAttribute("position",new A(h,3));this.addAttribute("normal",new A(h.slice(),3));this.addAttribute("uv",new A(k,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Hc(a,
15819 b){R.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Sb(a,b));this.mergeVertices()}function Sb(a,b){na.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Ic(a,b){R.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new pb(a,b));this.mergeVertices()}function pb(a,b){na.call(this,[1,0,0,
15820 -1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Jc(a,b){R.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Tb(a,b));this.mergeVertices()}function Tb(a,b){var c=(1+Math.sqrt(5))/2;na.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,
15821 11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Kc(a,b){R.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Ub(a,b));this.mergeVertices()}function Ub(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;na.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,
15822 0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Lc(a,b,c,d,e,f){R.call(this);this.type="TubeGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,
15823 closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new Vb(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function Vb(a,b,c,d,e){function f(e){q=a.getPointAt(e/b,q);var f=g.normals[e];e=g.binormals[e];for(t=0;t<=d;t++){var m=t/d*Math.PI*2,n=Math.sin(m);m=-Math.cos(m);k.x=m*f.x+n*e.x;k.y=m*f.y+n*e.y;k.z=m*f.z+n*e.z;k.normalize();r.push(k.x,k.y,k.z);h.x=q.x+c*k.x;h.y=q.y+c*k.y;h.z=
15824 q.z+c*k.z;l.push(h.x,h.y,h.z)}}C.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new p,k=new p,m=new z,q=new p,n,t,l=[],r=[],v=[],y=[];for(n=0;n<b;n++)f(n);f(!1===e?b:0);for(n=0;n<=b;n++)for(t=0;t<=d;t++)m.x=n/b,m.y=t/d,v.push(m.x,m.y);(function(){for(t=1;t<=b;t++)for(n=1;n<=d;n++){var a=
15825 (d+1)*t+(n-1),c=(d+1)*t+n,e=(d+1)*(t-1)+n;y.push((d+1)*(t-1)+(n-1),a,e);y.push(a,c,e)}})();this.setIndex(y);this.addAttribute("position",new A(l,3));this.addAttribute("normal",new A(r,3));this.addAttribute("uv",new A(v,2))}function Mc(a,b,c,d,e,f,g){R.call(this);this.type="TorusKnotGeometry";this.parameters={radius:a,tube:b,tubularSegments:c,radialSegments:d,p:e,q:f};void 0!==g&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.");this.fromBufferGeometry(new Wb(a,
15826 b,c,d,e,f));this.mergeVertices()}function Wb(a,b,c,d,e,f){function g(a,b,c,d,e){var f=Math.sin(a);b=c/b*a;c=Math.cos(b);e.x=d*(2+c)*.5*Math.cos(a);e.y=d*(2+c)*f*.5;e.z=d*Math.sin(b)*.5}C.call(this);this.type="TorusKnotBufferGeometry";this.parameters={radius:a,tube:b,tubularSegments:c,radialSegments:d,p:e,q:f};a=a||1;b=b||.4;c=Math.floor(c)||64;d=Math.floor(d)||8;e=e||2;f=f||3;var h=[],k=[],m=[],q=[],n,t=new p,l=new p,r=new p,v=new p,y=new p,x=new p,w=new p;for(n=0;n<=c;++n){var B=n/c*e*Math.PI*2;
15827 g(B,e,f,a,r);g(B+.01,e,f,a,v);x.subVectors(v,r);w.addVectors(v,r);y.crossVectors(x,w);w.crossVectors(y,x);y.normalize();w.normalize();for(B=0;B<=d;++B){var E=B/d*Math.PI*2,P=-b*Math.cos(E);E=b*Math.sin(E);t.x=r.x+(P*w.x+E*y.x);t.y=r.y+(P*w.y+E*y.y);t.z=r.z+(P*w.z+E*y.z);k.push(t.x,t.y,t.z);l.subVectors(t,r).normalize();m.push(l.x,l.y,l.z);q.push(n/c);q.push(B/d)}}for(B=1;B<=c;B++)for(n=1;n<=d;n++)a=(d+1)*B+(n-1),b=(d+1)*B+n,e=(d+1)*(B-1)+n,h.push((d+1)*(B-1)+(n-1),a,e),h.push(a,b,e);this.setIndex(h);
15828 this.addAttribute("position",new A(k,3));this.addAttribute("normal",new A(m,3));this.addAttribute("uv",new A(q,2))}function Nc(a,b,c,d,e){R.call(this);this.type="TorusGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};this.fromBufferGeometry(new Xb(a,b,c,d,e));this.mergeVertices()}function Xb(a,b,c,d,e){C.call(this);this.type="TorusBufferGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};a=a||1;b=b||.4;c=Math.floor(c)||8;d=Math.floor(d)||
15829 6;e=e||2*Math.PI;var f=[],g=[],h=[],k=[],m=new p,q=new p,n=new p,t,l;for(t=0;t<=c;t++)for(l=0;l<=d;l++){var r=l/d*e,v=t/c*Math.PI*2;q.x=(a+b*Math.cos(v))*Math.cos(r);q.y=(a+b*Math.cos(v))*Math.sin(r);q.z=b*Math.sin(v);g.push(q.x,q.y,q.z);m.x=a*Math.cos(r);m.y=a*Math.sin(r);n.subVectors(q,m).normalize();h.push(n.x,n.y,n.z);k.push(l/d);k.push(t/c)}for(t=1;t<=c;t++)for(l=1;l<=d;l++)a=(d+1)*(t-1)+l-1,b=(d+1)*(t-1)+l,e=(d+1)*t+l,f.push((d+1)*t+l-1,a,e),f.push(a,b,e);this.setIndex(f);this.addAttribute("position",
15830 new A(g,3));this.addAttribute("normal",new A(h,3));this.addAttribute("uv",new A(k,2))}function bf(a,b,c,d,e){for(var f,g=0,h=b,k=c-d;h<c;h+=d)g+=(a[k]-a[h])*(a[h+1]+a[k+1]),k=h;if(e===0<g)for(e=b;e<c;e+=d)f=cf(e,a[e],a[e+1],f);else for(e=c-d;e>=b;e-=d)f=cf(e,a[e],a[e+1],f);f&&qb(f,f.next)&&(Oc(f),f=f.next);return f}function Pc(a,b){if(!a)return a;b||(b=a);do{var c=!1;if(a.steiner||!qb(a,a.next)&&0!==ma(a.prev,a,a.next))a=a.next;else{Oc(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b}
15831 function Qc(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,k=h;do null===k.z&&(k.z=ae(k.x,k.y,d,e,f)),k.prevZ=k.prev,k=k.nextZ=k.next;while(k!==h);k.prevZ.nextZ=null;k.prevZ=null;h=k;var m,q,n,t,l=1;do{k=h;var r=h=null;for(q=0;k;){q++;var v=k;for(m=n=0;m<l&&(n++,v=v.nextZ,v);m++);for(t=l;0<n||0<t&&v;)0!==n&&(0===t||!v||k.z<=v.z)?(m=k,k=k.nextZ,n--):(m=v,v=v.nextZ,t--),r?r.nextZ=m:h=m,m.prevZ=r,r=m;k=v}r.nextZ=null;l*=2}while(1<q)}for(h=a;a.prev!==a.next;){k=a.prev;v=a.next;if(f)a:{r=a;t=d;var p=e,x=f;q=r.prev;
15832 n=r;l=r.next;if(0<=ma(q,n,l))r=!1;else{var w=q.x>n.x?q.x>l.x?q.x:l.x:n.x>l.x?n.x:l.x,B=q.y>n.y?q.y>l.y?q.y:l.y:n.y>l.y?n.y:l.y;m=ae(q.x<n.x?q.x<l.x?q.x:l.x:n.x<l.x?n.x:l.x,q.y<n.y?q.y<l.y?q.y:l.y:n.y<l.y?n.y:l.y,t,p,x);t=ae(w,B,t,p,x);for(p=r.nextZ;p&&p.z<=t;){if(p!==r.prev&&p!==r.next&&ud(q.x,q.y,n.x,n.y,l.x,l.y,p.x,p.y)&&0<=ma(p.prev,p,p.next)){r=!1;break a}p=p.nextZ}for(p=r.prevZ;p&&p.z>=m;){if(p!==r.prev&&p!==r.next&&ud(q.x,q.y,n.x,n.y,l.x,l.y,p.x,p.y)&&0<=ma(p.prev,p,p.next)){r=!1;break a}p=
15833 p.prevZ}r=!0}}else a:if(r=a,q=r.prev,n=r,l=r.next,0<=ma(q,n,l))r=!1;else{for(m=r.next.next;m!==r.prev;){if(ud(q.x,q.y,n.x,n.y,l.x,l.y,m.x,m.y)&&0<=ma(m.prev,m,m.next)){r=!1;break a}m=m.next}r=!0}if(r)b.push(k.i/c),b.push(a.i/c),b.push(v.i/c),Oc(a),h=a=v.next;else if(a=v,a===h){if(!g)Qc(Pc(a),b,c,d,e,f,1);else if(1===g){g=b;h=c;k=a;do v=k.prev,r=k.next.next,!qb(v,r)&&df(v,k,k.next,r)&&Rc(v,r)&&Rc(r,v)&&(g.push(v.i/h),g.push(k.i/h),g.push(r.i/h),Oc(k),Oc(k.next),k=a=r),k=k.next;while(k!==a);a=k;Qc(a,
15834 b,c,d,e,f,2)}else if(2===g)a:{g=a;do{for(h=g.next.next;h!==g.prev;){if(k=g.i!==h.i){k=g;v=h;if(r=k.next.i!==v.i&&k.prev.i!==v.i){b:{r=k;do{if(r.i!==k.i&&r.next.i!==k.i&&r.i!==v.i&&r.next.i!==v.i&&df(r,r.next,k,v)){r=!0;break b}r=r.next}while(r!==k);r=!1}r=!r}if(r=r&&Rc(k,v)&&Rc(v,k)){r=k;q=!1;n=(k.x+v.x)/2;v=(k.y+v.y)/2;do r.y>v!==r.next.y>v&&r.next.y!==r.y&&n<(r.next.x-r.x)*(v-r.y)/(r.next.y-r.y)+r.x&&(q=!q),r=r.next;while(r!==k);r=q}k=r}if(k){a=ef(g,h);g=Pc(g,g.next);a=Pc(a,a.next);Qc(g,b,c,d,e,
15835 f);Qc(a,b,c,d,e,f);break a}h=h.next}g=g.next}while(g!==a)}break}}}}function Ng(a,b){return a.x-b.x}function Og(a,b){var c=b,d=a.x,e=a.y,f=-Infinity;do{if(e<=c.y&&e>=c.next.y&&c.next.y!==c.y){var g=c.x+(e-c.y)*(c.next.x-c.x)/(c.next.y-c.y);if(g<=d&&g>f){f=g;if(g===d){if(e===c.y)return c;if(e===c.next.y)return c.next}var h=c.x<c.next.x?c:c.next}}c=c.next}while(c!==b);if(!h)return null;if(d===f)return h.prev;b=h;g=h.x;var k=h.y,m=Infinity;for(c=h.next;c!==b;){if(d>=c.x&&c.x>=g&&d!==c.x&&ud(e<k?d:f,e,
15836 g,k,e<k?f:d,e,c.x,c.y)){var q=Math.abs(e-c.y)/(d-c.x);(q<m||q===m&&c.x>h.x)&&Rc(c,a)&&(h=c,m=q)}c=c.next}return h}function ae(a,b,c,d,e){a=32767*(a-c)*e;b=32767*(b-d)*e;a=(a|a<<8)&16711935;a=(a|a<<4)&252645135;a=(a|a<<2)&858993459;b=(b|b<<8)&16711935;b=(b|b<<4)&252645135;b=(b|b<<2)&858993459;return(a|a<<1)&1431655765|((b|b<<1)&1431655765)<<1}function Pg(a){var b=a,c=a;do b.x<c.x&&(c=b),b=b.next;while(b!==a);return c}function ud(a,b,c,d,e,f,g,h){return 0<=(e-g)*(b-h)-(a-g)*(f-h)&&0<=(a-g)*(d-h)-(c-
15837 g)*(b-h)&&0<=(c-g)*(f-h)-(e-g)*(d-h)}function ma(a,b,c){return(b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y)}function qb(a,b){return a.x===b.x&&a.y===b.y}function df(a,b,c,d){return qb(a,b)&&qb(c,d)||qb(a,d)&&qb(c,b)?!0:0<ma(a,b,c)!==0<ma(a,b,d)&&0<ma(c,d,a)!==0<ma(c,d,b)}function Rc(a,b){return 0>ma(a.prev,a,a.next)?0<=ma(a,b,a.next)&&0<=ma(a,a.prev,b):0>ma(a,b,a.prev)||0>ma(a,a.next,b)}function ef(a,b){var c=new be(a.i,a.x,a.y),d=new be(b.i,b.x,b.y),e=a.next,f=b.prev;a.next=b;b.prev=a;c.next=e;e.prev=
15838 c;d.next=c;c.prev=d;f.next=d;d.prev=f;return d}function cf(a,b,c,d){a=new be(a,b,c);d?(a.next=d.next,a.prev=d,d.next.prev=a,d.next=a):(a.prev=a,a.next=a);return a}function Oc(a){a.next.prev=a.prev;a.prev.next=a.next;a.prevZ&&(a.prevZ.nextZ=a.nextZ);a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function be(a,b,c){this.i=a;this.x=b;this.y=c;this.nextZ=this.prevZ=this.z=this.next=this.prev=null;this.steiner=!1}function ff(a){var b=a.length;2<b&&a[b-1].equals(a[0])&&a.pop()}function gf(a,b){for(var c=0;c<b.length;c++)a.push(b[c].x),
15839 a.push(b[c].y)}function rb(a,b){R.call(this);this.type="ExtrudeGeometry";this.parameters={shapes:a,options:b};this.fromBufferGeometry(new Oa(a,b));this.mergeVertices()}function Oa(a,b){function c(a){function c(a,b,c){b||console.error("THREE.ExtrudeGeometry: vec does not exist");return b.clone().multiplyScalar(c).add(a)}function g(a,b,c){var d=a.x-b.x;var e=a.y-b.y;var f=c.x-a.x;var g=c.y-a.y,h=d*d+e*e;if(Math.abs(d*g-e*f)>Number.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(f*f+g*g);h=b.x-e/k;b=b.y+d/k;
15840 g=((c.x-g/m-h)*g-(c.y+f/m-b)*f)/(d*g-e*f);f=h+d*g-a.x;d=b+e*g-a.y;e=f*f+d*d;if(2>=e)return new z(f,d);e=Math.sqrt(e/2)}else a=!1,d>Number.EPSILON?f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(f=-e,e=Math.sqrt(h)):(f=d,d=e,e=Math.sqrt(h/2));return new z(f/e,d/e)}function h(a,b){for(M=a.length;0<=--M;){var c=M;var f=M-1;0>f&&(f=a.length-1);var g,h=w+2*O;for(g=0;g<h;g++){var k=Z*g,m=Z*(g+1),q=b+f+k,n=b+f+m;m=b+c+m;r(b+c+k);r(q);r(m);r(q);
15841 r(n);r(m);k=e.length/3;k=D.generateSideWallUV(d,e,k-6,k-3,k-2,k-1);v(k[0]);v(k[1]);v(k[3]);v(k[1]);v(k[2]);v(k[3])}}}function k(a,b,c){y.push(a);y.push(b);y.push(c)}function l(a,b,c){r(a);r(b);r(c);a=e.length/3;a=D.generateTopUV(d,e,a-3,a-2,a-1);v(a[0]);v(a[1]);v(a[2])}function r(a){e.push(y[3*a]);e.push(y[3*a+1]);e.push(y[3*a+2])}function v(a){f.push(a.x);f.push(a.y)}var y=[],x=void 0!==b.curveSegments?b.curveSegments:12,w=void 0!==b.steps?b.steps:1,B=void 0!==b.depth?b.depth:100,E=void 0!==b.bevelEnabled?
15842 b.bevelEnabled:!0,P=void 0!==b.bevelThickness?b.bevelThickness:6,N=void 0!==b.bevelSize?b.bevelSize:P-2,O=void 0!==b.bevelSegments?b.bevelSegments:3,A=b.extrudePath,D=void 0!==b.UVGenerator?b.UVGenerator:Qg;void 0!==b.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),B=b.amount);var C=!1;if(A){var G=A.getSpacedPoints(w);C=!0;E=!1;var K=A.computeFrenetFrames(w,!1);var L=new p;var R=new p;var Q=new p}E||(N=P=O=0);var I;x=a.extractPoints(x);a=x.shape;var J=x.holes;
15843 if(!Va.isClockWise(a)){a=a.reverse();var H=0;for(I=J.length;H<I;H++){var S=J[H];Va.isClockWise(S)&&(J[H]=S.reverse())}}var Y=Va.triangulateShape(a,J),W=a;H=0;for(I=J.length;H<I;H++)S=J[H],a=a.concat(S);var T,Z=a.length,V,ea=Y.length;x=[];var M=0;var U=W.length;var X=U-1;for(T=M+1;M<U;M++,X++,T++)X===U&&(X=0),T===U&&(T=0),x[M]=g(W[M],W[X],W[T]);A=[];var fa=x.concat();H=0;for(I=J.length;H<I;H++){S=J[H];var ca=[];M=0;U=S.length;X=U-1;for(T=M+1;M<U;M++,X++,T++)X===U&&(X=0),T===U&&(T=0),ca[M]=g(S[M],S[X],
15844 S[T]);A.push(ca);fa=fa.concat(ca)}for(X=0;X<O;X++){U=X/O;var da=P*Math.cos(U*Math.PI/2);T=N*Math.sin(U*Math.PI/2);M=0;for(U=W.length;M<U;M++){var aa=c(W[M],x[M],T);k(aa.x,aa.y,-da)}H=0;for(I=J.length;H<I;H++)for(S=J[H],ca=A[H],M=0,U=S.length;M<U;M++)aa=c(S[M],ca[M],T),k(aa.x,aa.y,-da)}T=N;for(M=0;M<Z;M++)aa=E?c(a[M],fa[M],T):a[M],C?(R.copy(K.normals[0]).multiplyScalar(aa.x),L.copy(K.binormals[0]).multiplyScalar(aa.y),Q.copy(G[0]).add(R).add(L),k(Q.x,Q.y,Q.z)):k(aa.x,aa.y,0);for(U=1;U<=w;U++)for(M=
15845 0;M<Z;M++)aa=E?c(a[M],fa[M],T):a[M],C?(R.copy(K.normals[U]).multiplyScalar(aa.x),L.copy(K.binormals[U]).multiplyScalar(aa.y),Q.copy(G[U]).add(R).add(L),k(Q.x,Q.y,Q.z)):k(aa.x,aa.y,B/w*U);for(X=O-1;0<=X;X--){U=X/O;da=P*Math.cos(U*Math.PI/2);T=N*Math.sin(U*Math.PI/2);M=0;for(U=W.length;M<U;M++)aa=c(W[M],x[M],T),k(aa.x,aa.y,B+da);H=0;for(I=J.length;H<I;H++)for(S=J[H],ca=A[H],M=0,U=S.length;M<U;M++)aa=c(S[M],ca[M],T),C?k(aa.x,aa.y+G[w-1].y,G[w-1].x+da):k(aa.x,aa.y,B+da)}(function(){var a=e.length/3;if(E){var b=
15846 0*Z;for(M=0;M<ea;M++)V=Y[M],l(V[2]+b,V[1]+b,V[0]+b);b=Z*(w+2*O);for(M=0;M<ea;M++)V=Y[M],l(V[0]+b,V[1]+b,V[2]+b)}else{for(M=0;M<ea;M++)V=Y[M],l(V[2],V[1],V[0]);for(M=0;M<ea;M++)V=Y[M],l(V[0]+Z*w,V[1]+Z*w,V[2]+Z*w)}d.addGroup(a,e.length/3-a,0)})();(function(){var a=e.length/3,b=0;h(W,b);b+=W.length;H=0;for(I=J.length;H<I;H++)S=J[H],h(S,b),b+=S.length;d.addGroup(a,e.length/3-a,1)})()}C.call(this);this.type="ExtrudeBufferGeometry";this.parameters={shapes:a,options:b};a=Array.isArray(a)?a:[a];for(var d=
15847 this,e=[],f=[],g=0,h=a.length;g<h;g++)c(a[g]);this.addAttribute("position",new A(e,3));this.addAttribute("uv",new A(f,2));this.computeVertexNormals()}function hf(a,b,c){c.shapes=[];if(Array.isArray(a))for(var d=0,e=a.length;d<e;d++)c.shapes.push(a[d].uuid);else c.shapes.push(a.uuid);void 0!==b.extrudePath&&(c.options.extrudePath=b.extrudePath.toJSON());return c}function Sc(a,b){R.call(this);this.type="TextGeometry";this.parameters={text:a,parameters:b};this.fromBufferGeometry(new Yb(a,b));this.mergeVertices()}
15848 function Yb(a,b){b=b||{};var c=b.font;if(!c||!c.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new R;a=c.generateShapes(a,b.size);b.depth=void 0!==b.height?b.height:50;void 0===b.bevelThickness&&(b.bevelThickness=10);void 0===b.bevelSize&&(b.bevelSize=8);void 0===b.bevelEnabled&&(b.bevelEnabled=!1);Oa.call(this,a,b);this.type="TextBufferGeometry"}function Tc(a,b,c,d,e,f,g){R.call(this);this.type="SphereGeometry";this.parameters={radius:a,widthSegments:b,
15849 heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};this.fromBufferGeometry(new sb(a,b,c,d,e,f,g));this.mergeVertices()}function sb(a,b,c,d,e,f,g){C.call(this);this.type="SphereBufferGeometry";this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};a=a||1;b=Math.max(3,Math.floor(b)||8);c=Math.max(2,Math.floor(c)||6);d=void 0!==d?d:0;e=void 0!==e?e:2*Math.PI;f=void 0!==f?f:0;g=void 0!==g?g:Math.PI;var h=f+g,k,m,q=0,n=[],l=new p,
15850 u=new p,r=[],v=[],y=[],x=[];for(m=0;m<=c;m++){var w=[],B=m/c;for(k=0;k<=b;k++){var E=k/b;l.x=-a*Math.cos(d+E*e)*Math.sin(f+B*g);l.y=a*Math.cos(f+B*g);l.z=a*Math.sin(d+E*e)*Math.sin(f+B*g);v.push(l.x,l.y,l.z);u.set(l.x,l.y,l.z).normalize();y.push(u.x,u.y,u.z);x.push(E,1-B);w.push(q++)}n.push(w)}for(m=0;m<c;m++)for(k=0;k<b;k++)a=n[m][k+1],d=n[m][k],e=n[m+1][k],g=n[m+1][k+1],(0!==m||0<f)&&r.push(a,d,g),(m!==c-1||h<Math.PI)&&r.push(d,e,g);this.setIndex(r);this.addAttribute("position",new A(v,3));this.addAttribute("normal",
15851 new A(y,3));this.addAttribute("uv",new A(x,2))}function Uc(a,b,c,d,e,f){R.call(this);this.type="RingGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f};this.fromBufferGeometry(new Zb(a,b,c,d,e,f));this.mergeVertices()}function Zb(a,b,c,d,e,f){C.call(this);this.type="RingBufferGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f};a=a||.5;b=b||1;e=void 0!==e?e:0;f=void 0!==f?f:2*Math.PI;
15852 c=void 0!==c?Math.max(3,c):8;d=void 0!==d?Math.max(1,d):1;var g=[],h=[],k=[],m=[],q=a,n=(b-a)/d,l=new p,u=new z,r,v;for(r=0;r<=d;r++){for(v=0;v<=c;v++)a=e+v/c*f,l.x=q*Math.cos(a),l.y=q*Math.sin(a),h.push(l.x,l.y,l.z),k.push(0,0,1),u.x=(l.x/b+1)/2,u.y=(l.y/b+1)/2,m.push(u.x,u.y);q+=n}for(r=0;r<d;r++)for(b=r*(c+1),v=0;v<c;v++)a=v+b,e=a+c+1,f=a+c+2,q=a+1,g.push(a,e,q),g.push(e,f,q);this.setIndex(g);this.addAttribute("position",new A(h,3));this.addAttribute("normal",new A(k,3));this.addAttribute("uv",
15853 new A(m,2))}function Vc(a,b,c,d){R.call(this);this.type="LatheGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};this.fromBufferGeometry(new $b(a,b,c,d));this.mergeVertices()}function $b(a,b,c,d){C.call(this);this.type="LatheBufferGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};b=Math.floor(b)||12;c=c||0;d=d||2*Math.PI;d=H.clamp(d,0,2*Math.PI);var e=[],f=[],g=[],h=1/b,k=new p,m=new z,q;for(q=0;q<=b;q++){var n=c+q*h*d;var l=Math.sin(n),u=Math.cos(n);for(n=
15854 0;n<=a.length-1;n++)k.x=a[n].x*l,k.y=a[n].y,k.z=a[n].x*u,f.push(k.x,k.y,k.z),m.x=q/b,m.y=n/(a.length-1),g.push(m.x,m.y)}for(q=0;q<b;q++)for(n=0;n<a.length-1;n++)c=n+q*a.length,h=c+a.length,k=c+a.length+1,m=c+1,e.push(c,h,m),e.push(h,k,m);this.setIndex(e);this.addAttribute("position",new A(f,3));this.addAttribute("uv",new A(g,2));this.computeVertexNormals();if(d===2*Math.PI)for(d=this.attributes.normal.array,e=new p,f=new p,g=new p,c=b*a.length*3,n=q=0;q<a.length;q++,n+=3)e.x=d[n+0],e.y=d[n+1],e.z=
15855 d[n+2],f.x=d[c+n+0],f.y=d[c+n+1],f.z=d[c+n+2],g.addVectors(e,f).normalize(),d[n+0]=d[c+n+0]=g.x,d[n+1]=d[c+n+1]=g.y,d[n+2]=d[c+n+2]=g.z}function tb(a,b){R.call(this);this.type="ShapeGeometry";"object"===typeof b&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),b=b.curveSegments);this.parameters={shapes:a,curveSegments:b};this.fromBufferGeometry(new ub(a,b));this.mergeVertices()}function ub(a,b){function c(a){var c,h=e.length/3;a=a.extractPoints(b);var m=a.shape,q=a.holes;
15856 if(!1===Va.isClockWise(m))for(m=m.reverse(),a=0,c=q.length;a<c;a++){var l=q[a];!0===Va.isClockWise(l)&&(q[a]=l.reverse())}var p=Va.triangulateShape(m,q);a=0;for(c=q.length;a<c;a++)l=q[a],m=m.concat(l);a=0;for(c=m.length;a<c;a++)l=m[a],e.push(l.x,l.y,0),f.push(0,0,1),g.push(l.x,l.y);a=0;for(c=p.length;a<c;a++)m=p[a],d.push(m[0]+h,m[1]+h,m[2]+h),k+=3}C.call(this);this.type="ShapeBufferGeometry";this.parameters={shapes:a,curveSegments:b};b=b||12;var d=[],e=[],f=[],g=[],h=0,k=0;if(!1===Array.isArray(a))c(a);
15857 else for(var m=0;m<a.length;m++)c(a[m]),this.addGroup(h,k,m),h+=k,k=0;this.setIndex(d);this.addAttribute("position",new A(e,3));this.addAttribute("normal",new A(f,3));this.addAttribute("uv",new A(g,2))}function jf(a,b){b.shapes=[];if(Array.isArray(a))for(var c=0,d=a.length;c<d;c++)b.shapes.push(a[c].uuid);else b.shapes.push(a.uuid);return b}function ac(a,b){C.call(this);this.type="EdgesGeometry";this.parameters={thresholdAngle:b};var c=[];b=Math.cos(H.DEG2RAD*(void 0!==b?b:1));var d=[0,0],e={},f=
15858 ["a","b","c"];if(a.isBufferGeometry){var g=new R;g.fromBufferGeometry(a)}else g=a.clone();g.mergeVertices();g.computeFaceNormals();a=g.vertices;g=g.faces;for(var h=0,k=g.length;h<k;h++)for(var m=g[h],q=0;3>q;q++){var n=m[f[q]];var l=m[f[(q+1)%3]];d[0]=Math.min(n,l);d[1]=Math.max(n,l);n=d[0]+","+d[1];void 0===e[n]?e[n]={index1:d[0],index2:d[1],face1:h,face2:void 0}:e[n].face2=h}for(n in e)if(d=e[n],void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=b)f=a[d.index1],c.push(f.x,f.y,f.z),f=a[d.index2],
15859 c.push(f.x,f.y,f.z);this.addAttribute("position",new A(c,3))}function vb(a,b,c,d,e,f,g,h){R.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new Wa(a,b,c,d,e,f,g,h));this.mergeVertices()}function Wa(a,b,c,d,e,f,g,h){function k(c){var e,f=new z,k=new p,t=0,v=!0===c?a:b,w=!0===c?1:-1;var A=r;for(e=1;e<=d;e++)n.push(0,y*w,0),l.push(0,w,0),u.push(.5,.5),r++;var C=
15860 r;for(e=0;e<=d;e++){var D=e/d*h+g,H=Math.cos(D);D=Math.sin(D);k.x=v*D;k.y=y*w;k.z=v*H;n.push(k.x,k.y,k.z);l.push(0,w,0);f.x=.5*H+.5;f.y=.5*D*w+.5;u.push(f.x,f.y);r++}for(e=0;e<d;e++)f=A+e,k=C+e,!0===c?q.push(k,k+1,f):q.push(k+1,k,f),t+=3;m.addGroup(x,t,!0===c?1:2);x+=t}C.call(this);this.type="CylinderBufferGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};var m=this;a=void 0!==a?a:1;b=void 0!==b?b:1;c=c||1;d=Math.floor(d)||
15861 8;e=Math.floor(e)||1;f=void 0!==f?f:!1;g=void 0!==g?g:0;h=void 0!==h?h:2*Math.PI;var q=[],n=[],l=[],u=[],r=0,v=[],y=c/2,x=0;(function(){var f,k,t=new p,P=new p,N=0,z=(b-a)/c;for(k=0;k<=e;k++){var A=[],D=k/e,C=D*(b-a)+a;for(f=0;f<=d;f++){var H=f/d,G=H*h+g,K=Math.sin(G);G=Math.cos(G);P.x=C*K;P.y=-D*c+y;P.z=C*G;n.push(P.x,P.y,P.z);t.set(K,z,G).normalize();l.push(t.x,t.y,t.z);u.push(H,1-D);A.push(r++)}v.push(A)}for(f=0;f<d;f++)for(k=0;k<e;k++)t=v[k+1][f],P=v[k+1][f+1],z=v[k][f+1],q.push(v[k][f],t,z),
15862 q.push(t,P,z),N+=6;m.addGroup(x,N,0);x+=N})();!1===f&&(0<a&&k(!0),0<b&&k(!1));this.setIndex(q);this.addAttribute("position",new A(n,3));this.addAttribute("normal",new A(l,3));this.addAttribute("uv",new A(u,2))}function Wc(a,b,c,d,e,f,g){vb.call(this,0,a,b,c,d,e,f,g);this.type="ConeGeometry";this.parameters={radius:a,height:b,radialSegments:c,heightSegments:d,openEnded:e,thetaStart:f,thetaLength:g}}function Xc(a,b,c,d,e,f,g){Wa.call(this,0,a,b,c,d,e,f,g);this.type="ConeBufferGeometry";this.parameters=
15863 {radius:a,height:b,radialSegments:c,heightSegments:d,openEnded:e,thetaStart:f,thetaLength:g}}function Yc(a,b,c,d){R.call(this);this.type="CircleGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};this.fromBufferGeometry(new bc(a,b,c,d));this.mergeVertices()}function bc(a,b,c,d){C.call(this);this.type="CircleBufferGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};a=a||1;b=void 0!==b?Math.max(3,b):8;c=void 0!==c?c:0;d=void 0!==d?d:2*Math.PI;var e=[],f=
15864 [],g=[],h=[],k,m=new p,q=new z;f.push(0,0,0);g.push(0,0,1);h.push(.5,.5);var n=0;for(k=3;n<=b;n++,k+=3){var l=c+n/b*d;m.x=a*Math.cos(l);m.y=a*Math.sin(l);f.push(m.x,m.y,m.z);g.push(0,0,1);q.x=(f[k]/a+1)/2;q.y=(f[k+1]/a+1)/2;h.push(q.x,q.y)}for(k=1;k<=b;k++)e.push(k,k+1,0);this.setIndex(e);this.addAttribute("position",new A(f,3));this.addAttribute("normal",new A(g,3));this.addAttribute("uv",new A(h,2))}function wb(a){J.call(this);this.type="ShadowMaterial";this.color=new G(0);this.transparent=!0;this.setValues(a)}
15865 function cc(a){ta.call(this,a);this.type="RawShaderMaterial"}function Pa(a){J.call(this);this.defines={STANDARD:""};this.type="MeshStandardMaterial";this.color=new G(16777215);this.metalness=this.roughness=.5;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new G(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new z(1,1);this.displacementMap=null;this.displacementScale=
15866 1;this.displacementBias=0;this.envMap=this.alphaMap=this.metalnessMap=this.roughnessMap=null;this.envMapIntensity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function xb(a){Pa.call(this);this.defines={PHYSICAL:""};this.type="MeshPhysicalMaterial";this.reflectivity=.5;this.clearCoatRoughness=this.clearCoat=0;this.setValues(a)}function Fa(a){J.call(this);
15867 this.type="MeshPhongMaterial";this.color=new G(16777215);this.specular=new G(1118481);this.shininess=30;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new G(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new z(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;
15868 this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function yb(a){Fa.call(this);this.defines={TOON:""};this.type="MeshToonMaterial";this.gradientMap=null;this.setValues(a)}function zb(a){J.call(this);this.type="MeshNormalMaterial";this.bumpMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new z(1,1);this.displacementMap=
15869 null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.morphNormals=this.morphTargets=this.skinning=this.lights=this.fog=!1;this.setValues(a)}function Ab(a){J.call(this);this.type="MeshLambertMaterial";this.color=new G(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new G(0);this.emissiveIntensity=1;this.envMap=this.alphaMap=this.specularMap=this.emissiveMap=null;this.combine=0;this.reflectivity=
15870 1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function Bb(a){Y.call(this);this.type="LineDashedMaterial";this.scale=1;this.dashSize=3;this.gapSize=1;this.setValues(a)}function ce(a,b,c){var d=this,e=!1,f=0,g=0,h=void 0;this.onStart=void 0;this.onLoad=a;this.onProgress=b;this.onError=c;this.itemStart=function(a){g++;if(!1===e&&void 0!==d.onStart)d.onStart(a,
15871 f,g);e=!0};this.itemEnd=function(a){f++;if(void 0!==d.onProgress)d.onProgress(a,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};this.itemError=function(a){if(void 0!==d.onError)d.onError(a)};this.resolveURL=function(a){return h?h(a):a};this.setURLModifier=function(a){h=a;return this}}function Ga(a){this.manager=void 0!==a?a:ka}function kf(a){this.manager=void 0!==a?a:ka;this._parser=null}function de(a){this.manager=void 0!==a?a:ka;this._parser=null}function Zc(a){this.manager=void 0!==a?a:ka}
15872 function ee(a){this.manager=void 0!==a?a:ka}function vd(a){this.manager=void 0!==a?a:ka}function L(){this.type="Curve";this.arcLengthDivisions=200}function za(a,b,c,d,e,f,g,h){L.call(this);this.type="EllipseCurve";this.aX=a||0;this.aY=b||0;this.xRadius=c||1;this.yRadius=d||1;this.aStartAngle=e||0;this.aEndAngle=f||2*Math.PI;this.aClockwise=g||!1;this.aRotation=h||0}function dc(a,b,c,d,e,f){za.call(this,a,b,c,c,d,e,f);this.type="ArcCurve"}function fe(){var a=0,b=0,c=0,d=0;return{initCatmullRom:function(e,
15873 f,g,h,k){e=k*(g-e);h=k*(h-f);a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},initNonuniformCatmullRom:function(e,f,g,h,k,m,q){e=((f-e)/k-(g-e)/(k+m)+(g-f)/m)*m;h=((g-f)/m-(h-f)/(m+q)+(h-g)/q)*m;a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},calc:function(e){var f=e*e;return a+b*e+c*f+d*f*e}}}function ca(a,b,c,d){L.call(this);this.type="CatmullRomCurve3";this.points=a||[];this.closed=b||!1;this.curveType=c||"centripetal";this.tension=d||.5}function lf(a,b,c,d,e){b=.5*(d-b);e=.5*(e-c);var f=a*a;return(2*c-2*d+b+e)*
15874 a*f+(-3*c+3*d-2*b-e)*f+b*a+c}function $c(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}function ad(a,b,c,d,e){var f=1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}function Ha(a,b,c,d){L.call(this);this.type="CubicBezierCurve";this.v0=a||new z;this.v1=b||new z;this.v2=c||new z;this.v3=d||new z}function Qa(a,b,c,d){L.call(this);this.type="CubicBezierCurve3";this.v0=a||new p;this.v1=b||new p;this.v2=c||new p;this.v3=d||new p}function va(a,b){L.call(this);this.type="LineCurve";this.v1=a||
15875 new z;this.v2=b||new z}function Ia(a,b){L.call(this);this.type="LineCurve3";this.v1=a||new p;this.v2=b||new p}function Ja(a,b,c){L.call(this);this.type="QuadraticBezierCurve";this.v0=a||new z;this.v1=b||new z;this.v2=c||new z}function Ra(a,b,c){L.call(this);this.type="QuadraticBezierCurve3";this.v0=a||new p;this.v1=b||new p;this.v2=c||new p}function Ka(a){L.call(this);this.type="SplineCurve";this.points=a||[]}function Xa(){L.call(this);this.type="CurvePath";this.curves=[];this.autoClose=!1}function La(a){Xa.call(this);
15876 this.type="Path";this.currentPoint=new z;a&&this.setFromPoints(a)}function db(a){La.call(this,a);this.uuid=H.generateUUID();this.type="Shape";this.holes=[]}function X(a,b){D.call(this);this.type="Light";this.color=new G(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0}function wd(a,b,c){X.call(this,a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.copy(D.DefaultUp);this.updateMatrix();this.groundColor=new G(b)}function Cb(a){this.camera=a;this.bias=0;this.radius=1;this.mapSize=
15877 new z(512,512);this.map=null;this.matrix=new I}function xd(){Cb.call(this,new Z(50,1,.5,500))}function yd(a,b,c,d,e,f){X.call(this,a,b);this.type="SpotLight";this.position.copy(D.DefaultUp);this.updateMatrix();this.target=new D;Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(a){this.intensity=a/Math.PI}});this.distance=void 0!==c?c:0;this.angle=void 0!==d?d:Math.PI/3;this.penumbra=void 0!==e?e:0;this.decay=void 0!==f?f:1;this.shadow=new xd}function zd(a,
15878 b,c,d){X.call(this,a,b);this.type="PointLight";Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(a){this.intensity=a/(4*Math.PI)}});this.distance=void 0!==c?c:0;this.decay=void 0!==d?d:1;this.shadow=new Cb(new Z(90,1,.5,500))}function Ad(){Cb.call(this,new Hb(-5,5,5,-5,.5,500))}function Bd(a,b){X.call(this,a,b);this.type="DirectionalLight";this.position.copy(D.DefaultUp);this.updateMatrix();this.target=new D;this.shadow=new Ad}function Cd(a,b){X.call(this,
15879 a,b);this.type="AmbientLight";this.castShadow=void 0}function Dd(a,b,c,d){X.call(this,a,b);this.type="RectAreaLight";this.width=void 0!==c?c:10;this.height=void 0!==d?d:10}function wa(a,b,c,d){this.parameterPositions=a;this._cachedIndex=0;this.resultBuffer=void 0!==d?d:new b.constructor(c);this.sampleValues=b;this.valueSize=c}function Ed(a,b,c,d){wa.call(this,a,b,c,d);this._offsetNext=this._weightNext=this._offsetPrev=this._weightPrev=-0}function bd(a,b,c,d){wa.call(this,a,b,c,d)}function Fd(a,b,
15880 c,d){wa.call(this,a,b,c,d)}function oa(a,b,c,d){if(void 0===a)throw Error("THREE.KeyframeTrack: track name is undefined");if(void 0===b||0===b.length)throw Error("THREE.KeyframeTrack: no keyframes in track named "+a);this.name=a;this.times=ia.convertArray(b,this.TimeBufferType);this.values=ia.convertArray(c,this.ValueBufferType);this.setInterpolation(d||this.DefaultInterpolation)}function Gd(a,b,c){oa.call(this,a,b,c)}function Hd(a,b,c,d){oa.call(this,a,b,c,d)}function ec(a,b,c,d){oa.call(this,a,
15881 b,c,d)}function Id(a,b,c,d){wa.call(this,a,b,c,d)}function cd(a,b,c,d){oa.call(this,a,b,c,d)}function Jd(a,b,c,d){oa.call(this,a,b,c,d)}function fc(a,b,c,d){oa.call(this,a,b,c,d)}function Ca(a,b,c){this.name=a;this.tracks=c;this.duration=void 0!==b?b:-1;this.uuid=H.generateUUID();0>this.duration&&this.resetDuration()}function Rg(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return ec;case "vector":case "vector2":case "vector3":case "vector4":return fc;
15882 case "color":return Hd;case "quaternion":return cd;case "bool":case "boolean":return Gd;case "string":return Jd}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+a);}function Sg(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var b=Rg(a.type);if(void 0===a.times){var c=[],d=[];ia.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,a.times,a.values,a.interpolation)}function Kd(a){this.manager=void 0!==
15883 a?a:ka;this.textures={}}function ge(a){this.manager=void 0!==a?a:ka}function gc(){}function he(a){"boolean"===typeof a&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),a=void 0);this.manager=void 0!==a?a:ka;this.withCredentials=!1}function mf(a){this.manager=void 0!==a?a:ka;this.texturePath=""}function ie(a){"undefined"===typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported.");"undefined"===typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported.");
15884 this.manager=void 0!==a?a:ka;this.options=void 0}function je(){this.type="ShapePath";this.color=new G;this.subPaths=[];this.currentPath=null}function ke(a){this.type="Font";this.data=a}function nf(a){this.manager=void 0!==a?a:ka}function le(a){this.manager=void 0!==a?a:ka}function of(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new Z;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new Z;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=
15885 !1}function dd(a,b,c){D.call(this);this.type="CubeCamera";var d=new Z(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new p(1,0,0));this.add(d);var e=new Z(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new p(-1,0,0));this.add(e);var f=new Z(90,1,a,b);f.up.set(0,0,1);f.lookAt(new p(0,1,0));this.add(f);var g=new Z(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new p(0,-1,0));this.add(g);var h=new Z(90,1,a,b);h.up.set(0,-1,0);h.lookAt(new p(0,0,1));this.add(h);var k=new Z(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new p(0,0,-1));this.add(k);
15886 this.renderTarget=new Gb(c,c,{format:1022,magFilter:1006,minFilter:1006});this.renderTarget.texture.name="CubeCamera";this.update=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=this.renderTarget,m=c.texture.generateMipmaps;c.texture.generateMipmaps=!1;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace=2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.texture.generateMipmaps=m;c.activeCubeFace=5;a.render(b,
15887 k,c);a.setRenderTarget(null)};this.clear=function(a,b,c,d){for(var e=this.renderTarget,f=0;6>f;f++)e.activeCubeFace=f,a.setRenderTarget(e),a.clear(b,c,d);a.setRenderTarget(null)}}function me(){D.call(this);this.type="AudioListener";this.context=ne.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null}function hc(a){D.call(this);this.type="Audio";this.context=a.context;this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=
15888 !1;this.buffer=null;this.loop=!1;this.offset=this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function oe(a){hc.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)}function pe(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)}function qe(a,b,c){this.binding=a;this.valueSize=
15889 c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function pf(a,b,c){c=c||pa.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)}function pa(a,b,c){this.path=b;this.parsedPath=c||pa.parseTrackName(b);this.node=pa.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function qf(){this.uuid=
15890 H.generateUUID();this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var a={};this._indicesByUUID=a;for(var b=0,c=arguments.length;b!==c;++b)a[arguments[b].uuid]=b;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var d=this;this.stats={objects:{get total(){return d._objects.length},get inUse(){return this.total-d.nCachedObjects_}},get bindingsPerObject(){return d._bindings.length}}}function rf(a,b,c){this._mixer=a;this._clip=b;this._localRoot=
15891 c||null;a=b.tracks;b=a.length;c=Array(b);for(var d={endingStart:2400,endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;
15892 this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function re(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Ld(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function se(){C.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function te(a,b,c){ob.call(this,a,b);this.meshPerAttribute=c||1}function ue(a,b,c){Q.call(this,
15893 a,b);this.meshPerAttribute=c||1}function sf(a,b,c,d){this.ray=new mb(a,b);this.near=c||0;this.far=d||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})}function tf(a,b){return a.distance-b.distance}function ve(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e=a.length;d<e;d++)ve(a[d],
15894 b,c,!0)}}function uf(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function vf(a,b,c){this.radius=void 0!==a?a:1;this.phi=void 0!==b?b:0;this.theta=void 0!==c?c:0;return this}function wf(a,b,c){this.radius=void 0!==a?a:1;this.theta=void 0!==b?b:0;this.y=void 0!==c?c:0;return this}function we(a,b){this.min=void 0!==a?a:new z(Infinity,Infinity);this.max=void 0!==b?b:new z(-Infinity,-Infinity)}function xe(a,b){this.start=void 0!==a?a:new p;this.end=
15895 void 0!==b?b:new p}function ed(a){D.call(this);this.material=a;this.render=function(){}}function fd(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16711680;d=void 0!==d?d:1;b=0;(c=this.object.geometry)&&c.isGeometry?b=3*c.faces.length:c&&c.isBufferGeometry&&(b=c.attributes.normal.count);c=new C;b=new A(6*b,3);c.addAttribute("position",b);W.call(this,c,new Y({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()}function ic(a,b){D.call(this);this.light=a;this.light.updateMatrixWorld();
15896 this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=b;a=new C;b=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(var c=0,d=1;32>c;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.addAttribute("position",new A(b,3));b=new Y({fog:!1});this.cone=new W(a,b);this.add(this.cone);this.update()}function xf(a){var b=[];a&&a.isBone&&b.push(a);for(var c=0;c<a.children.length;c++)b.push.apply(b,xf(a.children[c]));return b}
15897 function jc(a){for(var b=xf(a),c=new C,d=[],e=[],f=new G(0,0,1),g=new G(0,1,0),h=0;h<b.length;h++){var k=b[h];k.parent&&k.parent.isBone&&(d.push(0,0,0),d.push(0,0,0),e.push(f.r,f.g,f.b),e.push(g.r,g.g,g.b))}c.addAttribute("position",new A(d,3));c.addAttribute("color",new A(e,3));d=new Y({vertexColors:2,depthTest:!1,depthWrite:!1,transparent:!0});W.call(this,c,d);this.root=a;this.bones=b;this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1}function kc(a,b,c){this.light=a;this.light.updateMatrixWorld();
15898 this.color=c;a=new sb(b,4,2);b=new da({wireframe:!0,fog:!1});la.call(this,a,b);this.matrix=this.light.matrixWorld;this.matrixAutoUpdate=!1;this.update()}function lc(a,b){D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=b;a=new Y({fog:!1});b=new C;b.addAttribute("position",new Q(new Float32Array(15),3));this.line=new sa(b,a);this.add(this.line);this.update()}function mc(a,b,c){D.call(this);this.light=a;this.light.updateMatrixWorld();
15899 this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=c;a=new pb(b);a.rotateY(.5*Math.PI);this.material=new da({wireframe:!0,fog:!1});void 0===this.color&&(this.material.vertexColors=2);b=a.getAttribute("position");b=new Float32Array(3*b.count);a.addAttribute("color",new Q(b,3));this.add(new la(a,this.material));this.update()}function gd(a,b,c,d){a=a||10;b=b||10;c=new G(void 0!==c?c:4473924);d=new G(void 0!==d?d:8947848);var e=b/2,f=a/b,g=a/2;a=[];for(var h=[],k=0,m=0,q=-g;k<=b;k++,q+=f){a.push(-g,
15900 0,q,g,0,q);a.push(q,0,-g,q,0,g);var n=k===e?c:d;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3}b=new C;b.addAttribute("position",new A(a,3));b.addAttribute("color",new A(h,3));c=new Y({vertexColors:2});W.call(this,b,c)}function Md(a,b,c,d,e,f){a=a||10;b=b||16;c=c||8;d=d||64;e=new G(void 0!==e?e:4473924);f=new G(void 0!==f?f:8947848);var g=[],h=[],k;for(k=0;k<=b;k++){var m=k/b*2*Math.PI;var q=Math.sin(m)*a;m=Math.cos(m)*a;g.push(0,0,0);g.push(q,0,m);var n=k&1?e:f;h.push(n.r,
15901 n.g,n.b);h.push(n.r,n.g,n.b)}for(k=0;k<=c;k++){n=k&1?e:f;var l=a-a/c*k;for(b=0;b<d;b++)m=b/d*2*Math.PI,q=Math.sin(m)*l,m=Math.cos(m)*l,g.push(q,0,m),h.push(n.r,n.g,n.b),m=(b+1)/d*2*Math.PI,q=Math.sin(m)*l,m=Math.cos(m)*l,g.push(q,0,m),h.push(n.r,n.g,n.b)}a=new C;a.addAttribute("position",new A(g,3));a.addAttribute("color",new A(h,3));g=new Y({vertexColors:2});W.call(this,a,g)}function hd(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=0;(c=this.object.geometry)&&
15902 c.isGeometry?b=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");c=new C;b=new A(6*b,3);c.addAttribute("position",b);W.call(this,c,new Y({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()}function nc(a,b,c){D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=c;void 0===b&&(b=1);a=new C;a.addAttribute("position",new A([-b,b,0,b,b,0,b,-b,0,-b,
15903 -b,0,-b,b,0],3));b=new Y({fog:!1});this.lightPlane=new sa(a,b);this.add(this.lightPlane);a=new C;a.addAttribute("position",new A([0,0,0,0,0,1],3));this.targetLine=new sa(a,b);this.add(this.targetLine);this.update()}function id(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){f.push(0,0,0);g.push(b.r,b.g,b.b);void 0===h[a]&&(h[a]=[]);h[a].push(f.length/3-1)}var d=new C,e=new Y({color:16777215,vertexColors:1}),f=[],g=[],h={},k=new G(16755200),m=new G(16711680),q=new G(43775),n=new G(16777215),l=new G(3355443);
15904 b("n1","n2",k);b("n2","n4",k);b("n4","n3",k);b("n3","n1",k);b("f1","f2",k);b("f2","f4",k);b("f4","f3",k);b("f3","f1",k);b("n1","f1",k);b("n2","f2",k);b("n3","f3",k);b("n4","f4",k);b("p","n1",m);b("p","n2",m);b("p","n3",m);b("p","n4",m);b("u1","u2",q);b("u2","u3",q);b("u3","u1",q);b("c","t",n);b("p","c",l);b("cn1","cn2",l);b("cn3","cn4",l);b("cf1","cf2",l);b("cf3","cf4",l);d.addAttribute("position",new A(f,3));d.addAttribute("color",new A(g,3));W.call(this,d,e);this.camera=a;this.camera.updateProjectionMatrix&&
15905 this.camera.updateProjectionMatrix();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=h;this.update()}function Db(a,b){this.object=a;void 0===b&&(b=16776960);a=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);var c=new Float32Array(24),d=new C;d.setIndex(new Q(a,1));d.addAttribute("position",new Q(c,3));W.call(this,d,new Y({color:b}));this.matrixAutoUpdate=!1;this.update()}function jd(a,b){this.type="Box3Helper";this.box=a;a=void 0!==b?b:16776960;b=new Uint16Array([0,
15906 1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);var c=new C;c.setIndex(new Q(b,1));c.addAttribute("position",new A([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3));W.call(this,c,new Y({color:a}));this.geometry.computeBoundingSphere()}function kd(a,b,c){this.type="PlaneHelper";this.plane=a;this.size=void 0===b?1:b;a=void 0!==c?c:16776960;b=new C;b.addAttribute("position",new A([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3));b.computeBoundingSphere();sa.call(this,
15907 b,new Y({color:a}));b=new C;b.addAttribute("position",new A([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3));b.computeBoundingSphere();this.add(new la(b,new da({color:a,opacity:.2,transparent:!0,depthWrite:!1})))}function Eb(a,b,c,d,e,f){D.call(this);void 0===d&&(d=16776960);void 0===c&&(c=1);void 0===e&&(e=.2*c);void 0===f&&(f=.2*e);void 0===Nd&&(Nd=new C,Nd.addAttribute("position",new A([0,0,0,0,1,0],3)),ye=new Wa(0,.5,1,5,1),ye.translate(0,-.5,0));this.position.copy(b);this.line=new sa(Nd,new Y({color:d}));
15908 this.line.matrixAutoUpdate=!1;this.add(this.line);this.cone=new la(ye,new da({color:d}));this.cone.matrixAutoUpdate=!1;this.add(this.cone);this.setDirection(a);this.setLength(c,e,f)}function ld(a){a=a||1;var b=[0,0,0,a,0,0,0,0,0,0,a,0,0,0,0,0,0,a];a=new C;a.addAttribute("position",new A(b,3));a.addAttribute("color",new A([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));b=new Y({vertexColors:2});W.call(this,a,b)}function yf(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");
15909 ca.call(this,a);this.type="catmullrom";this.closed=!0}function zf(a){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");ca.call(this,a);this.type="catmullrom"}function ze(a){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.");ca.call(this,a);this.type="catmullrom"}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52));void 0===Number.isInteger&&(Number.isInteger=function(a){return"number"===typeof a&&isFinite(a)&&Math.floor(a)===
15910 a});void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0<a?1:+a});!1==="name"in Function.prototype&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}});void 0===Object.assign&&function(){Object.assign=function(a){if(void 0===a||null===a)throw new TypeError("Cannot convert undefined or null to object");for(var b=Object(a),c=1;c<arguments.length;c++){var d=arguments[c];if(void 0!==d&&null!==d)for(var e in d)Object.prototype.hasOwnProperty.call(d,
15911 e)&&(b[e]=d[e])}return b}}();Object.assign(ya.prototype,{addEventListener:function(a,b){void 0===this._listeners&&(this._listeners={});var c=this._listeners;void 0===c[a]&&(c[a]=[]);-1===c[a].indexOf(b)&&c[a].push(b)},hasEventListener:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;return void 0!==c[a]&&-1!==c[a].indexOf(b)},removeEventListener:function(a,b){void 0!==this._listeners&&(a=this._listeners[a],void 0!==a&&(b=a.indexOf(b),-1!==b&&a.splice(b,1)))},dispatchEvent:function(a){if(void 0!==
15912 this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;b=b.slice(0);for(var c=0,d=b.length;c<d;c++)b[c].call(this,a)}}}});var H={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){for(var a=[],b=0;256>b;b++)a[b]=(16>b?"0":"")+b.toString(16);return function(){var b=4294967295*Math.random()|0,d=4294967295*Math.random()|0,e=4294967295*Math.random()|0,f=4294967295*Math.random()|0;return(a[b&255]+a[b>>8&255]+a[b>>16&255]+a[b>>24&255]+"-"+a[d&255]+a[d>>8&255]+"-"+a[d>>
15913 16&15|64]+a[d>>24&255]+"-"+a[e&63|128]+a[e>>8&255]+"-"+a[e>>16&255]+a[e>>24&255]+a[f&255]+a[f>>8&255]+a[f>>16&255]+a[f>>24&255]).toUpperCase()}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;
15914 a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a*H.DEG2RAD},radToDeg:function(a){return a*H.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},ceilPowerOfTwo:function(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))},floorPowerOfTwo:function(a){return Math.pow(2,Math.floor(Math.log(a)/
15915 Math.LN2))}};Object.defineProperties(z.prototype,{width:{get:function(){return this.x},set:function(a){this.x=a}},height:{get:function(){return this.y},set:function(a){this.y=a}}});Object.assign(z.prototype,{isVector2:!0,set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+
15916 a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},
15917 addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=
15918 a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},applyMatrix3:function(a){var b=this.x,c=this.y;a=a.elements;this.x=a[0]*b+a[3]*c+a[6];this.y=a[1]*b+a[4]*c+a[7];return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,
15919 b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a=new z,b=new z;return function(c,d){a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=
15920 Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},cross:function(a){return this.x*a.y-this.y*a.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+
15921 Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=
15922 (a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);
15923 return this},rotateAround:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=this.x-a.x,e=this.y-a.y;this.x=d*c-e*b+a.x;this.y=d*b+e*c+a.y;return this}});Object.assign(I.prototype,{isMatrix4:!0,set:function(a,b,c,d,e,f,g,h,k,m,q,n,l,u,r,p){var t=this.elements;t[0]=a;t[4]=b;t[8]=c;t[12]=d;t[1]=e;t[5]=f;t[9]=g;t[13]=h;t[2]=k;t[6]=m;t[10]=q;t[14]=n;t[3]=l;t[7]=u;t[11]=r;t[15]=p;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new I).fromArray(this.elements)},
15924 copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return this},copyPosition:function(a){var b=this.elements;a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x,
15925 b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a=new p;return function(b){var c=this.elements,d=b.elements,e=1/a.setFromMatrixColumn(b,0).length(),f=1/a.setFromMatrixColumn(b,1).length();b=1/a.setFromMatrixColumn(b,2).length();c[0]=d[0]*e;c[1]=d[1]*e;c[2]=d[2]*e;c[3]=0;c[4]=d[4]*f;c[5]=d[5]*f;c[6]=d[6]*f;c[7]=0;c[8]=d[8]*b;c[9]=d[9]*b;c[10]=d[10]*b;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return this}}(),makeRotationFromEuler:function(a){a&&a.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
15926 var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=Math.cos(e);e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,m=c*h,q=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=k+m*d;b[5]=a-q*d;b[9]=-c*g;b[2]=q-a*d;b[6]=m+k*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,k=g*e,m=d*h,q=d*e,b[0]=a+q*c,b[4]=m*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-m,b[6]=q+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,m=d*h,q=d*e,b[0]=a-q*c,b[4]=-f*e,b[8]=m+k*c,b[1]=k+m*c,b[5]=f*h,b[9]=
15927 q-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,m=c*h,q=c*e,b[0]=g*h,b[4]=m*d-k,b[8]=a*d+q,b[1]=g*e,b[5]=q*d+a,b[9]=k*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,m=c*g,q=c*d,b[0]=g*h,b[4]=q-a*e,b[8]=m*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+m,b[10]=a-q*e):"XZY"===a.order&&(a=f*g,k=f*d,m=c*g,q=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+q,b[5]=f*h,b[9]=k*e-m,b[2]=m*e-k,b[6]=c*h,b[10]=q*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(){var a=
15928 new p(0,0,0),b=new p(1,1,1);return function(c){return this.compose(a,c,b)}}(),lookAt:function(){var a=new p,b=new p,c=new p;return function(d,e,f){var g=this.elements;c.subVectors(d,e);0===c.lengthSq()&&(c.z=1);c.normalize();a.crossVectors(f,c);0===a.lengthSq()&&(1===Math.abs(f.z)?c.x+=1E-4:c.z+=1E-4,c.normalize(),a.crossVectors(f,c));a.normalize();b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==
15929 b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[4],f=c[8],g=c[12],h=c[1],k=c[5],m=c[9],q=c[13],n=c[2],l=c[6],u=c[10],r=c[14],p=c[3],y=c[7],x=c[11];c=c[15];var w=d[0],B=d[4],E=d[8],P=d[12],N=d[1],z=d[5],A=d[9],D=d[13],C=d[2],
15930 H=d[6],G=d[10],K=d[14],L=d[3],I=d[7],J=d[11];d=d[15];b[0]=a*w+e*N+f*C+g*L;b[4]=a*B+e*z+f*H+g*I;b[8]=a*E+e*A+f*G+g*J;b[12]=a*P+e*D+f*K+g*d;b[1]=h*w+k*N+m*C+q*L;b[5]=h*B+k*z+m*H+q*I;b[9]=h*E+k*A+m*G+q*J;b[13]=h*P+k*D+m*K+q*d;b[2]=n*w+l*N+u*C+r*L;b[6]=n*B+l*z+u*H+r*I;b[10]=n*E+l*A+u*G+r*J;b[14]=n*P+l*D+u*K+r*d;b[3]=p*w+y*N+x*C+c*L;b[7]=p*B+y*z+x*H+c*I;b[11]=p*E+y*A+x*G+c*J;b[15]=p*P+y*D+x*K+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=
15931 a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToBufferAttribute:function(){var a=new p;return function(b){for(var c=0,d=b.count;c<d;c++)a.x=b.getX(c),a.y=b.getY(c),a.z=b.getZ(c),a.applyMatrix4(this),b.setXYZ(c,a.x,a.y,a.z);return b}}(),determinant:function(){var a=this.elements,b=a[0],c=a[4],d=a[8],e=a[12],f=a[1],g=a[5],h=a[9],k=a[13],m=a[2],q=a[6],n=a[10],l=a[14];return a[3]*(+e*h*q-d*k*q-e*g*n+c*k*n+d*g*l-c*h*l)+a[7]*(+b*h*l-b*k*n+e*f*n-
15932 d*f*l+d*k*m-e*h*m)+a[11]*(+b*k*q-b*g*l-e*f*q+c*f*l+e*g*m-c*k*m)+a[15]*(-d*g*m-b*h*q+b*g*n+d*f*q-c*f*n+c*h*m)},transpose:function(){var a=this.elements;var b=a[1];a[1]=a[4];a[4]=b;b=a[2];a[2]=a[8];a[8]=b;b=a[6];a[6]=a[9];a[9]=b;b=a[3];a[3]=a[12];a[12]=b;b=a[7];a[7]=a[13];a[13]=b;b=a[11];a[11]=a[14];a[14]=b;return this},setPosition:function(a){var b=this.elements;b[12]=a.x;b[13]=a.y;b[14]=a.z;return this},getInverse:function(a,b){var c=this.elements,d=a.elements;a=d[0];var e=d[1],f=d[2],g=d[3],h=d[4],
15933 k=d[5],m=d[6],q=d[7],n=d[8],l=d[9],u=d[10],r=d[11],p=d[12],y=d[13],x=d[14];d=d[15];var w=l*x*q-y*u*q+y*m*r-k*x*r-l*m*d+k*u*d,B=p*u*q-n*x*q-p*m*r+h*x*r+n*m*d-h*u*d,E=n*y*q-p*l*q+p*k*r-h*y*r-n*k*d+h*l*d,z=p*l*m-n*y*m-p*k*u+h*y*u+n*k*x-h*l*x,N=a*w+e*B+f*E+g*z;if(0===N){if(!0===b)throw Error("THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0");console.warn("THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0");return this.identity()}b=1/N;c[0]=w*b;c[1]=(y*u*g-l*x*g-y*f*
15934 r+e*x*r+l*f*d-e*u*d)*b;c[2]=(k*x*g-y*m*g+y*f*q-e*x*q-k*f*d+e*m*d)*b;c[3]=(l*m*g-k*u*g-l*f*q+e*u*q+k*f*r-e*m*r)*b;c[4]=B*b;c[5]=(n*x*g-p*u*g+p*f*r-a*x*r-n*f*d+a*u*d)*b;c[6]=(p*m*g-h*x*g-p*f*q+a*x*q+h*f*d-a*m*d)*b;c[7]=(h*u*g-n*m*g+n*f*q-a*u*q-h*f*r+a*m*r)*b;c[8]=E*b;c[9]=(p*l*g-n*y*g-p*e*r+a*y*r+n*e*d-a*l*d)*b;c[10]=(h*y*g-p*k*g+p*e*q-a*y*q-h*e*d+a*k*d)*b;c[11]=(n*k*g-h*l*g-n*e*q+a*l*q+h*e*r-a*k*r)*b;c[12]=z*b;c[13]=(n*y*f-p*l*f+p*e*u-a*y*u-n*e*x+a*l*x)*b;c[14]=(p*k*f-h*y*f-p*e*m+a*y*m+h*e*x-a*k*x)*
15935 b;c[15]=(h*l*f-n*k*f+n*e*m-a*l*m-h*e*u+a*k*u)*b;return this},scale:function(a){var b=this.elements,c=a.x,d=a.y;a=a.z;b[0]*=c;b[4]*=d;b[8]*=a;b[1]*=c;b[5]*=d;b[9]*=a;b[2]*=c;b[6]*=d;b[10]*=a;b[3]*=c;b[7]*=d;b[11]*=a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10]))},makeTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},makeRotationX:function(a){var b=
15936 Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},makeRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},makeRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},makeRotationAxis:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=1-c,e=a.x,f=a.y;a=a.z;var g=d*e,h=d*f;this.set(g*e+c,g*f-b*a,g*a+b*f,0,g*f+b*a,h*f+c,h*a-b*e,0,g*a-b*f,h*a+b*e,d*a*a+c,0,0,
15937 0,0,1);return this},makeScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},makeShear:function(a,b,c){this.set(1,b,c,0,a,1,c,0,a,b,1,0,0,0,0,1);return this},compose:function(a,b,c){var d=this.elements,e=b._x,f=b._y,g=b._z,h=b._w,k=e+e,m=f+f,q=g+g;b=e*k;var l=e*m;e*=q;var t=f*m;f*=q;g*=q;k*=h;m*=h;h*=q;q=c.x;var u=c.y;c=c.z;d[0]=(1-(t+g))*q;d[1]=(l+h)*q;d[2]=(e-m)*q;d[3]=0;d[4]=(l-h)*u;d[5]=(1-(b+g))*u;d[6]=(f+k)*u;d[7]=0;d[8]=(e+m)*c;d[9]=(f-k)*c;d[10]=(1-(b+t))*c;d[11]=0;
15938 d[12]=a.x;d[13]=a.y;d[14]=a.z;d[15]=1;return this},decompose:function(){var a=new p,b=new I;return function(c,d,e){var f=this.elements,g=a.set(f[0],f[1],f[2]).length(),h=a.set(f[4],f[5],f[6]).length(),k=a.set(f[8],f[9],f[10]).length();0>this.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.copy(this);c=1/g;f=1/h;var m=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=m;b.elements[9]*=m;b.elements[10]*=m;d.setFromRotationMatrix(b);
15939 e.x=g;e.y=h;e.z=k;return this}}(),makePerspective:function(a,b,c,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(c-d);g[9]=(c+d)/(c-d);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),k=1/(c-d),m=1/(f-e);g[0]=
15940 2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((c+d)*k);g[2]=0;g[6]=0;g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];
15941 a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}});Object.assign(fa,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var q=e[f+1],l=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==q||m!==l){f=1-g;var t=h*d+k*q+m*l+c*e,u=0<=t?1:-1,r=1-t*t;r>Number.EPSILON&&(r=Math.sqrt(r),t=Math.atan2(r,t*u),f=Math.sin(f*t)/r,g=Math.sin(g*
15942 t)/r);u*=g;h=h*f+d*u;k=k*f+q*u;m=m*f+l*u;c=c*f+e*u;f===1-g&&(g=1/Math.sqrt(h*h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c}});Object.defineProperties(fa.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this.onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this.onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this.onChangeCallback()}},w:{get:function(){return this._w},set:function(a){this._w=
15943 a;this.onChangeCallback()}}});Object.assign(fa.prototype,{set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!a||!a.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=
15944 a._x,d=a._y,e=a._z;a=a.order;var f=Math.cos,g=Math.sin,h=f(c/2),k=f(d/2);f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);"XYZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"YXZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"ZXY"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"ZYX"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"YZX"===a?(this._x=c*k*f+
15945 h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f-c*d*e):"XZY"===a&&(this._x=c*k*f-h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f+c*d*e);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){b/=2;var c=Math.sin(b);this._x=a.x*c;this._y=a.y*c;this._z=a.z*c;this._w=Math.cos(b);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6];b=b[10];var m=c+f+b;0<m?(c=.5/
15946 Math.sqrt(m+1),this._w=.25/c,this._x=(k-g)*c,this._y=(d-h)*c,this._z=(e-a)*c):c>f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a=new p,b;return function(c,d){void 0===a&&(a=new p);b=c.dot(d)+1;1E-6>b?(b=0,
15947 Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;return this.normalize()}}(),angleTo:function(a){return 2*Math.acos(Math.abs(H.clamp(this.dot(a),-1,1)))},rotateTowards:function(a,b){var c=this.angleTo(a);if(0===c)return this;this.slerp(a,Math.min(1,b/c));return this},inverse:function(){return this.conjugate()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*
15948 a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),
15949 this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z;a=a._w;var f=b._x,g=b._y,h=b._z;b=b._w;this._x=c*b+a*f+d*h-e*g;this._y=d*b+a*g+e*f-c*h;this._z=e*b+a*h+c*g-d*f;this._w=a*b-c*f-d*g-e*h;this.onChangeCallback();return this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;
15950 0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;a=1-g*g;if(a<=Number.EPSILON)return g=1-b,this._w=g*f+b*this._w,this._x=g*c+b*this._x,this._y=g*d+b*this._y,this._z=g*e+b*this._z,this.normalize();a=Math.sqrt(a);var h=Math.atan2(a,g);g=Math.sin((1-b)*h)/a;b=Math.sin(b*h)/a;this._w=f*g+this._w*b;this._x=c*g+this._x*b;this._y=d*g+this._y*b;this._z=e*g+this._z*b;this.onChangeCallback();return this},equals:function(a){return a._x===
15951 this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}});Object.assign(p.prototype,{isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},
15952 setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,
15953 this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=
15954 a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),
15955 this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a=new fa;return function(b){b&&b.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(a.setFromEuler(b))}}(),applyAxisAngle:function(){var a=new fa;return function(b,
15956 c){return this.applyQuaternion(a.setFromAxisAngle(b,c))}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,
15957 c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,m=a*d+e*c-f*b;b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-m*-f;this.y=k*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-k*-e;return this},project:function(){var a=new I;return function(b){a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld));return this.applyMatrix4(a)}}(),unproject:function(){var a=new I;return function(b){a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix));return this.applyMatrix4(a)}}(),transformDirection:function(a){var b=
15958 this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,
15959 b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a=new p,b=new p;return function(c,d){a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=
15960 Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*
15961 a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,
15962 b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){return void 0!==b?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b)):this.crossVectors(this,a)},crossVectors:function(a,b){var c=a.x,d=a.y;a=a.z;var e=b.x,f=b.y;b=b.z;this.x=d*b-a*f;this.y=a*e-c*b;this.z=c*f-d*e;return this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(){var a=
15963 new p;return function(b){a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a=new p;return function(b){return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(H.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-
15964 a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-a.z)},setFromSpherical:function(a){var b=Math.sin(a.phi)*a.radius;this.x=b*Math.sin(a.theta);this.y=Math.cos(a.phi)*a.radius;this.z=b*Math.cos(a.theta);return this},setFromCylindrical:function(a){this.x=a.radius*Math.sin(a.theta);this.y=a.y;this.z=a.radius*Math.cos(a.theta);return this},setFromMatrixPosition:function(a){a=a.elements;this.x=a[12];this.y=a[13];this.z=a[14];return this},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),
15965 c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromBufferAttribute:function(a,b,c){void 0!==
15966 c&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);return this}});Object.assign(ra.prototype,{isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,k){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]=f;m[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){var b=this.elements;a=a.elements;
15967 b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this},applyToBufferAttribute:function(){var a=new p;return function(b){for(var c=0,d=b.count;c<d;c++)a.x=b.getX(c),a.y=b.getY(c),a.z=b.getZ(c),a.applyMatrix3(this),b.setXYZ(c,a.x,a.y,a.z);return b}}(),multiply:function(a){return this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,
15968 this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[3],f=c[6],g=c[1],h=c[4],k=c[7],m=c[2],q=c[5];c=c[8];var l=d[0],t=d[3],u=d[6],r=d[1],p=d[4],y=d[7],x=d[2],w=d[5];d=d[8];b[0]=a*l+e*r+f*x;b[3]=a*t+e*p+f*w;b[6]=a*u+e*y+f*d;b[1]=g*l+h*r+k*x;b[4]=g*t+h*p+k*w;b[7]=g*u+h*y+k*d;b[2]=m*l+q*r+c*x;b[5]=m*t+q*p+c*w;b[8]=m*u+q*y+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[3]*=a;b[6]*=a;b[1]*=a;b[4]*=a;b[7]*=a;b[2]*=a;b[5]*=a;b[8]*=
15969 a;return this},determinant:function(){var a=this.elements,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],k=a[7];a=a[8];return b*f*a-b*g*k-c*e*a+c*g*h+d*e*k-d*f*h},getInverse:function(a,b){a&&a.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var c=a.elements;a=this.elements;var d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],k=c[5],m=c[6],q=c[7];c=c[8];var l=c*h-k*q,t=k*m-c*g,u=q*g-h*m,r=d*l+e*t+f*u;if(0===r){if(!0===b)throw Error("THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0");
15970 console.warn("THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0");return this.identity()}b=1/r;a[0]=l*b;a[1]=(f*q-c*e)*b;a[2]=(k*e-f*h)*b;a[3]=t*b;a[4]=(c*d-f*m)*b;a[5]=(f*g-k*d)*b;a[6]=u*b;a[7]=(e*m-q*d)*b;a[8]=(h*d-e*g)*b;return this},transpose:function(){var a=this.elements;var b=a[1];a[1]=a[3];a[3]=b;b=a[2];a[2]=a[6];a[6]=b;b=a[5];a[5]=a[7];a[7]=b;return this},getNormalMatrix:function(a){return this.setFromMatrix4(a).getInverse(this).transpose()},transposeIntoArray:function(a){var b=
15971 this.elements;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this},setUvTransform:function(a,b,c,d,e,f,g){var h=Math.cos(e);e=Math.sin(e);this.set(c*h,c*e,-c*(h*f+e*g)+f+a,-d*e,d*h,-d*(-e*f+h*g)+g+b,0,0,1)},scale:function(a,b){var c=this.elements;c[0]*=a;c[3]*=a;c[6]*=a;c[1]*=b;c[4]*=b;c[7]*=b;return this},rotate:function(a){var b=Math.cos(a);a=Math.sin(a);var c=this.elements,d=c[0],e=c[3],f=c[6],g=c[1],h=c[4],k=c[7];c[0]=b*d+a*g;c[3]=b*e+a*h;c[6]=
15972 b*f+a*k;c[1]=-a*d+b*g;c[4]=-a*e+b*h;c[7]=-a*f+b*k;return this},translate:function(a,b){var c=this.elements;c[0]+=a*c[2];c[3]+=a*c[5];c[6]+=a*c[8];c[1]+=b*c[2];c[4]+=b*c[5];c[7]+=b*c[8];return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;9>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;9>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];
15973 a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}});var eb={getDataURL:function(a){if(a instanceof HTMLCanvasElement)var b=a;else{"undefined"!==typeof OffscreenCanvas?b=new OffscreenCanvas(a.width,a.height):(b=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),b.width=a.width,b.height=a.height);var c=b.getContext("2d");a instanceof ImageData?c.putImageData(a,0,0):c.drawImage(a,0,0,a.width,a.height)}return 2048<b.width||2048<b.height?b.toDataURL("image/jpeg",
15974 .6):b.toDataURL("image/png")}},Ef=0;T.DEFAULT_IMAGE=void 0;T.DEFAULT_MAPPING=300;T.prototype=Object.assign(Object.create(ya.prototype),{constructor:T,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.name=a.name;this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=
15975 a.wrapT;this.magFilter=a.magFilter;this.minFilter=a.minFilter;this.anisotropy=a.anisotropy;this.format=a.format;this.type=a.type;this.offset.copy(a.offset);this.repeat.copy(a.repeat);this.center.copy(a.center);this.rotation=a.rotation;this.matrixAutoUpdate=a.matrixAutoUpdate;this.matrix.copy(a.matrix);this.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;this.encoding=a.encoding;return this},toJSON:function(a){var b=
15976 void 0===a||"string"===typeof a;if(!b&&void 0!==a.textures[this.uuid])return a.textures[this.uuid];var c={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==
15977 this.image){var d=this.image;void 0===d.uuid&&(d.uuid=H.generateUUID());if(!b&&void 0===a.images[d.uuid]){if(Array.isArray(d)){var e=[];for(var f=0,g=d.length;f<g;f++)e.push(eb.getDataURL(d[f]))}else e=eb.getDataURL(d);a.images[d.uuid]={uuid:d.uuid,url:e}}c.image=d.uuid}b||(a.textures[this.uuid]=c);return c},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(a){if(300===this.mapping){a.applyMatrix3(this.matrix);if(0>a.x||1<a.x)switch(this.wrapS){case 1E3:a.x-=Math.floor(a.x);
15978 break;case 1001:a.x=0>a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0>a.y||1<a.y)switch(this.wrapT){case 1E3:a.y-=Math.floor(a.y);break;case 1001:a.y=0>a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}});Object.defineProperty(T.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(V.prototype,{isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=
15979 b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;
15980 case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=
15981 a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=
15982 a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/
15983 a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){a=a.elements;var b=a[0];var c=a[4];var d=a[8],e=a[1],f=a[5],g=a[9];var h=a[2];var k=a[6];var m=a[10];if(.01>Math.abs(c-e)&&.01>Math.abs(d-h)&&.01>Math.abs(g-k)){if(.1>Math.abs(c+e)&&.1>Math.abs(d+h)&&.1>Math.abs(g+k)&&.1>Math.abs(b+f+m-3))return this.set(1,0,0,0),this;a=Math.PI;
15984 b=(b+1)/2;f=(f+1)/2;m=(m+1)/2;c=(c+e)/4;d=(d+h)/4;g=(g+k)/4;b>f&&b>m?.01>b?(k=0,c=h=.707106781):(k=Math.sqrt(b),h=c/k,c=d/k):f>m?.01>f?(k=.707106781,h=0,c=.707106781):(h=Math.sqrt(f),k=c/h,c=g/h):.01>m?(h=k=.707106781,c=0):(c=Math.sqrt(m),k=d/c,h=g/c);this.set(k,h,c,a);return this}a=Math.sqrt((k-g)*(k-g)+(d-h)*(d-h)+(e-c)*(e-c));.001>Math.abs(a)&&(a=1);this.x=(k-g)/a;this.y=(d-h)/a;this.z=(e-c)/a;this.w=Math.acos((b+f+m-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,
15985 a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new V,b=new V);a.set(c,
15986 c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);
15987 this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*
15988 this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,
15989 b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");
15990 this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);this.w=a.getW(b);return this}});fb.prototype=Object.assign(Object.create(ya.prototype),{constructor:fb,isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();
15991 this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Gb.prototype=Object.create(fb.prototype);Gb.prototype.constructor=Gb;Gb.prototype.isWebGLRenderTargetCube=!0;gb.prototype=Object.create(T.prototype);gb.prototype.constructor=gb;gb.prototype.isDataTexture=!0;Object.assign(Sa.prototype,{isBox3:!0,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromArray:function(a){for(var b=
15992 Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.length;h<k;h+=3){var m=a[h],q=a[h+1],l=a[h+2];m<b&&(b=m);q<c&&(c=q);l<d&&(d=l);m>e&&(e=m);q>f&&(f=q);l>g&&(g=l)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromBufferAttribute:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.count;h<k;h++){var m=a.getX(h),l=a.getY(h),n=a.getZ(h);m<b&&(b=m);l<c&&(c=l);n<d&&(d=n);m>e&&(e=m);l>f&&(f=l);n>g&&(g=n)}this.min.set(b,c,d);
15993 this.max.set(e,f,g);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(){var a=new p;return function(b,c){c=a.copy(c).multiplyScalar(.5);this.min.copy(b).sub(c);this.max.copy(b).add(c);return this}}(),setFromObject:function(a){this.makeEmpty();return this.expandByObject(a)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},
15994 makeEmpty:function(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(a){void 0===a&&(console.warn("THREE.Box3: .getCenter() target is now required"),a=new p);return this.isEmpty()?a.set(0,0,0):a.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(a){void 0===a&&(console.warn("THREE.Box3: .getSize() target is now required"),
15995 a=new p);return this.isEmpty()?a.set(0,0,0):a.subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);this.max.addScalar(a);return this},expandByObject:function(){function a(a){var f=a.geometry;if(void 0!==f)if(f.isGeometry)for(f=f.vertices,c=0,d=f.length;c<d;c++)e.copy(f[c]),e.applyMatrix4(a.matrixWorld),b.expandByPoint(e);else if(f.isBufferGeometry&&
15996 (f=f.attributes.position,void 0!==f))for(c=0,d=f.count;c<d;c++)e.fromBufferAttribute(f,c).applyMatrix4(a.matrixWorld),b.expandByPoint(e)}var b,c,d,e=new p;return function(c){b=this;c.updateMatrixWorld(!0);c.traverse(a);return this}}(),containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y||a.z<this.min.z||a.z>this.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&
15997 a.max.z<=this.max.z},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box3: .getParameter() target is now required"),b=new p);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y||a.max.z<this.min.z||a.min.z>this.max.z?!1:!0},intersectsSphere:function(){var a=new p;return function(b){this.clampPoint(b.center,
15998 a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){if(0<a.normal.x){var b=a.normal.x*this.min.x;var c=a.normal.x*this.max.x}else b=a.normal.x*this.max.x,c=a.normal.x*this.min.x;0<a.normal.y?(b+=a.normal.y*this.min.y,c+=a.normal.y*this.max.y):(b+=a.normal.y*this.max.y,c+=a.normal.y*this.min.y);0<a.normal.z?(b+=a.normal.z*this.min.z,c+=a.normal.z*this.max.z):(b+=a.normal.z*this.max.z,c+=a.normal.z*this.min.z);return b<=a.constant&&c>=a.constant},intersectsTriangle:function(){function a(a){var e;
15999 var f=0;for(e=a.length-3;f<=e;f+=3){h.fromArray(a,f);var g=m.x*Math.abs(h.x)+m.y*Math.abs(h.y)+m.z*Math.abs(h.z),k=b.dot(h),l=c.dot(h),q=d.dot(h);if(Math.max(-Math.max(k,l,q),Math.min(k,l,q))>g)return!1}return!0}var b=new p,c=new p,d=new p,e=new p,f=new p,g=new p,h=new p,k=new p,m=new p,l=new p;return function(h){if(this.isEmpty())return!1;this.getCenter(k);m.subVectors(this.max,k);b.subVectors(h.a,k);c.subVectors(h.b,k);d.subVectors(h.c,k);e.subVectors(c,b);f.subVectors(d,c);g.subVectors(b,d);h=
16000 [0,-e.z,e.y,0,-f.z,f.y,0,-g.z,g.y,e.z,0,-e.x,f.z,0,-f.x,g.z,0,-g.x,-e.y,e.x,0,-f.y,f.x,0,-g.y,g.x,0];if(!a(h))return!1;h=[1,0,0,0,1,0,0,0,1];if(!a(h))return!1;l.crossVectors(e,f);h=[l.x,l.y,l.z];return a(h)}}(),clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box3: .clampPoint() target is now required"),b=new p);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new p;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=
16001 new p;return function(b){void 0===b&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),b=new Da);this.getCenter(b.center);b.radius=.5*this.getSize(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(a){if(this.isEmpty())return this;a=a.elements;var b=a[0]*this.min.x,c=a[1]*this.min.x,d=a[2]*this.min.x,e=
16002 a[0]*this.max.x,f=a[1]*this.max.x,g=a[2]*this.max.x,h=a[4]*this.min.y,k=a[5]*this.min.y,m=a[6]*this.min.y,l=a[4]*this.max.y,n=a[5]*this.max.y,t=a[6]*this.max.y,u=a[8]*this.min.z,r=a[9]*this.min.z,p=a[10]*this.min.z,y=a[8]*this.max.z,x=a[9]*this.max.z,w=a[10]*this.max.z;this.min.x=Math.min(b,e)+Math.min(h,l)+Math.min(u,y)+a[12];this.min.y=Math.min(c,f)+Math.min(k,n)+Math.min(r,x)+a[13];this.min.z=Math.min(d,g)+Math.min(m,t)+Math.min(p,w)+a[14];this.max.x=Math.max(b,e)+Math.max(h,l)+Math.max(u,y)+a[12];
16003 this.max.y=Math.max(c,f)+Math.max(k,n)+Math.max(r,x)+a[13];this.max.z=Math.max(d,g)+Math.max(m,t)+Math.max(p,w)+a[14];return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});Object.assign(Da.prototype,{set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new Sa;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).getCenter(d);for(var e=
16004 c=0,f=b.length;e<f;e++)c=Math.max(c,d.distanceToSquared(b[e]));this.radius=Math.sqrt(c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.center.copy(a.center);this.radius=a.radius;return this},empty:function(){return 0>=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;
16005 return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(a.distanceToPoint(this.center))<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a);void 0===b&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),b=new p);b.copy(a);c>this.radius*this.radius&&(b.sub(this.center).normalize(),b.multiplyScalar(this.radius).add(this.center));return b},getBoundingBox:function(a){void 0===
16006 a&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),a=new Sa);a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}});Object.assign(Ma.prototype,{set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,
16007 b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new p,b=new p;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=
16008 1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){void 0===b&&(console.warn("THREE.Plane: .projectPoint() target is now required"),b=new p);return b.copy(this.normal).multiplyScalar(-this.distanceToPoint(a)).add(a)},intersectLine:function(){var a=
16009 new p;return function(b,c){void 0===c&&(console.warn("THREE.Plane: .intersectLine() target is now required"),c=new p);var d=b.delta(a),e=this.normal.dot(d);if(0===e){if(0===this.distanceToPoint(b.start))return c.copy(b.start)}else if(e=-(b.start.dot(this.normal)+this.constant)/e,!(0>e||1<e))return c.copy(d).multiplyScalar(e).add(b.start)}}(),intersectsLine:function(a){var b=this.distanceToPoint(a.start);a=this.distanceToPoint(a.end);return 0>b&&0<a||0>a&&0<b},intersectsBox:function(a){return a.intersectsPlane(this)},
16010 intersectsSphere:function(a){return a.intersectsPlane(this)},coplanarPoint:function(a){void 0===a&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),a=new p);return a.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var a=new p,b=new ra;return function(c,d){d=d||b.getNormalMatrix(c);c=this.coplanarPoint(a).applyMatrix4(c);d=this.normal.applyMatrix3(d).normalize();this.constant=-c.dot(d);return this}}(),translate:function(a){this.constant-=a.dot(this.normal);
16011 return this},equals:function(a){return a.normal.equals(this.normal)&&a.constant===this.constant}});Object.assign(md.prototype,{set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],
16012 h=c[5],k=c[6],m=c[7],l=c[8],n=c[9],t=c[10],p=c[11],r=c[12],v=c[13],y=c[14];c=c[15];b[0].setComponents(f-a,m-g,p-l,c-r).normalize();b[1].setComponents(f+a,m+g,p+l,c+r).normalize();b[2].setComponents(f+d,m+h,p+n,c+v).normalize();b[3].setComponents(f-d,m-h,p-n,c-v).normalize();b[4].setComponents(f-e,m-k,p-t,c-y).normalize();b[5].setComponents(f+e,m+k,p+t,c+y).normalize();return this},intersectsObject:function(){var a=new Da;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();
16013 a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSprite:function(){var a=new Da;return function(b){a.center.set(0,0,0);a.radius=.7071067811865476;a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)<a)return!1;return!0},intersectsBox:function(){var a=new p;return function(b){for(var c=this.planes,d=0;6>d;d++){var e=c[d];
16014 a.x=0<e.normal.x?b.max.x:b.min.x;a.y=0<e.normal.y?b.max.y:b.min.y;a.z=0<e.normal.z?b.max.z:b.min.z;if(0>e.distanceToPoint(a))return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}});var S={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",
16015 aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",
16016 begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",
16017 bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",
16018 clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n",
16019 clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",
16020 color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n",
16021 cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",
16022 defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",
16023 emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",
16024 envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",
16025 envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",
16026 envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",
16027 envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",
16028 fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",
16029 gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",
16030 lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",
16031 lights_pars_begin:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n",
16032 lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",
16033 lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",
16034 lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",
16035 lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n",
16036 lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n",
16037 lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",
16038 logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",
16039 map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",
16040 metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",
16041 morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",
16042 normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n",normal_fragment_maps:"#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t#ifdef FLIP_SIDED\n\t\t\tnormal = - normal;\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tnormal = normalize( normalMatrix * normal );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",
16043 normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif\n",
16044 packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",
16045 premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",
16046 roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",
16047 shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",
16048 shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",
16049 shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",
16050 skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",
16051 skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",
16052 specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",
16053 uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",
16054 uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",
16055 uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",
16056 cube_vert:"varying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",
16057 depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n",
16058 distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",
16059 distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}\n",
16060 equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}\n",
16061 linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",
16062 linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n",
16063 meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",
16064 meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n",
16065 meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",
16066 meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",
16067 meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",
16068 meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",
16069 meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",
16070 meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",
16071 normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",
16072 normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",
16073 points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",
16074 points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}\n",
16075 shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <fog_fragment>\n}\n",shadow_vert:"#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",
16076 sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",
16077 sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tvec4 mvPosition;\n\tmvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n"},
16078 Aa={merge:function(a){for(var b={},c=0;c<a.length;c++){var d=this.clone(a[c]),e;for(e in d)b[e]=d[e]}return b},clone:function(a){var b={},c;for(c in a){b[c]={};for(var d in a[c]){var e=a[c][d];e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture)?b[c][d]=e.clone():Array.isArray(e)?b[c][d]=e.slice():b[c][d]=e}}return b}},Tg={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,
16079 blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,
16080 darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,
16081 lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,
16082 mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,
16083 rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Object.assign(G.prototype,
16084 {isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1<d&&--d;return d<1/6?a+6*(c-a)*d:.5>d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b,
16085 c,d){b=H.euclideanModulo(b,1);c=H.clamp(c,0,1);d=H.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=
16086 Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){d=parseFloat(c[1])/
16087 360;var e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0<a.length&&(c=Tg[a],
16088 void 0!==c?this.setHex(c):console.warn("THREE.Color: Unknown color "+a));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a,b){void 0===b&&(b=2);this.r=Math.pow(a.r,b);this.g=Math.pow(a.g,b);this.b=Math.pow(a.b,b);return this},copyLinearToGamma:function(a,b){void 0===b&&(b=2);b=0<b?1/b:1;this.r=Math.pow(a.r,b);this.g=Math.pow(a.g,b);this.b=Math.pow(a.b,b);return this},convertGammaToLinear:function(a){this.copyGammaToLinear(this,
16089 a);return this},convertLinearToGamma:function(a){this.copyLinearToGamma(this,a);return this},copySRGBToLinear:function(){function a(a){return.04045>a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}return function(b){this.r=a(b.r);this.g=a(b.g);this.b=a(b.b);return this}}(),copyLinearToSRGB:function(){function a(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}return function(b){this.r=a(b.r);this.g=a(b.g);this.b=a(b.b);return this}}(),convertSRGBToLinear:function(){this.copySRGBToLinear(this);
16090 return this},convertLinearToSRGB:function(){this.copyLinearToSRGB(this);return this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(a){void 0===a&&(console.warn("THREE.Color: .getHSL() target is now required"),a={h:0,s:0,l:0});var b=this.r,c=this.g,d=this.b,e=Math.max(b,c,d),f=Math.min(b,c,d),g,h=(f+e)/2;if(f===e)f=g=0;else{var k=e-f;f=.5>=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-
16091 d)/k+(c<d?6:0);break;case c:g=(d-b)/k+2;break;case d:g=(b-c)/k+4}g/=6}a.h=g;a.s=f;a.l=h;return a},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(){var a={};return function(b,c,d){this.getHSL(a);a.h+=b;a.s+=c;a.l+=d;this.setHSL(a.h,a.s,a.l);return this}}(),add:function(a){this.r+=a.r;this.g+=a.g;this.b+=a.b;return this},addColors:function(a,b){this.r=a.r+b.r;this.g=a.g+b.g;this.b=a.b+b.b;return this},addScalar:function(a){this.r+=a;this.g+=
16092 a;this.b+=a;return this},sub:function(a){this.r=Math.max(0,this.r-a.r);this.g=Math.max(0,this.g-a.g);this.b=Math.max(0,this.b-a.b);return this},multiply:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b;return this},multiplyScalar:function(a){this.r*=a;this.g*=a;this.b*=a;return this},lerp:function(a,b){this.r+=(a.r-this.r)*b;this.g+=(a.g-this.g)*b;this.b+=(a.b-this.b)*b;return this},equals:function(a){return a.r===this.r&&a.g===this.g&&a.b===this.b},fromArray:function(a,b){void 0===b&&(b=0);this.r=
16093 a[b];this.g=a[b+1];this.b=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.r;a[b+1]=this.g;a[b+2]=this.b;return a},toJSON:function(){return this.getHex()}});var K={common:{diffuse:{value:new G(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new ra},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},
16094 aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new z(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:2.5E-4},fogNear:{value:1},
16095 fogFar:{value:2E3},fogColor:{value:new G(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},
16096 pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new G(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new ra}},
16097 sprite:{diffuse:{value:new G(15658734)},opacity:{value:1},center:{value:new z(.5,.5)},rotation:{value:0},map:{value:null},uvTransform:{value:new ra}}},nb={basic:{uniforms:Aa.merge([K.common,K.specularmap,K.envmap,K.aomap,K.lightmap,K.fog]),vertexShader:S.meshbasic_vert,fragmentShader:S.meshbasic_frag},lambert:{uniforms:Aa.merge([K.common,K.specularmap,K.envmap,K.aomap,K.lightmap,K.emissivemap,K.fog,K.lights,{emissive:{value:new G(0)}}]),vertexShader:S.meshlambert_vert,fragmentShader:S.meshlambert_frag},
16098 phong:{uniforms:Aa.merge([K.common,K.specularmap,K.envmap,K.aomap,K.lightmap,K.emissivemap,K.bumpmap,K.normalmap,K.displacementmap,K.gradientmap,K.fog,K.lights,{emissive:{value:new G(0)},specular:{value:new G(1118481)},shininess:{value:30}}]),vertexShader:S.meshphong_vert,fragmentShader:S.meshphong_frag},standard:{uniforms:Aa.merge([K.common,K.envmap,K.aomap,K.lightmap,K.emissivemap,K.bumpmap,K.normalmap,K.displacementmap,K.roughnessmap,K.metalnessmap,K.fog,K.lights,{emissive:{value:new G(0)},roughness:{value:.5},
16099 metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:S.meshphysical_vert,fragmentShader:S.meshphysical_frag},points:{uniforms:Aa.merge([K.points,K.fog]),vertexShader:S.points_vert,fragmentShader:S.points_frag},dashed:{uniforms:Aa.merge([K.common,K.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:S.linedashed_vert,fragmentShader:S.linedashed_frag},depth:{uniforms:Aa.merge([K.common,K.displacementmap]),vertexShader:S.depth_vert,fragmentShader:S.depth_frag},normal:{uniforms:Aa.merge([K.common,
16100 K.bumpmap,K.normalmap,K.displacementmap,{opacity:{value:1}}]),vertexShader:S.normal_vert,fragmentShader:S.normal_frag},sprite:{uniforms:Aa.merge([K.sprite,K.fog]),vertexShader:S.sprite_vert,fragmentShader:S.sprite_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:S.cube_vert,fragmentShader:S.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:S.equirect_vert,fragmentShader:S.equirect_frag},distanceRGBA:{uniforms:Aa.merge([K.common,K.displacementmap,
16101 {referencePosition:{value:new p},nearDistance:{value:1},farDistance:{value:1E3}}]),vertexShader:S.distanceRGBA_vert,fragmentShader:S.distanceRGBA_frag},shadow:{uniforms:Aa.merge([K.lights,K.fog,{color:{value:new G(0)},opacity:{value:1}}]),vertexShader:S.shadow_vert,fragmentShader:S.shadow_frag}};nb.physical={uniforms:Aa.merge([nb.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:S.meshphysical_vert,fragmentShader:S.meshphysical_frag};hb.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");
16102 hb.DefaultOrder="XYZ";Object.defineProperties(hb.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this.onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this.onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this.onChangeCallback()}},order:{get:function(){return this._order},set:function(a){this._order=a;this.onChangeCallback()}}});Object.assign(hb.prototype,{isEuler:!0,set:function(a,b,c,d){this._x=a;this._y=b;this._z=
16103 c;this._order=d||this._order;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=H.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],k=e[5],m=e[9],l=e[2],n=e[6];e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-m,e),this._z=
16104 Math.atan2(-f,a)):(this._x=Math.atan2(n,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(m,-1,1)),.99999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-l,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(n,-1,1)),.99999>Math.abs(n)?(this._y=Math.atan2(-l,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(l,-1,1)),.99999>Math.abs(l)?(this._x=Math.atan2(n,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===
16105 b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-m,k),this._y=Math.atan2(-l,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(n,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a=new I;return function(b,c,d){a.makeRotationFromQuaternion(b);
16106 return this.setFromRotationMatrix(a,c,d)}}(),setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new fa;return function(b){a.setFromEuler(this);return this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);
16107 void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new p(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}});Object.assign(Rd.prototype,{set:function(a){this.mask=1<<a|0},enable:function(a){this.mask=this.mask|1<<a|0},toggle:function(a){this.mask^=1<<a|0},disable:function(a){this.mask&=~(1<<a|0)},test:function(a){return 0!==(this.mask&
16108 a.mask)}});var Gf=0;D.DefaultUp=new p(0,1,0);D.DefaultMatrixAutoUpdate=!0;D.prototype=Object.assign(Object.create(ya.prototype),{constructor:D,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(a){this.matrix.multiplyMatrices(a,this.matrix);this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(a){this.quaternion.premultiply(a);return this},setRotationFromAxisAngle:function(a,b){this.quaternion.setFromAxisAngle(a,b)},setRotationFromEuler:function(a){this.quaternion.setFromEuler(a,
16109 !0)},setRotationFromMatrix:function(a){this.quaternion.setFromRotationMatrix(a)},setRotationFromQuaternion:function(a){this.quaternion.copy(a)},rotateOnAxis:function(){var a=new fa;return function(b,c){a.setFromAxisAngle(b,c);this.quaternion.multiply(a);return this}}(),rotateOnWorldAxis:function(){var a=new fa;return function(b,c){a.setFromAxisAngle(b,c);this.quaternion.premultiply(a);return this}}(),rotateX:function(){var a=new p(1,0,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateY:function(){var a=
16110 new p(0,1,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateZ:function(){var a=new p(0,0,1);return function(b){return this.rotateOnAxis(a,b)}}(),translateOnAxis:function(){var a=new p;return function(b,c){a.copy(b).applyQuaternion(this.quaternion);this.position.add(a.multiplyScalar(c));return this}}(),translateX:function(){var a=new p(1,0,0);return function(b){return this.translateOnAxis(a,b)}}(),translateY:function(){var a=new p(0,1,0);return function(b){return this.translateOnAxis(a,
16111 b)}}(),translateZ:function(){var a=new p(0,0,1);return function(b){return this.translateOnAxis(a,b)}}(),localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var a=new I;return function(b){return b.applyMatrix4(a.getInverse(this.matrixWorld))}}(),lookAt:function(){var a=new I,b=new p;return function(c,d,e){c.isVector3?b.copy(c):b.set(c,d,e);this.isCamera?a.lookAt(this.position,b,this.up):a.lookAt(b,this.position,this.up);this.quaternion.setFromRotationMatrix(a)}}(),
16112 add:function(a){if(1<arguments.length){for(var b=0;b<arguments.length;b++)this.add(arguments[b]);return this}if(a===this)return console.error("THREE.Object3D.add: object can't be added as a child of itself.",a),this;a&&a.isObject3D?(null!==a.parent&&a.parent.remove(a),a.parent=this,a.dispatchEvent({type:"added"}),this.children.push(a)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",a);return this},remove:function(a){if(1<arguments.length){for(var b=0;b<arguments.length;b++)this.remove(arguments[b]);
16113 return this}b=this.children.indexOf(a);-1!==b&&(a.parent=null,a.dispatchEvent({type:"removed"}),this.children.splice(b,1));return this},getObjectById:function(a){return this.getObjectByProperty("id",a)},getObjectByName:function(a){return this.getObjectByProperty("name",a)},getObjectByProperty:function(a,b){if(this[a]===b)return this;for(var c=0,d=this.children.length;c<d;c++){var e=this.children[c].getObjectByProperty(a,b);if(void 0!==e)return e}},getWorldPosition:function(a){void 0===a&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),
16114 a=new p);this.updateMatrixWorld(!0);return a.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var a=new p,b=new p;return function(c){void 0===c&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),c=new fa);this.updateMatrixWorld(!0);this.matrixWorld.decompose(a,c,b);return c}}(),getWorldScale:function(){var a=new p,b=new fa;return function(c){void 0===c&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),c=new p);this.updateMatrixWorld(!0);
16115 this.matrixWorld.decompose(a,b,c);return c}}(),getWorldDirection:function(){var a=new fa;return function(b){void 0===b&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),b=new p);this.getWorldQuaternion(a);return b.set(0,0,1).applyQuaternion(a)}}(),raycast:function(){},traverse:function(a){a(this);for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverse(a)},traverseVisible:function(a){if(!1!==this.visible){a(this);for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverseVisible(a)}},
16116 traverseAncestors:function(a){var b=this.parent;null!==b&&(a(b),b.traverseAncestors(a))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale);this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=this.children,c=
16117 0,d=b.length;c<d;c++)b[c].updateMatrixWorld(a)},toJSON:function(a){function b(b,c){void 0===b[c.uuid]&&(b[c.uuid]=c.toJSON(a));return c.uuid}function c(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var d=void 0===a||"string"===typeof a,e={};d&&(a={geometries:{},materials:{},textures:{},images:{},shapes:{}},e.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var f={};f.uuid=this.uuid;f.type=this.type;""!==this.name&&(f.name=this.name);!0===this.castShadow&&
16118 (f.castShadow=!0);!0===this.receiveShadow&&(f.receiveShadow=!0);!1===this.visible&&(f.visible=!1);!1===this.frustumCulled&&(f.frustumCulled=!1);0!==this.renderOrder&&(f.renderOrder=this.renderOrder);"{}"!==JSON.stringify(this.userData)&&(f.userData=this.userData);f.layers=this.layers.mask;f.matrix=this.matrix.toArray();!1===this.matrixAutoUpdate&&(f.matrixAutoUpdate=!1);if(this.isMesh||this.isLine||this.isPoints){f.geometry=b(a.geometries,this.geometry);var g=this.geometry.parameters;if(void 0!==
16119 g&&void 0!==g.shapes)if(g=g.shapes,Array.isArray(g))for(var h=0,k=g.length;h<k;h++)b(a.shapes,g[h]);else b(a.shapes,g)}if(void 0!==this.material)if(Array.isArray(this.material)){g=[];h=0;for(k=this.material.length;h<k;h++)g.push(b(a.materials,this.material[h]));f.material=g}else f.material=b(a.materials,this.material);if(0<this.children.length)for(f.children=[],h=0;h<this.children.length;h++)f.children.push(this.children[h].toJSON(a).object);if(d){d=c(a.geometries);h=c(a.materials);k=c(a.textures);
16120 var m=c(a.images);g=c(a.shapes);0<d.length&&(e.geometries=d);0<h.length&&(e.materials=h);0<k.length&&(e.textures=k);0<m.length&&(e.images=m);0<g.length&&(e.shapes=g)}e.object=f;return e},clone:function(a){return(new this.constructor).copy(this,a)},copy:function(a,b){void 0===b&&(b=!0);this.name=a.name;this.up.copy(a.up);this.position.copy(a.position);this.quaternion.copy(a.quaternion);this.scale.copy(a.scale);this.matrix.copy(a.matrix);this.matrixWorld.copy(a.matrixWorld);this.matrixAutoUpdate=a.matrixAutoUpdate;
16121 this.matrixWorldNeedsUpdate=a.matrixWorldNeedsUpdate;this.layers.mask=a.layers.mask;this.visible=a.visible;this.castShadow=a.castShadow;this.receiveShadow=a.receiveShadow;this.frustumCulled=a.frustumCulled;this.renderOrder=a.renderOrder;this.userData=JSON.parse(JSON.stringify(a.userData));if(!0===b)for(b=0;b<a.children.length;b++)this.add(a.children[b].clone());return this}});Na.prototype=Object.assign(Object.create(D.prototype),{constructor:Na,isCamera:!0,copy:function(a,b){D.prototype.copy.call(this,
16122 a,b);this.matrixWorldInverse.copy(a.matrixWorldInverse);this.projectionMatrix.copy(a.projectionMatrix);return this},getWorldDirection:function(){var a=new fa;return function(b){void 0===b&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),b=new p);this.getWorldQuaternion(a);return b.set(0,0,-1).applyQuaternion(a)}}(),updateMatrixWorld:function(a){D.prototype.updateMatrixWorld.call(this,a);this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}});
16123 Hb.prototype=Object.assign(Object.create(Na.prototype),{constructor:Hb,isOrthographicCamera:!0,copy:function(a,b){Na.prototype.copy.call(this,a,b);this.left=a.left;this.right=a.right;this.top=a.top;this.bottom=a.bottom;this.near=a.near;this.far=a.far;this.zoom=a.zoom;this.view=null===a.view?null:Object.assign({},a.view);return this},setViewOffset:function(a,b,c,d,e,f){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1});this.view.enabled=!0;this.view.fullWidth=
16124 a;this.view.fullHeight=b;this.view.offsetX=c;this.view.offsetY=d;this.view.width=e;this.view.height=f;this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1);this.updateProjectionMatrix()},updateProjectionMatrix:function(){var a=(this.right-this.left)/(2*this.zoom),b=(this.top-this.bottom)/(2*this.zoom),c=(this.right+this.left)/2,d=(this.top+this.bottom)/2,e=c-a;c+=a;a=d+b;b=d-b;if(null!==this.view&&this.view.enabled){c=this.zoom/(this.view.width/this.view.fullWidth);
16125 b=this.zoom/(this.view.height/this.view.fullHeight);var f=(this.right-this.left)/this.view.width;d=(this.top-this.bottom)/this.view.height;e+=this.view.offsetX/c*f;c=e+this.view.width/c*f;a-=this.view.offsetY/b*d;b=a-this.view.height/b*d}this.projectionMatrix.makeOrthographic(e,c,a,b,this.near,this.far)},toJSON:function(a){a=D.prototype.toJSON.call(this,a);a.object.zoom=this.zoom;a.object.left=this.left;a.object.right=this.right;a.object.top=this.top;a.object.bottom=this.bottom;a.object.near=this.near;
16126 a.object.far=this.far;null!==this.view&&(a.object.view=Object.assign({},this.view));return a}});Object.assign(Ta.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a=a.a;this.b=a.b;this.c=a.c;this.normal.copy(a.normal);this.color.copy(a.color);this.materialIndex=a.materialIndex;for(var b=0,c=a.vertexNormals.length;b<c;b++)this.vertexNormals[b]=a.vertexNormals[b].clone();b=0;for(c=a.vertexColors.length;b<c;b++)this.vertexColors[b]=a.vertexColors[b].clone();return this}});
16127 var Hf=0;R.prototype=Object.assign(Object.create(ya.prototype),{constructor:R,isGeometry:!0,applyMatrix:function(a){for(var b=(new ra).getNormalMatrix(a),c=0,d=this.vertices.length;c<d;c++)this.vertices[c].applyMatrix4(a);c=0;for(d=this.faces.length;c<d;c++){a=this.faces[c];a.normal.applyMatrix3(b).normalize();for(var e=0,f=a.vertexNormals.length;e<f;e++)a.vertexNormals[e].applyMatrix3(b).normalize()}null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();
16128 this.normalsNeedUpdate=this.verticesNeedUpdate=!0;return this},rotateX:function(){var a=new I;return function(b){a.makeRotationX(b);this.applyMatrix(a);return this}}(),rotateY:function(){var a=new I;return function(b){a.makeRotationY(b);this.applyMatrix(a);return this}}(),rotateZ:function(){var a=new I;return function(b){a.makeRotationZ(b);this.applyMatrix(a);return this}}(),translate:function(){var a=new I;return function(b,c,d){a.makeTranslation(b,c,d);this.applyMatrix(a);return this}}(),scale:function(){var a=
16129 new I;return function(b,c,d){a.makeScale(b,c,d);this.applyMatrix(a);return this}}(),lookAt:function(){var a=new D;return function(b){a.lookAt(b);a.updateMatrix();this.applyMatrix(a.matrix)}}(),fromBufferGeometry:function(a){function b(a,b,d,e){var f=void 0!==g?[l[a].clone(),l[b].clone(),l[d].clone()]:[],q=void 0!==h?[c.colors[a].clone(),c.colors[b].clone(),c.colors[d].clone()]:[];e=new Ta(a,b,d,f,q,e);c.faces.push(e);void 0!==k&&c.faceVertexUvs[0].push([n[a].clone(),n[b].clone(),n[d].clone()]);void 0!==
16130 m&&c.faceVertexUvs[1].push([t[a].clone(),t[b].clone(),t[d].clone()])}var c=this,d=null!==a.index?a.index.array:void 0,e=a.attributes,f=e.position.array,g=void 0!==e.normal?e.normal.array:void 0,h=void 0!==e.color?e.color.array:void 0,k=void 0!==e.uv?e.uv.array:void 0,m=void 0!==e.uv2?e.uv2.array:void 0;void 0!==m&&(this.faceVertexUvs[1]=[]);for(var l=[],n=[],t=[],u=e=0;e<f.length;e+=3,u+=2)c.vertices.push(new p(f[e],f[e+1],f[e+2])),void 0!==g&&l.push(new p(g[e],g[e+1],g[e+2])),void 0!==h&&c.colors.push(new G(h[e],
16131 h[e+1],h[e+2])),void 0!==k&&n.push(new z(k[u],k[u+1])),void 0!==m&&t.push(new z(m[u],m[u+1]));var r=a.groups;if(0<r.length)for(e=0;e<r.length;e++){f=r[e];var v=f.start,y=f.count;u=v;for(v+=y;u<v;u+=3)void 0!==d?b(d[u],d[u+1],d[u+2],f.materialIndex):b(u,u+1,u+2,f.materialIndex)}else if(void 0!==d)for(e=0;e<d.length;e+=3)b(d[e],d[e+1],d[e+2]);else for(e=0;e<f.length/3;e+=3)b(e,e+1,e+2);this.computeFaceNormals();null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());null!==a.boundingSphere&&
16132 (this.boundingSphere=a.boundingSphere.clone());return this},center:function(){var a=new p;return function(){this.computeBoundingBox();this.boundingBox.getCenter(a).negate();this.translate(a.x,a.y,a.z);return this}}(),normalize:function(){this.computeBoundingSphere();var a=this.boundingSphere.center,b=this.boundingSphere.radius;b=0===b?1:1/b;var c=new I;c.set(b,0,0,-b*a.x,0,b,0,-b*a.y,0,0,b,-b*a.z,0,0,0,1);this.applyMatrix(c);return this},computeFaceNormals:function(){for(var a=new p,b=new p,c=0,d=
16133 this.faces.length;c<d;c++){var e=this.faces[c],f=this.vertices[e.a],g=this.vertices[e.b];a.subVectors(this.vertices[e.c],g);b.subVectors(f,g);a.cross(b);a.normalize();e.normal.copy(a)}},computeVertexNormals:function(a){void 0===a&&(a=!0);var b;var c=Array(this.vertices.length);var d=0;for(b=this.vertices.length;d<b;d++)c[d]=new p;if(a){var e=new p,f=new p;a=0;for(d=this.faces.length;a<d;a++){b=this.faces[a];var g=this.vertices[b.a];var h=this.vertices[b.b];var k=this.vertices[b.c];e.subVectors(k,
16134 h);f.subVectors(g,h);e.cross(f);c[b.a].add(e);c[b.b].add(e);c[b.c].add(e)}}else for(this.computeFaceNormals(),a=0,d=this.faces.length;a<d;a++)b=this.faces[a],c[b.a].add(b.normal),c[b.b].add(b.normal),c[b.c].add(b.normal);d=0;for(b=this.vertices.length;d<b;d++)c[d].normalize();a=0;for(d=this.faces.length;a<d;a++)b=this.faces[a],g=b.vertexNormals,3===g.length?(g[0].copy(c[b.a]),g[1].copy(c[b.b]),g[2].copy(c[b.c])):(g[0]=c[b.a].clone(),g[1]=c[b.b].clone(),g[2]=c[b.c].clone());0<this.faces.length&&(this.normalsNeedUpdate=
16135 !0)},computeFlatVertexNormals:function(){var a;this.computeFaceNormals();var b=0;for(a=this.faces.length;b<a;b++){var c=this.faces[b];var d=c.vertexNormals;3===d.length?(d[0].copy(c.normal),d[1].copy(c.normal),d[2].copy(c.normal)):(d[0]=c.normal.clone(),d[1]=c.normal.clone(),d[2]=c.normal.clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var a,b;var c=0;for(b=this.faces.length;c<b;c++){var d=this.faces[c];d.__originalFaceNormal?d.__originalFaceNormal.copy(d.normal):
16136 d.__originalFaceNormal=d.normal.clone();d.__originalVertexNormals||(d.__originalVertexNormals=[]);var e=0;for(a=d.vertexNormals.length;e<a;e++)d.__originalVertexNormals[e]?d.__originalVertexNormals[e].copy(d.vertexNormals[e]):d.__originalVertexNormals[e]=d.vertexNormals[e].clone()}var f=new R;f.faces=this.faces;e=0;for(a=this.morphTargets.length;e<a;e++){if(!this.morphNormals[e]){this.morphNormals[e]={};this.morphNormals[e].faceNormals=[];this.morphNormals[e].vertexNormals=[];d=this.morphNormals[e].faceNormals;
16137 var g=this.morphNormals[e].vertexNormals;c=0;for(b=this.faces.length;c<b;c++){var h=new p;var k={a:new p,b:new p,c:new p};d.push(h);g.push(k)}}g=this.morphNormals[e];f.vertices=this.morphTargets[e].vertices;f.computeFaceNormals();f.computeVertexNormals();c=0;for(b=this.faces.length;c<b;c++)d=this.faces[c],h=g.faceNormals[c],k=g.vertexNormals[c],h.copy(d.normal),k.a.copy(d.vertexNormals[0]),k.b.copy(d.vertexNormals[1]),k.c.copy(d.vertexNormals[2])}c=0;for(b=this.faces.length;c<b;c++)d=this.faces[c],
16138 d.normal=d.__originalFaceNormal,d.vertexNormals=d.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Sa);this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Da);this.boundingSphere.setFromPoints(this.vertices)},merge:function(a,b,c){if(a&&a.isGeometry){var d,e=this.vertices.length,f=this.vertices,g=a.vertices,h=this.faces,k=a.faces,m=this.faceVertexUvs[0],l=a.faceVertexUvs[0],
16139 n=this.colors,t=a.colors;void 0===c&&(c=0);void 0!==b&&(d=(new ra).getNormalMatrix(b));a=0;for(var p=g.length;a<p;a++){var r=g[a].clone();void 0!==b&&r.applyMatrix4(b);f.push(r)}a=0;for(p=t.length;a<p;a++)n.push(t[a].clone());a=0;for(p=k.length;a<p;a++){g=k[a];var v=g.vertexNormals;t=g.vertexColors;n=new Ta(g.a+e,g.b+e,g.c+e);n.normal.copy(g.normal);void 0!==d&&n.normal.applyMatrix3(d).normalize();b=0;for(f=v.length;b<f;b++)r=v[b].clone(),void 0!==d&&r.applyMatrix3(d).normalize(),n.vertexNormals.push(r);
16140 n.color.copy(g.color);b=0;for(f=t.length;b<f;b++)r=t[b],n.vertexColors.push(r.clone());n.materialIndex=g.materialIndex+c;h.push(n)}a=0;for(p=l.length;a<p;a++)if(c=l[a],d=[],void 0!==c){b=0;for(f=c.length;b<f;b++)d.push(c[b].clone());m.push(d)}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",a)},mergeMesh:function(a){a&&a.isMesh?(a.matrixAutoUpdate&&a.updateMatrix(),this.merge(a.geometry,a.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",
16141 a)},mergeVertices:function(){var a={},b=[],c=[],d=Math.pow(10,4),e;var f=0;for(e=this.vertices.length;f<e;f++){var g=this.vertices[f];g=Math.round(g.x*d)+"_"+Math.round(g.y*d)+"_"+Math.round(g.z*d);void 0===a[g]?(a[g]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[g]]}a=[];f=0;for(e=this.faces.length;f<e;f++)for(d=this.faces[f],d.a=c[d.a],d.b=c[d.b],d.c=c[d.c],d=[d.a,d.b,d.c],g=0;3>g;g++)if(d[g]===d[(g+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(d=a[f],this.faces.splice(d,1),c=0,e=
16142 this.faceVertexUvs.length;c<e;c++)this.faceVertexUvs[c].splice(d,1);f=this.vertices.length-b.length;this.vertices=b;return f},setFromPoints:function(a){this.vertices=[];for(var b=0,c=a.length;b<c;b++){var d=a[b];this.vertices.push(new p(d.x,d.y,d.z||0))}return this},sortFacesByMaterialIndex:function(){for(var a=this.faces,b=a.length,c=0;c<b;c++)a[c]._id=c;a.sort(function(a,b){return a.materialIndex-b.materialIndex});var d=this.faceVertexUvs[0],e=this.faceVertexUvs[1],f,g;d&&d.length===b&&(f=[]);e&&
16143 e.length===b&&(g=[]);for(c=0;c<b;c++){var h=a[c]._id;f&&f.push(d[h]);g&&g.push(e[h])}f&&(this.faceVertexUvs[0]=f);g&&(this.faceVertexUvs[1]=g)},toJSON:function(){function a(a,b,c){return c?a|1<<b:a&~(1<<b)}function b(a){var b=a.x.toString()+a.y.toString()+a.z.toString();if(void 0!==m[b])return m[b];m[b]=k.length/3;k.push(a.x,a.y,a.z);return m[b]}function c(a){var b=a.r.toString()+a.g.toString()+a.b.toString();if(void 0!==n[b])return n[b];n[b]=l.length;l.push(a.getHex());return n[b]}function d(a){var b=
16144 a.x.toString()+a.y.toString();if(void 0!==p[b])return p[b];p[b]=t.length/2;t.push(a.x,a.y);return p[b]}var e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};e.uuid=this.uuid;e.type=this.type;""!==this.name&&(e.name=this.name);if(void 0!==this.parameters){var f=this.parameters,g;for(g in f)void 0!==f[g]&&(e[g]=f[g]);return e}f=[];for(g=0;g<this.vertices.length;g++){var h=this.vertices[g];f.push(h.x,h.y,h.z)}h=[];var k=[],m={},l=[],n={},t=[],p={};for(g=0;g<this.faces.length;g++){var r=
16145 this.faces[g],v=void 0!==this.faceVertexUvs[0][g],y=0<r.normal.length(),x=0<r.vertexNormals.length,w=1!==r.color.r||1!==r.color.g||1!==r.color.b,B=0<r.vertexColors.length,E=0;E=a(E,0,0);E=a(E,1,!0);E=a(E,2,!1);E=a(E,3,v);E=a(E,4,y);E=a(E,5,x);E=a(E,6,w);E=a(E,7,B);h.push(E);h.push(r.a,r.b,r.c);h.push(r.materialIndex);v&&(v=this.faceVertexUvs[0][g],h.push(d(v[0]),d(v[1]),d(v[2])));y&&h.push(b(r.normal));x&&(y=r.vertexNormals,h.push(b(y[0]),b(y[1]),b(y[2])));w&&h.push(c(r.color));B&&(r=r.vertexColors,
16146 h.push(c(r[0]),c(r[1]),c(r[2])))}e.data={};e.data.vertices=f;e.data.normals=k;0<l.length&&(e.data.colors=l);0<t.length&&(e.data.uvs=[t]);e.data.faces=h;return e},clone:function(){return(new R).copy(this)},copy:function(a){var b,c,d;this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.name=a.name;var e=a.vertices;var f=0;for(b=e.length;f<
16147 b;f++)this.vertices.push(e[f].clone());e=a.colors;f=0;for(b=e.length;f<b;f++)this.colors.push(e[f].clone());e=a.faces;f=0;for(b=e.length;f<b;f++)this.faces.push(e[f].clone());f=0;for(b=a.faceVertexUvs.length;f<b;f++){var g=a.faceVertexUvs[f];void 0===this.faceVertexUvs[f]&&(this.faceVertexUvs[f]=[]);e=0;for(c=g.length;e<c;e++){var h=g[e],k=[];var m=0;for(d=h.length;m<d;m++)k.push(h[m].clone());this.faceVertexUvs[f].push(k)}}m=a.morphTargets;f=0;for(b=m.length;f<b;f++){d={};d.name=m[f].name;if(void 0!==
16148 m[f].vertices)for(d.vertices=[],e=0,c=m[f].vertices.length;e<c;e++)d.vertices.push(m[f].vertices[e].clone());if(void 0!==m[f].normals)for(d.normals=[],e=0,c=m[f].normals.length;e<c;e++)d.normals.push(m[f].normals[e].clone());this.morphTargets.push(d)}m=a.morphNormals;f=0;for(b=m.length;f<b;f++){d={};if(void 0!==m[f].vertexNormals)for(d.vertexNormals=[],e=0,c=m[f].vertexNormals.length;e<c;e++)g=m[f].vertexNormals[e],h={},h.a=g.a.clone(),h.b=g.b.clone(),h.c=g.c.clone(),d.vertexNormals.push(h);if(void 0!==
16149 m[f].faceNormals)for(d.faceNormals=[],e=0,c=m[f].faceNormals.length;e<c;e++)d.faceNormals.push(m[f].faceNormals[e].clone());this.morphNormals.push(d)}e=a.skinWeights;f=0;for(b=e.length;f<b;f++)this.skinWeights.push(e[f].clone());e=a.skinIndices;f=0;for(b=e.length;f<b;f++)this.skinIndices.push(e[f].clone());e=a.lineDistances;f=0;for(b=e.length;f<b;f++)this.lineDistances.push(e[f]);f=a.boundingBox;null!==f&&(this.boundingBox=f.clone());f=a.boundingSphere;null!==f&&(this.boundingSphere=f.clone());this.elementsNeedUpdate=
16150 a.elementsNeedUpdate;this.verticesNeedUpdate=a.verticesNeedUpdate;this.uvsNeedUpdate=a.uvsNeedUpdate;this.normalsNeedUpdate=a.normalsNeedUpdate;this.colorsNeedUpdate=a.colorsNeedUpdate;this.lineDistancesNeedUpdate=a.lineDistancesNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Object.defineProperty(Q.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(Q.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},
16151 setArray:function(a){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==a?a.length/this.itemSize:0;this.array=a;return this},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.name=a.name;this.array=new a.array.constructor(a.array);this.itemSize=a.itemSize;this.count=a.count;this.normalized=a.normalized;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.itemSize;c*=b.itemSize;for(var d=0,e=this.itemSize;d<
16152 e;d++)this.array[a+d]=b.array[c+d];return this},copyArray:function(a){this.array.set(a);return this},copyColorsArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",d),f=new G);b[c++]=f.r;b[c++]=f.g;b[c++]=f.b}return this},copyVector2sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",
16153 d),f=new z);b[c++]=f.x;b[c++]=f.y}return this},copyVector3sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",d),f=new p);b[c++]=f.x;b[c++]=f.y;b[c++]=f.z}return this},copyVector4sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",d),f=new V);b[c++]=f.x;b[c++]=f.y;
16154 b[c++]=f.z;b[c++]=f.w}return this},set:function(a,b){void 0===b&&(b=0);this.array.set(a,b);return this},getX:function(a){return this.array[a*this.itemSize]},setX:function(a,b){this.array[a*this.itemSize]=b;return this},getY:function(a){return this.array[a*this.itemSize+1]},setY:function(a,b){this.array[a*this.itemSize+1]=b;return this},getZ:function(a){return this.array[a*this.itemSize+2]},setZ:function(a,b){this.array[a*this.itemSize+2]=b;return this},getW:function(a){return this.array[a*this.itemSize+
16155 3]},setW:function(a,b){this.array[a*this.itemSize+3]=b;return this},setXY:function(a,b,c){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;return this},setXYZ:function(a,b,c,d){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;this.array[a+2]=d;return this},setXYZW:function(a,b,c,d,e){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;this.array[a+2]=d;this.array[a+3]=e;return this},onUpload:function(a){this.onUploadCallback=a;return this},clone:function(){return(new this.constructor(this.array,
16156 this.itemSize)).copy(this)}});oc.prototype=Object.create(Q.prototype);oc.prototype.constructor=oc;pc.prototype=Object.create(Q.prototype);pc.prototype.constructor=pc;qc.prototype=Object.create(Q.prototype);qc.prototype.constructor=qc;rc.prototype=Object.create(Q.prototype);rc.prototype.constructor=rc;ib.prototype=Object.create(Q.prototype);ib.prototype.constructor=ib;sc.prototype=Object.create(Q.prototype);sc.prototype.constructor=sc;jb.prototype=Object.create(Q.prototype);jb.prototype.constructor=
16157 jb;A.prototype=Object.create(Q.prototype);A.prototype.constructor=A;tc.prototype=Object.create(Q.prototype);tc.prototype.constructor=tc;Object.assign(Ee.prototype,{computeGroups:function(a){var b=[],c=void 0;a=a.faces;for(var d=0;d<a.length;d++){var e=a[d];if(e.materialIndex!==c){c=e.materialIndex;void 0!==f&&(f.count=3*d-f.start,b.push(f));var f={start:3*d,materialIndex:c}}}void 0!==f&&(f.count=3*d-f.start,b.push(f));this.groups=b},fromGeometry:function(a){var b=a.faces,c=a.vertices,d=a.faceVertexUvs,
16158 e=d[0]&&0<d[0].length,f=d[1]&&0<d[1].length,g=a.morphTargets,h=g.length;if(0<h){var k=[];for(var m=0;m<h;m++)k[m]=[];this.morphTargets.position=k}var l=a.morphNormals,n=l.length;if(0<n){var t=[];for(m=0;m<n;m++)t[m]=[];this.morphTargets.normal=t}var p=a.skinIndices,r=a.skinWeights,v=p.length===c.length,y=r.length===c.length;0<c.length&&0===b.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(m=0;m<b.length;m++){var x=b[m];this.vertices.push(c[x.a],c[x.b],c[x.c]);
16159 var w=x.vertexNormals;3===w.length?this.normals.push(w[0],w[1],w[2]):(w=x.normal,this.normals.push(w,w,w));w=x.vertexColors;3===w.length?this.colors.push(w[0],w[1],w[2]):(w=x.color,this.colors.push(w,w,w));!0===e&&(w=d[0][m],void 0!==w?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new z,new z,new z)));!0===f&&(w=d[1][m],void 0!==w?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",
16160 m),this.uvs2.push(new z,new z,new z)));for(w=0;w<h;w++){var B=g[w].vertices;k[w].push(B[x.a],B[x.b],B[x.c])}for(w=0;w<n;w++)B=l[w].vertexNormals[m],t[w].push(B.a,B.b,B.c);v&&this.skinIndices.push(p[x.a],p[x.b],p[x.c]);y&&this.skinWeights.push(r[x.a],r[x.b],r[x.c])}this.computeGroups(a);this.verticesNeedUpdate=a.verticesNeedUpdate;this.normalsNeedUpdate=a.normalsNeedUpdate;this.colorsNeedUpdate=a.colorsNeedUpdate;this.uvsNeedUpdate=a.uvsNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;return this}});
16161 var If=1;C.prototype=Object.assign(Object.create(ya.prototype),{constructor:C,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(a){Array.isArray(a)?this.index=new (65535<Fe(a)?jb:ib)(a,1):this.index=a},addAttribute:function(a,b,c){if(!(b&&b.isBufferAttribute||b&&b.isInterleavedBufferAttribute))return console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(a,new Q(b,c));if("index"===a)return console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),
16162 this.setIndex(b),this;this.attributes[a]=b;return this},getAttribute:function(a){return this.attributes[a]},removeAttribute:function(a){delete this.attributes[a];return this},addGroup:function(a,b,c){this.groups.push({start:a,count:b,materialIndex:void 0!==c?c:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(a,b){this.drawRange.start=a;this.drawRange.count=b},applyMatrix:function(a){var b=this.attributes.position;void 0!==b&&(a.applyToBufferAttribute(b),b.needsUpdate=!0);b=this.attributes.normal;
16163 void 0!==b&&((new ra).getNormalMatrix(a).applyToBufferAttribute(b),b.needsUpdate=!0);null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();return this},rotateX:function(){var a=new I;return function(b){a.makeRotationX(b);this.applyMatrix(a);return this}}(),rotateY:function(){var a=new I;return function(b){a.makeRotationY(b);this.applyMatrix(a);return this}}(),rotateZ:function(){var a=new I;return function(b){a.makeRotationZ(b);this.applyMatrix(a);
16164 return this}}(),translate:function(){var a=new I;return function(b,c,d){a.makeTranslation(b,c,d);this.applyMatrix(a);return this}}(),scale:function(){var a=new I;return function(b,c,d){a.makeScale(b,c,d);this.applyMatrix(a);return this}}(),lookAt:function(){var a=new D;return function(b){a.lookAt(b);a.updateMatrix();this.applyMatrix(a.matrix)}}(),center:function(){var a=new p;return function(){this.computeBoundingBox();this.boundingBox.getCenter(a).negate();this.translate(a.x,a.y,a.z);return this}}(),
16165 setFromObject:function(a){var b=a.geometry;if(a.isPoints||a.isLine){a=new A(3*b.vertices.length,3);var c=new A(3*b.colors.length,3);this.addAttribute("position",a.copyVector3sArray(b.vertices));this.addAttribute("color",c.copyColorsArray(b.colors));b.lineDistances&&b.lineDistances.length===b.vertices.length&&(a=new A(b.lineDistances.length,1),this.addAttribute("lineDistance",a.copyArray(b.lineDistances)));null!==b.boundingSphere&&(this.boundingSphere=b.boundingSphere.clone());null!==b.boundingBox&&
16166 (this.boundingBox=b.boundingBox.clone())}else a.isMesh&&b&&b.isGeometry&&this.fromGeometry(b);return this},setFromPoints:function(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c];b.push(e.x,e.y,e.z||0)}this.addAttribute("position",new A(b,3));return this},updateFromObject:function(a){var b=a.geometry;if(a.isMesh){var c=b.__directGeometry;!0===b.elementsNeedUpdate&&(c=void 0,b.elementsNeedUpdate=!1);if(void 0===c)return this.fromGeometry(b);c.verticesNeedUpdate=b.verticesNeedUpdate;c.normalsNeedUpdate=
16167 b.normalsNeedUpdate;c.colorsNeedUpdate=b.colorsNeedUpdate;c.uvsNeedUpdate=b.uvsNeedUpdate;c.groupsNeedUpdate=b.groupsNeedUpdate;b.verticesNeedUpdate=!1;b.normalsNeedUpdate=!1;b.colorsNeedUpdate=!1;b.uvsNeedUpdate=!1;b.groupsNeedUpdate=!1;b=c}!0===b.verticesNeedUpdate&&(c=this.attributes.position,void 0!==c&&(c.copyVector3sArray(b.vertices),c.needsUpdate=!0),b.verticesNeedUpdate=!1);!0===b.normalsNeedUpdate&&(c=this.attributes.normal,void 0!==c&&(c.copyVector3sArray(b.normals),c.needsUpdate=!0),b.normalsNeedUpdate=
16168 !1);!0===b.colorsNeedUpdate&&(c=this.attributes.color,void 0!==c&&(c.copyColorsArray(b.colors),c.needsUpdate=!0),b.colorsNeedUpdate=!1);b.uvsNeedUpdate&&(c=this.attributes.uv,void 0!==c&&(c.copyVector2sArray(b.uvs),c.needsUpdate=!0),b.uvsNeedUpdate=!1);b.lineDistancesNeedUpdate&&(c=this.attributes.lineDistance,void 0!==c&&(c.copyArray(b.lineDistances),c.needsUpdate=!0),b.lineDistancesNeedUpdate=!1);b.groupsNeedUpdate&&(b.computeGroups(a.geometry),this.groups=b.groups,b.groupsNeedUpdate=!1);return this},
16169 fromGeometry:function(a){a.__directGeometry=(new Ee).fromGeometry(a);return this.fromDirectGeometry(a.__directGeometry)},fromDirectGeometry:function(a){var b=new Float32Array(3*a.vertices.length);this.addAttribute("position",(new Q(b,3)).copyVector3sArray(a.vertices));0<a.normals.length&&(b=new Float32Array(3*a.normals.length),this.addAttribute("normal",(new Q(b,3)).copyVector3sArray(a.normals)));0<a.colors.length&&(b=new Float32Array(3*a.colors.length),this.addAttribute("color",(new Q(b,3)).copyColorsArray(a.colors)));
16170 0<a.uvs.length&&(b=new Float32Array(2*a.uvs.length),this.addAttribute("uv",(new Q(b,2)).copyVector2sArray(a.uvs)));0<a.uvs2.length&&(b=new Float32Array(2*a.uvs2.length),this.addAttribute("uv2",(new Q(b,2)).copyVector2sArray(a.uvs2)));this.groups=a.groups;for(var c in a.morphTargets){b=[];for(var d=a.morphTargets[c],e=0,f=d.length;e<f;e++){var g=d[e],h=new A(3*g.length,3);b.push(h.copyVector3sArray(g))}this.morphAttributes[c]=b}0<a.skinIndices.length&&(c=new A(4*a.skinIndices.length,4),this.addAttribute("skinIndex",
16171 c.copyVector4sArray(a.skinIndices)));0<a.skinWeights.length&&(c=new A(4*a.skinWeights.length,4),this.addAttribute("skinWeight",c.copyVector4sArray(a.skinWeights)));null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());return this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Sa);var a=this.attributes.position;void 0!==a?this.boundingBox.setFromBufferAttribute(a):this.boundingBox.makeEmpty();
16172 (isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var a=new Sa,b=new p;return function(){null===this.boundingSphere&&(this.boundingSphere=new Da);var c=this.attributes.position;if(c){var d=this.boundingSphere.center;a.setFromBufferAttribute(c);a.getCenter(d);for(var e=0,
16173 f=0,g=c.count;f<g;f++)b.x=c.getX(f),b.y=c.getY(f),b.z=c.getZ(f),e=Math.max(e,d.distanceToSquared(b));this.boundingSphere.radius=Math.sqrt(e);isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var a=this.index,b=this.attributes,c=this.groups;if(b.position){var d=b.position.array;if(void 0===b.normal)this.addAttribute("normal",
16174 new Q(new Float32Array(d.length),3));else for(var e=b.normal.array,f=0,g=e.length;f<g;f++)e[f]=0;e=b.normal.array;var h=new p,k=new p,m=new p,l=new p,n=new p;if(a){a=a.array;0===c.length&&this.addGroup(0,a.length);for(var t=0,u=c.length;t<u;++t){f=c[t];g=f.start;var r=f.count;f=g;for(g+=r;f<g;f+=3){r=3*a[f+0];var v=3*a[f+1];var y=3*a[f+2];h.fromArray(d,r);k.fromArray(d,v);m.fromArray(d,y);l.subVectors(m,k);n.subVectors(h,k);l.cross(n);e[r]+=l.x;e[r+1]+=l.y;e[r+2]+=l.z;e[v]+=l.x;e[v+1]+=l.y;e[v+2]+=
16175 l.z;e[y]+=l.x;e[y+1]+=l.y;e[y+2]+=l.z}}}else for(f=0,g=d.length;f<g;f+=9)h.fromArray(d,f),k.fromArray(d,f+3),m.fromArray(d,f+6),l.subVectors(m,k),n.subVectors(h,k),l.cross(n),e[f]=l.x,e[f+1]=l.y,e[f+2]=l.z,e[f+3]=l.x,e[f+4]=l.y,e[f+5]=l.z,e[f+6]=l.x,e[f+7]=l.y,e[f+8]=l.z;this.normalizeNormals();b.normal.needsUpdate=!0}},merge:function(a,b){if(a&&a.isBufferGeometry){void 0===b&&(b=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));
16176 var c=this.attributes,d;for(d in c)if(void 0!==a.attributes[d]){var e=c[d].array,f=a.attributes[d],g=f.array,h=0;for(f=f.itemSize*b;h<g.length;h++,f++)e[f]=g[h]}return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",a)},normalizeNormals:function(){var a=new p;return function(){for(var b=this.attributes.normal,c=0,d=b.count;c<d;c++)a.x=b.getX(c),a.y=b.getY(c),a.z=b.getZ(c),a.normalize(),b.setXYZ(c,a.x,a.y,a.z)}}(),toNonIndexed:function(){if(null===
16177 this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var a=new C,b=this.index.array,c=this.attributes,d;for(d in c){var e=c[d],f=e.array,g=e.itemSize,h=new f.constructor(b.length*g),k=0;e=0;for(var m=b.length;e<m;e++){var l=b[e]*g;for(var n=0;n<g;n++)h[k++]=f[l++]}a.addAttribute(d,new Q(h,g))}b=this.groups;e=0;for(m=b.length;e<m;e++)c=b[e],a.addGroup(c.start,c.count,c.materialIndex);return a},toJSON:function(){var a={metadata:{version:4.5,type:"BufferGeometry",
16178 generator:"BufferGeometry.toJSON"}};a.uuid=this.uuid;a.type=this.type;""!==this.name&&(a.name=this.name);0<Object.keys(this.userData).length&&(a.userData=this.userData);if(void 0!==this.parameters){var b=this.parameters;for(e in b)void 0!==b[e]&&(a[e]=b[e]);return a}a.data={attributes:{}};var c=this.index;null!==c&&(b=Array.prototype.slice.call(c.array),a.data.index={type:c.array.constructor.name,array:b});c=this.attributes;for(e in c){var d=c[e];b=Array.prototype.slice.call(d.array);a.data.attributes[e]=
16179 {itemSize:d.itemSize,type:d.array.constructor.name,array:b,normalized:d.normalized}}var e=this.groups;0<e.length&&(a.data.groups=JSON.parse(JSON.stringify(e)));e=this.boundingSphere;null!==e&&(a.data.boundingSphere={center:e.center.toArray(),radius:e.radius});return a},clone:function(){return(new C).copy(this)},copy:function(a){var b;this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.name=a.name;var c=a.index;null!==c&&this.setIndex(c.clone());
16180 c=a.attributes;for(g in c)this.addAttribute(g,c[g].clone());var d=a.morphAttributes;for(g in d){var e=[],f=d[g];c=0;for(b=f.length;c<b;c++)e.push(f[c].clone());this.morphAttributes[g]=e}var g=a.groups;c=0;for(b=g.length;c<b;c++)d=g[c],this.addGroup(d.start,d.count,d.materialIndex);g=a.boundingBox;null!==g&&(this.boundingBox=g.clone());g=a.boundingSphere;null!==g&&(this.boundingSphere=g.clone());this.drawRange.start=a.drawRange.start;this.drawRange.count=a.drawRange.count;this.userData=a.userData;
16181 return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Ib.prototype=Object.create(R.prototype);Ib.prototype.constructor=Ib;kb.prototype=Object.create(C.prototype);kb.prototype.constructor=kb;uc.prototype=Object.create(R.prototype);uc.prototype.constructor=uc;lb.prototype=Object.create(C.prototype);lb.prototype.constructor=lb;var Kf=0;J.prototype=Object.assign(Object.create(ya.prototype),{constructor:J,isMaterial:!0,onBeforeCompile:function(){},setValues:function(a){if(void 0!==a)for(var b in a){var c=
16182 a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else if("shading"===b)console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===c?!0:!1;else{var d=this[b];void 0===d?console.warn("THREE."+this.type+": '"+b+"' is not a property of this material."):d&&d.isColor?d.set(c):d&&d.isVector3&&c&&c.isVector3?d.copy(c):this[b]="overdraw"===b?Number(c):c}}},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=
16183 a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a||"string"===typeof a;c&&(a={textures:{},images:{}});var d={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};d.uuid=this.uuid;d.type=this.type;""!==this.name&&(d.name=this.name);this.color&&this.color.isColor&&(d.color=this.color.getHex());void 0!==this.roughness&&(d.roughness=this.roughness);void 0!==this.metalness&&(d.metalness=this.metalness);this.emissive&&this.emissive.isColor&&(d.emissive=this.emissive.getHex());1!==
16184 this.emissiveIntensity&&(d.emissiveIntensity=this.emissiveIntensity);this.specular&&this.specular.isColor&&(d.specular=this.specular.getHex());void 0!==this.shininess&&(d.shininess=this.shininess);void 0!==this.clearCoat&&(d.clearCoat=this.clearCoat);void 0!==this.clearCoatRoughness&&(d.clearCoatRoughness=this.clearCoatRoughness);this.map&&this.map.isTexture&&(d.map=this.map.toJSON(a).uuid);this.alphaMap&&this.alphaMap.isTexture&&(d.alphaMap=this.alphaMap.toJSON(a).uuid);this.lightMap&&this.lightMap.isTexture&&
16185 (d.lightMap=this.lightMap.toJSON(a).uuid);this.aoMap&&this.aoMap.isTexture&&(d.aoMap=this.aoMap.toJSON(a).uuid,d.aoMapIntensity=this.aoMapIntensity);this.bumpMap&&this.bumpMap.isTexture&&(d.bumpMap=this.bumpMap.toJSON(a).uuid,d.bumpScale=this.bumpScale);this.normalMap&&this.normalMap.isTexture&&(d.normalMap=this.normalMap.toJSON(a).uuid,d.normalMapType=this.normalMapType,d.normalScale=this.normalScale.toArray());this.displacementMap&&this.displacementMap.isTexture&&(d.displacementMap=this.displacementMap.toJSON(a).uuid,
16186 d.displacementScale=this.displacementScale,d.displacementBias=this.displacementBias);this.roughnessMap&&this.roughnessMap.isTexture&&(d.roughnessMap=this.roughnessMap.toJSON(a).uuid);this.metalnessMap&&this.metalnessMap.isTexture&&(d.metalnessMap=this.metalnessMap.toJSON(a).uuid);this.emissiveMap&&this.emissiveMap.isTexture&&(d.emissiveMap=this.emissiveMap.toJSON(a).uuid);this.specularMap&&this.specularMap.isTexture&&(d.specularMap=this.specularMap.toJSON(a).uuid);this.envMap&&this.envMap.isTexture&&
16187 (d.envMap=this.envMap.toJSON(a).uuid,d.reflectivity=this.reflectivity);this.gradientMap&&this.gradientMap.isTexture&&(d.gradientMap=this.gradientMap.toJSON(a).uuid);void 0!==this.size&&(d.size=this.size);void 0!==this.sizeAttenuation&&(d.sizeAttenuation=this.sizeAttenuation);1!==this.blending&&(d.blending=this.blending);!0===this.flatShading&&(d.flatShading=this.flatShading);0!==this.side&&(d.side=this.side);0!==this.vertexColors&&(d.vertexColors=this.vertexColors);1>this.opacity&&(d.opacity=this.opacity);
16188 !0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;0!==this.rotation&&(d.rotation=this.rotation);1!==this.linewidth&&(d.linewidth=this.linewidth);void 0!==this.dashSize&&(d.dashSize=this.dashSize);void 0!==this.gapSize&&(d.gapSize=this.gapSize);void 0!==this.scale&&(d.scale=this.scale);!0===this.dithering&&(d.dithering=!0);0<this.alphaTest&&(d.alphaTest=this.alphaTest);!0===this.premultipliedAlpha&&(d.premultipliedAlpha=
16189 this.premultipliedAlpha);!0===this.wireframe&&(d.wireframe=this.wireframe);1<this.wireframeLinewidth&&(d.wireframeLinewidth=this.wireframeLinewidth);"round"!==this.wireframeLinecap&&(d.wireframeLinecap=this.wireframeLinecap);"round"!==this.wireframeLinejoin&&(d.wireframeLinejoin=this.wireframeLinejoin);!0===this.morphTargets&&(d.morphTargets=!0);!0===this.skinning&&(d.skinning=!0);!1===this.visible&&(d.visible=!1);"{}"!==JSON.stringify(this.userData)&&(d.userData=this.userData);c&&(c=b(a.textures),
16190 a=b(a.images),0<c.length&&(d.textures=c),0<a.length&&(d.images=a));return d},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.name=a.name;this.fog=a.fog;this.lights=a.lights;this.blending=a.blending;this.side=a.side;this.flatShading=a.flatShading;this.vertexColors=a.vertexColors;this.opacity=a.opacity;this.transparent=a.transparent;this.blendSrc=a.blendSrc;this.blendDst=a.blendDst;this.blendEquation=a.blendEquation;this.blendSrcAlpha=a.blendSrcAlpha;this.blendDstAlpha=
16191 a.blendDstAlpha;this.blendEquationAlpha=a.blendEquationAlpha;this.depthFunc=a.depthFunc;this.depthTest=a.depthTest;this.depthWrite=a.depthWrite;this.colorWrite=a.colorWrite;this.precision=a.precision;this.polygonOffset=a.polygonOffset;this.polygonOffsetFactor=a.polygonOffsetFactor;this.polygonOffsetUnits=a.polygonOffsetUnits;this.dithering=a.dithering;this.alphaTest=a.alphaTest;this.premultipliedAlpha=a.premultipliedAlpha;this.overdraw=a.overdraw;this.visible=a.visible;this.userData=JSON.parse(JSON.stringify(a.userData));
16192 this.clipShadows=a.clipShadows;this.clipIntersection=a.clipIntersection;var b=a.clippingPlanes,c=null;if(null!==b){var d=b.length;c=Array(d);for(var e=0;e!==d;++e)c[e]=b[e].clone()}this.clippingPlanes=c;this.shadowSide=a.shadowSide;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});da.prototype=Object.create(J.prototype);da.prototype.constructor=da;da.prototype.isMeshBasicMaterial=!0;da.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.map=
16193 a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=
16194 a.morphTargets;return this};ta.prototype=Object.create(J.prototype);ta.prototype.constructor=ta;ta.prototype.isShaderMaterial=!0;ta.prototype.copy=function(a){J.prototype.copy.call(this,a);this.fragmentShader=a.fragmentShader;this.vertexShader=a.vertexShader;this.uniforms=Aa.clone(a.uniforms);this.defines=Object.assign({},a.defines);this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.lights=a.lights;this.clipping=a.clipping;this.skinning=a.skinning;this.morphTargets=a.morphTargets;
16195 this.morphNormals=a.morphNormals;this.extensions=a.extensions;return this};ta.prototype.toJSON=function(a){a=J.prototype.toJSON.call(this,a);a.uniforms=this.uniforms;a.vertexShader=this.vertexShader;a.fragmentShader=this.fragmentShader;return a};Object.assign(mb.prototype,{set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,
16196 b){void 0===b&&(console.warn("THREE.Ray: .at() target is now required"),b=new p);return b.copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize();return this},recast:function(){var a=new p;return function(b){this.origin.copy(this.at(b,a));return this}}(),closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),b=new p);b.subVectors(a,this.origin);a=b.dot(this.direction);
16197 return 0>a?b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new p;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new p,b=new p,c=new p;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);
16198 b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),k=-this.direction.dot(b),m=c.dot(this.direction),l=-c.dot(b),n=c.lengthSq(),t=Math.abs(1-k*k);if(0<t){d=k*l-m;e=k*m-l;var p=h*t;0<=d?e>=-p?e<=p?(h=1/t,d*=h,e*=h,k=d*(d+k*e+2*m)+e*(k*d+e+2*l)+n):(e=h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+n):(e=-h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+n):e<=-p?(d=Math.max(0,-(-k*h+m)),e=0<d?-h:Math.min(Math.max(-h,-l),h),k=-d*d+e*(e+2*l)+n):e<=p?(d=0,e=Math.min(Math.max(-h,-l),h),k=
16199 e*(e+2*l)+n):(d=Math.max(0,-(k*h+m)),e=0<d?h:Math.min(Math.max(-h,-l),h),k=-d*d+e*(e+2*l)+n)}else e=0<k?-h:h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+n;f&&f.copy(this.direction).multiplyScalar(d).add(this.origin);g&&g.copy(b).multiplyScalar(e).add(a);return k}}(),intersectSphere:function(){var a=new p;return function(b,c){a.subVectors(b.center,this.origin);var d=a.dot(this.direction),e=a.dot(a)-d*d;b=b.radius*b.radius;if(e>b)return null;b=Math.sqrt(b-e);e=d-b;d+=b;return 0>e&&0>d?null:0>e?this.at(d,
16200 c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<=a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){a=this.distanceToPlane(a);return null===a?null:this.at(a,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,
16201 b){var c=1/this.direction.x;var d=1/this.direction.y;var e=1/this.direction.z,f=this.origin;if(0<=c){var g=(a.min.x-f.x)*c;c*=a.max.x-f.x}else g=(a.max.x-f.x)*c,c*=a.min.x-f.x;if(0<=d){var h=(a.min.y-f.y)*d;d*=a.max.y-f.y}else h=(a.max.y-f.y)*d,d*=a.min.y-f.y;if(g>d||h>c)return null;if(h>g||g!==g)g=h;if(d<c||c!==c)c=d;0<=e?(h=(a.min.z-f.z)*e,a=(a.max.z-f.z)*e):(h=(a.max.z-f.z)*e,a=(a.min.z-f.z)*e);if(g>a||h>c)return null;if(h>g||g!==g)g=h;if(a<c||c!==c)c=a;return 0>c?null:this.at(0<=g?g:c,b)},intersectsBox:function(){var a=
16202 new p;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new p,b=new p,c=new p,d=new p;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0<f){if(h)return null;h=1}else if(0>f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),
16203 applyMatrix4:function(a){this.origin.applyMatrix4(a);this.direction.transformDirection(a);return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}});Object.assign(ja,{getNormal:function(){var a=new p;return function(b,c,d,e){void 0===e&&(console.warn("THREE.Triangle: .getNormal() target is now required"),e=new p);e.subVectors(d,c);a.subVectors(b,c);e.cross(a);b=e.lengthSq();return 0<b?e.multiplyScalar(1/Math.sqrt(b)):e.set(0,0,0)}}(),getBarycoord:function(){var a=
16204 new p,b=new p,c=new p;return function(d,e,f,g,h){a.subVectors(g,e);b.subVectors(f,e);c.subVectors(d,e);d=a.dot(a);e=a.dot(b);f=a.dot(c);var k=b.dot(b);g=b.dot(c);var m=d*k-e*e;void 0===h&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),h=new p);if(0===m)return h.set(-2,-1,-1);m=1/m;k=(k*f-e*g)*m;d=(d*g-e*f)*m;return h.set(1-k-d,d,k)}}(),containsPoint:function(){var a=new p;return function(b,c,d,e){ja.getBarycoord(b,c,d,e,a);return 0<=a.x&&0<=a.y&&1>=a.x+a.y}}()});Object.assign(ja.prototype,
16205 {set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},getArea:function(){var a=new p,b=new p;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),getMidpoint:function(a){void 0===
16206 a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),a=new p);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(a){return ja.getNormal(this.a,this.b,this.c,a)},getPlane:function(a){void 0===a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new p);return a.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(a,b){return ja.getBarycoord(a,this.a,this.b,this.c,b)},containsPoint:function(a){return ja.containsPoint(a,
16207 this.a,this.b,this.c)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(){var a=new p,b=new p,c=new p,d=new p,e=new p,f=new p;return function(g,h){void 0===h&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),h=new p);var k=this.a,m=this.b,l=this.c;a.subVectors(m,k);b.subVectors(l,k);d.subVectors(g,k);var n=a.dot(d),t=b.dot(d);if(0>=n&&0>=t)return h.copy(k);e.subVectors(g,m);var u=a.dot(e),r=b.dot(e);if(0<=u&&r<=u)return h.copy(m);
16208 var v=n*r-u*t;if(0>=v&&0<=n&&0>=u)return m=n/(n-u),h.copy(k).addScaledVector(a,m);f.subVectors(g,l);g=a.dot(f);var y=b.dot(f);if(0<=y&&g<=y)return h.copy(l);n=g*t-n*y;if(0>=n&&0<=t&&0>=y)return v=t/(t-y),h.copy(k).addScaledVector(b,v);t=u*y-g*r;if(0>=t&&0<=r-u&&0<=g-y)return c.subVectors(l,m),v=(r-u)/(r-u+(g-y)),h.copy(m).addScaledVector(c,v);l=1/(t+n+v);m=n*l;v*=l;return h.copy(k).addScaledVector(a,m).addScaledVector(b,v)}}(),equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});
16209 la.prototype=Object.assign(Object.create(D.prototype),{constructor:la,isMesh:!0,setDrawMode:function(a){this.drawMode=a},copy:function(a){D.prototype.copy.call(this,a);this.drawMode=a.drawMode;void 0!==a.morphTargetInfluences&&(this.morphTargetInfluences=a.morphTargetInfluences.slice());void 0!==a.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},a.morphTargetDictionary));return this},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=a.morphAttributes;var b=
16210 Object.keys(a);if(0<b.length){var c=a[b[0]];if(void 0!==c)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},a=0,b=c.length;a<b;a++){var d=c[a].name||String(a);this.morphTargetInfluences.push(0);this.morphTargetDictionary[d]=a}}}else if(c=a.morphTargets,void 0!==c&&0<c.length)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},a=0,b=c.length;a<b;a++)d=c[a].name||String(a),this.morphTargetInfluences.push(0),this.morphTargetDictionary[d]=a},raycast:function(){function a(a,b,
16211 c,d,e,f,g){ja.getBarycoord(a,b,c,d,v);e.multiplyScalar(v.x);f.multiplyScalar(v.y);g.multiplyScalar(v.z);e.add(f).add(g);return e.clone()}function b(a,b,c,d,e,f,g,h){if(null===(1===b.side?d.intersectTriangle(g,f,e,!0,h):d.intersectTriangle(e,f,g,2!==b.side,h)))return null;x.copy(h);x.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(x);return b<c.near||b>c.far?null:{distance:b,point:x.clone(),object:a}}function c(c,d,e,f,m,l,n,q,p){g.fromBufferAttribute(m,n);h.fromBufferAttribute(m,q);k.fromBufferAttribute(m,
16212 p);if(c=b(c,d,e,f,g,h,k,y))l&&(t.fromBufferAttribute(l,n),u.fromBufferAttribute(l,q),r.fromBufferAttribute(l,p),c.uv=a(y,g,h,k,t,u,r)),l=new Ta(n,q,p),ja.getNormal(g,h,k,l.normal),c.face=l;return c}var d=new I,e=new mb,f=new Da,g=new p,h=new p,k=new p,m=new p,l=new p,n=new p,t=new z,u=new z,r=new z,v=new p,y=new p,x=new p;return function(q,p){var v=this.geometry,w=this.material,x=this.matrixWorld;if(void 0!==w&&(null===v.boundingSphere&&v.computeBoundingSphere(),f.copy(v.boundingSphere),f.applyMatrix4(x),
16213 !1!==q.ray.intersectsSphere(f)&&(d.getInverse(x),e.copy(q.ray).applyMatrix4(d),null===v.boundingBox||!1!==e.intersectsBox(v.boundingBox))))if(v.isBufferGeometry){var z=v.index,B=v.attributes.position,A=v.attributes.uv,D=v.groups;v=v.drawRange;var C;if(null!==z)if(Array.isArray(w)){var H=0;for(C=D.length;H<C;H++){var G=D[H];var K=w[G.materialIndex];x=Math.max(G.start,v.start);var L=Math.min(G.start+G.count,v.start+v.count);for(G=x;G<L;G+=3){x=z.getX(G);var I=z.getX(G+1);var J=z.getX(G+2);if(x=c(this,
16214 K,q,e,B,A,x,I,J))x.faceIndex=Math.floor(G/3),p.push(x)}}}else for(x=Math.max(0,v.start),L=Math.min(z.count,v.start+v.count),H=x,C=L;H<C;H+=3){if(x=z.getX(H),I=z.getX(H+1),J=z.getX(H+2),x=c(this,w,q,e,B,A,x,I,J))x.faceIndex=Math.floor(H/3),p.push(x)}else if(void 0!==B)if(Array.isArray(w))for(H=0,C=D.length;H<C;H++)for(G=D[H],K=w[G.materialIndex],x=Math.max(G.start,v.start),L=Math.min(G.start+G.count,v.start+v.count),G=x;G<L;G+=3){if(x=G,I=G+1,J=G+2,x=c(this,K,q,e,B,A,x,I,J))x.faceIndex=Math.floor(G/
16215 3),p.push(x)}else for(x=Math.max(0,v.start),L=Math.min(B.count,v.start+v.count),H=x,C=L;H<C;H+=3)if(x=H,I=H+1,J=H+2,x=c(this,w,q,e,B,A,x,I,J))x.faceIndex=Math.floor(H/3),p.push(x)}else if(v.isGeometry)for(B=Array.isArray(w),A=v.vertices,D=v.faces,x=v.faceVertexUvs[0],0<x.length&&(z=x),G=0,L=D.length;G<L;G++)if(I=D[G],x=B?w[I.materialIndex]:w,void 0!==x){H=A[I.a];C=A[I.b];K=A[I.c];if(!0===x.morphTargets){J=v.morphTargets;var R=this.morphTargetInfluences;g.set(0,0,0);h.set(0,0,0);k.set(0,0,0);for(var Q=
16216 0,S=J.length;Q<S;Q++){var T=R[Q];if(0!==T){var V=J[Q].vertices;g.addScaledVector(m.subVectors(V[I.a],H),T);h.addScaledVector(l.subVectors(V[I.b],C),T);k.addScaledVector(n.subVectors(V[I.c],K),T)}}g.add(H);h.add(C);k.add(K);H=g;C=h;K=k}if(x=b(this,x,q,e,H,C,K,y))z&&z[G]&&(J=z[G],t.copy(J[0]),u.copy(J[1]),r.copy(J[2]),x.uv=a(y,H,C,K,t,u,r)),x.face=I,x.faceIndex=G,p.push(x)}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});Ua.prototype=Object.create(T.prototype);
16217 Ua.prototype.constructor=Ua;Ua.prototype.isCubeTexture=!0;Object.defineProperty(Ua.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});var Me=new T,Ne=new Ua,Ge=[],Ie=[],Le=new Float32Array(16),Ke=new Float32Array(9),Je=new Float32Array(4);Re.prototype.updateCache=function(a){var b=this.cache;a instanceof Float32Array&&b.length!==a.length&&(this.cache=new Float32Array(a.length));qa(b,a)};Se.prototype.setValue=function(a,b,c){for(var d=this.seq,e=0,f=d.length;e!==
16218 f;++e){var g=d[e];g.setValue(a,b[g.id],c)}};var Vd=/([\w\d_]+)(\])?(\[|\.)?/g;Za.prototype.setValue=function(a,b,c){b=this.map[b];void 0!==b&&b.setValue(a,c,this.renderer)};Za.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};Za.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};Za.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in b&&c.push(f)}return c};var yg=
16219 0,Hg=0;$a.prototype=Object.create(J.prototype);$a.prototype.constructor=$a;$a.prototype.isMeshDepthMaterial=!0;$a.prototype.copy=function(a){J.prototype.copy.call(this,a);this.depthPacking=a.depthPacking;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};
16220 ab.prototype=Object.create(J.prototype);ab.prototype.constructor=ab;ab.prototype.isMeshDistanceMaterial=!0;ab.prototype.copy=function(a){J.prototype.copy.call(this,a);this.referencePosition.copy(a.referencePosition);this.nearDistance=a.nearDistance;this.farDistance=a.farDistance;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;
16221 return this};Kb.prototype=Object.assign(Object.create(D.prototype),{constructor:Kb,isGroup:!0});Z.prototype=Object.assign(Object.create(Na.prototype),{constructor:Z,isPerspectiveCamera:!0,copy:function(a,b){Na.prototype.copy.call(this,a,b);this.fov=a.fov;this.zoom=a.zoom;this.near=a.near;this.far=a.far;this.focus=a.focus;this.aspect=a.aspect;this.view=null===a.view?null:Object.assign({},a.view);this.filmGauge=a.filmGauge;this.filmOffset=a.filmOffset;return this},setFocalLength:function(a){a=.5*this.getFilmHeight()/
16222 a;this.fov=2*H.RAD2DEG*Math.atan(a);this.updateProjectionMatrix()},getFocalLength:function(){var a=Math.tan(.5*H.DEG2RAD*this.fov);return.5*this.getFilmHeight()/a},getEffectiveFOV:function(){return 2*H.RAD2DEG*Math.atan(Math.tan(.5*H.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(a,b,c,d,e,f){this.aspect=a/b;null===this.view&&(this.view={enabled:!0,fullWidth:1,
16223 fullHeight:1,offsetX:0,offsetY:0,width:1,height:1});this.view.enabled=!0;this.view.fullWidth=a;this.view.fullHeight=b;this.view.offsetX=c;this.view.offsetY=d;this.view.width=e;this.view.height=f;this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1);this.updateProjectionMatrix()},updateProjectionMatrix:function(){var a=this.near,b=a*Math.tan(.5*H.DEG2RAD*this.fov)/this.zoom,c=2*b,d=this.aspect*c,e=-.5*d,f=this.view;if(null!==this.view&&this.view.enabled){var g=
16224 f.fullWidth,h=f.fullHeight;e+=f.offsetX*d/g;b-=f.offsetY*c/h;d*=f.width/g;c*=f.height/h}f=this.filmOffset;0!==f&&(e+=a*f/this.getFilmWidth());this.projectionMatrix.makePerspective(e,e+d,b,b-c,a,this.far)},toJSON:function(a){a=D.prototype.toJSON.call(this,a);a.object.fov=this.fov;a.object.zoom=this.zoom;a.object.near=this.near;a.object.far=this.far;a.object.focus=this.focus;a.object.aspect=this.aspect;null!==this.view&&(a.object.view=Object.assign({},this.view));a.object.filmGauge=this.filmGauge;a.object.filmOffset=
16225 this.filmOffset;return a}});yc.prototype=Object.assign(Object.create(Z.prototype),{constructor:yc,isArrayCamera:!0});Lb.prototype.isFogExp2=!0;Lb.prototype.clone=function(){return new Lb(this.color,this.density)};Lb.prototype.toJSON=function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}};Mb.prototype.isFog=!0;Mb.prototype.clone=function(){return new Mb(this.color,this.near,this.far)};Mb.prototype.toJSON=function(){return{type:"Fog",color:this.color.getHex(),near:this.near,
16226 far:this.far}};qd.prototype=Object.assign(Object.create(D.prototype),{constructor:qd,copy:function(a,b){D.prototype.copy.call(this,a,b);null!==a.background&&(this.background=a.background.clone());null!==a.fog&&(this.fog=a.fog.clone());null!==a.overrideMaterial&&(this.overrideMaterial=a.overrideMaterial.clone());this.autoUpdate=a.autoUpdate;this.matrixAutoUpdate=a.matrixAutoUpdate;return this},toJSON:function(a){var b=D.prototype.toJSON.call(this,a);null!==this.background&&(b.object.background=this.background.toJSON(a));
16227 null!==this.fog&&(b.object.fog=this.fog.toJSON());return b}});Object.defineProperty(ob.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(ob.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setArray:function(a){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==a?a.length/this.stride:0;this.array=a;return this},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.array=
16228 new a.array.constructor(a.array);this.count=a.count;this.stride=a.stride;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.stride;c*=b.stride;for(var d=0,e=this.stride;d<e;d++)this.array[a+d]=b.array[c+d];return this},set:function(a,b){void 0===b&&(b=0);this.array.set(a,b);return this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(a){this.onUploadCallback=a;return this}});Object.defineProperties(zc.prototype,{count:{get:function(){return this.data.count}},
16229 array:{get:function(){return this.data.array}}});Object.assign(zc.prototype,{isInterleavedBufferAttribute:!0,setX:function(a,b){this.data.array[a*this.data.stride+this.offset]=b;return this},setY:function(a,b){this.data.array[a*this.data.stride+this.offset+1]=b;return this},setZ:function(a,b){this.data.array[a*this.data.stride+this.offset+2]=b;return this},setW:function(a,b){this.data.array[a*this.data.stride+this.offset+3]=b;return this},getX:function(a){return this.data.array[a*this.data.stride+
16230 this.offset]},getY:function(a){return this.data.array[a*this.data.stride+this.offset+1]},getZ:function(a){return this.data.array[a*this.data.stride+this.offset+2]},getW:function(a){return this.data.array[a*this.data.stride+this.offset+3]},setXY:function(a,b,c){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;return this},setXYZ:function(a,b,c,d){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;this.data.array[a+2]=d;return this},setXYZW:function(a,
16231 b,c,d,e){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;this.data.array[a+2]=d;this.data.array[a+3]=e;return this}});cb.prototype=Object.create(J.prototype);cb.prototype.constructor=cb;cb.prototype.isSpriteMaterial=!0;cb.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.rotation=a.rotation;return this};var Nb;Ac.prototype=Object.assign(Object.create(D.prototype),{constructor:Ac,isSprite:!0,raycast:function(){function a(a,
16232 b,c,d,h,k){e.subVectors(a,c).addScalar(.5).multiply(d);void 0!==h?(f.x=k*e.x-h*e.y,f.y=h*e.x+k*e.y):f.copy(e);a.copy(b);a.x+=f.x;a.y+=f.y;a.applyMatrix4(g)}var b=new p,c=new p,d=new p,e=new z,f=new z,g=new I,h=new p,k=new p,m=new p;return function(e,f){c.setFromMatrixScale(this.matrixWorld);g.getInverse(this.modelViewMatrix).premultiply(this.matrixWorld);d.setFromMatrixPosition(this.modelViewMatrix);var l=this.material.rotation;if(0!==l){var n=Math.cos(l);var q=Math.sin(l)}l=this.center;a(h.set(-.5,
16233 -.5,0),d,l,c,q,n);a(k.set(.5,-.5,0),d,l,c,q,n);a(m.set(.5,.5,0),d,l,c,q,n);var p=e.ray.intersectTriangle(h,k,m,!1,b);if(null===p&&(a(k.set(-.5,.5,0),d,l,c,q,n),p=e.ray.intersectTriangle(h,m,k,!1,b),null===p))return;q=e.ray.origin.distanceTo(b);q<e.near||q>e.far||f.push({distance:q,point:b.clone(),face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)},copy:function(a){D.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}});
16234 Bc.prototype=Object.assign(Object.create(D.prototype),{constructor:Bc,copy:function(a){D.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b<c;b++){var d=a[b];this.addLevel(d.object.clone(),d.distance)}return this},addLevel:function(a,b){void 0===b&&(b=0);b=Math.abs(b);for(var c=this.levels,d=0;d<c.length&&!(b<c[d].distance);d++);c.splice(d,0,{distance:b,object:a});this.add(a)},getObjectForDistance:function(a){for(var b=this.levels,c=1,d=b.length;c<d&&!(a<b[c].distance);c++);return b[c-
16235 1].object},raycast:function(){var a=new p;return function(b,c){a.setFromMatrixPosition(this.matrixWorld);var d=b.ray.origin.distanceTo(a);this.getObjectForDistance(d).raycast(b,c)}}(),update:function(){var a=new p,b=new p;return function(c){var d=this.levels;if(1<d.length){a.setFromMatrixPosition(c.matrixWorld);b.setFromMatrixPosition(this.matrixWorld);c=a.distanceTo(b);d[0].object.visible=!0;for(var e=1,f=d.length;e<f;e++)if(c>=d[e].distance)d[e-1].object.visible=!1,d[e].object.visible=!0;else break;
16236 for(;e<f;e++)d[e].object.visible=!1}}}(),toJSON:function(a){a=D.prototype.toJSON.call(this,a);a.object.levels=[];for(var b=this.levels,c=0,d=b.length;c<d;c++){var e=b[c];a.object.levels.push({object:e.object.uuid,distance:e.distance})}return a}});Object.assign(Cc.prototype,{calculateInverses:function(){this.boneInverses=[];for(var a=0,b=this.bones.length;a<b;a++){var c=new I;this.bones[a]&&c.getInverse(this.bones[a].matrixWorld);this.boneInverses.push(c)}},pose:function(){var a,b;var c=0;for(b=this.bones.length;c<
16237 b;c++)(a=this.bones[c])&&a.matrixWorld.getInverse(this.boneInverses[c]);c=0;for(b=this.bones.length;c<b;c++)if(a=this.bones[c])a.parent&&a.parent.isBone?(a.matrix.getInverse(a.parent.matrixWorld),a.matrix.multiply(a.matrixWorld)):a.matrix.copy(a.matrixWorld),a.matrix.decompose(a.position,a.quaternion,a.scale)},update:function(){var a=new I,b=new I;return function(){for(var c=this.bones,d=this.boneInverses,e=this.boneMatrices,f=this.boneTexture,g=0,h=c.length;g<h;g++)a.multiplyMatrices(c[g]?c[g].matrixWorld:
16238 b,d[g]),a.toArray(e,16*g);void 0!==f&&(f.needsUpdate=!0)}}(),clone:function(){return new Cc(this.bones,this.boneInverses)},getBoneByName:function(a){for(var b=0,c=this.bones.length;b<c;b++){var d=this.bones[b];if(d.name===a)return d}}});rd.prototype=Object.assign(Object.create(D.prototype),{constructor:rd,isBone:!0});sd.prototype=Object.assign(Object.create(la.prototype),{constructor:sd,isSkinnedMesh:!0,initBones:function(){var a=[],b;if(this.geometry&&void 0!==this.geometry.bones){var c=0;for(b=
16239 this.geometry.bones.length;c<b;c++){var d=this.geometry.bones[c];var e=new rd;a.push(e);e.name=d.name;e.position.fromArray(d.pos);e.quaternion.fromArray(d.rotq);void 0!==d.scl&&e.scale.fromArray(d.scl)}c=0;for(b=this.geometry.bones.length;c<b;c++)d=this.geometry.bones[c],-1!==d.parent&&null!==d.parent&&void 0!==a[d.parent]?a[d.parent].add(a[c]):this.add(a[c])}this.updateMatrixWorld(!0);return a},bind:function(a,b){this.skeleton=a;void 0===b&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),
16240 b=this.matrixWorld);this.bindMatrix.copy(b);this.bindMatrixInverse.getInverse(b)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){var a;if(this.geometry&&this.geometry.isGeometry)for(a=0;a<this.geometry.skinWeights.length;a++){var b=this.geometry.skinWeights[a];var c=1/b.manhattanLength();Infinity!==c?b.multiplyScalar(c):b.set(1,0,0,0)}else if(this.geometry&&this.geometry.isBufferGeometry){b=new V;var d=this.geometry.attributes.skinWeight;for(a=0;a<d.count;a++)b.x=d.getX(a),
16241 b.y=d.getY(a),b.z=d.getZ(a),b.w=d.getW(a),c=1/b.manhattanLength(),Infinity!==c?b.multiplyScalar(c):b.set(1,0,0,0),d.setXYZW(a,b.x,b.y,b.z,b.w)}},updateMatrixWorld:function(a){la.prototype.updateMatrixWorld.call(this,a);"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return(new this.constructor(this.geometry,
16242 this.material)).copy(this)}});Y.prototype=Object.create(J.prototype);Y.prototype.constructor=Y;Y.prototype.isLineBasicMaterial=!0;Y.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.linecap=a.linecap;this.linejoin=a.linejoin;return this};sa.prototype=Object.assign(Object.create(D.prototype),{constructor:sa,isLine:!0,computeLineDistances:function(){var a=new p,b=new p;return function(){var c=this.geometry;if(c.isBufferGeometry)if(null===
16243 c.index){for(var d=c.attributes.position,e=[0],f=1,g=d.count;f<g;f++)a.fromBufferAttribute(d,f-1),b.fromBufferAttribute(d,f),e[f]=e[f-1],e[f]+=a.distanceTo(b);c.addAttribute("lineDistance",new A(e,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(c.isGeometry)for(d=c.vertices,e=c.lineDistances,e[0]=0,f=1,g=d.length;f<g;f++)e[f]=e[f-1],e[f]+=d[f-1].distanceTo(d[f]);return this}}(),raycast:function(){var a=new I,b=new mb,c=
16244 new Da;return function(d,e){var f=d.linePrecision;f*=f;var g=this.geometry,h=this.matrixWorld;null===g.boundingSphere&&g.computeBoundingSphere();c.copy(g.boundingSphere);c.applyMatrix4(h);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(h);b.copy(d.ray).applyMatrix4(a);var k=new p,m=new p;h=new p;var l=new p,n=this&&this.isLineSegments?2:1;if(g.isBufferGeometry){var t=g.index,u=g.attributes.position.array;if(null!==t){t=t.array;g=0;for(var r=t.length-1;g<r;g+=n){var v=t[g+1];k.fromArray(u,3*t[g]);
16245 m.fromArray(u,3*v);v=b.distanceSqToSegment(k,m,l,h);v>f||(l.applyMatrix4(this.matrixWorld),v=d.ray.origin.distanceTo(l),v<d.near||v>d.far||e.push({distance:v,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}else for(g=0,r=u.length/3-1;g<r;g+=n)k.fromArray(u,3*g),m.fromArray(u,3*g+3),v=b.distanceSqToSegment(k,m,l,h),v>f||(l.applyMatrix4(this.matrixWorld),v=d.ray.origin.distanceTo(l),v<d.near||v>d.far||e.push({distance:v,point:h.clone().applyMatrix4(this.matrixWorld),
16246 index:g,face:null,faceIndex:null,object:this}))}else if(g.isGeometry)for(k=g.vertices,m=k.length,g=0;g<m-1;g+=n)v=b.distanceSqToSegment(k[g],k[g+1],l,h),v>f||(l.applyMatrix4(this.matrixWorld),v=d.ray.origin.distanceTo(l),v<d.near||v>d.far||e.push({distance:v,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});W.prototype=Object.assign(Object.create(sa.prototype),
16247 {constructor:W,isLineSegments:!0,computeLineDistances:function(){var a=new p,b=new p;return function(){var c=this.geometry;if(c.isBufferGeometry)if(null===c.index){for(var d=c.attributes.position,e=[],f=0,g=d.count;f<g;f+=2)a.fromBufferAttribute(d,f),b.fromBufferAttribute(d,f+1),e[f]=0===f?0:e[f-1],e[f+1]=e[f]+a.distanceTo(b);c.addAttribute("lineDistance",new A(e,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(c.isGeometry)for(d=
16248 c.vertices,e=c.lineDistances,f=0,g=d.length;f<g;f+=2)a.copy(d[f]),b.copy(d[f+1]),e[f]=0===f?0:e[f-1],e[f+1]=e[f]+a.distanceTo(b);return this}}()});td.prototype=Object.assign(Object.create(sa.prototype),{constructor:td,isLineLoop:!0});Ea.prototype=Object.create(J.prototype);Ea.prototype.constructor=Ea;Ea.prototype.isPointsMaterial=!0;Ea.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;this.morphTargets=
16249 a.morphTargets;return this};Ob.prototype=Object.assign(Object.create(D.prototype),{constructor:Ob,isPoints:!0,raycast:function(){var a=new I,b=new mb,c=new Da;return function(d,e){function f(a,c){var f=b.distanceSqToPoint(a);f<l&&(b.closestPointToPoint(a,n),n.applyMatrix4(k),a=d.ray.origin.distanceTo(n),a<d.near||a>d.far||e.push({distance:a,distanceToRay:Math.sqrt(f),point:n.clone(),index:c,face:null,object:g}))}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold;null===h.boundingSphere&&
16250 h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);c.radius+=m;if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);m/=(this.scale.x+this.scale.y+this.scale.z)/3;var l=m*m;m=new p;var n=new p;if(h.isBufferGeometry){var t=h.index;h=h.attributes.position.array;if(null!==t){var u=t.array;t=0;for(var r=u.length;t<r;t++){var v=u[t];m.fromArray(h,3*v);f(m,v)}}else for(t=0,u=h.length/3;t<u;t++)m.fromArray(h,3*t),f(m,t)}else for(m=h.vertices,t=0,u=m.length;t<
16251 u;t++)f(m[t],t)}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});$d.prototype=Object.assign(Object.create(T.prototype),{constructor:$d,isVideoTexture:!0,update:function(){var a=this.image;a.readyState>=a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Pb.prototype=Object.create(T.prototype);Pb.prototype.constructor=Pb;Pb.prototype.isCompressedTexture=!0;Dc.prototype=Object.create(T.prototype);Dc.prototype.constructor=Dc;Dc.prototype.isCanvasTexture=!0;Ec.prototype=
16252 Object.create(T.prototype);Ec.prototype.constructor=Ec;Ec.prototype.isDepthTexture=!0;Qb.prototype=Object.create(C.prototype);Qb.prototype.constructor=Qb;Fc.prototype=Object.create(R.prototype);Fc.prototype.constructor=Fc;Rb.prototype=Object.create(C.prototype);Rb.prototype.constructor=Rb;Gc.prototype=Object.create(R.prototype);Gc.prototype.constructor=Gc;na.prototype=Object.create(C.prototype);na.prototype.constructor=na;Hc.prototype=Object.create(R.prototype);Hc.prototype.constructor=Hc;Sb.prototype=
16253 Object.create(na.prototype);Sb.prototype.constructor=Sb;Ic.prototype=Object.create(R.prototype);Ic.prototype.constructor=Ic;pb.prototype=Object.create(na.prototype);pb.prototype.constructor=pb;Jc.prototype=Object.create(R.prototype);Jc.prototype.constructor=Jc;Tb.prototype=Object.create(na.prototype);Tb.prototype.constructor=Tb;Kc.prototype=Object.create(R.prototype);Kc.prototype.constructor=Kc;Ub.prototype=Object.create(na.prototype);Ub.prototype.constructor=Ub;Lc.prototype=Object.create(R.prototype);
16254 Lc.prototype.constructor=Lc;Vb.prototype=Object.create(C.prototype);Vb.prototype.constructor=Vb;Mc.prototype=Object.create(R.prototype);Mc.prototype.constructor=Mc;Wb.prototype=Object.create(C.prototype);Wb.prototype.constructor=Wb;Nc.prototype=Object.create(R.prototype);Nc.prototype.constructor=Nc;Xb.prototype=Object.create(C.prototype);Xb.prototype.constructor=Xb;var Ug={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=bf(a,0,e,c,!0),g=[];if(!f)return g;var h;if(d){var k=
16255 c;d=[];var m;var l=0;for(m=b.length;l<m;l++){var n=b[l]*k;var t=l<m-1?b[l+1]*k:a.length;n=bf(a,n,t,k,!1);n===n.next&&(n.steiner=!0);d.push(Pg(n))}d.sort(Ng);for(l=0;l<d.length;l++){b=d[l];k=f;if(k=Og(b,k))b=ef(k,b),Pc(b,b.next);f=Pc(f,f.next)}}if(a.length>80*c){var p=h=a[0];var r=d=a[1];for(k=c;k<e;k+=c)l=a[k],b=a[k+1],l<p&&(p=l),b<r&&(r=b),l>h&&(h=l),b>d&&(d=b);h=Math.max(h-p,d-r);h=0!==h?1/h:0}Qc(f,g,c,p,r,h);return g}},Va={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;e<b;d=e++)c+=a[d].x*a[e].y-
16256 a[e].x*a[d].y;return.5*c},isClockWise:function(a){return 0>Va.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];ff(a);gf(c,a);var f=a.length;b.forEach(ff);for(a=0;a<b.length;a++)d.push(f),f+=b[a].length,gf(c,b[a]);b=Ug.triangulate(c,d);for(a=0;a<b.length;a+=3)e.push(b.slice(a,a+3));return e}};rb.prototype=Object.create(R.prototype);rb.prototype.constructor=rb;rb.prototype.toJSON=function(){var a=R.prototype.toJSON.call(this);return hf(this.parameters.shapes,this.parameters.options,a)};Oa.prototype=
16257 Object.create(C.prototype);Oa.prototype.constructor=Oa;Oa.prototype.toJSON=function(){var a=C.prototype.toJSON.call(this);return hf(this.parameters.shapes,this.parameters.options,a)};var Qg={generateTopUV:function(a,b,c,d,e){a=b[3*d];d=b[3*d+1];var f=b[3*e];e=b[3*e+1];return[new z(b[3*c],b[3*c+1]),new z(a,d),new z(f,e)]},generateSideWallUV:function(a,b,c,d,e,f){a=b[3*c];var g=b[3*c+1];c=b[3*c+2];var h=b[3*d],k=b[3*d+1];d=b[3*d+2];var m=b[3*e],l=b[3*e+1];e=b[3*e+2];var n=b[3*f],t=b[3*f+1];b=b[3*f+
16258 2];return.01>Math.abs(g-k)?[new z(a,1-c),new z(h,1-d),new z(m,1-e),new z(n,1-b)]:[new z(g,1-c),new z(k,1-d),new z(l,1-e),new z(t,1-b)]}};Sc.prototype=Object.create(R.prototype);Sc.prototype.constructor=Sc;Yb.prototype=Object.create(Oa.prototype);Yb.prototype.constructor=Yb;Tc.prototype=Object.create(R.prototype);Tc.prototype.constructor=Tc;sb.prototype=Object.create(C.prototype);sb.prototype.constructor=sb;Uc.prototype=Object.create(R.prototype);Uc.prototype.constructor=Uc;Zb.prototype=Object.create(C.prototype);
16259 Zb.prototype.constructor=Zb;Vc.prototype=Object.create(R.prototype);Vc.prototype.constructor=Vc;$b.prototype=Object.create(C.prototype);$b.prototype.constructor=$b;tb.prototype=Object.create(R.prototype);tb.prototype.constructor=tb;tb.prototype.toJSON=function(){var a=R.prototype.toJSON.call(this);return jf(this.parameters.shapes,a)};ub.prototype=Object.create(C.prototype);ub.prototype.constructor=ub;ub.prototype.toJSON=function(){var a=C.prototype.toJSON.call(this);return jf(this.parameters.shapes,
16260 a)};ac.prototype=Object.create(C.prototype);ac.prototype.constructor=ac;vb.prototype=Object.create(R.prototype);vb.prototype.constructor=vb;Wa.prototype=Object.create(C.prototype);Wa.prototype.constructor=Wa;Wc.prototype=Object.create(vb.prototype);Wc.prototype.constructor=Wc;Xc.prototype=Object.create(Wa.prototype);Xc.prototype.constructor=Xc;Yc.prototype=Object.create(R.prototype);Yc.prototype.constructor=Yc;bc.prototype=Object.create(C.prototype);bc.prototype.constructor=bc;var xa=Object.freeze({WireframeGeometry:Qb,
16261 ParametricGeometry:Fc,ParametricBufferGeometry:Rb,TetrahedronGeometry:Hc,TetrahedronBufferGeometry:Sb,OctahedronGeometry:Ic,OctahedronBufferGeometry:pb,IcosahedronGeometry:Jc,IcosahedronBufferGeometry:Tb,DodecahedronGeometry:Kc,DodecahedronBufferGeometry:Ub,PolyhedronGeometry:Gc,PolyhedronBufferGeometry:na,TubeGeometry:Lc,TubeBufferGeometry:Vb,TorusKnotGeometry:Mc,TorusKnotBufferGeometry:Wb,TorusGeometry:Nc,TorusBufferGeometry:Xb,TextGeometry:Sc,TextBufferGeometry:Yb,SphereGeometry:Tc,SphereBufferGeometry:sb,
16262 RingGeometry:Uc,RingBufferGeometry:Zb,PlaneGeometry:uc,PlaneBufferGeometry:lb,LatheGeometry:Vc,LatheBufferGeometry:$b,ShapeGeometry:tb,ShapeBufferGeometry:ub,ExtrudeGeometry:rb,ExtrudeBufferGeometry:Oa,EdgesGeometry:ac,ConeGeometry:Wc,ConeBufferGeometry:Xc,CylinderGeometry:vb,CylinderBufferGeometry:Wa,CircleGeometry:Yc,CircleBufferGeometry:bc,BoxGeometry:Ib,BoxBufferGeometry:kb});wb.prototype=Object.create(J.prototype);wb.prototype.constructor=wb;wb.prototype.isShadowMaterial=!0;wb.prototype.copy=
16263 function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);return this};cc.prototype=Object.create(ta.prototype);cc.prototype.constructor=cc;cc.prototype.isRawShaderMaterial=!0;Pa.prototype=Object.create(J.prototype);Pa.prototype.constructor=Pa;Pa.prototype.isMeshStandardMaterial=!0;Pa.prototype.copy=function(a){J.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=
16264 a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=
16265 a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};xb.prototype=Object.create(Pa.prototype);xb.prototype.constructor=xb;xb.prototype.isMeshPhysicalMaterial=
16266 !0;xb.prototype.copy=function(a){Pa.prototype.copy.call(this,a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearCoat=a.clearCoat;this.clearCoatRoughness=a.clearCoatRoughness;return this};Fa.prototype=Object.create(J.prototype);Fa.prototype.constructor=Fa;Fa.prototype.isMeshPhongMaterial=!0;Fa.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=
16267 a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;
16268 this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};yb.prototype=Object.create(Fa.prototype);yb.prototype.constructor=yb;yb.prototype.isMeshToonMaterial=!0;yb.prototype.copy=function(a){Fa.prototype.copy.call(this,
16269 a);this.gradientMap=a.gradientMap;return this};zb.prototype=Object.create(J.prototype);zb.prototype.constructor=zb;zb.prototype.isMeshNormalMaterial=!0;zb.prototype.copy=function(a){J.prototype.copy.call(this,a);this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;
16270 this.wireframeLinewidth=a.wireframeLinewidth;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Ab.prototype=Object.create(J.prototype);Ab.prototype.constructor=Ab;Ab.prototype.isMeshLambertMaterial=!0;Ab.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);
16271 this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};
16272 Bb.prototype=Object.create(Y.prototype);Bb.prototype.constructor=Bb;Bb.prototype.isLineDashedMaterial=!0;Bb.prototype.copy=function(a){Y.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var Vg=Object.freeze({ShadowMaterial:wb,SpriteMaterial:cb,RawShaderMaterial:cc,ShaderMaterial:ta,PointsMaterial:Ea,MeshPhysicalMaterial:xb,MeshStandardMaterial:Pa,MeshPhongMaterial:Fa,MeshToonMaterial:yb,MeshNormalMaterial:zb,MeshLambertMaterial:Ab,MeshDepthMaterial:$a,
16273 MeshDistanceMaterial:ab,MeshBasicMaterial:da,LineDashedMaterial:Bb,LineBasicMaterial:Y,Material:J}),Fb={enabled:!1,files:{},add:function(a,b){!1!==this.enabled&&(this.files[a]=b)},get:function(a){if(!1!==this.enabled)return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}},ka=new ce,Ya={};Object.assign(Ga.prototype,{load:function(a,b,c,d){void 0===a&&(a="");void 0!==this.path&&(a=this.path+a);a=this.manager.resolveURL(a);var e=this,f=Fb.get(a);if(void 0!==f)return e.manager.itemStart(a),
16274 setTimeout(function(){b&&b(f);e.manager.itemEnd(a)},0),f;if(void 0!==Ya[a])Ya[a].push({onLoad:b,onProgress:c,onError:d});else{var g=a.match(/^data:(.*?)(;base64)?,(.*)$/);if(g){c=g[1];var h=!!g[2];g=g[3];g=window.decodeURIComponent(g);h&&(g=window.atob(g));try{var k=(this.responseType||"").toLowerCase();switch(k){case "arraybuffer":case "blob":var m=new Uint8Array(g.length);for(h=0;h<g.length;h++)m[h]=g.charCodeAt(h);var l="blob"===k?new Blob([m.buffer],{type:c}):m.buffer;break;case "document":l=
16275 (new DOMParser).parseFromString(g,c);break;case "json":l=JSON.parse(g);break;default:l=g}window.setTimeout(function(){b&&b(l);e.manager.itemEnd(a)},0)}catch(t){window.setTimeout(function(){d&&d(t);e.manager.itemEnd(a);e.manager.itemError(a)},0)}}else{Ya[a]=[];Ya[a].push({onLoad:b,onProgress:c,onError:d});var n=new XMLHttpRequest;n.open("GET",a,!0);n.addEventListener("load",function(b){var c=this.response;Fb.add(a,c);var d=Ya[a];delete Ya[a];if(200===this.status||0===this.status){0===this.status&&
16276 console.warn("THREE.FileLoader: HTTP Status 0 received.");for(var f=0,g=d.length;f<g;f++){var h=d[f];if(h.onLoad)h.onLoad(c)}e.manager.itemEnd(a)}else{f=0;for(g=d.length;f<g;f++)if(h=d[f],h.onError)h.onError(b);e.manager.itemEnd(a);e.manager.itemError(a)}},!1);n.addEventListener("progress",function(b){for(var c=Ya[a],d=0,e=c.length;d<e;d++){var f=c[d];if(f.onProgress)f.onProgress(b)}},!1);n.addEventListener("error",function(b){var c=Ya[a];delete Ya[a];for(var d=0,f=c.length;d<f;d++){var g=c[d];if(g.onError)g.onError(b)}e.manager.itemEnd(a);
16277 e.manager.itemError(a)},!1);void 0!==this.responseType&&(n.responseType=this.responseType);void 0!==this.withCredentials&&(n.withCredentials=this.withCredentials);n.overrideMimeType&&n.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(h in this.requestHeader)n.setRequestHeader(h,this.requestHeader[h]);n.send(null)}e.manager.itemStart(a);return n}},setPath:function(a){this.path=a;return this},setResponseType:function(a){this.responseType=a;return this},setWithCredentials:function(a){this.withCredentials=
16278 a;return this},setMimeType:function(a){this.mimeType=a;return this},setRequestHeader:function(a){this.requestHeader=a;return this}});Object.assign(kf.prototype,{load:function(a,b,c,d){function e(e){k.load(a[e],function(a){a=f._parser(a,!0);g[e]={width:a.width,height:a.height,format:a.format,mipmaps:a.mipmaps};m+=1;6===m&&(1===a.mipmapCount&&(h.minFilter=1006),h.format=a.format,h.needsUpdate=!0,b&&b(h))},c,d)}var f=this,g=[],h=new Pb;h.image=g;var k=new Ga(this.manager);k.setPath(this.path);k.setResponseType("arraybuffer");
16279 if(Array.isArray(a))for(var m=0,l=0,n=a.length;l<n;++l)e(l);else k.load(a,function(a){a=f._parser(a,!0);if(a.isCubemap)for(var c=a.mipmaps.length/a.mipmapCount,d=0;d<c;d++){g[d]={mipmaps:[]};for(var e=0;e<a.mipmapCount;e++)g[d].mipmaps.push(a.mipmaps[d*a.mipmapCount+e]),g[d].format=a.format,g[d].width=a.width,g[d].height=a.height}else h.image.width=a.width,h.image.height=a.height,h.mipmaps=a.mipmaps;1===a.mipmapCount&&(h.minFilter=1006);h.format=a.format;h.needsUpdate=!0;b&&b(h)},c,d);return h},setPath:function(a){this.path=
16280 a;return this}});Object.assign(de.prototype,{load:function(a,b,c,d){var e=this,f=new gb,g=new Ga(this.manager);g.setResponseType("arraybuffer");g.load(a,function(a){if(a=e._parser(a))void 0!==a.image?f.image=a.image:void 0!==a.data&&(f.image.width=a.width,f.image.height=a.height,f.image.data=a.data),f.wrapS=void 0!==a.wrapS?a.wrapS:1001,f.wrapT=void 0!==a.wrapT?a.wrapT:1001,f.magFilter=void 0!==a.magFilter?a.magFilter:1006,f.minFilter=void 0!==a.minFilter?a.minFilter:1008,f.anisotropy=void 0!==a.anisotropy?
16281 a.anisotropy:1,void 0!==a.format&&(f.format=a.format),void 0!==a.type&&(f.type=a.type),void 0!==a.mipmaps&&(f.mipmaps=a.mipmaps),1===a.mipmapCount&&(f.minFilter=1006),f.needsUpdate=!0,b&&b(f,a)},c,d);return f}});Object.assign(Zc.prototype,{crossOrigin:"anonymous",load:function(a,b,c,d){function e(){k.removeEventListener("load",e,!1);k.removeEventListener("error",f,!1);Fb.add(a,this);b&&b(this);g.manager.itemEnd(a)}function f(b){k.removeEventListener("load",e,!1);k.removeEventListener("error",f,!1);
16282 d&&d(b);g.manager.itemEnd(a);g.manager.itemError(a)}void 0===a&&(a="");void 0!==this.path&&(a=this.path+a);a=this.manager.resolveURL(a);var g=this,h=Fb.get(a);if(void 0!==h)return g.manager.itemStart(a),setTimeout(function(){b&&b(h);g.manager.itemEnd(a)},0),h;var k=document.createElementNS("http://www.w3.org/1999/xhtml","img");k.addEventListener("load",e,!1);k.addEventListener("error",f,!1);"data:"!==a.substr(0,5)&&void 0!==this.crossOrigin&&(k.crossOrigin=this.crossOrigin);g.manager.itemStart(a);
16283 k.src=a;return k},setCrossOrigin:function(a){this.crossOrigin=a;return this},setPath:function(a){this.path=a;return this}});Object.assign(ee.prototype,{crossOrigin:"anonymous",load:function(a,b,c,d){function e(c){g.load(a[c],function(a){f.images[c]=a;h++;6===h&&(f.needsUpdate=!0,b&&b(f))},void 0,d)}var f=new Ua,g=new Zc(this.manager);g.setCrossOrigin(this.crossOrigin);g.setPath(this.path);var h=0;for(c=0;c<a.length;++c)e(c);return f},setCrossOrigin:function(a){this.crossOrigin=a;return this},setPath:function(a){this.path=
16284 a;return this}});Object.assign(vd.prototype,{crossOrigin:"anonymous",load:function(a,b,c,d){var e=new T,f=new Zc(this.manager);f.setCrossOrigin(this.crossOrigin);f.setPath(this.path);f.load(a,function(c){e.image=c;c=0<a.search(/\.(jpg|jpeg)$/)||0===a.search(/^data:image\/jpeg/);e.format=c?1022:1023;e.needsUpdate=!0;void 0!==b&&b(e)},c,d);return e},setCrossOrigin:function(a){this.crossOrigin=a;return this},setPath:function(a){this.path=a;return this}});Object.assign(L.prototype,{getPoint:function(){console.warn("THREE.Curve: .getPoint() not implemented.");
16285 return null},getPointAt:function(a,b){a=this.getUtoTmapping(a);return this.getPoint(a,b)},getPoints:function(a){void 0===a&&(a=5);for(var b=[],c=0;c<=a;c++)b.push(this.getPoint(c/a));return b},getSpacedPoints:function(a){void 0===a&&(a=5);for(var b=[],c=0;c<=a;c++)b.push(this.getPointAt(c/a));return b},getLength:function(){var a=this.getLengths();return a[a.length-1]},getLengths:function(a){void 0===a&&(a=this.arcLengthDivisions);if(this.cacheArcLengths&&this.cacheArcLengths.length===a+1&&!this.needsUpdate)return this.cacheArcLengths;
16286 this.needsUpdate=!1;var b=[],c=this.getPoint(0),d,e=0;b.push(0);for(d=1;d<=a;d++){var f=this.getPoint(d/a);e+=f.distanceTo(c);b.push(e);c=f}return this.cacheArcLengths=b},updateArcLengths:function(){this.needsUpdate=!0;this.getLengths()},getUtoTmapping:function(a,b){var c=this.getLengths(),d=c.length;b=b?b:a*c[d-1];for(var e=0,f=d-1,g;e<=f;)if(a=Math.floor(e+(f-e)/2),g=c[a]-b,0>g)e=a+1;else if(0<g)f=a-1;else{f=a;break}a=f;if(c[a]===b)return a/(d-1);e=c[a];return(a+(b-e)/(c[a+1]-e))/(d-1)},getTangent:function(a){var b=
16287 a-1E-4;a+=1E-4;0>b&&(b=0);1<a&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().sub(b).normalize()},getTangentAt:function(a){a=this.getUtoTmapping(a);return this.getTangent(a)},computeFrenetFrames:function(a,b){var c=new p,d=[],e=[],f=[],g=new p,h=new I,k;for(k=0;k<=a;k++){var m=k/a;d[k]=this.getTangentAt(m);d[k].normalize()}e[0]=new p;f[0]=new p;k=Number.MAX_VALUE;m=Math.abs(d[0].x);var l=Math.abs(d[0].y),n=Math.abs(d[0].z);m<=k&&(k=m,c.set(1,0,0));l<=k&&(k=l,c.set(0,1,0));n<=k&&c.set(0,
16288 0,1);g.crossVectors(d[0],c).normalize();e[0].crossVectors(d[0],g);f[0].crossVectors(d[0],e[0]);for(k=1;k<=a;k++)e[k]=e[k-1].clone(),f[k]=f[k-1].clone(),g.crossVectors(d[k-1],d[k]),g.length()>Number.EPSILON&&(g.normalize(),c=Math.acos(H.clamp(d[k-1].dot(d[k]),-1,1)),e[k].applyMatrix4(h.makeRotationAxis(g,c))),f[k].crossVectors(d[k],e[k]);if(!0===b)for(c=Math.acos(H.clamp(e[0].dot(e[a]),-1,1)),c/=a,0<d[0].dot(g.crossVectors(e[0],e[a]))&&(c=-c),k=1;k<=a;k++)e[k].applyMatrix4(h.makeRotationAxis(d[k],
16289 c*k)),f[k].crossVectors(d[k],e[k]);return{tangents:d,normals:e,binormals:f}},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.arcLengthDivisions=a.arcLengthDivisions;return this},toJSON:function(){var a={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};a.arcLengthDivisions=this.arcLengthDivisions;a.type=this.type;return a},fromJSON:function(a){this.arcLengthDivisions=a.arcLengthDivisions;return this}});za.prototype=Object.create(L.prototype);za.prototype.constructor=
16290 za;za.prototype.isEllipseCurve=!0;za.prototype.getPoint=function(a,b){b=b||new z;for(var c=2*Math.PI,d=this.aEndAngle-this.aStartAngle,e=Math.abs(d)<Number.EPSILON;0>d;)d+=c;for(;d>c;)d-=c;d<Number.EPSILON&&(d=e?0:c);!0!==this.aClockwise||e||(d=d===c?-c:d-c);c=this.aStartAngle+a*d;a=this.aX+this.xRadius*Math.cos(c);var f=this.aY+this.yRadius*Math.sin(c);0!==this.aRotation&&(c=Math.cos(this.aRotation),d=Math.sin(this.aRotation),e=a-this.aX,f-=this.aY,a=e*c-f*d+this.aX,f=e*d+f*c+this.aY);return b.set(a,
16291 f)};za.prototype.copy=function(a){L.prototype.copy.call(this,a);this.aX=a.aX;this.aY=a.aY;this.xRadius=a.xRadius;this.yRadius=a.yRadius;this.aStartAngle=a.aStartAngle;this.aEndAngle=a.aEndAngle;this.aClockwise=a.aClockwise;this.aRotation=a.aRotation;return this};za.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.aX=this.aX;a.aY=this.aY;a.xRadius=this.xRadius;a.yRadius=this.yRadius;a.aStartAngle=this.aStartAngle;a.aEndAngle=this.aEndAngle;a.aClockwise=this.aClockwise;a.aRotation=
16292 this.aRotation;return a};za.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.aX=a.aX;this.aY=a.aY;this.xRadius=a.xRadius;this.yRadius=a.yRadius;this.aStartAngle=a.aStartAngle;this.aEndAngle=a.aEndAngle;this.aClockwise=a.aClockwise;this.aRotation=a.aRotation;return this};dc.prototype=Object.create(za.prototype);dc.prototype.constructor=dc;dc.prototype.isArcCurve=!0;var Od=new p,Ae=new fe,Be=new fe,Ce=new fe;ca.prototype=Object.create(L.prototype);ca.prototype.constructor=ca;ca.prototype.isCatmullRomCurve3=
16293 !0;ca.prototype.getPoint=function(a,b){b=b||new p;var c=this.points,d=c.length;a*=d-(this.closed?0:1);var e=Math.floor(a);a-=e;this.closed?e+=0<e?0:(Math.floor(Math.abs(e)/d)+1)*d:0===a&&e===d-1&&(e=d-2,a=1);if(this.closed||0<e)var f=c[(e-1)%d];else Od.subVectors(c[0],c[1]).add(c[0]),f=Od;var g=c[e%d];var h=c[(e+1)%d];this.closed||e+2<d?c=c[(e+2)%d]:(Od.subVectors(c[d-1],c[d-2]).add(c[d-1]),c=Od);if("centripetal"===this.curveType||"chordal"===this.curveType){var k="chordal"===this.curveType?.5:.25;
16294 d=Math.pow(f.distanceToSquared(g),k);e=Math.pow(g.distanceToSquared(h),k);k=Math.pow(h.distanceToSquared(c),k);1E-4>e&&(e=1);1E-4>d&&(d=e);1E-4>k&&(k=e);Ae.initNonuniformCatmullRom(f.x,g.x,h.x,c.x,d,e,k);Be.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,k);Ce.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,k)}else"catmullrom"===this.curveType&&(Ae.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),Be.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),Ce.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(Ae.calc(a),
16295 Be.calc(a),Ce.calc(a));return b};ca.prototype.copy=function(a){L.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++)this.points.push(a.points[b].clone());this.closed=a.closed;this.curveType=a.curveType;this.tension=a.tension;return this};ca.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.points=[];for(var b=0,c=this.points.length;b<c;b++)a.points.push(this.points[b].toArray());a.closed=this.closed;a.curveType=this.curveType;a.tension=this.tension;return a};
16296 ca.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++){var d=a.points[b];this.points.push((new p).fromArray(d))}this.closed=a.closed;this.curveType=a.curveType;this.tension=a.tension;return this};Ha.prototype=Object.create(L.prototype);Ha.prototype.constructor=Ha;Ha.prototype.isCubicBezierCurve=!0;Ha.prototype.getPoint=function(a,b){b=b||new z;var c=this.v0,d=this.v1,e=this.v2,f=this.v3;b.set(ad(a,c.x,d.x,e.x,f.x),ad(a,c.y,d.y,e.y,
16297 f.y));return b};Ha.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);this.v3.copy(a.v3);return this};Ha.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();a.v3=this.v3.toArray();return a};Ha.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);this.v3.fromArray(a.v3);return this};
16298 Qa.prototype=Object.create(L.prototype);Qa.prototype.constructor=Qa;Qa.prototype.isCubicBezierCurve3=!0;Qa.prototype.getPoint=function(a,b){b=b||new p;var c=this.v0,d=this.v1,e=this.v2,f=this.v3;b.set(ad(a,c.x,d.x,e.x,f.x),ad(a,c.y,d.y,e.y,f.y),ad(a,c.z,d.z,e.z,f.z));return b};Qa.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);this.v3.copy(a.v3);return this};Qa.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v0=this.v0.toArray();
16299 a.v1=this.v1.toArray();a.v2=this.v2.toArray();a.v3=this.v3.toArray();return a};Qa.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);this.v3.fromArray(a.v3);return this};va.prototype=Object.create(L.prototype);va.prototype.constructor=va;va.prototype.isLineCurve=!0;va.prototype.getPoint=function(a,b){b=b||new z;1===a?b.copy(this.v2):(b.copy(this.v2).sub(this.v1),b.multiplyScalar(a).add(this.v1));return b};va.prototype.getPointAt=
16300 function(a,b){return this.getPoint(a,b)};va.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()};va.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};va.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};va.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Ia.prototype=
16301 Object.create(L.prototype);Ia.prototype.constructor=Ia;Ia.prototype.isLineCurve3=!0;Ia.prototype.getPoint=function(a,b){b=b||new p;1===a?b.copy(this.v2):(b.copy(this.v2).sub(this.v1),b.multiplyScalar(a).add(this.v1));return b};Ia.prototype.getPointAt=function(a,b){return this.getPoint(a,b)};Ia.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};Ia.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v1=this.v1.toArray();a.v2=this.v2.toArray();
16302 return a};Ia.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Ja.prototype=Object.create(L.prototype);Ja.prototype.constructor=Ja;Ja.prototype.isQuadraticBezierCurve=!0;Ja.prototype.getPoint=function(a,b){b=b||new z;var c=this.v0,d=this.v1,e=this.v2;b.set($c(a,c.x,d.x,e.x),$c(a,c.y,d.y,e.y));return b};Ja.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};
16303 Ja.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};Ja.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Ra.prototype=Object.create(L.prototype);Ra.prototype.constructor=Ra;Ra.prototype.isQuadraticBezierCurve3=!0;Ra.prototype.getPoint=function(a,b){b=b||new p;var c=this.v0,d=this.v1,e=this.v2;b.set($c(a,c.x,
16304 d.x,e.x),$c(a,c.y,d.y,e.y),$c(a,c.z,d.z,e.z));return b};Ra.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};Ra.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};Ra.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Ka.prototype=Object.create(L.prototype);
16305 Ka.prototype.constructor=Ka;Ka.prototype.isSplineCurve=!0;Ka.prototype.getPoint=function(a,b){b=b||new z;var c=this.points,d=(c.length-1)*a;a=Math.floor(d);d-=a;var e=c[0===a?a:a-1],f=c[a],g=c[a>c.length-2?c.length-1:a+1];c=c[a>c.length-3?c.length-1:a+2];b.set(lf(d,e.x,f.x,g.x,c.x),lf(d,e.y,f.y,g.y,c.y));return b};Ka.prototype.copy=function(a){L.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++)this.points.push(a.points[b].clone());return this};Ka.prototype.toJSON=function(){var a=
16306 L.prototype.toJSON.call(this);a.points=[];for(var b=0,c=this.points.length;b<c;b++)a.points.push(this.points[b].toArray());return a};Ka.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++){var d=a.points[b];this.points.push((new z).fromArray(d))}return this};var Af=Object.freeze({ArcCurve:dc,CatmullRomCurve3:ca,CubicBezierCurve:Ha,CubicBezierCurve3:Qa,EllipseCurve:za,LineCurve:va,LineCurve3:Ia,QuadraticBezierCurve:Ja,QuadraticBezierCurve3:Ra,
16307 SplineCurve:Ka});Xa.prototype=Object.assign(Object.create(L.prototype),{constructor:Xa,add:function(a){this.curves.push(a)},closePath:function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new va(b,a))},getPoint:function(a){var b=a*this.getLength(),c=this.getCurveLengths();for(a=0;a<c.length;){if(c[a]>=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths();
16308 return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;c<d;c++)b+=this.curves[c].getLength(),a.push(b);return this.cacheLengths=a},getSpacedPoints:function(a){void 0===a&&(a=40);for(var b=[],c=0;c<=a;c++)b.push(this.getPoint(c/a));this.autoClose&&b.push(b[0]);return b},getPoints:function(a){a=
16309 a||12;for(var b=[],c,d=0,e=this.curves;d<e.length;d++){var f=e[d];f=f.getPoints(f&&f.isEllipseCurve?2*a:f&&(f.isLineCurve||f.isLineCurve3)?1:f&&f.isSplineCurve?a*f.points.length:a);for(var g=0;g<f.length;g++){var h=f[g];c&&c.equals(h)||(b.push(h),c=h)}}this.autoClose&&1<b.length&&!b[b.length-1].equals(b[0])&&b.push(b[0]);return b},copy:function(a){L.prototype.copy.call(this,a);this.curves=[];for(var b=0,c=a.curves.length;b<c;b++)this.curves.push(a.curves[b].clone());this.autoClose=a.autoClose;return this},
16310 toJSON:function(){var a=L.prototype.toJSON.call(this);a.autoClose=this.autoClose;a.curves=[];for(var b=0,c=this.curves.length;b<c;b++)a.curves.push(this.curves[b].toJSON());return a},fromJSON:function(a){L.prototype.fromJSON.call(this,a);this.autoClose=a.autoClose;this.curves=[];for(var b=0,c=a.curves.length;b<c;b++){var d=a.curves[b];this.curves.push((new Af[d.type]).fromJSON(d))}return this}});La.prototype=Object.assign(Object.create(Xa.prototype),{constructor:La,setFromPoints:function(a){this.moveTo(a[0].x,
16311 a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y)},moveTo:function(a,b){this.currentPoint.set(a,b)},lineTo:function(a,b){var c=new va(this.currentPoint.clone(),new z(a,b));this.curves.push(c);this.currentPoint.set(a,b)},quadraticCurveTo:function(a,b,c,d){a=new Ja(this.currentPoint.clone(),new z(a,b),new z(c,d));this.curves.push(a);this.currentPoint.set(c,d)},bezierCurveTo:function(a,b,c,d,e,f){a=new Ha(this.currentPoint.clone(),new z(a,b),new z(c,d),new z(e,f));this.curves.push(a);
16312 this.currentPoint.set(e,f)},splineThru:function(a){var b=[this.currentPoint.clone()].concat(a);b=new Ka(b);this.curves.push(b);this.currentPoint.copy(a[a.length-1])},arc:function(a,b,c,d,e,f){this.absarc(a+this.currentPoint.x,b+this.currentPoint.y,c,d,e,f)},absarc:function(a,b,c,d,e,f){this.absellipse(a,b,c,c,d,e,f)},ellipse:function(a,b,c,d,e,f,g,h){this.absellipse(a+this.currentPoint.x,b+this.currentPoint.y,c,d,e,f,g,h)},absellipse:function(a,b,c,d,e,f,g,h){a=new za(a,b,c,d,e,f,g,h);0<this.curves.length&&
16313 (b=a.getPoint(0),b.equals(this.currentPoint)||this.lineTo(b.x,b.y));this.curves.push(a);a=a.getPoint(1);this.currentPoint.copy(a)},copy:function(a){Xa.prototype.copy.call(this,a);this.currentPoint.copy(a.currentPoint);return this},toJSON:function(){var a=Xa.prototype.toJSON.call(this);a.currentPoint=this.currentPoint.toArray();return a},fromJSON:function(a){Xa.prototype.fromJSON.call(this,a);this.currentPoint.fromArray(a.currentPoint);return this}});db.prototype=Object.assign(Object.create(La.prototype),
16314 {constructor:db,getPointsHoles:function(a){for(var b=[],c=0,d=this.holes.length;c<d;c++)b[c]=this.holes[c].getPoints(a);return b},extractPoints:function(a){return{shape:this.getPoints(a),holes:this.getPointsHoles(a)}},copy:function(a){La.prototype.copy.call(this,a);this.holes=[];for(var b=0,c=a.holes.length;b<c;b++)this.holes.push(a.holes[b].clone());return this},toJSON:function(){var a=La.prototype.toJSON.call(this);a.uuid=this.uuid;a.holes=[];for(var b=0,c=this.holes.length;b<c;b++)a.holes.push(this.holes[b].toJSON());
16315 return a},fromJSON:function(a){La.prototype.fromJSON.call(this,a);this.uuid=a.uuid;this.holes=[];for(var b=0,c=a.holes.length;b<c;b++){var d=a.holes[b];this.holes.push((new La).fromJSON(d))}return this}});X.prototype=Object.assign(Object.create(D.prototype),{constructor:X,isLight:!0,copy:function(a){D.prototype.copy.call(this,a);this.color.copy(a.color);this.intensity=a.intensity;return this},toJSON:function(a){a=D.prototype.toJSON.call(this,a);a.object.color=this.color.getHex();a.object.intensity=
16316 this.intensity;void 0!==this.groundColor&&(a.object.groundColor=this.groundColor.getHex());void 0!==this.distance&&(a.object.distance=this.distance);void 0!==this.angle&&(a.object.angle=this.angle);void 0!==this.decay&&(a.object.decay=this.decay);void 0!==this.penumbra&&(a.object.penumbra=this.penumbra);void 0!==this.shadow&&(a.object.shadow=this.shadow.toJSON());return a}});wd.prototype=Object.assign(Object.create(X.prototype),{constructor:wd,isHemisphereLight:!0,copy:function(a){X.prototype.copy.call(this,
16317 a);this.groundColor.copy(a.groundColor);return this}});Object.assign(Cb.prototype,{copy:function(a){this.camera=a.camera.clone();this.bias=a.bias;this.radius=a.radius;this.mapSize.copy(a.mapSize);return this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var a={};0!==this.bias&&(a.bias=this.bias);1!==this.radius&&(a.radius=this.radius);if(512!==this.mapSize.x||512!==this.mapSize.y)a.mapSize=this.mapSize.toArray();a.camera=this.camera.toJSON(!1).object;delete a.camera.matrix;
16318 return a}});xd.prototype=Object.assign(Object.create(Cb.prototype),{constructor:xd,isSpotLightShadow:!0,update:function(a){var b=this.camera,c=2*H.RAD2DEG*a.angle,d=this.mapSize.width/this.mapSize.height;a=a.distance||b.far;if(c!==b.fov||d!==b.aspect||a!==b.far)b.fov=c,b.aspect=d,b.far=a,b.updateProjectionMatrix()}});yd.prototype=Object.assign(Object.create(X.prototype),{constructor:yd,isSpotLight:!0,copy:function(a){X.prototype.copy.call(this,a);this.distance=a.distance;this.angle=a.angle;this.penumbra=
16319 a.penumbra;this.decay=a.decay;this.target=a.target.clone();this.shadow=a.shadow.clone();return this}});zd.prototype=Object.assign(Object.create(X.prototype),{constructor:zd,isPointLight:!0,copy:function(a){X.prototype.copy.call(this,a);this.distance=a.distance;this.decay=a.decay;this.shadow=a.shadow.clone();return this}});Ad.prototype=Object.assign(Object.create(Cb.prototype),{constructor:Ad});Bd.prototype=Object.assign(Object.create(X.prototype),{constructor:Bd,isDirectionalLight:!0,copy:function(a){X.prototype.copy.call(this,
16320 a);this.target=a.target.clone();this.shadow=a.shadow.clone();return this}});Cd.prototype=Object.assign(Object.create(X.prototype),{constructor:Cd,isAmbientLight:!0});Dd.prototype=Object.assign(Object.create(X.prototype),{constructor:Dd,isRectAreaLight:!0,copy:function(a){X.prototype.copy.call(this,a);this.width=a.width;this.height=a.height;return this},toJSON:function(a){a=X.prototype.toJSON.call(this,a);a.object.width=this.width;a.object.height=this.height;return a}});var ia={arraySlice:function(a,
16321 b,c){return ia.isTypedArray(a)?new a.constructor(a.subarray(b,void 0!==c?c:a.length)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},isTypedArray:function(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b=a.length,c=Array(b),d=0;d!==b;++d)c[d]=d;c.sort(function(b,c){return a[b]-a[c]});return c},sortedArray:function(a,b,c){for(var d=a.length,e=
16322 new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,k=0;k!==b;++k)e[g++]=a[h+k];return e},flattenJSON:function(a,b,c,d){for(var e=1,f=a[0];void 0!==f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d];if(void 0!==g)if(Array.isArray(g)){do g=f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)),f=a[e++];while(void 0!==f)}else if(void 0!==g.toArray){do g=f[d],void 0!==g&&(b.push(f.time),g.toArray(c,c.length)),f=a[e++];while(void 0!==f)}else{do g=f[d],void 0!==g&&(b.push(f.time),c.push(g)),f=a[e++];
16323 while(void 0!==f)}}}};Object.assign(wa.prototype,{evaluate:function(a){var b=this.parameterPositions,c=this._cachedIndex,d=b[c],e=b[c-1];a:{b:{c:{d:if(!(a<d)){for(var f=c+2;;){if(void 0===d){if(a<e)break d;this._cachedIndex=c=b.length;return this.afterEnd_(c-1,a,e)}if(c===f)break;e=d;d=b[++c];if(a<d)break b}d=b.length;break c}if(a>=e)break a;else{f=b[1];a<f&&(c=2,e=f);for(f=c-2;;){if(void 0===e)return this._cachedIndex=0,this.beforeStart_(0,a,d);if(c===f)break;d=e;e=b[--c-1];if(a>=e)break b}d=c;c=
16324 0}}for(;c<d;)e=c+d>>>1,a<b[e]?d=e:c=e+1;d=b[c];e=b[c-1];if(void 0===e)return this._cachedIndex=0,this.beforeStart_(0,a,d);if(void 0===d)return this._cachedIndex=c=b.length,this.afterEnd_(c-1,e,a)}this._cachedIndex=c;this.intervalChanged_(c,e,d)}return this.interpolate_(c,e,a,d)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(a){var b=this.resultBuffer,c=this.sampleValues,d=this.valueSize;a*=d;for(var e=0;e!==d;++e)b[e]=
16325 c[a+e];return b},interpolate_:function(){throw Error("call to abstract method");},intervalChanged_:function(){}});Object.assign(wa.prototype,{beforeStart_:wa.prototype.copySampleValue_,afterEnd_:wa.prototype.copySampleValue_});Ed.prototype=Object.assign(Object.create(wa.prototype),{constructor:Ed,DefaultSettings_:{endingStart:2400,endingEnd:2400},intervalChanged_:function(a,b,c){var d=this.parameterPositions,e=a-2,f=a+1,g=d[e],h=d[f];if(void 0===g)switch(this.getSettings_().endingStart){case 2401:e=
16326 a;g=2*b-c;break;case 2402:e=d.length-2;g=b+d[e]-d[e+1];break;default:e=a,g=c}if(void 0===h)switch(this.getSettings_().endingEnd){case 2401:f=a;h=2*c-b;break;case 2402:f=1;h=c+d[1]-d[0];break;default:f=a-1,h=b}a=.5*(c-b);d=this.valueSize;this._weightPrev=a/(b-g);this._weightNext=a/(h-c);this._offsetPrev=e*d;this._offsetNext=f*d},interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;var h=a-g,k=this._offsetPrev,m=this._offsetNext,l=this._weightPrev,n=this._weightNext,
16327 p=(c-b)/(d-b);c=p*p;d=c*p;b=-l*d+2*l*c-l*p;l=(1+l)*d+(-1.5-2*l)*c+(-.5+l)*p+1;p=(-1-n)*d+(1.5+n)*c+.5*p;n=n*d-n*c;for(c=0;c!==g;++c)e[c]=b*f[k+c]+l*f[h+c]+p*f[a+c]+n*f[m+c];return e}});bd.prototype=Object.assign(Object.create(wa.prototype),{constructor:bd,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;var h=a-g;b=(c-b)/(d-b);c=1-b;for(d=0;d!==g;++d)e[d]=f[h+d]*c+f[a+d]*b;return e}});Fd.prototype=Object.assign(Object.create(wa.prototype),{constructor:Fd,
16328 interpolate_:function(a){return this.copySampleValue_(a-1)}});Object.assign(oa,{toJSON:function(a){var b=a.constructor;if(void 0!==b.toJSON)b=b.toJSON(a);else{b={name:a.name,times:ia.convertArray(a.times,Array),values:ia.convertArray(a.values,Array)};var c=a.getInterpolation();c!==a.DefaultInterpolation&&(b.interpolation=c)}b.type=a.ValueTypeName;return b}});Object.assign(oa.prototype,{constructor:oa,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:2301,InterpolantFactoryMethodDiscrete:function(a){return new Fd(this.times,
16329 this.values,this.getValueSize(),a)},InterpolantFactoryMethodLinear:function(a){return new bd(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:function(a){return new Ed(this.times,this.values,this.getValueSize(),a)},setInterpolation:function(a){switch(a){case 2300:var b=this.InterpolantFactoryMethodDiscrete;break;case 2301:b=this.InterpolantFactoryMethodLinear;break;case 2302:b=this.InterpolantFactoryMethodSmooth}if(void 0===b){b="unsupported interpolation for "+this.ValueTypeName+
16330 " keyframe track named "+this.name;if(void 0===this.createInterpolant)if(a!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(b);console.warn("THREE.KeyframeTrack:",b);return this}this.createInterpolant=b;return this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}},getValueSize:function(){return this.values.length/
16331 this.times.length},shift:function(a){if(0!==a)for(var b=this.times,c=0,d=b.length;c!==d;++c)b[c]+=a;return this},scale:function(a){if(1!==a)for(var b=this.times,c=0,d=b.length;c!==d;++c)b[c]*=a;return this},trim:function(a,b){for(var c=this.times,d=c.length,e=0,f=d-1;e!==d&&c[e]<a;)++e;for(;-1!==f&&c[f]>b;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),a=this.getValueSize(),this.times=ia.arraySlice(c,e,f),this.values=ia.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=
16332 !0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var c=this.times;b=this.values;var d=c.length;0===d&&(console.error("THREE.KeyframeTrack: Track is empty.",this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,g,e);a=!1;break}e=
16333 g}if(void 0!==b&&ia.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;g<f;++g){var h=!1,k=a[g];if(k!==a[g+1]&&(1!==g||k!==k[0]))if(d)h=!0;else{var m=g*c,l=m-c,n=m+c;for(k=0;k!==c;++k){var p=b[m+k];if(p!==b[l+k]||p!==b[n+k]){h=!0;break}}}if(h){if(g!==e)for(a[e]=
16334 a[g],h=g*c,m=e*c,k=0;k!==c;++k)b[m+k]=b[h+k];++e}}if(0<f){a[e]=a[f];h=f*c;m=e*c;for(k=0;k!==c;++k)b[m+k]=b[h+k];++e}e!==a.length&&(this.times=ia.arraySlice(a,0,e),this.values=ia.arraySlice(b,0,e*c));return this}});Gd.prototype=Object.assign(Object.create(oa.prototype),{constructor:Gd,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});Hd.prototype=Object.assign(Object.create(oa.prototype),{constructor:Hd,
16335 ValueTypeName:"color"});ec.prototype=Object.assign(Object.create(oa.prototype),{constructor:ec,ValueTypeName:"number"});Id.prototype=Object.assign(Object.create(wa.prototype),{constructor:Id,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;b=(c-b)/(d-b);for(c=a+g;a!==c;a+=4)fa.slerpFlat(e,0,f,a-g,f,a,b);return e}});cd.prototype=Object.assign(Object.create(oa.prototype),{constructor:cd,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(a){return new Id(this.times,
16336 this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:void 0});Jd.prototype=Object.assign(Object.create(oa.prototype),{constructor:Jd,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});fc.prototype=Object.assign(Object.create(oa.prototype),{constructor:fc,ValueTypeName:"vector"});Object.assign(Ca,{parse:function(a){for(var b=[],c=a.tracks,d=1/(a.fps||1),e=0,f=c.length;e!==f;++e)b.push(Sg(c[e]).scale(d));
16337 return new Ca(a.name,a.duration,b)},toJSON:function(a){var b=[],c=a.tracks;a={name:a.name,duration:a.duration,tracks:b,uuid:a.uuid};for(var d=0,e=c.length;d!==e;++d)b.push(oa.toJSON(c[d]));return a},CreateFromMorphTargetSequence:function(a,b,c,d){for(var e=b.length,f=[],g=0;g<e;g++){var h=[],k=[];h.push((g+e-1)%e,g,(g+1)%e);k.push(0,1,0);var m=ia.getKeyframeOrder(h);h=ia.sortedArray(h,1,m);k=ia.sortedArray(k,1,m);d||0!==h[0]||(h.push(e),k.push(k[0]));f.push((new ec(".morphTargetInfluences["+b[g].name+
16338 "]",h,k)).scale(1/c))}return new Ca(a,-1,f)},findByName:function(a,b){var c=a;Array.isArray(a)||(c=a.geometry&&a.geometry.animations||a.animations);for(a=0;a<c.length;a++)if(c[a].name===b)return c[a];return null},CreateClipsFromMorphTargetSequences:function(a,b,c){for(var d={},e=/^([\w-]*?)([\d]+)$/,f=0,g=a.length;f<g;f++){var h=a[f],k=h.name.match(e);if(k&&1<k.length){var m=k[1];(k=d[m])||(d[m]=k=[]);k.push(h)}}a=[];for(m in d)a.push(Ca.CreateFromMorphTargetSequence(m,d[m],b,c));return a},parseAnimation:function(a,
16339 b){if(!a)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;var c=function(a,b,c,d,e){if(0!==c.length){var f=[],g=[];ia.flattenJSON(c,f,g,d);0!==f.length&&e.push(new a(b,f,g))}},d=[],e=a.name||"default",f=a.length||-1,g=a.fps||30;a=a.hierarchy||[];for(var h=0;h<a.length;h++){var k=a[h].keys;if(k&&0!==k.length)if(k[0].morphTargets){f={};for(var m=0;m<k.length;m++)if(k[m].morphTargets)for(var l=0;l<k[m].morphTargets.length;l++)f[k[m].morphTargets[l]]=-1;for(var n in f){var p=
16340 [],u=[];for(l=0;l!==k[m].morphTargets.length;++l){var r=k[m];p.push(r.time);u.push(r.morphTarget===n?1:0)}d.push(new ec(".morphTargetInfluence["+n+"]",p,u))}f=f.length*(g||1)}else m=".bones["+b[h].name+"]",c(fc,m+".position",k,"pos",d),c(cd,m+".quaternion",k,"rot",d),c(fc,m+".scale",k,"scl",d)}return 0===d.length?null:new Ca(e,f,d)}});Object.assign(Ca.prototype,{resetDuration:function(){for(var a=0,b=0,c=this.tracks.length;b!==c;++b){var d=this.tracks[b];a=Math.max(a,d.times[d.times.length-1])}this.duration=
16341 a;return this},trim:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].trim(0,this.duration);return this},validate:function(){for(var a=!0,b=0;b<this.tracks.length;b++)a=a&&this.tracks[b].validate();return a},optimize:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].optimize();return this}});Object.assign(Kd.prototype,{load:function(a,b,c,d){var e=this;(new Ga(e.manager)).load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},setTextures:function(a){this.textures=a},parse:function(a){function b(a){void 0===
16342 c[a]&&console.warn("THREE.MaterialLoader: Undefined texture",a);return c[a]}var c=this.textures,d=new Vg[a.type];void 0!==a.uuid&&(d.uuid=a.uuid);void 0!==a.name&&(d.name=a.name);void 0!==a.color&&d.color.setHex(a.color);void 0!==a.roughness&&(d.roughness=a.roughness);void 0!==a.metalness&&(d.metalness=a.metalness);void 0!==a.emissive&&d.emissive.setHex(a.emissive);void 0!==a.specular&&d.specular.setHex(a.specular);void 0!==a.shininess&&(d.shininess=a.shininess);void 0!==a.clearCoat&&(d.clearCoat=
16343 a.clearCoat);void 0!==a.clearCoatRoughness&&(d.clearCoatRoughness=a.clearCoatRoughness);void 0!==a.uniforms&&(d.uniforms=a.uniforms);void 0!==a.vertexShader&&(d.vertexShader=a.vertexShader);void 0!==a.fragmentShader&&(d.fragmentShader=a.fragmentShader);void 0!==a.vertexColors&&(d.vertexColors=a.vertexColors);void 0!==a.fog&&(d.fog=a.fog);void 0!==a.flatShading&&(d.flatShading=a.flatShading);void 0!==a.blending&&(d.blending=a.blending);void 0!==a.side&&(d.side=a.side);void 0!==a.opacity&&(d.opacity=
16344 a.opacity);void 0!==a.transparent&&(d.transparent=a.transparent);void 0!==a.alphaTest&&(d.alphaTest=a.alphaTest);void 0!==a.depthTest&&(d.depthTest=a.depthTest);void 0!==a.depthWrite&&(d.depthWrite=a.depthWrite);void 0!==a.colorWrite&&(d.colorWrite=a.colorWrite);void 0!==a.wireframe&&(d.wireframe=a.wireframe);void 0!==a.wireframeLinewidth&&(d.wireframeLinewidth=a.wireframeLinewidth);void 0!==a.wireframeLinecap&&(d.wireframeLinecap=a.wireframeLinecap);void 0!==a.wireframeLinejoin&&(d.wireframeLinejoin=
16345 a.wireframeLinejoin);void 0!==a.rotation&&(d.rotation=a.rotation);1!==a.linewidth&&(d.linewidth=a.linewidth);void 0!==a.dashSize&&(d.dashSize=a.dashSize);void 0!==a.gapSize&&(d.gapSize=a.gapSize);void 0!==a.scale&&(d.scale=a.scale);void 0!==a.polygonOffset&&(d.polygonOffset=a.polygonOffset);void 0!==a.polygonOffsetFactor&&(d.polygonOffsetFactor=a.polygonOffsetFactor);void 0!==a.polygonOffsetUnits&&(d.polygonOffsetUnits=a.polygonOffsetUnits);void 0!==a.skinning&&(d.skinning=a.skinning);void 0!==a.morphTargets&&
16346 (d.morphTargets=a.morphTargets);void 0!==a.dithering&&(d.dithering=a.dithering);void 0!==a.visible&&(d.visible=a.visible);void 0!==a.userData&&(d.userData=a.userData);void 0!==a.shading&&(d.flatShading=1===a.shading);void 0!==a.size&&(d.size=a.size);void 0!==a.sizeAttenuation&&(d.sizeAttenuation=a.sizeAttenuation);void 0!==a.map&&(d.map=b(a.map));void 0!==a.alphaMap&&(d.alphaMap=b(a.alphaMap),d.transparent=!0);void 0!==a.bumpMap&&(d.bumpMap=b(a.bumpMap));void 0!==a.bumpScale&&(d.bumpScale=a.bumpScale);
16347 void 0!==a.normalMap&&(d.normalMap=b(a.normalMap));void 0!==a.normalMapType&&(d.normalMapType=a.normalMapType);if(void 0!==a.normalScale){var e=a.normalScale;!1===Array.isArray(e)&&(e=[e,e]);d.normalScale=(new z).fromArray(e)}void 0!==a.displacementMap&&(d.displacementMap=b(a.displacementMap));void 0!==a.displacementScale&&(d.displacementScale=a.displacementScale);void 0!==a.displacementBias&&(d.displacementBias=a.displacementBias);void 0!==a.roughnessMap&&(d.roughnessMap=b(a.roughnessMap));void 0!==
16348 a.metalnessMap&&(d.metalnessMap=b(a.metalnessMap));void 0!==a.emissiveMap&&(d.emissiveMap=b(a.emissiveMap));void 0!==a.emissiveIntensity&&(d.emissiveIntensity=a.emissiveIntensity);void 0!==a.specularMap&&(d.specularMap=b(a.specularMap));void 0!==a.envMap&&(d.envMap=b(a.envMap));void 0!==a.reflectivity&&(d.reflectivity=a.reflectivity);void 0!==a.lightMap&&(d.lightMap=b(a.lightMap));void 0!==a.lightMapIntensity&&(d.lightMapIntensity=a.lightMapIntensity);void 0!==a.aoMap&&(d.aoMap=b(a.aoMap));void 0!==
16349 a.aoMapIntensity&&(d.aoMapIntensity=a.aoMapIntensity);void 0!==a.gradientMap&&(d.gradientMap=b(a.gradientMap));return d}});Object.assign(ge.prototype,{load:function(a,b,c,d){var e=this;(new Ga(e.manager)).load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},parse:function(a){var b=new C,c=a.data.index;void 0!==c&&(c=new Bf[c.type](c.array),b.setIndex(new Q(c,1)));var d=a.data.attributes;for(f in d){var e=d[f];c=new Bf[e.type](e.array);b.addAttribute(f,new Q(c,e.itemSize,e.normalized))}var f=a.data.groups||
16350 a.data.drawcalls||a.data.offsets;if(void 0!==f)for(c=0,d=f.length;c!==d;++c)e=f[c],b.addGroup(e.start,e.count,e.materialIndex);a=a.data.boundingSphere;void 0!==a&&(f=new p,void 0!==a.center&&f.fromArray(a.center),b.boundingSphere=new Da(f,a.radius));return b}});var Bf={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!==typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,
16351 Float64Array:Float64Array};gc.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=this.handlers,c=0,d=b.length;c<d;c+=2){var e=b[c+1];if(b[c].test(a))return e}return null}};Object.assign(gc.prototype,{crossOrigin:"anonymous",onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(a,b,c){for(var d=[],e=0;e<a.length;++e)d[e]=this.createMaterial(a[e],b,c);return d},createMaterial:function(){var a={NoBlending:0,NormalBlending:1,
16352 AdditiveBlending:2,SubtractiveBlending:3,MultiplyBlending:4,CustomBlending:5},b=new G,c=new vd,d=new Kd;return function(e,f,g){function h(a,b,d,e,h){a=f+a;var m=gc.Handlers.get(a);null!==m?a=m.load(a):(c.setCrossOrigin(g),a=c.load(a));void 0!==b&&(a.repeat.fromArray(b),1!==b[0]&&(a.wrapS=1E3),1!==b[1]&&(a.wrapT=1E3));void 0!==d&&a.offset.fromArray(d);void 0!==e&&("repeat"===e[0]&&(a.wrapS=1E3),"mirror"===e[0]&&(a.wrapS=1002),"repeat"===e[1]&&(a.wrapT=1E3),"mirror"===e[1]&&(a.wrapT=1002));void 0!==
16353 h&&(a.anisotropy=h);b=H.generateUUID();k[b]=a;return b}var k={},m={uuid:H.generateUUID(),type:"MeshLambertMaterial"},l;for(l in e){var n=e[l];switch(l){case "DbgColor":case "DbgIndex":case "opticalDensity":case "illumination":break;case "DbgName":m.name=n;break;case "blending":m.blending=a[n];break;case "colorAmbient":case "mapAmbient":console.warn("THREE.Loader.createMaterial:",l,"is no longer supported.");break;case "colorDiffuse":m.color=b.fromArray(n).getHex();break;case "colorSpecular":m.specular=
16354 b.fromArray(n).getHex();break;case "colorEmissive":m.emissive=b.fromArray(n).getHex();break;case "specularCoef":m.shininess=n;break;case "shading":"basic"===n.toLowerCase()&&(m.type="MeshBasicMaterial");"phong"===n.toLowerCase()&&(m.type="MeshPhongMaterial");"standard"===n.toLowerCase()&&(m.type="MeshStandardMaterial");break;case "mapDiffuse":m.map=h(n,e.mapDiffuseRepeat,e.mapDiffuseOffset,e.mapDiffuseWrap,e.mapDiffuseAnisotropy);break;case "mapDiffuseRepeat":case "mapDiffuseOffset":case "mapDiffuseWrap":case "mapDiffuseAnisotropy":break;
16355 case "mapEmissive":m.emissiveMap=h(n,e.mapEmissiveRepeat,e.mapEmissiveOffset,e.mapEmissiveWrap,e.mapEmissiveAnisotropy);break;case "mapEmissiveRepeat":case "mapEmissiveOffset":case "mapEmissiveWrap":case "mapEmissiveAnisotropy":break;case "mapLight":m.lightMap=h(n,e.mapLightRepeat,e.mapLightOffset,e.mapLightWrap,e.mapLightAnisotropy);break;case "mapLightRepeat":case "mapLightOffset":case "mapLightWrap":case "mapLightAnisotropy":break;case "mapAO":m.aoMap=h(n,e.mapAORepeat,e.mapAOOffset,e.mapAOWrap,
16356 e.mapAOAnisotropy);break;case "mapAORepeat":case "mapAOOffset":case "mapAOWrap":case "mapAOAnisotropy":break;case "mapBump":m.bumpMap=h(n,e.mapBumpRepeat,e.mapBumpOffset,e.mapBumpWrap,e.mapBumpAnisotropy);break;case "mapBumpScale":m.bumpScale=n;break;case "mapBumpRepeat":case "mapBumpOffset":case "mapBumpWrap":case "mapBumpAnisotropy":break;case "mapNormal":m.normalMap=h(n,e.mapNormalRepeat,e.mapNormalOffset,e.mapNormalWrap,e.mapNormalAnisotropy);break;case "mapNormalFactor":m.normalScale=n;break;
16357 case "mapNormalRepeat":case "mapNormalOffset":case "mapNormalWrap":case "mapNormalAnisotropy":break;case "mapSpecular":m.specularMap=h(n,e.mapSpecularRepeat,e.mapSpecularOffset,e.mapSpecularWrap,e.mapSpecularAnisotropy);break;case "mapSpecularRepeat":case "mapSpecularOffset":case "mapSpecularWrap":case "mapSpecularAnisotropy":break;case "mapMetalness":m.metalnessMap=h(n,e.mapMetalnessRepeat,e.mapMetalnessOffset,e.mapMetalnessWrap,e.mapMetalnessAnisotropy);break;case "mapMetalnessRepeat":case "mapMetalnessOffset":case "mapMetalnessWrap":case "mapMetalnessAnisotropy":break;
16358 case "mapRoughness":m.roughnessMap=h(n,e.mapRoughnessRepeat,e.mapRoughnessOffset,e.mapRoughnessWrap,e.mapRoughnessAnisotropy);break;case "mapRoughnessRepeat":case "mapRoughnessOffset":case "mapRoughnessWrap":case "mapRoughnessAnisotropy":break;case "mapAlpha":m.alphaMap=h(n,e.mapAlphaRepeat,e.mapAlphaOffset,e.mapAlphaWrap,e.mapAlphaAnisotropy);break;case "mapAlphaRepeat":case "mapAlphaOffset":case "mapAlphaWrap":case "mapAlphaAnisotropy":break;case "flipSided":m.side=1;break;case "doubleSided":m.side=
16359 2;break;case "transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity");m.opacity=n;break;case "depthTest":case "depthWrite":case "colorWrite":case "opacity":case "reflectivity":case "transparent":case "visible":case "wireframe":m[l]=n;break;case "vertexColors":!0===n&&(m.vertexColors=2);"face"===n&&(m.vertexColors=1);break;default:console.error("THREE.Loader.createMaterial: Unsupported",l,n)}}"MeshBasicMaterial"===m.type&&delete m.emissive;"MeshPhongMaterial"!==
16360 m.type&&delete m.specular;1>m.opacity&&(m.transparent=!0);d.setTextures(k);return d.parse(m)}}()});var De={decodeText:function(a){if("undefined"!==typeof TextDecoder)return(new TextDecoder).decode(a);for(var b="",c=0,d=a.length;c<d;c++)b+=String.fromCharCode(a[c]);return decodeURIComponent(escape(b))},extractUrlBase:function(a){var b=a.lastIndexOf("/");return-1===b?"./":a.substr(0,b+1)}};Object.assign(he.prototype,{crossOrigin:"anonymous",load:function(a,b,c,d){var e=this,f=this.texturePath&&"string"===
16361 typeof this.texturePath?this.texturePath:De.extractUrlBase(a),g=new Ga(this.manager);g.setWithCredentials(this.withCredentials);g.load(a,function(c){c=JSON.parse(c);var d=c.metadata;if(void 0!==d&&(d=d.type,void 0!==d&&"object"===d.toLowerCase())){console.error("THREE.JSONLoader: "+a+" should be loaded with THREE.ObjectLoader instead.");return}c=e.parse(c,f);b(c.geometry,c.materials)},c,d)},setCrossOrigin:function(a){this.crossOrigin=a;return this},setTexturePath:function(a){this.texturePath=a;return this},
16362 parse:function(){return function(a,b){void 0!==a.data&&(a=a.data);a.scale=void 0!==a.scale?1/a.scale:1;var c=new R,d=a,e,f,g,h=d.faces;var k=d.vertices;var m=d.normals,l=d.colors;var n=d.scale;var t=0;if(void 0!==d.uvs){for(e=0;e<d.uvs.length;e++)d.uvs[e].length&&t++;for(e=0;e<t;e++)c.faceVertexUvs[e]=[]}var u=0;for(g=k.length;u<g;)e=new p,e.x=k[u++]*n,e.y=k[u++]*n,e.z=k[u++]*n,c.vertices.push(e);u=0;for(g=h.length;u<g;){k=h[u++];var r=k&1;var v=k&2;e=k&8;var y=k&16;var x=k&32;n=k&64;k&=128;if(r){r=
16363 new Ta;r.a=h[u];r.b=h[u+1];r.c=h[u+3];var w=new Ta;w.a=h[u+1];w.b=h[u+2];w.c=h[u+3];u+=4;v&&(v=h[u++],r.materialIndex=v,w.materialIndex=v);v=c.faces.length;if(e)for(e=0;e<t;e++){var B=d.uvs[e];c.faceVertexUvs[e][v]=[];c.faceVertexUvs[e][v+1]=[];for(f=0;4>f;f++){var E=h[u++];var A=B[2*E];E=B[2*E+1];A=new z(A,E);2!==f&&c.faceVertexUvs[e][v].push(A);0!==f&&c.faceVertexUvs[e][v+1].push(A)}}y&&(y=3*h[u++],r.normal.set(m[y++],m[y++],m[y]),w.normal.copy(r.normal));if(x)for(e=0;4>e;e++)y=3*h[u++],x=new p(m[y++],
16364 m[y++],m[y]),2!==e&&r.vertexNormals.push(x),0!==e&&w.vertexNormals.push(x);n&&(n=h[u++],n=l[n],r.color.setHex(n),w.color.setHex(n));if(k)for(e=0;4>e;e++)n=h[u++],n=l[n],2!==e&&r.vertexColors.push(new G(n)),0!==e&&w.vertexColors.push(new G(n));c.faces.push(r);c.faces.push(w)}else{r=new Ta;r.a=h[u++];r.b=h[u++];r.c=h[u++];v&&(v=h[u++],r.materialIndex=v);v=c.faces.length;if(e)for(e=0;e<t;e++)for(B=d.uvs[e],c.faceVertexUvs[e][v]=[],f=0;3>f;f++)E=h[u++],A=B[2*E],E=B[2*E+1],A=new z(A,E),c.faceVertexUvs[e][v].push(A);
16365 y&&(y=3*h[u++],r.normal.set(m[y++],m[y++],m[y]));if(x)for(e=0;3>e;e++)y=3*h[u++],x=new p(m[y++],m[y++],m[y]),r.vertexNormals.push(x);n&&(n=h[u++],r.color.setHex(l[n]));if(k)for(e=0;3>e;e++)n=h[u++],r.vertexColors.push(new G(l[n]));c.faces.push(r)}}d=a;u=void 0!==d.influencesPerVertex?d.influencesPerVertex:2;if(d.skinWeights)for(g=0,h=d.skinWeights.length;g<h;g+=u)c.skinWeights.push(new V(d.skinWeights[g],1<u?d.skinWeights[g+1]:0,2<u?d.skinWeights[g+2]:0,3<u?d.skinWeights[g+3]:0));if(d.skinIndices)for(g=
16366 0,h=d.skinIndices.length;g<h;g+=u)c.skinIndices.push(new V(d.skinIndices[g],1<u?d.skinIndices[g+1]:0,2<u?d.skinIndices[g+2]:0,3<u?d.skinIndices[g+3]:0));c.bones=d.bones;c.bones&&0<c.bones.length&&(c.skinWeights.length!==c.skinIndices.length||c.skinIndices.length!==c.vertices.length)&&console.warn("When skinning, number of vertices ("+c.vertices.length+"), skinIndices ("+c.skinIndices.length+"), and skinWeights ("+c.skinWeights.length+") should match.");g=a;h=g.scale;if(void 0!==g.morphTargets)for(d=
16367 0,u=g.morphTargets.length;d<u;d++)for(c.morphTargets[d]={},c.morphTargets[d].name=g.morphTargets[d].name,c.morphTargets[d].vertices=[],m=c.morphTargets[d].vertices,l=g.morphTargets[d].vertices,t=0,k=l.length;t<k;t+=3)n=new p,n.x=l[t]*h,n.y=l[t+1]*h,n.z=l[t+2]*h,m.push(n);if(void 0!==g.morphColors&&0<g.morphColors.length)for(console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.'),h=c.faces,g=g.morphColors[0].colors,d=0,u=h.length;d<u;d++)h[d].color.fromArray(g,
16368 3*d);g=a;d=[];u=[];void 0!==g.animation&&u.push(g.animation);void 0!==g.animations&&(g.animations.length?u=u.concat(g.animations):u.push(g.animations));for(g=0;g<u.length;g++)(h=Ca.parseAnimation(u[g],c.bones))&&d.push(h);c.morphTargets&&(u=Ca.CreateClipsFromMorphTargetSequences(c.morphTargets,10),d=d.concat(u));0<d.length&&(c.animations=d);c.computeFaceNormals();c.computeBoundingSphere();if(void 0===a.materials||0===a.materials.length)return{geometry:c};a=gc.prototype.initMaterials(a.materials,b,
16369 this.crossOrigin);return{geometry:c,materials:a}}}()});Object.assign(mf.prototype,{crossOrigin:"anonymous",load:function(a,b,c,d){""===this.texturePath&&(this.texturePath=a.substring(0,a.lastIndexOf("/")+1));var e=this;(new Ga(e.manager)).load(a,function(c){var f=null;try{f=JSON.parse(c)}catch(h){void 0!==d&&d(h);console.error("THREE:ObjectLoader: Can't parse "+a+".",h.message);return}c=f.metadata;void 0===c||void 0===c.type||"geometry"===c.type.toLowerCase()?console.error("THREE.ObjectLoader: Can't load "+
16370 a+". Use THREE.JSONLoader instead."):e.parse(f,b)},c,d)},setTexturePath:function(a){this.texturePath=a;return this},setCrossOrigin:function(a){this.crossOrigin=a;return this},parse:function(a,b){var c=this.parseShape(a.shapes);c=this.parseGeometries(a.geometries,c);var d=this.parseImages(a.images,function(){void 0!==b&&b(e)});d=this.parseTextures(a.textures,d);d=this.parseMaterials(a.materials,d);var e=this.parseObject(a.object,c,d);a.animations&&(e.animations=this.parseAnimations(a.animations));
16371 void 0!==a.images&&0!==a.images.length||void 0===b||b(e);return e},parseShape:function(a){var b={};if(void 0!==a)for(var c=0,d=a.length;c<d;c++){var e=(new db).fromJSON(a[c]);b[e.uuid]=e}return b},parseGeometries:function(a,b){var c={};if(void 0!==a)for(var d=new he,e=new ge,f=0,g=a.length;f<g;f++){var h=a[f];switch(h.type){case "PlaneGeometry":case "PlaneBufferGeometry":var k=new xa[h.type](h.width,h.height,h.widthSegments,h.heightSegments);break;case "BoxGeometry":case "BoxBufferGeometry":case "CubeGeometry":k=
16372 new xa[h.type](h.width,h.height,h.depth,h.widthSegments,h.heightSegments,h.depthSegments);break;case "CircleGeometry":case "CircleBufferGeometry":k=new xa[h.type](h.radius,h.segments,h.thetaStart,h.thetaLength);break;case "CylinderGeometry":case "CylinderBufferGeometry":k=new xa[h.type](h.radiusTop,h.radiusBottom,h.height,h.radialSegments,h.heightSegments,h.openEnded,h.thetaStart,h.thetaLength);break;case "ConeGeometry":case "ConeBufferGeometry":k=new xa[h.type](h.radius,h.height,h.radialSegments,
16373 h.heightSegments,h.openEnded,h.thetaStart,h.thetaLength);break;case "SphereGeometry":case "SphereBufferGeometry":k=new xa[h.type](h.radius,h.widthSegments,h.heightSegments,h.phiStart,h.phiLength,h.thetaStart,h.thetaLength);break;case "DodecahedronGeometry":case "DodecahedronBufferGeometry":case "IcosahedronGeometry":case "IcosahedronBufferGeometry":case "OctahedronGeometry":case "OctahedronBufferGeometry":case "TetrahedronGeometry":case "TetrahedronBufferGeometry":k=new xa[h.type](h.radius,h.detail);
16374 break;case "RingGeometry":case "RingBufferGeometry":k=new xa[h.type](h.innerRadius,h.outerRadius,h.thetaSegments,h.phiSegments,h.thetaStart,h.thetaLength);break;case "TorusGeometry":case "TorusBufferGeometry":k=new xa[h.type](h.radius,h.tube,h.radialSegments,h.tubularSegments,h.arc);break;case "TorusKnotGeometry":case "TorusKnotBufferGeometry":k=new xa[h.type](h.radius,h.tube,h.tubularSegments,h.radialSegments,h.p,h.q);break;case "LatheGeometry":case "LatheBufferGeometry":k=new xa[h.type](h.points,
16375 h.segments,h.phiStart,h.phiLength);break;case "PolyhedronGeometry":case "PolyhedronBufferGeometry":k=new xa[h.type](h.vertices,h.indices,h.radius,h.details);break;case "ShapeGeometry":case "ShapeBufferGeometry":k=[];for(var m=0,l=h.shapes.length;m<l;m++){var n=b[h.shapes[m]];k.push(n)}k=new xa[h.type](k,h.curveSegments);break;case "ExtrudeGeometry":case "ExtrudeBufferGeometry":k=[];m=0;for(l=h.shapes.length;m<l;m++)n=b[h.shapes[m]],k.push(n);m=h.options.extrudePath;void 0!==m&&(h.options.extrudePath=
16376 (new Af[m.type]).fromJSON(m));k=new xa[h.type](k,h.options);break;case "BufferGeometry":k=e.parse(h);break;case "Geometry":k=d.parse(h,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+h.type+'"');continue}k.uuid=h.uuid;void 0!==h.name&&(k.name=h.name);!0===k.isBufferGeometry&&void 0!==h.userData&&(k.userData=h.userData);c[h.uuid]=k}return c},parseMaterials:function(a,b){var c={};if(void 0!==a){var d=new Kd;d.setTextures(b);b=0;for(var e=a.length;b<
16377 e;b++){var f=a[b];if("MultiMaterial"===f.type){for(var g=[],h=0;h<f.materials.length;h++)g.push(d.parse(f.materials[h]));c[f.uuid]=g}else c[f.uuid]=d.parse(f)}}return c},parseAnimations:function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c],e=Ca.parse(d);void 0!==d.uuid&&(e.uuid=d.uuid);b.push(e)}return b},parseImages:function(a,b){function c(a){d.manager.itemStart(a);return f.load(a,function(){d.manager.itemEnd(a)},void 0,function(){d.manager.itemEnd(a);d.manager.itemError(a)})}var d=this,e={};
16378 if(void 0!==a&&0<a.length){b=new ce(b);var f=new Zc(b);f.setCrossOrigin(this.crossOrigin);b=0;for(var g=a.length;b<g;b++){var h=a[b],k=h.url;if(Array.isArray(k)){e[h.uuid]=[];for(var m=0,l=k.length;m<l;m++){var n=k[m];n=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:d.texturePath+n;e[h.uuid].push(c(n))}}else n=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h.url)?h.url:d.texturePath+h.url,e[h.uuid]=c(n)}}return e},parseTextures:function(a,b){function c(a,b){if("number"===typeof a)return a;console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",
16379 a);return b[a]}var d={};if(void 0!==a)for(var e=0,f=a.length;e<f;e++){var g=a[e];void 0===g.image&&console.warn('THREE.ObjectLoader: No "image" specified for',g.uuid);void 0===b[g.image]&&console.warn("THREE.ObjectLoader: Undefined image",g.image);var h=Array.isArray(b[g.image])?new Ua(b[g.image]):new T(b[g.image]);h.needsUpdate=!0;h.uuid=g.uuid;void 0!==g.name&&(h.name=g.name);void 0!==g.mapping&&(h.mapping=c(g.mapping,Wg));void 0!==g.offset&&h.offset.fromArray(g.offset);void 0!==g.repeat&&h.repeat.fromArray(g.repeat);
16380 void 0!==g.center&&h.center.fromArray(g.center);void 0!==g.rotation&&(h.rotation=g.rotation);void 0!==g.wrap&&(h.wrapS=c(g.wrap[0],Cf),h.wrapT=c(g.wrap[1],Cf));void 0!==g.format&&(h.format=g.format);void 0!==g.minFilter&&(h.minFilter=c(g.minFilter,Df));void 0!==g.magFilter&&(h.magFilter=c(g.magFilter,Df));void 0!==g.anisotropy&&(h.anisotropy=g.anisotropy);void 0!==g.flipY&&(h.flipY=g.flipY);d[g.uuid]=h}return d},parseObject:function(a,b,c){function d(a){void 0===b[a]&&console.warn("THREE.ObjectLoader: Undefined geometry",
16381 a);return b[a]}function e(a){if(void 0!==a){if(Array.isArray(a)){for(var b=[],d=0,e=a.length;d<e;d++){var f=a[d];void 0===c[f]&&console.warn("THREE.ObjectLoader: Undefined material",f);b.push(c[f])}return b}void 0===c[a]&&console.warn("THREE.ObjectLoader: Undefined material",a);return c[a]}}switch(a.type){case "Scene":var f=new qd;void 0!==a.background&&Number.isInteger(a.background)&&(f.background=new G(a.background));void 0!==a.fog&&("Fog"===a.fog.type?f.fog=new Mb(a.fog.color,a.fog.near,a.fog.far):
16382 "FogExp2"===a.fog.type&&(f.fog=new Lb(a.fog.color,a.fog.density)));break;case "PerspectiveCamera":f=new Z(a.fov,a.aspect,a.near,a.far);void 0!==a.focus&&(f.focus=a.focus);void 0!==a.zoom&&(f.zoom=a.zoom);void 0!==a.filmGauge&&(f.filmGauge=a.filmGauge);void 0!==a.filmOffset&&(f.filmOffset=a.filmOffset);void 0!==a.view&&(f.view=Object.assign({},a.view));break;case "OrthographicCamera":f=new Hb(a.left,a.right,a.top,a.bottom,a.near,a.far);void 0!==a.zoom&&(f.zoom=a.zoom);void 0!==a.view&&(f.view=Object.assign({},
16383 a.view));break;case "AmbientLight":f=new Cd(a.color,a.intensity);break;case "DirectionalLight":f=new Bd(a.color,a.intensity);break;case "PointLight":f=new zd(a.color,a.intensity,a.distance,a.decay);break;case "RectAreaLight":f=new Dd(a.color,a.intensity,a.width,a.height);break;case "SpotLight":f=new yd(a.color,a.intensity,a.distance,a.angle,a.penumbra,a.decay);break;case "HemisphereLight":f=new wd(a.color,a.groundColor,a.intensity);break;case "SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");
16384 case "Mesh":f=d(a.geometry);var g=e(a.material);f=f.bones&&0<f.bones.length?new sd(f,g):new la(f,g);break;case "LOD":f=new Bc;break;case "Line":f=new sa(d(a.geometry),e(a.material),a.mode);break;case "LineLoop":f=new td(d(a.geometry),e(a.material));break;case "LineSegments":f=new W(d(a.geometry),e(a.material));break;case "PointCloud":case "Points":f=new Ob(d(a.geometry),e(a.material));break;case "Sprite":f=new Ac(e(a.material));break;case "Group":f=new Kb;break;default:f=new D}f.uuid=a.uuid;void 0!==
16385 a.name&&(f.name=a.name);void 0!==a.matrix?(f.matrix.fromArray(a.matrix),void 0!==a.matrixAutoUpdate&&(f.matrixAutoUpdate=a.matrixAutoUpdate),f.matrixAutoUpdate&&f.matrix.decompose(f.position,f.quaternion,f.scale)):(void 0!==a.position&&f.position.fromArray(a.position),void 0!==a.rotation&&f.rotation.fromArray(a.rotation),void 0!==a.quaternion&&f.quaternion.fromArray(a.quaternion),void 0!==a.scale&&f.scale.fromArray(a.scale));void 0!==a.castShadow&&(f.castShadow=a.castShadow);void 0!==a.receiveShadow&&
16386 (f.receiveShadow=a.receiveShadow);a.shadow&&(void 0!==a.shadow.bias&&(f.shadow.bias=a.shadow.bias),void 0!==a.shadow.radius&&(f.shadow.radius=a.shadow.radius),void 0!==a.shadow.mapSize&&f.shadow.mapSize.fromArray(a.shadow.mapSize),void 0!==a.shadow.camera&&(f.shadow.camera=this.parseObject(a.shadow.camera)));void 0!==a.visible&&(f.visible=a.visible);void 0!==a.frustumCulled&&(f.frustumCulled=a.frustumCulled);void 0!==a.renderOrder&&(f.renderOrder=a.renderOrder);void 0!==a.userData&&(f.userData=a.userData);
16387 void 0!==a.layers&&(f.layers.mask=a.layers);if(void 0!==a.children){g=a.children;for(var h=0;h<g.length;h++)f.add(this.parseObject(g[h],b,c))}if("LOD"===a.type)for(a=a.levels,g=0;g<a.length;g++){h=a[g];var k=f.getObjectByProperty("uuid",h.object);void 0!==k&&f.addLevel(k,h.distance)}return f}});var Wg={UVMapping:300,CubeReflectionMapping:301,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,SphericalReflectionMapping:305,CubeUVReflectionMapping:306,
16388 CubeUVRefractionMapping:307},Cf={RepeatWrapping:1E3,ClampToEdgeWrapping:1001,MirroredRepeatWrapping:1002},Df={NearestFilter:1003,NearestMipMapNearestFilter:1004,NearestMipMapLinearFilter:1005,LinearFilter:1006,LinearMipMapNearestFilter:1007,LinearMipMapLinearFilter:1008};ie.prototype={constructor:ie,setOptions:function(a){this.options=a;return this},load:function(a,b,c,d){void 0===a&&(a="");void 0!==this.path&&(a=this.path+a);a=this.manager.resolveURL(a);var e=this,f=Fb.get(a);if(void 0!==f)return e.manager.itemStart(a),
16389 setTimeout(function(){b&&b(f);e.manager.itemEnd(a)},0),f;fetch(a).then(function(a){return a.blob()}).then(function(a){return createImageBitmap(a,e.options)}).then(function(c){Fb.add(a,c);b&&b(c);e.manager.itemEnd(a)}).catch(function(b){d&&d(b);e.manager.itemEnd(a);e.manager.itemError(a)})},setCrossOrigin:function(){return this},setPath:function(a){this.path=a;return this}};Object.assign(je.prototype,{moveTo:function(a,b){this.currentPath=new La;this.subPaths.push(this.currentPath);this.currentPath.moveTo(a,
16390 b)},lineTo:function(a,b){this.currentPath.lineTo(a,b)},quadraticCurveTo:function(a,b,c,d){this.currentPath.quadraticCurveTo(a,b,c,d)},bezierCurveTo:function(a,b,c,d,e,f){this.currentPath.bezierCurveTo(a,b,c,d,e,f)},splineThru:function(a){this.currentPath.splineThru(a)},toShapes:function(a,b){function c(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c],f=new db;f.curves=e.curves;b.push(f)}return b}function d(a,b){for(var c=b.length,d=!1,e=c-1,f=0;f<c;e=f++){var g=b[e],h=b[f],k=h.x-g.x,m=h.y-g.y;if(Math.abs(m)>
16391 Number.EPSILON){if(0>m&&(g=b[f],k=-k,h=b[e],m=-m),!(a.y<g.y||a.y>h.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=m*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=Va.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);b=[];if(1===f.length){var g=f[0];var h=new db;h.curves=g.curves;b.push(h);return b}var k=!e(f[0].getPoints());k=a?!k:k;h=[];var m=[],l=[],n=0;m[n]=void 0;l[n]=[];for(var p=
16392 0,u=f.length;p<u;p++){g=f[p];var r=g.getPoints();var v=e(r);(v=a?!v:v)?(!k&&m[n]&&n++,m[n]={s:new db,p:r},m[n].s.curves=g.curves,k&&n++,l[n]=[]):l[n].push({h:g,p:r[0]})}if(!m[0])return c(f);if(1<m.length){p=!1;a=[];e=0;for(f=m.length;e<f;e++)h[e]=[];e=0;for(f=m.length;e<f;e++)for(g=l[e],v=0;v<g.length;v++){k=g[v];n=!0;for(r=0;r<m.length;r++)d(k.p,m[r].p)&&(e!==r&&a.push({froms:e,tos:r,hole:v}),n?(n=!1,h[r].push(k)):p=!0);n&&h[e].push(k)}0<a.length&&(p||(l=h))}p=0;for(e=m.length;p<e;p++)for(h=m[p].s,
16393 b.push(h),a=l[p],f=0,g=a.length;f<g;f++)h.holes.push(a[f].h);return b}});Object.assign(ke.prototype,{isFont:!0,generateShapes:function(a,b){void 0===b&&(b=100);var c=[],d=b;b=this.data;var e=Array.from?Array.from(a):String(a).split("");d/=b.resolution;var f=(b.boundingBox.yMax-b.boundingBox.yMin+b.underlineThickness)*d;a=[];for(var g=0,h=0,k=0;k<e.length;k++){var m=e[k];if("\n"===m)g=0,h-=f;else{var l=d;var n=g,p=h;if(m=b.glyphs[m]||b.glyphs["?"]){var u=new je;if(m.o)for(var r=m._cachedOutline||(m._cachedOutline=
16394 m.o.split(" ")),v=0,y=r.length;v<y;)switch(r[v++]){case "m":var x=r[v++]*l+n;var w=r[v++]*l+p;u.moveTo(x,w);break;case "l":x=r[v++]*l+n;w=r[v++]*l+p;u.lineTo(x,w);break;case "q":var z=r[v++]*l+n;var A=r[v++]*l+p;var C=r[v++]*l+n;var D=r[v++]*l+p;u.quadraticCurveTo(C,D,z,A);break;case "b":z=r[v++]*l+n,A=r[v++]*l+p,C=r[v++]*l+n,D=r[v++]*l+p,x=r[v++]*l+n,w=r[v++]*l+p,u.bezierCurveTo(C,D,x,w,z,A)}l={offsetX:m.ha*l,path:u}}else l=void 0;g+=l.offsetX;a.push(l.path)}}b=0;for(e=a.length;b<e;b++)Array.prototype.push.apply(c,
16395 a[b].toShapes());return c}});Object.assign(nf.prototype,{load:function(a,b,c,d){var e=this,f=new Ga(this.manager);f.setPath(this.path);f.load(a,function(a){try{var c=JSON.parse(a)}catch(k){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),c=JSON.parse(a.substring(65,a.length-2))}a=e.parse(c);b&&b(a)},c,d)},parse:function(a){return new ke(a)},setPath:function(a){this.path=a;return this}});var Pd,ne={getContext:function(){void 0===Pd&&(Pd=new (window.AudioContext||
16396 window.webkitAudioContext));return Pd},setContext:function(a){Pd=a}};Object.assign(le.prototype,{load:function(a,b,c,d){var e=new Ga(this.manager);e.setResponseType("arraybuffer");e.load(a,function(a){a=a.slice(0);ne.getContext().decodeAudioData(a,function(a){b(a)})},c,d)}});Object.assign(of.prototype,{update:function(){var a,b,c,d,e,f,g,h,k=new I,l=new I;return function(m){if(a!==this||b!==m.focus||c!==m.fov||d!==m.aspect*this.aspect||e!==m.near||f!==m.far||g!==m.zoom||h!==this.eyeSep){a=this;b=
16397 m.focus;c=m.fov;d=m.aspect*this.aspect;e=m.near;f=m.far;g=m.zoom;var n=m.projectionMatrix.clone();h=this.eyeSep/2;var p=h*e/b,q=e*Math.tan(H.DEG2RAD*c*.5)/g;l.elements[12]=-h;k.elements[12]=h;var r=-q*d+p;var v=q*d+p;n.elements[0]=2*e/(v-r);n.elements[8]=(v+r)/(v-r);this.cameraL.projectionMatrix.copy(n);r=-q*d-p;v=q*d-p;n.elements[0]=2*e/(v-r);n.elements[8]=(v+r)/(v-r);this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(m.matrixWorld).multiply(l);this.cameraR.matrixWorld.copy(m.matrixWorld).multiply(k)}}()});
16398 dd.prototype=Object.create(D.prototype);dd.prototype.constructor=dd;me.prototype=Object.assign(Object.create(D.prototype),{constructor:me,getInput:function(){return this.gain},removeFilter:function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null);return this},getFilter:function(){return this.filter},setFilter:function(a){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):
16399 this.gain.disconnect(this.context.destination);this.filter=a;this.gain.connect(this.filter);this.filter.connect(this.context.destination);return this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this},updateMatrixWorld:function(){var a=new p,b=new fa,c=new p,d=new p;return function(e){D.prototype.updateMatrixWorld.call(this,e);e=this.context.listener;var f=this.up;this.matrixWorld.decompose(a,
16400 b,c);d.set(0,0,-1).applyQuaternion(b);e.positionX?(e.positionX.setValueAtTime(a.x,this.context.currentTime),e.positionY.setValueAtTime(a.y,this.context.currentTime),e.positionZ.setValueAtTime(a.z,this.context.currentTime),e.forwardX.setValueAtTime(d.x,this.context.currentTime),e.forwardY.setValueAtTime(d.y,this.context.currentTime),e.forwardZ.setValueAtTime(d.z,this.context.currentTime),e.upX.setValueAtTime(f.x,this.context.currentTime),e.upY.setValueAtTime(f.y,this.context.currentTime),e.upZ.setValueAtTime(f.z,
16401 this.context.currentTime)):(e.setPosition(a.x,a.y,a.z),e.setOrientation(d.x,d.y,d.z,f.x,f.y,f.z))}}()});hc.prototype=Object.assign(Object.create(D.prototype),{constructor:hc,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl=!1;this.sourceType="audioNode";this.source=a;this.connect();return this},setMediaElementSource:function(a){this.hasPlaybackControl=!1;this.sourceType="mediaNode";this.source=this.context.createMediaElementSource(a);this.connect();return this},
16402 setBuffer:function(a){this.buffer=a;this.sourceType="buffer";this.autoplay&&this.play();return this},play:function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else{var a=this.context.createBufferSource();a.buffer=this.buffer;a.loop=this.loop;a.onended=this.onEnded.bind(this);a.playbackRate.setValueAtTime(this.playbackRate,this.startTime);this.startTime=this.context.currentTime;
16403 a.start(this.startTime,this.offset);this.isPlaying=!0;this.source=a;return this.connect()}},pause:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return!0===this.isPlaying&&(this.source.stop(),this.source.onended=null,this.offset+=(this.context.currentTime-this.startTime)*this.playbackRate,this.isPlaying=!1),this},stop:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.source.stop(),
16404 this.source.onended=null,this.offset=0,this.isPlaying=!1,this},connect:function(){if(0<this.filters.length){this.source.connect(this.filters[0]);for(var a=1,b=this.filters.length;a<b;a++)this.filters[a-1].connect(this.filters[a]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(0<this.filters.length){this.source.disconnect(this.filters[0]);for(var a=1,b=this.filters.length;a<b;a++)this.filters[a-1].disconnect(this.filters[a]);
16405 this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(a){a||(a=[]);!0===this.isPlaying?(this.disconnect(),this.filters=a,this.connect()):this.filters=a;return this},getFilter:function(){return this.getFilters()[0]},setFilter:function(a){return this.setFilters(a?[a]:[])},setPlaybackRate:function(a){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");
16406 else return this.playbackRate=a,!0===this.isPlaying&&this.source.playbackRate.setValueAtTime(this.playbackRate,this.context.currentTime),this},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(a){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.loop=
16407 a,!0===this.isPlaying&&(this.source.loop=this.loop),this},getVolume:function(){return this.gain.gain.value},setVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this}});oe.prototype=Object.assign(Object.create(hc.prototype),{constructor:oe,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(a){this.panner.refDistance=a;return this},getRolloffFactor:function(){return this.panner.rolloffFactor},
16408 setRolloffFactor:function(a){this.panner.rolloffFactor=a;return this},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(a){this.panner.distanceModel=a;return this},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(a){this.panner.maxDistance=a;return this},setDirectionalCone:function(a,b,c){this.panner.coneInnerAngle=a;this.panner.coneOuterAngle=b;this.panner.coneOuterGain=c;return this},updateMatrixWorld:function(){var a=new p,
16409 b=new fa,c=new p,d=new p;return function(e){D.prototype.updateMatrixWorld.call(this,e);e=this.panner;this.matrixWorld.decompose(a,b,c);d.set(0,0,1).applyQuaternion(b);e.setPosition(a.x,a.y,a.z);e.setOrientation(d.x,d.y,d.z)}}()});Object.assign(pe.prototype,{getFrequencyData:function(){this.analyser.getByteFrequencyData(this.data);return this.data},getAverageFrequency:function(){for(var a=0,b=this.getFrequencyData(),c=0;c<b.length;c++)a+=b[c];return a/b.length}});Object.assign(qe.prototype,{accumulate:function(a,
16410 b){var c=this.buffer,d=this.valueSize;a=a*d+d;var e=this.cumulativeWeight;if(0===e){for(e=0;e!==d;++e)c[a+e]=c[e];e=b}else e+=b,this._mixBufferRegion(c,a,0,b/e,d);this.cumulativeWeight=e},apply:function(a){var b=this.valueSize,c=this.buffer;a=a*b+b;var d=this.cumulativeWeight,e=this.binding;this.cumulativeWeight=0;1>d&&this._mixBufferRegion(c,a,3*b,1-d,b);d=b;for(var f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,
16411 c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d){fa.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}});Object.assign(pf.prototype,{getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];void 0!==c&&c.getValue(a,
16412 b)},setValue:function(a,b){for(var c=this._bindings,d=this._targetGroup.nCachedObjects_,e=c.length;d!==e;++d)c[d].setValue(a,b)},bind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].bind()},unbind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].unbind()}});Object.assign(pa,{Composite:pf,create:function(a,b,c){return a&&a.isAnimationObjectGroup?new pa.Composite(a,b,c):new pa(a,b,c)},sanitizeNodeName:function(){var a=
16413 /[\[\]\.:\/]/g;return function(b){return b.replace(/\s/g,"_").replace(a,"")}}(),parseTrackName:function(){var a="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",b=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]");a=/(WCOD+)?/.source.replace("WCOD",a);var c=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),d=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),e=new RegExp("^"+b+a+c+d+"$"),f=["material","materials","bones"];return function(a){var b=e.exec(a);if(!b)throw Error("PropertyBinding: Cannot parse trackName: "+
16414 a);b={nodeName:b[2],objectName:b[3],objectIndex:b[4],propertyName:b[5],propertyIndex:b[6]};var c=b.nodeName&&b.nodeName.lastIndexOf(".");if(void 0!==c&&-1!==c){var d=b.nodeName.substring(c+1);-1!==f.indexOf(d)&&(b.nodeName=b.nodeName.substring(0,c),b.objectName=d)}if(null===b.propertyName||0===b.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+a);return b}}(),findNode:function(a,b){if(!b||""===b||"root"===b||"."===b||-1===b||b===a.name||b===a.uuid)return a;
16415 if(a.skeleton){var c=a.skeleton.getBoneByName(b);if(void 0!==c)return c}if(a.children){var d=function(a){for(var c=0;c<a.length;c++){var e=a[c];if(e.name===b||e.uuid===b||(e=d(e.children)))return e}return null};if(a=d(a.children))return a}return null}});Object.assign(pa.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(a,
16416 b){a[b]=this.node[this.propertyName]},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)a[b++]=c[d]},function(a,b){a[b]=this.resolvedProperty[this.propertyIndex]},function(a,b){this.resolvedProperty.toArray(a,b)}],SetterByBindingTypeAndVersioning:[[function(a,b){this.targetObject[this.propertyName]=a[b]},function(a,b){this.targetObject[this.propertyName]=a[b];this.targetObject.needsUpdate=!0},function(a,b){this.targetObject[this.propertyName]=a[b];this.targetObject.matrixWorldNeedsUpdate=
16417 !0}],[function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++]},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++];this.targetObject.needsUpdate=!0},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){this.resolvedProperty[this.propertyIndex]=a[b]},function(a,b){this.resolvedProperty[this.propertyIndex]=a[b];this.targetObject.needsUpdate=!0},function(a,
16418 b){this.resolvedProperty[this.propertyIndex]=a[b];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){this.resolvedProperty.fromArray(a,b)},function(a,b){this.resolvedProperty.fromArray(a,b);this.targetObject.needsUpdate=!0},function(a,b){this.resolvedProperty.fromArray(a,b);this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(a,b){this.bind();this.getValue(a,b)},setValue:function(a,b){this.bind();this.setValue(a,b)},bind:function(){var a=this.node,b=this.parsedPath,c=b.objectName,
16419 d=b.propertyName,e=b.propertyIndex;a||(this.node=a=pa.findNode(this.rootNode,b.nodeName)||this.rootNode);this.getValue=this._getValue_unavailable;this.setValue=this._setValue_unavailable;if(a){if(c){var f=b.objectIndex;switch(c){case "materials":if(!a.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!a.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",
16420 this);return}a=a.material.materials;break;case "bones":if(!a.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}a=a.skeleton.bones;for(c=0;c<a.length;c++)if(a[c].name===f){f=c;break}break;default:if(void 0===a[c]){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}a=a[c]}if(void 0!==f){if(void 0===a[f]){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",
16421 this,a);return}a=a[f]}}f=a[d];if(void 0===f)console.error("THREE.PropertyBinding: Trying to update property for track: "+b.nodeName+"."+d+" but it wasn't found.",a);else{b=this.Versioning.None;void 0!==a.needsUpdate?(b=this.Versioning.NeedsUpdate,this.targetObject=a):void 0!==a.matrixWorldNeedsUpdate&&(b=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=a);c=this.BindingType.Direct;if(void 0!==e){if("morphTargetInfluences"===d){if(!a.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",
16422 this);return}if(a.geometry.isBufferGeometry){if(!a.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}for(c=0;c<this.node.geometry.morphAttributes.position.length;c++)if(a.geometry.morphAttributes.position[c].name===e){e=c;break}}else{if(!a.geometry.morphTargets){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",
16423 this);return}for(c=0;c<this.node.geometry.morphTargets.length;c++)if(a.geometry.morphTargets[c].name===e){e=c;break}}}c=this.BindingType.ArrayElement;this.resolvedProperty=f;this.propertyIndex=e}else void 0!==f.fromArray&&void 0!==f.toArray?(c=this.BindingType.HasFromToArray,this.resolvedProperty=f):Array.isArray(f)?(c=this.BindingType.EntireArray,this.resolvedProperty=f):this.propertyName=d;this.getValue=this.GetterByBindingType[c];this.setValue=this.SetterByBindingTypeAndVersioning[c][b]}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+
16424 this.path+" but it wasn't found.")},unbind:function(){this.node=null;this.getValue=this._getValue_unbound;this.setValue=this._setValue_unbound}});Object.assign(pa.prototype,{_getValue_unbound:pa.prototype.getValue,_setValue_unbound:pa.prototype.setValue});Object.assign(qf.prototype,{isAnimationObjectGroup:!0,add:function(){for(var a=this._objects,b=a.length,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._paths,f=this._parsedPaths,g=this._bindings,h=g.length,k=void 0,l=0,p=arguments.length;l!==
16425 p;++l){var n=arguments[l],t=n.uuid,u=d[t];if(void 0===u){u=b++;d[t]=u;a.push(n);t=0;for(var r=h;t!==r;++t)g[t].push(new pa(n,e[t],f[t]))}else if(u<c){k=a[u];var v=--c;r=a[v];d[r.uuid]=u;a[u]=r;d[t]=v;a[v]=n;t=0;for(r=h;t!==r;++t){var y=g[t],x=y[u];y[u]=y[v];void 0===x&&(x=new pa(n,e[t],f[t]));y[v]=x}}else a[u]!==k&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=
16426 c},remove:function(){for(var a=this._objects,b=this.nCachedObjects_,c=this._indicesByUUID,d=this._bindings,e=d.length,f=0,g=arguments.length;f!==g;++f){var h=arguments[f],k=h.uuid,l=c[k];if(void 0!==l&&l>=b){var p=b++,n=a[p];c[n.uuid]=l;a[l]=n;c[k]=p;a[p]=h;h=0;for(k=e;h!==k;++h){n=d[h];var t=n[l];n[l]=n[p];n[p]=t}}}this.nCachedObjects_=b},uncache:function(){for(var a=this._objects,b=a.length,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._bindings,f=e.length,g=0,h=arguments.length;g!==h;++g){var k=
16427 arguments[g].uuid,l=d[k];if(void 0!==l)if(delete d[k],l<c){k=--c;var p=a[k],n=--b,t=a[n];d[p.uuid]=l;a[l]=p;d[t.uuid]=k;a[k]=t;a.pop();p=0;for(t=f;p!==t;++p){var u=e[p],r=u[n];u[l]=u[k];u[k]=r;u.pop()}}else for(n=--b,t=a[n],d[t.uuid]=l,a[l]=t,a.pop(),p=0,t=f;p!==t;++p)u=e[p],u[l]=u[n],u.pop()}this.nCachedObjects_=c},subscribe_:function(a,b){var c=this._bindingsIndicesByPath,d=c[a],e=this._bindings;if(void 0!==d)return e[d];var f=this._paths,g=this._parsedPaths,h=this._objects,k=this.nCachedObjects_,
16428 l=Array(h.length);d=e.length;c[a]=d;f.push(a);g.push(b);e.push(l);c=k;for(d=h.length;c!==d;++c)l[c]=new pa(h[c],a,b);return l},unsubscribe_:function(a){var b=this._bindingsIndicesByPath,c=b[a];if(void 0!==c){var d=this._paths,e=this._parsedPaths,f=this._bindings,g=f.length-1,h=f[g];b[a[g]]=c;f[c]=h;f.pop();e[c]=e[g];e.pop();d[c]=d[g];d.pop()}}});Object.assign(rf.prototype,{play:function(){this._mixer._activateAction(this);return this},stop:function(){this._mixer._deactivateAction(this);return this.reset()},
16429 reset:function(){this.paused=!1;this.enabled=!0;this.time=0;this._loopCount=-1;this._startTime=null;return this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(a){this._startTime=a;return this},setLoop:function(a,b){this.loop=a;this.repetitions=b;return this},setEffectiveWeight:function(a){this.weight=a;
16430 this._effectiveWeight=this.enabled?a:0;return this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(a){return this._scheduleFading(a,0,1)},fadeOut:function(a){return this._scheduleFading(a,1,0)},crossFadeFrom:function(a,b,c){a.fadeOut(b);this.fadeIn(b);if(c){c=this._clip.duration;var d=a._clip.duration,e=c/d;a.warp(1,d/c,b);this.warp(e,1,b)}return this},crossFadeTo:function(a,b,c){return a.crossFadeFrom(this,b,c)},stopFading:function(){var a=this._weightInterpolant;
16431 null!==a&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(a));return this},setEffectiveTimeScale:function(a){this.timeScale=a;this._effectiveTimeScale=this.paused?0:a;return this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(a){this.timeScale=this._clip.duration/a;return this.stopWarping()},syncWith:function(a){this.time=a.time;this.timeScale=a.timeScale;return this.stopWarping()},halt:function(a){return this.warp(this._effectiveTimeScale,
16432 0,a)},warp:function(a,b,c){var d=this._mixer,e=d.time,f=this._timeScaleInterpolant,g=this.timeScale;null===f&&(this._timeScaleInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;d[1]=e+c;f[0]=a/g;f[1]=b/g;return this},stopWarping:function(){var a=this._timeScaleInterpolant;null!==a&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(a));return this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||
16433 this._mixer._root},_update:function(a,b,c,d){if(this.enabled){var e=this._startTime;if(null!==e){b=(a-e)*c;if(0>b||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0<a){b=this._interpolants;e=this._propertyBindings;for(var f=0,g=b.length;f!==g;++f)b[f].evaluate(c),e[f].accumulate(d,a)}}else this._updateWeight(a)},_updateWeight:function(a){var b=0;if(this.enabled){b=this.weight;var c=this._weightInterpolant;if(null!==c){var d=c.evaluate(a)[0];
16434 b*=d;a>c.parameterPositions[1]&&(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){b=this.timeScale;var c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0];b*=d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale=b},_updateTime:function(a){var b=this.time+a,c=this._clip.duration,d=this.loop,e=this._loopCount,f=2202===d;if(0===a)return-1===
16435 e?b:f&&1===(e&1)?c-b:b;if(2200===d)a:{if(-1===e&&(this._loopCount=0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else break a;this.clampWhenFinished?this.paused=!0:this.enabled=!1;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1})}else{-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,f)):this._setEndings(0===this.repetitions,!0,f));if(b>=c||0>b){d=Math.floor(b/c);b-=c*d;e+=Math.abs(d);var g=this.repetitions-e;0>=g?(this.clampWhenFinished?this.paused=!0:
16436 this.enabled=!1,b=0<a?c:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:0<a?1:-1})):(1===g?(a=0>a,this._setEndings(a,!a,f)):this._setEndings(!1,!1,f),this._loopCount=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d}))}if(f&&1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,b,c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd=b?this.zeroSlopeAtEnd?2401:
16437 2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}});re.prototype=Object.assign(Object.create(ya.prototype),{constructor:re,_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings;a=a._interpolants;var g=c.uuid,h=this._bindingsByRootAndName,k=h[g];void 0===
16438 k&&(k={},h[g]=k);for(h=0;h!==e;++h){var l=d[h],p=l.name,n=k[p];if(void 0===n){n=f[h];if(void 0!==n){null===n._cacheIndex&&(++n.referenceCount,this._addInactiveBinding(n,g,p));continue}n=new qe(pa.create(c,p,b&&b._propertyBindings[h].binding.parsedPath),l.ValueTypeName,l.getValueSize());++n.referenceCount;this._addInactiveBinding(n,g,p)}f[h]=n;a[h].resultBuffer=n.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.uuid,
16439 d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}},_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=
16440 [];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length},get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},
16441 _isActiveAction:function(a){a=a._cacheIndex;return null!==a&&a<this._nActiveActions},_addInactiveAction:function(a,b,c){var d=this._actions,e=this._actionsByClip,f=e[b];void 0===f?(f={knownActions:[a],actionByRoot:{}},a._byClipCacheIndex=0,e[b]=f):(b=f.knownActions,a._byClipCacheIndex=b.length,b.push(a));a._cacheIndex=d.length;d.push(a);f.actionByRoot[c]=a},_removeInactiveAction:function(a){var b=this._actions,c=b[b.length-1],d=a._cacheIndex;c._cacheIndex=d;b[d]=c;b.pop();a._cacheIndex=null;b=a._clip.uuid;
16442 c=this._actionsByClip;d=c[b];var e=d.knownActions,f=e[e.length-1],g=a._byClipCacheIndex;f._byClipCacheIndex=g;e[g]=f;e.pop();a._byClipCacheIndex=null;delete d.actionByRoot[(a._localRoot||this._root).uuid];0===e.length&&delete c[b];this._removeInactiveBindingsForAction(a)},_removeInactiveBindingsForAction:function(a){a=a._propertyBindings;for(var b=0,c=a.length;b!==c;++b){var d=a[b];0===--d.referenceCount&&this._removeInactiveBinding(d)}},_lendAction:function(a){var b=this._actions,c=a._cacheIndex,
16443 d=this._nActiveActions++,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_takeBackAction:function(a){var b=this._actions,c=a._cacheIndex,d=--this._nActiveActions,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_addInactiveBinding:function(a,b,c){var d=this._bindingsByRootAndName,e=d[b],f=this._bindings;void 0===e&&(e={},d[b]=e);e[c]=a;a._cacheIndex=f.length;f.push(a)},_removeInactiveBinding:function(a){var b=this._bindings,c=a.binding,d=c.rootNode.uuid;c=c.path;var e=this._bindingsByRootAndName,
16444 f=e[d],g=b[b.length-1];a=a._cacheIndex;g._cacheIndex=a;b[a]=g;b.pop();delete f[c];a:{for(var h in f)break a;delete e[d]}},_lendBinding:function(a){var b=this._bindings,c=a._cacheIndex,d=this._nActiveBindings++,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_takeBackBinding:function(a){var b=this._bindings,c=a._cacheIndex,d=--this._nActiveBindings,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_lendControlInterpolant:function(){var a=this._controlInterpolants,b=this._nActiveControlInterpolants++,
16445 c=a[b];void 0===c&&(c=new bd(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),c.__cacheIndex=b,a[b]=c);return c},_takeBackControlInterpolant:function(a){var b=this._controlInterpolants,c=a.__cacheIndex,d=--this._nActiveControlInterpolants,e=b[d];a.__cacheIndex=d;b[d]=a;e.__cacheIndex=c;b[c]=e},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(a,b){var c=b||this._root,d=c.uuid;c="string"===typeof a?Ca.findByName(c,a):a;a=null!==c?c.uuid:a;var e=
16446 this._actionsByClip[a],f=null;if(void 0!==e){f=e.actionByRoot[d];if(void 0!==f)return f;f=e.knownActions[0];null===c&&(c=f._clip)}if(null===c)return null;b=new rf(this,c,b);this._bindAction(b,f);this._addInactiveAction(b,a,d);return b},existingAction:function(a,b){var c=b||this._root;b=c.uuid;c="string"===typeof a?Ca.findByName(c,a):a;a=this._actionsByClip[c?c.uuid:a];return void 0!==a?a.actionByRoot[b]||null:null},stopAllAction:function(){for(var a=this._actions,b=this._nActiveActions,c=this._bindings,
16447 d=this._nActiveBindings,e=this._nActiveBindings=this._nActiveActions=0;e!==b;++e)a[e].reset();for(e=0;e!==d;++e)c[e].useCount=0;return this},update:function(a){a*=this.timeScale;for(var b=this._actions,c=this._nActiveActions,d=this.time+=a,e=Math.sign(a),f=this._accuIndex^=1,g=0;g!==c;++g)b[g]._update(d,a,e,f);a=this._bindings;b=this._nActiveBindings;for(g=0;g!==b;++g)a[g].apply(f);return this},getRoot:function(){return this._root},uncacheClip:function(a){var b=this._actions;a=a.uuid;var c=this._actionsByClip,
16448 d=c[a];if(void 0!==d){d=d.knownActions;for(var e=0,f=d.length;e!==f;++e){var g=d[e];this._deactivateAction(g);var h=g._cacheIndex,k=b[b.length-1];g._cacheIndex=null;g._byClipCacheIndex=null;k._cacheIndex=h;b[h]=k;b.pop();this._removeInactiveBindingsForAction(g)}delete c[a]}},uncacheRoot:function(a){a=a.uuid;var b=this._actionsByClip;for(d in b){var c=b[d].actionByRoot[a];void 0!==c&&(this._deactivateAction(c),this._removeInactiveAction(c))}var d=this._bindingsByRootAndName[a];if(void 0!==d)for(var e in d)a=
16449 d[e],a.restoreOriginalState(),this._removeInactiveBinding(a)},uncacheAction:function(a,b){a=this.existingAction(a,b);null!==a&&(this._deactivateAction(a),this._removeInactiveAction(a))}});Ld.prototype.clone=function(){return new Ld(void 0===this.value.clone?this.value:this.value.clone())};se.prototype=Object.assign(Object.create(C.prototype),{constructor:se,isInstancedBufferGeometry:!0,copy:function(a){C.prototype.copy.call(this,a);this.maxInstancedCount=a.maxInstancedCount;return this},clone:function(){return(new this.constructor).copy(this)}});
16450 te.prototype=Object.assign(Object.create(ob.prototype),{constructor:te,isInstancedInterleavedBuffer:!0,copy:function(a){ob.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this}});ue.prototype=Object.assign(Object.create(Q.prototype),{constructor:ue,isInstancedBufferAttribute:!0,copy:function(a){Q.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this}});Object.assign(sf.prototype,{linePrecision:1,set:function(a,b){this.ray.set(a,b)},setFromCamera:function(a,
16451 b){b&&b.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(b.matrixWorld),this.ray.direction.set(a.x,a.y,.5).unproject(b).sub(this.ray.origin).normalize()):b&&b.isOrthographicCamera?(this.ray.origin.set(a.x,a.y,(b.near+b.far)/(b.near-b.far)).unproject(b),this.ray.direction.set(0,0,-1).transformDirection(b.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(a,b,c){c=c||[];ve(a,this,c,b);c.sort(tf);return c},intersectObjects:function(a,b,c){c=c||
16452 [];if(!1===Array.isArray(a))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),c;for(var d=0,e=a.length;d<e;d++)ve(a[d],this,c,b);c.sort(tf);return c}});Object.assign(uf.prototype,{start:function(){this.oldTime=this.startTime=("undefined"===typeof performance?Date:performance).now();this.elapsedTime=0;this.running=!0},stop:function(){this.getElapsedTime();this.autoStart=this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=
16453 0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var b=("undefined"===typeof performance?Date:performance).now();a=(b-this.oldTime)/1E3;this.oldTime=b;this.elapsedTime+=a}return a}});Object.assign(vf.prototype,{set:function(a,b,c){this.radius=a;this.phi=b;this.theta=c;return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.radius=a.radius;this.phi=a.phi;this.theta=a.theta;return this},makeSafe:function(){this.phi=Math.max(1E-6,Math.min(Math.PI-
16454 1E-6,this.phi));return this},setFromVector3:function(a){this.radius=a.length();0===this.radius?this.phi=this.theta=0:(this.theta=Math.atan2(a.x,a.z),this.phi=Math.acos(H.clamp(a.y/this.radius,-1,1)));return this}});Object.assign(wf.prototype,{set:function(a,b,c){this.radius=a;this.theta=b;this.y=c;return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.radius=a.radius;this.theta=a.theta;this.y=a.y;return this},setFromVector3:function(a){this.radius=Math.sqrt(a.x*
16455 a.x+a.z*a.z);this.theta=Math.atan2(a.x,a.z);this.y=a.y;return this}});Object.assign(we.prototype,{set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(){var a=new z;return function(b,c){c=a.copy(c).multiplyScalar(.5);this.min.copy(b).sub(c);this.max.copy(b).add(c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);
16456 this.max.copy(a.max);return this},makeEmpty:function(){this.min.x=this.min.y=Infinity;this.max.x=this.max.y=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(a){void 0===a&&(console.warn("THREE.Box2: .getCenter() target is now required"),a=new z);return this.isEmpty()?a.set(0,0):a.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(a){void 0===a&&(console.warn("THREE.Box2: .getSize() target is now required"),a=new z);return this.isEmpty()?
16457 a.set(0,0):a.subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);this.max.addScalar(a);return this},containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y},getParameter:function(a,
16458 b){void 0===b&&(console.warn("THREE.Box2: .getParameter() target is now required"),b=new z);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y?!1:!0},clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box2: .clampPoint() target is now required"),b=new z);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new z;
16459 return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});Object.assign(xe.prototype,{set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},
16460 copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},getCenter:function(a){void 0===a&&(console.warn("THREE.Line3: .getCenter() target is now required"),a=new p);return a.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){void 0===a&&(console.warn("THREE.Line3: .delta() target is now required"),a=new p);return a.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},
16461 at:function(a,b){void 0===b&&(console.warn("THREE.Line3: .at() target is now required"),b=new p);return this.delta(b).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new p,b=new p;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);c=b.dot(b);c=b.dot(a)/c;d&&(c=H.clamp(c,0,1));return c}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);void 0===c&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),
16462 c=new p);return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a);this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}});ed.prototype=Object.create(D.prototype);ed.prototype.constructor=ed;ed.prototype.isImmediateRenderObject=!0;fd.prototype=Object.create(W.prototype);fd.prototype.constructor=fd;fd.prototype.update=function(){var a=new p,b=new p,c=new ra;return function(){var d=["a","b",
16463 "c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,f=this.geometry.attributes.position,g=this.object.geometry;if(g&&g.isGeometry)for(var h=g.vertices,k=g.faces,l=g=0,p=k.length;l<p;l++)for(var n=k[l],t=0,u=n.vertexNormals.length;t<u;t++){var r=n.vertexNormals[t];a.copy(h[n[d[t]]]).applyMatrix4(e);b.copy(r).applyMatrix3(c).normalize().multiplyScalar(this.size).add(a);f.setXYZ(g,a.x,a.y,a.z);g+=1;f.setXYZ(g,b.x,b.y,b.z);g+=1}else if(g&&g.isBufferGeometry)for(d=
16464 g.attributes.position,h=g.attributes.normal,t=g=0,u=d.count;t<u;t++)a.set(d.getX(t),d.getY(t),d.getZ(t)).applyMatrix4(e),b.set(h.getX(t),h.getY(t),h.getZ(t)),b.applyMatrix3(c).normalize().multiplyScalar(this.size).add(a),f.setXYZ(g,a.x,a.y,a.z),g+=1,f.setXYZ(g,b.x,b.y,b.z),g+=1;f.needsUpdate=!0}}();ic.prototype=Object.create(D.prototype);ic.prototype.constructor=ic;ic.prototype.dispose=function(){this.cone.geometry.dispose();this.cone.material.dispose()};ic.prototype.update=function(){var a=new p,
16465 b=new p;return function(){this.light.updateMatrixWorld();var c=this.light.distance?this.light.distance:1E3,d=c*Math.tan(this.light.angle);this.cone.scale.set(d,d,c);a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);this.cone.lookAt(b.sub(a));void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}();jc.prototype=Object.create(W.prototype);jc.prototype.constructor=jc;jc.prototype.updateMatrixWorld=
16466 function(){var a=new p,b=new I,c=new I;return function(d){var e=this.bones,f=this.geometry,g=f.getAttribute("position");c.getInverse(this.root.matrixWorld);for(var h=0,k=0;h<e.length;h++){var l=e[h];l.parent&&l.parent.isBone&&(b.multiplyMatrices(c,l.matrixWorld),a.setFromMatrixPosition(b),g.setXYZ(k,a.x,a.y,a.z),b.multiplyMatrices(c,l.parent.matrixWorld),a.setFromMatrixPosition(b),g.setXYZ(k+1,a.x,a.y,a.z),k+=2)}f.getAttribute("position").needsUpdate=!0;D.prototype.updateMatrixWorld.call(this,d)}}();
16467 kc.prototype=Object.create(la.prototype);kc.prototype.constructor=kc;kc.prototype.dispose=function(){this.geometry.dispose();this.material.dispose()};kc.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)};lc.prototype=Object.create(D.prototype);lc.prototype.constructor=lc;lc.prototype.dispose=function(){this.children[0].geometry.dispose();this.children[0].material.dispose()};lc.prototype.update=function(){var a=.5*this.light.width,
16468 b=.5*this.light.height,c=this.line.geometry.attributes.position,d=c.array;d[0]=a;d[1]=-b;d[2]=0;d[3]=a;d[4]=b;d[5]=0;d[6]=-a;d[7]=b;d[8]=0;d[9]=-a;d[10]=-b;d[11]=0;d[12]=a;d[13]=-b;d[14]=0;c.needsUpdate=!0;void 0!==this.color?this.line.material.color.set(this.color):this.line.material.color.copy(this.light.color)};mc.prototype=Object.create(D.prototype);mc.prototype.constructor=mc;mc.prototype.dispose=function(){this.children[0].geometry.dispose();this.children[0].material.dispose()};mc.prototype.update=
16469 function(){var a=new p,b=new G,c=new G;return function(){var d=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var e=d.geometry.getAttribute("color");b.copy(this.light.color);c.copy(this.light.groundColor);for(var f=0,g=e.count;f<g;f++){var h=f<g/2?b:c;e.setXYZ(f,h.r,h.g,h.b)}e.needsUpdate=!0}d.lookAt(a.setFromMatrixPosition(this.light.matrixWorld).negate())}}();gd.prototype=Object.create(W.prototype);gd.prototype.constructor=gd;Md.prototype=Object.create(W.prototype);
16470 Md.prototype.constructor=Md;hd.prototype=Object.create(W.prototype);hd.prototype.constructor=hd;hd.prototype.update=function(){var a=new p,b=new p,c=new ra;return function(){this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);var d=this.object.matrixWorld,e=this.geometry.attributes.position,f=this.object.geometry,g=f.vertices;f=f.faces;for(var h=0,k=0,l=f.length;k<l;k++){var p=f[k],n=p.normal;a.copy(g[p.a]).add(g[p.b]).add(g[p.c]).divideScalar(3).applyMatrix4(d);b.copy(n).applyMatrix3(c).normalize().multiplyScalar(this.size).add(a);
16471 e.setXYZ(h,a.x,a.y,a.z);h+=1;e.setXYZ(h,b.x,b.y,b.z);h+=1}e.needsUpdate=!0}}();nc.prototype=Object.create(D.prototype);nc.prototype.constructor=nc;nc.prototype.dispose=function(){this.lightPlane.geometry.dispose();this.lightPlane.material.dispose();this.targetLine.geometry.dispose();this.targetLine.material.dispose()};nc.prototype.update=function(){var a=new p,b=new p,c=new p;return function(){a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);c.subVectors(b,
16472 a);this.lightPlane.lookAt(c);void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color));this.targetLine.lookAt(c);this.targetLine.scale.z=c.length()}}();id.prototype=Object.create(W.prototype);id.prototype.constructor=id;id.prototype.update=function(){function a(a,g,h,k){d.set(g,h,k).unproject(e);a=c[a];if(void 0!==a)for(g=b.getAttribute("position"),
16473 h=0,k=a.length;h<k;h++)g.setXYZ(a[h],d.x,d.y,d.z)}var b,c,d=new p,e=new Na;return function(){b=this.geometry;c=this.pointMap;e.projectionMatrix.copy(this.camera.projectionMatrix);a("c",0,0,-1);a("t",0,0,1);a("n1",-1,-1,-1);a("n2",1,-1,-1);a("n3",-1,1,-1);a("n4",1,1,-1);a("f1",-1,-1,1);a("f2",1,-1,1);a("f3",-1,1,1);a("f4",1,1,1);a("u1",.7,1.1,-1);a("u2",-.7,1.1,-1);a("u3",0,2,-1);a("cf1",-1,0,1);a("cf2",1,0,1);a("cf3",0,-1,1);a("cf4",0,1,1);a("cn1",-1,0,-1);a("cn2",1,0,-1);a("cn3",0,-1,-1);a("cn4",
16474 0,1,-1);b.getAttribute("position").needsUpdate=!0}}();Db.prototype=Object.create(W.prototype);Db.prototype.constructor=Db;Db.prototype.update=function(){var a=new Sa;return function(b){void 0!==b&&console.warn("THREE.BoxHelper: .update() has no longer arguments.");void 0!==this.object&&a.setFromObject(this.object);if(!a.isEmpty()){b=a.min;var c=a.max,d=this.geometry.attributes.position,e=d.array;e[0]=c.x;e[1]=c.y;e[2]=c.z;e[3]=b.x;e[4]=c.y;e[5]=c.z;e[6]=b.x;e[7]=b.y;e[8]=c.z;e[9]=c.x;e[10]=b.y;e[11]=
16475 c.z;e[12]=c.x;e[13]=c.y;e[14]=b.z;e[15]=b.x;e[16]=c.y;e[17]=b.z;e[18]=b.x;e[19]=b.y;e[20]=b.z;e[21]=c.x;e[22]=b.y;e[23]=b.z;d.needsUpdate=!0;this.geometry.computeBoundingSphere()}}}();Db.prototype.setFromObject=function(a){this.object=a;this.update();return this};jd.prototype=Object.create(W.prototype);jd.prototype.constructor=jd;jd.prototype.updateMatrixWorld=function(a){var b=this.box;b.isEmpty()||(b.getCenter(this.position),b.getSize(this.scale),this.scale.multiplyScalar(.5),D.prototype.updateMatrixWorld.call(this,
16476 a))};kd.prototype=Object.create(sa.prototype);kd.prototype.constructor=kd;kd.prototype.updateMatrixWorld=function(a){var b=-this.plane.constant;1E-8>Math.abs(b)&&(b=1E-8);this.scale.set(.5*this.size,.5*this.size,b);this.children[0].material.side=0>b?1:0;this.lookAt(this.plane.normal);D.prototype.updateMatrixWorld.call(this,a)};var Nd,ye;Eb.prototype=Object.create(D.prototype);Eb.prototype.constructor=Eb;Eb.prototype.setDirection=function(){var a=new p,b;return function(c){.99999<c.y?this.quaternion.set(0,
16477 0,0,1):-.99999>c.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}();Eb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};Eb.prototype.setColor=function(a){this.line.material.color.copy(a);this.cone.material.color.copy(a)};ld.prototype=Object.create(W.prototype);
16478 ld.prototype.constructor=ld;L.create=function(a,b){console.log("THREE.Curve.create() has been deprecated");a.prototype=Object.create(L.prototype);a.prototype.constructor=a;a.prototype.getPoint=b;return a};Object.assign(Xa.prototype,{createPointsGeometry:function(a){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");a=this.getPoints(a);return this.createGeometry(a)},createSpacedPointsGeometry:function(a){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
16479 a=this.getSpacedPoints(a);return this.createGeometry(a)},createGeometry:function(a){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var b=new R,c=0,d=a.length;c<d;c++){var e=a[c];b.vertices.push(new p(e.x,e.y,e.z||0))}return b}});Object.assign(La.prototype,{fromPoints:function(a){console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints().");this.setFromPoints(a)}});yf.prototype=Object.create(ca.prototype);
16480 zf.prototype=Object.create(ca.prototype);ze.prototype=Object.create(ca.prototype);Object.assign(ze.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}});gd.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};
16481 jc.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")};Object.assign(gc.prototype,{extractUrlBase:function(a){console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.");return De.extractUrlBase(a)}});Object.assign(we.prototype,{center:function(a){console.warn("THREE.Box2: .center() has been renamed to .getCenter().");return this.getCenter(a)},empty:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");
16482 return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},size:function(a){console.warn("THREE.Box2: .size() has been renamed to .getSize().");return this.getSize(a)}});Object.assign(Sa.prototype,{center:function(a){console.warn("THREE.Box3: .center() has been renamed to .getCenter().");return this.getCenter(a)},empty:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");
16483 return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},isIntersectionSphere:function(a){console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)},size:function(a){console.warn("THREE.Box3: .size() has been renamed to .getSize().");return this.getSize(a)}});xe.prototype.center=function(a){console.warn("THREE.Line3: .center() has been renamed to .getCenter().");
16484 return this.getCenter(a)};Object.assign(H,{random16:function(){console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead.");return Math.random()},nearestPowerOfTwo:function(a){console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().");return H.floorPowerOfTwo(a)},nextPowerOfTwo:function(a){console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().");return H.ceilPowerOfTwo(a)}});Object.assign(ra.prototype,{flattenToArrayOffset:function(a,
16485 b){console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");return this.toArray(a,b)},multiplyVector3:function(a){console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBuffer:function(a){console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.");
16486 return this.applyToBufferAttribute(a)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}});Object.assign(I.prototype,{extractPosition:function(a){console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");return this.copyPosition(a)},flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");return this.toArray(a,b)},getPosition:function(){var a;
16487 return function(){void 0===a&&(a=new p);console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");return a.setFromMatrixColumn(this,3)}}(),setRotationFromQuaternion:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");return this.makeRotationFromQuaternion(a)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.");
16488 return a.applyMatrix4(this)},multiplyVector4:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.");a.transformDirection(this)},crossVector:function(a){console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");
16489 return a.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(a){console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.");
16490 return this.applyToBufferAttribute(a)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(a,b,c,d,e,f){console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.");return this.makePerspective(a,b,d,c,e,f)}});Ma.prototype.isIntersectionLine=function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");return this.intersectsLine(a)};
16491 fa.prototype.multiplyVector3=function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return a.applyQuaternion(this)};Object.assign(mb.prototype,{isIntersectionBox:function(a){console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},isIntersectionPlane:function(a){console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().");return this.intersectsPlane(a)},
16492 isIntersectionSphere:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}});Object.assign(ja.prototype,{area:function(){console.warn("THREE.Triangle: .area() has been renamed to .getArea().");return this.getArea()},barycoordFromPoint:function(a,b){console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");return this.getBarycoord(a,b)},midpoint:function(a){console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint().");
16493 return this.getMidpoint(a)},normal:function(a){console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");return this.getNormal(a)},plane:function(a){console.warn("THREE.Triangle: .plane() has been renamed to .getPlane().");return this.getPlane(a)}});Object.assign(ja,{barycoordFromPoint:function(a,b,c,d,e){console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");return ja.getBarycoord(a,b,c,d,e)},normal:function(a,b,c,d){console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");
16494 return ja.getNormal(a,b,c,d)}});Object.assign(db.prototype,{extractAllPoints:function(a){console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.");return this.extractPoints(a)},extrude:function(a){console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.");return new rb(this,a)},makeGeometry:function(a){console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");return new tb(this,a)}});Object.assign(z.prototype,
16495 {fromAttribute:function(a,b,c){console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,b,c)},distanceToManhattan:function(a){console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().");return this.manhattanDistanceTo(a)},lengthManhattan:function(){console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(p.prototype,
16496 {setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(a){console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().");return this.setFromMatrixPosition(a)},getScaleFromMatrix:function(a){console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().");
16497 return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(b,a)},applyProjection:function(a){console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.");return this.applyMatrix4(a)},fromAttribute:function(a,b,c){console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,
16498 b,c)},distanceToManhattan:function(a){console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().");return this.manhattanDistanceTo(a)},lengthManhattan:function(){console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(V.prototype,{fromAttribute:function(a,b,c){console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,
16499 b,c)},lengthManhattan:function(){console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(R.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}});Object.assign(D.prototype,{getChildByName:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");
16500 return this.getObjectByName(a)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(a,b){console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");return this.translateOnAxis(b,a)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")}});Object.defineProperties(D.prototype,
16501 {eulerOrder:{get:function(){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");return this.rotation.order},set:function(a){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");this.rotation.order=a}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});
16502 Object.defineProperties(Bc.prototype,{objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels.");return this.levels}}});Object.defineProperty(Cc.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}});Object.defineProperty(L.prototype,"__arcLengthDivisions",{get:function(){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");
16503 return this.arcLengthDivisions},set:function(a){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");this.arcLengthDivisions=a}});Z.prototype.setLens=function(a,b){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.");void 0!==b&&(this.filmGauge=b);this.setFocalLength(a)};Object.defineProperties(X.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(a){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");
16504 this.shadow.camera.fov=a}},shadowCameraLeft:{set:function(a){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left.");this.shadow.camera.left=a}},shadowCameraRight:{set:function(a){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");this.shadow.camera.right=a}},shadowCameraTop:{set:function(a){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top.");this.shadow.camera.top=a}},shadowCameraBottom:{set:function(a){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.");
16505 this.shadow.camera.bottom=a}},shadowCameraNear:{set:function(a){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near.");this.shadow.camera.near=a}},shadowCameraFar:{set:function(a){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far.");this.shadow.camera.far=a}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(a){console.warn("THREE.Light: .shadowBias is now .shadow.bias.");
16506 this.shadow.bias=a}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(a){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.");this.shadow.mapSize.width=a}},shadowMapHeight:{set:function(a){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");this.shadow.mapSize.height=a}}});Object.defineProperties(Q.prototype,{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead.");
16507 return this.array.length}},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")}});Object.assign(C.prototype,{addIndex:function(a){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");this.setIndex(a)},addDrawCall:function(a,b,c){void 0!==c&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");this.addGroup(a,b)},
16508 clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}});Object.defineProperties(C.prototype,{drawcalls:{get:function(){console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");return this.groups}},offsets:{get:function(){console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups.");
16509 return this.groups}}});Object.assign(Oa.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}});Object.defineProperties(Ld.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},
16510 onUpdate:{value:function(){console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.");return this}}});Object.defineProperties(J.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},wrapRGB:{get:function(){console.warn("THREE.Material: .wrapRGB has been removed.");return new G}},shading:{get:function(){console.error("THREE."+this.type+
16511 ": .shading has been removed. Use the boolean .flatShading instead.")},set:function(a){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.");this.flatShading=1===a}}});Object.defineProperties(Fa.prototype,{metal:{get:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.");return!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});
16512 Object.defineProperties(ta.prototype,{derivatives:{get:function(){console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");return this.extensions.derivatives},set:function(a){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");this.extensions.derivatives=a}}});Object.assign(Zd.prototype,{animate:function(a){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop().");this.setAnimationLoop(a)},getCurrentRenderTarget:function(){console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().");
16513 return this.getRenderTarget()},getMaxAnisotropy:function(){console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().");return this.capabilities.getMaxAnisotropy()},getPrecision:function(){console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.");return this.capabilities.precision},resetGLState:function(){console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset().");return this.state.reset()},supportsFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");
16514 return this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' ).");return this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).");return this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' ).");
16515 return this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).");return this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).");return this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.");
16516 return this.capabilities.vertexTextures},supportsInstancedArrays:function(){console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).");return this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(a){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().");this.setScissorTest(a)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},
16517 addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")}});Object.defineProperties(Zd.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");
16518 this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.");this.shadowMap.type=a}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}}});Object.defineProperties(Ze.prototype,
16519 {cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},
16520 renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}});Object.defineProperties(fb.prototype,{wrapS:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");return this.texture.wrapS},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");
16521 this.texture.wrapS=a}},wrapT:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");return this.texture.wrapT},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");this.texture.wrapT=a}},magFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");return this.texture.magFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");this.texture.magFilter=
16522 a}},minFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");return this.texture.minFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");this.texture.minFilter=a}},anisotropy:{get:function(){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");return this.texture.anisotropy},set:function(a){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");this.texture.anisotropy=
16523 a}},offset:{get:function(){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");return this.texture.offset},set:function(a){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");this.texture.offset=a}},repeat:{get:function(){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");return this.texture.repeat},set:function(a){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");this.texture.repeat=a}},format:{get:function(){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");
16524 return this.texture.format},set:function(a){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");this.texture.format=a}},type:{get:function(){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");return this.texture.type},set:function(a){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");this.texture.type=a}},generateMipmaps:{get:function(){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");return this.texture.generateMipmaps},
16525 set:function(a){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");this.texture.generateMipmaps=a}}});Object.defineProperties(af.prototype,{standing:{set:function(){console.warn("THREE.WebVRManager: .standing has been removed.")}}});hc.prototype.load=function(a){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var b=this;(new le).load(a,function(a){b.setBuffer(a)});return this};pe.prototype.getData=function(){console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData().");
16526 return this.getFrequencyData()};dd.prototype.updateCubeMap=function(a,b){console.warn("THREE.CubeCamera: .updateCubeMap() is now .update().");return this.update(a,b)};eb.crossOrigin=void 0;eb.loadTexture=function(a,b,c,d){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var e=new vd;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a};eb.loadTextureCube=function(a,b,c,d){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");
16527 var e=new ee;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a};eb.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")};eb.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};l.WebGLRenderTargetCube=Gb;l.WebGLRenderTarget=fb;l.WebGLRenderer=Zd;l.ShaderLib=nb;l.UniformsLib=K;l.UniformsUtils=
16528 Aa;l.ShaderChunk=S;l.FogExp2=Lb;l.Fog=Mb;l.Scene=qd;l.Sprite=Ac;l.LOD=Bc;l.SkinnedMesh=sd;l.Skeleton=Cc;l.Bone=rd;l.Mesh=la;l.LineSegments=W;l.LineLoop=td;l.Line=sa;l.Points=Ob;l.Group=Kb;l.VideoTexture=$d;l.DataTexture=gb;l.CompressedTexture=Pb;l.CubeTexture=Ua;l.CanvasTexture=Dc;l.DepthTexture=Ec;l.Texture=T;l.CompressedTextureLoader=kf;l.DataTextureLoader=de;l.CubeTextureLoader=ee;l.TextureLoader=vd;l.ObjectLoader=mf;l.MaterialLoader=Kd;l.BufferGeometryLoader=ge;l.DefaultLoadingManager=ka;l.LoadingManager=
16529 ce;l.JSONLoader=he;l.ImageLoader=Zc;l.ImageBitmapLoader=ie;l.FontLoader=nf;l.FileLoader=Ga;l.Loader=gc;l.LoaderUtils=De;l.Cache=Fb;l.AudioLoader=le;l.SpotLightShadow=xd;l.SpotLight=yd;l.PointLight=zd;l.RectAreaLight=Dd;l.HemisphereLight=wd;l.DirectionalLightShadow=Ad;l.DirectionalLight=Bd;l.AmbientLight=Cd;l.LightShadow=Cb;l.Light=X;l.StereoCamera=of;l.PerspectiveCamera=Z;l.OrthographicCamera=Hb;l.CubeCamera=dd;l.ArrayCamera=yc;l.Camera=Na;l.AudioListener=me;l.PositionalAudio=oe;l.AudioContext=ne;
16530 l.AudioAnalyser=pe;l.Audio=hc;l.VectorKeyframeTrack=fc;l.StringKeyframeTrack=Jd;l.QuaternionKeyframeTrack=cd;l.NumberKeyframeTrack=ec;l.ColorKeyframeTrack=Hd;l.BooleanKeyframeTrack=Gd;l.PropertyMixer=qe;l.PropertyBinding=pa;l.KeyframeTrack=oa;l.AnimationUtils=ia;l.AnimationObjectGroup=qf;l.AnimationMixer=re;l.AnimationClip=Ca;l.Uniform=Ld;l.InstancedBufferGeometry=se;l.BufferGeometry=C;l.Geometry=R;l.InterleavedBufferAttribute=zc;l.InstancedInterleavedBuffer=te;l.InterleavedBuffer=ob;l.InstancedBufferAttribute=
16531 ue;l.Face3=Ta;l.Object3D=D;l.Raycaster=sf;l.Layers=Rd;l.EventDispatcher=ya;l.Clock=uf;l.QuaternionLinearInterpolant=Id;l.LinearInterpolant=bd;l.DiscreteInterpolant=Fd;l.CubicInterpolant=Ed;l.Interpolant=wa;l.Triangle=ja;l.Math=H;l.Spherical=vf;l.Cylindrical=wf;l.Plane=Ma;l.Frustum=md;l.Sphere=Da;l.Ray=mb;l.Matrix4=I;l.Matrix3=ra;l.Box3=Sa;l.Box2=we;l.Line3=xe;l.Euler=hb;l.Vector4=V;l.Vector3=p;l.Vector2=z;l.Quaternion=fa;l.Color=G;l.ImmediateRenderObject=ed;l.VertexNormalsHelper=fd;l.SpotLightHelper=
16532 ic;l.SkeletonHelper=jc;l.PointLightHelper=kc;l.RectAreaLightHelper=lc;l.HemisphereLightHelper=mc;l.GridHelper=gd;l.PolarGridHelper=Md;l.FaceNormalsHelper=hd;l.DirectionalLightHelper=nc;l.CameraHelper=id;l.BoxHelper=Db;l.Box3Helper=jd;l.PlaneHelper=kd;l.ArrowHelper=Eb;l.AxesHelper=ld;l.Shape=db;l.Path=La;l.ShapePath=je;l.Font=ke;l.CurvePath=Xa;l.Curve=L;l.ImageUtils=eb;l.ShapeUtils=Va;l.WebGLUtils=$e;l.WireframeGeometry=Qb;l.ParametricGeometry=Fc;l.ParametricBufferGeometry=Rb;l.TetrahedronGeometry=
16533 Hc;l.TetrahedronBufferGeometry=Sb;l.OctahedronGeometry=Ic;l.OctahedronBufferGeometry=pb;l.IcosahedronGeometry=Jc;l.IcosahedronBufferGeometry=Tb;l.DodecahedronGeometry=Kc;l.DodecahedronBufferGeometry=Ub;l.PolyhedronGeometry=Gc;l.PolyhedronBufferGeometry=na;l.TubeGeometry=Lc;l.TubeBufferGeometry=Vb;l.TorusKnotGeometry=Mc;l.TorusKnotBufferGeometry=Wb;l.TorusGeometry=Nc;l.TorusBufferGeometry=Xb;l.TextGeometry=Sc;l.TextBufferGeometry=Yb;l.SphereGeometry=Tc;l.SphereBufferGeometry=sb;l.RingGeometry=Uc;l.RingBufferGeometry=
16534 Zb;l.PlaneGeometry=uc;l.PlaneBufferGeometry=lb;l.LatheGeometry=Vc;l.LatheBufferGeometry=$b;l.ShapeGeometry=tb;l.ShapeBufferGeometry=ub;l.ExtrudeGeometry=rb;l.ExtrudeBufferGeometry=Oa;l.EdgesGeometry=ac;l.ConeGeometry=Wc;l.ConeBufferGeometry=Xc;l.CylinderGeometry=vb;l.CylinderBufferGeometry=Wa;l.CircleGeometry=Yc;l.CircleBufferGeometry=bc;l.BoxGeometry=Ib;l.BoxBufferGeometry=kb;l.ShadowMaterial=wb;l.SpriteMaterial=cb;l.RawShaderMaterial=cc;l.ShaderMaterial=ta;l.PointsMaterial=Ea;l.MeshPhysicalMaterial=
16535 xb;l.MeshStandardMaterial=Pa;l.MeshPhongMaterial=Fa;l.MeshToonMaterial=yb;l.MeshNormalMaterial=zb;l.MeshLambertMaterial=Ab;l.MeshDepthMaterial=$a;l.MeshDistanceMaterial=ab;l.MeshBasicMaterial=da;l.LineDashedMaterial=Bb;l.LineBasicMaterial=Y;l.Material=J;l.Float64BufferAttribute=tc;l.Float32BufferAttribute=A;l.Uint32BufferAttribute=jb;l.Int32BufferAttribute=sc;l.Uint16BufferAttribute=ib;l.Int16BufferAttribute=rc;l.Uint8ClampedBufferAttribute=qc;l.Uint8BufferAttribute=pc;l.Int8BufferAttribute=oc;l.BufferAttribute=
16536 Q;l.ArcCurve=dc;l.CatmullRomCurve3=ca;l.CubicBezierCurve=Ha;l.CubicBezierCurve3=Qa;l.EllipseCurve=za;l.LineCurve=va;l.LineCurve3=Ia;l.QuadraticBezierCurve=Ja;l.QuadraticBezierCurve3=Ra;l.SplineCurve=Ka;l.REVISION="95";l.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2};l.CullFaceNone=0;l.CullFaceBack=1;l.CullFaceFront=2;l.CullFaceFrontBack=3;l.FrontFaceDirectionCW=0;l.FrontFaceDirectionCCW=1;l.BasicShadowMap=0;l.PCFShadowMap=1;l.PCFSoftShadowMap=2;l.FrontSide=0;l.BackSide=1;l.DoubleSide=2;l.FlatShading=1;l.SmoothShading=
16537 2;l.NoColors=0;l.FaceColors=1;l.VertexColors=2;l.NoBlending=0;l.NormalBlending=1;l.AdditiveBlending=2;l.SubtractiveBlending=3;l.MultiplyBlending=4;l.CustomBlending=5;l.AddEquation=100;l.SubtractEquation=101;l.ReverseSubtractEquation=102;l.MinEquation=103;l.MaxEquation=104;l.ZeroFactor=200;l.OneFactor=201;l.SrcColorFactor=202;l.OneMinusSrcColorFactor=203;l.SrcAlphaFactor=204;l.OneMinusSrcAlphaFactor=205;l.DstAlphaFactor=206;l.OneMinusDstAlphaFactor=207;l.DstColorFactor=208;l.OneMinusDstColorFactor=
16538 209;l.SrcAlphaSaturateFactor=210;l.NeverDepth=0;l.AlwaysDepth=1;l.LessDepth=2;l.LessEqualDepth=3;l.EqualDepth=4;l.GreaterEqualDepth=5;l.GreaterDepth=6;l.NotEqualDepth=7;l.MultiplyOperation=0;l.MixOperation=1;l.AddOperation=2;l.NoToneMapping=0;l.LinearToneMapping=1;l.ReinhardToneMapping=2;l.Uncharted2ToneMapping=3;l.CineonToneMapping=4;l.UVMapping=300;l.CubeReflectionMapping=301;l.CubeRefractionMapping=302;l.EquirectangularReflectionMapping=303;l.EquirectangularRefractionMapping=304;l.SphericalReflectionMapping=
16539 305;l.CubeUVReflectionMapping=306;l.CubeUVRefractionMapping=307;l.RepeatWrapping=1E3;l.ClampToEdgeWrapping=1001;l.MirroredRepeatWrapping=1002;l.NearestFilter=1003;l.NearestMipMapNearestFilter=1004;l.NearestMipMapLinearFilter=1005;l.LinearFilter=1006;l.LinearMipMapNearestFilter=1007;l.LinearMipMapLinearFilter=1008;l.UnsignedByteType=1009;l.ByteType=1010;l.ShortType=1011;l.UnsignedShortType=1012;l.IntType=1013;l.UnsignedIntType=1014;l.FloatType=1015;l.HalfFloatType=1016;l.UnsignedShort4444Type=1017;
16540 l.UnsignedShort5551Type=1018;l.UnsignedShort565Type=1019;l.UnsignedInt248Type=1020;l.AlphaFormat=1021;l.RGBFormat=1022;l.RGBAFormat=1023;l.LuminanceFormat=1024;l.LuminanceAlphaFormat=1025;l.RGBEFormat=1023;l.DepthFormat=1026;l.DepthStencilFormat=1027;l.RGB_S3TC_DXT1_Format=33776;l.RGBA_S3TC_DXT1_Format=33777;l.RGBA_S3TC_DXT3_Format=33778;l.RGBA_S3TC_DXT5_Format=33779;l.RGB_PVRTC_4BPPV1_Format=35840;l.RGB_PVRTC_2BPPV1_Format=35841;l.RGBA_PVRTC_4BPPV1_Format=35842;l.RGBA_PVRTC_2BPPV1_Format=35843;l.RGB_ETC1_Format=
16541 36196;l.RGBA_ASTC_4x4_Format=37808;l.RGBA_ASTC_5x4_Format=37809;l.RGBA_ASTC_5x5_Format=37810;l.RGBA_ASTC_6x5_Format=37811;l.RGBA_ASTC_6x6_Format=37812;l.RGBA_ASTC_8x5_Format=37813;l.RGBA_ASTC_8x6_Format=37814;l.RGBA_ASTC_8x8_Format=37815;l.RGBA_ASTC_10x5_Format=37816;l.RGBA_ASTC_10x6_Format=37817;l.RGBA_ASTC_10x8_Format=37818;l.RGBA_ASTC_10x10_Format=37819;l.RGBA_ASTC_12x10_Format=37820;l.RGBA_ASTC_12x12_Format=37821;l.LoopOnce=2200;l.LoopRepeat=2201;l.LoopPingPong=2202;l.InterpolateDiscrete=2300;
16542 l.InterpolateLinear=2301;l.InterpolateSmooth=2302;l.ZeroCurvatureEnding=2400;l.ZeroSlopeEnding=2401;l.WrapAroundEnding=2402;l.TrianglesDrawMode=0;l.TriangleStripDrawMode=1;l.TriangleFanDrawMode=2;l.LinearEncoding=3E3;l.sRGBEncoding=3001;l.GammaEncoding=3007;l.RGBEEncoding=3002;l.LogLuvEncoding=3003;l.RGBM7Encoding=3004;l.RGBM16Encoding=3005;l.RGBDEncoding=3006;l.BasicDepthPacking=3200;l.RGBADepthPacking=3201;l.TangentSpaceNormalMap=0;l.ObjectSpaceNormalMap=1;l.CubeGeometry=Ib;l.Face4=function(a,b,
16543 c,d,e,f,g){console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead.");return new Ta(a,b,c,e,f,g)};l.LineStrip=0;l.LinePieces=1;l.MeshFaceMaterial=function(a){console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead.");return a};l.MultiMaterial=function(a){void 0===a&&(a=[]);console.warn("THREE.MultiMaterial has been removed. Use an Array instead.");a.isMultiMaterial=!0;a.materials=a;a.clone=function(){return a.slice()};return a};l.PointCloud=function(a,
16544 b){console.warn("THREE.PointCloud has been renamed to THREE.Points.");return new Ob(a,b)};l.Particle=function(a){console.warn("THREE.Particle has been renamed to THREE.Sprite.");return new Ac(a)};l.ParticleSystem=function(a,b){console.warn("THREE.ParticleSystem has been renamed to THREE.Points.");return new Ob(a,b)};l.PointCloudMaterial=function(a){console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.");return new Ea(a)};l.ParticleBasicMaterial=function(a){console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.");
16545 return new Ea(a)};l.ParticleSystemMaterial=function(a){console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.");return new Ea(a)};l.Vertex=function(a,b,c){console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead.");return new p(a,b,c)};l.DynamicBufferAttribute=function(a,b){console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.");return(new Q(a,b)).setDynamic(!0)};l.Int8Attribute=function(a,
16546 b){console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.");return new oc(a,b)};l.Uint8Attribute=function(a,b){console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.");return new pc(a,b)};l.Uint8ClampedAttribute=function(a,b){console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.");return new qc(a,b)};l.Int16Attribute=function(a,b){console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.");
16547 return new rc(a,b)};l.Uint16Attribute=function(a,b){console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.");return new ib(a,b)};l.Int32Attribute=function(a,b){console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.");return new sc(a,b)};l.Uint32Attribute=function(a,b){console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.");return new jb(a,b)};l.Float32Attribute=
16548 function(a,b){console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.");return new A(a,b)};l.Float64Attribute=function(a,b){console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.");return new tc(a,b)};l.ClosedSplineCurve3=yf;l.SplineCurve3=zf;l.Spline=ze;l.AxisHelper=function(a){console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper.");return new ld(a)};l.BoundingBoxHelper=function(a,b){console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.");
16549 return new Db(a,b)};l.EdgesHelper=function(a,b){console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.");return new W(new ac(a.geometry),new Y({color:void 0!==b?b:16777215}))};l.WireframeHelper=function(a,b){console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.");return new W(new Qb(a.geometry),new Y({color:void 0!==b?b:16777215}))};l.XHRLoader=function(a){console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader.");return new Ga(a)};
16550 l.BinaryTextureLoader=function(a){console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader.");return new de(a)};l.GeometryUtils={merge:function(a,b,c){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");if(b.isMesh){b.matrixAutoUpdate&&b.updateMatrix();var d=b.matrix;b=b.geometry}a.merge(b,d,c)},center:function(a){console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.");
16551 return a.center()}};l.Projector=function(){console.error("THREE.Projector has been moved to /examples/js/renderers/Projector.js.");this.projectVector=function(a,b){console.warn("THREE.Projector: .projectVector() is now vector.project().");a.project(b)};this.unprojectVector=function(a,b){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject().");a.unproject(b)};this.pickingRay=function(){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")}};l.CanvasRenderer=
16552 function(){console.error("THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js");this.domElement=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");this.clear=function(){};this.render=function(){};this.setClearColor=function(){};this.setSize=function(){}};l.SceneUtils={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")},
16553 attach:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")}};l.LensFlare=function(){console.error("THREE.LensFlare has been moved to /examples/js/objects/Lensflare.js")};Object.defineProperty(l,"__esModule",{value:!0})});
16555 },{}],226:[function(require,module,exports){
16558 module.exports = TinyQueue;
16560 function TinyQueue(data, compare) {
16561 if (!(this instanceof TinyQueue)) return new TinyQueue(data, compare);
16563 this.data = data || [];
16564 this.length = this.data.length;
16565 this.compare = compare || defaultCompare;
16567 if (this.length > 0) {
16568 for (var i = (this.length >> 1); i >= 0; i--) this._down(i);
16572 function defaultCompare(a, b) {
16573 return a < b ? -1 : a > b ? 1 : 0;
16576 TinyQueue.prototype = {
16578 push: function (item) {
16579 this.data.push(item);
16581 this._up(this.length - 1);
16585 if (this.length === 0) return undefined;
16586 var top = this.data[0];
16588 if (this.length > 0) {
16589 this.data[0] = this.data[this.length];
16596 peek: function () {
16597 return this.data[0];
16600 _up: function (pos) {
16601 var data = this.data;
16602 var compare = this.compare;
16603 var item = data[pos];
16606 var parent = (pos - 1) >> 1;
16607 var current = data[parent];
16608 if (compare(item, current) >= 0) break;
16609 data[pos] = current;
16616 _down: function (pos) {
16617 var data = this.data;
16618 var compare = this.compare;
16619 var len = this.length;
16620 var halfLen = len >> 1;
16621 var item = data[pos];
16623 while (pos < halfLen) {
16624 var left = (pos << 1) + 1;
16625 var right = left + 1;
16626 var best = data[left];
16628 if (right < len && compare(data[right], best) < 0) {
16630 best = data[right];
16632 if (compare(best, item) >= 0) break;
16642 },{}],227:[function(require,module,exports){
16643 var createElement = require("./vdom/create-element.js")
16645 module.exports = createElement
16647 },{"./vdom/create-element.js":233}],228:[function(require,module,exports){
16648 var diff = require("./vtree/diff.js")
16650 module.exports = diff
16652 },{"./vtree/diff.js":253}],229:[function(require,module,exports){
16653 var h = require("./virtual-hyperscript/index.js")
16657 },{"./virtual-hyperscript/index.js":240}],230:[function(require,module,exports){
16658 var diff = require("./diff.js")
16659 var patch = require("./patch.js")
16660 var h = require("./h.js")
16661 var create = require("./create-element.js")
16662 var VNode = require('./vnode/vnode.js')
16663 var VText = require('./vnode/vtext.js')
16674 },{"./create-element.js":227,"./diff.js":228,"./h.js":229,"./patch.js":231,"./vnode/vnode.js":249,"./vnode/vtext.js":251}],231:[function(require,module,exports){
16675 var patch = require("./vdom/patch.js")
16677 module.exports = patch
16679 },{"./vdom/patch.js":236}],232:[function(require,module,exports){
16680 var isObject = require("is-object")
16681 var isHook = require("../vnode/is-vhook.js")
16683 module.exports = applyProperties
16685 function applyProperties(node, props, previous) {
16686 for (var propName in props) {
16687 var propValue = props[propName]
16689 if (propValue === undefined) {
16690 removeProperty(node, propName, propValue, previous);
16691 } else if (isHook(propValue)) {
16692 removeProperty(node, propName, propValue, previous)
16693 if (propValue.hook) {
16694 propValue.hook(node,
16696 previous ? previous[propName] : undefined)
16699 if (isObject(propValue)) {
16700 patchObject(node, props, previous, propName, propValue);
16702 node[propName] = propValue
16708 function removeProperty(node, propName, propValue, previous) {
16710 var previousValue = previous[propName]
16712 if (!isHook(previousValue)) {
16713 if (propName === "attributes") {
16714 for (var attrName in previousValue) {
16715 node.removeAttribute(attrName)
16717 } else if (propName === "style") {
16718 for (var i in previousValue) {
16721 } else if (typeof previousValue === "string") {
16722 node[propName] = ""
16724 node[propName] = null
16726 } else if (previousValue.unhook) {
16727 previousValue.unhook(node, propName, propValue)
16732 function patchObject(node, props, previous, propName, propValue) {
16733 var previousValue = previous ? previous[propName] : undefined
16736 if (propName === "attributes") {
16737 for (var attrName in propValue) {
16738 var attrValue = propValue[attrName]
16740 if (attrValue === undefined) {
16741 node.removeAttribute(attrName)
16743 node.setAttribute(attrName, attrValue)
16750 if(previousValue && isObject(previousValue) &&
16751 getPrototype(previousValue) !== getPrototype(propValue)) {
16752 node[propName] = propValue
16756 if (!isObject(node[propName])) {
16757 node[propName] = {}
16760 var replacer = propName === "style" ? "" : undefined
16762 for (var k in propValue) {
16763 var value = propValue[k]
16764 node[propName][k] = (value === undefined) ? replacer : value
16768 function getPrototype(value) {
16769 if (Object.getPrototypeOf) {
16770 return Object.getPrototypeOf(value)
16771 } else if (value.__proto__) {
16772 return value.__proto__
16773 } else if (value.constructor) {
16774 return value.constructor.prototype
16778 },{"../vnode/is-vhook.js":244,"is-object":20}],233:[function(require,module,exports){
16779 var document = require("global/document")
16781 var applyProperties = require("./apply-properties")
16783 var isVNode = require("../vnode/is-vnode.js")
16784 var isVText = require("../vnode/is-vtext.js")
16785 var isWidget = require("../vnode/is-widget.js")
16786 var handleThunk = require("../vnode/handle-thunk.js")
16788 module.exports = createElement
16790 function createElement(vnode, opts) {
16791 var doc = opts ? opts.document || document : document
16792 var warn = opts ? opts.warn : null
16794 vnode = handleThunk(vnode).a
16796 if (isWidget(vnode)) {
16797 return vnode.init()
16798 } else if (isVText(vnode)) {
16799 return doc.createTextNode(vnode.text)
16800 } else if (!isVNode(vnode)) {
16802 warn("Item is not a valid virtual dom node", vnode)
16807 var node = (vnode.namespace === null) ?
16808 doc.createElement(vnode.tagName) :
16809 doc.createElementNS(vnode.namespace, vnode.tagName)
16811 var props = vnode.properties
16812 applyProperties(node, props)
16814 var children = vnode.children
16816 for (var i = 0; i < children.length; i++) {
16817 var childNode = createElement(children[i], opts)
16819 node.appendChild(childNode)
16826 },{"../vnode/handle-thunk.js":242,"../vnode/is-vnode.js":245,"../vnode/is-vtext.js":246,"../vnode/is-widget.js":247,"./apply-properties":232,"global/document":16}],234:[function(require,module,exports){
16827 // Maps a virtual DOM tree onto a real DOM tree in an efficient manner.
16828 // We don't want to read all of the DOM nodes in the tree so we use
16829 // the in-order tree indexing to eliminate recursion down certain branches.
16830 // We only recurse into a DOM node if we know that it contains a child of
16835 module.exports = domIndex
16837 function domIndex(rootNode, tree, indices, nodes) {
16838 if (!indices || indices.length === 0) {
16841 indices.sort(ascending)
16842 return recurse(rootNode, tree, indices, nodes, 0)
16846 function recurse(rootNode, tree, indices, nodes, rootIndex) {
16847 nodes = nodes || {}
16851 if (indexInRange(indices, rootIndex, rootIndex)) {
16852 nodes[rootIndex] = rootNode
16855 var vChildren = tree.children
16859 var childNodes = rootNode.childNodes
16861 for (var i = 0; i < tree.children.length; i++) {
16864 var vChild = vChildren[i] || noChild
16865 var nextIndex = rootIndex + (vChild.count || 0)
16867 // skip recursion down the tree if there are no nodes down here
16868 if (indexInRange(indices, rootIndex, nextIndex)) {
16869 recurse(childNodes[i], vChild, indices, nodes, rootIndex)
16872 rootIndex = nextIndex
16880 // Binary search for an index in the interval [left, right]
16881 function indexInRange(indices, left, right) {
16882 if (indices.length === 0) {
16887 var maxIndex = indices.length - 1
16891 while (minIndex <= maxIndex) {
16892 currentIndex = ((maxIndex + minIndex) / 2) >> 0
16893 currentItem = indices[currentIndex]
16895 if (minIndex === maxIndex) {
16896 return currentItem >= left && currentItem <= right
16897 } else if (currentItem < left) {
16898 minIndex = currentIndex + 1
16899 } else if (currentItem > right) {
16900 maxIndex = currentIndex - 1
16909 function ascending(a, b) {
16910 return a > b ? 1 : -1
16913 },{}],235:[function(require,module,exports){
16914 var applyProperties = require("./apply-properties")
16916 var isWidget = require("../vnode/is-widget.js")
16917 var VPatch = require("../vnode/vpatch.js")
16919 var updateWidget = require("./update-widget")
16921 module.exports = applyPatch
16923 function applyPatch(vpatch, domNode, renderOptions) {
16924 var type = vpatch.type
16925 var vNode = vpatch.vNode
16926 var patch = vpatch.patch
16929 case VPatch.REMOVE:
16930 return removeNode(domNode, vNode)
16931 case VPatch.INSERT:
16932 return insertNode(domNode, patch, renderOptions)
16934 return stringPatch(domNode, vNode, patch, renderOptions)
16935 case VPatch.WIDGET:
16936 return widgetPatch(domNode, vNode, patch, renderOptions)
16938 return vNodePatch(domNode, vNode, patch, renderOptions)
16940 reorderChildren(domNode, patch)
16943 applyProperties(domNode, patch, vNode.properties)
16946 return replaceRoot(domNode,
16947 renderOptions.patch(domNode, patch, renderOptions))
16953 function removeNode(domNode, vNode) {
16954 var parentNode = domNode.parentNode
16957 parentNode.removeChild(domNode)
16960 destroyWidget(domNode, vNode);
16965 function insertNode(parentNode, vNode, renderOptions) {
16966 var newNode = renderOptions.render(vNode, renderOptions)
16969 parentNode.appendChild(newNode)
16975 function stringPatch(domNode, leftVNode, vText, renderOptions) {
16978 if (domNode.nodeType === 3) {
16979 domNode.replaceData(0, domNode.length, vText.text)
16982 var parentNode = domNode.parentNode
16983 newNode = renderOptions.render(vText, renderOptions)
16985 if (parentNode && newNode !== domNode) {
16986 parentNode.replaceChild(newNode, domNode)
16993 function widgetPatch(domNode, leftVNode, widget, renderOptions) {
16994 var updating = updateWidget(leftVNode, widget)
16998 newNode = widget.update(leftVNode, domNode) || domNode
17000 newNode = renderOptions.render(widget, renderOptions)
17003 var parentNode = domNode.parentNode
17005 if (parentNode && newNode !== domNode) {
17006 parentNode.replaceChild(newNode, domNode)
17010 destroyWidget(domNode, leftVNode)
17016 function vNodePatch(domNode, leftVNode, vNode, renderOptions) {
17017 var parentNode = domNode.parentNode
17018 var newNode = renderOptions.render(vNode, renderOptions)
17020 if (parentNode && newNode !== domNode) {
17021 parentNode.replaceChild(newNode, domNode)
17027 function destroyWidget(domNode, w) {
17028 if (typeof w.destroy === "function" && isWidget(w)) {
17033 function reorderChildren(domNode, moves) {
17034 var childNodes = domNode.childNodes
17040 for (var i = 0; i < moves.removes.length; i++) {
17041 remove = moves.removes[i]
17042 node = childNodes[remove.from]
17044 keyMap[remove.key] = node
17046 domNode.removeChild(node)
17049 var length = childNodes.length
17050 for (var j = 0; j < moves.inserts.length; j++) {
17051 insert = moves.inserts[j]
17052 node = keyMap[insert.key]
17053 // this is the weirdest bug i've ever seen in webkit
17054 domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to])
17058 function replaceRoot(oldRoot, newRoot) {
17059 if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {
17060 oldRoot.parentNode.replaceChild(newRoot, oldRoot)
17066 },{"../vnode/is-widget.js":247,"../vnode/vpatch.js":250,"./apply-properties":232,"./update-widget":237}],236:[function(require,module,exports){
17067 var document = require("global/document")
17068 var isArray = require("x-is-array")
17070 var render = require("./create-element")
17071 var domIndex = require("./dom-index")
17072 var patchOp = require("./patch-op")
17073 module.exports = patch
17075 function patch(rootNode, patches, renderOptions) {
17076 renderOptions = renderOptions || {}
17077 renderOptions.patch = renderOptions.patch && renderOptions.patch !== patch
17078 ? renderOptions.patch
17080 renderOptions.render = renderOptions.render || render
17082 return renderOptions.patch(rootNode, patches, renderOptions)
17085 function patchRecursive(rootNode, patches, renderOptions) {
17086 var indices = patchIndices(patches)
17088 if (indices.length === 0) {
17092 var index = domIndex(rootNode, patches.a, indices)
17093 var ownerDocument = rootNode.ownerDocument
17095 if (!renderOptions.document && ownerDocument !== document) {
17096 renderOptions.document = ownerDocument
17099 for (var i = 0; i < indices.length; i++) {
17100 var nodeIndex = indices[i]
17101 rootNode = applyPatch(rootNode,
17103 patches[nodeIndex],
17110 function applyPatch(rootNode, domNode, patchList, renderOptions) {
17117 if (isArray(patchList)) {
17118 for (var i = 0; i < patchList.length; i++) {
17119 newNode = patchOp(patchList[i], domNode, renderOptions)
17121 if (domNode === rootNode) {
17126 newNode = patchOp(patchList, domNode, renderOptions)
17128 if (domNode === rootNode) {
17136 function patchIndices(patches) {
17139 for (var key in patches) {
17141 indices.push(Number(key))
17148 },{"./create-element":233,"./dom-index":234,"./patch-op":235,"global/document":16,"x-is-array":272}],237:[function(require,module,exports){
17149 var isWidget = require("../vnode/is-widget.js")
17151 module.exports = updateWidget
17153 function updateWidget(a, b) {
17154 if (isWidget(a) && isWidget(b)) {
17155 if ("name" in a && "name" in b) {
17156 return a.id === b.id
17158 return a.init === b.init
17165 },{"../vnode/is-widget.js":247}],238:[function(require,module,exports){
17168 var EvStore = require('ev-store');
17170 module.exports = EvHook;
17172 function EvHook(value) {
17173 if (!(this instanceof EvHook)) {
17174 return new EvHook(value);
17177 this.value = value;
17180 EvHook.prototype.hook = function (node, propertyName) {
17181 var es = EvStore(node);
17182 var propName = propertyName.substr(3);
17184 es[propName] = this.value;
17187 EvHook.prototype.unhook = function(node, propertyName) {
17188 var es = EvStore(node);
17189 var propName = propertyName.substr(3);
17191 es[propName] = undefined;
17194 },{"ev-store":9}],239:[function(require,module,exports){
17197 module.exports = SoftSetHook;
17199 function SoftSetHook(value) {
17200 if (!(this instanceof SoftSetHook)) {
17201 return new SoftSetHook(value);
17204 this.value = value;
17207 SoftSetHook.prototype.hook = function (node, propertyName) {
17208 if (node[propertyName] !== this.value) {
17209 node[propertyName] = this.value;
17213 },{}],240:[function(require,module,exports){
17216 var isArray = require('x-is-array');
17218 var VNode = require('../vnode/vnode.js');
17219 var VText = require('../vnode/vtext.js');
17220 var isVNode = require('../vnode/is-vnode');
17221 var isVText = require('../vnode/is-vtext');
17222 var isWidget = require('../vnode/is-widget');
17223 var isHook = require('../vnode/is-vhook');
17224 var isVThunk = require('../vnode/is-thunk');
17226 var parseTag = require('./parse-tag.js');
17227 var softSetHook = require('./hooks/soft-set-hook.js');
17228 var evHook = require('./hooks/ev-hook.js');
17230 module.exports = h;
17232 function h(tagName, properties, children) {
17233 var childNodes = [];
17234 var tag, props, key, namespace;
17236 if (!children && isChildren(properties)) {
17237 children = properties;
17241 props = props || properties || {};
17242 tag = parseTag(tagName, props);
17245 if (props.hasOwnProperty('key')) {
17247 props.key = undefined;
17250 // support namespace
17251 if (props.hasOwnProperty('namespace')) {
17252 namespace = props.namespace;
17253 props.namespace = undefined;
17257 if (tag === 'INPUT' &&
17259 props.hasOwnProperty('value') &&
17260 props.value !== undefined &&
17261 !isHook(props.value)
17263 props.value = softSetHook(props.value);
17266 transformProperties(props);
17268 if (children !== undefined && children !== null) {
17269 addChild(children, childNodes, tag, props);
17273 return new VNode(tag, props, childNodes, key, namespace);
17276 function addChild(c, childNodes, tag, props) {
17277 if (typeof c === 'string') {
17278 childNodes.push(new VText(c));
17279 } else if (typeof c === 'number') {
17280 childNodes.push(new VText(String(c)));
17281 } else if (isChild(c)) {
17282 childNodes.push(c);
17283 } else if (isArray(c)) {
17284 for (var i = 0; i < c.length; i++) {
17285 addChild(c[i], childNodes, tag, props);
17287 } else if (c === null || c === undefined) {
17290 throw UnexpectedVirtualElement({
17300 function transformProperties(props) {
17301 for (var propName in props) {
17302 if (props.hasOwnProperty(propName)) {
17303 var value = props[propName];
17305 if (isHook(value)) {
17309 if (propName.substr(0, 3) === 'ev-') {
17310 // add ev-foo support
17311 props[propName] = evHook(value);
17317 function isChild(x) {
17318 return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x);
17321 function isChildren(x) {
17322 return typeof x === 'string' || isArray(x) || isChild(x);
17325 function UnexpectedVirtualElement(data) {
17326 var err = new Error();
17328 err.type = 'virtual-hyperscript.unexpected.virtual-element';
17329 err.message = 'Unexpected virtual child passed to h().\n' +
17330 'Expected a VNode / Vthunk / VWidget / string but:\n' +
17332 errorString(data.foreignObject) +
17334 'The parent vnode is:\n' +
17335 errorString(data.parentVnode)
17337 'Suggested fix: change your `h(..., [ ... ])` callsite.';
17338 err.foreignObject = data.foreignObject;
17339 err.parentVnode = data.parentVnode;
17344 function errorString(obj) {
17346 return JSON.stringify(obj, null, ' ');
17348 return String(obj);
17352 },{"../vnode/is-thunk":243,"../vnode/is-vhook":244,"../vnode/is-vnode":245,"../vnode/is-vtext":246,"../vnode/is-widget":247,"../vnode/vnode.js":249,"../vnode/vtext.js":251,"./hooks/ev-hook.js":238,"./hooks/soft-set-hook.js":239,"./parse-tag.js":241,"x-is-array":272}],241:[function(require,module,exports){
17355 var split = require('browser-split');
17357 var classIdSplit = /([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/;
17358 var notClassId = /^\.|#/;
17360 module.exports = parseTag;
17362 function parseTag(tag, props) {
17367 var noId = !(props.hasOwnProperty('id'));
17369 var tagParts = split(tag, classIdSplit);
17370 var tagName = null;
17372 if (notClassId.test(tagParts[1])) {
17376 var classes, part, type, i;
17378 for (i = 0; i < tagParts.length; i++) {
17379 part = tagParts[i];
17385 type = part.charAt(0);
17389 } else if (type === '.') {
17390 classes = classes || [];
17391 classes.push(part.substring(1, part.length));
17392 } else if (type === '#' && noId) {
17393 props.id = part.substring(1, part.length);
17398 if (props.className) {
17399 classes.push(props.className);
17402 props.className = classes.join(' ');
17405 return props.namespace ? tagName : tagName.toUpperCase();
17408 },{"browser-split":5}],242:[function(require,module,exports){
17409 var isVNode = require("./is-vnode")
17410 var isVText = require("./is-vtext")
17411 var isWidget = require("./is-widget")
17412 var isThunk = require("./is-thunk")
17414 module.exports = handleThunk
17416 function handleThunk(a, b) {
17421 renderedB = renderThunk(b, a)
17425 renderedA = renderThunk(a, null)
17434 function renderThunk(thunk, previous) {
17435 var renderedThunk = thunk.vnode
17437 if (!renderedThunk) {
17438 renderedThunk = thunk.vnode = thunk.render(previous)
17441 if (!(isVNode(renderedThunk) ||
17442 isVText(renderedThunk) ||
17443 isWidget(renderedThunk))) {
17444 throw new Error("thunk did not return a valid node");
17447 return renderedThunk
17450 },{"./is-thunk":243,"./is-vnode":245,"./is-vtext":246,"./is-widget":247}],243:[function(require,module,exports){
17451 module.exports = isThunk
17453 function isThunk(t) {
17454 return t && t.type === "Thunk"
17457 },{}],244:[function(require,module,exports){
17458 module.exports = isHook
17460 function isHook(hook) {
17462 (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||
17463 typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))
17466 },{}],245:[function(require,module,exports){
17467 var version = require("./version")
17469 module.exports = isVirtualNode
17471 function isVirtualNode(x) {
17472 return x && x.type === "VirtualNode" && x.version === version
17475 },{"./version":248}],246:[function(require,module,exports){
17476 var version = require("./version")
17478 module.exports = isVirtualText
17480 function isVirtualText(x) {
17481 return x && x.type === "VirtualText" && x.version === version
17484 },{"./version":248}],247:[function(require,module,exports){
17485 module.exports = isWidget
17487 function isWidget(w) {
17488 return w && w.type === "Widget"
17491 },{}],248:[function(require,module,exports){
17492 module.exports = "2"
17494 },{}],249:[function(require,module,exports){
17495 var version = require("./version")
17496 var isVNode = require("./is-vnode")
17497 var isWidget = require("./is-widget")
17498 var isThunk = require("./is-thunk")
17499 var isVHook = require("./is-vhook")
17501 module.exports = VirtualNode
17503 var noProperties = {}
17504 var noChildren = []
17506 function VirtualNode(tagName, properties, children, key, namespace) {
17507 this.tagName = tagName
17508 this.properties = properties || noProperties
17509 this.children = children || noChildren
17510 this.key = key != null ? String(key) : undefined
17511 this.namespace = (typeof namespace === "string") ? namespace : null
17513 var count = (children && children.length) || 0
17514 var descendants = 0
17515 var hasWidgets = false
17516 var hasThunks = false
17517 var descendantHooks = false
17520 for (var propName in properties) {
17521 if (properties.hasOwnProperty(propName)) {
17522 var property = properties[propName]
17523 if (isVHook(property) && property.unhook) {
17528 hooks[propName] = property
17533 for (var i = 0; i < count; i++) {
17534 var child = children[i]
17535 if (isVNode(child)) {
17536 descendants += child.count || 0
17538 if (!hasWidgets && child.hasWidgets) {
17542 if (!hasThunks && child.hasThunks) {
17546 if (!descendantHooks && (child.hooks || child.descendantHooks)) {
17547 descendantHooks = true
17549 } else if (!hasWidgets && isWidget(child)) {
17550 if (typeof child.destroy === "function") {
17553 } else if (!hasThunks && isThunk(child)) {
17558 this.count = count + descendants
17559 this.hasWidgets = hasWidgets
17560 this.hasThunks = hasThunks
17562 this.descendantHooks = descendantHooks
17565 VirtualNode.prototype.version = version
17566 VirtualNode.prototype.type = "VirtualNode"
17568 },{"./is-thunk":243,"./is-vhook":244,"./is-vnode":245,"./is-widget":247,"./version":248}],250:[function(require,module,exports){
17569 var version = require("./version")
17571 VirtualPatch.NONE = 0
17572 VirtualPatch.VTEXT = 1
17573 VirtualPatch.VNODE = 2
17574 VirtualPatch.WIDGET = 3
17575 VirtualPatch.PROPS = 4
17576 VirtualPatch.ORDER = 5
17577 VirtualPatch.INSERT = 6
17578 VirtualPatch.REMOVE = 7
17579 VirtualPatch.THUNK = 8
17581 module.exports = VirtualPatch
17583 function VirtualPatch(type, vNode, patch) {
17584 this.type = Number(type)
17589 VirtualPatch.prototype.version = version
17590 VirtualPatch.prototype.type = "VirtualPatch"
17592 },{"./version":248}],251:[function(require,module,exports){
17593 var version = require("./version")
17595 module.exports = VirtualText
17597 function VirtualText(text) {
17598 this.text = String(text)
17601 VirtualText.prototype.version = version
17602 VirtualText.prototype.type = "VirtualText"
17604 },{"./version":248}],252:[function(require,module,exports){
17605 var isObject = require("is-object")
17606 var isHook = require("../vnode/is-vhook")
17608 module.exports = diffProps
17610 function diffProps(a, b) {
17613 for (var aKey in a) {
17614 if (!(aKey in b)) {
17616 diff[aKey] = undefined
17619 var aValue = a[aKey]
17620 var bValue = b[aKey]
17622 if (aValue === bValue) {
17624 } else if (isObject(aValue) && isObject(bValue)) {
17625 if (getPrototype(bValue) !== getPrototype(aValue)) {
17627 diff[aKey] = bValue
17628 } else if (isHook(bValue)) {
17630 diff[aKey] = bValue
17632 var objectDiff = diffProps(aValue, bValue)
17635 diff[aKey] = objectDiff
17640 diff[aKey] = bValue
17644 for (var bKey in b) {
17645 if (!(bKey in a)) {
17647 diff[bKey] = b[bKey]
17654 function getPrototype(value) {
17655 if (Object.getPrototypeOf) {
17656 return Object.getPrototypeOf(value)
17657 } else if (value.__proto__) {
17658 return value.__proto__
17659 } else if (value.constructor) {
17660 return value.constructor.prototype
17664 },{"../vnode/is-vhook":244,"is-object":20}],253:[function(require,module,exports){
17665 var isArray = require("x-is-array")
17667 var VPatch = require("../vnode/vpatch")
17668 var isVNode = require("../vnode/is-vnode")
17669 var isVText = require("../vnode/is-vtext")
17670 var isWidget = require("../vnode/is-widget")
17671 var isThunk = require("../vnode/is-thunk")
17672 var handleThunk = require("../vnode/handle-thunk")
17674 var diffProps = require("./diff-props")
17676 module.exports = diff
17678 function diff(a, b) {
17679 var patch = { a: a }
17680 walk(a, b, patch, 0)
17684 function walk(a, b, patch, index) {
17689 var apply = patch[index]
17690 var applyClear = false
17692 if (isThunk(a) || isThunk(b)) {
17693 thunks(a, b, patch, index)
17694 } else if (b == null) {
17696 // If a is a widget we will add a remove patch for it
17697 // Otherwise any child widgets/hooks must be destroyed.
17698 // This prevents adding two remove patches for a widget.
17699 if (!isWidget(a)) {
17700 clearState(a, patch, index)
17701 apply = patch[index]
17704 apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b))
17705 } else if (isVNode(b)) {
17707 if (a.tagName === b.tagName &&
17708 a.namespace === b.namespace &&
17710 var propsPatch = diffProps(a.properties, b.properties)
17712 apply = appendPatch(apply,
17713 new VPatch(VPatch.PROPS, a, propsPatch))
17715 apply = diffChildren(a, b, patch, apply, index)
17717 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
17721 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
17724 } else if (isVText(b)) {
17726 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
17728 } else if (a.text !== b.text) {
17729 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
17731 } else if (isWidget(b)) {
17732 if (!isWidget(a)) {
17736 apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b))
17740 patch[index] = apply
17744 clearState(a, patch, index)
17748 function diffChildren(a, b, patch, apply, index) {
17749 var aChildren = a.children
17750 var orderedSet = reorder(aChildren, b.children)
17751 var bChildren = orderedSet.children
17753 var aLen = aChildren.length
17754 var bLen = bChildren.length
17755 var len = aLen > bLen ? aLen : bLen
17757 for (var i = 0; i < len; i++) {
17758 var leftNode = aChildren[i]
17759 var rightNode = bChildren[i]
17764 // Excess nodes in b need to be added
17765 apply = appendPatch(apply,
17766 new VPatch(VPatch.INSERT, null, rightNode))
17769 walk(leftNode, rightNode, patch, index)
17772 if (isVNode(leftNode) && leftNode.count) {
17773 index += leftNode.count
17777 if (orderedSet.moves) {
17778 // Reorder nodes last
17779 apply = appendPatch(apply, new VPatch(
17789 function clearState(vNode, patch, index) {
17790 // TODO: Make this a single walk, not two
17791 unhook(vNode, patch, index)
17792 destroyWidgets(vNode, patch, index)
17795 // Patch records for all destroyed widgets must be added because we need
17796 // a DOM node reference for the destroy function
17797 function destroyWidgets(vNode, patch, index) {
17798 if (isWidget(vNode)) {
17799 if (typeof vNode.destroy === "function") {
17800 patch[index] = appendPatch(
17802 new VPatch(VPatch.REMOVE, vNode, null)
17805 } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
17806 var children = vNode.children
17807 var len = children.length
17808 for (var i = 0; i < len; i++) {
17809 var child = children[i]
17812 destroyWidgets(child, patch, index)
17814 if (isVNode(child) && child.count) {
17815 index += child.count
17818 } else if (isThunk(vNode)) {
17819 thunks(vNode, null, patch, index)
17823 // Create a sub-patch for thunks
17824 function thunks(a, b, patch, index) {
17825 var nodes = handleThunk(a, b)
17826 var thunkPatch = diff(nodes.a, nodes.b)
17827 if (hasPatches(thunkPatch)) {
17828 patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)
17832 function hasPatches(patch) {
17833 for (var index in patch) {
17834 if (index !== "a") {
17842 // Execute hooks when two nodes are identical
17843 function unhook(vNode, patch, index) {
17844 if (isVNode(vNode)) {
17846 patch[index] = appendPatch(
17851 undefinedKeys(vNode.hooks)
17856 if (vNode.descendantHooks || vNode.hasThunks) {
17857 var children = vNode.children
17858 var len = children.length
17859 for (var i = 0; i < len; i++) {
17860 var child = children[i]
17863 unhook(child, patch, index)
17865 if (isVNode(child) && child.count) {
17866 index += child.count
17870 } else if (isThunk(vNode)) {
17871 thunks(vNode, null, patch, index)
17875 function undefinedKeys(obj) {
17878 for (var key in obj) {
17879 result[key] = undefined
17885 // List diff, naive left to right reordering
17886 function reorder(aChildren, bChildren) {
17887 // O(M) time, O(M) memory
17888 var bChildIndex = keyIndex(bChildren)
17889 var bKeys = bChildIndex.keys
17890 var bFree = bChildIndex.free
17892 if (bFree.length === bChildren.length) {
17894 children: bChildren,
17899 // O(N) time, O(N) memory
17900 var aChildIndex = keyIndex(aChildren)
17901 var aKeys = aChildIndex.keys
17902 var aFree = aChildIndex.free
17904 if (aFree.length === aChildren.length) {
17906 children: bChildren,
17911 // O(MAX(N, M)) memory
17912 var newChildren = []
17915 var freeCount = bFree.length
17916 var deletedItems = 0
17918 // Iterate through a and match a node in b
17920 for (var i = 0 ; i < aChildren.length; i++) {
17921 var aItem = aChildren[i]
17925 if (bKeys.hasOwnProperty(aItem.key)) {
17926 // Match up the old keys
17927 itemIndex = bKeys[aItem.key]
17928 newChildren.push(bChildren[itemIndex])
17931 // Remove old keyed items
17932 itemIndex = i - deletedItems++
17933 newChildren.push(null)
17936 // Match the item in a with the next free item in b
17937 if (freeIndex < freeCount) {
17938 itemIndex = bFree[freeIndex++]
17939 newChildren.push(bChildren[itemIndex])
17941 // There are no free items in b to match with
17942 // the free items in a, so the extra free nodes
17944 itemIndex = i - deletedItems++
17945 newChildren.push(null)
17950 var lastFreeIndex = freeIndex >= bFree.length ?
17954 // Iterate through b and append any new keys
17956 for (var j = 0; j < bChildren.length; j++) {
17957 var newItem = bChildren[j]
17960 if (!aKeys.hasOwnProperty(newItem.key)) {
17961 // Add any new keyed items
17962 // We are adding new items to the end and then sorting them
17963 // in place. In future we should insert new items in place.
17964 newChildren.push(newItem)
17966 } else if (j >= lastFreeIndex) {
17967 // Add any leftover non-keyed items
17968 newChildren.push(newItem)
17972 var simulate = newChildren.slice()
17973 var simulateIndex = 0
17978 for (var k = 0; k < bChildren.length;) {
17979 var wantedItem = bChildren[k]
17980 simulateItem = simulate[simulateIndex]
17983 while (simulateItem === null && simulate.length) {
17984 removes.push(remove(simulate, simulateIndex, null))
17985 simulateItem = simulate[simulateIndex]
17988 if (!simulateItem || simulateItem.key !== wantedItem.key) {
17989 // if we need a key in this position...
17990 if (wantedItem.key) {
17991 if (simulateItem && simulateItem.key) {
17992 // if an insert doesn't put this key in place, it needs to move
17993 if (bKeys[simulateItem.key] !== k + 1) {
17994 removes.push(remove(simulate, simulateIndex, simulateItem.key))
17995 simulateItem = simulate[simulateIndex]
17996 // if the remove didn't put the wanted item in place, we need to insert it
17997 if (!simulateItem || simulateItem.key !== wantedItem.key) {
17998 inserts.push({key: wantedItem.key, to: k})
18000 // items are matching, so skip ahead
18006 inserts.push({key: wantedItem.key, to: k})
18010 inserts.push({key: wantedItem.key, to: k})
18014 // a key in simulate has no matching wanted key, remove it
18015 else if (simulateItem && simulateItem.key) {
18016 removes.push(remove(simulate, simulateIndex, simulateItem.key))
18025 // remove all the remaining nodes from simulate
18026 while(simulateIndex < simulate.length) {
18027 simulateItem = simulate[simulateIndex]
18028 removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key))
18031 // If the only moves we have are deletes then we can just
18032 // let the delete patch remove these items.
18033 if (removes.length === deletedItems && !inserts.length) {
18035 children: newChildren,
18041 children: newChildren,
18049 function remove(arr, index, key) {
18050 arr.splice(index, 1)
18058 function keyIndex(children) {
18061 var length = children.length
18063 for (var i = 0; i < length; i++) {
18064 var child = children[i]
18067 keys[child.key] = i
18074 keys: keys, // A hash of key name to index
18075 free: free // An array of unkeyed item indices
18079 function appendPatch(apply, patch) {
18081 if (isArray(apply)) {
18084 apply = [apply, patch]
18093 },{"../vnode/handle-thunk":242,"../vnode/is-thunk":243,"../vnode/is-vnode":245,"../vnode/is-vtext":246,"../vnode/is-widget":247,"../vnode/vpatch":250,"./diff-props":252,"x-is-array":272}],254:[function(require,module,exports){
18094 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18095 /** @author Brian Cavalier */
18096 /** @author John Hann */
18098 (function(define) { 'use strict';
18099 define(function (require) {
18101 var makePromise = require('./makePromise');
18102 var Scheduler = require('./Scheduler');
18103 var async = require('./env').asap;
18105 return makePromise({
18106 scheduler: new Scheduler(async)
18110 })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
18112 },{"./Scheduler":255,"./env":267,"./makePromise":269}],255:[function(require,module,exports){
18113 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18114 /** @author Brian Cavalier */
18115 /** @author John Hann */
18117 (function(define) { 'use strict';
18118 define(function() {
18120 // Credit to Twisol (https://github.com/Twisol) for suggesting
18121 // this type of extensible queue + trampoline approach for next-tick conflation.
18124 * Async task scheduler
18125 * @param {function} async function to schedule a single async function
18128 function Scheduler(async) {
18129 this._async = async;
18130 this._running = false;
18132 this._queue = this;
18133 this._queueLen = 0;
18134 this._afterQueue = {};
18135 this._afterQueueLen = 0;
18138 this.drain = function() {
18145 * @param {{ run:function }} task
18147 Scheduler.prototype.enqueue = function(task) {
18148 this._queue[this._queueLen++] = task;
18153 * Enqueue a task to run after the main task queue
18154 * @param {{ run:function }} task
18156 Scheduler.prototype.afterQueue = function(task) {
18157 this._afterQueue[this._afterQueueLen++] = task;
18161 Scheduler.prototype.run = function() {
18162 if (!this._running) {
18163 this._running = true;
18164 this._async(this.drain);
18169 * Drain the handler queue entirely, and then the after queue
18171 Scheduler.prototype._drain = function() {
18173 for (; i < this._queueLen; ++i) {
18174 this._queue[i].run();
18175 this._queue[i] = void 0;
18178 this._queueLen = 0;
18179 this._running = false;
18181 for (i = 0; i < this._afterQueueLen; ++i) {
18182 this._afterQueue[i].run();
18183 this._afterQueue[i] = void 0;
18186 this._afterQueueLen = 0;
18192 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
18194 },{}],256:[function(require,module,exports){
18195 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18196 /** @author Brian Cavalier */
18197 /** @author John Hann */
18199 (function(define) { 'use strict';
18200 define(function() {
18203 * Custom error type for promises rejected by promise.timeout
18204 * @param {string} message
18207 function TimeoutError (message) {
18209 this.message = message;
18210 this.name = TimeoutError.name;
18211 if (typeof Error.captureStackTrace === 'function') {
18212 Error.captureStackTrace(this, TimeoutError);
18216 TimeoutError.prototype = Object.create(Error.prototype);
18217 TimeoutError.prototype.constructor = TimeoutError;
18219 return TimeoutError;
18221 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
18222 },{}],257:[function(require,module,exports){
18223 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18224 /** @author Brian Cavalier */
18225 /** @author John Hann */
18227 (function(define) { 'use strict';
18228 define(function() {
18230 makeApply.tryCatchResolve = tryCatchResolve;
18234 function makeApply(Promise, call) {
18235 if(arguments.length < 2) {
18236 call = tryCatchResolve;
18241 function apply(f, thisArg, args) {
18242 var p = Promise._defer();
18243 var l = args.length;
18244 var params = new Array(l);
18245 callAndResolve({ f:f, thisArg:thisArg, args:args, params:params, i:l-1, call:call }, p._handler);
18250 function callAndResolve(c, h) {
18252 return call(c.f, c.thisArg, c.params, h);
18255 var handler = Promise._handler(c.args[c.i]);
18256 handler.fold(callAndResolveNext, c, void 0, h);
18259 function callAndResolveNext(c, x, h) {
18262 callAndResolve(c, h);
18266 function tryCatchResolve(f, thisArg, args, resolver) {
18268 resolver.resolve(f.apply(thisArg, args));
18270 resolver.reject(e);
18275 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
18279 },{}],258:[function(require,module,exports){
18280 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18281 /** @author Brian Cavalier */
18282 /** @author John Hann */
18284 (function(define) { 'use strict';
18285 define(function(require) {
18287 var state = require('../state');
18288 var applier = require('../apply');
18290 return function array(Promise) {
18292 var applyFold = applier(Promise);
18293 var toPromise = Promise.resolve;
18294 var all = Promise.all;
18296 var ar = Array.prototype.reduce;
18297 var arr = Array.prototype.reduceRight;
18298 var slice = Array.prototype.slice;
18300 // Additional array combinators
18303 Promise.some = some;
18304 Promise.settle = settle;
18307 Promise.filter = filter;
18308 Promise.reduce = reduce;
18309 Promise.reduceRight = reduceRight;
18312 * When this promise fulfills with an array, do
18313 * onFulfilled.apply(void 0, array)
18314 * @param {function} onFulfilled function to apply
18315 * @returns {Promise} promise for the result of applying onFulfilled
18317 Promise.prototype.spread = function(onFulfilled) {
18318 return this.then(all).then(function(array) {
18319 return onFulfilled.apply(this, array);
18326 * One-winner competitive race.
18327 * Return a promise that will fulfill when one of the promises
18328 * in the input array fulfills, or will reject when all promises
18330 * @param {array} promises
18331 * @returns {Promise} promise for the first fulfilled value
18333 function any(promises) {
18334 var p = Promise._defer();
18335 var resolver = p._handler;
18336 var l = promises.length>>>0;
18341 for (var h, x, i = 0; i < l; ++i) {
18343 if(x === void 0 && !(i in promises)) {
18348 h = Promise._handler(x);
18349 if(h.state() > 0) {
18350 resolver.become(h);
18351 Promise._visitRemaining(promises, i, h);
18354 h.visit(resolver, handleFulfill, handleReject);
18358 if(pending === 0) {
18359 resolver.reject(new RangeError('any(): array must not be empty'));
18364 function handleFulfill(x) {
18365 /*jshint validthis:true*/
18367 this.resolve(x); // this === resolver
18370 function handleReject(e) {
18371 /*jshint validthis:true*/
18372 if(this.resolved) { // this === resolver
18377 if(--pending === 0) {
18378 this.reject(errors);
18384 * N-winner competitive race
18385 * Return a promise that will fulfill when n input promises have
18386 * fulfilled, or will reject when it becomes impossible for n
18387 * input promises to fulfill (ie when promises.length - n + 1
18389 * @param {array} promises
18390 * @param {number} n
18391 * @returns {Promise} promise for the earliest n fulfillment values
18395 function some(promises, n) {
18396 /*jshint maxcomplexity:7*/
18397 var p = Promise._defer();
18398 var resolver = p._handler;
18403 var l = promises.length>>>0;
18406 var x, i; // reused in both for() loops
18408 // First pass: count actual array items
18409 for(i=0; i<l; ++i) {
18411 if(x === void 0 && !(i in promises)) {
18417 // Compute actual goals
18418 n = Math.max(n, 0);
18419 nReject = (nFulfill - n + 1);
18420 nFulfill = Math.min(n, nFulfill);
18423 resolver.reject(new RangeError('some(): array must contain at least '
18424 + n + ' item(s), but had ' + nFulfill));
18425 } else if(nFulfill === 0) {
18426 resolver.resolve(results);
18429 // Second pass: observe each array item, make progress toward goals
18430 for(i=0; i<l; ++i) {
18432 if(x === void 0 && !(i in promises)) {
18436 Promise._handler(x).visit(resolver, fulfill, reject, resolver.notify);
18441 function fulfill(x) {
18442 /*jshint validthis:true*/
18443 if(this.resolved) { // this === resolver
18448 if(--nFulfill === 0) {
18450 this.resolve(results);
18454 function reject(e) {
18455 /*jshint validthis:true*/
18456 if(this.resolved) { // this === resolver
18461 if(--nReject === 0) {
18463 this.reject(errors);
18469 * Apply f to the value of each promise in a list of promises
18470 * and return a new list containing the results.
18471 * @param {array} promises
18472 * @param {function(x:*, index:Number):*} f mapping function
18473 * @returns {Promise}
18475 function map(promises, f) {
18476 return Promise._traverse(f, promises);
18480 * Filter the provided array of promises using the provided predicate. Input may
18481 * contain promises and values
18482 * @param {Array} promises array of promises and values
18483 * @param {function(x:*, index:Number):boolean} predicate filtering predicate.
18484 * Must return truthy (or promise for truthy) for items to retain.
18485 * @returns {Promise} promise that will fulfill with an array containing all items
18486 * for which predicate returned truthy.
18488 function filter(promises, predicate) {
18489 var a = slice.call(promises);
18490 return Promise._traverse(predicate, a).then(function(keep) {
18491 return filterSync(a, keep);
18495 function filterSync(promises, keep) {
18496 // Safe because we know all promises have fulfilled if we've made it this far
18497 var l = keep.length;
18498 var filtered = new Array(l);
18499 for(var i=0, j=0; i<l; ++i) {
18501 filtered[j++] = Promise._handler(promises[i]).value;
18504 filtered.length = j;
18510 * Return a promise that will always fulfill with an array containing
18511 * the outcome states of all input promises. The returned promise
18512 * will never reject.
18513 * @param {Array} promises
18514 * @returns {Promise} promise for array of settled state descriptors
18516 function settle(promises) {
18517 return all(promises.map(settleOne));
18520 function settleOne(p) {
18521 // Optimize the case where we get an already-resolved when.js promise
18522 // by extracting its state:
18524 if (p instanceof Promise) {
18525 // This is our own Promise type and we can reach its handler internals:
18526 handler = p._handler.join();
18528 if((handler && handler.state() === 0) || !handler) {
18529 // Either still pending, or not a Promise at all:
18530 return toPromise(p).then(state.fulfilled, state.rejected);
18533 // The promise is our own, but it is already resolved. Take a shortcut.
18534 // Since we're not actually handling the resolution, we need to disable
18535 // rejection reporting.
18536 handler._unreport();
18537 return state.inspect(handler);
18541 * Traditional reduce function, similar to `Array.prototype.reduce()`, but
18542 * input may contain promises and/or values, and reduceFunc
18543 * may return either a value or a promise, *and* initialValue may
18544 * be a promise for the starting value.
18545 * @param {Array|Promise} promises array or promise for an array of anything,
18546 * may contain a mix of promises and values.
18547 * @param {function(accumulated:*, x:*, index:Number):*} f reduce function
18548 * @returns {Promise} that will resolve to the final reduced value
18550 function reduce(promises, f /*, initialValue */) {
18551 return arguments.length > 2 ? ar.call(promises, liftCombine(f), arguments[2])
18552 : ar.call(promises, liftCombine(f));
18556 * Traditional reduce function, similar to `Array.prototype.reduceRight()`, but
18557 * input may contain promises and/or values, and reduceFunc
18558 * may return either a value or a promise, *and* initialValue may
18559 * be a promise for the starting value.
18560 * @param {Array|Promise} promises array or promise for an array of anything,
18561 * may contain a mix of promises and values.
18562 * @param {function(accumulated:*, x:*, index:Number):*} f reduce function
18563 * @returns {Promise} that will resolve to the final reduced value
18565 function reduceRight(promises, f /*, initialValue */) {
18566 return arguments.length > 2 ? arr.call(promises, liftCombine(f), arguments[2])
18567 : arr.call(promises, liftCombine(f));
18570 function liftCombine(f) {
18571 return function(z, x, i) {
18572 return applyFold(f, void 0, [z,x,i]);
18578 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
18580 },{"../apply":257,"../state":270}],259:[function(require,module,exports){
18581 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18582 /** @author Brian Cavalier */
18583 /** @author John Hann */
18585 (function(define) { 'use strict';
18586 define(function() {
18588 return function flow(Promise) {
18590 var resolve = Promise.resolve;
18591 var reject = Promise.reject;
18592 var origCatch = Promise.prototype['catch'];
18595 * Handle the ultimate fulfillment value or rejection reason, and assume
18596 * responsibility for all errors. If an error propagates out of result
18597 * or handleFatalError, it will be rethrown to the host, resulting in a
18598 * loud stack track on most platforms and a crash on some.
18599 * @param {function?} onResult
18600 * @param {function?} onError
18601 * @returns {undefined}
18603 Promise.prototype.done = function(onResult, onError) {
18604 this._handler.visit(this._handler.receiver, onResult, onError);
18608 * Add Error-type and predicate matching to catch. Examples:
18609 * promise.catch(TypeError, handleTypeError)
18610 * .catch(predicate, handleMatchedErrors)
18611 * .catch(handleRemainingErrors)
18612 * @param onRejected
18615 Promise.prototype['catch'] = Promise.prototype.otherwise = function(onRejected) {
18616 if (arguments.length < 2) {
18617 return origCatch.call(this, onRejected);
18620 if(typeof onRejected !== 'function') {
18621 return this.ensure(rejectInvalidPredicate);
18624 return origCatch.call(this, createCatchFilter(arguments[1], onRejected));
18628 * Wraps the provided catch handler, so that it will only be called
18629 * if the predicate evaluates truthy
18630 * @param {?function} handler
18631 * @param {function} predicate
18632 * @returns {function} conditional catch handler
18634 function createCatchFilter(handler, predicate) {
18635 return function(e) {
18636 return evaluatePredicate(e, predicate)
18637 ? handler.call(this, e)
18643 * Ensures that onFulfilledOrRejected will be called regardless of whether
18644 * this promise is fulfilled or rejected. onFulfilledOrRejected WILL NOT
18645 * receive the promises' value or reason. Any returned value will be disregarded.
18646 * onFulfilledOrRejected may throw or return a rejected promise to signal
18647 * an additional error.
18648 * @param {function} handler handler to be called regardless of
18649 * fulfillment or rejection
18650 * @returns {Promise}
18652 Promise.prototype['finally'] = Promise.prototype.ensure = function(handler) {
18653 if(typeof handler !== 'function') {
18657 return this.then(function(x) {
18658 return runSideEffect(handler, this, identity, x);
18660 return runSideEffect(handler, this, reject, e);
18664 function runSideEffect (handler, thisArg, propagate, value) {
18665 var result = handler.call(thisArg);
18666 return maybeThenable(result)
18667 ? propagateValue(result, propagate, value)
18668 : propagate(value);
18671 function propagateValue (result, propagate, x) {
18672 return resolve(result).then(function () {
18673 return propagate(x);
18678 * Recover from a failure by returning a defaultValue. If defaultValue
18679 * is a promise, it's fulfillment value will be used. If defaultValue is
18680 * a promise that rejects, the returned promise will reject with the
18682 * @param {*} defaultValue
18683 * @returns {Promise} new promise
18685 Promise.prototype['else'] = Promise.prototype.orElse = function(defaultValue) {
18686 return this.then(void 0, function() {
18687 return defaultValue;
18692 * Shortcut for .then(function() { return value; })
18694 * @return {Promise} a promise that:
18695 * - is fulfilled if value is not a promise, or
18696 * - if value is a promise, will fulfill with its value, or reject
18699 Promise.prototype['yield'] = function(value) {
18700 return this.then(function() {
18706 * Runs a side effect when this promise fulfills, without changing the
18707 * fulfillment value.
18708 * @param {function} onFulfilledSideEffect
18709 * @returns {Promise}
18711 Promise.prototype.tap = function(onFulfilledSideEffect) {
18712 return this.then(onFulfilledSideEffect)['yield'](this);
18718 function rejectInvalidPredicate() {
18719 throw new TypeError('catch predicate must be a function');
18722 function evaluatePredicate(e, predicate) {
18723 return isError(predicate) ? e instanceof predicate : predicate(e);
18726 function isError(predicate) {
18727 return predicate === Error
18728 || (predicate != null && predicate.prototype instanceof Error);
18731 function maybeThenable(x) {
18732 return (typeof x === 'object' || typeof x === 'function') && x !== null;
18735 function identity(x) {
18740 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
18742 },{}],260:[function(require,module,exports){
18743 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18744 /** @author Brian Cavalier */
18745 /** @author John Hann */
18746 /** @author Jeff Escalante */
18748 (function(define) { 'use strict';
18749 define(function() {
18751 return function fold(Promise) {
18753 Promise.prototype.fold = function(f, z) {
18754 var promise = this._beget();
18756 this._handler.fold(function(z, x, to) {
18757 Promise._handler(z).fold(function(x, z, to) {
18758 to.resolve(f.call(this, z, x));
18760 }, z, promise._handler.receiver, promise._handler);
18769 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
18771 },{}],261:[function(require,module,exports){
18772 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18773 /** @author Brian Cavalier */
18774 /** @author John Hann */
18776 (function(define) { 'use strict';
18777 define(function(require) {
18779 var inspect = require('../state').inspect;
18781 return function inspection(Promise) {
18783 Promise.prototype.inspect = function() {
18784 return inspect(Promise._handler(this));
18791 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
18793 },{"../state":270}],262:[function(require,module,exports){
18794 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18795 /** @author Brian Cavalier */
18796 /** @author John Hann */
18798 (function(define) { 'use strict';
18799 define(function() {
18801 return function generate(Promise) {
18803 var resolve = Promise.resolve;
18805 Promise.iterate = iterate;
18806 Promise.unfold = unfold;
18811 * @deprecated Use github.com/cujojs/most streams and most.iterate
18812 * Generate a (potentially infinite) stream of promised values:
18813 * x, f(x), f(f(x)), etc. until condition(x) returns true
18814 * @param {function} f function to generate a new x from the previous x
18815 * @param {function} condition function that, given the current x, returns
18816 * truthy when the iterate should stop
18817 * @param {function} handler function to handle the value produced by f
18818 * @param {*|Promise} x starting value, may be a promise
18819 * @return {Promise} the result of the last call to f before
18820 * condition returns true
18822 function iterate(f, condition, handler, x) {
18823 return unfold(function(x) {
18825 }, condition, handler, x);
18829 * @deprecated Use github.com/cujojs/most streams and most.unfold
18830 * Generate a (potentially infinite) stream of promised values
18831 * by applying handler(generator(seed)) iteratively until
18832 * condition(seed) returns true.
18833 * @param {function} unspool function that generates a [value, newSeed]
18835 * @param {function} condition function that, given the current seed, returns
18836 * truthy when the unfold should stop
18837 * @param {function} handler function to handle the value produced by unspool
18838 * @param x {*|Promise} starting value, may be a promise
18839 * @return {Promise} the result of the last value produced by unspool before
18840 * condition returns true
18842 function unfold(unspool, condition, handler, x) {
18843 return resolve(x).then(function(seed) {
18844 return resolve(condition(seed)).then(function(done) {
18845 return done ? seed : resolve(unspool(seed)).spread(next);
18849 function next(item, newSeed) {
18850 return resolve(handler(item)).then(function() {
18851 return unfold(unspool, condition, handler, newSeed);
18858 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
18860 },{}],263:[function(require,module,exports){
18861 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18862 /** @author Brian Cavalier */
18863 /** @author John Hann */
18865 (function(define) { 'use strict';
18866 define(function() {
18868 return function progress(Promise) {
18872 * Register a progress handler for this promise
18873 * @param {function} onProgress
18874 * @returns {Promise}
18876 Promise.prototype.progress = function(onProgress) {
18877 return this.then(void 0, void 0, onProgress);
18884 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
18886 },{}],264:[function(require,module,exports){
18887 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18888 /** @author Brian Cavalier */
18889 /** @author John Hann */
18891 (function(define) { 'use strict';
18892 define(function(require) {
18894 var env = require('../env');
18895 var TimeoutError = require('../TimeoutError');
18897 function setTimeout(f, ms, x, y) {
18898 return env.setTimer(function() {
18903 return function timed(Promise) {
18905 * Return a new promise whose fulfillment value is revealed only
18906 * after ms milliseconds
18907 * @param {number} ms milliseconds
18908 * @returns {Promise}
18910 Promise.prototype.delay = function(ms) {
18911 var p = this._beget();
18912 this._handler.fold(handleDelay, ms, void 0, p._handler);
18916 function handleDelay(ms, x, h) {
18917 setTimeout(resolveDelay, ms, x, h);
18920 function resolveDelay(x, h) {
18925 * Return a new promise that rejects after ms milliseconds unless
18926 * this promise fulfills earlier, in which case the returned promise
18927 * fulfills with the same value.
18928 * @param {number} ms milliseconds
18929 * @param {Error|*=} reason optional rejection reason to use, defaults
18930 * to a TimeoutError if not provided
18931 * @returns {Promise}
18933 Promise.prototype.timeout = function(ms, reason) {
18934 var p = this._beget();
18935 var h = p._handler;
18937 var t = setTimeout(onTimeout, ms, reason, p._handler);
18939 this._handler.visit(h,
18940 function onFulfill(x) {
18942 this.resolve(x); // this = h
18944 function onReject(x) {
18946 this.reject(x); // this = h
18953 function onTimeout(reason, h, ms) {
18954 var e = typeof reason === 'undefined'
18955 ? new TimeoutError('timed out after ' + ms + 'ms')
18964 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
18966 },{"../TimeoutError":256,"../env":267}],265:[function(require,module,exports){
18967 /** @license MIT License (c) copyright 2010-2014 original author or authors */
18968 /** @author Brian Cavalier */
18969 /** @author John Hann */
18971 (function(define) { 'use strict';
18972 define(function(require) {
18974 var setTimer = require('../env').setTimer;
18975 var format = require('../format');
18977 return function unhandledRejection(Promise) {
18979 var logError = noop;
18980 var logInfo = noop;
18983 if(typeof console !== 'undefined') {
18984 // Alias console to prevent things like uglify's drop_console option from
18985 // removing console.log/error. Unhandled rejections fall into the same
18986 // category as uncaught exceptions, and build tools shouldn't silence them.
18987 localConsole = console;
18988 logError = typeof localConsole.error !== 'undefined'
18989 ? function (e) { localConsole.error(e); }
18990 : function (e) { localConsole.log(e); };
18992 logInfo = typeof localConsole.info !== 'undefined'
18993 ? function (e) { localConsole.info(e); }
18994 : function (e) { localConsole.log(e); };
18997 Promise.onPotentiallyUnhandledRejection = function(rejection) {
18998 enqueue(report, rejection);
19001 Promise.onPotentiallyUnhandledRejectionHandled = function(rejection) {
19002 enqueue(unreport, rejection);
19005 Promise.onFatalRejection = function(rejection) {
19006 enqueue(throwit, rejection.value);
19011 var running = null;
19013 function report(r) {
19016 logError('Potentially unhandled rejection [' + r.id + '] ' + format.formatError(r.value));
19020 function unreport(r) {
19021 var i = reported.indexOf(r);
19023 reported.splice(i, 1);
19024 logInfo('Handled previous rejection [' + r.id + '] ' + format.formatObject(r.value));
19028 function enqueue(f, x) {
19030 if(running === null) {
19031 running = setTimer(flush, 0);
19037 while(tasks.length > 0) {
19038 tasks.shift()(tasks.shift());
19045 function throwit(e) {
19052 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
19054 },{"../env":267,"../format":268}],266:[function(require,module,exports){
19055 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19056 /** @author Brian Cavalier */
19057 /** @author John Hann */
19059 (function(define) { 'use strict';
19060 define(function() {
19062 return function addWith(Promise) {
19064 * Returns a promise whose handlers will be called with `this` set to
19065 * the supplied receiver. Subsequent promises derived from the
19066 * returned promise will also have their handlers called with receiver
19067 * as `this`. Calling `with` with undefined or no arguments will return
19068 * a promise whose handlers will again be called in the usual Promises/A+
19069 * way (no `this`) thus safely undoing any previous `with` in the
19072 * WARNING: Promises returned from `with`/`withThis` are NOT Promises/A+
19073 * compliant, specifically violating 2.2.5 (http://promisesaplus.com/#point-41)
19075 * @param {object} receiver `this` value for all handlers attached to
19076 * the returned promise.
19077 * @returns {Promise}
19079 Promise.prototype['with'] = Promise.prototype.withThis = function(receiver) {
19080 var p = this._beget();
19081 var child = p._handler;
19082 child.receiver = receiver;
19083 this._handler.chain(child, receiver);
19091 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
19094 },{}],267:[function(require,module,exports){
19095 (function (process){
19096 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19097 /** @author Brian Cavalier */
19098 /** @author John Hann */
19100 /*global process,document,setTimeout,clearTimeout,MutationObserver,WebKitMutationObserver*/
19101 (function(define) { 'use strict';
19102 define(function(require) {
19103 /*jshint maxcomplexity:6*/
19105 // Sniff "best" async scheduling option
19106 // Prefer process.nextTick or MutationObserver, then check for
19107 // setTimeout, and finally vertx, since its the only env that doesn't
19111 var capturedSetTimeout = typeof setTimeout !== 'undefined' && setTimeout;
19114 var setTimer = function(f, ms) { return setTimeout(f, ms); };
19115 var clearTimer = function(t) { return clearTimeout(t); };
19116 var asap = function (f) { return capturedSetTimeout(f, 0); };
19118 // Detect specific env
19119 if (isNode()) { // Node
19120 asap = function (f) { return process.nextTick(f); };
19122 } else if (MutationObs = hasMutationObserver()) { // Modern browser
19123 asap = initMutationObserver(MutationObs);
19125 } else if (!capturedSetTimeout) { // vert.x
19126 var vertxRequire = require;
19127 var vertx = vertxRequire('vertx');
19128 setTimer = function (f, ms) { return vertx.setTimer(ms, f); };
19129 clearTimer = vertx.cancelTimer;
19130 asap = vertx.runOnLoop || vertx.runOnContext;
19134 setTimer: setTimer,
19135 clearTimer: clearTimer,
19139 function isNode () {
19140 return typeof process !== 'undefined' &&
19141 Object.prototype.toString.call(process) === '[object process]';
19144 function hasMutationObserver () {
19145 return (typeof MutationObserver !== 'undefined' && MutationObserver) ||
19146 (typeof WebKitMutationObserver !== 'undefined' && WebKitMutationObserver);
19149 function initMutationObserver(MutationObserver) {
19151 var node = document.createTextNode('');
19152 var o = new MutationObserver(run);
19153 o.observe(node, { characterData: true });
19157 scheduled = void 0;
19162 return function (f) {
19164 node.data = (i ^= 1);
19168 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
19170 }).call(this,require('_process'))
19172 },{"_process":6}],268:[function(require,module,exports){
19173 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19174 /** @author Brian Cavalier */
19175 /** @author John Hann */
19177 (function(define) { 'use strict';
19178 define(function() {
19181 formatError: formatError,
19182 formatObject: formatObject,
19183 tryStringify: tryStringify
19187 * Format an error into a string. If e is an Error and has a stack property,
19188 * it's returned. Otherwise, e is formatted using formatObject, with a
19189 * warning added about e not being a proper Error.
19191 * @returns {String} formatted string, suitable for output to developers
19193 function formatError(e) {
19194 var s = typeof e === 'object' && e !== null && (e.stack || e.message) ? e.stack || e.message : formatObject(e);
19195 return e instanceof Error ? s : s + ' (WARNING: non-Error used)';
19199 * Format an object, detecting "plain" objects and running them through
19200 * JSON.stringify if possible.
19201 * @param {Object} o
19202 * @returns {string}
19204 function formatObject(o) {
19206 if(s === '[object Object]' && typeof JSON !== 'undefined') {
19207 s = tryStringify(o, s);
19213 * Try to return the result of JSON.stringify(x). If that fails, return
19216 * @param {*} defaultValue
19217 * @returns {String|*} JSON.stringify(x) or defaultValue
19219 function tryStringify(x, defaultValue) {
19221 return JSON.stringify(x);
19223 return defaultValue;
19228 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
19230 },{}],269:[function(require,module,exports){
19231 (function (process){
19232 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19233 /** @author Brian Cavalier */
19234 /** @author John Hann */
19236 (function(define) { 'use strict';
19237 define(function() {
19239 return function makePromise(environment) {
19241 var tasks = environment.scheduler;
19242 var emitRejection = initEmitRejection();
19244 var objectCreate = Object.create ||
19246 function Child() {}
19247 Child.prototype = proto;
19248 return new Child();
19252 * Create a promise whose fate is determined by resolver
19254 * @returns {Promise} promise
19257 function Promise(resolver, handler) {
19258 this._handler = resolver === Handler ? handler : init(resolver);
19262 * Run the supplied resolver
19264 * @returns {Pending}
19266 function init(resolver) {
19267 var handler = new Pending();
19270 resolver(promiseResolve, promiseReject, promiseNotify);
19278 * Transition from pre-resolution state to post-resolution state, notifying
19279 * all listeners of the ultimate fulfillment or rejection
19280 * @param {*} x resolution value
19282 function promiseResolve (x) {
19283 handler.resolve(x);
19286 * Reject this promise with reason, which will be used verbatim
19287 * @param {Error|*} reason rejection reason, strongly suggested
19288 * to be an Error type
19290 function promiseReject (reason) {
19291 handler.reject(reason);
19296 * Issue a progress event, notifying all progress listeners
19297 * @param {*} x progress event payload to pass to all listeners
19299 function promiseNotify (x) {
19306 Promise.resolve = resolve;
19307 Promise.reject = reject;
19308 Promise.never = never;
19310 Promise._defer = defer;
19311 Promise._handler = getHandler;
19314 * Returns a trusted promise. If x is already a trusted promise, it is
19315 * returned, otherwise returns a new trusted Promise which follows x.
19317 * @return {Promise} promise
19319 function resolve(x) {
19320 return isPromise(x) ? x
19321 : new Promise(Handler, new Async(getHandler(x)));
19325 * Return a reject promise with x as its reason (x is used verbatim)
19327 * @returns {Promise} rejected promise
19329 function reject(x) {
19330 return new Promise(Handler, new Async(new Rejected(x)));
19334 * Return a promise that remains pending forever
19335 * @returns {Promise} forever-pending promise.
19338 return foreverPendingPromise; // Should be frozen
19342 * Creates an internal {promise, resolver} pair
19344 * @returns {Promise}
19347 return new Promise(Handler, new Pending());
19350 // Transformation and flow control
19353 * Transform this promise's fulfillment value, returning a new Promise
19354 * for the transformed result. If the promise cannot be fulfilled, onRejected
19355 * is called with the reason. onProgress *may* be called with updates toward
19356 * this promise's fulfillment.
19357 * @param {function=} onFulfilled fulfillment handler
19358 * @param {function=} onRejected rejection handler
19359 * @param {function=} onProgress @deprecated progress handler
19360 * @return {Promise} new promise
19362 Promise.prototype.then = function(onFulfilled, onRejected, onProgress) {
19363 var parent = this._handler;
19364 var state = parent.join().state();
19366 if ((typeof onFulfilled !== 'function' && state > 0) ||
19367 (typeof onRejected !== 'function' && state < 0)) {
19368 // Short circuit: value will not change, simply share handler
19369 return new this.constructor(Handler, parent);
19372 var p = this._beget();
19373 var child = p._handler;
19375 parent.chain(child, parent.receiver, onFulfilled, onRejected, onProgress);
19381 * If this promise cannot be fulfilled due to an error, call onRejected to
19382 * handle the error. Shortcut for .then(undefined, onRejected)
19383 * @param {function?} onRejected
19384 * @return {Promise}
19386 Promise.prototype['catch'] = function(onRejected) {
19387 return this.then(void 0, onRejected);
19391 * Creates a new, pending promise of the same type as this promise
19393 * @returns {Promise}
19395 Promise.prototype._beget = function() {
19396 return begetFrom(this._handler, this.constructor);
19399 function begetFrom(parent, Promise) {
19400 var child = new Pending(parent.receiver, parent.join().context);
19401 return new Promise(Handler, child);
19404 // Array combinators
19407 Promise.race = race;
19408 Promise._traverse = traverse;
19411 * Return a promise that will fulfill when all promises in the
19412 * input array have fulfilled, or will reject when one of the
19413 * promises rejects.
19414 * @param {array} promises array of promises
19415 * @returns {Promise} promise for array of fulfillment values
19417 function all(promises) {
19418 return traverseWith(snd, null, promises);
19422 * Array<Promise<X>> -> Promise<Array<f(X)>>
19424 * @param {function} f function to apply to each promise's value
19425 * @param {Array} promises array of promises
19426 * @returns {Promise} promise for transformed values
19428 function traverse(f, promises) {
19429 return traverseWith(tryCatch2, f, promises);
19432 function traverseWith(tryMap, f, promises) {
19433 var handler = typeof f === 'function' ? mapAt : settleAt;
19435 var resolver = new Pending();
19436 var pending = promises.length >>> 0;
19437 var results = new Array(pending);
19439 for (var i = 0, x; i < promises.length && !resolver.resolved; ++i) {
19442 if (x === void 0 && !(i in promises)) {
19447 traverseAt(promises, handler, i, x, resolver);
19450 if(pending === 0) {
19451 resolver.become(new Fulfilled(results));
19454 return new Promise(Handler, resolver);
19456 function mapAt(i, x, resolver) {
19457 if(!resolver.resolved) {
19458 traverseAt(promises, settleAt, i, tryMap(f, x, i), resolver);
19462 function settleAt(i, x, resolver) {
19464 if(--pending === 0) {
19465 resolver.become(new Fulfilled(results));
19470 function traverseAt(promises, handler, i, x, resolver) {
19471 if (maybeThenable(x)) {
19472 var h = getHandlerMaybeThenable(x);
19476 h.fold(handler, i, void 0, resolver);
19477 } else if (s > 0) {
19478 handler(i, h.value, resolver);
19480 resolver.become(h);
19481 visitRemaining(promises, i+1, h);
19484 handler(i, x, resolver);
19488 Promise._visitRemaining = visitRemaining;
19489 function visitRemaining(promises, start, handler) {
19490 for(var i=start; i<promises.length; ++i) {
19491 markAsHandled(getHandler(promises[i]), handler);
19495 function markAsHandled(h, handler) {
19496 if(h === handler) {
19502 h.visit(h, void 0, h._unreport);
19509 * Fulfill-reject competitive race. Return a promise that will settle
19510 * to the same state as the earliest input promise to settle.
19512 * WARNING: The ES6 Promise spec requires that race()ing an empty array
19513 * must return a promise that is pending forever. This implementation
19514 * returns a singleton forever-pending promise, the same singleton that is
19515 * returned by Promise.never(), thus can be checked with ===
19517 * @param {array} promises array of promises to race
19518 * @returns {Promise} if input is non-empty, a promise that will settle
19519 * to the same outcome as the earliest input promise to settle. if empty
19520 * is empty, returns a promise that will never settle.
19522 function race(promises) {
19523 if(typeof promises !== 'object' || promises === null) {
19524 return reject(new TypeError('non-iterable passed to race()'));
19527 // Sigh, race([]) is untestable unless we return *something*
19528 // that is recognizable without calling .then() on it.
19529 return promises.length === 0 ? never()
19530 : promises.length === 1 ? resolve(promises[0])
19531 : runRace(promises);
19534 function runRace(promises) {
19535 var resolver = new Pending();
19537 for(i=0; i<promises.length; ++i) {
19539 if (x === void 0 && !(i in promises)) {
19544 if(h.state() !== 0) {
19545 resolver.become(h);
19546 visitRemaining(promises, i+1, h);
19549 h.visit(resolver, resolver.resolve, resolver.reject);
19552 return new Promise(Handler, resolver);
19555 // Promise internals
19556 // Below this, everything is @private
19559 * Get an appropriate handler for x, without checking for cycles
19561 * @returns {object} handler
19563 function getHandler(x) {
19565 return x._handler.join();
19567 return maybeThenable(x) ? getHandlerUntrusted(x) : new Fulfilled(x);
19571 * Get a handler for thenable x.
19572 * NOTE: You must only call this if maybeThenable(x) == true
19573 * @param {object|function|Promise} x
19574 * @returns {object} handler
19576 function getHandlerMaybeThenable(x) {
19577 return isPromise(x) ? x._handler.join() : getHandlerUntrusted(x);
19581 * Get a handler for potentially untrusted thenable x
19583 * @returns {object} handler
19585 function getHandlerUntrusted(x) {
19587 var untrustedThen = x.then;
19588 return typeof untrustedThen === 'function'
19589 ? new Thenable(untrustedThen, x)
19590 : new Fulfilled(x);
19592 return new Rejected(e);
19597 * Handler for a promise that is pending forever
19600 function Handler() {}
19602 Handler.prototype.when
19603 = Handler.prototype.become
19604 = Handler.prototype.notify // deprecated
19605 = Handler.prototype.fail
19606 = Handler.prototype._unreport
19607 = Handler.prototype._report
19610 Handler.prototype._state = 0;
19612 Handler.prototype.state = function() {
19613 return this._state;
19617 * Recursively collapse handler chain to find the handler
19618 * nearest to the fully resolved value.
19619 * @returns {object} handler nearest the fully resolved value
19621 Handler.prototype.join = function() {
19623 while(h.handler !== void 0) {
19629 Handler.prototype.chain = function(to, receiver, fulfilled, rejected, progress) {
19632 receiver: receiver,
19633 fulfilled: fulfilled,
19634 rejected: rejected,
19639 Handler.prototype.visit = function(receiver, fulfilled, rejected, progress) {
19640 this.chain(failIfRejected, receiver, fulfilled, rejected, progress);
19643 Handler.prototype.fold = function(f, z, c, to) {
19644 this.when(new Fold(f, z, c, to));
19648 * Handler that invokes fail() on any handler it becomes
19651 function FailIfRejected() {}
19653 inherit(Handler, FailIfRejected);
19655 FailIfRejected.prototype.become = function(h) {
19659 var failIfRejected = new FailIfRejected();
19662 * Handler that manages a queue of consumers waiting on a pending promise
19665 function Pending(receiver, inheritedContext) {
19666 Promise.createContext(this, inheritedContext);
19668 this.consumers = void 0;
19669 this.receiver = receiver;
19670 this.handler = void 0;
19671 this.resolved = false;
19674 inherit(Handler, Pending);
19676 Pending.prototype._state = 0;
19678 Pending.prototype.resolve = function(x) {
19679 this.become(getHandler(x));
19682 Pending.prototype.reject = function(x) {
19683 if(this.resolved) {
19687 this.become(new Rejected(x));
19690 Pending.prototype.join = function() {
19691 if (!this.resolved) {
19697 while (h.handler !== void 0) {
19700 return this.handler = cycle();
19707 Pending.prototype.run = function() {
19708 var q = this.consumers;
19709 var handler = this.handler;
19710 this.handler = this.handler.join();
19711 this.consumers = void 0;
19713 for (var i = 0; i < q.length; ++i) {
19714 handler.when(q[i]);
19718 Pending.prototype.become = function(handler) {
19719 if(this.resolved) {
19723 this.resolved = true;
19724 this.handler = handler;
19725 if(this.consumers !== void 0) {
19726 tasks.enqueue(this);
19729 if(this.context !== void 0) {
19730 handler._report(this.context);
19734 Pending.prototype.when = function(continuation) {
19735 if(this.resolved) {
19736 tasks.enqueue(new ContinuationTask(continuation, this.handler));
19738 if(this.consumers === void 0) {
19739 this.consumers = [continuation];
19741 this.consumers.push(continuation);
19749 Pending.prototype.notify = function(x) {
19750 if(!this.resolved) {
19751 tasks.enqueue(new ProgressTask(x, this));
19755 Pending.prototype.fail = function(context) {
19756 var c = typeof context === 'undefined' ? this.context : context;
19757 this.resolved && this.handler.join().fail(c);
19760 Pending.prototype._report = function(context) {
19761 this.resolved && this.handler.join()._report(context);
19764 Pending.prototype._unreport = function() {
19765 this.resolved && this.handler.join()._unreport();
19769 * Wrap another handler and force it into a future stack
19770 * @param {object} handler
19773 function Async(handler) {
19774 this.handler = handler;
19777 inherit(Handler, Async);
19779 Async.prototype.when = function(continuation) {
19780 tasks.enqueue(new ContinuationTask(continuation, this));
19783 Async.prototype._report = function(context) {
19784 this.join()._report(context);
19787 Async.prototype._unreport = function() {
19788 this.join()._unreport();
19792 * Handler that wraps an untrusted thenable and assimilates it in a future stack
19793 * @param {function} then
19794 * @param {{then: function}} thenable
19797 function Thenable(then, thenable) {
19798 Pending.call(this);
19799 tasks.enqueue(new AssimilateTask(then, thenable, this));
19802 inherit(Pending, Thenable);
19805 * Handler for a fulfilled promise
19806 * @param {*} x fulfillment value
19809 function Fulfilled(x) {
19810 Promise.createContext(this);
19814 inherit(Handler, Fulfilled);
19816 Fulfilled.prototype._state = 1;
19818 Fulfilled.prototype.fold = function(f, z, c, to) {
19819 runContinuation3(f, z, this, c, to);
19822 Fulfilled.prototype.when = function(cont) {
19823 runContinuation1(cont.fulfilled, this, cont.receiver, cont.resolver);
19829 * Handler for a rejected promise
19830 * @param {*} x rejection reason
19833 function Rejected(x) {
19834 Promise.createContext(this);
19836 this.id = ++errorId;
19838 this.handled = false;
19839 this.reported = false;
19844 inherit(Handler, Rejected);
19846 Rejected.prototype._state = -1;
19848 Rejected.prototype.fold = function(f, z, c, to) {
19852 Rejected.prototype.when = function(cont) {
19853 if(typeof cont.rejected === 'function') {
19856 runContinuation1(cont.rejected, this, cont.receiver, cont.resolver);
19859 Rejected.prototype._report = function(context) {
19860 tasks.afterQueue(new ReportTask(this, context));
19863 Rejected.prototype._unreport = function() {
19867 this.handled = true;
19868 tasks.afterQueue(new UnreportTask(this));
19871 Rejected.prototype.fail = function(context) {
19872 this.reported = true;
19873 emitRejection('unhandledRejection', this);
19874 Promise.onFatalRejection(this, context === void 0 ? this.context : context);
19877 function ReportTask(rejection, context) {
19878 this.rejection = rejection;
19879 this.context = context;
19882 ReportTask.prototype.run = function() {
19883 if(!this.rejection.handled && !this.rejection.reported) {
19884 this.rejection.reported = true;
19885 emitRejection('unhandledRejection', this.rejection) ||
19886 Promise.onPotentiallyUnhandledRejection(this.rejection, this.context);
19890 function UnreportTask(rejection) {
19891 this.rejection = rejection;
19894 UnreportTask.prototype.run = function() {
19895 if(this.rejection.reported) {
19896 emitRejection('rejectionHandled', this.rejection) ||
19897 Promise.onPotentiallyUnhandledRejectionHandled(this.rejection);
19901 // Unhandled rejection hooks
19902 // By default, everything is a noop
19904 Promise.createContext
19905 = Promise.enterContext
19906 = Promise.exitContext
19907 = Promise.onPotentiallyUnhandledRejection
19908 = Promise.onPotentiallyUnhandledRejectionHandled
19909 = Promise.onFatalRejection
19912 // Errors and singletons
19914 var foreverPendingHandler = new Handler();
19915 var foreverPendingPromise = new Promise(Handler, foreverPendingHandler);
19918 return new Rejected(new TypeError('Promise cycle'));
19924 * Run a single consumer
19927 function ContinuationTask(continuation, handler) {
19928 this.continuation = continuation;
19929 this.handler = handler;
19932 ContinuationTask.prototype.run = function() {
19933 this.handler.join().when(this.continuation);
19937 * Run a queue of progress handlers
19940 function ProgressTask(value, handler) {
19941 this.handler = handler;
19942 this.value = value;
19945 ProgressTask.prototype.run = function() {
19946 var q = this.handler.consumers;
19951 for (var c, i = 0; i < q.length; ++i) {
19953 runNotify(c.progress, this.value, this.handler, c.receiver, c.resolver);
19958 * Assimilate a thenable, sending it's value to resolver
19959 * @param {function} then
19960 * @param {object|function} thenable
19961 * @param {object} resolver
19964 function AssimilateTask(then, thenable, resolver) {
19966 this.thenable = thenable;
19967 this.resolver = resolver;
19970 AssimilateTask.prototype.run = function() {
19971 var h = this.resolver;
19972 tryAssimilate(this._then, this.thenable, _resolve, _reject, _notify);
19974 function _resolve(x) { h.resolve(x); }
19975 function _reject(x) { h.reject(x); }
19976 function _notify(x) { h.notify(x); }
19979 function tryAssimilate(then, thenable, resolve, reject, notify) {
19981 then.call(thenable, resolve, reject, notify);
19988 * Fold a handler value with z
19991 function Fold(f, z, c, to) {
19992 this.f = f; this.z = z; this.c = c; this.to = to;
19993 this.resolver = failIfRejected;
19994 this.receiver = this;
19997 Fold.prototype.fulfilled = function(x) {
19998 this.f.call(this.c, this.z, x, this.to);
20001 Fold.prototype.rejected = function(x) {
20005 Fold.prototype.progress = function(x) {
20013 * @returns {boolean} true iff x is a trusted Promise
20015 function isPromise(x) {
20016 return x instanceof Promise;
20020 * Test just enough to rule out primitives, in order to take faster
20021 * paths in some code
20023 * @returns {boolean} false iff x is guaranteed *not* to be a thenable
20025 function maybeThenable(x) {
20026 return (typeof x === 'object' || typeof x === 'function') && x !== null;
20029 function runContinuation1(f, h, receiver, next) {
20030 if(typeof f !== 'function') {
20031 return next.become(h);
20034 Promise.enterContext(h);
20035 tryCatchReject(f, h.value, receiver, next);
20036 Promise.exitContext();
20039 function runContinuation3(f, x, h, receiver, next) {
20040 if(typeof f !== 'function') {
20041 return next.become(h);
20044 Promise.enterContext(h);
20045 tryCatchReject3(f, x, h.value, receiver, next);
20046 Promise.exitContext();
20052 function runNotify(f, x, h, receiver, next) {
20053 if(typeof f !== 'function') {
20054 return next.notify(x);
20057 Promise.enterContext(h);
20058 tryCatchReturn(f, x, receiver, next);
20059 Promise.exitContext();
20062 function tryCatch2(f, a, b) {
20071 * Return f.call(thisArg, x), or if it throws return a rejected promise for
20072 * the thrown exception
20074 function tryCatchReject(f, x, thisArg, next) {
20076 next.become(getHandler(f.call(thisArg, x)));
20078 next.become(new Rejected(e));
20083 * Same as above, but includes the extra argument parameter.
20085 function tryCatchReject3(f, x, y, thisArg, next) {
20087 f.call(thisArg, x, y, next);
20089 next.become(new Rejected(e));
20095 * Return f.call(thisArg, x), or if it throws, *return* the exception
20097 function tryCatchReturn(f, x, thisArg, next) {
20099 next.notify(f.call(thisArg, x));
20105 function inherit(Parent, Child) {
20106 Child.prototype = objectCreate(Parent.prototype);
20107 Child.prototype.constructor = Child;
20110 function snd(x, y) {
20116 function hasCustomEvent() {
20117 if(typeof CustomEvent === 'function') {
20119 var ev = new CustomEvent('unhandledRejection');
20120 return ev instanceof CustomEvent;
20121 } catch (ignoredException) {}
20126 function hasInternetExplorerCustomEvent() {
20127 if(typeof document !== 'undefined' && typeof document.createEvent === 'function') {
20129 // Try to create one event to make sure it's supported
20130 var ev = document.createEvent('CustomEvent');
20131 ev.initCustomEvent('eventType', false, true, {});
20133 } catch (ignoredException) {}
20138 function initEmitRejection() {
20139 /*global process, self, CustomEvent*/
20140 if(typeof process !== 'undefined' && process !== null
20141 && typeof process.emit === 'function') {
20142 // Returning falsy here means to call the default
20143 // onPotentiallyUnhandledRejection API. This is safe even in
20144 // browserify since process.emit always returns falsy in browserify:
20145 // https://github.com/defunctzombie/node-process/blob/master/browser.js#L40-L46
20146 return function(type, rejection) {
20147 return type === 'unhandledRejection'
20148 ? process.emit(type, rejection.value, rejection)
20149 : process.emit(type, rejection);
20151 } else if(typeof self !== 'undefined' && hasCustomEvent()) {
20152 return (function (self, CustomEvent) {
20153 return function (type, rejection) {
20154 var ev = new CustomEvent(type, {
20156 reason: rejection.value,
20163 return !self.dispatchEvent(ev);
20165 }(self, CustomEvent));
20166 } else if(typeof self !== 'undefined' && hasInternetExplorerCustomEvent()) {
20167 return (function(self, document) {
20168 return function(type, rejection) {
20169 var ev = document.createEvent('CustomEvent');
20170 ev.initCustomEvent(type, false, true, {
20171 reason: rejection.value,
20175 return !self.dispatchEvent(ev);
20177 }(self, document));
20186 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20188 }).call(this,require('_process'))
20190 },{"_process":6}],270:[function(require,module,exports){
20191 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20192 /** @author Brian Cavalier */
20193 /** @author John Hann */
20195 (function(define) { 'use strict';
20196 define(function() {
20199 pending: toPendingState,
20200 fulfilled: toFulfilledState,
20201 rejected: toRejectedState,
20205 function toPendingState() {
20206 return { state: 'pending' };
20209 function toRejectedState(e) {
20210 return { state: 'rejected', reason: e };
20213 function toFulfilledState(x) {
20214 return { state: 'fulfilled', value: x };
20217 function inspect(handler) {
20218 var state = handler.state();
20219 return state === 0 ? toPendingState()
20220 : state > 0 ? toFulfilledState(handler.value)
20221 : toRejectedState(handler.value);
20225 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20227 },{}],271:[function(require,module,exports){
20228 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20231 * Promises/A+ and when() implementation
20232 * when is part of the cujoJS family of libraries (http://cujojs.com/)
20233 * @author Brian Cavalier
20234 * @author John Hann
20236 (function(define) { 'use strict';
20237 define(function (require) {
20239 var timed = require('./lib/decorators/timed');
20240 var array = require('./lib/decorators/array');
20241 var flow = require('./lib/decorators/flow');
20242 var fold = require('./lib/decorators/fold');
20243 var inspect = require('./lib/decorators/inspect');
20244 var generate = require('./lib/decorators/iterate');
20245 var progress = require('./lib/decorators/progress');
20246 var withThis = require('./lib/decorators/with');
20247 var unhandledRejection = require('./lib/decorators/unhandledRejection');
20248 var TimeoutError = require('./lib/TimeoutError');
20250 var Promise = [array, flow, fold, generate, progress,
20251 inspect, withThis, timed, unhandledRejection]
20252 .reduce(function(Promise, feature) {
20253 return feature(Promise);
20254 }, require('./lib/Promise'));
20256 var apply = require('./lib/apply')(Promise);
20260 when.promise = promise; // Create a pending promise
20261 when.resolve = Promise.resolve; // Create a resolved promise
20262 when.reject = Promise.reject; // Create a rejected promise
20264 when.lift = lift; // lift a function to return promises
20265 when['try'] = attempt; // call a function and return a promise
20266 when.attempt = attempt; // alias for when.try
20268 when.iterate = Promise.iterate; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
20269 when.unfold = Promise.unfold; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
20271 when.join = join; // Join 2 or more promises
20273 when.all = all; // Resolve a list of promises
20274 when.settle = settle; // Settle a list of promises
20276 when.any = lift(Promise.any); // One-winner race
20277 when.some = lift(Promise.some); // Multi-winner race
20278 when.race = lift(Promise.race); // First-to-settle race
20280 when.map = map; // Array.map() for promises
20281 when.filter = filter; // Array.filter() for promises
20282 when.reduce = lift(Promise.reduce); // Array.reduce() for promises
20283 when.reduceRight = lift(Promise.reduceRight); // Array.reduceRight() for promises
20285 when.isPromiseLike = isPromiseLike; // Is something promise-like, aka thenable
20287 when.Promise = Promise; // Promise constructor
20288 when.defer = defer; // Create a {promise, resolve, reject} tuple
20292 when.TimeoutError = TimeoutError;
20295 * Get a trusted promise for x, or by transforming x with onFulfilled
20298 * @param {function?} onFulfilled callback to be called when x is
20299 * successfully fulfilled. If promiseOrValue is an immediate value, callback
20300 * will be invoked immediately.
20301 * @param {function?} onRejected callback to be called when x is
20303 * @param {function?} onProgress callback to be called when progress updates
20304 * are issued for x. @deprecated
20305 * @returns {Promise} a new promise that will fulfill with the return
20306 * value of callback or errback or the completion value of promiseOrValue if
20307 * callback and/or errback is not supplied.
20309 function when(x, onFulfilled, onRejected, onProgress) {
20310 var p = Promise.resolve(x);
20311 if (arguments.length < 2) {
20315 return p.then(onFulfilled, onRejected, onProgress);
20319 * Creates a new promise whose fate is determined by resolver.
20320 * @param {function} resolver function(resolve, reject, notify)
20321 * @returns {Promise} promise whose fate is determine by resolver
20323 function promise(resolver) {
20324 return new Promise(resolver);
20328 * Lift the supplied function, creating a version of f that returns
20329 * promises, and accepts promises as arguments.
20330 * @param {function} f
20331 * @returns {Function} version of f that returns promises
20334 return function() {
20335 for(var i=0, l=arguments.length, a=new Array(l); i<l; ++i) {
20336 a[i] = arguments[i];
20338 return apply(f, this, a);
20343 * Call f in a future turn, with the supplied args, and return a promise
20345 * @param {function} f
20346 * @returns {Promise}
20348 function attempt(f /*, args... */) {
20349 /*jshint validthis:true */
20350 for(var i=0, l=arguments.length-1, a=new Array(l); i<l; ++i) {
20351 a[i] = arguments[i+1];
20353 return apply(f, this, a);
20357 * Creates a {promise, resolver} pair, either or both of which
20358 * may be given out safely to consumers.
20359 * @return {{promise: Promise, resolve: function, reject: function, notify: function}}
20362 return new Deferred();
20365 function Deferred() {
20366 var p = Promise._defer();
20368 function resolve(x) { p._handler.resolve(x); }
20369 function reject(x) { p._handler.reject(x); }
20370 function notify(x) { p._handler.notify(x); }
20373 this.resolve = resolve;
20374 this.reject = reject;
20375 this.notify = notify;
20376 this.resolver = { resolve: resolve, reject: reject, notify: notify };
20380 * Determines if x is promise-like, i.e. a thenable object
20381 * NOTE: Will return true for *any thenable object*, and isn't truly
20382 * safe, since it may attempt to access the `then` property of x (i.e.
20383 * clever/malicious getters may do weird things)
20384 * @param {*} x anything
20385 * @returns {boolean} true if x is promise-like
20387 function isPromiseLike(x) {
20388 return x && typeof x.then === 'function';
20392 * Return a promise that will resolve only once all the supplied arguments
20393 * have resolved. The resolution value of the returned promise will be an array
20394 * containing the resolution values of each of the arguments.
20395 * @param {...*} arguments may be a mix of promises and values
20396 * @returns {Promise}
20398 function join(/* ...promises */) {
20399 return Promise.all(arguments);
20403 * Return a promise that will fulfill once all input promises have
20404 * fulfilled, or reject when any one input promise rejects.
20405 * @param {array|Promise} promises array (or promise for an array) of promises
20406 * @returns {Promise}
20408 function all(promises) {
20409 return when(promises, Promise.all);
20413 * Return a promise that will always fulfill with an array containing
20414 * the outcome states of all input promises. The returned promise
20415 * will only reject if `promises` itself is a rejected promise.
20416 * @param {array|Promise} promises array (or promise for an array) of promises
20417 * @returns {Promise} promise for array of settled state descriptors
20419 function settle(promises) {
20420 return when(promises, Promise.settle);
20424 * Promise-aware array map function, similar to `Array.prototype.map()`,
20425 * but input array may contain promises or values.
20426 * @param {Array|Promise} promises array of anything, may contain promises and values
20427 * @param {function(x:*, index:Number):*} mapFunc map function which may
20428 * return a promise or value
20429 * @returns {Promise} promise that will fulfill with an array of mapped values
20430 * or reject if any input promise rejects.
20432 function map(promises, mapFunc) {
20433 return when(promises, function(promises) {
20434 return Promise.map(promises, mapFunc);
20439 * Filter the provided array of promises using the provided predicate. Input may
20440 * contain promises and values
20441 * @param {Array|Promise} promises array of promises and values
20442 * @param {function(x:*, index:Number):boolean} predicate filtering predicate.
20443 * Must return truthy (or promise for truthy) for items to retain.
20444 * @returns {Promise} promise that will fulfill with an array containing all items
20445 * for which predicate returned truthy.
20447 function filter(promises, predicate) {
20448 return when(promises, function(promises) {
20449 return Promise.filter(promises, predicate);
20455 })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
20457 },{"./lib/Promise":254,"./lib/TimeoutError":256,"./lib/apply":257,"./lib/decorators/array":258,"./lib/decorators/flow":259,"./lib/decorators/fold":260,"./lib/decorators/inspect":261,"./lib/decorators/iterate":262,"./lib/decorators/progress":263,"./lib/decorators/timed":264,"./lib/decorators/unhandledRejection":265,"./lib/decorators/with":266}],272:[function(require,module,exports){
20458 var nativeIsArray = Array.isArray
20459 var toString = Object.prototype.toString
20461 module.exports = nativeIsArray || isArray
20463 function isArray(obj) {
20464 return toString.call(obj) === "[object Array]"
20467 },{}],273:[function(require,module,exports){
20469 Object.defineProperty(exports, "__esModule", { value: true });
20470 var APIv3_1 = require("./api/APIv3");
20471 exports.APIv3 = APIv3_1.APIv3;
20472 var ModelCreator_1 = require("./api/ModelCreator");
20473 exports.ModelCreator = ModelCreator_1.ModelCreator;
20475 },{"./api/APIv3":286,"./api/ModelCreator":287}],274:[function(require,module,exports){
20477 function __export(m) {
20478 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
20480 Object.defineProperty(exports, "__esModule", { value: true });
20481 var Component_1 = require("./component/Component");
20482 exports.Component = Component_1.Component;
20483 var ComponentService_1 = require("./component/ComponentService");
20484 exports.ComponentService = ComponentService_1.ComponentService;
20485 var HandlerBase_1 = require("./component/utils/HandlerBase");
20486 exports.HandlerBase = HandlerBase_1.HandlerBase;
20487 var MeshFactory_1 = require("./component/utils/MeshFactory");
20488 exports.MeshFactory = MeshFactory_1.MeshFactory;
20489 var MeshScene_1 = require("./component/utils/MeshScene");
20490 exports.MeshScene = MeshScene_1.MeshScene;
20491 var MouseOperator_1 = require("./component/utils/MouseOperator");
20492 exports.MouseOperator = MouseOperator_1.MouseOperator;
20493 var AttributionComponent_1 = require("./component/AttributionComponent");
20494 exports.AttributionComponent = AttributionComponent_1.AttributionComponent;
20495 var BackgroundComponent_1 = require("./component/BackgroundComponent");
20496 exports.BackgroundComponent = BackgroundComponent_1.BackgroundComponent;
20497 var BearingComponent_1 = require("./component/BearingComponent");
20498 exports.BearingComponent = BearingComponent_1.BearingComponent;
20499 var CacheComponent_1 = require("./component/CacheComponent");
20500 exports.CacheComponent = CacheComponent_1.CacheComponent;
20501 var CoverComponent_1 = require("./component/CoverComponent");
20502 exports.CoverComponent = CoverComponent_1.CoverComponent;
20503 var DebugComponent_1 = require("./component/DebugComponent");
20504 exports.DebugComponent = DebugComponent_1.DebugComponent;
20505 var DirectionComponent_1 = require("./component/direction/DirectionComponent");
20506 exports.DirectionComponent = DirectionComponent_1.DirectionComponent;
20507 var DirectionDOMCalculator_1 = require("./component/direction/DirectionDOMCalculator");
20508 exports.DirectionDOMCalculator = DirectionDOMCalculator_1.DirectionDOMCalculator;
20509 var DirectionDOMRenderer_1 = require("./component/direction/DirectionDOMRenderer");
20510 exports.DirectionDOMRenderer = DirectionDOMRenderer_1.DirectionDOMRenderer;
20511 var ImageComponent_1 = require("./component/ImageComponent");
20512 exports.ImageComponent = ImageComponent_1.ImageComponent;
20513 var KeyboardComponent_1 = require("./component/keyboard/KeyboardComponent");
20514 exports.KeyboardComponent = KeyboardComponent_1.KeyboardComponent;
20515 var KeyPlayHandler_1 = require("./component/keyboard/KeyPlayHandler");
20516 exports.KeyPlayHandler = KeyPlayHandler_1.KeyPlayHandler;
20517 var KeyZoomHandler_1 = require("./component/keyboard/KeyZoomHandler");
20518 exports.KeyZoomHandler = KeyZoomHandler_1.KeyZoomHandler;
20519 var KeySequenceNavigationHandler_1 = require("./component/keyboard/KeySequenceNavigationHandler");
20520 exports.KeySequenceNavigationHandler = KeySequenceNavigationHandler_1.KeySequenceNavigationHandler;
20521 var KeySpatialNavigationHandler_1 = require("./component/keyboard/KeySpatialNavigationHandler");
20522 exports.KeySpatialNavigationHandler = KeySpatialNavigationHandler_1.KeySpatialNavigationHandler;
20523 var LoadingComponent_1 = require("./component/LoadingComponent");
20524 exports.LoadingComponent = LoadingComponent_1.LoadingComponent;
20525 var Marker_1 = require("./component/marker/marker/Marker");
20526 exports.Marker = Marker_1.Marker;
20527 var MarkerComponent_1 = require("./component/marker/MarkerComponent");
20528 exports.MarkerComponent = MarkerComponent_1.MarkerComponent;
20529 var MarkerScene_1 = require("./component/marker/MarkerScene");
20530 exports.MarkerScene = MarkerScene_1.MarkerScene;
20531 var MarkerSet_1 = require("./component/marker/MarkerSet");
20532 exports.MarkerSet = MarkerSet_1.MarkerSet;
20533 var MouseComponent_1 = require("./component/mouse/MouseComponent");
20534 exports.MouseComponent = MouseComponent_1.MouseComponent;
20535 var BounceHandler_1 = require("./component/mouse/BounceHandler");
20536 exports.BounceHandler = BounceHandler_1.BounceHandler;
20537 var DragPanHandler_1 = require("./component/mouse/DragPanHandler");
20538 exports.DragPanHandler = DragPanHandler_1.DragPanHandler;
20539 var DoubleClickZoomHandler_1 = require("./component/mouse/DoubleClickZoomHandler");
20540 exports.DoubleClickZoomHandler = DoubleClickZoomHandler_1.DoubleClickZoomHandler;
20541 var EarthControlHandler_1 = require("./component/mouse/EarthControlHandler");
20542 exports.EarthControlHandler = EarthControlHandler_1.EarthControlHandler;
20543 var ScrollZoomHandler_1 = require("./component/mouse/ScrollZoomHandler");
20544 exports.ScrollZoomHandler = ScrollZoomHandler_1.ScrollZoomHandler;
20545 var TouchZoomHandler_1 = require("./component/mouse/TouchZoomHandler");
20546 exports.TouchZoomHandler = TouchZoomHandler_1.TouchZoomHandler;
20547 var ImageBoundary = require("./component/mouse/ImageBoundary");
20548 exports.ImageBoundary = ImageBoundary;
20549 var Popup_1 = require("./component/popup/popup/Popup");
20550 exports.Popup = Popup_1.Popup;
20551 var PopupComponent_1 = require("./component/popup/PopupComponent");
20552 exports.PopupComponent = PopupComponent_1.PopupComponent;
20553 var NavigationComponent_1 = require("./component/NavigationComponent");
20554 exports.NavigationComponent = NavigationComponent_1.NavigationComponent;
20555 var RouteComponent_1 = require("./component/RouteComponent");
20556 exports.RouteComponent = RouteComponent_1.RouteComponent;
20557 var SequenceComponent_1 = require("./component/sequence/SequenceComponent");
20558 exports.SequenceComponent = SequenceComponent_1.SequenceComponent;
20559 var SequenceDOMRenderer_1 = require("./component/sequence/SequenceDOMRenderer");
20560 exports.SequenceDOMRenderer = SequenceDOMRenderer_1.SequenceDOMRenderer;
20561 var SequenceMode_1 = require("./component/sequence/SequenceMode");
20562 exports.SequenceMode = SequenceMode_1.SequenceMode;
20563 var SpatialDataCache_1 = require("./component/spatialdata/SpatialDataCache");
20564 exports.SpatialDataCache = SpatialDataCache_1.SpatialDataCache;
20565 var SpatialDataComponent_1 = require("./component/spatialdata/SpatialDataComponent");
20566 exports.SpatialDataComponent = SpatialDataComponent_1.SpatialDataComponent;
20567 var SpatialDataScene_1 = require("./component/spatialdata/SpatialDataScene");
20568 exports.SpatialDataScene = SpatialDataScene_1.SpatialDataScene;
20569 var ImagePlaneComponent_1 = require("./component/imageplane/ImagePlaneComponent");
20570 exports.ImagePlaneComponent = ImagePlaneComponent_1.ImagePlaneComponent;
20571 var ImagePlaneGLRenderer_1 = require("./component/imageplane/ImagePlaneGLRenderer");
20572 exports.ImagePlaneGLRenderer = ImagePlaneGLRenderer_1.ImagePlaneGLRenderer;
20573 var Shaders_1 = require("./component/shaders/Shaders");
20574 exports.Shaders = Shaders_1.Shaders;
20575 var SimpleMarker_1 = require("./component/marker/marker/SimpleMarker");
20576 exports.SimpleMarker = SimpleMarker_1.SimpleMarker;
20577 var CircleMarker_1 = require("./component/marker/marker/CircleMarker");
20578 exports.CircleMarker = CircleMarker_1.CircleMarker;
20579 var SliderComponent_1 = require("./component/slider/SliderComponent");
20580 exports.SliderComponent = SliderComponent_1.SliderComponent;
20581 var SliderDOMRenderer_1 = require("./component/slider/SliderDOMRenderer");
20582 exports.SliderDOMRenderer = SliderDOMRenderer_1.SliderDOMRenderer;
20583 var SliderGLRenderer_1 = require("./component/slider/SliderGLRenderer");
20584 exports.SliderGLRenderer = SliderGLRenderer_1.SliderGLRenderer;
20585 var StatsComponent_1 = require("./component/StatsComponent");
20586 exports.StatsComponent = StatsComponent_1.StatsComponent;
20587 var TagHandlerBase_1 = require("./component/tag/handlers/TagHandlerBase");
20588 exports.TagHandlerBase = TagHandlerBase_1.TagHandlerBase;
20589 var CreateHandlerBase_1 = require("./component/tag/handlers/CreateHandlerBase");
20590 exports.CreateHandlerBase = CreateHandlerBase_1.CreateHandlerBase;
20591 var CreatePointHandler_1 = require("./component/tag/handlers/CreatePointHandler");
20592 exports.CreatePointHandler = CreatePointHandler_1.CreatePointHandler;
20593 var CreateVertexHandler_1 = require("./component/tag/handlers/CreateVertexHandler");
20594 exports.CreateVertexHandler = CreateVertexHandler_1.CreateVertexHandler;
20595 var CreatePolygonHandler_1 = require("./component/tag/handlers/CreatePolygonHandler");
20596 exports.CreatePolygonHandler = CreatePolygonHandler_1.CreatePolygonHandler;
20597 var CreateRectHandler_1 = require("./component/tag/handlers/CreateRectHandler");
20598 exports.CreateRectHandler = CreateRectHandler_1.CreateRectHandler;
20599 var CreateRectDragHandler_1 = require("./component/tag/handlers/CreateRectDragHandler");
20600 exports.CreateRectDragHandler = CreateRectDragHandler_1.CreateRectDragHandler;
20601 var EditVertexHandler_1 = require("./component/tag/handlers/EditVertexHandler");
20602 exports.EditVertexHandler = EditVertexHandler_1.EditVertexHandler;
20603 var Tag_1 = require("./component/tag/tag/Tag");
20604 exports.Tag = Tag_1.Tag;
20605 var OutlineTag_1 = require("./component/tag/tag/OutlineTag");
20606 exports.OutlineTag = OutlineTag_1.OutlineTag;
20607 var RenderTag_1 = require("./component/tag/tag/RenderTag");
20608 exports.RenderTag = RenderTag_1.RenderTag;
20609 var OutlineRenderTag_1 = require("./component/tag/tag/OutlineRenderTag");
20610 exports.OutlineRenderTag = OutlineRenderTag_1.OutlineRenderTag;
20611 var OutlineCreateTag_1 = require("./component/tag/tag/OutlineCreateTag");
20612 exports.OutlineCreateTag = OutlineCreateTag_1.OutlineCreateTag;
20613 var SpotTag_1 = require("./component/tag/tag/SpotTag");
20614 exports.SpotTag = SpotTag_1.SpotTag;
20615 var SpotRenderTag_1 = require("./component/tag/tag/SpotRenderTag");
20616 exports.SpotRenderTag = SpotRenderTag_1.SpotRenderTag;
20617 var TagDomain_1 = require("./component/tag/tag/TagDomain");
20618 exports.TagDomain = TagDomain_1.TagDomain;
20619 var TagComponent_1 = require("./component/tag/TagComponent");
20620 exports.TagComponent = TagComponent_1.TagComponent;
20621 var TagCreator_1 = require("./component/tag/TagCreator");
20622 exports.TagCreator = TagCreator_1.TagCreator;
20623 var TagDOMRenderer_1 = require("./component/tag/TagDOMRenderer");
20624 exports.TagDOMRenderer = TagDOMRenderer_1.TagDOMRenderer;
20625 var TagMode_1 = require("./component/tag/TagMode");
20626 exports.TagMode = TagMode_1.TagMode;
20627 var TagOperation_1 = require("./component/tag/TagOperation");
20628 exports.TagOperation = TagOperation_1.TagOperation;
20629 var TagScene_1 = require("./component/tag/TagScene");
20630 exports.TagScene = TagScene_1.TagScene;
20631 var TagSet_1 = require("./component/tag/TagSet");
20632 exports.TagSet = TagSet_1.TagSet;
20633 var Geometry_1 = require("./component/tag/geometry/Geometry");
20634 exports.Geometry = Geometry_1.Geometry;
20635 var VertexGeometry_1 = require("./component/tag/geometry/VertexGeometry");
20636 exports.VertexGeometry = VertexGeometry_1.VertexGeometry;
20637 var RectGeometry_1 = require("./component/tag/geometry/RectGeometry");
20638 exports.RectGeometry = RectGeometry_1.RectGeometry;
20639 var PointGeometry_1 = require("./component/tag/geometry/PointGeometry");
20640 exports.PointGeometry = PointGeometry_1.PointGeometry;
20641 var PolygonGeometry_1 = require("./component/tag/geometry/PolygonGeometry");
20642 exports.PolygonGeometry = PolygonGeometry_1.PolygonGeometry;
20643 var GeometryTagError_1 = require("./component/tag/error/GeometryTagError");
20644 exports.GeometryTagError = GeometryTagError_1.GeometryTagError;
20645 var ZoomComponent_1 = require("./component/zoom/ZoomComponent");
20646 exports.ZoomComponent = ZoomComponent_1.ZoomComponent;
20647 __export(require("./component/interfaces/interfaces"));
20649 },{"./component/AttributionComponent":288,"./component/BackgroundComponent":289,"./component/BearingComponent":290,"./component/CacheComponent":291,"./component/Component":292,"./component/ComponentService":293,"./component/CoverComponent":294,"./component/DebugComponent":295,"./component/ImageComponent":296,"./component/LoadingComponent":297,"./component/NavigationComponent":298,"./component/RouteComponent":299,"./component/StatsComponent":300,"./component/direction/DirectionComponent":301,"./component/direction/DirectionDOMCalculator":302,"./component/direction/DirectionDOMRenderer":303,"./component/imageplane/ImagePlaneComponent":304,"./component/imageplane/ImagePlaneGLRenderer":305,"./component/interfaces/interfaces":308,"./component/keyboard/KeyPlayHandler":309,"./component/keyboard/KeySequenceNavigationHandler":310,"./component/keyboard/KeySpatialNavigationHandler":311,"./component/keyboard/KeyZoomHandler":312,"./component/keyboard/KeyboardComponent":313,"./component/marker/MarkerComponent":315,"./component/marker/MarkerScene":316,"./component/marker/MarkerSet":317,"./component/marker/marker/CircleMarker":318,"./component/marker/marker/Marker":319,"./component/marker/marker/SimpleMarker":320,"./component/mouse/BounceHandler":321,"./component/mouse/DoubleClickZoomHandler":322,"./component/mouse/DragPanHandler":323,"./component/mouse/EarthControlHandler":324,"./component/mouse/ImageBoundary":325,"./component/mouse/MouseComponent":326,"./component/mouse/ScrollZoomHandler":327,"./component/mouse/TouchZoomHandler":328,"./component/popup/PopupComponent":330,"./component/popup/popup/Popup":331,"./component/sequence/SequenceComponent":332,"./component/sequence/SequenceDOMRenderer":333,"./component/sequence/SequenceMode":334,"./component/shaders/Shaders":335,"./component/slider/SliderComponent":336,"./component/slider/SliderDOMRenderer":337,"./component/slider/SliderGLRenderer":338,"./component/spatialdata/SpatialDataCache":339,"./component/spatialdata/SpatialDataComponent":340,"./component/spatialdata/SpatialDataScene":341,"./component/tag/TagComponent":343,"./component/tag/TagCreator":344,"./component/tag/TagDOMRenderer":345,"./component/tag/TagMode":346,"./component/tag/TagOperation":347,"./component/tag/TagScene":348,"./component/tag/TagSet":349,"./component/tag/error/GeometryTagError":350,"./component/tag/geometry/Geometry":351,"./component/tag/geometry/PointGeometry":352,"./component/tag/geometry/PolygonGeometry":353,"./component/tag/geometry/RectGeometry":354,"./component/tag/geometry/VertexGeometry":355,"./component/tag/handlers/CreateHandlerBase":356,"./component/tag/handlers/CreatePointHandler":357,"./component/tag/handlers/CreatePolygonHandler":358,"./component/tag/handlers/CreateRectDragHandler":359,"./component/tag/handlers/CreateRectHandler":360,"./component/tag/handlers/CreateVertexHandler":361,"./component/tag/handlers/EditVertexHandler":362,"./component/tag/handlers/TagHandlerBase":363,"./component/tag/tag/OutlineCreateTag":364,"./component/tag/tag/OutlineRenderTag":365,"./component/tag/tag/OutlineTag":366,"./component/tag/tag/RenderTag":367,"./component/tag/tag/SpotRenderTag":368,"./component/tag/tag/SpotTag":369,"./component/tag/tag/Tag":370,"./component/tag/tag/TagDomain":371,"./component/utils/HandlerBase":372,"./component/utils/MeshFactory":373,"./component/utils/MeshScene":374,"./component/utils/MouseOperator":375,"./component/zoom/ZoomComponent":376}],275:[function(require,module,exports){
20651 Object.defineProperty(exports, "__esModule", { value: true });
20652 var EdgeDirection_1 = require("./graph/edge/EdgeDirection");
20653 exports.EdgeDirection = EdgeDirection_1.EdgeDirection;
20654 var EdgeCalculatorSettings_1 = require("./graph/edge/EdgeCalculatorSettings");
20655 exports.EdgeCalculatorSettings = EdgeCalculatorSettings_1.EdgeCalculatorSettings;
20656 var EdgeCalculatorDirections_1 = require("./graph/edge/EdgeCalculatorDirections");
20657 exports.EdgeCalculatorDirections = EdgeCalculatorDirections_1.EdgeCalculatorDirections;
20658 var EdgeCalculatorCoefficients_1 = require("./graph/edge/EdgeCalculatorCoefficients");
20659 exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients_1.EdgeCalculatorCoefficients;
20660 var EdgeCalculator_1 = require("./graph/edge/EdgeCalculator");
20661 exports.EdgeCalculator = EdgeCalculator_1.EdgeCalculator;
20663 },{"./graph/edge/EdgeCalculator":398,"./graph/edge/EdgeCalculatorCoefficients":399,"./graph/edge/EdgeCalculatorDirections":400,"./graph/edge/EdgeCalculatorSettings":401,"./graph/edge/EdgeDirection":402}],276:[function(require,module,exports){
20665 Object.defineProperty(exports, "__esModule", { value: true });
20666 var AbortMapillaryError_1 = require("./error/AbortMapillaryError");
20667 exports.AbortMapillaryError = AbortMapillaryError_1.AbortMapillaryError;
20668 var ArgumentMapillaryError_1 = require("./error/ArgumentMapillaryError");
20669 exports.ArgumentMapillaryError = ArgumentMapillaryError_1.ArgumentMapillaryError;
20670 var GraphMapillaryError_1 = require("./error/GraphMapillaryError");
20671 exports.GraphMapillaryError = GraphMapillaryError_1.GraphMapillaryError;
20672 var MapillaryError_1 = require("./error/MapillaryError");
20673 exports.MapillaryError = MapillaryError_1.MapillaryError;
20675 },{"./error/AbortMapillaryError":377,"./error/ArgumentMapillaryError":378,"./error/GraphMapillaryError":379,"./error/MapillaryError":380}],277:[function(require,module,exports){
20677 Object.defineProperty(exports, "__esModule", { value: true });
20678 var Camera_1 = require("./geo/Camera");
20679 exports.Camera = Camera_1.Camera;
20680 var GeoCoords_1 = require("./geo/GeoCoords");
20681 exports.GeoCoords = GeoCoords_1.GeoCoords;
20682 var ViewportCoords_1 = require("./geo/ViewportCoords");
20683 exports.ViewportCoords = ViewportCoords_1.ViewportCoords;
20684 var Spatial_1 = require("./geo/Spatial");
20685 exports.Spatial = Spatial_1.Spatial;
20686 var Transform_1 = require("./geo/Transform");
20687 exports.Transform = Transform_1.Transform;
20688 var Geo = require("./geo/Geo");
20690 var Lines = require("./geo/Lines");
20691 exports.Lines = Lines;
20693 },{"./geo/Camera":381,"./geo/Geo":382,"./geo/GeoCoords":383,"./geo/Lines":384,"./geo/Spatial":385,"./geo/Transform":386,"./geo/ViewportCoords":387}],278:[function(require,module,exports){
20695 Object.defineProperty(exports, "__esModule", { value: true });
20696 var FilterCreator_1 = require("./graph/FilterCreator");
20697 exports.FilterCreator = FilterCreator_1.FilterCreator;
20698 var Graph_1 = require("./graph/Graph");
20699 exports.Graph = Graph_1.Graph;
20700 var GraphCalculator_1 = require("./graph/GraphCalculator");
20701 exports.GraphCalculator = GraphCalculator_1.GraphCalculator;
20702 var GraphMode_1 = require("./graph/GraphMode");
20703 exports.GraphMode = GraphMode_1.GraphMode;
20704 var GraphService_1 = require("./graph/GraphService");
20705 exports.GraphService = GraphService_1.GraphService;
20706 var ImageLoadingService_1 = require("./graph/ImageLoadingService");
20707 exports.ImageLoadingService = ImageLoadingService_1.ImageLoadingService;
20708 var MeshReader_1 = require("./graph/MeshReader");
20709 exports.MeshReader = MeshReader_1.MeshReader;
20710 var Node_1 = require("./graph/Node");
20711 exports.Node = Node_1.Node;
20712 var NodeCache_1 = require("./graph/NodeCache");
20713 exports.NodeCache = NodeCache_1.NodeCache;
20714 var Sequence_1 = require("./graph/Sequence");
20715 exports.Sequence = Sequence_1.Sequence;
20717 },{"./graph/FilterCreator":388,"./graph/Graph":389,"./graph/GraphCalculator":390,"./graph/GraphMode":391,"./graph/GraphService":392,"./graph/ImageLoadingService":393,"./graph/MeshReader":394,"./graph/Node":395,"./graph/NodeCache":396,"./graph/Sequence":397}],279:[function(require,module,exports){
20720 * MapillaryJS is a WebGL JavaScript library for exploring street level imagery
20723 function __export(m) {
20724 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
20726 Object.defineProperty(exports, "__esModule", { value: true });
20727 __export(require("./Support"));
20728 var Edge_1 = require("./Edge");
20729 exports.EdgeDirection = Edge_1.EdgeDirection;
20730 var Error_1 = require("./Error");
20731 exports.AbortMapillaryError = Error_1.AbortMapillaryError;
20732 var Render_1 = require("./Render");
20733 exports.RenderMode = Render_1.RenderMode;
20734 var State_1 = require("./State");
20735 exports.TransitionMode = State_1.TransitionMode;
20736 var Viewer_1 = require("./Viewer");
20737 exports.Alignment = Viewer_1.Alignment;
20738 exports.ImageSize = Viewer_1.ImageSize;
20739 exports.Viewer = Viewer_1.Viewer;
20740 var Component_1 = require("./Component");
20741 exports.SliderMode = Component_1.SliderMode;
20742 var TagComponent = require("./component/tag/Tag");
20743 exports.TagComponent = TagComponent;
20744 var MarkerComponent = require("./component/marker/Marker");
20745 exports.MarkerComponent = MarkerComponent;
20746 var PopupComponent = require("./component/popup/Popup");
20747 exports.PopupComponent = PopupComponent;
20749 },{"./Component":274,"./Edge":275,"./Error":276,"./Render":280,"./State":281,"./Support":282,"./Viewer":285,"./component/marker/Marker":314,"./component/popup/Popup":329,"./component/tag/Tag":342}],280:[function(require,module,exports){
20751 Object.defineProperty(exports, "__esModule", { value: true });
20752 var DOMRenderer_1 = require("./render/DOMRenderer");
20753 exports.DOMRenderer = DOMRenderer_1.DOMRenderer;
20754 var GLRenderer_1 = require("./render/GLRenderer");
20755 exports.GLRenderer = GLRenderer_1.GLRenderer;
20756 var GLRenderStage_1 = require("./render/GLRenderStage");
20757 exports.GLRenderStage = GLRenderStage_1.GLRenderStage;
20758 var RenderCamera_1 = require("./render/RenderCamera");
20759 exports.RenderCamera = RenderCamera_1.RenderCamera;
20760 var RenderMode_1 = require("./render/RenderMode");
20761 exports.RenderMode = RenderMode_1.RenderMode;
20762 var RenderService_1 = require("./render/RenderService");
20763 exports.RenderService = RenderService_1.RenderService;
20765 },{"./render/DOMRenderer":403,"./render/GLRenderStage":404,"./render/GLRenderer":405,"./render/RenderCamera":406,"./render/RenderMode":407,"./render/RenderService":408}],281:[function(require,module,exports){
20767 Object.defineProperty(exports, "__esModule", { value: true });
20768 var FrameGenerator_1 = require("./state/FrameGenerator");
20769 exports.FrameGenerator = FrameGenerator_1.FrameGenerator;
20770 var RotationDelta_1 = require("./state/RotationDelta");
20771 exports.RotationDelta = RotationDelta_1.RotationDelta;
20772 var State_1 = require("./state/State");
20773 exports.State = State_1.State;
20774 var StateBase_1 = require("./state/states/StateBase");
20775 exports.StateBase = StateBase_1.StateBase;
20776 var StateContext_1 = require("./state/StateContext");
20777 exports.StateContext = StateContext_1.StateContext;
20778 var StateService_1 = require("./state/StateService");
20779 exports.StateService = StateService_1.StateService;
20780 var TransitionMode_1 = require("./state/TransitionMode");
20781 exports.TransitionMode = TransitionMode_1.TransitionMode;
20782 var EarthState_1 = require("./state/states/EarthState");
20783 exports.EarthState = EarthState_1.EarthState;
20784 var InteractiveStateBase_1 = require("./state/states/InteractiveStateBase");
20785 exports.InteractiveStateBase = InteractiveStateBase_1.InteractiveStateBase;
20786 var InteractiveWaitingState_1 = require("./state/states/InteractiveWaitingState");
20787 exports.InteractiveWaitingState = InteractiveWaitingState_1.InteractiveWaitingState;
20788 var TraversingState_1 = require("./state/states/TraversingState");
20789 exports.TraversingState = TraversingState_1.TraversingState;
20790 var WaitingState_1 = require("./state/states/WaitingState");
20791 exports.WaitingState = WaitingState_1.WaitingState;
20793 },{"./state/FrameGenerator":409,"./state/RotationDelta":410,"./state/State":411,"./state/StateContext":412,"./state/StateService":413,"./state/TransitionMode":414,"./state/states/EarthState":415,"./state/states/InteractiveStateBase":416,"./state/states/InteractiveWaitingState":417,"./state/states/StateBase":418,"./state/states/TraversingState":419,"./state/states/WaitingState":420}],282:[function(require,module,exports){
20795 Object.defineProperty(exports, "__esModule", { value: true });
20796 var support = require("./utils/Support");
20798 * Test whether the current browser supports the full
20799 * functionality of MapillaryJS.
20801 * @description The full functionality includes WebGL rendering.
20803 * @return {boolean}
20805 * @example `var supported = Mapillary.isSupported();`
20807 function isSupported() {
20808 return isFallbackSupported() &&
20809 support.isWebGLSupportedCached();
20811 exports.isSupported = isSupported;
20813 * Test whether the current browser supports the fallback
20814 * functionality of MapillaryJS.
20816 * @description The fallback functionality does not include WebGL
20817 * rendering, only 2D canvas rendering.
20819 * @return {boolean}
20821 * @example `var fallbackSupported = Mapillary.isFallbackSupported();`
20823 function isFallbackSupported() {
20824 return support.isBrowser() &&
20825 support.isBlobSupported() &&
20826 support.isArraySupported() &&
20827 support.isFunctionSupported() &&
20828 support.isJSONSupported() &&
20829 support.isObjectSupported();
20831 exports.isFallbackSupported = isFallbackSupported;
20833 },{"./utils/Support":428}],283:[function(require,module,exports){
20835 Object.defineProperty(exports, "__esModule", { value: true });
20836 var ImageTileLoader_1 = require("./tiles/ImageTileLoader");
20837 exports.ImageTileLoader = ImageTileLoader_1.ImageTileLoader;
20838 var ImageTileStore_1 = require("./tiles/ImageTileStore");
20839 exports.ImageTileStore = ImageTileStore_1.ImageTileStore;
20840 var TextureProvider_1 = require("./tiles/TextureProvider");
20841 exports.TextureProvider = TextureProvider_1.TextureProvider;
20842 var RegionOfInterestCalculator_1 = require("./tiles/RegionOfInterestCalculator");
20843 exports.RegionOfInterestCalculator = RegionOfInterestCalculator_1.RegionOfInterestCalculator;
20845 },{"./tiles/ImageTileLoader":421,"./tiles/ImageTileStore":422,"./tiles/RegionOfInterestCalculator":423,"./tiles/TextureProvider":424}],284:[function(require,module,exports){
20847 function __export(m) {
20848 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
20850 Object.defineProperty(exports, "__esModule", { value: true });
20851 var DOM_1 = require("./utils/DOM");
20852 exports.DOM = DOM_1.DOM;
20853 var EventEmitter_1 = require("./utils/EventEmitter");
20854 exports.EventEmitter = EventEmitter_1.EventEmitter;
20855 var Settings_1 = require("./utils/Settings");
20856 exports.Settings = Settings_1.Settings;
20857 __export(require("./utils/Support"));
20858 var Urls_1 = require("./utils/Urls");
20859 exports.Urls = Urls_1.Urls;
20861 },{"./utils/DOM":425,"./utils/EventEmitter":426,"./utils/Settings":427,"./utils/Support":428,"./utils/Urls":429}],285:[function(require,module,exports){
20863 Object.defineProperty(exports, "__esModule", { value: true });
20864 var Alignment_1 = require("./viewer/Alignment");
20865 exports.Alignment = Alignment_1.Alignment;
20866 var CacheService_1 = require("./viewer/CacheService");
20867 exports.CacheService = CacheService_1.CacheService;
20868 var ComponentController_1 = require("./viewer/ComponentController");
20869 exports.ComponentController = ComponentController_1.ComponentController;
20870 var Container_1 = require("./viewer/Container");
20871 exports.Container = Container_1.Container;
20872 var Observer_1 = require("./viewer/Observer");
20873 exports.Observer = Observer_1.Observer;
20874 var ImageSize_1 = require("./viewer/ImageSize");
20875 exports.ImageSize = ImageSize_1.ImageSize;
20876 var KeyboardService_1 = require("./viewer/KeyboardService");
20877 exports.KeyboardService = KeyboardService_1.KeyboardService;
20878 var LoadingService_1 = require("./viewer/LoadingService");
20879 exports.LoadingService = LoadingService_1.LoadingService;
20880 var MouseService_1 = require("./viewer/MouseService");
20881 exports.MouseService = MouseService_1.MouseService;
20882 var Navigator_1 = require("./viewer/Navigator");
20883 exports.Navigator = Navigator_1.Navigator;
20884 var PlayService_1 = require("./viewer/PlayService");
20885 exports.PlayService = PlayService_1.PlayService;
20886 var Projection_1 = require("./viewer/Projection");
20887 exports.Projection = Projection_1.Projection;
20888 var SpriteService_1 = require("./viewer/SpriteService");
20889 exports.SpriteService = SpriteService_1.SpriteService;
20890 var TouchService_1 = require("./viewer/TouchService");
20891 exports.TouchService = TouchService_1.TouchService;
20892 var Viewer_1 = require("./viewer/Viewer");
20893 exports.Viewer = Viewer_1.Viewer;
20895 },{"./viewer/Alignment":430,"./viewer/CacheService":431,"./viewer/ComponentController":432,"./viewer/Container":433,"./viewer/ImageSize":434,"./viewer/KeyboardService":435,"./viewer/LoadingService":436,"./viewer/MouseService":437,"./viewer/Navigator":438,"./viewer/Observer":439,"./viewer/PlayService":440,"./viewer/Projection":441,"./viewer/SpriteService":442,"./viewer/TouchService":443,"./viewer/Viewer":444}],286:[function(require,module,exports){
20897 Object.defineProperty(exports, "__esModule", { value: true });
20898 var operators_1 = require("rxjs/operators");
20899 var rxjs_1 = require("rxjs");
20900 var API_1 = require("../API");
20904 * @classdesc Provides methods for access of API v3.
20906 var APIv3 = /** @class */ (function () {
20908 * Create a new api v3 instance.
20910 * @param {number} clientId - Client id for API requests.
20911 * @param {number} [token] - Optional bearer token for API requests of
20912 * protected resources.
20913 * @param {ModelCreator} [creator] - Optional model creator instance.
20915 function APIv3(clientId, token, creator) {
20916 this._clientId = clientId;
20917 this._modelCreator = creator != null ? creator : new API_1.ModelCreator();
20918 this._model = this._modelCreator.createModel(clientId, token);
20919 this._pageCount = 999;
20920 this._pathImageByKey = "imageByKey";
20921 this._pathImageCloseTo = "imageCloseTo";
20922 this._pathImagesByH = "imagesByH";
20923 this._pathImageViewAdd = "imageViewAdd";
20924 this._pathSequenceByKey = "sequenceByKey";
20925 this._pathSequenceViewAdd = "sequenceViewAdd";
20926 this._propertiesCore = [
20931 this._propertiesFill = [
20933 "captured_with_camera_uuid",
20935 "organization_key",
20939 this._propertiesKey = [
20942 this._propertiesSequence = [
20945 this._propertiesSpatial = [
20961 this._propertiesUser = [
20965 APIv3.prototype.imageByKeyFill$ = function (keys) {
20966 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
20967 this._pathImageByKey,
20969 this._propertiesKey
20970 .concat(this._propertiesFill)
20971 .concat(this._propertiesSpatial),
20972 this._propertiesKey
20973 .concat(this._propertiesUser)
20974 ])).pipe(operators_1.map(function (value) {
20976 throw new Error("Images (" + keys.join(", ") + ") could not be found.");
20978 return value.json.imageByKey;
20979 })), this._pathImageByKey, keys);
20981 APIv3.prototype.imageByKeyFull$ = function (keys) {
20982 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
20983 this._pathImageByKey,
20985 this._propertiesKey
20986 .concat(this._propertiesCore)
20987 .concat(this._propertiesFill)
20988 .concat(this._propertiesSpatial),
20989 this._propertiesKey
20990 .concat(this._propertiesUser)
20991 ])).pipe(operators_1.map(function (value) {
20993 throw new Error("Images (" + keys.join(", ") + ") could not be found.");
20995 return value.json.imageByKey;
20996 })), this._pathImageByKey, keys);
20998 APIv3.prototype.imageCloseTo$ = function (lat, lon) {
20999 var lonLat = lon + ":" + lat;
21000 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
21001 this._pathImageCloseTo,
21003 this._propertiesKey
21004 .concat(this._propertiesCore)
21005 .concat(this._propertiesFill)
21006 .concat(this._propertiesSpatial),
21007 this._propertiesKey
21008 .concat(this._propertiesUser)
21009 ])).pipe(operators_1.map(function (value) {
21010 return value != null ? value.json.imageCloseTo[lonLat] : null;
21011 })), this._pathImageCloseTo, [lonLat]);
21013 APIv3.prototype.imagesByH$ = function (hs) {
21015 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
21016 this._pathImagesByH,
21018 { from: 0, to: this._pageCount },
21019 this._propertiesKey
21020 .concat(this._propertiesCore)
21021 ])).pipe(operators_1.map(function (value) {
21023 value = { json: { imagesByH: {} } };
21024 for (var _i = 0, hs_1 = hs; _i < hs_1.length; _i++) {
21026 value.json.imagesByH[h] = {};
21027 for (var i = 0; i <= _this._pageCount; i++) {
21028 value.json.imagesByH[h][i] = null;
21032 return value.json.imagesByH;
21033 })), this._pathImagesByH, hs);
21035 APIv3.prototype.imageViewAdd$ = function (keys) {
21036 return this._catchInvalidateCall$(this._wrapCallModelResponse$(this._model.call([this._pathImageViewAdd], [keys])), this._pathImageViewAdd, keys);
21038 APIv3.prototype.invalidateImageByKey = function (keys) {
21039 this._invalidateGet(this._pathImageByKey, keys);
21041 APIv3.prototype.invalidateImagesByH = function (hs) {
21042 this._invalidateGet(this._pathImagesByH, hs);
21044 APIv3.prototype.invalidateSequenceByKey = function (sKeys) {
21045 this._invalidateGet(this._pathSequenceByKey, sKeys);
21047 APIv3.prototype.setToken = function (token) {
21048 this._model.invalidate([]);
21049 this._model = null;
21050 this._model = this._modelCreator.createModel(this._clientId, token);
21052 APIv3.prototype.sequenceByKey$ = function (sequenceKeys) {
21053 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
21054 this._pathSequenceByKey,
21056 this._propertiesKey
21057 .concat(this._propertiesSequence)
21058 ])).pipe(operators_1.map(function (value) {
21060 value = { json: { sequenceByKey: {} } };
21062 for (var _i = 0, sequenceKeys_1 = sequenceKeys; _i < sequenceKeys_1.length; _i++) {
21063 var sequenceKey = sequenceKeys_1[_i];
21064 if (!(sequenceKey in value.json.sequenceByKey)) {
21065 console.warn("Sequence data missing (" + sequenceKey + ")");
21066 value.json.sequenceByKey[sequenceKey] = { key: sequenceKey, keys: [] };
21069 return value.json.sequenceByKey;
21070 })), this._pathSequenceByKey, sequenceKeys);
21072 APIv3.prototype.sequenceViewAdd$ = function (sequenceKeys) {
21073 return this._catchInvalidateCall$(this._wrapCallModelResponse$(this._model.call([this._pathSequenceViewAdd], [sequenceKeys])), this._pathSequenceViewAdd, sequenceKeys);
21075 Object.defineProperty(APIv3.prototype, "clientId", {
21077 return this._clientId;
21082 APIv3.prototype._catchInvalidateGet$ = function (observable, path, paths) {
21084 return observable.pipe(operators_1.catchError(function (error) {
21085 _this._invalidateGet(path, paths);
21089 APIv3.prototype._catchInvalidateCall$ = function (observable, path, paths) {
21091 return observable.pipe(operators_1.catchError(function (error) {
21092 _this._invalidateCall(path, paths);
21096 APIv3.prototype._invalidateGet = function (path, paths) {
21097 this._model.invalidate([path, paths]);
21099 APIv3.prototype._invalidateCall = function (path, paths) {
21100 this._model.invalidate([path], [paths]);
21102 APIv3.prototype._wrapModelResponse$ = function (modelResponse) {
21103 return rxjs_1.Observable
21104 .create(function (subscriber) {
21106 .then(function (value) {
21107 subscriber.next(value);
21108 subscriber.complete();
21109 }, function (error) {
21110 subscriber.error(error);
21114 APIv3.prototype._wrapCallModelResponse$ = function (modelResponse) {
21115 return this._wrapModelResponse$(modelResponse).pipe(operators_1.map(function (value) {
21121 exports.APIv3 = APIv3;
21122 exports.default = APIv3;
21124 },{"../API":273,"rxjs":26,"rxjs/operators":224}],287:[function(require,module,exports){
21126 Object.defineProperty(exports, "__esModule", { value: true });
21127 var falcor = require("falcor");
21128 var falcor_http_datasource_1 = require("falcor-http-datasource");
21129 var Utils_1 = require("../Utils");
21131 * @class ModelCreator
21133 * @classdesc Creates API models.
21135 var ModelCreator = /** @class */ (function () {
21136 function ModelCreator() {
21139 * Creates a Falcor model.
21141 * @description Max cache size will be set to 16 MB. Authorization
21142 * header will be added if bearer token is supplied.
21144 * @param {number} clientId - Client id for API requests.
21145 * @param {number} [token] - Optional bearer token for API requests of
21146 * protected resources.
21147 * @returns {falcor.Model} Falcor model for HTTP requests.
21149 ModelCreator.prototype.createModel = function (clientId, token) {
21150 var configuration = {
21152 withCredentials: false,
21154 if (token != null) {
21155 configuration.headers = { "Authorization": "Bearer " + token };
21157 return new falcor.Model({
21158 maxSize: 16 * 1024 * 1024,
21159 source: new falcor_http_datasource_1.default(Utils_1.Urls.falcorModel(clientId), configuration),
21162 return ModelCreator;
21164 exports.ModelCreator = ModelCreator;
21165 exports.default = ModelCreator;
21167 },{"../Utils":284,"falcor":15,"falcor-http-datasource":10}],288:[function(require,module,exports){
21169 var __extends = (this && this.__extends) || (function () {
21170 var extendStatics = function (d, b) {
21171 extendStatics = Object.setPrototypeOf ||
21172 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21173 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21174 return extendStatics(d, b);
21176 return function (d, b) {
21177 extendStatics(d, b);
21178 function __() { this.constructor = d; }
21179 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21182 Object.defineProperty(exports, "__esModule", { value: true });
21183 var rxjs_1 = require("rxjs");
21184 var operators_1 = require("rxjs/operators");
21185 var vd = require("virtual-dom");
21186 var Component_1 = require("../Component");
21187 var Utils_1 = require("../Utils");
21188 var AttributionComponent = /** @class */ (function (_super) {
21189 __extends(AttributionComponent, _super);
21190 function AttributionComponent(name, container, navigator) {
21191 return _super.call(this, name, container, navigator) || this;
21193 AttributionComponent.prototype._activate = function () {
21195 this._disposable = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
21196 var node = _a[0], size = _a[1];
21199 vnode: _this._getAttributionNode(node.username, node.key, node.capturedAt, size.width),
21202 .subscribe(this._container.domRenderer.render$);
21204 AttributionComponent.prototype._deactivate = function () {
21205 this._disposable.unsubscribe();
21207 AttributionComponent.prototype._getDefaultConfiguration = function () {
21210 AttributionComponent.prototype._getAttributionNode = function (username, key, capturedAt, width) {
21211 var compact = width <= 640;
21212 var mapillaryIcon = vd.h("div.AttributionMapillaryLogo", []);
21213 var mapillaryLink = vd.h("a.AttributionIconContainer", { href: Utils_1.Urls.explore, target: "_blank" }, [mapillaryIcon]);
21214 var imageBy = compact ? "" + username : "image by " + username;
21215 var imageByContent = vd.h("div.AttributionUsername", { textContent: imageBy }, []);
21216 var date = new Date(capturedAt).toDateString().split(" ");
21217 var formatted = (date.length > 3 ?
21220 [date[1], date[2] + ",", date[3]] :
21222 var dateContent = vd.h("div.AttributionDate", { textContent: formatted }, []);
21223 var imageLink = vd.h("a.AttributionImageContainer", { href: Utils_1.Urls.exporeImage(key), target: "_blank" }, [imageByContent, dateContent]);
21224 var compactClass = compact ? ".AttributionCompact" : "";
21225 return vd.h("div.AttributionContainer" + compactClass, {}, [mapillaryLink, imageLink]);
21227 AttributionComponent.componentName = "attribution";
21228 return AttributionComponent;
21229 }(Component_1.Component));
21230 exports.AttributionComponent = AttributionComponent;
21231 Component_1.ComponentService.register(AttributionComponent);
21232 exports.default = AttributionComponent;
21234 },{"../Component":274,"../Utils":284,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],289:[function(require,module,exports){
21236 var __extends = (this && this.__extends) || (function () {
21237 var extendStatics = function (d, b) {
21238 extendStatics = Object.setPrototypeOf ||
21239 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21240 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21241 return extendStatics(d, b);
21243 return function (d, b) {
21244 extendStatics(d, b);
21245 function __() { this.constructor = d; }
21246 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21249 Object.defineProperty(exports, "__esModule", { value: true });
21250 var vd = require("virtual-dom");
21251 var Component_1 = require("../Component");
21252 var BackgroundComponent = /** @class */ (function (_super) {
21253 __extends(BackgroundComponent, _super);
21254 function BackgroundComponent(name, container, navigator) {
21255 return _super.call(this, name, container, navigator) || this;
21257 BackgroundComponent.prototype._activate = function () {
21258 this._container.domRenderer.render$
21259 .next({ name: this._name, vnode: this._getBackgroundNode("The viewer can't display the given image.") });
21261 BackgroundComponent.prototype._deactivate = function () {
21264 BackgroundComponent.prototype._getDefaultConfiguration = function () {
21267 BackgroundComponent.prototype._getBackgroundNode = function (notice) {
21268 // todo: add condition for when to display the DOM node
21269 return vd.h("div.BackgroundWrapper", {}, [
21270 vd.h("p", { textContent: notice }, []),
21273 BackgroundComponent.componentName = "background";
21274 return BackgroundComponent;
21275 }(Component_1.Component));
21276 exports.BackgroundComponent = BackgroundComponent;
21277 Component_1.ComponentService.register(BackgroundComponent);
21278 exports.default = BackgroundComponent;
21280 },{"../Component":274,"virtual-dom":230}],290:[function(require,module,exports){
21282 var __extends = (this && this.__extends) || (function () {
21283 var extendStatics = function (d, b) {
21284 extendStatics = Object.setPrototypeOf ||
21285 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21286 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21287 return extendStatics(d, b);
21289 return function (d, b) {
21290 extendStatics(d, b);
21291 function __() { this.constructor = d; }
21292 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21295 Object.defineProperty(exports, "__esModule", { value: true });
21296 var operators_1 = require("rxjs/operators");
21297 var vd = require("virtual-dom");
21298 var Component_1 = require("../Component");
21299 var Geo_1 = require("../Geo");
21300 var BearingComponent = /** @class */ (function (_super) {
21301 __extends(BearingComponent, _super);
21302 function BearingComponent(name, container, navigator) {
21303 var _this = _super.call(this, name, container, navigator) || this;
21304 _this._spatial = new Geo_1.Spatial();
21305 _this._svgNamespace = "http://www.w3.org/2000/svg";
21306 _this._distinctThreshold = Math.PI / 360;
21309 BearingComponent.prototype._activate = function () {
21311 var cameraBearingFov$ = this._container.renderService.renderCamera$.pipe(operators_1.map(function (rc) {
21312 var vFov = _this._spatial.degToRad(rc.perspective.fov);
21313 var hFov = rc.perspective.aspect === Number.POSITIVE_INFINITY ?
21315 Math.atan(rc.perspective.aspect * Math.tan(0.5 * vFov)) * 2;
21316 return [_this._spatial.azimuthalToBearing(rc.rotation.phi), hFov];
21317 }), operators_1.distinctUntilChanged(function (a1, a2) {
21318 return Math.abs(a2[0] - a1[0]) < _this._distinctThreshold &&
21319 Math.abs(a2[1] - a1[1]) < _this._distinctThreshold;
21321 this._renderSubscription = cameraBearingFov$.pipe(operators_1.map(function (_a) {
21322 var bearing = _a[0], fov = _a[1];
21323 var background = vd.h("div.BearingIndicatorBackground", {}, []);
21324 var backgroundCircle = vd.h("div.BearingIndicatorBackgroundCircle", {}, []);
21325 var north = _this._createNorth(bearing);
21326 var cameraSector = _this._createCircleSectorCompass(_this._createCircleSector(Math.max(Math.PI / 20, fov), "#FFF"));
21329 vnode: vd.h("div.BearingIndicatorContainer", { oncontextmenu: function (event) { event.preventDefault(); } }, [
21337 .subscribe(this._container.domRenderer.render$);
21339 BearingComponent.prototype._deactivate = function () {
21340 this._renderSubscription.unsubscribe();
21342 BearingComponent.prototype._getDefaultConfiguration = function () {
21345 BearingComponent.prototype._createCircleSectorCompass = function (cameraSector) {
21346 var group = vd.h("g", {
21347 attributes: { transform: "translate(1,1)" },
21348 namespace: this._svgNamespace,
21349 }, [cameraSector]);
21350 var svg = vd.h("svg", {
21351 attributes: { viewBox: "0 0 2 2" },
21352 namespace: this._svgNamespace,
21356 position: "absolute",
21363 BearingComponent.prototype._createCircleSector = function (fov, fill) {
21364 if (fov > 2 * Math.PI - Math.PI / 90) {
21365 return vd.h("circle", {
21366 attributes: { cx: "0", cy: "0", fill: fill, r: "1" },
21367 namespace: this._svgNamespace,
21370 var arcStart = -Math.PI / 2 - fov / 2;
21371 var arcEnd = arcStart + fov;
21372 var startX = Math.cos(arcStart);
21373 var startY = Math.sin(arcStart);
21374 var endX = Math.cos(arcEnd);
21375 var endY = Math.sin(arcEnd);
21376 var largeArc = fov >= Math.PI ? 1 : 0;
21377 var description = "M 0 0 " + startX + " " + startY + " A 1 1 0 " + largeArc + " 1 " + endX + " " + endY;
21378 return vd.h("path", {
21379 attributes: { d: description, fill: fill },
21380 namespace: this._svgNamespace,
21383 BearingComponent.prototype._createNorth = function (bearing) {
21384 var north = vd.h("div.BearingNorth", []);
21385 var container = vd.h("div.BearingNorthContainer", { style: { transform: "rotateZ(" + -bearing * 180 / Math.PI + "deg)" } }, [north]);
21388 BearingComponent.componentName = "bearing";
21389 return BearingComponent;
21390 }(Component_1.Component));
21391 exports.BearingComponent = BearingComponent;
21392 Component_1.ComponentService.register(BearingComponent);
21393 exports.default = BearingComponent;
21395 },{"../Component":274,"../Geo":277,"rxjs/operators":224,"virtual-dom":230}],291:[function(require,module,exports){
21397 var __extends = (this && this.__extends) || (function () {
21398 var extendStatics = function (d, b) {
21399 extendStatics = Object.setPrototypeOf ||
21400 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21401 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21402 return extendStatics(d, b);
21404 return function (d, b) {
21405 extendStatics(d, b);
21406 function __() { this.constructor = d; }
21407 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21410 Object.defineProperty(exports, "__esModule", { value: true });
21411 var rxjs_1 = require("rxjs");
21412 var operators_1 = require("rxjs/operators");
21413 var Edge_1 = require("../Edge");
21414 var Component_1 = require("../Component");
21415 var CacheComponent = /** @class */ (function (_super) {
21416 __extends(CacheComponent, _super);
21417 function CacheComponent(name, container, navigator) {
21418 return _super.call(this, name, container, navigator) || this;
21421 * Set the cache depth.
21423 * Configures the cache depth. The cache depth can be different for
21424 * different edge direction types.
21426 * @param {ICacheDepth} depth - Cache depth structure.
21428 CacheComponent.prototype.setDepth = function (depth) {
21429 this.configure({ depth: depth });
21431 CacheComponent.prototype._activate = function () {
21433 this._sequenceSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
21434 return node.sequenceEdges$;
21435 }), operators_1.filter(function (status) {
21436 return status.cached;
21437 })), this._configuration$).pipe(operators_1.switchMap(function (nc) {
21438 var status = nc[0];
21439 var configuration = nc[1];
21440 var sequenceDepth = Math.max(0, Math.min(4, configuration.depth.sequence));
21441 var next$ = _this._cache$(status.edges, Edge_1.EdgeDirection.Next, sequenceDepth);
21442 var prev$ = _this._cache$(status.edges, Edge_1.EdgeDirection.Prev, sequenceDepth);
21443 return rxjs_1.merge(next$, prev$).pipe(operators_1.catchError(function (error, caught) {
21444 console.error("Failed to cache sequence edges.", error);
21445 return rxjs_1.empty();
21448 .subscribe(function () { });
21449 this._spatialSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
21450 return rxjs_1.combineLatest(rxjs_1.of(node), node.spatialEdges$.pipe(operators_1.filter(function (status) {
21451 return status.cached;
21453 })), this._configuration$).pipe(operators_1.switchMap(function (_a) {
21454 var _b = _a[0], node = _b[0], edgeStatus = _b[1], configuration = _a[1];
21455 var edges = edgeStatus.edges;
21456 var depth = configuration.depth;
21457 var panoDepth = Math.max(0, Math.min(2, depth.pano));
21458 var stepDepth = node.pano ? 0 : Math.max(0, Math.min(3, depth.step));
21459 var turnDepth = node.pano ? 0 : Math.max(0, Math.min(1, depth.turn));
21460 var pano$ = _this._cache$(edges, Edge_1.EdgeDirection.Pano, panoDepth);
21461 var forward$ = _this._cache$(edges, Edge_1.EdgeDirection.StepForward, stepDepth);
21462 var backward$ = _this._cache$(edges, Edge_1.EdgeDirection.StepBackward, stepDepth);
21463 var left$ = _this._cache$(edges, Edge_1.EdgeDirection.StepLeft, stepDepth);
21464 var right$ = _this._cache$(edges, Edge_1.EdgeDirection.StepRight, stepDepth);
21465 var turnLeft$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnLeft, turnDepth);
21466 var turnRight$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnRight, turnDepth);
21467 var turnU$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnU, turnDepth);
21468 return rxjs_1.merge(forward$, backward$, left$, right$, pano$, turnLeft$, turnRight$, turnU$).pipe(operators_1.catchError(function (error, caught) {
21469 console.error("Failed to cache spatial edges.", error);
21470 return rxjs_1.empty();
21473 .subscribe(function () { });
21475 CacheComponent.prototype._deactivate = function () {
21476 this._sequenceSubscription.unsubscribe();
21477 this._spatialSubscription.unsubscribe();
21479 CacheComponent.prototype._getDefaultConfiguration = function () {
21480 return { depth: { pano: 1, sequence: 2, step: 1, turn: 0 } };
21482 CacheComponent.prototype._cache$ = function (edges, direction, depth) {
21484 return rxjs_1.zip(rxjs_1.of(edges), rxjs_1.of(depth)).pipe(operators_1.expand(function (ed) {
21487 var edgesDepths$ = [];
21489 for (var _i = 0, es_1 = es; _i < es_1.length; _i++) {
21490 var edge = es_1[_i];
21491 if (edge.data.direction === direction) {
21492 edgesDepths$.push(rxjs_1.zip(_this._navigator.graphService.cacheNode$(edge.to).pipe(operators_1.mergeMap(function (n) {
21493 return _this._nodeToEdges$(n, direction);
21494 })), rxjs_1.of(d - 1)));
21498 return rxjs_1.from(edgesDepths$).pipe(operators_1.mergeAll());
21499 }), operators_1.skip(1));
21501 CacheComponent.prototype._nodeToEdges$ = function (node, direction) {
21502 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
21503 node.sequenceEdges$ :
21504 node.spatialEdges$).pipe(operators_1.first(function (status) {
21505 return status.cached;
21506 }), operators_1.map(function (status) {
21507 return status.edges;
21510 CacheComponent.componentName = "cache";
21511 return CacheComponent;
21512 }(Component_1.Component));
21513 exports.CacheComponent = CacheComponent;
21514 Component_1.ComponentService.register(CacheComponent);
21515 exports.default = CacheComponent;
21517 },{"../Component":274,"../Edge":275,"rxjs":26,"rxjs/operators":224}],292:[function(require,module,exports){
21519 var __extends = (this && this.__extends) || (function () {
21520 var extendStatics = function (d, b) {
21521 extendStatics = Object.setPrototypeOf ||
21522 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21523 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21524 return extendStatics(d, b);
21526 return function (d, b) {
21527 extendStatics(d, b);
21528 function __() { this.constructor = d; }
21529 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21532 Object.defineProperty(exports, "__esModule", { value: true });
21533 var operators_1 = require("rxjs/operators");
21534 var rxjs_1 = require("rxjs");
21535 var Utils_1 = require("../Utils");
21536 var Component = /** @class */ (function (_super) {
21537 __extends(Component, _super);
21538 function Component(name, container, navigator) {
21539 var _this = _super.call(this) || this;
21540 _this._activated$ = new rxjs_1.BehaviorSubject(false);
21541 _this._configurationSubject$ = new rxjs_1.Subject();
21542 _this._activated = false;
21543 _this._container = container;
21544 _this._name = name;
21545 _this._navigator = navigator;
21546 _this._configuration$ =
21547 _this._configurationSubject$.pipe(operators_1.startWith(_this.defaultConfiguration), operators_1.scan(function (conf, newConf) {
21548 for (var key in newConf) {
21549 if (newConf.hasOwnProperty(key)) {
21550 conf[key] = newConf[key];
21554 }), operators_1.publishReplay(1), operators_1.refCount());
21555 _this._configuration$.subscribe(function () { });
21558 Object.defineProperty(Component.prototype, "activated", {
21560 return this._activated;
21565 Object.defineProperty(Component.prototype, "activated$", {
21568 return this._activated$;
21573 Object.defineProperty(Component.prototype, "defaultConfiguration", {
21575 * Get default configuration.
21577 * @returns {TConfiguration} Default configuration for component.
21580 return this._getDefaultConfiguration();
21585 Object.defineProperty(Component.prototype, "configuration$", {
21588 return this._configuration$;
21593 Object.defineProperty(Component.prototype, "name", {
21597 * @description The name of the component. Used when interacting with the
21598 * component through the Viewer's API.
21606 Component.prototype.activate = function (conf) {
21607 if (this._activated) {
21610 if (conf !== undefined) {
21611 this._configurationSubject$.next(conf);
21613 this._activated = true;
21615 this._activated$.next(true);
21617 Component.prototype.configure = function (conf) {
21618 this._configurationSubject$.next(conf);
21620 Component.prototype.deactivate = function () {
21621 if (!this._activated) {
21624 this._activated = false;
21625 this._deactivate();
21626 this._container.domRenderer.clear(this._name);
21627 this._container.glRenderer.clear(this._name);
21628 this._activated$.next(false);
21631 * Detect the viewer's new width and height and resize the component's
21632 * rendered elements accordingly if applicable.
21636 Component.prototype.resize = function () { return; };
21637 Component.componentName = "not_worthy";
21639 }(Utils_1.EventEmitter));
21640 exports.Component = Component;
21641 exports.default = Component;
21643 },{"../Utils":284,"rxjs":26,"rxjs/operators":224}],293:[function(require,module,exports){
21645 Object.defineProperty(exports, "__esModule", { value: true });
21646 var Error_1 = require("../Error");
21647 var ComponentService = /** @class */ (function () {
21648 function ComponentService(container, navigator) {
21649 this._components = {};
21650 for (var componentName in ComponentService.registeredComponents) {
21651 if (!ComponentService.registeredComponents.hasOwnProperty(componentName)) {
21654 var component = ComponentService.registeredComponents[componentName];
21655 this._components[componentName] = {
21657 component: new component(componentName, container, navigator),
21660 this._coverComponent = new ComponentService.registeredCoverComponent("cover", container, navigator);
21661 this._coverComponent.activate();
21662 this._coverActivated = true;
21664 ComponentService.register = function (component) {
21665 if (ComponentService.registeredComponents[component.componentName] === undefined) {
21666 ComponentService.registeredComponents[component.componentName] = component;
21669 ComponentService.registerCover = function (coverComponent) {
21670 ComponentService.registeredCoverComponent = coverComponent;
21672 Object.defineProperty(ComponentService.prototype, "coverActivated", {
21674 return this._coverActivated;
21679 ComponentService.prototype.activateCover = function () {
21680 if (this._coverActivated) {
21683 this._coverActivated = true;
21684 for (var componentName in this._components) {
21685 if (!this._components.hasOwnProperty(componentName)) {
21688 var component = this._components[componentName];
21689 if (component.active) {
21690 component.component.deactivate();
21694 ComponentService.prototype.deactivateCover = function () {
21695 if (!this._coverActivated) {
21698 this._coverActivated = false;
21699 for (var componentName in this._components) {
21700 if (!this._components.hasOwnProperty(componentName)) {
21703 var component = this._components[componentName];
21704 if (component.active) {
21705 component.component.activate();
21709 ComponentService.prototype.activate = function (name) {
21710 this._checkName(name);
21711 this._components[name].active = true;
21712 if (!this._coverActivated) {
21713 this.get(name).activate();
21716 ComponentService.prototype.configure = function (name, conf) {
21717 this._checkName(name);
21718 this.get(name).configure(conf);
21720 ComponentService.prototype.deactivate = function (name) {
21721 this._checkName(name);
21722 this._components[name].active = false;
21723 if (!this._coverActivated) {
21724 this.get(name).deactivate();
21727 ComponentService.prototype.resize = function () {
21728 for (var componentName in this._components) {
21729 if (!this._components.hasOwnProperty(componentName)) {
21732 var component = this._components[componentName];
21733 component.component.resize();
21736 ComponentService.prototype.get = function (name) {
21737 return this._components[name].component;
21739 ComponentService.prototype.getCover = function () {
21740 return this._coverComponent;
21742 ComponentService.prototype._checkName = function (name) {
21743 if (!(name in this._components)) {
21744 throw new Error_1.ArgumentMapillaryError("Component does not exist: " + name);
21747 ComponentService.registeredComponents = {};
21748 return ComponentService;
21750 exports.ComponentService = ComponentService;
21751 exports.default = ComponentService;
21753 },{"../Error":276}],294:[function(require,module,exports){
21755 var __extends = (this && this.__extends) || (function () {
21756 var extendStatics = function (d, b) {
21757 extendStatics = Object.setPrototypeOf ||
21758 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21759 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21760 return extendStatics(d, b);
21762 return function (d, b) {
21763 extendStatics(d, b);
21764 function __() { this.constructor = d; }
21765 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21768 Object.defineProperty(exports, "__esModule", { value: true });
21769 var rxjs_1 = require("rxjs");
21770 var operators_1 = require("rxjs/operators");
21771 var vd = require("virtual-dom");
21772 var Component_1 = require("../Component");
21773 var Utils_1 = require("../Utils");
21774 var Viewer_1 = require("../Viewer");
21775 var CoverComponent = /** @class */ (function (_super) {
21776 __extends(CoverComponent, _super);
21777 function CoverComponent(name, container, navigator) {
21778 return _super.call(this, name, container, navigator) || this;
21780 CoverComponent.prototype._activate = function () {
21782 this._configuration$.pipe(operators_1.distinctUntilChanged(undefined, function (configuration) {
21783 return configuration.state;
21784 }), operators_1.switchMap(function (configuration) {
21785 return rxjs_1.combineLatest(rxjs_1.of(configuration.state), _this._navigator.stateService.currentNode$);
21786 }), operators_1.switchMap(function (_a) {
21787 var state = _a[0], node = _a[1];
21788 var keySrc$ = rxjs_1.combineLatest(rxjs_1.of(node.key), node.image$.pipe(operators_1.filter(function (image) {
21790 }), operators_1.map(function (image) {
21793 return state === Component_1.CoverState.Visible ? keySrc$.pipe(operators_1.first()) : keySrc$;
21794 }), operators_1.distinctUntilChanged(function (_a, _b) {
21795 var k1 = _a[0], s1 = _a[1];
21796 var k2 = _b[0], s2 = _b[1];
21797 return k1 === k2 && s1 === s2;
21798 }), operators_1.map(function (_a) {
21799 var key = _a[0], src = _a[1];
21800 return { key: key, src: src };
21802 .subscribe(this._configurationSubject$);
21803 this._renderSubscription = rxjs_1.combineLatest(this._configuration$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
21804 var configuration = _a[0], size = _a[1];
21805 if (!configuration.key) {
21806 return { name: _this._name, vnode: vd.h("div", []) };
21808 var compactClass = size.width <= 640 || size.height <= 480 ? ".CoverCompact" : "";
21809 if (configuration.state === Component_1.CoverState.Hidden) {
21810 var doneContainer = vd.h("div.CoverContainer.CoverDone" + compactClass, [_this._getCoverBackgroundVNode(configuration)]);
21811 return { name: _this._name, vnode: doneContainer };
21813 var container = vd.h("div.CoverContainer" + compactClass, [_this._getCoverButtonVNode(configuration)]);
21814 return { name: _this._name, vnode: container };
21816 .subscribe(this._container.domRenderer.render$);
21818 CoverComponent.prototype._deactivate = function () {
21819 this._renderSubscription.unsubscribe();
21820 this._keySubscription.unsubscribe();
21822 CoverComponent.prototype._getDefaultConfiguration = function () {
21823 return { state: Component_1.CoverState.Visible };
21825 CoverComponent.prototype._getCoverButtonVNode = function (configuration) {
21827 var cover = configuration.state === Component_1.CoverState.Loading ? "div.Cover.CoverLoading" : "div.Cover";
21828 var coverButton = vd.h("div.CoverButton", { onclick: function () { _this.configure({ state: Component_1.CoverState.Loading }); } }, [vd.h("div.CoverButtonIcon", [])]);
21829 var coverLogo = vd.h("a.CoverLogo", { href: Utils_1.Urls.explore, target: "_blank" }, []);
21830 return vd.h(cover, [this._getCoverBackgroundVNode(configuration), coverButton, coverLogo]);
21832 CoverComponent.prototype._getCoverBackgroundVNode = function (conf) {
21833 var url = conf.src != null ?
21834 conf.src : Utils_1.Urls.thumbnail(conf.key, Viewer_1.ImageSize.Size640);
21835 var properties = { style: { backgroundImage: "url(" + url + ")" } };
21837 if (conf.state === Component_1.CoverState.Loading) {
21838 children.push(vd.h("div.Spinner", {}, []));
21840 return vd.h("div.CoverBackground", properties, children);
21842 CoverComponent.componentName = "cover";
21843 return CoverComponent;
21844 }(Component_1.Component));
21845 exports.CoverComponent = CoverComponent;
21846 Component_1.ComponentService.registerCover(CoverComponent);
21847 exports.default = CoverComponent;
21849 },{"../Component":274,"../Utils":284,"../Viewer":285,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],295:[function(require,module,exports){
21851 var __extends = (this && this.__extends) || (function () {
21852 var extendStatics = function (d, b) {
21853 extendStatics = Object.setPrototypeOf ||
21854 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21855 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21856 return extendStatics(d, b);
21858 return function (d, b) {
21859 extendStatics(d, b);
21860 function __() { this.constructor = d; }
21861 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21864 Object.defineProperty(exports, "__esModule", { value: true });
21865 var rxjs_1 = require("rxjs");
21866 var operators_1 = require("rxjs/operators");
21867 var vd = require("virtual-dom");
21868 var Component_1 = require("../Component");
21869 var DebugComponent = /** @class */ (function (_super) {
21870 __extends(DebugComponent, _super);
21871 function DebugComponent() {
21872 var _this = _super !== null && _super.apply(this, arguments) || this;
21873 _this._open$ = new rxjs_1.BehaviorSubject(false);
21876 DebugComponent.prototype._activate = function () {
21878 this._disposable = rxjs_1.combineLatest(this._navigator.stateService.currentState$, this._open$, this._navigator.imageLoadingService.loadstatus$).pipe(operators_1.map(function (_a) {
21879 var frame = _a[0], open = _a[1], loadStatus = _a[2];
21880 return { name: _this._name, vnode: _this._getDebugVNode(open, _this._getDebugInfo(frame, loadStatus)) };
21882 .subscribe(this._container.domRenderer.render$);
21884 DebugComponent.prototype._deactivate = function () {
21885 this._disposable.unsubscribe();
21887 DebugComponent.prototype._getDefaultConfiguration = function () {
21890 DebugComponent.prototype._getDebugInfo = function (frame, loadStatus) {
21892 ret.push(vd.h("h2", "Node"));
21893 if (frame.state.currentNode) {
21894 ret.push(vd.h("p", "currentNode: " + frame.state.currentNode.key));
21896 if (frame.state.previousNode) {
21897 ret.push(vd.h("p", "previousNode: " + frame.state.previousNode.key));
21899 ret.push(vd.h("h2", "Loading"));
21903 for (var key in loadStatus) {
21904 if (!loadStatus.hasOwnProperty(key)) {
21907 var status_1 = loadStatus[key];
21908 total += status_1.loaded;
21909 if (status_1.loaded !== status_1.total) {
21916 ret.push(vd.h("p", "Loaded Images: " + loaded));
21917 ret.push(vd.h("p", "Loading Images: " + loading));
21918 ret.push(vd.h("p", "Total bytes loaded: " + total));
21919 ret.push(vd.h("h2", "Camera"));
21920 ret.push(vd.h("p", "camera.position.x: " + frame.state.camera.position.x));
21921 ret.push(vd.h("p", "camera.position.y: " + frame.state.camera.position.y));
21922 ret.push(vd.h("p", "camera.position.z: " + frame.state.camera.position.z));
21923 ret.push(vd.h("p", "camera.lookat.x: " + frame.state.camera.lookat.x));
21924 ret.push(vd.h("p", "camera.lookat.y: " + frame.state.camera.lookat.y));
21925 ret.push(vd.h("p", "camera.lookat.z: " + frame.state.camera.lookat.z));
21926 ret.push(vd.h("p", "camera.up.x: " + frame.state.camera.up.x));
21927 ret.push(vd.h("p", "camera.up.y: " + frame.state.camera.up.y));
21928 ret.push(vd.h("p", "camera.up.z: " + frame.state.camera.up.z));
21931 DebugComponent.prototype._getDebugVNode = function (open, info) {
21933 return vd.h("div.Debug", {}, [
21934 vd.h("h2", {}, ["Debug"]),
21935 this._getDebugVNodeButton(open),
21936 vd.h("pre", {}, info),
21940 return this._getDebugVNodeButton(open);
21943 DebugComponent.prototype._getDebugVNodeButton = function (open) {
21944 var buttonText = open ? "Disable Debug" : "D";
21945 var buttonCssClass = open ? "" : ".DebugButtonFixed";
21947 return vd.h("button.DebugButton" + buttonCssClass, { onclick: this._closeDebugElement.bind(this) }, [buttonText]);
21950 return vd.h("button.DebugButton" + buttonCssClass, { onclick: this._openDebugElement.bind(this) }, [buttonText]);
21953 DebugComponent.prototype._closeDebugElement = function (open) {
21954 this._open$.next(false);
21956 DebugComponent.prototype._openDebugElement = function () {
21957 this._open$.next(true);
21959 DebugComponent.componentName = "debug";
21960 return DebugComponent;
21961 }(Component_1.Component));
21962 exports.DebugComponent = DebugComponent;
21963 Component_1.ComponentService.register(DebugComponent);
21964 exports.default = DebugComponent;
21966 },{"../Component":274,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],296:[function(require,module,exports){
21968 var __extends = (this && this.__extends) || (function () {
21969 var extendStatics = function (d, b) {
21970 extendStatics = Object.setPrototypeOf ||
21971 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21972 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21973 return extendStatics(d, b);
21975 return function (d, b) {
21976 extendStatics(d, b);
21977 function __() { this.constructor = d; }
21978 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21981 Object.defineProperty(exports, "__esModule", { value: true });
21982 var rxjs_1 = require("rxjs");
21983 var operators_1 = require("rxjs/operators");
21984 var vd = require("virtual-dom");
21985 var Component_1 = require("../Component");
21986 var Utils_1 = require("../Utils");
21987 var ImageComponent = /** @class */ (function (_super) {
21988 __extends(ImageComponent, _super);
21989 function ImageComponent(name, container, navigator, dom) {
21990 var _this = _super.call(this, name, container, navigator) || this;
21991 _this._canvasId = container.id + "-" + _this._name;
21992 _this._dom = !!dom ? dom : new Utils_1.DOM();
21995 ImageComponent.prototype._activate = function () {
21997 var canvasSize$ = this._container.domRenderer.element$.pipe(operators_1.map(function (element) {
21998 return _this._dom.document.getElementById(_this._canvasId);
21999 }), operators_1.filter(function (canvas) {
22001 }), operators_1.map(function (canvas) {
22002 var adaptableDomRenderer = canvas.parentElement;
22003 var width = adaptableDomRenderer.offsetWidth;
22004 var height = adaptableDomRenderer.offsetHeight;
22005 return [canvas, { height: height, width: width }];
22006 }), operators_1.distinctUntilChanged(function (s1, s2) {
22007 return s1.height === s2.height && s1.width === s2.width;
22009 var canvas = _a[0], size = _a[1];
22012 this.drawSubscription = rxjs_1.combineLatest(canvasSize$, this._navigator.stateService.currentNode$)
22013 .subscribe(function (_a) {
22014 var _b = _a[0], canvas = _b[0], size = _b[1], node = _a[1];
22015 canvas.width = size.width;
22016 canvas.height = size.height;
22019 .drawImage(node.image, 0, 0, size.width, size.height);
22021 this._container.domRenderer.renderAdaptive$.next({ name: this._name, vnode: vd.h("canvas#" + this._canvasId, []) });
22023 ImageComponent.prototype._deactivate = function () {
22024 this.drawSubscription.unsubscribe();
22026 ImageComponent.prototype._getDefaultConfiguration = function () {
22029 ImageComponent.componentName = "image";
22030 return ImageComponent;
22031 }(Component_1.Component));
22032 exports.ImageComponent = ImageComponent;
22033 Component_1.ComponentService.register(ImageComponent);
22034 exports.default = ImageComponent;
22037 },{"../Component":274,"../Utils":284,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],297:[function(require,module,exports){
22039 var __extends = (this && this.__extends) || (function () {
22040 var extendStatics = function (d, b) {
22041 extendStatics = Object.setPrototypeOf ||
22042 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22043 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22044 return extendStatics(d, b);
22046 return function (d, b) {
22047 extendStatics(d, b);
22048 function __() { this.constructor = d; }
22049 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22052 Object.defineProperty(exports, "__esModule", { value: true });
22053 var rxjs_1 = require("rxjs");
22054 var operators_1 = require("rxjs/operators");
22055 var vd = require("virtual-dom");
22056 var Component_1 = require("../Component");
22057 var LoadingComponent = /** @class */ (function (_super) {
22058 __extends(LoadingComponent, _super);
22059 function LoadingComponent(name, container, navigator) {
22060 return _super.call(this, name, container, navigator) || this;
22062 LoadingComponent.prototype._activate = function () {
22064 this._loadingSubscription = this._navigator.loadingService.loading$.pipe(operators_1.switchMap(function (loading) {
22066 _this._navigator.imageLoadingService.loadstatus$ :
22068 }), operators_1.map(function (loadStatus) {
22071 for (var key in loadStatus) {
22072 if (!loadStatus.hasOwnProperty(key)) {
22075 var status_1 = loadStatus[key];
22076 if (status_1.loaded !== status_1.total) {
22077 loaded += status_1.loaded;
22078 total += status_1.total;
22081 var percentage = 100;
22083 percentage = (loaded / total) * 100;
22085 return { name: _this._name, vnode: _this._getBarVNode(percentage) };
22087 .subscribe(this._container.domRenderer.render$);
22089 LoadingComponent.prototype._deactivate = function () {
22090 this._loadingSubscription.unsubscribe();
22092 LoadingComponent.prototype._getDefaultConfiguration = function () {
22095 LoadingComponent.prototype._getBarVNode = function (percentage) {
22096 var loadingBarStyle = {};
22097 var loadingContainerStyle = {};
22098 if (percentage !== 100) {
22099 loadingBarStyle.width = percentage.toFixed(0) + "%";
22100 loadingBarStyle.opacity = "1";
22103 loadingBarStyle.width = "100%";
22104 loadingBarStyle.opacity = "0";
22106 return vd.h("div.Loading", { style: loadingContainerStyle }, [vd.h("div.LoadingBar", { style: loadingBarStyle }, [])]);
22108 LoadingComponent.componentName = "loading";
22109 return LoadingComponent;
22110 }(Component_1.Component));
22111 exports.LoadingComponent = LoadingComponent;
22112 Component_1.ComponentService.register(LoadingComponent);
22113 exports.default = LoadingComponent;
22115 },{"../Component":274,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],298:[function(require,module,exports){
22117 var __extends = (this && this.__extends) || (function () {
22118 var extendStatics = function (d, b) {
22119 extendStatics = Object.setPrototypeOf ||
22120 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22121 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22122 return extendStatics(d, b);
22124 return function (d, b) {
22125 extendStatics(d, b);
22126 function __() { this.constructor = d; }
22127 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22130 Object.defineProperty(exports, "__esModule", { value: true });
22131 var rxjs_1 = require("rxjs");
22132 var operators_1 = require("rxjs/operators");
22133 var vd = require("virtual-dom");
22134 var Edge_1 = require("../Edge");
22135 var Error_1 = require("../Error");
22136 var Component_1 = require("../Component");
22138 * @class NavigationComponent
22140 * @classdesc Fallback navigation component for environments without WebGL support.
22142 * Replaces the functionality in the Direction and Sequence components.
22144 var NavigationComponent = /** @class */ (function (_super) {
22145 __extends(NavigationComponent, _super);
22147 function NavigationComponent(name, container, navigator) {
22148 var _this = _super.call(this, name, container, navigator) || this;
22149 _this._seqNames = {};
22150 _this._seqNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.Prev]] = "Prev";
22151 _this._seqNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.Next]] = "Next";
22152 _this._spaTopNames = {};
22153 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnLeft]] = "Turnleft";
22154 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepLeft]] = "Left";
22155 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepForward]] = "Forward";
22156 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepRight]] = "Right";
22157 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnRight]] = "Turnright";
22158 _this._spaBottomNames = {};
22159 _this._spaBottomNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnU]] = "Turnaround";
22160 _this._spaBottomNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepBackward]] = "Backward";
22163 NavigationComponent.prototype._activate = function () {
22165 this._renderSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, this._configuration$).pipe(operators_1.switchMap(function (_a) {
22166 var node = _a[0], configuration = _a[1];
22167 var sequenceEdges$ = configuration.sequence ?
22168 node.sequenceEdges$.pipe(operators_1.map(function (status) {
22169 return status.edges
22170 .map(function (edge) {
22171 return edge.data.direction;
22175 var spatialEdges$ = !node.pano && configuration.spatial ?
22176 node.spatialEdges$.pipe(operators_1.map(function (status) {
22177 return status.edges
22178 .map(function (edge) {
22179 return edge.data.direction;
22183 return rxjs_1.combineLatest(sequenceEdges$, spatialEdges$).pipe(operators_1.map(function (_a) {
22184 var seq = _a[0], spa = _a[1];
22185 return seq.concat(spa);
22187 }), operators_1.map(function (edgeDirections) {
22188 var seqs = _this._createArrowRow(_this._seqNames, edgeDirections);
22189 var spaTops = _this._createArrowRow(_this._spaTopNames, edgeDirections);
22190 var spaBottoms = _this._createArrowRow(_this._spaBottomNames, edgeDirections);
22191 var seqContainer = vd.h("div.NavigationSequence", seqs);
22192 var spaTopContainer = vd.h("div.NavigationSpatialTop", spaTops);
22193 var spaBottomContainer = vd.h("div.NavigationSpatialBottom", spaBottoms);
22194 var spaContainer = vd.h("div.NavigationSpatial", [spaTopContainer, spaBottomContainer]);
22195 return { name: _this._name, vnode: vd.h("div.NavigationContainer", [seqContainer, spaContainer]) };
22197 .subscribe(this._container.domRenderer.render$);
22199 NavigationComponent.prototype._deactivate = function () {
22200 this._renderSubscription.unsubscribe();
22202 NavigationComponent.prototype._getDefaultConfiguration = function () {
22203 return { sequence: true, spatial: true };
22205 NavigationComponent.prototype._createArrowRow = function (arrowNames, edgeDirections) {
22207 for (var arrowName in arrowNames) {
22208 if (!(arrowNames.hasOwnProperty(arrowName))) {
22211 var direction = Edge_1.EdgeDirection[arrowName];
22212 if (edgeDirections.indexOf(direction) !== -1) {
22213 arrows.push(this._createVNode(direction, arrowNames[arrowName], "visible"));
22216 arrows.push(this._createVNode(direction, arrowNames[arrowName], "hidden"));
22221 NavigationComponent.prototype._createVNode = function (direction, name, visibility) {
22223 return vd.h("span.Direction.Direction" + name, {
22224 onclick: function (ev) {
22225 _this._navigator.moveDir$(direction)
22226 .subscribe(undefined, function (error) {
22227 if (!(error instanceof Error_1.AbortMapillaryError)) {
22228 console.error(error);
22233 visibility: visibility,
22237 NavigationComponent.componentName = "navigation";
22238 return NavigationComponent;
22239 }(Component_1.Component));
22240 exports.NavigationComponent = NavigationComponent;
22241 Component_1.ComponentService.register(NavigationComponent);
22242 exports.default = NavigationComponent;
22244 },{"../Component":274,"../Edge":275,"../Error":276,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],299:[function(require,module,exports){
22246 var __extends = (this && this.__extends) || (function () {
22247 var extendStatics = function (d, b) {
22248 extendStatics = Object.setPrototypeOf ||
22249 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22250 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22251 return extendStatics(d, b);
22253 return function (d, b) {
22254 extendStatics(d, b);
22255 function __() { this.constructor = d; }
22256 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22259 Object.defineProperty(exports, "__esModule", { value: true });
22260 var rxjs_1 = require("rxjs");
22261 var operators_1 = require("rxjs/operators");
22262 var vd = require("virtual-dom");
22263 var Component_1 = require("../Component");
22264 var DescriptionState = /** @class */ (function () {
22265 function DescriptionState() {
22267 return DescriptionState;
22269 var RouteState = /** @class */ (function () {
22270 function RouteState() {
22274 var RouteTrack = /** @class */ (function () {
22275 function RouteTrack() {
22276 this.nodeInstructions = [];
22277 this.nodeInstructionsOrdered = [];
22281 var RouteComponent = /** @class */ (function (_super) {
22282 __extends(RouteComponent, _super);
22283 function RouteComponent(name, container, navigator) {
22284 return _super.call(this, name, container, navigator) || this;
22286 RouteComponent.prototype._activate = function () {
22288 var slowedStream$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
22289 return (frame.id % 2) === 0;
22290 }), operators_1.filter(function (frame) {
22291 return frame.state.nodesAhead < 15;
22292 }), operators_1.distinctUntilChanged(undefined, function (frame) {
22293 return frame.state.lastNode.key;
22295 var routeTrack$ = rxjs_1.combineLatest(this.configuration$.pipe(operators_1.mergeMap(function (conf) {
22296 return rxjs_1.from(conf.paths);
22297 }), operators_1.distinct(function (p) {
22298 return p.sequenceKey;
22299 }), operators_1.mergeMap(function (path) {
22300 return _this._navigator.apiV3.sequenceByKey$([path.sequenceKey]).pipe(operators_1.map(function (sequenceByKey) {
22301 return sequenceByKey[path.sequenceKey];
22303 })), this.configuration$).pipe(operators_1.map(function (_a) {
22304 var sequence = _a[0], conf = _a[1];
22306 var instructionPlaces = [];
22307 for (var _i = 0, _b = conf.paths; _i < _b.length; _i++) {
22309 if (path.sequenceKey === sequence.key) {
22310 var nodeInstructions = [];
22311 var saveKey = false;
22312 for (var _c = 0, _d = sequence.keys; _c < _d.length; _c++) {
22314 if (path.startKey === key) {
22318 var description = null;
22319 for (var _e = 0, _f = path.infoKeys; _e < _f.length; _e++) {
22320 var infoKey = _f[_e];
22321 if (infoKey.key === key) {
22322 description = infoKey.description;
22325 nodeInstructions.push({ description: description, key: key });
22327 if (path.stopKey === key) {
22331 instructionPlaces.push({ nodeInstructions: nodeInstructions, place: i });
22335 return instructionPlaces;
22336 }), operators_1.scan(function (routeTrack, instructionPlaces) {
22337 for (var _i = 0, instructionPlaces_1 = instructionPlaces; _i < instructionPlaces_1.length; _i++) {
22338 var instructionPlace = instructionPlaces_1[_i];
22339 routeTrack.nodeInstructionsOrdered[instructionPlace.place] = instructionPlace.nodeInstructions;
22341 for (var place in routeTrack.nodeInstructionsOrdered) {
22342 if (!routeTrack.nodeInstructionsOrdered.hasOwnProperty(place)) {
22345 var instructionGroup = routeTrack.nodeInstructionsOrdered[place];
22346 for (var _a = 0, instructionGroup_1 = instructionGroup; _a < instructionGroup_1.length; _a++) {
22347 var instruction = instructionGroup_1[_a];
22348 routeTrack.nodeInstructions.push(instruction);
22352 }, new RouteTrack()));
22353 var cacheNode$ = rxjs_1.combineLatest(slowedStream$, routeTrack$, this.configuration$).pipe(operators_1.map(function (_a) {
22354 var frame = _a[0], routeTrack = _a[1], conf = _a[2];
22355 return { conf: conf, frame: frame, routeTrack: routeTrack };
22356 }), operators_1.scan(function (routeState, rtAndFrame) {
22357 if (rtAndFrame.conf.playing === undefined || rtAndFrame.conf.playing) {
22358 routeState.routeTrack = rtAndFrame.routeTrack;
22359 routeState.currentNode = rtAndFrame.frame.state.currentNode;
22360 routeState.lastNode = rtAndFrame.frame.state.lastNode;
22361 routeState.playing = true;
22364 _this._navigator.stateService.cutNodes();
22365 routeState.playing = false;
22368 }, new RouteState()), operators_1.filter(function (routeState) {
22369 return routeState.playing;
22370 }), operators_1.filter(function (routeState) {
22371 for (var _i = 0, _a = routeState.routeTrack.nodeInstructions; _i < _a.length; _i++) {
22372 var nodeInstruction = _a[_i];
22373 if (!nodeInstruction) {
22376 if (nodeInstruction.key === routeState.lastNode.key) {
22381 }), operators_1.distinctUntilChanged(undefined, function (routeState) {
22382 return routeState.lastNode.key;
22383 }), operators_1.mergeMap(function (routeState) {
22385 for (var _i = 0, _a = routeState.routeTrack.nodeInstructions; _i < _a.length; _i++) {
22386 var nodeInstruction = _a[_i];
22387 if (nodeInstruction.key === routeState.lastNode.key) {
22392 var nextInstruction = routeState.routeTrack.nodeInstructions[i + 1];
22393 if (!nextInstruction) {
22394 return rxjs_1.of(null);
22396 return _this._navigator.graphService.cacheNode$(nextInstruction.key);
22398 this._disposable = rxjs_1.combineLatest(cacheNode$, this.configuration$).pipe(operators_1.map(function (_a) {
22399 var node = _a[0], conf = _a[1];
22400 return { conf: conf, node: node };
22401 }), operators_1.filter(function (cAN) {
22402 return cAN.node !== null && cAN.conf.playing;
22403 }), operators_1.pluck("node"))
22404 .subscribe(this._navigator.stateService.appendNode$);
22405 this._disposableDescription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, routeTrack$, this.configuration$).pipe(operators_1.map(function (_a) {
22406 var node = _a[0], routeTrack = _a[1], conf = _a[2];
22407 if (conf.playing !== undefined && !conf.playing) {
22410 var description = null;
22411 for (var _i = 0, _b = routeTrack.nodeInstructions; _i < _b.length; _i++) {
22412 var nodeInstruction = _b[_i];
22413 if (nodeInstruction.key === node.key) {
22414 description = nodeInstruction.description;
22418 return description;
22419 }), operators_1.scan(function (descriptionState, description) {
22420 if (description !== descriptionState.description && description !== null) {
22421 descriptionState.description = description;
22422 descriptionState.showsLeft = 6;
22425 descriptionState.showsLeft--;
22427 if (description === "quit") {
22428 descriptionState.description = null;
22430 return descriptionState;
22431 }, new DescriptionState()), operators_1.map(function (descriptionState) {
22432 if (descriptionState.showsLeft > 0 && descriptionState.description) {
22433 return { name: _this._name, vnode: _this._getRouteAnnotationNode(descriptionState.description) };
22436 return { name: _this._name, vnode: vd.h("div", []) };
22439 .subscribe(this._container.domRenderer.render$);
22441 RouteComponent.prototype._deactivate = function () {
22442 this._disposable.unsubscribe();
22443 this._disposableDescription.unsubscribe();
22445 RouteComponent.prototype._getDefaultConfiguration = function () {
22448 RouteComponent.prototype.play = function () {
22449 this.configure({ playing: true });
22451 RouteComponent.prototype.stop = function () {
22452 this.configure({ playing: false });
22454 RouteComponent.prototype._getRouteAnnotationNode = function (description) {
22455 return vd.h("div.RouteFrame", {}, [
22456 vd.h("p", { textContent: description }, []),
22459 RouteComponent.componentName = "route";
22460 return RouteComponent;
22461 }(Component_1.Component));
22462 exports.RouteComponent = RouteComponent;
22463 Component_1.ComponentService.register(RouteComponent);
22464 exports.default = RouteComponent;
22466 },{"../Component":274,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],300:[function(require,module,exports){
22468 var __extends = (this && this.__extends) || (function () {
22469 var extendStatics = function (d, b) {
22470 extendStatics = Object.setPrototypeOf ||
22471 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22472 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22473 return extendStatics(d, b);
22475 return function (d, b) {
22476 extendStatics(d, b);
22477 function __() { this.constructor = d; }
22478 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22481 Object.defineProperty(exports, "__esModule", { value: true });
22482 var rxjs_1 = require("rxjs");
22483 var operators_1 = require("rxjs/operators");
22484 var Component_1 = require("../Component");
22485 var StatsComponent = /** @class */ (function (_super) {
22486 __extends(StatsComponent, _super);
22487 function StatsComponent(name, container, navigator, scheduler) {
22488 var _this = _super.call(this, name, container, navigator) || this;
22489 _this._scheduler = scheduler;
22492 StatsComponent.prototype._activate = function () {
22494 this._sequenceSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.scan(function (keys, node) {
22495 var sKey = node.sequenceKey;
22497 if (!(sKey in keys.reported)) {
22498 keys.report = [sKey];
22499 keys.reported[sKey] = true;
22502 }, { report: [], reported: {} }), operators_1.filter(function (keys) {
22503 return keys.report.length > 0;
22504 }), operators_1.mergeMap(function (keys) {
22505 return _this._navigator.apiV3.sequenceViewAdd$(keys.report).pipe(operators_1.catchError(function (error, caught) {
22506 console.error("Failed to report sequence stats (" + keys.report + ")", error);
22507 return rxjs_1.empty();
22510 .subscribe(function () { });
22511 this._imageSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
22513 })).pipe(operators_1.buffer(this._navigator.stateService.currentNode$.pipe(operators_1.debounceTime(5000, this._scheduler))), operators_1.scan(function (keys, newKeys) {
22515 for (var _i = 0, newKeys_1 = newKeys; _i < newKeys_1.length; _i++) {
22516 var key = newKeys_1[_i];
22517 if (!(key in keys.reported)) {
22518 keys.report.push(key);
22519 keys.reported[key] = true;
22523 }, { report: [], reported: {} }), operators_1.filter(function (keys) {
22524 return keys.report.length > 0;
22525 }), operators_1.mergeMap(function (keys) {
22526 return _this._navigator.apiV3.imageViewAdd$(keys.report).pipe(operators_1.catchError(function (error, caught) {
22527 console.error("Failed to report image stats (" + keys.report + ")", error);
22528 return rxjs_1.empty();
22531 .subscribe(function () { });
22533 StatsComponent.prototype._deactivate = function () {
22534 this._sequenceSubscription.unsubscribe();
22535 this._imageSubscription.unsubscribe();
22537 StatsComponent.prototype._getDefaultConfiguration = function () {
22540 StatsComponent.componentName = "stats";
22541 return StatsComponent;
22542 }(Component_1.Component));
22543 exports.StatsComponent = StatsComponent;
22544 Component_1.ComponentService.register(StatsComponent);
22545 exports.default = StatsComponent;
22547 },{"../Component":274,"rxjs":26,"rxjs/operators":224}],301:[function(require,module,exports){
22549 var __extends = (this && this.__extends) || (function () {
22550 var extendStatics = function (d, b) {
22551 extendStatics = Object.setPrototypeOf ||
22552 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22553 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22554 return extendStatics(d, b);
22556 return function (d, b) {
22557 extendStatics(d, b);
22558 function __() { this.constructor = d; }
22559 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22562 Object.defineProperty(exports, "__esModule", { value: true });
22563 var rxjs_1 = require("rxjs");
22564 var operators_1 = require("rxjs/operators");
22565 var vd = require("virtual-dom");
22566 var Component_1 = require("../../Component");
22568 * @class DirectionComponent
22569 * @classdesc Component showing navigation arrows for steps and turns.
22571 var DirectionComponent = /** @class */ (function (_super) {
22572 __extends(DirectionComponent, _super);
22573 function DirectionComponent(name, container, navigator, directionDOMRenderer) {
22574 var _this = _super.call(this, name, container, navigator) || this;
22575 _this._renderer = !!directionDOMRenderer ?
22576 directionDOMRenderer :
22577 new Component_1.DirectionDOMRenderer(_this.defaultConfiguration, container.element);
22578 _this._hoveredKeySubject$ = new rxjs_1.Subject();
22579 _this._hoveredKey$ = _this._hoveredKeySubject$.pipe(operators_1.share());
22582 Object.defineProperty(DirectionComponent.prototype, "hoveredKey$", {
22584 * Get hovered key observable.
22586 * @description An observable emitting the key of the node for the direction
22587 * arrow that is being hovered. When the mouse leaves a direction arrow null
22590 * @returns {Observable<string>}
22593 return this._hoveredKey$;
22599 * Set highlight key.
22601 * @description The arrow pointing towards the node corresponding to the
22602 * highlight key will be highlighted.
22604 * @param {string} highlightKey Key of node to be highlighted if existing
22607 DirectionComponent.prototype.setHighlightKey = function (highlightKey) {
22608 this.configure({ highlightKey: highlightKey });
22611 * Set min width of container element.
22613 * @description Set min width of the non transformed container element holding
22614 * the navigation arrows. If the min width is larger than the max width the
22615 * min width value will be used.
22617 * The container element is automatically resized when the resize
22618 * method on the Viewer class is called.
22620 * @param {number} minWidth
22622 DirectionComponent.prototype.setMinWidth = function (minWidth) {
22623 this.configure({ minWidth: minWidth });
22626 * Set max width of container element.
22628 * @description Set max width of the non transformed container element holding
22629 * the navigation arrows. If the min width is larger than the max width the
22630 * min width value will be used.
22632 * The container element is automatically resized when the resize
22633 * method on the Viewer class is called.
22635 * @param {number} minWidth
22637 DirectionComponent.prototype.setMaxWidth = function (maxWidth) {
22638 this.configure({ maxWidth: maxWidth });
22641 DirectionComponent.prototype.resize = function () {
22642 this._renderer.resize(this._container.element);
22644 DirectionComponent.prototype._activate = function () {
22646 this._configurationSubscription = this._configuration$
22647 .subscribe(function (configuration) {
22648 _this._renderer.setConfiguration(configuration);
22650 this._nodeSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.tap(function (node) {
22651 _this._container.domRenderer.render$.next({ name: _this._name, vnode: vd.h("div", {}, []) });
22652 _this._renderer.setNode(node);
22653 }), operators_1.withLatestFrom(this._configuration$), operators_1.switchMap(function (_a) {
22654 var node = _a[0], configuration = _a[1];
22655 return rxjs_1.combineLatest(node.spatialEdges$, configuration.distinguishSequence ?
22656 _this._navigator.graphService
22657 .cacheSequence$(node.sequenceKey).pipe(operators_1.catchError(function (error, caught) {
22658 console.error("Failed to cache sequence (" + node.sequenceKey + ")", error);
22659 return rxjs_1.of(null);
22663 .subscribe(function (_a) {
22664 var edgeStatus = _a[0], sequence = _a[1];
22665 _this._renderer.setEdges(edgeStatus, sequence);
22667 this._renderCameraSubscription = this._container.renderService.renderCameraFrame$.pipe(operators_1.tap(function (renderCamera) {
22668 _this._renderer.setRenderCamera(renderCamera);
22669 }), operators_1.map(function () {
22670 return _this._renderer;
22671 }), operators_1.filter(function (renderer) {
22672 return renderer.needsRender;
22673 }), operators_1.map(function (renderer) {
22674 return { name: _this._name, vnode: renderer.render(_this._navigator) };
22676 .subscribe(this._container.domRenderer.render$);
22677 this._hoveredKeySubscription = rxjs_1.combineLatest(this._container.domRenderer.element$, this._container.renderService.renderCamera$, this._container.mouseService.mouseMove$.pipe(operators_1.startWith(null)), this._container.mouseService.mouseUp$.pipe(operators_1.startWith(null))).pipe(operators_1.map(function (_a) {
22678 var element = _a[0];
22679 var elements = element.getElementsByClassName("DirectionsPerspective");
22680 for (var i = 0; i < elements.length; i++) {
22681 var hovered = elements.item(i).querySelector(":hover");
22682 if (hovered != null && hovered.hasAttribute("data-key")) {
22683 return hovered.getAttribute("data-key");
22687 }), operators_1.distinctUntilChanged())
22688 .subscribe(this._hoveredKeySubject$);
22689 this._emitHoveredKeySubscription = this._hoveredKey$
22690 .subscribe(function (key) {
22691 _this.fire(DirectionComponent.hoveredkeychanged, key);
22694 DirectionComponent.prototype._deactivate = function () {
22695 this._configurationSubscription.unsubscribe();
22696 this._emitHoveredKeySubscription.unsubscribe();
22697 this._hoveredKeySubscription.unsubscribe();
22698 this._nodeSubscription.unsubscribe();
22699 this._renderCameraSubscription.unsubscribe();
22701 DirectionComponent.prototype._getDefaultConfiguration = function () {
22703 distinguishSequence: false,
22709 DirectionComponent.componentName = "direction";
22711 * Event fired when the hovered key changes.
22713 * @description Emits the key of the node for the direction
22714 * arrow that is being hovered. When the mouse leaves a
22715 * direction arrow null is emitted.
22717 * @event DirectionComponent#hoveredkeychanged
22718 * @type {string} The hovered key, null if no key is hovered.
22720 DirectionComponent.hoveredkeychanged = "hoveredkeychanged";
22721 return DirectionComponent;
22722 }(Component_1.Component));
22723 exports.DirectionComponent = DirectionComponent;
22724 Component_1.ComponentService.register(DirectionComponent);
22725 exports.default = DirectionComponent;
22727 },{"../../Component":274,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],302:[function(require,module,exports){
22729 Object.defineProperty(exports, "__esModule", { value: true });
22730 var Geo_1 = require("../../Geo");
22732 * @class DirectionDOMCalculator
22733 * @classdesc Helper class for calculating DOM CSS properties.
22735 var DirectionDOMCalculator = /** @class */ (function () {
22736 function DirectionDOMCalculator(configuration, element) {
22737 this._spatial = new Geo_1.Spatial();
22738 this._minThresholdWidth = 320;
22739 this._maxThresholdWidth = 1480;
22740 this._minThresholdHeight = 240;
22741 this._maxThresholdHeight = 820;
22742 this._configure(configuration);
22743 this._resize(element);
22746 Object.defineProperty(DirectionDOMCalculator.prototype, "minWidth", {
22748 return this._minWidth;
22753 Object.defineProperty(DirectionDOMCalculator.prototype, "maxWidth", {
22755 return this._maxWidth;
22760 Object.defineProperty(DirectionDOMCalculator.prototype, "containerWidth", {
22762 return this._containerWidth;
22767 Object.defineProperty(DirectionDOMCalculator.prototype, "containerWidthCss", {
22769 return this._containerWidthCss;
22774 Object.defineProperty(DirectionDOMCalculator.prototype, "containerMarginCss", {
22776 return this._containerMarginCss;
22781 Object.defineProperty(DirectionDOMCalculator.prototype, "containerLeftCss", {
22783 return this._containerLeftCss;
22788 Object.defineProperty(DirectionDOMCalculator.prototype, "containerHeight", {
22790 return this._containerHeight;
22795 Object.defineProperty(DirectionDOMCalculator.prototype, "containerHeightCss", {
22797 return this._containerHeightCss;
22802 Object.defineProperty(DirectionDOMCalculator.prototype, "containerBottomCss", {
22804 return this._containerBottomCss;
22809 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleSize", {
22811 return this._stepCircleSize;
22816 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleSizeCss", {
22818 return this._stepCircleSizeCss;
22823 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleMarginCss", {
22825 return this._stepCircleMarginCss;
22830 Object.defineProperty(DirectionDOMCalculator.prototype, "turnCircleSize", {
22832 return this._turnCircleSize;
22837 Object.defineProperty(DirectionDOMCalculator.prototype, "turnCircleSizeCss", {
22839 return this._turnCircleSizeCss;
22844 Object.defineProperty(DirectionDOMCalculator.prototype, "outerRadius", {
22846 return this._outerRadius;
22851 Object.defineProperty(DirectionDOMCalculator.prototype, "innerRadius", {
22853 return this._innerRadius;
22858 Object.defineProperty(DirectionDOMCalculator.prototype, "shadowOffset", {
22860 return this._shadowOffset;
22866 * Configures the min and max width values.
22868 * @param {IDirectionConfiguration} configuration Configuration
22869 * with min and max width values.
22871 DirectionDOMCalculator.prototype.configure = function (configuration) {
22872 this._configure(configuration);
22876 * Resizes all properties according to the width and height
22879 * @param {HTMLElement} element The container element from which to extract
22880 * the width and height.
22882 DirectionDOMCalculator.prototype.resize = function (element) {
22883 this._resize(element);
22887 * Calculates the coordinates on the unit circle for an angle.
22889 * @param {number} angle Angle in radians.
22890 * @returns {Array<number>} The x and y coordinates on the unit circle.
22892 DirectionDOMCalculator.prototype.angleToCoordinates = function (angle) {
22893 return [Math.cos(angle), Math.sin(angle)];
22896 * Calculates the coordinates on the unit circle for the
22897 * relative angle between the first and second angle.
22899 * @param {number} first Angle in radians.
22900 * @param {number} second Angle in radians.
22901 * @returns {Array<number>} The x and y coordinates on the unit circle
22902 * for the relative angle between the first and second angle.
22904 DirectionDOMCalculator.prototype.relativeAngleToCoordiantes = function (first, second) {
22905 var relativeAngle = this._spatial.wrapAngle(first - second);
22906 return this.angleToCoordinates(relativeAngle);
22908 DirectionDOMCalculator.prototype._configure = function (configuration) {
22909 this._minWidth = configuration.minWidth;
22910 this._maxWidth = this._getMaxWidth(configuration.minWidth, configuration.maxWidth);
22912 DirectionDOMCalculator.prototype._resize = function (element) {
22913 this._elementWidth = element.offsetWidth;
22914 this._elementHeight = element.offsetHeight;
22916 DirectionDOMCalculator.prototype._reset = function () {
22917 this._containerWidth = this._getContainerWidth(this._elementWidth, this._elementHeight);
22918 this._containerHeight = this._getContainerHeight(this.containerWidth);
22919 this._stepCircleSize = this._getStepCircleDiameter(this._containerHeight);
22920 this._turnCircleSize = this._getTurnCircleDiameter(this.containerHeight);
22921 this._outerRadius = this._getOuterRadius(this._containerHeight);
22922 this._innerRadius = this._getInnerRadius(this._containerHeight);
22923 this._shadowOffset = 3;
22924 this._containerWidthCss = this._numberToCssPixels(this._containerWidth);
22925 this._containerMarginCss = this._numberToCssPixels(-0.5 * this._containerWidth);
22926 this._containerLeftCss = this._numberToCssPixels(Math.floor(0.5 * this._elementWidth));
22927 this._containerHeightCss = this._numberToCssPixels(this._containerHeight);
22928 this._containerBottomCss = this._numberToCssPixels(Math.floor(-0.08 * this._containerHeight));
22929 this._stepCircleSizeCss = this._numberToCssPixels(this._stepCircleSize);
22930 this._stepCircleMarginCss = this._numberToCssPixels(-0.5 * this._stepCircleSize);
22931 this._turnCircleSizeCss = this._numberToCssPixels(this._turnCircleSize);
22933 DirectionDOMCalculator.prototype._getContainerWidth = function (elementWidth, elementHeight) {
22934 var relativeWidth = (elementWidth - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth);
22935 var relativeHeight = (elementHeight - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight);
22936 var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight)));
22937 coeff = 0.04 * Math.round(25 * coeff);
22938 return this._minWidth + coeff * (this._maxWidth - this._minWidth);
22940 DirectionDOMCalculator.prototype._getContainerHeight = function (containerWidth) {
22941 return 0.77 * containerWidth;
22943 DirectionDOMCalculator.prototype._getStepCircleDiameter = function (containerHeight) {
22944 return 0.34 * containerHeight;
22946 DirectionDOMCalculator.prototype._getTurnCircleDiameter = function (containerHeight) {
22947 return 0.3 * containerHeight;
22949 DirectionDOMCalculator.prototype._getOuterRadius = function (containerHeight) {
22950 return 0.31 * containerHeight;
22952 DirectionDOMCalculator.prototype._getInnerRadius = function (containerHeight) {
22953 return 0.125 * containerHeight;
22955 DirectionDOMCalculator.prototype._numberToCssPixels = function (value) {
22956 return value + "px";
22958 DirectionDOMCalculator.prototype._getMaxWidth = function (value, minWidth) {
22959 return value > minWidth ? value : minWidth;
22961 return DirectionDOMCalculator;
22963 exports.DirectionDOMCalculator = DirectionDOMCalculator;
22964 exports.default = DirectionDOMCalculator;
22967 },{"../../Geo":277}],303:[function(require,module,exports){
22969 Object.defineProperty(exports, "__esModule", { value: true });
22970 var vd = require("virtual-dom");
22971 var Component_1 = require("../../Component");
22972 var Edge_1 = require("../../Edge");
22973 var Error_1 = require("../../Error");
22974 var Geo_1 = require("../../Geo");
22976 * @class DirectionDOMRenderer
22977 * @classdesc DOM renderer for direction arrows.
22979 var DirectionDOMRenderer = /** @class */ (function () {
22980 function DirectionDOMRenderer(configuration, element) {
22981 this._isEdge = false;
22982 this._spatial = new Geo_1.Spatial();
22983 this._calculator = new Component_1.DirectionDOMCalculator(configuration, element);
22985 this._rotation = { phi: 0, theta: 0 };
22986 this._epsilon = 0.5 * Math.PI / 180;
22987 this._highlightKey = null;
22988 this._distinguishSequence = false;
22989 this._needsRender = false;
22990 this._stepEdges = [];
22991 this._turnEdges = [];
22992 this._panoEdges = [];
22993 this._sequenceEdgeKeys = [];
22994 this._stepDirections = [
22995 Edge_1.EdgeDirection.StepForward,
22996 Edge_1.EdgeDirection.StepBackward,
22997 Edge_1.EdgeDirection.StepLeft,
22998 Edge_1.EdgeDirection.StepRight,
23000 this._turnDirections = [
23001 Edge_1.EdgeDirection.TurnLeft,
23002 Edge_1.EdgeDirection.TurnRight,
23003 Edge_1.EdgeDirection.TurnU,
23005 this._turnNames = {};
23006 this._turnNames[Edge_1.EdgeDirection.TurnLeft] = "TurnLeft";
23007 this._turnNames[Edge_1.EdgeDirection.TurnRight] = "TurnRight";
23008 this._turnNames[Edge_1.EdgeDirection.TurnU] = "TurnAround";
23009 // detects IE 8-11, then Edge 20+.
23010 var isIE = !!document.documentMode;
23011 this._isEdge = !isIE && !!window.StyleMedia;
23013 Object.defineProperty(DirectionDOMRenderer.prototype, "needsRender", {
23015 * Get needs render.
23017 * @returns {boolean} Value indicating whether render should be called.
23020 return this._needsRender;
23026 * Renders virtual DOM elements.
23028 * @description Calling render resets the needs render property.
23030 DirectionDOMRenderer.prototype.render = function (navigator) {
23031 this._needsRender = false;
23032 var rotation = this._rotation;
23035 if (this._node.pano) {
23036 steps = steps.concat(this._createPanoArrows(navigator, rotation));
23039 steps = steps.concat(this._createPerspectiveToPanoArrows(navigator, rotation));
23040 steps = steps.concat(this._createStepArrows(navigator, rotation));
23041 turns = turns.concat(this._createTurnArrows(navigator));
23043 return this._getContainer(steps, turns, rotation);
23045 DirectionDOMRenderer.prototype.setEdges = function (edgeStatus, sequence) {
23046 this._setEdges(edgeStatus, sequence);
23047 this._setNeedsRender();
23050 * Set node for which to show edges.
23052 * @param {Node} node
23054 DirectionDOMRenderer.prototype.setNode = function (node) {
23056 this._clearEdges();
23057 this._setNeedsRender();
23060 * Set the render camera to use for calculating rotations.
23062 * @param {RenderCamera} renderCamera
23064 DirectionDOMRenderer.prototype.setRenderCamera = function (renderCamera) {
23065 var rotation = renderCamera.rotation;
23066 if (Math.abs(rotation.phi - this._rotation.phi) < this._epsilon) {
23069 this._rotation = rotation;
23070 this._setNeedsRender();
23073 * Set configuration values.
23075 * @param {IDirectionConfiguration} configuration
23077 DirectionDOMRenderer.prototype.setConfiguration = function (configuration) {
23078 var needsRender = false;
23079 if (this._highlightKey !== configuration.highlightKey ||
23080 this._distinguishSequence !== configuration.distinguishSequence) {
23081 this._highlightKey = configuration.highlightKey;
23082 this._distinguishSequence = configuration.distinguishSequence;
23083 needsRender = true;
23085 if (this._calculator.minWidth !== configuration.minWidth ||
23086 this._calculator.maxWidth !== configuration.maxWidth) {
23087 this._calculator.configure(configuration);
23088 needsRender = true;
23091 this._setNeedsRender();
23095 * Detect the element's width and height and resize
23096 * elements accordingly.
23098 * @param {HTMLElement} element Viewer container element.
23100 DirectionDOMRenderer.prototype.resize = function (element) {
23101 this._calculator.resize(element);
23102 this._setNeedsRender();
23104 DirectionDOMRenderer.prototype._setNeedsRender = function () {
23105 if (this._node != null) {
23106 this._needsRender = true;
23109 DirectionDOMRenderer.prototype._clearEdges = function () {
23110 this._stepEdges = [];
23111 this._turnEdges = [];
23112 this._panoEdges = [];
23113 this._sequenceEdgeKeys = [];
23115 DirectionDOMRenderer.prototype._setEdges = function (edgeStatus, sequence) {
23116 this._stepEdges = [];
23117 this._turnEdges = [];
23118 this._panoEdges = [];
23119 this._sequenceEdgeKeys = [];
23120 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
23122 var direction = edge.data.direction;
23123 if (this._stepDirections.indexOf(direction) > -1) {
23124 this._stepEdges.push(edge);
23127 if (this._turnDirections.indexOf(direction) > -1) {
23128 this._turnEdges.push(edge);
23131 if (edge.data.direction === Edge_1.EdgeDirection.Pano) {
23132 this._panoEdges.push(edge);
23135 if (this._distinguishSequence && sequence != null) {
23136 var edges = this._panoEdges
23137 .concat(this._stepEdges)
23138 .concat(this._turnEdges);
23139 for (var _b = 0, edges_1 = edges; _b < edges_1.length; _b++) {
23140 var edge = edges_1[_b];
23141 var edgeKey = edge.to;
23142 for (var _c = 0, _d = sequence.keys; _c < _d.length; _c++) {
23143 var sequenceKey = _d[_c];
23144 if (sequenceKey === edgeKey) {
23145 this._sequenceEdgeKeys.push(edgeKey);
23152 DirectionDOMRenderer.prototype._createPanoArrows = function (navigator, rotation) {
23154 for (var _i = 0, _a = this._panoEdges; _i < _a.length; _i++) {
23155 var panoEdge = _a[_i];
23156 arrows.push(this._createVNodeByKey(navigator, panoEdge.to, panoEdge.data.worldMotionAzimuth, rotation, this._calculator.outerRadius, "DirectionsArrowPano"));
23158 for (var _b = 0, _c = this._stepEdges; _b < _c.length; _b++) {
23159 var stepEdge = _c[_b];
23160 arrows.push(this._createPanoToPerspectiveArrow(navigator, stepEdge.to, stepEdge.data.worldMotionAzimuth, rotation, stepEdge.data.direction));
23164 DirectionDOMRenderer.prototype._createPanoToPerspectiveArrow = function (navigator, key, azimuth, rotation, direction) {
23165 var threshold = Math.PI / 8;
23166 var relativePhi = rotation.phi;
23167 switch (direction) {
23168 case Edge_1.EdgeDirection.StepBackward:
23169 relativePhi = rotation.phi - Math.PI;
23171 case Edge_1.EdgeDirection.StepLeft:
23172 relativePhi = rotation.phi + Math.PI / 2;
23174 case Edge_1.EdgeDirection.StepRight:
23175 relativePhi = rotation.phi - Math.PI / 2;
23180 if (Math.abs(this._spatial.wrapAngle(azimuth - relativePhi)) < threshold) {
23181 return this._createVNodeByKey(navigator, key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowStep");
23183 return this._createVNodeDisabled(key, azimuth, rotation);
23185 DirectionDOMRenderer.prototype._createPerspectiveToPanoArrows = function (navigator, rotation) {
23187 for (var _i = 0, _a = this._panoEdges; _i < _a.length; _i++) {
23188 var panoEdge = _a[_i];
23189 arrows.push(this._createVNodeByKey(navigator, panoEdge.to, panoEdge.data.worldMotionAzimuth, rotation, this._calculator.innerRadius, "DirectionsArrowPano", true));
23193 DirectionDOMRenderer.prototype._createStepArrows = function (navigator, rotation) {
23195 for (var _i = 0, _a = this._stepEdges; _i < _a.length; _i++) {
23196 var stepEdge = _a[_i];
23197 arrows.push(this._createVNodeByDirection(navigator, stepEdge.to, stepEdge.data.worldMotionAzimuth, rotation, stepEdge.data.direction));
23201 DirectionDOMRenderer.prototype._createTurnArrows = function (navigator) {
23203 for (var _i = 0, _a = this._turnEdges; _i < _a.length; _i++) {
23204 var turnEdge = _a[_i];
23205 var direction = turnEdge.data.direction;
23206 var name_1 = this._turnNames[direction];
23207 turns.push(this._createVNodeByTurn(navigator, turnEdge.to, name_1, direction));
23211 DirectionDOMRenderer.prototype._createVNodeByKey = function (navigator, key, azimuth, rotation, offset, className, shiftVertically) {
23212 var onClick = function (e) {
23213 navigator.moveToKey$(key)
23214 .subscribe(undefined, function (error) {
23215 if (!(error instanceof Error_1.AbortMapillaryError)) {
23216 console.error(error);
23220 return this._createVNode(key, azimuth, rotation, offset, className, "DirectionsCircle", onClick, shiftVertically);
23222 DirectionDOMRenderer.prototype._createVNodeByDirection = function (navigator, key, azimuth, rotation, direction) {
23223 var onClick = function (e) {
23224 navigator.moveDir$(direction)
23225 .subscribe(undefined, function (error) {
23226 if (!(error instanceof Error_1.AbortMapillaryError)) {
23227 console.error(error);
23231 return this._createVNode(key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowStep", "DirectionsCircle", onClick);
23233 DirectionDOMRenderer.prototype._createVNodeByTurn = function (navigator, key, className, direction) {
23234 var onClick = function (e) {
23235 navigator.moveDir$(direction)
23236 .subscribe(undefined, function (error) {
23237 if (!(error instanceof Error_1.AbortMapillaryError)) {
23238 console.error(error);
23243 height: this._calculator.turnCircleSizeCss,
23244 transform: "rotate(0)",
23245 width: this._calculator.turnCircleSizeCss,
23247 switch (direction) {
23248 case Edge_1.EdgeDirection.TurnLeft:
23249 style.left = "5px";
23252 case Edge_1.EdgeDirection.TurnRight:
23253 style.right = "5px";
23256 case Edge_1.EdgeDirection.TurnU:
23257 style.left = "5px";
23258 style.bottom = "5px";
23263 var circleProperties = {
23270 var circleClassName = "TurnCircle";
23271 if (this._sequenceEdgeKeys.indexOf(key) > -1) {
23272 circleClassName += "Sequence";
23274 if (this._highlightKey === key) {
23275 circleClassName += "Highlight";
23277 var turn = vd.h("div." + className, {}, []);
23278 return vd.h("div." + circleClassName, circleProperties, [turn]);
23280 DirectionDOMRenderer.prototype._createVNodeDisabled = function (key, azimuth, rotation) {
23281 return this._createVNode(key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowDisabled", "DirectionsCircleDisabled");
23283 DirectionDOMRenderer.prototype._createVNode = function (key, azimuth, rotation, radius, className, circleClassName, onClick, shiftVertically) {
23284 var translation = this._calculator.angleToCoordinates(azimuth - rotation.phi);
23285 // rotate 90 degrees clockwise and flip over X-axis
23286 var translationX = Math.round(-radius * translation[1] + 0.5 * this._calculator.containerWidth);
23287 var translationY = Math.round(-radius * translation[0] + 0.5 * this._calculator.containerHeight);
23288 var shadowTranslation = this._calculator.relativeAngleToCoordiantes(azimuth, rotation.phi);
23289 var shadowOffset = this._calculator.shadowOffset;
23290 var shadowTranslationX = -shadowOffset * shadowTranslation[1];
23291 var shadowTranslationY = shadowOffset * shadowTranslation[0];
23292 var filter = "drop-shadow(" + shadowTranslationX + "px " + shadowTranslationY + "px 1px rgba(0,0,0,0.8))";
23295 "-webkit-filter": filter,
23299 var chevron = vd.h("div." + className, properties, []);
23300 var azimuthDeg = -this._spatial.radToDeg(azimuth - rotation.phi);
23301 var circleTransform = shiftVertically ?
23302 "translate(" + translationX + "px, " + translationY + "px) rotate(" + azimuthDeg + "deg) translateZ(-0.01px)" :
23303 "translate(" + translationX + "px, " + translationY + "px) rotate(" + azimuthDeg + "deg)";
23304 var circleProperties = {
23305 attributes: { "data-key": key },
23308 height: this._calculator.stepCircleSizeCss,
23309 marginLeft: this._calculator.stepCircleMarginCss,
23310 marginTop: this._calculator.stepCircleMarginCss,
23311 transform: circleTransform,
23312 width: this._calculator.stepCircleSizeCss,
23315 if (this._sequenceEdgeKeys.indexOf(key) > -1) {
23316 circleClassName += "Sequence";
23318 if (this._highlightKey === key) {
23319 circleClassName += "Highlight";
23321 return vd.h("div." + circleClassName, circleProperties, [chevron]);
23323 DirectionDOMRenderer.prototype._getContainer = function (steps, turns, rotation) {
23324 // edge does not handle hover on perspective transforms.
23325 var transform = this._isEdge ?
23327 "perspective(" + this._calculator.containerWidthCss + ") rotateX(60deg)";
23329 oncontextmenu: function (event) { event.preventDefault(); },
23331 bottom: this._calculator.containerBottomCss,
23332 height: this._calculator.containerHeightCss,
23333 left: this._calculator.containerLeftCss,
23334 marginLeft: this._calculator.containerMarginCss,
23335 transform: transform,
23336 width: this._calculator.containerWidthCss,
23339 return vd.h("div.DirectionsPerspective", properties, turns.concat(steps));
23341 return DirectionDOMRenderer;
23343 exports.DirectionDOMRenderer = DirectionDOMRenderer;
23344 exports.default = DirectionDOMRenderer;
23347 },{"../../Component":274,"../../Edge":275,"../../Error":276,"../../Geo":277,"virtual-dom":230}],304:[function(require,module,exports){
23349 var __extends = (this && this.__extends) || (function () {
23350 var extendStatics = function (d, b) {
23351 extendStatics = Object.setPrototypeOf ||
23352 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23353 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23354 return extendStatics(d, b);
23356 return function (d, b) {
23357 extendStatics(d, b);
23358 function __() { this.constructor = d; }
23359 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23362 Object.defineProperty(exports, "__esModule", { value: true });
23363 var rxjs_1 = require("rxjs");
23364 var operators_1 = require("rxjs/operators");
23365 var Component_1 = require("../../Component");
23366 var Render_1 = require("../../Render");
23367 var Tiles_1 = require("../../Tiles");
23368 var Utils_1 = require("../../Utils");
23369 var ImagePlaneComponent = /** @class */ (function (_super) {
23370 __extends(ImagePlaneComponent, _super);
23371 function ImagePlaneComponent(name, container, navigator) {
23372 var _this = _super.call(this, name, container, navigator) || this;
23373 _this._imageTileLoader = new Tiles_1.ImageTileLoader(Utils_1.Urls.tileScheme, Utils_1.Urls.tileDomain, Utils_1.Urls.origin);
23374 _this._roiCalculator = new Tiles_1.RegionOfInterestCalculator();
23375 _this._rendererOperation$ = new rxjs_1.Subject();
23376 _this._rendererCreator$ = new rxjs_1.Subject();
23377 _this._rendererDisposer$ = new rxjs_1.Subject();
23378 _this._renderer$ = _this._rendererOperation$.pipe(operators_1.scan(function (renderer, operation) {
23379 return operation(renderer);
23380 }, null), operators_1.filter(function (renderer) {
23381 return renderer != null;
23382 }), operators_1.distinctUntilChanged(undefined, function (renderer) {
23383 return renderer.frameId;
23385 _this._rendererCreator$.pipe(operators_1.map(function () {
23386 return function (renderer) {
23387 if (renderer != null) {
23388 throw new Error("Multiple image plane states can not be created at the same time");
23390 return new Component_1.ImagePlaneGLRenderer();
23393 .subscribe(_this._rendererOperation$);
23394 _this._rendererDisposer$.pipe(operators_1.map(function () {
23395 return function (renderer) {
23396 renderer.dispose();
23400 .subscribe(_this._rendererOperation$);
23403 ImagePlaneComponent.prototype._activate = function () {
23405 this._rendererSubscription = this._renderer$.pipe(operators_1.map(function (renderer) {
23409 frameId: renderer.frameId,
23410 needsRender: renderer.needsRender,
23411 render: renderer.render.bind(renderer),
23412 stage: Render_1.GLRenderStage.Background,
23415 renderer.clearNeedsRender();
23418 .subscribe(this._container.glRenderer.render$);
23419 this._rendererCreator$.next(null);
23420 this._stateSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
23421 return function (renderer) {
23422 renderer.updateFrame(frame);
23426 .subscribe(this._rendererOperation$);
23427 var textureProvider$ = this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
23428 return frame.state.currentNode.key;
23429 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
23430 var frame = _a[0], renderer = _a[1], size = _a[2];
23431 var state = frame.state;
23432 var viewportSize = Math.max(size.width, size.height);
23433 var currentNode = state.currentNode;
23434 var currentTransform = state.currentTransform;
23435 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
23436 return new Tiles_1.TextureProvider(currentNode.key, currentTransform.basicWidth, currentTransform.basicHeight, tileSize, currentNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
23437 }), operators_1.publishReplay(1), operators_1.refCount());
23438 this._textureProviderSubscription = textureProvider$.subscribe(function () { });
23439 this._setTextureProviderSubscription = textureProvider$.pipe(operators_1.map(function (provider) {
23440 return function (renderer) {
23441 renderer.setTextureProvider(provider.key, provider);
23445 .subscribe(this._rendererOperation$);
23446 this._setTileSizeSubscription = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
23447 return rxjs_1.combineLatest(textureProvider$, rxjs_1.of(size)).pipe(operators_1.first());
23449 .subscribe(function (_a) {
23450 var provider = _a[0], size = _a[1];
23451 var viewportSize = Math.max(size.width, size.height);
23452 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
23453 provider.setTileSize(tileSize);
23455 this._abortTextureProviderSubscription = textureProvider$.pipe(operators_1.pairwise())
23456 .subscribe(function (pair) {
23457 var previous = pair[0];
23460 var roiTrigger$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
23461 var camera = _a[0], size = _a[1];
23463 camera.camera.position.clone(),
23464 camera.camera.lookat.clone(),
23465 camera.zoom.valueOf(),
23466 size.height.valueOf(),
23467 size.width.valueOf()
23469 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
23470 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
23471 }), operators_1.map(function (pls) {
23472 var samePosition = pls[0][0].equals(pls[1][0]);
23473 var sameLookat = pls[0][1].equals(pls[1][1]);
23474 var sameZoom = pls[0][2] === pls[1][2];
23475 var sameHeight = pls[0][3] === pls[1][3];
23476 var sameWidth = pls[0][4] === pls[1][4];
23477 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
23478 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
23480 }), operators_1.switchMap(function (stalled) {
23481 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
23482 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
23483 this._setRegionOfInterestSubscription = textureProvider$.pipe(operators_1.switchMap(function (provider) {
23484 return roiTrigger$.pipe(operators_1.map(function (_a) {
23485 var camera = _a[0], size = _a[1], transform = _a[2];
23487 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
23491 }), operators_1.filter(function (args) {
23492 return !args[1].disposed;
23494 .subscribe(function (args) {
23496 var provider = args[1];
23497 provider.setRegionOfInterest(roi);
23499 var hasTexture$ = textureProvider$.pipe(operators_1.switchMap(function (provider) {
23500 return provider.hasTexture$;
23501 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
23502 this._hasTextureSubscription = hasTexture$.subscribe(function () { });
23503 var nodeImage$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
23504 return frame.state.nodesAhead === 0;
23505 }), operators_1.map(function (frame) {
23506 return frame.state.currentNode;
23507 }), operators_1.distinctUntilChanged(undefined, function (node) {
23509 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexture$), operators_1.filter(function (args) {
23511 }), operators_1.map(function (args) {
23513 }), operators_1.filter(function (node) {
23515 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
23516 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
23517 }), operators_1.switchMap(function (node) {
23518 var baseImageSize = node.pano ?
23519 Utils_1.Settings.basePanoramaSize :
23520 Utils_1.Settings.baseImageSize;
23521 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
23522 return rxjs_1.empty();
23525 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
23526 return [n.image, n];
23528 return image$.pipe(operators_1.takeUntil(hasTexture$.pipe(operators_1.filter(function (hasTexture) {
23530 }))), operators_1.catchError(function (error, caught) {
23531 console.error("Failed to fetch high res image (" + node.key + ")", error);
23532 return rxjs_1.empty();
23534 })).pipe(operators_1.publish(), operators_1.refCount());
23535 this._updateBackgroundSubscription = nodeImage$.pipe(operators_1.withLatestFrom(textureProvider$))
23536 .subscribe(function (args) {
23537 if (args[0][1].key !== args[1].key ||
23538 args[1].disposed) {
23541 args[1].updateBackground(args[0][0]);
23543 this._updateTextureImageSubscription = nodeImage$.pipe(operators_1.map(function (imn) {
23544 return function (renderer) {
23545 renderer.updateTextureImage(imn[0], imn[1]);
23549 .subscribe(this._rendererOperation$);
23551 ImagePlaneComponent.prototype._deactivate = function () {
23552 this._rendererDisposer$.next(null);
23553 this._abortTextureProviderSubscription.unsubscribe();
23554 this._hasTextureSubscription.unsubscribe();
23555 this._rendererSubscription.unsubscribe();
23556 this._setRegionOfInterestSubscription.unsubscribe();
23557 this._setTextureProviderSubscription.unsubscribe();
23558 this._setTileSizeSubscription.unsubscribe();
23559 this._stateSubscription.unsubscribe();
23560 this._textureProviderSubscription.unsubscribe();
23561 this._updateBackgroundSubscription.unsubscribe();
23562 this._updateTextureImageSubscription.unsubscribe();
23564 ImagePlaneComponent.prototype._getDefaultConfiguration = function () {
23567 ImagePlaneComponent.componentName = "imagePlane";
23568 return ImagePlaneComponent;
23569 }(Component_1.Component));
23570 exports.ImagePlaneComponent = ImagePlaneComponent;
23571 Component_1.ComponentService.register(ImagePlaneComponent);
23572 exports.default = ImagePlaneComponent;
23574 },{"../../Component":274,"../../Render":280,"../../Tiles":283,"../../Utils":284,"rxjs":26,"rxjs/operators":224}],305:[function(require,module,exports){
23576 Object.defineProperty(exports, "__esModule", { value: true });
23577 var Component_1 = require("../../Component");
23578 var ImagePlaneGLRenderer = /** @class */ (function () {
23579 function ImagePlaneGLRenderer() {
23580 this._factory = new Component_1.MeshFactory();
23581 this._scene = new Component_1.MeshScene();
23583 this._alphaOld = 0;
23584 this._fadeOutSpeed = 0.05;
23585 this._currentKey = null;
23586 this._previousKey = null;
23587 this._providerDisposers = {};
23589 this._needsRender = false;
23591 Object.defineProperty(ImagePlaneGLRenderer.prototype, "frameId", {
23593 return this._frameId;
23598 Object.defineProperty(ImagePlaneGLRenderer.prototype, "needsRender", {
23600 return this._needsRender;
23605 ImagePlaneGLRenderer.prototype.indicateNeedsRender = function () {
23606 this._needsRender = true;
23608 ImagePlaneGLRenderer.prototype.updateFrame = function (frame) {
23609 this._updateFrameId(frame.id);
23610 this._needsRender = this._updateAlpha(frame.state.alpha) || this._needsRender;
23611 this._needsRender = this._updateAlphaOld(frame.state.alpha) || this._needsRender;
23612 this._needsRender = this._updateImagePlanes(frame.state) || this._needsRender;
23614 ImagePlaneGLRenderer.prototype.setTextureProvider = function (key, provider) {
23616 if (key !== this._currentKey) {
23619 var createdSubscription = provider.textureCreated$
23620 .subscribe(function (texture) {
23621 _this._updateTexture(texture);
23623 var updatedSubscription = provider.textureUpdated$
23624 .subscribe(function (updated) {
23625 _this._needsRender = true;
23627 var dispose = function () {
23628 createdSubscription.unsubscribe();
23629 updatedSubscription.unsubscribe();
23630 provider.dispose();
23632 if (key in this._providerDisposers) {
23633 var disposeProvider = this._providerDisposers[key];
23635 delete this._providerDisposers[key];
23637 this._providerDisposers[key] = dispose;
23639 ImagePlaneGLRenderer.prototype._updateTexture = function (texture) {
23640 this._needsRender = true;
23641 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
23642 var plane = _a[_i];
23643 var material = plane.material;
23644 var oldTexture = material.uniforms.projectorTex.value;
23645 material.uniforms.projectorTex.value = null;
23646 oldTexture.dispose();
23647 material.uniforms.projectorTex.value = texture;
23650 ImagePlaneGLRenderer.prototype.updateTextureImage = function (image, node) {
23651 if (this._currentKey !== node.key) {
23654 this._needsRender = true;
23655 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
23656 var plane = _a[_i];
23657 var material = plane.material;
23658 var texture = material.uniforms.projectorTex.value;
23659 texture.image = image;
23660 texture.needsUpdate = true;
23663 ImagePlaneGLRenderer.prototype.render = function (perspectiveCamera, renderer) {
23664 var planeAlpha = this._scene.imagePlanesOld.length ? 1 : this._alpha;
23665 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
23666 var plane = _a[_i];
23667 plane.material.uniforms.opacity.value = planeAlpha;
23669 for (var _b = 0, _c = this._scene.imagePlanesOld; _b < _c.length; _b++) {
23670 var plane = _c[_b];
23671 plane.material.uniforms.opacity.value = this._alphaOld;
23673 renderer.render(this._scene.scene, perspectiveCamera);
23674 renderer.render(this._scene.sceneOld, perspectiveCamera);
23675 for (var _d = 0, _e = this._scene.imagePlanes; _d < _e.length; _d++) {
23676 var plane = _e[_d];
23677 plane.material.uniforms.opacity.value = this._alpha;
23679 renderer.render(this._scene.scene, perspectiveCamera);
23681 ImagePlaneGLRenderer.prototype.clearNeedsRender = function () {
23682 this._needsRender = false;
23684 ImagePlaneGLRenderer.prototype.dispose = function () {
23685 this._scene.clear();
23687 ImagePlaneGLRenderer.prototype._updateFrameId = function (frameId) {
23688 this._frameId = frameId;
23690 ImagePlaneGLRenderer.prototype._updateAlpha = function (alpha) {
23691 if (alpha === this._alpha) {
23694 this._alpha = alpha;
23697 ImagePlaneGLRenderer.prototype._updateAlphaOld = function (alpha) {
23698 if (alpha < 1 || this._alphaOld === 0) {
23701 this._alphaOld = Math.max(0, this._alphaOld - this._fadeOutSpeed);
23704 ImagePlaneGLRenderer.prototype._updateImagePlanes = function (state) {
23705 if (state.currentNode == null || state.currentNode.key === this._currentKey) {
23708 var previousKey = state.previousNode != null ? state.previousNode.key : null;
23709 var currentKey = state.currentNode.key;
23710 if (this._previousKey !== previousKey &&
23711 this._previousKey !== currentKey &&
23712 this._previousKey in this._providerDisposers) {
23713 var disposeProvider = this._providerDisposers[this._previousKey];
23715 delete this._providerDisposers[this._previousKey];
23717 if (previousKey != null) {
23718 if (previousKey !== this._currentKey && previousKey !== this._previousKey) {
23719 var previousMesh = this._factory.createMesh(state.previousNode, state.previousTransform);
23720 this._scene.updateImagePlanes([previousMesh]);
23722 this._previousKey = previousKey;
23724 this._currentKey = currentKey;
23725 var currentMesh = this._factory.createMesh(state.currentNode, state.currentTransform);
23726 this._scene.updateImagePlanes([currentMesh]);
23727 this._alphaOld = 1;
23730 return ImagePlaneGLRenderer;
23732 exports.ImagePlaneGLRenderer = ImagePlaneGLRenderer;
23733 exports.default = ImagePlaneGLRenderer;
23735 },{"../../Component":274}],306:[function(require,module,exports){
23737 Object.defineProperty(exports, "__esModule", { value: true });
23739 (function (CoverState) {
23740 CoverState[CoverState["Hidden"] = 0] = "Hidden";
23741 CoverState[CoverState["Loading"] = 1] = "Loading";
23742 CoverState[CoverState["Visible"] = 2] = "Visible";
23743 })(CoverState = exports.CoverState || (exports.CoverState = {}));
23745 },{}],307:[function(require,module,exports){
23747 Object.defineProperty(exports, "__esModule", { value: true });
23749 * Enumeration for slider mode.
23754 * @description Modes for specifying how transitions
23755 * between nodes are performed in slider mode. Only
23756 * applicable when the slider component determines
23757 * that transitions with motion is possilble. When it
23758 * is not, the stationary mode will be applied.
23761 (function (SliderMode) {
23763 * Transitions with motion.
23765 * @description The slider component moves the
23766 * camera between the node origins.
23768 * In this mode it is not possible to zoom or pan.
23770 * The slider component falls back to stationary
23771 * mode when it determines that the pair of nodes
23772 * does not have a strong enough relation.
23774 SliderMode[SliderMode["Motion"] = 0] = "Motion";
23776 * Stationary transitions.
23778 * @description The camera is stationary.
23780 * In this mode it is possible to zoom and pan.
23782 SliderMode[SliderMode["Stationary"] = 1] = "Stationary";
23783 })(SliderMode = exports.SliderMode || (exports.SliderMode = {}));
23785 },{}],308:[function(require,module,exports){
23787 Object.defineProperty(exports, "__esModule", { value: true });
23788 var ICoverConfiguration_1 = require("./ICoverConfiguration");
23789 exports.CoverState = ICoverConfiguration_1.CoverState;
23790 var ISliderConfiguration_1 = require("./ISliderConfiguration");
23791 exports.SliderMode = ISliderConfiguration_1.SliderMode;
23793 },{"./ICoverConfiguration":306,"./ISliderConfiguration":307}],309:[function(require,module,exports){
23795 var __extends = (this && this.__extends) || (function () {
23796 var extendStatics = function (d, b) {
23797 extendStatics = Object.setPrototypeOf ||
23798 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23799 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23800 return extendStatics(d, b);
23802 return function (d, b) {
23803 extendStatics(d, b);
23804 function __() { this.constructor = d; }
23805 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23808 Object.defineProperty(exports, "__esModule", { value: true });
23809 var operators_1 = require("rxjs/operators");
23810 var Component_1 = require("../../Component");
23811 var Edge_1 = require("../../Edge");
23813 * The `KeyPlayHandler` allows the user to control the play behavior
23814 * using the following key commands:
23816 * `Spacebar`: Start or stop playing.
23817 * `SHIFT` + `D`: Switch direction.
23818 * `<`: Decrease speed.
23819 * `>`: Increase speed.
23823 * var keyboardComponent = viewer.getComponent("keyboard");
23825 * keyboardComponent.keyPlay.disable();
23826 * keyboardComponent.keyPlay.enable();
23828 * var isEnabled = keyboardComponent.keyPlay.isEnabled;
23831 var KeyPlayHandler = /** @class */ (function (_super) {
23832 __extends(KeyPlayHandler, _super);
23833 function KeyPlayHandler() {
23834 return _super !== null && _super.apply(this, arguments) || this;
23836 KeyPlayHandler.prototype._enable = function () {
23838 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(this._navigator.playService.playing$, this._navigator.playService.direction$, this._navigator.playService.speed$, this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
23839 return node.sequenceEdges$;
23841 .subscribe(function (_a) {
23842 var event = _a[0], playing = _a[1], direction = _a[2], speed = _a[3], status = _a[4];
23843 if (event.altKey || event.ctrlKey || event.metaKey) {
23846 switch (event.key) {
23848 if (!event.shiftKey) {
23851 var newDirection = playing ?
23852 null : direction === Edge_1.EdgeDirection.Next ?
23853 Edge_1.EdgeDirection.Prev : direction === Edge_1.EdgeDirection.Prev ?
23854 Edge_1.EdgeDirection.Next : null;
23855 if (newDirection != null) {
23856 _this._navigator.playService.setDirection(newDirection);
23860 if (event.shiftKey) {
23864 _this._navigator.playService.stop();
23867 for (var _i = 0, _b = status.edges; _i < _b.length; _i++) {
23869 if (edge.data.direction === direction) {
23870 _this._navigator.playService.play();
23876 _this._navigator.playService.setSpeed(speed - 0.05);
23879 _this._navigator.playService.setSpeed(speed + 0.05);
23884 event.preventDefault();
23887 KeyPlayHandler.prototype._disable = function () {
23888 this._keyDownSubscription.unsubscribe();
23890 KeyPlayHandler.prototype._getConfiguration = function (enable) {
23891 return { keyZoom: enable };
23893 return KeyPlayHandler;
23894 }(Component_1.HandlerBase));
23895 exports.KeyPlayHandler = KeyPlayHandler;
23896 exports.default = KeyPlayHandler;
23898 },{"../../Component":274,"../../Edge":275,"rxjs/operators":224}],310:[function(require,module,exports){
23900 var __extends = (this && this.__extends) || (function () {
23901 var extendStatics = function (d, b) {
23902 extendStatics = Object.setPrototypeOf ||
23903 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23904 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23905 return extendStatics(d, b);
23907 return function (d, b) {
23908 extendStatics(d, b);
23909 function __() { this.constructor = d; }
23910 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23913 Object.defineProperty(exports, "__esModule", { value: true });
23914 var operators_1 = require("rxjs/operators");
23915 var Component_1 = require("../../Component");
23916 var Edge_1 = require("../../Edge");
23917 var Error_1 = require("../../Error");
23919 * The `KeySequenceNavigationHandler` allows the user to navigate through a sequence using the
23920 * following key commands:
23922 * `ALT` + `Up Arrow`: Navigate to next image in the sequence.
23923 * `ALT` + `Down Arrow`: Navigate to previous image in sequence.
23927 * var keyboardComponent = viewer.getComponent("keyboard");
23929 * keyboardComponent.keySequenceNavigation.disable();
23930 * keyboardComponent.keySequenceNavigation.enable();
23932 * var isEnabled = keyboardComponent.keySequenceNavigation.isEnabled;
23935 var KeySequenceNavigationHandler = /** @class */ (function (_super) {
23936 __extends(KeySequenceNavigationHandler, _super);
23937 function KeySequenceNavigationHandler() {
23938 return _super !== null && _super.apply(this, arguments) || this;
23940 KeySequenceNavigationHandler.prototype._enable = function () {
23942 var sequenceEdges$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
23943 return node.sequenceEdges$;
23945 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(sequenceEdges$))
23946 .subscribe(function (_a) {
23947 var event = _a[0], edgeStatus = _a[1];
23948 var direction = null;
23949 switch (event.keyCode) {
23951 direction = Edge_1.EdgeDirection.Next;
23954 direction = Edge_1.EdgeDirection.Prev;
23959 event.preventDefault();
23960 if (!event.altKey || event.shiftKey || !edgeStatus.cached) {
23963 for (var _i = 0, _b = edgeStatus.edges; _i < _b.length; _i++) {
23965 if (edge.data.direction === direction) {
23966 _this._navigator.moveToKey$(edge.to)
23967 .subscribe(undefined, function (error) {
23968 if (!(error instanceof Error_1.AbortMapillaryError)) {
23969 console.error(error);
23977 KeySequenceNavigationHandler.prototype._disable = function () {
23978 this._keyDownSubscription.unsubscribe();
23980 KeySequenceNavigationHandler.prototype._getConfiguration = function (enable) {
23981 return { keySequenceNavigation: enable };
23983 return KeySequenceNavigationHandler;
23984 }(Component_1.HandlerBase));
23985 exports.KeySequenceNavigationHandler = KeySequenceNavigationHandler;
23986 exports.default = KeySequenceNavigationHandler;
23988 },{"../../Component":274,"../../Edge":275,"../../Error":276,"rxjs/operators":224}],311:[function(require,module,exports){
23990 var __extends = (this && this.__extends) || (function () {
23991 var extendStatics = function (d, b) {
23992 extendStatics = Object.setPrototypeOf ||
23993 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23994 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23995 return extendStatics(d, b);
23997 return function (d, b) {
23998 extendStatics(d, b);
23999 function __() { this.constructor = d; }
24000 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24003 Object.defineProperty(exports, "__esModule", { value: true });
24004 var operators_1 = require("rxjs/operators");
24005 var Component_1 = require("../../Component");
24006 var Edge_1 = require("../../Edge");
24007 var Error_1 = require("../../Error");
24009 * The `KeySpatialNavigationHandler` allows the user to navigate through a sequence using the
24010 * following key commands:
24012 * `Up Arrow`: Step forward.
24013 * `Down Arrow`: Step backward.
24014 * `Left Arrow`: Step to the left.
24015 * `Rigth Arrow`: Step to the right.
24016 * `SHIFT` + `Down Arrow`: Turn around.
24017 * `SHIFT` + `Left Arrow`: Turn to the left.
24018 * `SHIFT` + `Rigth Arrow`: Turn to the right.
24022 * var keyboardComponent = viewer.getComponent("keyboard");
24024 * keyboardComponent.keySpatialNavigation.disable();
24025 * keyboardComponent.keySpatialNavigation.enable();
24027 * var isEnabled = keyboardComponent.keySpatialNavigation.isEnabled;
24030 var KeySpatialNavigationHandler = /** @class */ (function (_super) {
24031 __extends(KeySpatialNavigationHandler, _super);
24033 function KeySpatialNavigationHandler(component, container, navigator, spatial) {
24034 var _this = _super.call(this, component, container, navigator) || this;
24035 _this._spatial = spatial;
24038 KeySpatialNavigationHandler.prototype._enable = function () {
24040 var spatialEdges$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
24041 return node.spatialEdges$;
24043 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(spatialEdges$, this._navigator.stateService.currentState$))
24044 .subscribe(function (_a) {
24045 var event = _a[0], edgeStatus = _a[1], frame = _a[2];
24046 var pano = frame.state.currentNode.pano;
24047 var direction = null;
24048 switch (event.keyCode) {
24050 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnLeft : Edge_1.EdgeDirection.StepLeft;
24053 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.Pano : Edge_1.EdgeDirection.StepForward;
24056 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnRight : Edge_1.EdgeDirection.StepRight;
24059 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnU : Edge_1.EdgeDirection.StepBackward;
24064 event.preventDefault();
24065 if (event.altKey || !edgeStatus.cached ||
24066 (event.shiftKey && pano)) {
24070 _this._moveDir(direction, edgeStatus);
24074 shifts[Edge_1.EdgeDirection.StepBackward] = Math.PI;
24075 shifts[Edge_1.EdgeDirection.StepForward] = 0;
24076 shifts[Edge_1.EdgeDirection.StepLeft] = Math.PI / 2;
24077 shifts[Edge_1.EdgeDirection.StepRight] = -Math.PI / 2;
24078 var phi = _this._rotationFromCamera(frame.state.camera).phi;
24079 var navigationAngle = _this._spatial.wrapAngle(phi + shifts[direction]);
24080 var threshold = Math.PI / 4;
24081 var edges = edgeStatus.edges.filter(function (e) {
24082 return e.data.direction === Edge_1.EdgeDirection.Pano || e.data.direction === direction;
24084 var smallestAngle = Number.MAX_VALUE;
24086 for (var _i = 0, edges_1 = edges; _i < edges_1.length; _i++) {
24087 var edge = edges_1[_i];
24088 var angle = Math.abs(_this._spatial.wrapAngle(edge.data.worldMotionAzimuth - navigationAngle));
24089 if (angle < Math.min(smallestAngle, threshold)) {
24090 smallestAngle = angle;
24094 if (toKey == null) {
24097 _this._moveToKey(toKey);
24101 KeySpatialNavigationHandler.prototype._disable = function () {
24102 this._keyDownSubscription.unsubscribe();
24104 KeySpatialNavigationHandler.prototype._getConfiguration = function (enable) {
24105 return { keySpatialNavigation: enable };
24107 KeySpatialNavigationHandler.prototype._moveDir = function (direction, edgeStatus) {
24108 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
24110 if (edge.data.direction === direction) {
24111 this._moveToKey(edge.to);
24116 KeySpatialNavigationHandler.prototype._moveToKey = function (key) {
24117 this._navigator.moveToKey$(key)
24118 .subscribe(undefined, function (error) {
24119 if (!(error instanceof Error_1.AbortMapillaryError)) {
24120 console.error(error);
24124 KeySpatialNavigationHandler.prototype._rotationFromCamera = function (camera) {
24125 var direction = camera.lookat.clone().sub(camera.position);
24126 var upProjection = direction.clone().dot(camera.up);
24127 var planeProjection = direction.clone().sub(camera.up.clone().multiplyScalar(upProjection));
24128 var phi = Math.atan2(planeProjection.y, planeProjection.x);
24129 var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
24130 return { phi: phi, theta: theta };
24132 return KeySpatialNavigationHandler;
24133 }(Component_1.HandlerBase));
24134 exports.KeySpatialNavigationHandler = KeySpatialNavigationHandler;
24135 exports.default = KeySpatialNavigationHandler;
24137 },{"../../Component":274,"../../Edge":275,"../../Error":276,"rxjs/operators":224}],312:[function(require,module,exports){
24139 var __extends = (this && this.__extends) || (function () {
24140 var extendStatics = function (d, b) {
24141 extendStatics = Object.setPrototypeOf ||
24142 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24143 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
24144 return extendStatics(d, b);
24146 return function (d, b) {
24147 extendStatics(d, b);
24148 function __() { this.constructor = d; }
24149 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24152 Object.defineProperty(exports, "__esModule", { value: true });
24153 var operators_1 = require("rxjs/operators");
24154 var Component_1 = require("../../Component");
24156 * The `KeyZoomHandler` allows the user to zoom in and out using the
24157 * following key commands:
24164 * var keyboardComponent = viewer.getComponent("keyboard");
24166 * keyboardComponent.keyZoom.disable();
24167 * keyboardComponent.keyZoom.enable();
24169 * var isEnabled = keyboardComponent.keyZoom.isEnabled;
24172 var KeyZoomHandler = /** @class */ (function (_super) {
24173 __extends(KeyZoomHandler, _super);
24175 function KeyZoomHandler(component, container, navigator, viewportCoords) {
24176 var _this = _super.call(this, component, container, navigator) || this;
24177 _this._viewportCoords = viewportCoords;
24180 KeyZoomHandler.prototype._enable = function () {
24182 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
24183 .subscribe(function (_a) {
24184 var event = _a[0], render = _a[1], transform = _a[2];
24185 if (event.altKey || event.shiftKey || event.ctrlKey || event.metaKey) {
24189 switch (event.key) {
24199 event.preventDefault();
24200 var unprojected = _this._viewportCoords.unprojectFromViewport(0, 0, render.perspective);
24201 var reference = transform.projectBasic(unprojected.toArray());
24202 _this._navigator.stateService.zoomIn(delta, reference);
24205 KeyZoomHandler.prototype._disable = function () {
24206 this._keyDownSubscription.unsubscribe();
24208 KeyZoomHandler.prototype._getConfiguration = function (enable) {
24209 return { keyZoom: enable };
24211 return KeyZoomHandler;
24212 }(Component_1.HandlerBase));
24213 exports.KeyZoomHandler = KeyZoomHandler;
24214 exports.default = KeyZoomHandler;
24216 },{"../../Component":274,"rxjs/operators":224}],313:[function(require,module,exports){
24218 var __extends = (this && this.__extends) || (function () {
24219 var extendStatics = function (d, b) {
24220 extendStatics = Object.setPrototypeOf ||
24221 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24222 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
24223 return extendStatics(d, b);
24225 return function (d, b) {
24226 extendStatics(d, b);
24227 function __() { this.constructor = d; }
24228 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24231 Object.defineProperty(exports, "__esModule", { value: true });
24232 var Component_1 = require("../../Component");
24233 var Geo_1 = require("../../Geo");
24235 * @class KeyboardComponent
24237 * @classdesc Component for keyboard event handling.
24239 * To retrive and use the keyboard component
24243 * var viewer = new Mapillary.Viewer(
24248 * var keyboardComponent = viewer.getComponent("keyboard");
24251 var KeyboardComponent = /** @class */ (function (_super) {
24252 __extends(KeyboardComponent, _super);
24254 function KeyboardComponent(name, container, navigator) {
24255 var _this = _super.call(this, name, container, navigator) || this;
24256 _this._keyPlayHandler = new Component_1.KeyPlayHandler(_this, container, navigator);
24257 _this._keySequenceNavigationHandler = new Component_1.KeySequenceNavigationHandler(_this, container, navigator);
24258 _this._keySpatialNavigationHandler = new Component_1.KeySpatialNavigationHandler(_this, container, navigator, new Geo_1.Spatial());
24259 _this._keyZoomHandler = new Component_1.KeyZoomHandler(_this, container, navigator, new Geo_1.ViewportCoords());
24262 Object.defineProperty(KeyboardComponent.prototype, "keyPlay", {
24266 * @returns {KeyPlayHandler} The key play handler.
24269 return this._keyPlayHandler;
24274 Object.defineProperty(KeyboardComponent.prototype, "keySequenceNavigation", {
24276 * Get key sequence navigation.
24278 * @returns {KeySequenceNavigationHandler} The key sequence navigation handler.
24281 return this._keySequenceNavigationHandler;
24286 Object.defineProperty(KeyboardComponent.prototype, "keySpatialNavigation", {
24290 * @returns {KeySpatialNavigationHandler} The spatial handler.
24293 return this._keySpatialNavigationHandler;
24298 Object.defineProperty(KeyboardComponent.prototype, "keyZoom", {
24302 * @returns {KeyZoomHandler} The key zoom handler.
24305 return this._keyZoomHandler;
24310 KeyboardComponent.prototype._activate = function () {
24312 this._configurationSubscription = this._configuration$
24313 .subscribe(function (configuration) {
24314 if (configuration.keyPlay) {
24315 _this._keyPlayHandler.enable();
24318 _this._keyPlayHandler.disable();
24320 if (configuration.keySequenceNavigation) {
24321 _this._keySequenceNavigationHandler.enable();
24324 _this._keySequenceNavigationHandler.disable();
24326 if (configuration.keySpatialNavigation) {
24327 _this._keySpatialNavigationHandler.enable();
24330 _this._keySpatialNavigationHandler.disable();
24332 if (configuration.keyZoom) {
24333 _this._keyZoomHandler.enable();
24336 _this._keyZoomHandler.disable();
24340 KeyboardComponent.prototype._deactivate = function () {
24341 this._configurationSubscription.unsubscribe();
24342 this._keyPlayHandler.disable();
24343 this._keySequenceNavigationHandler.disable();
24344 this._keySpatialNavigationHandler.disable();
24345 this._keyZoomHandler.disable();
24347 KeyboardComponent.prototype._getDefaultConfiguration = function () {
24348 return { keyPlay: true, keySequenceNavigation: true, keySpatialNavigation: true, keyZoom: true };
24350 KeyboardComponent.componentName = "keyboard";
24351 return KeyboardComponent;
24352 }(Component_1.Component));
24353 exports.KeyboardComponent = KeyboardComponent;
24354 Component_1.ComponentService.register(KeyboardComponent);
24355 exports.default = KeyboardComponent;
24357 },{"../../Component":274,"../../Geo":277}],314:[function(require,module,exports){
24359 Object.defineProperty(exports, "__esModule", { value: true });
24360 var MarkerComponent_1 = require("./MarkerComponent");
24361 exports.MarkerComponent = MarkerComponent_1.MarkerComponent;
24362 var SimpleMarker_1 = require("./marker/SimpleMarker");
24363 exports.SimpleMarker = SimpleMarker_1.SimpleMarker;
24364 var CircleMarker_1 = require("./marker/CircleMarker");
24365 exports.CircleMarker = CircleMarker_1.CircleMarker;
24367 },{"./MarkerComponent":315,"./marker/CircleMarker":318,"./marker/SimpleMarker":320}],315:[function(require,module,exports){
24369 var __extends = (this && this.__extends) || (function () {
24370 var extendStatics = function (d, b) {
24371 extendStatics = Object.setPrototypeOf ||
24372 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24373 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
24374 return extendStatics(d, b);
24376 return function (d, b) {
24377 extendStatics(d, b);
24378 function __() { this.constructor = d; }
24379 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24382 Object.defineProperty(exports, "__esModule", { value: true });
24383 var rxjs_1 = require("rxjs");
24384 var operators_1 = require("rxjs/operators");
24385 var THREE = require("three");
24386 var when = require("when");
24387 var Component_1 = require("../../Component");
24388 var Render_1 = require("../../Render");
24389 var Graph_1 = require("../../Graph");
24390 var Geo_1 = require("../../Geo");
24392 * @class MarkerComponent
24394 * @classdesc Component for showing and editing 3D marker objects.
24396 * The `add` method is used for adding new markers or replacing
24397 * markers already in the set.
24399 * If a marker already in the set has the same
24400 * id as one of the markers added, the old marker will be removed and
24401 * the added marker will take its place.
24403 * It is not possible to update markers in the set by updating any properties
24404 * directly on the marker object. Markers need to be replaced by
24405 * re-adding them for updates to geographic position or configuration
24408 * Markers added to the marker component can be either interactive
24409 * or non-interactive. Different marker types define their behavior.
24410 * Markers with interaction support can be configured with options
24411 * to respond to dragging inside the viewer and be detected when
24412 * retrieving markers from pixel points with the `getMarkerIdAt` method.
24414 * To retrive and use the marker component
24418 * var viewer = new Mapillary.Viewer(
24422 * { component: { marker: true } });
24424 * var markerComponent = viewer.getComponent("marker");
24427 var MarkerComponent = /** @class */ (function (_super) {
24428 __extends(MarkerComponent, _super);
24430 function MarkerComponent(name, container, navigator) {
24431 var _this = _super.call(this, name, container, navigator) || this;
24432 _this._relativeGroundAltitude = -2;
24433 _this._geoCoords = new Geo_1.GeoCoords();
24434 _this._graphCalculator = new Graph_1.GraphCalculator();
24435 _this._markerScene = new Component_1.MarkerScene();
24436 _this._markerSet = new Component_1.MarkerSet();
24437 _this._viewportCoords = new Geo_1.ViewportCoords();
24441 * Add markers to the marker set or replace markers in the marker set.
24443 * @description If a marker already in the set has the same
24444 * id as one of the markers added, the old marker will be removed
24445 * the added marker will take its place.
24447 * Any marker inside the visible bounding bbox
24448 * will be initialized and placed in the viewer.
24450 * @param {Array<Marker>} markers - Markers to add.
24452 * @example ```markerComponent.add([marker1, marker2]);```
24454 MarkerComponent.prototype.add = function (markers) {
24455 this._markerSet.add(markers);
24458 * Returns the marker in the marker set with the specified id, or
24459 * undefined if the id matches no marker.
24461 * @param {string} markerId - Id of the marker.
24463 * @example ```var marker = markerComponent.get("markerId");```
24466 MarkerComponent.prototype.get = function (markerId) {
24467 return this._markerSet.get(markerId);
24470 * Returns an array of all markers.
24472 * @example ```var markers = markerComponent.getAll();```
24474 MarkerComponent.prototype.getAll = function () {
24475 return this._markerSet.getAll();
24478 * Returns the id of the interactive marker closest to the current camera
24479 * position at the specified point.
24481 * @description Notice that the pixelPoint argument requires x, y
24482 * coordinates from pixel space.
24484 * With this function, you can use the coordinates provided by mouse
24485 * events to get information out of the marker component.
24487 * If no interactive geometry of an interactive marker exist at the pixel
24488 * point, `null` will be returned.
24490 * @param {Array<number>} pixelPoint - Pixel coordinates on the viewer element.
24491 * @returns {string} Id of the interactive marker closest to the camera. If no
24492 * interactive marker exist at the pixel point, `null` will be returned.
24496 * markerComponent.getMarkerIdAt([100, 100])
24497 * .then((markerId) => { console.log(markerId); });
24500 MarkerComponent.prototype.getMarkerIdAt = function (pixelPoint) {
24502 return when.promise(function (resolve, reject) {
24503 _this._container.renderService.renderCamera$.pipe(operators_1.first(), operators_1.map(function (render) {
24504 var viewport = _this._viewportCoords
24505 .canvasToViewport(pixelPoint[0], pixelPoint[1], _this._container.element);
24506 var id = _this._markerScene.intersectObjects(viewport, render.perspective);
24509 .subscribe(function (id) {
24511 }, function (error) {
24517 * Check if a marker exist in the marker set.
24519 * @param {string} markerId - Id of the marker.
24521 * @example ```var markerExists = markerComponent.has("markerId");```
24523 MarkerComponent.prototype.has = function (markerId) {
24524 return this._markerSet.has(markerId);
24527 * Remove markers with the specified ids from the marker set.
24529 * @param {Array<string>} markerIds - Ids for markers to remove.
24531 * @example ```markerComponent.remove(["id-1", "id-2"]);```
24533 MarkerComponent.prototype.remove = function (markerIds) {
24534 this._markerSet.remove(markerIds);
24537 * Remove all markers from the marker set.
24539 * @example ```markerComponent.removeAll();```
24541 MarkerComponent.prototype.removeAll = function () {
24542 this._markerSet.removeAll();
24544 MarkerComponent.prototype._activate = function () {
24546 var groundAltitude$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
24547 return frame.state.camera.position.z + _this._relativeGroundAltitude;
24548 }), operators_1.distinctUntilChanged(function (a1, a2) {
24549 return Math.abs(a1 - a2) < 0.01;
24550 }), operators_1.publishReplay(1), operators_1.refCount());
24551 var geoInitiated$ = rxjs_1.combineLatest(groundAltitude$, this._navigator.stateService.reference$).pipe(operators_1.first(), operators_1.map(function () { }), operators_1.publishReplay(1), operators_1.refCount());
24552 var clampedConfiguration$ = this._configuration$.pipe(operators_1.map(function (configuration) {
24553 return { visibleBBoxSize: Math.max(1, Math.min(200, configuration.visibleBBoxSize)) };
24555 var currentlatLon$ = this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) { return node.latLon; }), operators_1.publishReplay(1), operators_1.refCount());
24556 var visibleBBox$ = rxjs_1.combineLatest(clampedConfiguration$, currentlatLon$).pipe(operators_1.map(function (_a) {
24557 var configuration = _a[0], latLon = _a[1];
24558 return _this._graphCalculator
24559 .boundingBoxCorners(latLon, configuration.visibleBBoxSize / 2);
24560 }), operators_1.publishReplay(1), operators_1.refCount());
24561 var visibleMarkers$ = rxjs_1.combineLatest(rxjs_1.concat(rxjs_1.of(this._markerSet), this._markerSet.changed$), visibleBBox$).pipe(operators_1.map(function (_a) {
24562 var set = _a[0], bbox = _a[1];
24563 return set.search(bbox);
24565 this._setChangedSubscription = geoInitiated$.pipe(operators_1.switchMap(function () {
24566 return visibleMarkers$.pipe(operators_1.withLatestFrom(_this._navigator.stateService.reference$, groundAltitude$));
24568 .subscribe(function (_a) {
24569 var markers = _a[0], reference = _a[1], alt = _a[2];
24570 var geoCoords = _this._geoCoords;
24571 var markerScene = _this._markerScene;
24572 var sceneMarkers = markerScene.markers;
24573 var markersToRemove = Object.assign({}, sceneMarkers);
24574 for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
24575 var marker = markers_1[_i];
24576 if (marker.id in sceneMarkers) {
24577 delete markersToRemove[marker.id];
24580 var point3d = geoCoords
24581 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
24582 markerScene.add(marker, point3d);
24585 for (var id in markersToRemove) {
24586 if (!markersToRemove.hasOwnProperty(id)) {
24589 markerScene.remove(id);
24592 this._markersUpdatedSubscription = geoInitiated$.pipe(operators_1.switchMap(function () {
24593 return _this._markerSet.updated$.pipe(operators_1.withLatestFrom(visibleBBox$, _this._navigator.stateService.reference$, groundAltitude$));
24595 .subscribe(function (_a) {
24596 var markers = _a[0], _b = _a[1], sw = _b[0], ne = _b[1], reference = _a[2], alt = _a[3];
24597 var geoCoords = _this._geoCoords;
24598 var markerScene = _this._markerScene;
24599 for (var _i = 0, markers_2 = markers; _i < markers_2.length; _i++) {
24600 var marker = markers_2[_i];
24601 var exists = markerScene.has(marker.id);
24602 var visible = marker.latLon.lat > sw.lat &&
24603 marker.latLon.lat < ne.lat &&
24604 marker.latLon.lon > sw.lon &&
24605 marker.latLon.lon < ne.lon;
24607 var point3d = geoCoords
24608 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
24609 markerScene.add(marker, point3d);
24611 else if (!visible && exists) {
24612 markerScene.remove(marker.id);
24616 this._referenceSubscription = this._navigator.stateService.reference$.pipe(operators_1.skip(1), operators_1.withLatestFrom(groundAltitude$))
24617 .subscribe(function (_a) {
24618 var reference = _a[0], alt = _a[1];
24619 var geoCoords = _this._geoCoords;
24620 var markerScene = _this._markerScene;
24621 for (var _i = 0, _b = markerScene.getAll(); _i < _b.length; _i++) {
24622 var marker = _b[_i];
24623 var point3d = geoCoords
24624 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
24625 markerScene.update(marker.id, point3d);
24628 this._adjustHeightSubscription = groundAltitude$.pipe(operators_1.skip(1), operators_1.withLatestFrom(this._navigator.stateService.reference$, currentlatLon$))
24629 .subscribe(function (_a) {
24630 var alt = _a[0], reference = _a[1], latLon = _a[2];
24631 var geoCoords = _this._geoCoords;
24632 var markerScene = _this._markerScene;
24633 var position = geoCoords
24634 .geodeticToEnu(latLon.lat, latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
24635 for (var _i = 0, _b = markerScene.getAll(); _i < _b.length; _i++) {
24636 var marker = _b[_i];
24637 var point3d = geoCoords
24638 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
24639 var distanceX = point3d[0] - position[0];
24640 var distanceY = point3d[1] - position[1];
24641 var groundDistance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
24642 if (groundDistance > 50) {
24645 markerScene.lerpAltitude(marker.id, alt, Math.min(1, Math.max(0, 1.2 - 1.2 * groundDistance / 50)));
24648 this._renderSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
24649 var scene = _this._markerScene;
24654 needsRender: scene.needsRender,
24655 render: scene.render.bind(scene),
24656 stage: Render_1.GLRenderStage.Foreground,
24660 .subscribe(this._container.glRenderer.render$);
24661 var hoveredMarkerId$ = rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._container.mouseService.mouseMove$).pipe(operators_1.map(function (_a) {
24662 var render = _a[0], event = _a[1];
24663 var element = _this._container.element;
24664 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
24665 var viewport = _this._viewportCoords.canvasToViewport(canvasX, canvasY, element);
24666 var markerId = _this._markerScene.intersectObjects(viewport, render.perspective);
24668 }), operators_1.publishReplay(1), operators_1.refCount());
24669 var draggingStarted$ = this._container.mouseService
24670 .filtered$(this._name, this._container.mouseService.mouseDragStart$).pipe(operators_1.map(function (event) {
24673 var draggingStopped$ = this._container.mouseService
24674 .filtered$(this._name, this._container.mouseService.mouseDragEnd$).pipe(operators_1.map(function (event) {
24677 var filteredDragging$ = rxjs_1.merge(draggingStarted$, draggingStopped$).pipe(operators_1.startWith(false));
24678 this._dragEventSubscription = rxjs_1.merge(draggingStarted$.pipe(operators_1.withLatestFrom(hoveredMarkerId$)), rxjs_1.combineLatest(draggingStopped$, rxjs_1.of(null))).pipe(operators_1.startWith([false, null]), operators_1.pairwise())
24679 .subscribe(function (_a) {
24680 var previous = _a[0], current = _a[1];
24681 var dragging = current[0];
24682 var eventType = dragging ? MarkerComponent.dragstart : MarkerComponent.dragend;
24683 var id = dragging ? current[1] : previous[1];
24684 var marker = _this._markerScene.get(id);
24685 var markerEvent = { marker: marker, target: _this, type: eventType };
24686 _this.fire(eventType, markerEvent);
24688 var mouseDown$ = rxjs_1.merge(this._container.mouseService.mouseDown$.pipe(operators_1.map(function (event) { return true; })), this._container.mouseService.documentMouseUp$.pipe(operators_1.map(function (event) { return false; }))).pipe(operators_1.startWith(false));
24689 this._mouseClaimSubscription = rxjs_1.combineLatest(this._container.mouseService.active$, hoveredMarkerId$.pipe(operators_1.distinctUntilChanged()), mouseDown$, filteredDragging$).pipe(operators_1.map(function (_a) {
24690 var active = _a[0], markerId = _a[1], mouseDown = _a[2], filteredDragging = _a[3];
24691 return (!active && markerId != null && mouseDown) || filteredDragging;
24692 }), operators_1.distinctUntilChanged())
24693 .subscribe(function (claim) {
24695 _this._container.mouseService.claimMouse(_this._name, 1);
24696 _this._container.mouseService.claimWheel(_this._name, 1);
24699 _this._container.mouseService.unclaimMouse(_this._name);
24700 _this._container.mouseService.unclaimWheel(_this._name);
24703 var offset$ = this._container.mouseService
24704 .filtered$(this._name, this._container.mouseService.mouseDragStart$).pipe(operators_1.withLatestFrom(hoveredMarkerId$, this._container.renderService.renderCamera$), operators_1.map(function (_a) {
24705 var e = _a[0], id = _a[1], r = _a[2];
24706 var marker = _this._markerScene.get(id);
24707 var element = _this._container.element;
24708 var _b = _this._viewportCoords.projectToCanvas(marker.geometry.position.toArray(), element, r.perspective), groundCanvasX = _b[0], groundCanvasY = _b[1];
24709 var _c = _this._viewportCoords.canvasPosition(e, element), canvasX = _c[0], canvasY = _c[1];
24710 var offset = [canvasX - groundCanvasX, canvasY - groundCanvasY];
24711 return [marker, offset, r];
24712 }), operators_1.publishReplay(1), operators_1.refCount());
24713 this._updateMarkerSubscription = this._container.mouseService
24714 .filtered$(this._name, this._container.mouseService.mouseDrag$).pipe(operators_1.withLatestFrom(offset$, this._navigator.stateService.reference$, clampedConfiguration$))
24715 .subscribe(function (_a) {
24716 var event = _a[0], _b = _a[1], marker = _b[0], offset = _b[1], render = _b[2], reference = _a[2], configuration = _a[3];
24717 if (!_this._markerScene.has(marker.id)) {
24720 var element = _this._container.element;
24721 var _c = _this._viewportCoords.canvasPosition(event, element), canvasX = _c[0], canvasY = _c[1];
24722 var groundX = canvasX - offset[0];
24723 var groundY = canvasY - offset[1];
24724 var _d = _this._viewportCoords
24725 .canvasToViewport(groundX, groundY, element), viewportX = _d[0], viewportY = _d[1];
24726 var direction = new THREE.Vector3(viewportX, viewportY, 1)
24727 .unproject(render.perspective)
24728 .sub(render.perspective.position)
24730 var distance = Math.min(_this._relativeGroundAltitude / direction.z, configuration.visibleBBoxSize / 2 - 0.1);
24731 if (distance < 0) {
24734 var intersection = direction
24736 .multiplyScalar(distance)
24737 .add(render.perspective.position);
24738 intersection.z = render.perspective.position.z + _this._relativeGroundAltitude;
24739 var _e = _this._geoCoords
24740 .enuToGeodetic(intersection.x, intersection.y, intersection.z, reference.lat, reference.lon, reference.alt), lat = _e[0], lon = _e[1];
24741 _this._markerScene.update(marker.id, intersection.toArray(), { lat: lat, lon: lon });
24742 _this._markerSet.update(marker);
24743 var markerEvent = { marker: marker, target: _this, type: MarkerComponent.changed };
24744 _this.fire(MarkerComponent.changed, markerEvent);
24747 MarkerComponent.prototype._deactivate = function () {
24748 this._adjustHeightSubscription.unsubscribe();
24749 this._dragEventSubscription.unsubscribe();
24750 this._markersUpdatedSubscription.unsubscribe();
24751 this._mouseClaimSubscription.unsubscribe();
24752 this._referenceSubscription.unsubscribe();
24753 this._renderSubscription.unsubscribe();
24754 this._setChangedSubscription.unsubscribe();
24755 this._updateMarkerSubscription.unsubscribe();
24756 this._markerScene.clear();
24758 MarkerComponent.prototype._getDefaultConfiguration = function () {
24759 return { visibleBBoxSize: 100 };
24761 MarkerComponent.componentName = "marker";
24763 * Fired when the position of a marker is changed.
24765 * @type {IMarkerEvent} markerEvent - Marker event data.
24768 * markerComponent.on("changed", function(e) {
24769 * console.log(e.marker.id, e.marker.latLon);
24773 MarkerComponent.changed = "changed";
24775 * Fired when a marker drag interaction starts.
24777 * @type {IMarkerEvent} markerEvent - Marker event data.
24780 * markerComponent.on("dragstart", function(e) {
24781 * console.log(e.marker.id, e.marker.latLon);
24785 MarkerComponent.dragstart = "dragstart";
24787 * Fired when a marker drag interaction ends.
24789 * @type {IMarkerEvent} markerEvent - Marker event data.
24792 * markerComponent.on("dragend", function(e) {
24793 * console.log(e.marker.id, e.marker.latLon);
24797 MarkerComponent.dragend = "dragend";
24798 return MarkerComponent;
24799 }(Component_1.Component));
24800 exports.MarkerComponent = MarkerComponent;
24801 Component_1.ComponentService.register(MarkerComponent);
24802 exports.default = MarkerComponent;
24805 },{"../../Component":274,"../../Geo":277,"../../Graph":278,"../../Render":280,"rxjs":26,"rxjs/operators":224,"three":225,"when":271}],316:[function(require,module,exports){
24807 Object.defineProperty(exports, "__esModule", { value: true });
24808 var THREE = require("three");
24809 var MarkerScene = /** @class */ (function () {
24810 function MarkerScene(scene, raycaster) {
24811 this._needsRender = false;
24812 this._interactiveObjects = [];
24813 this._markers = {};
24814 this._objectMarkers = {};
24815 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster();
24816 this._scene = !!scene ? scene : new THREE.Scene();
24818 Object.defineProperty(MarkerScene.prototype, "markers", {
24820 return this._markers;
24825 Object.defineProperty(MarkerScene.prototype, "needsRender", {
24827 return this._needsRender;
24832 MarkerScene.prototype.add = function (marker, position) {
24833 if (marker.id in this._markers) {
24834 this._dispose(marker.id);
24836 marker.createGeometry(position);
24837 this._scene.add(marker.geometry);
24838 this._markers[marker.id] = marker;
24839 for (var _i = 0, _a = marker.getInteractiveObjects(); _i < _a.length; _i++) {
24840 var interactiveObject = _a[_i];
24841 this._interactiveObjects.push(interactiveObject);
24842 this._objectMarkers[interactiveObject.uuid] = marker.id;
24844 this._needsRender = true;
24846 MarkerScene.prototype.clear = function () {
24847 for (var id in this._markers) {
24848 if (!this._markers.hasOwnProperty) {
24853 this._needsRender = true;
24855 MarkerScene.prototype.get = function (id) {
24856 return this._markers[id];
24858 MarkerScene.prototype.getAll = function () {
24861 .keys(this._markers)
24862 .map(function (id) { return _this._markers[id]; });
24864 MarkerScene.prototype.has = function (id) {
24865 return id in this._markers;
24867 MarkerScene.prototype.intersectObjects = function (_a, camera) {
24868 var viewportX = _a[0], viewportY = _a[1];
24869 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
24870 var intersects = this._raycaster.intersectObjects(this._interactiveObjects);
24871 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
24872 var intersect = intersects_1[_i];
24873 if (intersect.object.uuid in this._objectMarkers) {
24874 return this._objectMarkers[intersect.object.uuid];
24879 MarkerScene.prototype.lerpAltitude = function (id, alt, alpha) {
24880 if (!(id in this._markers)) {
24883 this._markers[id].lerpAltitude(alt, alpha);
24884 this._needsRender = true;
24886 MarkerScene.prototype.remove = function (id) {
24887 if (!(id in this._markers)) {
24891 this._needsRender = true;
24893 MarkerScene.prototype.render = function (perspectiveCamera, renderer) {
24894 renderer.render(this._scene, perspectiveCamera);
24895 this._needsRender = false;
24897 MarkerScene.prototype.update = function (id, position, latLon) {
24898 if (!(id in this._markers)) {
24901 var marker = this._markers[id];
24902 marker.updatePosition(position, latLon);
24903 this._needsRender = true;
24905 MarkerScene.prototype._dispose = function (id) {
24906 var marker = this._markers[id];
24907 this._scene.remove(marker.geometry);
24908 for (var _i = 0, _a = marker.getInteractiveObjects(); _i < _a.length; _i++) {
24909 var interactiveObject = _a[_i];
24910 var index = this._interactiveObjects.indexOf(interactiveObject);
24911 if (index !== -1) {
24912 this._interactiveObjects.splice(index, 1);
24915 console.warn("Object does not exist (" + interactiveObject.id + ") for " + id);
24917 delete this._objectMarkers[interactiveObject.uuid];
24919 marker.disposeGeometry();
24920 delete this._markers[id];
24922 return MarkerScene;
24924 exports.MarkerScene = MarkerScene;
24925 exports.default = MarkerScene;
24927 },{"three":225}],317:[function(require,module,exports){
24929 Object.defineProperty(exports, "__esModule", { value: true });
24930 var rbush = require("rbush");
24931 var rxjs_1 = require("rxjs");
24932 var MarkerSet = /** @class */ (function () {
24933 function MarkerSet() {
24935 this._index = rbush(16, [".lon", ".lat", ".lon", ".lat"]);
24936 this._indexChanged$ = new rxjs_1.Subject();
24937 this._updated$ = new rxjs_1.Subject();
24939 Object.defineProperty(MarkerSet.prototype, "changed$", {
24941 return this._indexChanged$;
24946 Object.defineProperty(MarkerSet.prototype, "updated$", {
24948 return this._updated$;
24953 MarkerSet.prototype.add = function (markers) {
24955 var hash = this._hash;
24956 var index = this._index;
24957 for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
24958 var marker = markers_1[_i];
24959 var id = marker.id;
24961 index.remove(hash[id]);
24962 updated.push(marker);
24965 lat: marker.latLon.lat,
24966 lon: marker.latLon.lon,
24970 index.insert(item);
24972 if (updated.length > 0) {
24973 this._updated$.next(updated);
24975 if (markers.length > updated.length) {
24976 this._indexChanged$.next(this);
24979 MarkerSet.prototype.has = function (id) {
24980 return id in this._hash;
24982 MarkerSet.prototype.get = function (id) {
24983 return this.has(id) ? this._hash[id].marker : undefined;
24985 MarkerSet.prototype.getAll = function () {
24988 .map(function (indexItem) {
24989 return indexItem.marker;
24992 MarkerSet.prototype.remove = function (ids) {
24993 var hash = this._hash;
24994 var index = this._index;
24995 var changed = false;
24996 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
24997 var id = ids_1[_i];
24998 if (!(id in hash)) {
25001 var item = hash[id];
25002 index.remove(item);
25007 this._indexChanged$.next(this);
25010 MarkerSet.prototype.removeAll = function () {
25012 this._index.clear();
25013 this._indexChanged$.next(this);
25015 MarkerSet.prototype.search = function (_a) {
25016 var sw = _a[0], ne = _a[1];
25018 .search({ maxX: ne.lon, maxY: ne.lat, minX: sw.lon, minY: sw.lat })
25019 .map(function (indexItem) {
25020 return indexItem.marker;
25023 MarkerSet.prototype.update = function (marker) {
25024 var hash = this._hash;
25025 var index = this._index;
25026 var id = marker.id;
25027 if (!(id in hash)) {
25030 index.remove(hash[id]);
25032 lat: marker.latLon.lat,
25033 lon: marker.latLon.lon,
25037 index.insert(item);
25041 exports.MarkerSet = MarkerSet;
25042 exports.default = MarkerSet;
25044 },{"rbush":25,"rxjs":26}],318:[function(require,module,exports){
25046 var __extends = (this && this.__extends) || (function () {
25047 var extendStatics = function (d, b) {
25048 extendStatics = Object.setPrototypeOf ||
25049 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25050 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25051 return extendStatics(d, b);
25053 return function (d, b) {
25054 extendStatics(d, b);
25055 function __() { this.constructor = d; }
25056 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25059 Object.defineProperty(exports, "__esModule", { value: true });
25060 var THREE = require("three");
25061 var Component_1 = require("../../../Component");
25063 * @class CircleMarker
25065 * @classdesc Non-interactive marker with a flat circle shape. The circle
25066 * marker can not be configured to be interactive.
25068 * Circle marker properties can not be updated after creation.
25070 * To create and add one `CircleMarker` with default configuration
25071 * and one with configuration use
25075 * var defaultMarker = new Mapillary.MarkerComponent.CircleMarker(
25077 * { lat: 0, lon: 0, });
25079 * var configuredMarker = new Mapillary.MarkerComponent.CircleMarker(
25081 * { lat: 0, lon: 0, },
25088 * markerComponent.add([defaultMarker, configuredMarker]);
25091 var CircleMarker = /** @class */ (function (_super) {
25092 __extends(CircleMarker, _super);
25093 function CircleMarker(id, latLon, options) {
25094 var _this = _super.call(this, id, latLon) || this;
25095 options = !!options ? options : {};
25096 _this._color = options.color != null ? options.color : 0xffffff;
25097 _this._opacity = options.opacity != null ? options.opacity : 0.4;
25098 _this._radius = options.radius != null ? options.radius : 1;
25101 CircleMarker.prototype._createGeometry = function (position) {
25102 var circle = new THREE.Mesh(new THREE.CircleGeometry(this._radius, 16), new THREE.MeshBasicMaterial({
25103 color: this._color,
25104 opacity: this._opacity,
25107 circle.up.fromArray([0, 0, 1]);
25108 circle.renderOrder = -1;
25109 var group = new THREE.Object3D();
25111 group.position.fromArray(position);
25112 this._geometry = group;
25114 CircleMarker.prototype._disposeGeometry = function () {
25115 for (var _i = 0, _a = this._geometry.children; _i < _a.length; _i++) {
25117 mesh.geometry.dispose();
25118 mesh.material.dispose();
25121 CircleMarker.prototype._getInteractiveObjects = function () {
25124 return CircleMarker;
25125 }(Component_1.Marker));
25126 exports.CircleMarker = CircleMarker;
25127 exports.default = CircleMarker;
25129 },{"../../../Component":274,"three":225}],319:[function(require,module,exports){
25131 Object.defineProperty(exports, "__esModule", { value: true });
25135 * @classdesc Represents an abstract marker class that should be extended
25136 * by marker implementations used in the marker component.
25138 var Marker = /** @class */ (function () {
25139 function Marker(id, latLon) {
25141 this._latLon = latLon;
25143 Object.defineProperty(Marker.prototype, "id", {
25146 * @returns {string} The id of the marker.
25154 Object.defineProperty(Marker.prototype, "geometry", {
25161 return this._geometry;
25166 Object.defineProperty(Marker.prototype, "latLon", {
25169 * @returns {ILatLon} The geographic coordinates of the marker.
25172 return this._latLon;
25178 Marker.prototype.createGeometry = function (position) {
25179 if (!!this._geometry) {
25182 this._createGeometry(position);
25183 // update matrix world if raycasting occurs before first render
25184 this._geometry.updateMatrixWorld(true);
25187 Marker.prototype.disposeGeometry = function () {
25188 if (!this._geometry) {
25191 this._disposeGeometry();
25192 this._geometry = undefined;
25195 Marker.prototype.getInteractiveObjects = function () {
25196 if (!this._geometry) {
25199 return this._getInteractiveObjects();
25202 Marker.prototype.lerpAltitude = function (alt, alpha) {
25203 if (!this._geometry) {
25206 this._geometry.position.z = (1 - alpha) * this._geometry.position.z + alpha * alt;
25209 Marker.prototype.updatePosition = function (position, latLon) {
25211 this._latLon.lat = latLon.lat;
25212 this._latLon.lon = latLon.lon;
25214 if (!this._geometry) {
25217 this._geometry.position.fromArray(position);
25218 this._geometry.updateMatrixWorld(true);
25222 exports.Marker = Marker;
25223 exports.default = Marker;
25225 },{}],320:[function(require,module,exports){
25227 var __extends = (this && this.__extends) || (function () {
25228 var extendStatics = function (d, b) {
25229 extendStatics = Object.setPrototypeOf ||
25230 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25231 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25232 return extendStatics(d, b);
25234 return function (d, b) {
25235 extendStatics(d, b);
25236 function __() { this.constructor = d; }
25237 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25240 Object.defineProperty(exports, "__esModule", { value: true });
25241 var THREE = require("three");
25242 var Component_1 = require("../../../Component");
25244 * @class SimpleMarker
25246 * @classdesc Interactive marker with ice cream shape. The sphere
25247 * inside the ice cream can be configured to be interactive.
25249 * Simple marker properties can not be updated after creation.
25251 * To create and add one `SimpleMarker` with default configuration
25252 * (non-interactive) and one interactive with configuration use
25256 * var defaultMarker = new Mapillary.MarkerComponent.SimpleMarker(
25258 * { lat: 0, lon: 0, });
25260 * var interactiveMarker = new Mapillary.MarkerComponent.SimpleMarker(
25262 * { lat: 0, lon: 0, },
25264 * ballColor: "#00f",
25265 * ballOpacity: 0.5,
25267 * interactive: true,
25272 * markerComponent.add([defaultMarker, interactiveMarker]);
25275 var SimpleMarker = /** @class */ (function (_super) {
25276 __extends(SimpleMarker, _super);
25277 function SimpleMarker(id, latLon, options) {
25278 var _this = _super.call(this, id, latLon) || this;
25279 options = !!options ? options : {};
25280 _this._ballColor = options.ballColor != null ? options.ballColor : 0xff0000;
25281 _this._ballOpacity = options.ballOpacity != null ? options.ballOpacity : 0.8;
25282 _this._circleToRayAngle = 2;
25283 _this._color = options.color != null ? options.color : 0xff0000;
25284 _this._interactive = !!options.interactive;
25285 _this._opacity = options.opacity != null ? options.opacity : 0.4;
25286 _this._radius = options.radius != null ? options.radius : 1;
25289 SimpleMarker.prototype._createGeometry = function (position) {
25290 var radius = this._radius;
25291 var cone = new THREE.Mesh(this._markerGeometry(radius, 8, 8), new THREE.MeshBasicMaterial({
25292 color: this._color,
25293 opacity: this._opacity,
25296 cone.renderOrder = 1;
25297 var ball = new THREE.Mesh(new THREE.SphereGeometry(radius / 2, 8, 8), new THREE.MeshBasicMaterial({
25298 color: this._ballColor,
25299 opacity: this._ballOpacity,
25302 ball.position.z = this._markerHeight(radius);
25303 var group = new THREE.Object3D();
25306 group.position.fromArray(position);
25307 this._geometry = group;
25309 SimpleMarker.prototype._disposeGeometry = function () {
25310 for (var _i = 0, _a = this._geometry.children; _i < _a.length; _i++) {
25312 mesh.geometry.dispose();
25313 mesh.material.dispose();
25316 SimpleMarker.prototype._getInteractiveObjects = function () {
25317 return this._interactive ? [this._geometry.children[0]] : [];
25319 SimpleMarker.prototype._markerHeight = function (radius) {
25320 var t = Math.tan(Math.PI - this._circleToRayAngle);
25321 return radius * Math.sqrt(1 + t * t);
25323 SimpleMarker.prototype._markerGeometry = function (radius, widthSegments, heightSegments) {
25324 var geometry = new THREE.Geometry();
25325 widthSegments = Math.max(3, Math.floor(widthSegments) || 8);
25326 heightSegments = Math.max(2, Math.floor(heightSegments) || 6);
25327 var height = this._markerHeight(radius);
25329 for (var y = 0; y <= heightSegments; ++y) {
25330 var verticesRow = [];
25331 for (var x = 0; x <= widthSegments; ++x) {
25332 var u = x / widthSegments * Math.PI * 2;
25333 var v = y / heightSegments * Math.PI;
25335 if (v < this._circleToRayAngle) {
25339 var t = Math.tan(v - this._circleToRayAngle);
25340 r = radius * Math.sqrt(1 + t * t);
25342 var vertex = new THREE.Vector3();
25343 vertex.x = r * Math.cos(u) * Math.sin(v);
25344 vertex.y = r * Math.sin(u) * Math.sin(v);
25345 vertex.z = r * Math.cos(v) + height;
25346 geometry.vertices.push(vertex);
25347 verticesRow.push(geometry.vertices.length - 1);
25349 vertices.push(verticesRow);
25351 for (var y = 0; y < heightSegments; ++y) {
25352 for (var x = 0; x < widthSegments; ++x) {
25353 var v1 = vertices[y][x + 1];
25354 var v2 = vertices[y][x];
25355 var v3 = vertices[y + 1][x];
25356 var v4 = vertices[y + 1][x + 1];
25357 var n1 = geometry.vertices[v1].clone().normalize();
25358 var n2 = geometry.vertices[v2].clone().normalize();
25359 var n3 = geometry.vertices[v3].clone().normalize();
25360 var n4 = geometry.vertices[v4].clone().normalize();
25361 geometry.faces.push(new THREE.Face3(v1, v2, v4, [n1, n2, n4]));
25362 geometry.faces.push(new THREE.Face3(v2, v3, v4, [n2.clone(), n3, n4.clone()]));
25365 geometry.computeFaceNormals();
25366 geometry.boundingSphere = new THREE.Sphere(new THREE.Vector3(), radius + height);
25369 return SimpleMarker;
25370 }(Component_1.Marker));
25371 exports.SimpleMarker = SimpleMarker;
25372 exports.default = SimpleMarker;
25374 },{"../../../Component":274,"three":225}],321:[function(require,module,exports){
25376 var __extends = (this && this.__extends) || (function () {
25377 var extendStatics = function (d, b) {
25378 extendStatics = Object.setPrototypeOf ||
25379 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25380 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25381 return extendStatics(d, b);
25383 return function (d, b) {
25384 extendStatics(d, b);
25385 function __() { this.constructor = d; }
25386 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25389 Object.defineProperty(exports, "__esModule", { value: true });
25390 var rxjs_1 = require("rxjs");
25391 var operators_1 = require("rxjs/operators");
25392 var Component_1 = require("../../Component");
25394 * The `BounceHandler` ensures that the viewer bounces back to the image
25395 * when drag panning outside of the image edge.
25397 var BounceHandler = /** @class */ (function (_super) {
25398 __extends(BounceHandler, _super);
25399 function BounceHandler(component, container, navigator, viewportCoords, spatial) {
25400 var _this = _super.call(this, component, container, navigator) || this;
25401 _this._spatial = spatial;
25402 _this._viewportCoords = viewportCoords;
25405 BounceHandler.prototype._enable = function () {
25407 var inTransition$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
25408 return frame.state.alpha < 1;
25410 this._bounceSubscription = rxjs_1.combineLatest(inTransition$, this._navigator.stateService.inTranslation$, this._container.mouseService.active$, this._container.touchService.active$).pipe(operators_1.map(function (noForce) {
25411 return noForce[0] || noForce[1] || noForce[2] || noForce[3];
25412 }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (noForce) {
25415 rxjs_1.combineLatest(_this._container.renderService.renderCamera$, _this._navigator.stateService.currentTransform$.pipe(operators_1.first()));
25417 .subscribe(function (_a) {
25418 var render = _a[0], transform = _a[1];
25419 if (!transform.hasValidScale && render.camera.focal < 0.1) {
25422 if (render.perspective.aspect === 0 || render.perspective.aspect === Number.POSITIVE_INFINITY) {
25425 var distances = Component_1.ImageBoundary.viewportDistances(transform, render.perspective, _this._viewportCoords);
25426 if (Math.max.apply(Math, distances) < 0.01) {
25429 var horizontalDistance = distances[1] - distances[3];
25430 var verticalDistance = distances[0] - distances[2];
25431 var currentDirection = _this._viewportCoords
25432 .unprojectFromViewport(0, 0, render.perspective)
25433 .sub(render.perspective.position);
25434 var directionPhi = _this._viewportCoords
25435 .unprojectFromViewport(horizontalDistance, 0, render.perspective)
25436 .sub(render.perspective.position);
25437 var directionTheta = _this._viewportCoords
25438 .unprojectFromViewport(0, verticalDistance, render.perspective)
25439 .sub(render.perspective.position);
25440 var phi = (horizontalDistance > 0 ? 1 : -1) * directionPhi.angleTo(currentDirection);
25441 var theta = (verticalDistance > 0 ? 1 : -1) * directionTheta.angleTo(currentDirection);
25442 var threshold = Math.PI / 60;
25444 phi = _this._spatial.clamp(coeff * phi, -threshold, threshold);
25445 theta = _this._spatial.clamp(coeff * theta, -threshold, threshold);
25446 _this._navigator.stateService.rotateUnbounded({ phi: phi, theta: theta });
25449 BounceHandler.prototype._disable = function () {
25450 this._bounceSubscription.unsubscribe();
25452 BounceHandler.prototype._getConfiguration = function () {
25455 return BounceHandler;
25456 }(Component_1.HandlerBase));
25457 exports.BounceHandler = BounceHandler;
25458 exports.default = BounceHandler;
25460 },{"../../Component":274,"rxjs":26,"rxjs/operators":224}],322:[function(require,module,exports){
25462 var __extends = (this && this.__extends) || (function () {
25463 var extendStatics = function (d, b) {
25464 extendStatics = Object.setPrototypeOf ||
25465 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25466 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25467 return extendStatics(d, b);
25469 return function (d, b) {
25470 extendStatics(d, b);
25471 function __() { this.constructor = d; }
25472 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25475 Object.defineProperty(exports, "__esModule", { value: true });
25476 var rxjs_1 = require("rxjs");
25477 var operators_1 = require("rxjs/operators");
25478 var Component_1 = require("../../Component");
25480 * The `DoubleClickZoomHandler` allows the user to zoom the viewer image at a point by double clicking.
25484 * var mouseComponent = viewer.getComponent("mouse");
25486 * mouseComponent.doubleClickZoom.disable();
25487 * mouseComponent.doubleClickZoom.enable();
25489 * var isEnabled = mouseComponent.doubleClickZoom.isEnabled;
25492 var DoubleClickZoomHandler = /** @class */ (function (_super) {
25493 __extends(DoubleClickZoomHandler, _super);
25495 function DoubleClickZoomHandler(component, container, navigator, viewportCoords) {
25496 var _this = _super.call(this, component, container, navigator) || this;
25497 _this._viewportCoords = viewportCoords;
25500 DoubleClickZoomHandler.prototype._enable = function () {
25502 this._zoomSubscription = rxjs_1.merge(this._container.mouseService
25503 .filtered$(this._component.name, this._container.mouseService.dblClick$), this._container.touchService.doubleTap$.pipe(operators_1.map(function (e) {
25504 var touch = e.touches[0];
25505 return { clientX: touch.clientX, clientY: touch.clientY, shiftKey: e.shiftKey };
25506 }))).pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
25507 .subscribe(function (_a) {
25508 var event = _a[0], render = _a[1], transform = _a[2];
25509 var element = _this._container.element;
25510 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
25511 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
25512 var reference = transform.projectBasic(unprojected.toArray());
25513 var delta = !!event.shiftKey ? -1 : 1;
25514 _this._navigator.stateService.zoomIn(delta, reference);
25517 DoubleClickZoomHandler.prototype._disable = function () {
25518 this._zoomSubscription.unsubscribe();
25520 DoubleClickZoomHandler.prototype._getConfiguration = function (enable) {
25521 return { doubleClickZoom: enable };
25523 return DoubleClickZoomHandler;
25524 }(Component_1.HandlerBase));
25525 exports.DoubleClickZoomHandler = DoubleClickZoomHandler;
25526 exports.default = DoubleClickZoomHandler;
25528 },{"../../Component":274,"rxjs":26,"rxjs/operators":224}],323:[function(require,module,exports){
25530 var __extends = (this && this.__extends) || (function () {
25531 var extendStatics = function (d, b) {
25532 extendStatics = Object.setPrototypeOf ||
25533 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25534 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25535 return extendStatics(d, b);
25537 return function (d, b) {
25538 extendStatics(d, b);
25539 function __() { this.constructor = d; }
25540 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25543 Object.defineProperty(exports, "__esModule", { value: true });
25544 var rxjs_1 = require("rxjs");
25545 var operators_1 = require("rxjs/operators");
25546 var Component_1 = require("../../Component");
25548 * The `DragPanHandler` allows the user to pan the viewer image by clicking and dragging the cursor.
25552 * var mouseComponent = viewer.getComponent("mouse");
25554 * mouseComponent.dragPan.disable();
25555 * mouseComponent.dragPan.enable();
25557 * var isEnabled = mouseComponent.dragPan.isEnabled;
25560 var DragPanHandler = /** @class */ (function (_super) {
25561 __extends(DragPanHandler, _super);
25563 function DragPanHandler(component, container, navigator, viewportCoords, spatial) {
25564 var _this = _super.call(this, component, container, navigator) || this;
25565 _this._spatial = spatial;
25566 _this._viewportCoords = viewportCoords;
25569 DragPanHandler.prototype._enable = function () {
25571 var draggingStarted$ = this._container.mouseService
25572 .filtered$(this._component.name, this._container.mouseService.mouseDragStart$).pipe(operators_1.map(function () {
25574 }), operators_1.share());
25575 var draggingStopped$ = this._container.mouseService
25576 .filtered$(this._component.name, this._container.mouseService.mouseDragEnd$).pipe(operators_1.map(function () {
25578 }), operators_1.share());
25579 this._activeMouseSubscription = rxjs_1.merge(draggingStarted$, draggingStopped$)
25580 .subscribe(this._container.mouseService.activate$);
25581 var documentMouseMove$ = rxjs_1.merge(draggingStarted$, draggingStopped$).pipe(operators_1.switchMap(function (dragging) {
25583 _this._container.mouseService.documentMouseMove$ :
25586 this._preventDefaultSubscription = rxjs_1.merge(documentMouseMove$, this._container.touchService.touchMove$)
25587 .subscribe(function (event) {
25588 event.preventDefault(); // prevent selection of content outside the viewer
25590 var touchMovingStarted$ = this._container.touchService.singleTouchDragStart$.pipe(operators_1.map(function () {
25593 var touchMovingStopped$ = this._container.touchService.singleTouchDragEnd$.pipe(operators_1.map(function () {
25596 this._activeTouchSubscription = rxjs_1.merge(touchMovingStarted$, touchMovingStopped$)
25597 .subscribe(this._container.touchService.activate$);
25598 var rotation$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
25599 return frame.state.currentNode.fullPano || frame.state.nodesAhead < 1;
25600 }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (enable) {
25602 return rxjs_1.empty();
25604 var mouseDrag$ = Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService);
25605 var singleTouchDrag$ = rxjs_1.merge(_this._container.touchService.singleTouchDragStart$, _this._container.touchService.singleTouchDrag$, _this._container.touchService.singleTouchDragEnd$.pipe(operators_1.map(function () { return null; }))).pipe(operators_1.map(function (event) {
25606 return event != null && event.touches.length > 0 ?
25607 event.touches[0] : null;
25608 }), operators_1.pairwise(), operators_1.filter(function (pair) {
25609 return pair[0] != null && pair[1] != null;
25611 return rxjs_1.merge(mouseDrag$, singleTouchDrag$);
25612 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
25613 var events = _a[0], render = _a[1], transform = _a[2];
25614 var previousEvent = events[0];
25615 var event = events[1];
25616 var movementX = event.clientX - previousEvent.clientX;
25617 var movementY = event.clientY - previousEvent.clientY;
25618 var element = _this._container.element;
25619 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
25620 var currentDirection = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective)
25621 .sub(render.perspective.position);
25622 var directionX = _this._viewportCoords.unprojectFromCanvas(canvasX - movementX, canvasY, element, render.perspective)
25623 .sub(render.perspective.position);
25624 var directionY = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY - movementY, element, render.perspective)
25625 .sub(render.perspective.position);
25626 var phi = (movementX > 0 ? 1 : -1) * directionX.angleTo(currentDirection);
25627 var theta = (movementY > 0 ? -1 : 1) * directionY.angleTo(currentDirection);
25628 var distances = Component_1.ImageBoundary.viewportDistances(transform, render.perspective, _this._viewportCoords);
25629 if (distances[0] > 0 && theta < 0) {
25630 theta /= Math.max(1, 2e2 * distances[0]);
25632 if (distances[2] > 0 && theta > 0) {
25633 theta /= Math.max(1, 2e2 * distances[2]);
25635 if (distances[1] > 0 && phi < 0) {
25636 phi /= Math.max(1, 2e2 * distances[1]);
25638 if (distances[3] > 0 && phi > 0) {
25639 phi /= Math.max(1, 2e2 * distances[3]);
25641 return { phi: phi, theta: theta };
25642 }), operators_1.share());
25643 this._rotateWithoutInertiaSubscription = rotation$
25644 .subscribe(function (rotation) {
25645 _this._navigator.stateService.rotateWithoutInertia(rotation);
25647 this._rotateSubscription = rotation$.pipe(operators_1.scan(function (rotationBuffer, rotation) {
25648 _this._drainBuffer(rotationBuffer);
25649 rotationBuffer.push([Date.now(), rotation]);
25650 return rotationBuffer;
25651 }, []), operators_1.sample(rxjs_1.merge(this._container.mouseService.filtered$(this._component.name, this._container.mouseService.mouseDragEnd$), this._container.touchService.singleTouchDragEnd$)), operators_1.map(function (rotationBuffer) {
25652 var drainedBuffer = _this._drainBuffer(rotationBuffer.slice());
25653 var rotation = { phi: 0, theta: 0 };
25654 for (var _i = 0, drainedBuffer_1 = drainedBuffer; _i < drainedBuffer_1.length; _i++) {
25655 var bufferedRotation = drainedBuffer_1[_i];
25656 rotation.phi += bufferedRotation[1].phi;
25657 rotation.theta += bufferedRotation[1].theta;
25659 var count = drainedBuffer.length;
25661 rotation.phi /= count;
25662 rotation.theta /= count;
25664 var threshold = Math.PI / 18;
25665 rotation.phi = _this._spatial.clamp(rotation.phi, -threshold, threshold);
25666 rotation.theta = _this._spatial.clamp(rotation.theta, -threshold, threshold);
25669 .subscribe(function (rotation) {
25670 _this._navigator.stateService.rotate(rotation);
25673 DragPanHandler.prototype._disable = function () {
25674 this._activeMouseSubscription.unsubscribe();
25675 this._activeTouchSubscription.unsubscribe();
25676 this._preventDefaultSubscription.unsubscribe();
25677 this._rotateSubscription.unsubscribe();
25678 this._rotateWithoutInertiaSubscription.unsubscribe();
25679 this._activeMouseSubscription = null;
25680 this._activeTouchSubscription = null;
25681 this._preventDefaultSubscription = null;
25682 this._rotateSubscription = null;
25684 DragPanHandler.prototype._getConfiguration = function (enable) {
25685 return { dragPan: enable };
25687 DragPanHandler.prototype._drainBuffer = function (buffer) {
25689 var now = Date.now();
25690 while (buffer.length > 0 && now - buffer[0][0] > cutoff) {
25695 return DragPanHandler;
25696 }(Component_1.HandlerBase));
25697 exports.DragPanHandler = DragPanHandler;
25698 exports.default = DragPanHandler;
25700 },{"../../Component":274,"rxjs":26,"rxjs/operators":224}],324:[function(require,module,exports){
25702 var __extends = (this && this.__extends) || (function () {
25703 var extendStatics = function (d, b) {
25704 extendStatics = Object.setPrototypeOf ||
25705 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25706 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25707 return extendStatics(d, b);
25709 return function (d, b) {
25710 extendStatics(d, b);
25711 function __() { this.constructor = d; }
25712 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25715 Object.defineProperty(exports, "__esModule", { value: true });
25716 var THREE = require("three");
25717 var rxjs_1 = require("rxjs");
25718 var operators_1 = require("rxjs/operators");
25719 var Component_1 = require("../../Component");
25720 var State_1 = require("../../State");
25721 var EarthControlHandler = /** @class */ (function (_super) {
25722 __extends(EarthControlHandler, _super);
25723 function EarthControlHandler(component, container, navigator, viewportCoords, spatial) {
25724 var _this = _super.call(this, component, container, navigator) || this;
25725 _this._spatial = spatial;
25726 _this._viewportCoords = viewportCoords;
25729 EarthControlHandler.prototype._enable = function () {
25731 var earth$ = this._navigator.stateService.state$.pipe(operators_1.map(function (state) {
25732 return state === State_1.State.Earth;
25733 }), operators_1.share());
25734 this._preventDefaultSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
25736 _this._container.mouseService.mouseWheel$ :
25739 .subscribe(function (event) {
25740 event.preventDefault();
25742 this._truckSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
25744 return rxjs_1.empty();
25746 return Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService).pipe(operators_1.filter(function (_a) {
25747 var e1 = _a[0], e2 = _a[1];
25748 return !(e1.ctrlKey && e2.ctrlKey);
25750 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
25751 var _b = _a[0], previous = _b[0], current = _b[1], render = _a[1], transform = _a[2];
25752 var planeNormal = [0, 0, 1];
25753 var planePoint = transform.unprojectBasic([0.5, 0.5], 0);
25754 planePoint[2] -= 2;
25755 var currentIntersection = _this._planeIntersection(current, planeNormal, planePoint, render.perspective, _this._container.element);
25756 var previousIntersection = _this._planeIntersection(previous, planeNormal, planePoint, render.perspective, _this._container.element);
25757 if (!currentIntersection || !previousIntersection) {
25760 var direction = new THREE.Vector3()
25761 .subVectors(currentIntersection, previousIntersection)
25762 .multiplyScalar(-1)
25765 }), operators_1.filter(function (direction) {
25766 return !!direction;
25768 .subscribe(function (direction) {
25769 _this._navigator.stateService.truck(direction);
25771 this._orbitSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
25773 return rxjs_1.empty();
25775 return Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService).pipe(operators_1.filter(function (_a) {
25776 var e1 = _a[0], e2 = _a[1];
25777 return e1.ctrlKey && e2.ctrlKey;
25779 }), operators_1.map(function (_a) {
25780 var previous = _a[0], current = _a[1];
25781 var _b = _this._eventToViewport(current, _this._container.element), currentX = _b[0], currentY = _b[1];
25782 var _c = _this._eventToViewport(previous, _this._container.element), previousX = _c[0], previousY = _c[1];
25783 var phi = (previousX - currentX) * Math.PI;
25784 var theta = (currentY - previousY) * Math.PI / 2;
25785 return { phi: phi, theta: theta };
25787 .subscribe(function (rotation) {
25788 _this._navigator.stateService.orbit(rotation);
25790 this._dollySubscription = earth$.pipe(operators_1.switchMap(function (earth) {
25792 return rxjs_1.empty();
25794 return _this._container.mouseService
25795 .filteredWheel$(_this._component.name, _this._container.mouseService.mouseWheel$);
25796 }), operators_1.map(function (event) {
25797 var delta = event.deltaY;
25798 if (event.deltaMode === 1) {
25799 delta = 40 * delta;
25801 else if (event.deltaMode === 2) {
25802 delta = 800 * delta;
25804 var canvasSize = _this._viewportCoords.containerToCanvas(_this._container.element);
25805 return -delta / canvasSize[1];
25807 .subscribe(function (delta) {
25808 _this._navigator.stateService.dolly(delta);
25811 EarthControlHandler.prototype._disable = function () {
25812 this._dollySubscription.unsubscribe();
25813 this._orbitSubscription.unsubscribe();
25814 this._preventDefaultSubscription.unsubscribe();
25815 this._truckSubscription.unsubscribe();
25817 EarthControlHandler.prototype._getConfiguration = function () {
25820 EarthControlHandler.prototype._eventToViewport = function (event, element) {
25821 var previousCanvas = this._viewportCoords.canvasPosition(event, element);
25822 return this._viewportCoords.canvasToViewport(previousCanvas[0], previousCanvas[1], element);
25824 EarthControlHandler.prototype._planeIntersection = function (event, planeNormal, planePoint, camera, element) {
25825 var _a = this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
25826 var direction = this._viewportCoords
25827 .unprojectFromCanvas(canvasX, canvasY, element, camera)
25828 .sub(camera.position)
25830 if (Math.abs(this._spatial.angleToPlane(direction.toArray(), planeNormal)) < Math.PI / 90) {
25833 var l0 = camera.position.clone();
25834 var n = new THREE.Vector3().fromArray(planeNormal);
25835 var p0 = new THREE.Vector3().fromArray(planePoint);
25836 var d = new THREE.Vector3().subVectors(p0, l0).dot(n) / direction.clone().dot(n);
25837 var intersection = new THREE.Vector3().addVectors(l0, direction.multiplyScalar(d));
25838 if (this._viewportCoords.worldToCamera(intersection.toArray(), camera)[2] > 0) {
25841 return intersection;
25843 return EarthControlHandler;
25844 }(Component_1.HandlerBase));
25845 exports.EarthControlHandler = EarthControlHandler;
25846 exports.default = EarthControlHandler;
25848 },{"../../Component":274,"../../State":281,"rxjs":26,"rxjs/operators":224,"three":225}],325:[function(require,module,exports){
25850 Object.defineProperty(exports, "__esModule", { value: true });
25851 var Geo_1 = require("../../../src/Geo");
25852 function basicBoundaryPoints(pointsPerSide) {
25854 var os = [[0, 0], [1, 0], [1, 1], [0, 1]];
25855 var ds = [[1, 0], [0, 1], [-1, 0], [0, -1]];
25856 for (var side = 0; side < 4; ++side) {
25859 for (var i = 0; i < pointsPerSide; ++i) {
25860 points.push([o[0] + d[0] * i / pointsPerSide,
25861 o[1] + d[1] * i / pointsPerSide]);
25866 function insideViewport(x, y) {
25867 return x >= -1 && x <= 1 && y >= -1 && y <= 1;
25869 function insideBasic(x, y) {
25870 return x >= 0 && x <= 1 && y >= 0 && y <= 1;
25872 function viewportDistances(transform, perspective, viewportCoords) {
25873 var boundaryPointsBasic = basicBoundaryPoints(100);
25874 var boundaryPointsViewport = boundaryPointsBasic
25875 .map(function (basic) {
25876 return viewportCoords.basicToViewportSafe(basic[0], basic[1], transform, perspective);
25878 var visibleBoundaryPoints = [];
25879 var viewportSides = [
25885 var intersections = [false, false, false, false];
25886 for (var i = 0; i < boundaryPointsViewport.length; i++) {
25887 var p1 = boundaryPointsViewport[i];
25888 var p2 = boundaryPointsViewport[(i + 1) % boundaryPointsViewport.length];
25893 if (insideViewport(p1[0], p1[1])) {
25894 visibleBoundaryPoints.push(p1);
25898 var x1 = p1[0], y1 = p1[1];
25899 var x2 = p2[0], y2 = p2[1];
25900 if (insideViewport(x1, y1)) {
25901 if (insideViewport(x2, y2)) {
25902 visibleBoundaryPoints.push(p1);
25905 for (var side = 0; side < 4; side++) {
25906 var s1 = { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } };
25907 var s2 = { p1: viewportSides[side], p2: viewportSides[(side + 1) % 4] };
25908 var intersecting = Geo_1.Lines.segmentsIntersect(s1, s2);
25909 if (intersecting) {
25910 var intersection = Geo_1.Lines.segmentIntersection(s1, s2);
25911 visibleBoundaryPoints.push(p1, [intersection.x, intersection.y]);
25912 intersections[side] = true;
25918 var _a = viewportCoords.viewportToBasic(-1, 1, transform, perspective), topLeftBasicX = _a[0], topLeftBasicY = _a[1];
25919 var _b = viewportCoords.viewportToBasic(1, 1, transform, perspective), topRightBasicX = _b[0], topRightBasicY = _b[1];
25920 var _c = viewportCoords.viewportToBasic(1, -1, transform, perspective), bottomRightBasicX = _c[0], bottomRightBasicY = _c[1];
25921 var _d = viewportCoords.viewportToBasic(-1, -1, transform, perspective), bottomLeftBasicX = _d[0], bottomLeftBasicY = _d[1];
25922 if (insideBasic(topLeftBasicX, topLeftBasicY)) {
25923 intersections[3] = intersections[0] = true;
25925 if (insideBasic(topRightBasicX, topRightBasicY)) {
25926 intersections[0] = intersections[1] = true;
25928 if (insideBasic(bottomRightBasicX, bottomRightBasicY)) {
25929 intersections[1] = intersections[2] = true;
25931 if (insideBasic(bottomLeftBasicX, bottomLeftBasicY)) {
25932 intersections[2] = intersections[3] = true;
25934 var maximums = [-1, -1, 1, 1];
25935 for (var _i = 0, visibleBoundaryPoints_1 = visibleBoundaryPoints; _i < visibleBoundaryPoints_1.length; _i++) {
25936 var visibleBoundaryPoint = visibleBoundaryPoints_1[_i];
25937 var x = visibleBoundaryPoint[0];
25938 var y = visibleBoundaryPoint[1];
25939 if (x > maximums[1]) {
25942 if (x < maximums[3]) {
25945 if (y > maximums[0]) {
25948 if (y < maximums[2]) {
25952 var boundary = [1, 1, -1, -1];
25953 var distances = [];
25954 for (var side = 0; side < 4; side++) {
25955 if (intersections[side]) {
25959 distances.push(Math.abs(boundary[side] - maximums[side]));
25963 exports.viewportDistances = viewportDistances;
25965 },{"../../../src/Geo":277}],326:[function(require,module,exports){
25967 var __extends = (this && this.__extends) || (function () {
25968 var extendStatics = function (d, b) {
25969 extendStatics = Object.setPrototypeOf ||
25970 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25971 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25972 return extendStatics(d, b);
25974 return function (d, b) {
25975 extendStatics(d, b);
25976 function __() { this.constructor = d; }
25977 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25980 Object.defineProperty(exports, "__esModule", { value: true });
25981 var Component_1 = require("../../Component");
25982 var Geo_1 = require("../../Geo");
25984 * @class MouseComponent
25986 * @classdesc Component handling mouse and touch events for camera movement.
25988 * To retrive and use the mouse component
25992 * var viewer = new Mapillary.Viewer(
25997 * var mouseComponent = viewer.getComponent("mouse");
26000 var MouseComponent = /** @class */ (function (_super) {
26001 __extends(MouseComponent, _super);
26003 function MouseComponent(name, container, navigator) {
26004 var _this = _super.call(this, name, container, navigator) || this;
26005 var spatial = new Geo_1.Spatial();
26006 var viewportCoords = new Geo_1.ViewportCoords();
26007 _this._bounceHandler = new Component_1.BounceHandler(_this, container, navigator, viewportCoords, spatial);
26008 _this._doubleClickZoomHandler = new Component_1.DoubleClickZoomHandler(_this, container, navigator, viewportCoords);
26009 _this._dragPanHandler = new Component_1.DragPanHandler(_this, container, navigator, viewportCoords, spatial);
26010 _this._earthControlHandler = new Component_1.EarthControlHandler(_this, container, navigator, viewportCoords, spatial);
26011 _this._scrollZoomHandler = new Component_1.ScrollZoomHandler(_this, container, navigator, viewportCoords);
26012 _this._touchZoomHandler = new Component_1.TouchZoomHandler(_this, container, navigator, viewportCoords);
26015 Object.defineProperty(MouseComponent.prototype, "doubleClickZoom", {
26017 * Get double click zoom.
26019 * @returns {DoubleClickZoomHandler} The double click zoom handler.
26022 return this._doubleClickZoomHandler;
26027 Object.defineProperty(MouseComponent.prototype, "dragPan", {
26031 * @returns {DragPanHandler} The drag pan handler.
26034 return this._dragPanHandler;
26039 Object.defineProperty(MouseComponent.prototype, "scrollZoom", {
26043 * @returns {ScrollZoomHandler} The scroll zoom handler.
26046 return this._scrollZoomHandler;
26051 Object.defineProperty(MouseComponent.prototype, "touchZoom", {
26055 * @returns {TouchZoomHandler} The touch zoom handler.
26058 return this._touchZoomHandler;
26063 MouseComponent.prototype._activate = function () {
26065 this._bounceHandler.enable();
26066 this._earthControlHandler.enable();
26067 this._configurationSubscription = this._configuration$
26068 .subscribe(function (configuration) {
26069 if (configuration.doubleClickZoom) {
26070 _this._doubleClickZoomHandler.enable();
26073 _this._doubleClickZoomHandler.disable();
26075 if (configuration.dragPan) {
26076 _this._dragPanHandler.enable();
26079 _this._dragPanHandler.disable();
26081 if (configuration.scrollZoom) {
26082 _this._scrollZoomHandler.enable();
26085 _this._scrollZoomHandler.disable();
26087 if (configuration.touchZoom) {
26088 _this._touchZoomHandler.enable();
26091 _this._touchZoomHandler.disable();
26094 this._container.mouseService.claimMouse(this._name, 0);
26096 MouseComponent.prototype._deactivate = function () {
26097 this._container.mouseService.unclaimMouse(this._name);
26098 this._configurationSubscription.unsubscribe();
26099 this._bounceHandler.disable();
26100 this._doubleClickZoomHandler.disable();
26101 this._dragPanHandler.disable();
26102 this._earthControlHandler.disable();
26103 this._scrollZoomHandler.disable();
26104 this._touchZoomHandler.disable();
26106 MouseComponent.prototype._getDefaultConfiguration = function () {
26107 return { doubleClickZoom: false, dragPan: true, scrollZoom: true, touchZoom: true };
26110 MouseComponent.componentName = "mouse";
26111 return MouseComponent;
26112 }(Component_1.Component));
26113 exports.MouseComponent = MouseComponent;
26114 Component_1.ComponentService.register(MouseComponent);
26115 exports.default = MouseComponent;
26117 },{"../../Component":274,"../../Geo":277}],327:[function(require,module,exports){
26119 var __extends = (this && this.__extends) || (function () {
26120 var extendStatics = function (d, b) {
26121 extendStatics = Object.setPrototypeOf ||
26122 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26123 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26124 return extendStatics(d, b);
26126 return function (d, b) {
26127 extendStatics(d, b);
26128 function __() { this.constructor = d; }
26129 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26132 Object.defineProperty(exports, "__esModule", { value: true });
26133 var operators_1 = require("rxjs/operators");
26134 var Component_1 = require("../../Component");
26136 * The `ScrollZoomHandler` allows the user to zoom the viewer image by scrolling.
26140 * var mouseComponent = viewer.getComponent("mouse");
26142 * mouseComponent.scrollZoom.disable();
26143 * mouseComponent.scrollZoom.enable();
26145 * var isEnabled = mouseComponent.scrollZoom.isEnabled;
26148 var ScrollZoomHandler = /** @class */ (function (_super) {
26149 __extends(ScrollZoomHandler, _super);
26151 function ScrollZoomHandler(component, container, navigator, viewportCoords) {
26152 var _this = _super.call(this, component, container, navigator) || this;
26153 _this._viewportCoords = viewportCoords;
26156 ScrollZoomHandler.prototype._enable = function () {
26158 this._container.mouseService.claimWheel(this._component.name, 0);
26159 this._preventDefaultSubscription = this._container.mouseService.mouseWheel$
26160 .subscribe(function (event) {
26161 event.preventDefault();
26163 this._zoomSubscription = this._container.mouseService
26164 .filteredWheel$(this._component.name, this._container.mouseService.mouseWheel$).pipe(operators_1.withLatestFrom(this._navigator.stateService.currentState$, function (w, f) {
26166 }), operators_1.filter(function (args) {
26167 var state = args[1].state;
26168 return state.currentNode.fullPano || state.nodesAhead < 1;
26169 }), operators_1.map(function (args) {
26171 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, function (w, r, t) {
26174 .subscribe(function (args) {
26175 var event = args[0];
26176 var render = args[1];
26177 var transform = args[2];
26178 var element = _this._container.element;
26179 var _a = _this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
26180 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
26181 var reference = transform.projectBasic(unprojected.toArray());
26182 var deltaY = event.deltaY;
26183 if (event.deltaMode === 1) {
26184 deltaY = 40 * deltaY;
26186 else if (event.deltaMode === 2) {
26187 deltaY = 800 * deltaY;
26189 var canvasSize = _this._viewportCoords.containerToCanvas(element);
26190 var zoom = -3 * deltaY / canvasSize[1];
26191 _this._navigator.stateService.zoomIn(zoom, reference);
26194 ScrollZoomHandler.prototype._disable = function () {
26195 this._container.mouseService.unclaimWheel(this._component.name);
26196 this._preventDefaultSubscription.unsubscribe();
26197 this._zoomSubscription.unsubscribe();
26198 this._preventDefaultSubscription = null;
26199 this._zoomSubscription = null;
26201 ScrollZoomHandler.prototype._getConfiguration = function (enable) {
26202 return { scrollZoom: enable };
26204 return ScrollZoomHandler;
26205 }(Component_1.HandlerBase));
26206 exports.ScrollZoomHandler = ScrollZoomHandler;
26207 exports.default = ScrollZoomHandler;
26209 },{"../../Component":274,"rxjs/operators":224}],328:[function(require,module,exports){
26211 var __extends = (this && this.__extends) || (function () {
26212 var extendStatics = function (d, b) {
26213 extendStatics = Object.setPrototypeOf ||
26214 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26215 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26216 return extendStatics(d, b);
26218 return function (d, b) {
26219 extendStatics(d, b);
26220 function __() { this.constructor = d; }
26221 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26224 Object.defineProperty(exports, "__esModule", { value: true });
26225 var rxjs_1 = require("rxjs");
26226 var operators_1 = require("rxjs/operators");
26227 var Component_1 = require("../../Component");
26229 * The `TouchZoomHandler` allows the user to zoom the viewer image by pinching on a touchscreen.
26233 * var mouseComponent = viewer.getComponent("mouse");
26235 * mouseComponent.touchZoom.disable();
26236 * mouseComponent.touchZoom.enable();
26238 * var isEnabled = mouseComponent.touchZoom.isEnabled;
26241 var TouchZoomHandler = /** @class */ (function (_super) {
26242 __extends(TouchZoomHandler, _super);
26244 function TouchZoomHandler(component, container, navigator, viewportCoords) {
26245 var _this = _super.call(this, component, container, navigator) || this;
26246 _this._viewportCoords = viewportCoords;
26249 TouchZoomHandler.prototype._enable = function () {
26251 this._preventDefaultSubscription = this._container.touchService.pinch$
26252 .subscribe(function (pinch) {
26253 pinch.originalEvent.preventDefault();
26255 var pinchStarted$ = this._container.touchService.pinchStart$.pipe(operators_1.map(function (event) {
26258 var pinchStopped$ = this._container.touchService.pinchEnd$.pipe(operators_1.map(function (event) {
26261 this._activeSubscription = rxjs_1.merge(pinchStarted$, pinchStopped$)
26262 .subscribe(this._container.touchService.activate$);
26263 this._zoomSubscription = this._container.touchService.pinch$.pipe(operators_1.withLatestFrom(this._navigator.stateService.currentState$), operators_1.filter(function (args) {
26264 var state = args[1].state;
26265 return state.currentNode.fullPano || state.nodesAhead < 1;
26266 }), operators_1.map(function (args) {
26268 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
26269 .subscribe(function (_a) {
26270 var pinch = _a[0], render = _a[1], transform = _a[2];
26271 var element = _this._container.element;
26272 var _b = _this._viewportCoords.canvasPosition(pinch, element), canvasX = _b[0], canvasY = _b[1];
26273 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
26274 var reference = transform.projectBasic(unprojected.toArray());
26275 var _c = _this._viewportCoords.containerToCanvas(element), canvasWidth = _c[0], canvasHeight = _c[1];
26276 var zoom = 3 * pinch.distanceChange / Math.min(canvasWidth, canvasHeight);
26277 _this._navigator.stateService.zoomIn(zoom, reference);
26280 TouchZoomHandler.prototype._disable = function () {
26281 this._activeSubscription.unsubscribe();
26282 this._preventDefaultSubscription.unsubscribe();
26283 this._zoomSubscription.unsubscribe();
26284 this._preventDefaultSubscription = null;
26285 this._zoomSubscription = null;
26287 TouchZoomHandler.prototype._getConfiguration = function (enable) {
26288 return { touchZoom: enable };
26290 return TouchZoomHandler;
26291 }(Component_1.HandlerBase));
26292 exports.TouchZoomHandler = TouchZoomHandler;
26293 exports.default = TouchZoomHandler;
26295 },{"../../Component":274,"rxjs":26,"rxjs/operators":224}],329:[function(require,module,exports){
26297 Object.defineProperty(exports, "__esModule", { value: true });
26298 var Popup_1 = require("./popup/Popup");
26299 exports.Popup = Popup_1.Popup;
26300 var PopupComponent_1 = require("./PopupComponent");
26301 exports.PopupComponent = PopupComponent_1.PopupComponent;
26303 },{"./PopupComponent":330,"./popup/Popup":331}],330:[function(require,module,exports){
26305 var __extends = (this && this.__extends) || (function () {
26306 var extendStatics = function (d, b) {
26307 extendStatics = Object.setPrototypeOf ||
26308 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26309 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26310 return extendStatics(d, b);
26312 return function (d, b) {
26313 extendStatics(d, b);
26314 function __() { this.constructor = d; }
26315 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26318 Object.defineProperty(exports, "__esModule", { value: true });
26319 var rxjs_1 = require("rxjs");
26320 var operators_1 = require("rxjs/operators");
26321 var Component_1 = require("../../Component");
26322 var Utils_1 = require("../../Utils");
26324 * @class PopupComponent
26326 * @classdesc Component for showing HTML popup objects.
26328 * The `add` method is used for adding new popups. Popups are removed by reference.
26330 * It is not possible to update popups in the set by updating any properties
26331 * directly on the popup object. Popups need to be replaced by
26332 * removing them and creating new ones with relevant changed properties and
26333 * adding those instead.
26335 * Popups are only relevant to a single image because they are based on
26336 * 2D basic image coordinates. Popups related to a certain image should
26337 * be removed when the viewer is moved to another node.
26339 * To retrive and use the popup component
26343 * var viewer = new Mapillary.Viewer(
26347 * { component: { popup: true } });
26349 * var popupComponent = viewer.getComponent("popup");
26352 var PopupComponent = /** @class */ (function (_super) {
26353 __extends(PopupComponent, _super);
26355 function PopupComponent(name, container, navigator, dom) {
26356 var _this = _super.call(this, name, container, navigator) || this;
26357 _this._dom = !!dom ? dom : new Utils_1.DOM();
26358 _this._popups = [];
26359 _this._added$ = new rxjs_1.Subject();
26360 _this._popups$ = new rxjs_1.Subject();
26364 * Add popups to the popups set.
26366 * @description Adding a new popup never replaces an old one
26367 * because they are stored by reference. Adding an already
26368 * existing popup has no effect.
26370 * @param {Array<Popup>} popups - Popups to add.
26372 * @example ```popupComponent.add([popup1, popup2]);```
26374 PopupComponent.prototype.add = function (popups) {
26375 for (var _i = 0, popups_1 = popups; _i < popups_1.length; _i++) {
26376 var popup = popups_1[_i];
26377 if (this._popups.indexOf(popup) !== -1) {
26380 this._popups.push(popup);
26381 if (this._activated) {
26382 popup.setParentContainer(this._popupContainer);
26385 this._added$.next(popups);
26386 this._popups$.next(this._popups);
26389 * Returns an array of all popups.
26391 * @example ```var popups = popupComponent.getAll();```
26393 PopupComponent.prototype.getAll = function () {
26394 return this._popups.slice();
26397 * Remove popups based on reference from the popup set.
26399 * @param {Array<Popup>} popups - Popups to remove.
26401 * @example ```popupComponent.remove([popup1, popup2]);```
26403 PopupComponent.prototype.remove = function (popups) {
26404 for (var _i = 0, popups_2 = popups; _i < popups_2.length; _i++) {
26405 var popup = popups_2[_i];
26406 this._remove(popup);
26408 this._popups$.next(this._popups);
26411 * Remove all popups from the popup set.
26413 * @example ```popupComponent.removeAll();```
26415 PopupComponent.prototype.removeAll = function () {
26416 for (var _i = 0, _a = this._popups.slice(); _i < _a.length; _i++) {
26417 var popup = _a[_i];
26418 this._remove(popup);
26420 this._popups$.next(this._popups);
26422 PopupComponent.prototype._activate = function () {
26424 this._popupContainer = this._dom.createElement("div", "mapillary-js-popup-container", this._container.element);
26425 for (var _i = 0, _a = this._popups; _i < _a.length; _i++) {
26426 var popup = _a[_i];
26427 popup.setParentContainer(this._popupContainer);
26429 this._updateAllSubscription = rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._container.renderService.size$, this._navigator.stateService.currentTransform$)
26430 .subscribe(function (_a) {
26431 var renderCamera = _a[0], size = _a[1], transform = _a[2];
26432 for (var _i = 0, _b = _this._popups; _i < _b.length; _i++) {
26433 var popup = _b[_i];
26434 popup.update(renderCamera, size, transform);
26437 var changed$ = this._popups$.pipe(operators_1.startWith(this._popups), operators_1.switchMap(function (popups) {
26438 return rxjs_1.from(popups).pipe(operators_1.mergeMap(function (popup) {
26439 return popup.changed$;
26441 }), operators_1.map(function (popup) {
26444 this._updateAddedChangedSubscription = rxjs_1.merge(this._added$, changed$).pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._container.renderService.size$, this._navigator.stateService.currentTransform$))
26445 .subscribe(function (_a) {
26446 var popups = _a[0], renderCamera = _a[1], size = _a[2], transform = _a[3];
26447 for (var _i = 0, popups_3 = popups; _i < popups_3.length; _i++) {
26448 var popup = popups_3[_i];
26449 popup.update(renderCamera, size, transform);
26453 PopupComponent.prototype._deactivate = function () {
26454 this._updateAllSubscription.unsubscribe();
26455 this._updateAddedChangedSubscription.unsubscribe();
26456 for (var _i = 0, _a = this._popups; _i < _a.length; _i++) {
26457 var popup = _a[_i];
26460 this._container.element.removeChild(this._popupContainer);
26461 delete this._popupContainer;
26463 PopupComponent.prototype._getDefaultConfiguration = function () {
26466 PopupComponent.prototype._remove = function (popup) {
26467 var index = this._popups.indexOf(popup);
26468 if (index === -1) {
26471 var removed = this._popups.splice(index, 1)[0];
26472 if (this._activated) {
26476 PopupComponent.componentName = "popup";
26477 return PopupComponent;
26478 }(Component_1.Component));
26479 exports.PopupComponent = PopupComponent;
26480 Component_1.ComponentService.register(PopupComponent);
26481 exports.default = PopupComponent;
26483 },{"../../Component":274,"../../Utils":284,"rxjs":26,"rxjs/operators":224}],331:[function(require,module,exports){
26485 Object.defineProperty(exports, "__esModule", { value: true });
26486 var rxjs_1 = require("rxjs");
26487 var Geo_1 = require("../../../Geo");
26488 var Utils_1 = require("../../../Utils");
26489 var Viewer_1 = require("../../../Viewer");
26493 * @classdesc Popup instance for rendering custom HTML content
26494 * on top of images. Popups are based on 2D basic image coordinates
26495 * (see the {@link Viewer} class documentation for more information about coordinate
26496 * systems) and a certain popup is therefore only relevant to a single image.
26497 * Popups related to a certain image should be removed when moving
26498 * to another image.
26500 * A popup must have both its content and its point or rect set to be
26501 * rendered. Popup options can not be updated after creation but the
26502 * basic point or rect as well as its content can be changed by calling
26503 * the appropriate methods.
26505 * To create and add one `Popup` with default configuration
26506 * (tooltip visuals and automatic float) and one with specific options
26511 * var defaultSpan = document.createElement('span');
26512 * defaultSpan.innerHTML = 'hello default';
26514 * var defaultPopup = new Mapillary.PopupComponent.Popup();
26515 * defaultPopup.setDOMContent(defaultSpan);
26516 * defaultPopup.setBasicPoint([0.3, 0.3]);
26518 * var cleanSpan = document.createElement('span');
26519 * cleanSpan.innerHTML = 'hello clean';
26521 * var cleanPopup = new Mapillary.PopupComponent.Popup({
26523 * float: Mapillary.Alignment.Top,
26528 * cleanPopup.setDOMContent(cleanSpan);
26529 * cleanPopup.setBasicPoint([0.6, 0.6]);
26531 * popupComponent.add([defaultPopup, cleanPopup]);
26534 * @description Implementation of API methods and API documentation inspired
26535 * by/used from https://github.com/mapbox/mapbox-gl-js/blob/v0.38.0/src/ui/popup.js
26537 var Popup = /** @class */ (function () {
26538 function Popup(options, viewportCoords, dom) {
26539 this._options = {};
26540 options = !!options ? options : {};
26541 this._options.capturePointer = options.capturePointer === false ?
26542 options.capturePointer : true;
26543 this._options.clean = options.clean;
26544 this._options.float = options.float;
26545 this._options.offset = options.offset;
26546 this._options.opacity = options.opacity;
26547 this._options.position = options.position;
26548 this._dom = !!dom ? dom : new Utils_1.DOM();
26549 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
26550 this._notifyChanged$ = new rxjs_1.Subject();
26552 Object.defineProperty(Popup.prototype, "changed$", {
26554 * @description Internal observable used by the component to
26555 * render the popup when its position or content has changed.
26559 return this._notifyChanged$;
26565 * @description Internal method used by the component to
26566 * remove all references to the popup.
26569 Popup.prototype.remove = function () {
26570 if (this._content && this._content.parentNode) {
26571 this._content.parentNode.removeChild(this._content);
26573 if (this._container) {
26574 this._container.parentNode.removeChild(this._container);
26575 delete this._container;
26577 if (this._parentContainer) {
26578 delete this._parentContainer;
26582 * Sets a 2D basic image coordinates point to the popup's anchor, and
26583 * moves the popup to it.
26585 * @description Overwrites any previously set point or rect.
26587 * @param {Array<number>} basicPoint - Point in 2D basic image coordinates.
26591 * var popup = new Mapillary.PopupComponent.Popup();
26592 * popup.setText('hello image');
26593 * popup.setBasicPoint([0.3, 0.3]);
26595 * popupComponent.add([popup]);
26598 Popup.prototype.setBasicPoint = function (basicPoint) {
26599 this._point = basicPoint.slice();
26601 this._notifyChanged$.next(this);
26604 * Sets a 2D basic image coordinates rect to the popup's anchor, and
26605 * moves the popup to it.
26607 * @description Overwrites any previously set point or rect.
26609 * @param {Array<number>} basicRect - Rect in 2D basic image
26610 * coordinates ([topLeftX, topLeftY, bottomRightX, bottomRightY]) .
26614 * var popup = new Mapillary.PopupComponent.Popup();
26615 * popup.setText('hello image');
26616 * popup.setBasicRect([0.3, 0.3, 0.5, 0.6]);
26618 * popupComponent.add([popup]);
26621 Popup.prototype.setBasicRect = function (basicRect) {
26622 this._rect = basicRect.slice();
26623 this._point = null;
26624 this._notifyChanged$.next(this);
26627 * Sets the popup's content to the element provided as a DOM node.
26629 * @param {Node} htmlNode - A DOM node to be used as content for the popup.
26633 * var div = document.createElement('div');
26634 * div.innerHTML = 'hello image';
26636 * var popup = new Mapillary.PopupComponent.Popup();
26637 * popup.setDOMContent(div);
26638 * popup.setBasicPoint([0.3, 0.3]);
26640 * popupComponent.add([popup]);
26643 Popup.prototype.setDOMContent = function (htmlNode) {
26644 if (this._content && this._content.parentNode) {
26645 this._content.parentNode.removeChild(this._content);
26647 var className = "mapillaryjs-popup-content" +
26648 (this._options.clean === true ? "-clean" : "") +
26649 (this._options.capturePointer === true ? " mapillaryjs-popup-capture-pointer" : "");
26650 this._content = this._dom.createElement("div", className, this._container);
26651 this._content.appendChild(htmlNode);
26652 this._notifyChanged$.next(this);
26655 * Sets the popup's content to the HTML provided as a string.
26657 * @description This method does not perform HTML filtering or sanitization,
26658 * and must be used only with trusted content. Consider Popup#setText if the
26659 * content is an untrusted text string.
26661 * @param {string} html - A string representing HTML content for the popup.
26665 * var popup = new Mapillary.PopupComponent.Popup();
26666 * popup.setHTML('<div>hello image</div>');
26667 * popup.setBasicPoint([0.3, 0.3]);
26669 * popupComponent.add([popup]);
26672 Popup.prototype.setHTML = function (html) {
26673 var frag = this._dom.document.createDocumentFragment();
26674 var temp = this._dom.createElement("body");
26676 temp.innerHTML = html;
26678 child = temp.firstChild;
26682 frag.appendChild(child);
26684 this.setDOMContent(frag);
26687 * Sets the popup's content to a string of text.
26689 * @description This function creates a Text node in the DOM, so it cannot insert raw HTML.
26690 * Use this method for security against XSS if the popup content is user-provided.
26692 * @param {string} text - Textual content for the popup.
26696 * var popup = new Mapillary.PopupComponent.Popup();
26697 * popup.setText('hello image');
26698 * popup.setBasicPoint([0.3, 0.3]);
26700 * popupComponent.add([popup]);
26703 Popup.prototype.setText = function (text) {
26704 this.setDOMContent(this._dom.document.createTextNode(text));
26707 * @description Internal method for attaching the popup to
26708 * its parent container so that it is rendered in the DOM tree.
26711 Popup.prototype.setParentContainer = function (parentContainer) {
26712 this._parentContainer = parentContainer;
26715 * @description Internal method for updating the rendered
26716 * position of the popup called by the popup component.
26719 Popup.prototype.update = function (renderCamera, size, transform) {
26721 if (!this._parentContainer || !this._content) {
26724 if (!this._point && !this._rect) {
26727 if (!this._container) {
26728 this._container = this._dom.createElement("div", "mapillaryjs-popup", this._parentContainer);
26729 var showTip = this._options.clean !== true &&
26730 this._options.float !== Viewer_1.Alignment.Center;
26732 var tipClassName = "mapillaryjs-popup-tip" +
26733 (this._options.capturePointer === true ? " mapillaryjs-popup-capture-pointer" : "");
26734 this._tip = this._dom.createElement("div", tipClassName, this._container);
26735 this._dom.createElement("div", "mapillaryjs-popup-tip-inner", this._tip);
26737 this._container.appendChild(this._content);
26738 this._parentContainer.appendChild(this._container);
26739 if (this._options.opacity != null) {
26740 this._container.style.opacity = this._options.opacity.toString();
26743 var pointPixel = null;
26744 var position = this._alignmentToPopupAligment(this._options.position);
26745 var float = this._alignmentToPopupAligment(this._options.float);
26746 var classList = this._container.classList;
26747 if (this._point != null) {
26749 this._viewportCoords.basicToCanvasSafe(this._point[0], this._point[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
26752 var alignments = ["center", "top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"];
26753 var appliedPosition = null;
26754 for (var _i = 0, alignments_1 = alignments; _i < alignments_1.length; _i++) {
26755 var alignment = alignments_1[_i];
26756 if (classList.contains("mapillaryjs-popup-float-" + alignment)) {
26757 appliedPosition = alignment;
26761 _a = this._rectToPixel(this._rect, position, appliedPosition, renderCamera, size, transform), pointPixel = _a[0], position = _a[1];
26766 if (pointPixel == null) {
26767 this._container.style.visibility = "hidden";
26770 this._container.style.visibility = "visible";
26772 var width = this._container.offsetWidth;
26773 var height = this._container.offsetHeight;
26774 var floats = this._pixelToFloats(pointPixel, size, width, height);
26775 float = floats.length === 0 ? "top" : floats.join("-");
26777 var offset = this._normalizeOffset(this._options.offset);
26778 pointPixel = [pointPixel[0] + offset[float][0], pointPixel[1] + offset[float][1]];
26779 pointPixel = [Math.round(pointPixel[0]), Math.round(pointPixel[1])];
26780 var floatTranslate = {
26781 "bottom": "translate(-50%,0)",
26782 "bottom-left": "translate(-100%,0)",
26783 "bottom-right": "translate(0,0)",
26784 "center": "translate(-50%,-50%)",
26785 "left": "translate(-100%,-50%)",
26786 "right": "translate(0,-50%)",
26787 "top": "translate(-50%,-100%)",
26788 "top-left": "translate(-100%,-100%)",
26789 "top-right": "translate(0,-100%)",
26791 for (var key in floatTranslate) {
26792 if (!floatTranslate.hasOwnProperty(key)) {
26795 classList.remove("mapillaryjs-popup-float-" + key);
26797 classList.add("mapillaryjs-popup-float-" + float);
26798 this._container.style.transform = floatTranslate[float] + " translate(" + pointPixel[0] + "px," + pointPixel[1] + "px)";
26800 Popup.prototype._rectToPixel = function (rect, position, appliedPosition, renderCamera, size, transform) {
26802 var width = this._container.offsetWidth;
26803 var height = this._container.offsetHeight;
26804 var floatOffsets = {
26805 "bottom": [0, height / 2],
26806 "bottom-left": [-width / 2, height / 2],
26807 "bottom-right": [width / 2, height / 2],
26808 "left": [-width / 2, 0],
26809 "right": [width / 2, 0],
26810 "top": [0, -height / 2],
26811 "top-left": [-width / 2, -height / 2],
26812 "top-right": [width / 2, -height / 2],
26814 var automaticPositions = ["top", "bottom", "left", "right"];
26815 var largestVisibleArea = [0, null, null];
26816 for (var _i = 0, automaticPositions_1 = automaticPositions; _i < automaticPositions_1.length; _i++) {
26817 var automaticPosition = automaticPositions_1[_i];
26818 var autoPointBasic = this._pointFromRectPosition(rect, automaticPosition);
26819 var autoPointPixel = this._viewportCoords.basicToCanvasSafe(autoPointBasic[0], autoPointBasic[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
26820 if (autoPointPixel == null) {
26823 var floatOffset = floatOffsets[automaticPosition];
26824 var offsetedPosition = [autoPointPixel[0] + floatOffset[0], autoPointPixel[1] + floatOffset[1]];
26825 var staticCoeff = appliedPosition != null && appliedPosition === automaticPosition ? 1 : 0.7;
26826 var floats = this._pixelToFloats(offsetedPosition, size, width / staticCoeff, height / (2 * staticCoeff));
26827 if (floats.length === 0 &&
26828 autoPointPixel[0] > 0 &&
26829 autoPointPixel[0] < size.width &&
26830 autoPointPixel[1] > 0 &&
26831 autoPointPixel[1] < size.height) {
26832 return [autoPointPixel, automaticPosition];
26834 var minX = Math.max(offsetedPosition[0] - width / 2, 0);
26835 var maxX = Math.min(offsetedPosition[0] + width / 2, size.width);
26836 var minY = Math.max(offsetedPosition[1] - height / 2, 0);
26837 var maxY = Math.min(offsetedPosition[1] + height / 2, size.height);
26838 var visibleX = Math.max(0, maxX - minX);
26839 var visibleY = Math.max(0, maxY - minY);
26840 var visibleArea = staticCoeff * visibleX * visibleY;
26841 if (visibleArea > largestVisibleArea[0]) {
26842 largestVisibleArea[0] = visibleArea;
26843 largestVisibleArea[1] = autoPointPixel;
26844 largestVisibleArea[2] = automaticPosition;
26847 if (largestVisibleArea[0] > 0) {
26848 return [largestVisibleArea[1], largestVisibleArea[2]];
26851 var pointBasic = this._pointFromRectPosition(rect, position);
26852 var pointPixel = this._viewportCoords.basicToCanvasSafe(pointBasic[0], pointBasic[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
26853 return [pointPixel, position != null ? position : "top"];
26855 Popup.prototype._alignmentToPopupAligment = function (float) {
26857 case Viewer_1.Alignment.Bottom:
26859 case Viewer_1.Alignment.BottomLeft:
26860 return "bottom-left";
26861 case Viewer_1.Alignment.BottomRight:
26862 return "bottom-right";
26863 case Viewer_1.Alignment.Center:
26865 case Viewer_1.Alignment.Left:
26867 case Viewer_1.Alignment.Right:
26869 case Viewer_1.Alignment.Top:
26871 case Viewer_1.Alignment.TopLeft:
26873 case Viewer_1.Alignment.TopRight:
26874 return "top-right";
26879 Popup.prototype._normalizeOffset = function (offset) {
26880 if (offset == null) {
26881 return this._normalizeOffset(0);
26883 if (typeof offset === "number") {
26884 // input specifies a radius
26885 var sideOffset = offset;
26886 var sign = sideOffset >= 0 ? 1 : -1;
26887 var cornerOffset = sign * Math.round(Math.sqrt(0.5 * Math.pow(sideOffset, 2)));
26889 "bottom": [0, sideOffset],
26890 "bottom-left": [-cornerOffset, cornerOffset],
26891 "bottom-right": [cornerOffset, cornerOffset],
26893 "left": [-sideOffset, 0],
26894 "right": [sideOffset, 0],
26895 "top": [0, -sideOffset],
26896 "top-left": [-cornerOffset, -cornerOffset],
26897 "top-right": [cornerOffset, -cornerOffset],
26901 // input specifes a value for each position
26903 "bottom": offset.bottom || [0, 0],
26904 "bottom-left": offset.bottomLeft || [0, 0],
26905 "bottom-right": offset.bottomRight || [0, 0],
26906 "center": offset.center || [0, 0],
26907 "left": offset.left || [0, 0],
26908 "right": offset.right || [0, 0],
26909 "top": offset.top || [0, 0],
26910 "top-left": offset.topLeft || [0, 0],
26911 "top-right": offset.topRight || [0, 0],
26915 Popup.prototype._pixelToFloats = function (pointPixel, size, width, height) {
26917 if (pointPixel[1] < height) {
26918 floats.push("bottom");
26920 else if (pointPixel[1] > size.height - height) {
26921 floats.push("top");
26923 if (pointPixel[0] < width / 2) {
26924 floats.push("right");
26926 else if (pointPixel[0] > size.width - width / 2) {
26927 floats.push("left");
26931 Popup.prototype._pointFromRectPosition = function (rect, position) {
26933 var x1 = rect[0] < rect[2] ? rect[2] : rect[2] + 1;
26936 switch (position) {
26938 return [(x0 + x1) / 2, y1];
26939 case "bottom-left":
26941 case "bottom-right":
26944 return [(x0 + x1) / 2, (y0 + y1) / 2];
26946 return [x0, (y0 + y1) / 2];
26948 return [x1, (y0 + y1) / 2];
26950 return [(x0 + x1) / 2, y0];
26956 return [(x0 + x1) / 2, y1];
26961 exports.Popup = Popup;
26962 exports.default = Popup;
26965 },{"../../../Geo":277,"../../../Utils":284,"../../../Viewer":285,"rxjs":26}],332:[function(require,module,exports){
26967 var __extends = (this && this.__extends) || (function () {
26968 var extendStatics = function (d, b) {
26969 extendStatics = Object.setPrototypeOf ||
26970 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26971 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26972 return extendStatics(d, b);
26974 return function (d, b) {
26975 extendStatics(d, b);
26976 function __() { this.constructor = d; }
26977 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26980 Object.defineProperty(exports, "__esModule", { value: true });
26981 var rxjs_1 = require("rxjs");
26982 var operators_1 = require("rxjs/operators");
26983 var Component_1 = require("../../Component");
26984 var Edge_1 = require("../../Edge");
26985 var Graph_1 = require("../../Graph");
26987 * @class SequenceComponent
26988 * @classdesc Component showing navigation arrows for sequence directions
26989 * as well as playing button. Exposes an API to start and stop play.
26991 var SequenceComponent = /** @class */ (function (_super) {
26992 __extends(SequenceComponent, _super);
26993 function SequenceComponent(name, container, navigator, renderer, scheduler) {
26994 var _this = _super.call(this, name, container, navigator) || this;
26995 _this._sequenceDOMRenderer = !!renderer ? renderer : new Component_1.SequenceDOMRenderer(container);
26996 _this._scheduler = scheduler;
26997 _this._containerWidth$ = new rxjs_1.Subject();
26998 _this._hoveredKeySubject$ = new rxjs_1.Subject();
26999 _this._hoveredKey$ = _this._hoveredKeySubject$.pipe(operators_1.share());
27000 _this._navigator.playService.playing$.pipe(operators_1.skip(1), operators_1.withLatestFrom(_this._configuration$))
27001 .subscribe(function (_a) {
27002 var playing = _a[0], configuration = _a[1];
27003 _this.fire(SequenceComponent.playingchanged, playing);
27004 if (playing === configuration.playing) {
27014 _this._navigator.playService.direction$.pipe(operators_1.skip(1), operators_1.withLatestFrom(_this._configuration$))
27015 .subscribe(function (_a) {
27016 var direction = _a[0], configuration = _a[1];
27017 if (direction !== configuration.direction) {
27018 _this.setDirection(direction);
27023 Object.defineProperty(SequenceComponent.prototype, "hoveredKey$", {
27025 * Get hovered key observable.
27027 * @description An observable emitting the key of the node for the direction
27028 * arrow that is being hovered. When the mouse leaves a direction arrow null
27031 * @returns {Observable<string>}
27034 return this._hoveredKey$;
27042 * @fires PlayerComponent#playingchanged
27044 SequenceComponent.prototype.play = function () {
27045 this.configure({ playing: true });
27050 * @fires PlayerComponent#playingchanged
27052 SequenceComponent.prototype.stop = function () {
27053 this.configure({ playing: false });
27056 * Set the direction to follow when playing.
27058 * @param {EdgeDirection} direction - The direction that will be followed when playing.
27060 SequenceComponent.prototype.setDirection = function (direction) {
27061 this.configure({ direction: direction });
27064 * Set highlight key.
27066 * @description The arrow pointing towards the node corresponding to the
27067 * highlight key will be highlighted.
27069 * @param {string} highlightKey Key of node to be highlighted if existing.
27071 SequenceComponent.prototype.setHighlightKey = function (highlightKey) {
27072 this.configure({ highlightKey: highlightKey });
27075 * Set max width of container element.
27077 * @description Set max width of the container element holding
27078 * the sequence navigation elements. If the min width is larger than the
27079 * max width the min width value will be used.
27081 * The container element is automatically resized when the resize
27082 * method on the Viewer class is called.
27084 * @param {number} minWidth
27086 SequenceComponent.prototype.setMaxWidth = function (maxWidth) {
27087 this.configure({ maxWidth: maxWidth });
27090 * Set min width of container element.
27092 * @description Set min width of the container element holding
27093 * the sequence navigation elements. If the min width is larger than the
27094 * max width the min width value will be used.
27096 * The container element is automatically resized when the resize
27097 * method on the Viewer class is called.
27099 * @param {number} minWidth
27101 SequenceComponent.prototype.setMinWidth = function (minWidth) {
27102 this.configure({ minWidth: minWidth });
27105 * Set the value indicating whether the sequence UI elements should be visible.
27107 * @param {boolean} visible
27109 SequenceComponent.prototype.setVisible = function (visible) {
27110 this.configure({ visible: visible });
27113 SequenceComponent.prototype.resize = function () {
27115 this._configuration$.pipe(operators_1.first(), operators_1.map(function (configuration) {
27116 return _this._sequenceDOMRenderer.getContainerWidth(_this._container.element, configuration);
27118 .subscribe(function (containerWidth) {
27119 _this._containerWidth$.next(containerWidth);
27122 SequenceComponent.prototype._activate = function () {
27124 this._sequenceDOMRenderer.activate();
27125 var edgeStatus$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
27126 return node.sequenceEdges$;
27127 }), operators_1.publishReplay(1), operators_1.refCount());
27128 var sequence$ = this._navigator.stateService.currentNode$.pipe(operators_1.distinctUntilChanged(undefined, function (node) {
27129 return node.sequenceKey;
27130 }), operators_1.switchMap(function (node) {
27131 return rxjs_1.concat(rxjs_1.of(null), _this._navigator.graphService.cacheSequence$(node.sequenceKey).pipe(operators_1.retry(3), operators_1.catchError(function (e) {
27132 console.error("Failed to cache sequence", e);
27133 return rxjs_1.of(null);
27135 }), operators_1.startWith(null), operators_1.publishReplay(1), operators_1.refCount());
27136 this._sequenceSubscription = sequence$.subscribe();
27137 var rendererKey$ = this._sequenceDOMRenderer.index$.pipe(operators_1.withLatestFrom(sequence$), operators_1.map(function (_a) {
27138 var index = _a[0], sequence = _a[1];
27139 return sequence != null ? sequence.keys[index] : null;
27140 }), operators_1.filter(function (key) {
27142 }), operators_1.distinctUntilChanged(), operators_1.publish(), operators_1.refCount());
27143 this._moveSubscription = rxjs_1.merge(rendererKey$.pipe(operators_1.debounceTime(100, this._scheduler)), rendererKey$.pipe(operators_1.auditTime(400, this._scheduler))).pipe(operators_1.distinctUntilChanged(), operators_1.switchMap(function (key) {
27144 return _this._navigator.moveToKey$(key).pipe(operators_1.catchError(function (e) {
27145 return rxjs_1.empty();
27149 this._setSequenceGraphModeSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
27152 .subscribe(function () {
27153 _this._navigator.graphService.setGraphMode(Graph_1.GraphMode.Sequence);
27155 this._setSpatialGraphModeSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
27158 .subscribe(function () {
27159 _this._navigator.graphService.setGraphMode(Graph_1.GraphMode.Spatial);
27161 this._navigator.graphService.graphMode$.pipe(operators_1.switchMap(function (mode) {
27162 return mode === Graph_1.GraphMode.Spatial ?
27163 _this._navigator.stateService.currentNode$.pipe(operators_1.take(2)) :
27165 }), operators_1.filter(function (node) {
27166 return !node.spatialEdges.cached;
27167 }), operators_1.switchMap(function (node) {
27168 return _this._navigator.graphService.cacheNode$(node.key).pipe(operators_1.catchError(function (e) {
27169 return rxjs_1.empty();
27173 this._stopSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
27176 .subscribe(function () {
27177 _this._navigator.playService.stop();
27179 this._cacheSequenceNodesSubscription = rxjs_1.combineLatest(this._navigator.graphService.graphMode$, this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.startWith(false), operators_1.distinctUntilChanged())).pipe(operators_1.withLatestFrom(this._navigator.stateService.currentNode$), operators_1.switchMap(function (_a) {
27180 var _b = _a[0], mode = _b[0], changing = _b[1], node = _a[1];
27181 return changing && mode === Graph_1.GraphMode.Sequence ?
27182 _this._navigator.graphService.cacheSequenceNodes$(node.sequenceKey, node.key).pipe(operators_1.retry(3), operators_1.catchError(function (error) {
27183 console.error("Failed to cache sequence nodes.", error);
27184 return rxjs_1.empty();
27189 var position$ = sequence$.pipe(operators_1.switchMap(function (sequence) {
27191 return rxjs_1.of({ index: null, max: null });
27193 var firstCurrentKey = true;
27194 return _this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.startWith(false), operators_1.distinctUntilChanged(), operators_1.switchMap(function (changingPosition) {
27195 var skipCount = !changingPosition && firstCurrentKey ? 0 : 1;
27196 firstCurrentKey = false;
27197 return changingPosition ?
27199 _this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
27201 }), operators_1.distinctUntilChanged(), operators_1.skip(skipCount));
27202 }), operators_1.map(function (key) {
27203 var index = sequence.keys.indexOf(key);
27204 if (index === -1) {
27205 return { index: null, max: null };
27207 return { index: index, max: sequence.keys.length - 1 };
27210 this._renderSubscription = rxjs_1.combineLatest(edgeStatus$, this._configuration$, this._containerWidth$, this._sequenceDOMRenderer.changed$.pipe(operators_1.startWith(this._sequenceDOMRenderer)), this._navigator.playService.speed$, position$).pipe(operators_1.map(function (_a) {
27211 var edgeStatus = _a[0], configuration = _a[1], containerWidth = _a[2], renderer = _a[3], speed = _a[4], position = _a[5];
27212 var vNode = _this._sequenceDOMRenderer
27213 .render(edgeStatus, configuration, containerWidth, speed, position.index, position.max, _this, _this._navigator);
27214 return { name: _this._name, vnode: vNode };
27216 .subscribe(this._container.domRenderer.render$);
27217 this._setSpeedSubscription = this._sequenceDOMRenderer.speed$
27218 .subscribe(function (speed) {
27219 _this._navigator.playService.setSpeed(speed);
27221 this._setDirectionSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
27222 return configuration.direction;
27223 }), operators_1.distinctUntilChanged())
27224 .subscribe(function (direction) {
27225 _this._navigator.playService.setDirection(direction);
27227 this._containerWidthSubscription = this._configuration$.pipe(operators_1.distinctUntilChanged(function (value1, value2) {
27228 return value1[0] === value2[0] && value1[1] === value2[1];
27229 }, function (configuration) {
27230 return [configuration.minWidth, configuration.maxWidth];
27231 }), operators_1.map(function (configuration) {
27232 return _this._sequenceDOMRenderer.getContainerWidth(_this._container.element, configuration);
27234 .subscribe(this._containerWidth$);
27235 this._playingSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
27236 return configuration.playing;
27237 }), operators_1.distinctUntilChanged())
27238 .subscribe(function (playing) {
27240 _this._navigator.playService.play();
27243 _this._navigator.playService.stop();
27246 this._hoveredKeySubscription = this._sequenceDOMRenderer.mouseEnterDirection$.pipe(operators_1.switchMap(function (direction) {
27247 var edgeTo$ = edgeStatus$.pipe(operators_1.map(function (edgeStatus) {
27248 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
27250 if (edge.data.direction === direction) {
27255 }), operators_1.takeUntil(_this._sequenceDOMRenderer.mouseLeaveDirection$));
27256 return rxjs_1.concat(edgeTo$, rxjs_1.of(null));
27257 }), operators_1.distinctUntilChanged())
27258 .subscribe(this._hoveredKeySubject$);
27259 this._emitHoveredKeySubscription = this._hoveredKey$
27260 .subscribe(function (key) {
27261 _this.fire(SequenceComponent.hoveredkeychanged, key);
27264 SequenceComponent.prototype._deactivate = function () {
27265 this._emitHoveredKeySubscription.unsubscribe();
27266 this._renderSubscription.unsubscribe();
27267 this._playingSubscription.unsubscribe();
27268 this._containerWidthSubscription.unsubscribe();
27269 this._hoveredKeySubscription.unsubscribe();
27270 this._setSpeedSubscription.unsubscribe();
27271 this._setDirectionSubscription.unsubscribe();
27272 this._setSequenceGraphModeSubscription.unsubscribe();
27273 this._setSpatialGraphModeSubscription.unsubscribe();
27274 this._sequenceSubscription.unsubscribe();
27275 this._moveSubscription.unsubscribe();
27276 this._cacheSequenceNodesSubscription.unsubscribe();
27277 this._stopSubscription.unsubscribe();
27278 this._sequenceDOMRenderer.deactivate();
27280 SequenceComponent.prototype._getDefaultConfiguration = function () {
27282 direction: Edge_1.EdgeDirection.Next,
27290 SequenceComponent.componentName = "sequence";
27292 * Event fired when playing starts or stops.
27294 * @event SequenceComponent#playingchanged
27295 * @type {boolean} Indicates whether the player is playing.
27297 SequenceComponent.playingchanged = "playingchanged";
27299 * Event fired when the hovered key changes.
27301 * @description Emits the key of the node for the direction
27302 * arrow that is being hovered. When the mouse leaves a
27303 * direction arrow null is emitted.
27305 * @event SequenceComponent#hoveredkeychanged
27306 * @type {string} The hovered key, null if no key is hovered.
27308 SequenceComponent.hoveredkeychanged = "hoveredkeychanged";
27309 return SequenceComponent;
27310 }(Component_1.Component));
27311 exports.SequenceComponent = SequenceComponent;
27312 Component_1.ComponentService.register(SequenceComponent);
27313 exports.default = SequenceComponent;
27315 },{"../../Component":274,"../../Edge":275,"../../Graph":278,"rxjs":26,"rxjs/operators":224}],333:[function(require,module,exports){
27317 Object.defineProperty(exports, "__esModule", { value: true });
27318 var rxjs_1 = require("rxjs");
27319 var operators_1 = require("rxjs/operators");
27320 var vd = require("virtual-dom");
27321 var Component_1 = require("../../Component");
27322 var Edge_1 = require("../../Edge");
27323 var Error_1 = require("../../Error");
27324 var SequenceDOMRenderer = /** @class */ (function () {
27325 function SequenceDOMRenderer(container) {
27326 this._container = container;
27327 this._minThresholdWidth = 320;
27328 this._maxThresholdWidth = 1480;
27329 this._minThresholdHeight = 240;
27330 this._maxThresholdHeight = 820;
27331 this._stepperDefaultWidth = 108;
27332 this._controlsDefaultWidth = 88;
27333 this._defaultHeight = 30;
27334 this._expandControls = false;
27335 this._mode = Component_1.SequenceMode.Default;
27337 this._changingSpeed = false;
27338 this._index = null;
27339 this._changingPosition = false;
27340 this._mouseEnterDirection$ = new rxjs_1.Subject();
27341 this._mouseLeaveDirection$ = new rxjs_1.Subject();
27342 this._notifyChanged$ = new rxjs_1.Subject();
27343 this._notifyChangingPositionChanged$ = new rxjs_1.Subject();
27344 this._notifySpeedChanged$ = new rxjs_1.Subject();
27345 this._notifyIndexChanged$ = new rxjs_1.Subject();
27347 Object.defineProperty(SequenceDOMRenderer.prototype, "changed$", {
27349 return this._notifyChanged$;
27354 Object.defineProperty(SequenceDOMRenderer.prototype, "changingPositionChanged$", {
27356 return this._notifyChangingPositionChanged$;
27361 Object.defineProperty(SequenceDOMRenderer.prototype, "speed$", {
27363 return this._notifySpeedChanged$;
27368 Object.defineProperty(SequenceDOMRenderer.prototype, "index$", {
27370 return this._notifyIndexChanged$;
27375 Object.defineProperty(SequenceDOMRenderer.prototype, "mouseEnterDirection$", {
27377 return this._mouseEnterDirection$;
27382 Object.defineProperty(SequenceDOMRenderer.prototype, "mouseLeaveDirection$", {
27384 return this._mouseLeaveDirection$;
27389 SequenceDOMRenderer.prototype.activate = function () {
27391 if (!!this._changingSubscription) {
27394 this._changingSubscription = rxjs_1.merge(this._container.mouseService.documentMouseUp$, this._container.touchService.touchEnd$.pipe(operators_1.filter(function (touchEvent) {
27395 return touchEvent.touches.length === 0;
27397 .subscribe(function (event) {
27398 if (_this._changingSpeed) {
27399 _this._changingSpeed = false;
27401 if (_this._changingPosition) {
27402 _this._setChangingPosition(false);
27406 SequenceDOMRenderer.prototype.deactivate = function () {
27407 if (!this._changingSubscription) {
27410 this._changingSpeed = false;
27411 this._changingPosition = false;
27412 this._expandControls = false;
27413 this._mode = Component_1.SequenceMode.Default;
27414 this._changingSubscription.unsubscribe();
27415 this._changingSubscription = null;
27417 SequenceDOMRenderer.prototype.render = function (edgeStatus, configuration, containerWidth, speed, index, max, component, navigator) {
27418 if (configuration.visible === false) {
27419 return vd.h("div.SequenceContainer", {}, []);
27421 var stepper = this._createStepper(edgeStatus, configuration, containerWidth, component, navigator);
27422 var controls = this._createSequenceControls(containerWidth);
27423 var playback = this._createPlaybackControls(containerWidth, speed, component, configuration);
27424 var timeline = this._createTimelineControls(containerWidth, index, max);
27425 return vd.h("div.SequenceContainer", [stepper, controls, playback, timeline]);
27427 SequenceDOMRenderer.prototype.getContainerWidth = function (element, configuration) {
27428 var elementWidth = element.offsetWidth;
27429 var elementHeight = element.offsetHeight;
27430 var minWidth = configuration.minWidth;
27431 var maxWidth = configuration.maxWidth;
27432 if (maxWidth < minWidth) {
27433 maxWidth = minWidth;
27435 var relativeWidth = (elementWidth - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth);
27436 var relativeHeight = (elementHeight - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight);
27437 var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight)));
27438 return minWidth + coeff * (maxWidth - minWidth);
27440 SequenceDOMRenderer.prototype._createPositionInput = function (index, max) {
27442 this._index = index;
27443 var onPosition = function (e) {
27444 _this._index = Number(e.target.value);
27445 _this._notifyIndexChanged$.next(_this._index);
27447 var boundingRect = this._container.domContainer.getBoundingClientRect();
27448 var width = Math.max(276, Math.min(410, 5 + 0.8 * boundingRect.width)) - 65;
27449 var onStart = function (e) {
27450 e.stopPropagation();
27451 _this._setChangingPosition(true);
27453 var onMove = function (e) {
27454 if (_this._changingPosition === true) {
27455 e.stopPropagation();
27458 var onKeyDown = function (e) {
27459 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
27460 e.key === "ArrowRight" || e.key === "ArrowUp") {
27461 e.preventDefault();
27464 var positionInputProperties = {
27465 max: max != null ? max : 1,
27467 onchange: onPosition,
27468 oninput: onPosition,
27469 onkeydown: onKeyDown,
27470 onmousedown: onStart,
27471 onmousemove: onMove,
27472 ontouchmove: onMove,
27473 ontouchstart: onStart,
27475 width: width + "px",
27478 value: index != null ? index : 0,
27480 var disabled = index == null || max == null || max <= 1;
27482 positionInputProperties.disabled = "true";
27484 var positionInput = vd.h("input.SequencePosition", positionInputProperties, []);
27485 var positionContainerClass = disabled ? ".SequencePositionContainerDisabled" : ".SequencePositionContainer";
27486 return vd.h("div" + positionContainerClass, [positionInput]);
27488 SequenceDOMRenderer.prototype._createSpeedInput = function (speed) {
27490 this._speed = speed;
27491 var onSpeed = function (e) {
27492 _this._speed = Number(e.target.value) / 1000;
27493 _this._notifySpeedChanged$.next(_this._speed);
27495 var boundingRect = this._container.domContainer.getBoundingClientRect();
27496 var width = Math.max(276, Math.min(410, 5 + 0.8 * boundingRect.width)) - 160;
27497 var onStart = function (e) {
27498 _this._changingSpeed = true;
27499 e.stopPropagation();
27501 var onMove = function (e) {
27502 if (_this._changingSpeed === true) {
27503 e.stopPropagation();
27506 var onKeyDown = function (e) {
27507 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
27508 e.key === "ArrowRight" || e.key === "ArrowUp") {
27509 e.preventDefault();
27512 var speedInput = vd.h("input.SequenceSpeed", {
27517 onkeydown: onKeyDown,
27518 onmousedown: onStart,
27519 onmousemove: onMove,
27520 ontouchmove: onMove,
27521 ontouchstart: onStart,
27523 width: width + "px",
27526 value: 1000 * speed,
27528 return vd.h("div.SequenceSpeedContainer", [speedInput]);
27530 SequenceDOMRenderer.prototype._createPlaybackControls = function (containerWidth, speed, component, configuration) {
27532 if (this._mode !== Component_1.SequenceMode.Playback) {
27533 return vd.h("div.SequencePlayback", []);
27535 var switchIcon = vd.h("div.SequenceSwitchIcon.SequenceIconVisible", []);
27536 var direction = configuration.direction === Edge_1.EdgeDirection.Next ?
27537 Edge_1.EdgeDirection.Prev : Edge_1.EdgeDirection.Next;
27538 var playing = configuration.playing;
27539 var switchButtonProperties = {
27540 onclick: function () {
27542 component.setDirection(direction);
27546 var switchButtonClassName = configuration.playing ? ".SequenceSwitchButtonDisabled" : ".SequenceSwitchButton";
27547 var switchButton = vd.h("div" + switchButtonClassName, switchButtonProperties, [switchIcon]);
27548 var slowIcon = vd.h("div.SequenceSlowIcon.SequenceIconVisible", []);
27549 var slowContainer = vd.h("div.SequenceSlowContainer", [slowIcon]);
27550 var fastIcon = vd.h("div.SequenceFastIcon.SequenceIconVisible", []);
27551 var fastContainer = vd.h("div.SequenceFastContainer", [fastIcon]);
27552 var closeIcon = vd.h("div.SequenceCloseIcon.SequenceIconVisible", []);
27553 var closeButtonProperties = {
27554 onclick: function () {
27555 _this._mode = Component_1.SequenceMode.Default;
27556 _this._notifyChanged$.next(_this);
27559 var closeButton = vd.h("div.SequenceCloseButton", closeButtonProperties, [closeIcon]);
27560 var speedInput = this._createSpeedInput(speed);
27561 var playbackChildren = [switchButton, slowContainer, speedInput, fastContainer, closeButton];
27562 var top = Math.round(containerWidth / this._stepperDefaultWidth * this._defaultHeight + 10);
27563 var playbackProperties = { style: { top: top + "px" } };
27564 return vd.h("div.SequencePlayback", playbackProperties, playbackChildren);
27566 SequenceDOMRenderer.prototype._createPlayingButton = function (nextKey, prevKey, configuration, component) {
27567 var canPlay = configuration.direction === Edge_1.EdgeDirection.Next && nextKey != null ||
27568 configuration.direction === Edge_1.EdgeDirection.Prev && prevKey != null;
27569 var onclick = configuration.playing ?
27570 function (e) { component.stop(); } :
27571 canPlay ? function (e) { component.play(); } : null;
27572 var buttonProperties = { onclick: onclick };
27573 var iconClass = configuration.playing ?
27575 canPlay ? "Play" : "PlayDisabled";
27576 var iconProperties = { className: iconClass };
27577 if (configuration.direction === Edge_1.EdgeDirection.Prev) {
27578 iconProperties.style = {
27579 transform: "rotate(180deg) translate(50%, 50%)",
27582 var icon = vd.h("div.SequenceComponentIcon", iconProperties, []);
27583 var buttonClass = canPlay ? "SequencePlay" : "SequencePlayDisabled";
27584 return vd.h("div." + buttonClass, buttonProperties, [icon]);
27586 SequenceDOMRenderer.prototype._createSequenceControls = function (containerWidth) {
27588 var borderRadius = Math.round(8 / this._stepperDefaultWidth * containerWidth);
27589 var expanderProperties = {
27590 onclick: function () {
27591 _this._expandControls = !_this._expandControls;
27592 _this._mode = Component_1.SequenceMode.Default;
27593 _this._notifyChanged$.next(_this);
27596 "border-bottom-right-radius": borderRadius + "px",
27597 "border-top-right-radius": borderRadius + "px",
27600 var expanderBar = vd.h("div.SequenceExpanderBar", []);
27601 var expander = vd.h("div.SequenceExpanderButton", expanderProperties, [expanderBar]);
27602 var fastIconClassName = this._mode === Component_1.SequenceMode.Playback ?
27603 ".SequenceFastIconGrey.SequenceIconVisible" : ".SequenceFastIcon";
27604 var fastIcon = vd.h("div" + fastIconClassName, []);
27605 var playbackProperties = {
27606 onclick: function () {
27607 _this._mode = _this._mode === Component_1.SequenceMode.Playback ?
27608 Component_1.SequenceMode.Default :
27609 Component_1.SequenceMode.Playback;
27610 _this._notifyChanged$.next(_this);
27613 var playback = vd.h("div.SequencePlaybackButton", playbackProperties, [fastIcon]);
27614 var timelineIconClassName = this._mode === Component_1.SequenceMode.Timeline ?
27615 ".SequenceTimelineIconGrey.SequenceIconVisible" : ".SequenceTimelineIcon";
27616 var timelineIcon = vd.h("div" + timelineIconClassName, []);
27617 var timelineProperties = {
27618 onclick: function () {
27619 _this._mode = _this._mode === Component_1.SequenceMode.Timeline ?
27620 Component_1.SequenceMode.Default :
27621 Component_1.SequenceMode.Timeline;
27622 _this._notifyChanged$.next(_this);
27625 var timeline = vd.h("div.SequenceTimelineButton", timelineProperties, [timelineIcon]);
27628 height: (this._defaultHeight / this._stepperDefaultWidth * containerWidth) + "px",
27629 transform: "translate(" + (containerWidth / 2 + 2) + "px, 0)",
27630 width: (this._controlsDefaultWidth / this._stepperDefaultWidth * containerWidth) + "px",
27633 var className = ".SequenceControls" +
27634 (this._expandControls ? ".SequenceControlsExpanded" : "");
27635 return vd.h("div" + className, properties, [playback, timeline, expander]);
27637 SequenceDOMRenderer.prototype._createSequenceArrows = function (nextKey, prevKey, containerWidth, configuration, navigator) {
27639 var nextProperties = {
27640 onclick: nextKey != null ?
27642 navigator.moveDir$(Edge_1.EdgeDirection.Next)
27643 .subscribe(undefined, function (error) {
27644 if (!(error instanceof Error_1.AbortMapillaryError)) {
27645 console.error(error);
27650 onmouseenter: function (e) { _this._mouseEnterDirection$.next(Edge_1.EdgeDirection.Next); },
27651 onmouseleave: function (e) { _this._mouseLeaveDirection$.next(Edge_1.EdgeDirection.Next); },
27653 var borderRadius = Math.round(8 / this._stepperDefaultWidth * containerWidth);
27654 var prevProperties = {
27655 onclick: prevKey != null ?
27657 navigator.moveDir$(Edge_1.EdgeDirection.Prev)
27658 .subscribe(undefined, function (error) {
27659 if (!(error instanceof Error_1.AbortMapillaryError)) {
27660 console.error(error);
27665 onmouseenter: function (e) { _this._mouseEnterDirection$.next(Edge_1.EdgeDirection.Prev); },
27666 onmouseleave: function (e) { _this._mouseLeaveDirection$.next(Edge_1.EdgeDirection.Prev); },
27668 "border-bottom-left-radius": borderRadius + "px",
27669 "border-top-left-radius": borderRadius + "px",
27672 var nextClass = this._getStepClassName(Edge_1.EdgeDirection.Next, nextKey, configuration.highlightKey);
27673 var prevClass = this._getStepClassName(Edge_1.EdgeDirection.Prev, prevKey, configuration.highlightKey);
27674 var nextIcon = vd.h("div.SequenceComponentIcon", []);
27675 var prevIcon = vd.h("div.SequenceComponentIcon", []);
27677 vd.h("div." + prevClass, prevProperties, [prevIcon]),
27678 vd.h("div." + nextClass, nextProperties, [nextIcon]),
27681 SequenceDOMRenderer.prototype._createStepper = function (edgeStatus, configuration, containerWidth, component, navigator) {
27682 var nextKey = null;
27683 var prevKey = null;
27684 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
27686 if (edge.data.direction === Edge_1.EdgeDirection.Next) {
27689 if (edge.data.direction === Edge_1.EdgeDirection.Prev) {
27693 var playingButton = this._createPlayingButton(nextKey, prevKey, configuration, component);
27694 var buttons = this._createSequenceArrows(nextKey, prevKey, containerWidth, configuration, navigator);
27695 buttons.splice(1, 0, playingButton);
27696 var containerProperties = {
27697 oncontextmenu: function (event) { event.preventDefault(); },
27699 height: (this._defaultHeight / this._stepperDefaultWidth * containerWidth) + "px",
27700 width: containerWidth + "px",
27703 return vd.h("div.SequenceStepper", containerProperties, buttons);
27705 SequenceDOMRenderer.prototype._createTimelineControls = function (containerWidth, index, max) {
27707 if (this._mode !== Component_1.SequenceMode.Timeline) {
27708 return vd.h("div.SequenceTimeline", []);
27710 var positionInput = this._createPositionInput(index, max);
27711 var closeIcon = vd.h("div.SequenceCloseIcon.SequenceIconVisible", []);
27712 var closeButtonProperties = {
27713 onclick: function () {
27714 _this._mode = Component_1.SequenceMode.Default;
27715 _this._notifyChanged$.next(_this);
27718 var closeButton = vd.h("div.SequenceCloseButton", closeButtonProperties, [closeIcon]);
27719 var top = Math.round(containerWidth / this._stepperDefaultWidth * this._defaultHeight + 10);
27720 var playbackProperties = { style: { top: top + "px" } };
27721 return vd.h("div.SequenceTimeline", playbackProperties, [positionInput, closeButton]);
27723 SequenceDOMRenderer.prototype._getStepClassName = function (direction, key, highlightKey) {
27724 var className = direction === Edge_1.EdgeDirection.Next ?
27725 "SequenceStepNext" :
27726 "SequenceStepPrev";
27728 className += "Disabled";
27731 if (highlightKey === key) {
27732 className += "Highlight";
27737 SequenceDOMRenderer.prototype._setChangingPosition = function (value) {
27738 this._changingPosition = value;
27739 this._notifyChangingPositionChanged$.next(value);
27741 return SequenceDOMRenderer;
27743 exports.SequenceDOMRenderer = SequenceDOMRenderer;
27744 exports.default = SequenceDOMRenderer;
27747 },{"../../Component":274,"../../Edge":275,"../../Error":276,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],334:[function(require,module,exports){
27749 Object.defineProperty(exports, "__esModule", { value: true });
27751 (function (SequenceMode) {
27752 SequenceMode[SequenceMode["Default"] = 0] = "Default";
27753 SequenceMode[SequenceMode["Playback"] = 1] = "Playback";
27754 SequenceMode[SequenceMode["Timeline"] = 2] = "Timeline";
27755 })(SequenceMode = exports.SequenceMode || (exports.SequenceMode = {}));
27756 exports.default = SequenceMode;
27758 },{}],335:[function(require,module,exports){
27760 Object.defineProperty(exports, "__esModule", { value: true });
27762 var path = require("path");
27763 var Shaders = /** @class */ (function () {
27764 function Shaders() {
27766 Shaders.equirectangular = {
27767 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float phiLength;\nuniform float phiShift;\nuniform float thetaLength;\nuniform float thetaShift;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vec3 b = normalize(vRstq.xyz);\n float lat = -asin(b.y);\n float lon = atan(b.x, b.z);\n float x = (lon - phiShift) / phiLength + 0.5;\n float y = (lat - thetaShift) / thetaLength + 0.5;\n vec4 baseColor = texture2D(projectorTex, vec2(x, y));\n baseColor.a = opacity;\n gl_FragColor = baseColor;\n}",
27768 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",
27770 Shaders.equirectangularCurtain = {
27771 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float curtain;\nuniform float opacity;\nuniform float phiLength;\nuniform float phiShift;\nuniform float thetaLength;\nuniform float thetaShift;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vec3 b = normalize(vRstq.xyz);\n float lat = -asin(b.y);\n float lon = atan(b.x, b.z);\n float x = (lon - phiShift) / phiLength + 0.5;\n float y = (lat - thetaShift) / thetaLength + 0.5;\n\n bool inverted = curtain < 0.5;\n\n float curtainMin = inverted ? curtain + 0.5 : curtain - 0.5;\n float curtainMax = curtain;\n\n bool insideCurtain = inverted ?\n x > curtainMin || x < curtainMax :\n x > curtainMin && x < curtainMax;\n\n vec4 baseColor;\n if (insideCurtain) {\n baseColor = texture2D(projectorTex, vec2(x, y));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}",
27772 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",
27774 Shaders.perspective = {
27775 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.z;\n float y = vRstq.y / vRstq.z;\n float r2 = x * x + y * y;\n\n if (radial_peak > 0. && r2 > radial_peak * sqrt(r2)) {\n r2 = radial_peak * radial_peak;\n }\n\n float d = 1.0 + k1 * r2 + k2 * r2 * r2;\n float u = scale_x * focal * d * x + 0.5;\n float v = - scale_y * focal * d * y + 0.5;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}",
27776 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",
27778 Shaders.perspectiveCurtain = {
27779 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.z;\n float y = vRstq.y / vRstq.z;\n float r2 = x * x + y * y;\n\n if (radial_peak > 0. && r2 > radial_peak * sqrt(r2)) {\n r2 = radial_peak * radial_peak;\n }\n\n float d = 1.0 + k1 * r2 + k2 * r2 * r2;\n float u = scale_x * focal * d * x + 0.5;\n float v = - scale_y * focal * d * y + 0.5;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",
27780 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",
27782 Shaders.perspectiveDistorted = {
27783 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float u = vRstq.x / vRstq.w;\n float v = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",
27784 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",
27786 Shaders.perspectiveDistortedCurtain = {
27787 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float u = vRstq.x / vRstq.w;\n float v = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",
27788 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",
27792 exports.Shaders = Shaders;
27795 },{"path":22}],336:[function(require,module,exports){
27797 var __extends = (this && this.__extends) || (function () {
27798 var extendStatics = function (d, b) {
27799 extendStatics = Object.setPrototypeOf ||
27800 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27801 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27802 return extendStatics(d, b);
27804 return function (d, b) {
27805 extendStatics(d, b);
27806 function __() { this.constructor = d; }
27807 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27810 Object.defineProperty(exports, "__esModule", { value: true });
27811 var rxjs_1 = require("rxjs");
27812 var operators_1 = require("rxjs/operators");
27813 var Component_1 = require("../../Component");
27814 var Geo_1 = require("../../Geo");
27815 var State_1 = require("../../State");
27816 var Render_1 = require("../../Render");
27817 var Tiles_1 = require("../../Tiles");
27818 var Utils_1 = require("../../Utils");
27820 * @class SliderComponent
27822 * @classdesc Component for comparing pairs of images. Renders
27823 * a slider for adjusting the curtain of the first image.
27825 * Deactivate the sequence, direction and image plane
27826 * components when activating the slider component to avoid
27827 * interfering UI elements.
27829 * To retrive and use the marker component
27833 * var viewer = new Mapillary.Viewer(
27838 * viewer.deactivateComponent("imagePlane");
27839 * viewer.deactivateComponent("direction");
27840 * viewer.deactivateComponent("sequence");
27842 * viewer.activateComponent("slider");
27844 * var sliderComponent = viewer.getComponent("marker");
27847 var SliderComponent = /** @class */ (function (_super) {
27848 __extends(SliderComponent, _super);
27850 function SliderComponent(name, container, navigator, viewportCoords) {
27851 var _this = _super.call(this, name, container, navigator) || this;
27852 _this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
27853 _this._domRenderer = new Component_1.SliderDOMRenderer(container);
27854 _this._imageTileLoader = new Tiles_1.ImageTileLoader(Utils_1.Urls.tileScheme, Utils_1.Urls.tileDomain, Utils_1.Urls.origin);
27855 _this._roiCalculator = new Tiles_1.RegionOfInterestCalculator();
27856 _this._spatial = new Geo_1.Spatial();
27857 _this._glRendererOperation$ = new rxjs_1.Subject();
27858 _this._glRendererCreator$ = new rxjs_1.Subject();
27859 _this._glRendererDisposer$ = new rxjs_1.Subject();
27860 _this._glRenderer$ = _this._glRendererOperation$.pipe(operators_1.scan(function (glRenderer, operation) {
27861 return operation(glRenderer);
27862 }, null), operators_1.filter(function (glRenderer) {
27863 return glRenderer != null;
27864 }), operators_1.distinctUntilChanged(undefined, function (glRenderer) {
27865 return glRenderer.frameId;
27867 _this._glRendererCreator$.pipe(operators_1.map(function () {
27868 return function (glRenderer) {
27869 if (glRenderer != null) {
27870 throw new Error("Multiple slider states can not be created at the same time");
27872 return new Component_1.SliderGLRenderer();
27875 .subscribe(_this._glRendererOperation$);
27876 _this._glRendererDisposer$.pipe(operators_1.map(function () {
27877 return function (glRenderer) {
27878 glRenderer.dispose();
27882 .subscribe(_this._glRendererOperation$);
27886 * Set the initial position.
27888 * @description Configures the intial position of the slider.
27889 * The inital position value will be used when the component
27892 * @param {number} initialPosition - Initial slider position.
27894 SliderComponent.prototype.setInitialPosition = function (initialPosition) {
27895 this.configure({ initialPosition: initialPosition });
27898 * Set the image keys.
27900 * @description Configures the component to show the image
27901 * planes for the supplied image keys.
27903 * @param {ISliderKeys} keys - Slider keys object specifying
27904 * the images to be shown in the foreground and the background.
27906 SliderComponent.prototype.setKeys = function (keys) {
27907 this.configure({ keys: keys });
27910 * Set the slider mode.
27912 * @description Configures the mode for transitions between
27915 * @param {SliderMode} mode - Slider mode to be set.
27917 SliderComponent.prototype.setSliderMode = function (mode) {
27918 this.configure({ mode: mode });
27921 * Set the value controlling if the slider is visible.
27923 * @param {boolean} sliderVisible - Value indicating if
27924 * the slider should be visible or not.
27926 SliderComponent.prototype.setSliderVisible = function (sliderVisible) {
27927 this.configure({ sliderVisible: sliderVisible });
27929 SliderComponent.prototype._activate = function () {
27931 this._modeSubcription = this._domRenderer.mode$
27932 .subscribe(function (mode) {
27933 _this.setSliderMode(mode);
27935 this._glRenderSubscription = this._glRenderer$.pipe(operators_1.map(function (glRenderer) {
27939 frameId: glRenderer.frameId,
27940 needsRender: glRenderer.needsRender,
27941 render: glRenderer.render.bind(glRenderer),
27942 stage: Render_1.GLRenderStage.Background,
27947 .subscribe(this._container.glRenderer.render$);
27948 var position$ = rxjs_1.concat(this.configuration$.pipe(operators_1.map(function (configuration) {
27949 return configuration.initialPosition != null ?
27950 configuration.initialPosition : 1;
27951 }), operators_1.first()), this._domRenderer.position$);
27952 var mode$ = this.configuration$.pipe(operators_1.map(function (configuration) {
27953 return configuration.mode;
27954 }), operators_1.distinctUntilChanged());
27955 var motionless$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
27956 return frame.state.motionless;
27957 }), operators_1.distinctUntilChanged());
27958 var fullPano$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
27959 return frame.state.currentNode.fullPano;
27960 }), operators_1.distinctUntilChanged());
27961 var sliderVisible$ = rxjs_1.combineLatest(this._configuration$.pipe(operators_1.map(function (configuration) {
27962 return configuration.sliderVisible;
27963 })), this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
27964 return !(frame.state.currentNode == null ||
27965 frame.state.previousNode == null ||
27966 (frame.state.currentNode.pano && !frame.state.currentNode.fullPano) ||
27967 (frame.state.previousNode.pano && !frame.state.previousNode.fullPano) ||
27968 (frame.state.currentNode.fullPano && !frame.state.previousNode.fullPano));
27969 }), operators_1.distinctUntilChanged())).pipe(operators_1.map(function (_a) {
27970 var sliderVisible = _a[0], enabledState = _a[1];
27971 return sliderVisible && enabledState;
27972 }), operators_1.distinctUntilChanged());
27973 this._waitSubscription = rxjs_1.combineLatest(mode$, motionless$, fullPano$, sliderVisible$).pipe(operators_1.withLatestFrom(this._navigator.stateService.state$))
27974 .subscribe(function (_a) {
27975 var _b = _a[0], mode = _b[0], motionless = _b[1], fullPano = _b[2], sliderVisible = _b[3], state = _a[1];
27976 var interactive = sliderVisible &&
27977 (motionless || mode === Component_1.SliderMode.Stationary || fullPano);
27978 if (interactive && state !== State_1.State.WaitingInteractively) {
27979 _this._navigator.stateService.waitInteractively();
27981 else if (!interactive && state !== State_1.State.Waiting) {
27982 _this._navigator.stateService.wait();
27985 this._moveSubscription = rxjs_1.combineLatest(position$, mode$, motionless$, fullPano$, sliderVisible$)
27986 .subscribe(function (_a) {
27987 var position = _a[0], mode = _a[1], motionless = _a[2], fullPano = _a[3], sliderVisible = _a[4];
27988 if (motionless || mode === Component_1.SliderMode.Stationary || fullPano) {
27989 _this._navigator.stateService.moveTo(1);
27992 _this._navigator.stateService.moveTo(position);
27995 this._domRenderSubscription = rxjs_1.combineLatest(position$, mode$, motionless$, fullPano$, sliderVisible$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
27996 var position = _a[0], mode = _a[1], motionless = _a[2], fullPano = _a[3], sliderVisible = _a[4], size = _a[5];
27999 vnode: _this._domRenderer.render(position, mode, motionless, fullPano, sliderVisible),
28002 .subscribe(this._container.domRenderer.render$);
28003 this._glRendererCreator$.next(null);
28004 this._updateCurtainSubscription = rxjs_1.combineLatest(position$, fullPano$, sliderVisible$, this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.map(function (_a) {
28005 var position = _a[0], fullPano = _a[1], visible = _a[2], render = _a[3], transform = _a[4];
28007 return visible ? position : 1;
28009 var basicMin = _this._viewportCoords.viewportToBasic(-1.15, 0, transform, render.perspective);
28010 var basicMax = _this._viewportCoords.viewportToBasic(1.15, 0, transform, render.perspective);
28011 var shiftedMax = basicMax[0] < basicMin[0] ? basicMax[0] + 1 : basicMax[0];
28012 var basicPosition = basicMin[0] + position * (shiftedMax - basicMin[0]);
28013 return basicPosition > 1 ? basicPosition - 1 : basicPosition;
28014 }), operators_1.map(function (position) {
28015 return function (glRenderer) {
28016 glRenderer.updateCurtain(position);
28020 .subscribe(this._glRendererOperation$);
28021 this._stateSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentState$, mode$).pipe(operators_1.map(function (_a) {
28022 var frame = _a[0], mode = _a[1];
28023 return function (glRenderer) {
28024 glRenderer.update(frame, mode);
28028 .subscribe(this._glRendererOperation$);
28029 this._setKeysSubscription = this._configuration$.pipe(operators_1.filter(function (configuration) {
28030 return configuration.keys != null;
28031 }), operators_1.switchMap(function (configuration) {
28032 return rxjs_1.zip(rxjs_1.zip(_this._catchCacheNode$(configuration.keys.background), _this._catchCacheNode$(configuration.keys.foreground)).pipe(operators_1.map(function (nodes) {
28033 return { background: nodes[0], foreground: nodes[1] };
28034 })), _this._navigator.stateService.currentState$.pipe(operators_1.first())).pipe(operators_1.map(function (nf) {
28035 return { nodes: nf[0], state: nf[1].state };
28038 .subscribe(function (co) {
28039 if (co.state.currentNode != null &&
28040 co.state.previousNode != null &&
28041 co.state.currentNode.key === co.nodes.foreground.key &&
28042 co.state.previousNode.key === co.nodes.background.key) {
28045 if (co.state.currentNode.key === co.nodes.background.key) {
28046 _this._navigator.stateService.setNodes([co.nodes.foreground]);
28049 if (co.state.currentNode.key === co.nodes.foreground.key &&
28050 co.state.trajectory.length === 1) {
28051 _this._navigator.stateService.prependNodes([co.nodes.background]);
28054 _this._navigator.stateService.setNodes([co.nodes.background]);
28055 _this._navigator.stateService.setNodes([co.nodes.foreground]);
28059 var previousNode$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
28060 return frame.state.previousNode;
28061 }), operators_1.filter(function (node) {
28062 return node != null;
28063 }), operators_1.distinctUntilChanged(undefined, function (node) {
28066 var textureProvider$ = this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
28067 return frame.state.currentNode.key;
28068 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
28069 var frame = _a[0], renderer = _a[1], size = _a[2];
28070 var state = frame.state;
28071 var viewportSize = Math.max(size.width, size.height);
28072 var currentNode = state.currentNode;
28073 var currentTransform = state.currentTransform;
28074 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
28075 return new Tiles_1.TextureProvider(currentNode.key, currentTransform.basicWidth, currentTransform.basicHeight, tileSize, currentNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
28076 }), operators_1.publishReplay(1), operators_1.refCount());
28077 this._textureProviderSubscription = textureProvider$.subscribe(function () { });
28078 this._setTextureProviderSubscription = textureProvider$.pipe(operators_1.map(function (provider) {
28079 return function (renderer) {
28080 renderer.setTextureProvider(provider.key, provider);
28084 .subscribe(this._glRendererOperation$);
28085 this._setTileSizeSubscription = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
28086 return rxjs_1.combineLatest(textureProvider$, rxjs_1.of(size)).pipe(operators_1.first());
28088 .subscribe(function (_a) {
28089 var provider = _a[0], size = _a[1];
28090 var viewportSize = Math.max(size.width, size.height);
28091 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
28092 provider.setTileSize(tileSize);
28094 this._abortTextureProviderSubscription = textureProvider$.pipe(operators_1.pairwise())
28095 .subscribe(function (pair) {
28096 var previous = pair[0];
28099 var roiTrigger$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
28100 var camera = _a[0], size = _a[1];
28102 camera.camera.position.clone(),
28103 camera.camera.lookat.clone(),
28104 camera.zoom.valueOf(),
28105 size.height.valueOf(),
28106 size.width.valueOf()
28108 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
28109 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
28110 }), operators_1.map(function (pls) {
28111 var samePosition = pls[0][0].equals(pls[1][0]);
28112 var sameLookat = pls[0][1].equals(pls[1][1]);
28113 var sameZoom = pls[0][2] === pls[1][2];
28114 var sameHeight = pls[0][3] === pls[1][3];
28115 var sameWidth = pls[0][4] === pls[1][4];
28116 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
28117 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
28119 }), operators_1.switchMap(function (stalled) {
28120 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
28121 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
28122 this._setRegionOfInterestSubscription = textureProvider$.pipe(operators_1.switchMap(function (provider) {
28123 return roiTrigger$.pipe(operators_1.map(function (_a) {
28124 var camera = _a[0], size = _a[1], transform = _a[2];
28126 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
28130 }), operators_1.filter(function (args) {
28131 return !args[1].disposed;
28133 .subscribe(function (args) {
28135 var provider = args[1];
28136 provider.setRegionOfInterest(roi);
28138 var hasTexture$ = textureProvider$.pipe(operators_1.switchMap(function (provider) {
28139 return provider.hasTexture$;
28140 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
28141 this._hasTextureSubscription = hasTexture$.subscribe(function () { });
28142 var nodeImage$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
28143 return frame.state.nodesAhead === 0;
28144 }), operators_1.map(function (frame) {
28145 return frame.state.currentNode;
28146 }), operators_1.distinctUntilChanged(undefined, function (node) {
28148 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexture$), operators_1.filter(function (args) {
28150 }), operators_1.map(function (args) {
28152 }), operators_1.filter(function (node) {
28154 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
28155 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
28156 }), operators_1.switchMap(function (node) {
28157 var baseImageSize = node.pano ?
28158 Utils_1.Settings.basePanoramaSize :
28159 Utils_1.Settings.baseImageSize;
28160 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
28161 return rxjs_1.empty();
28164 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
28165 return [n.image, n];
28167 return image$.pipe(operators_1.takeUntil(hasTexture$.pipe(operators_1.filter(function (hasTexture) {
28169 }))), operators_1.catchError(function (error, caught) {
28170 console.error("Failed to fetch high res image (" + node.key + ")", error);
28171 return rxjs_1.empty();
28173 })).pipe(operators_1.publish(), operators_1.refCount());
28174 this._updateBackgroundSubscription = nodeImage$.pipe(operators_1.withLatestFrom(textureProvider$))
28175 .subscribe(function (args) {
28176 if (args[0][1].key !== args[1].key ||
28177 args[1].disposed) {
28180 args[1].updateBackground(args[0][0]);
28182 this._updateTextureImageSubscription = nodeImage$.pipe(operators_1.map(function (imn) {
28183 return function (renderer) {
28184 renderer.updateTextureImage(imn[0], imn[1]);
28188 .subscribe(this._glRendererOperation$);
28189 var textureProviderPrev$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
28190 return !!frame.state.previousNode;
28191 }), operators_1.distinctUntilChanged(undefined, function (frame) {
28192 return frame.state.previousNode.key;
28193 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
28194 var frame = _a[0], renderer = _a[1], size = _a[2];
28195 var state = frame.state;
28196 var viewportSize = Math.max(size.width, size.height);
28197 var previousNode = state.previousNode;
28198 var previousTransform = state.previousTransform;
28199 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
28200 return new Tiles_1.TextureProvider(previousNode.key, previousTransform.basicWidth, previousTransform.basicHeight, tileSize, previousNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
28201 }), operators_1.publishReplay(1), operators_1.refCount());
28202 this._textureProviderSubscriptionPrev = textureProviderPrev$.subscribe(function () { });
28203 this._setTextureProviderSubscriptionPrev = textureProviderPrev$.pipe(operators_1.map(function (provider) {
28204 return function (renderer) {
28205 renderer.setTextureProviderPrev(provider.key, provider);
28209 .subscribe(this._glRendererOperation$);
28210 this._setTileSizeSubscriptionPrev = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
28211 return rxjs_1.combineLatest(textureProviderPrev$, rxjs_1.of(size)).pipe(operators_1.first());
28213 .subscribe(function (_a) {
28214 var provider = _a[0], size = _a[1];
28215 var viewportSize = Math.max(size.width, size.height);
28216 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
28217 provider.setTileSize(tileSize);
28219 this._abortTextureProviderSubscriptionPrev = textureProviderPrev$.pipe(operators_1.pairwise())
28220 .subscribe(function (pair) {
28221 var previous = pair[0];
28224 var roiTriggerPrev$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
28225 var camera = _a[0], size = _a[1];
28227 camera.camera.position.clone(),
28228 camera.camera.lookat.clone(),
28229 camera.zoom.valueOf(),
28230 size.height.valueOf(),
28231 size.width.valueOf()
28233 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
28234 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
28235 }), operators_1.map(function (pls) {
28236 var samePosition = pls[0][0].equals(pls[1][0]);
28237 var sameLookat = pls[0][1].equals(pls[1][1]);
28238 var sameZoom = pls[0][2] === pls[1][2];
28239 var sameHeight = pls[0][3] === pls[1][3];
28240 var sameWidth = pls[0][4] === pls[1][4];
28241 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
28242 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
28244 }), operators_1.switchMap(function (stalled) {
28245 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
28246 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
28247 this._setRegionOfInterestSubscriptionPrev = textureProviderPrev$.pipe(operators_1.switchMap(function (provider) {
28248 return roiTriggerPrev$.pipe(operators_1.map(function (_a) {
28249 var camera = _a[0], size = _a[1], transform = _a[2];
28251 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
28255 }), operators_1.filter(function (args) {
28256 return !args[1].disposed;
28257 }), operators_1.withLatestFrom(this._navigator.stateService.currentState$))
28258 .subscribe(function (_a) {
28259 var _b = _a[0], roi = _b[0], provider = _b[1], frame = _a[1];
28260 var shiftedRoi = null;
28261 if (frame.state.previousNode.fullPano) {
28262 if (frame.state.currentNode.fullPano) {
28263 var currentViewingDirection = _this._spatial.viewingDirection(frame.state.currentNode.rotation);
28264 var previousViewingDirection = _this._spatial.viewingDirection(frame.state.previousNode.rotation);
28265 var directionDiff = _this._spatial.angleBetweenVector2(currentViewingDirection.x, currentViewingDirection.y, previousViewingDirection.x, previousViewingDirection.y);
28266 var shift = directionDiff / (2 * Math.PI);
28268 maxX: _this._spatial.wrap(roi.bbox.maxX + shift, 0, 1),
28269 maxY: roi.bbox.maxY,
28270 minX: _this._spatial.wrap(roi.bbox.minX + shift, 0, 1),
28271 minY: roi.bbox.minY,
28275 pixelHeight: roi.pixelHeight,
28276 pixelWidth: roi.pixelWidth,
28280 var currentViewingDirection = _this._spatial.viewingDirection(frame.state.currentNode.rotation);
28281 var previousViewingDirection = _this._spatial.viewingDirection(frame.state.previousNode.rotation);
28282 var directionDiff = _this._spatial.angleBetweenVector2(currentViewingDirection.x, currentViewingDirection.y, previousViewingDirection.x, previousViewingDirection.y);
28283 var shiftX = directionDiff / (2 * Math.PI);
28284 var a1 = _this._spatial.angleToPlane(currentViewingDirection.toArray(), [0, 0, 1]);
28285 var a2 = _this._spatial.angleToPlane(previousViewingDirection.toArray(), [0, 0, 1]);
28286 var shiftY = (a2 - a1) / (2 * Math.PI);
28287 var currentTransform = frame.state.currentTransform;
28288 var size = Math.max(currentTransform.basicWidth, currentTransform.basicHeight);
28289 var hFov = size > 0 ?
28290 2 * Math.atan(0.5 * currentTransform.basicWidth / (size * currentTransform.focal)) :
28292 var vFov = size > 0 ?
28293 2 * Math.atan(0.5 * currentTransform.basicHeight / (size * currentTransform.focal)) :
28295 var spanningWidth = hFov / (2 * Math.PI);
28296 var spanningHeight = vFov / Math.PI;
28297 var basicWidth = (roi.bbox.maxX - roi.bbox.minX) * spanningWidth;
28298 var basicHeight = (roi.bbox.maxY - roi.bbox.minY) * spanningHeight;
28299 var pixelWidth = roi.pixelWidth * spanningWidth;
28300 var pixelHeight = roi.pixelHeight * spanningHeight;
28301 var zoomShiftX = (roi.bbox.minX + roi.bbox.maxX) / 2 - 0.5;
28302 var zoomShiftY = (roi.bbox.minY + roi.bbox.maxY) / 2 - 0.5;
28303 var minX = 0.5 + shiftX + spanningWidth * zoomShiftX - basicWidth / 2;
28304 var maxX = 0.5 + shiftX + spanningWidth * zoomShiftX + basicWidth / 2;
28305 var minY = 0.5 + shiftY + spanningHeight * zoomShiftY - basicHeight / 2;
28306 var maxY = 0.5 + shiftY + spanningHeight * zoomShiftY + basicHeight / 2;
28308 maxX: _this._spatial.wrap(maxX, 0, 1),
28310 minX: _this._spatial.wrap(minX, 0, 1),
28315 pixelHeight: pixelHeight,
28316 pixelWidth: pixelWidth,
28321 var currentBasicAspect = frame.state.currentTransform.basicAspect;
28322 var previousBasicAspect = frame.state.previousTransform.basicAspect;
28323 var _c = _this._getBasicCorners(currentBasicAspect, previousBasicAspect), _d = _c[0], cornerMinX = _d[0], cornerMinY = _d[1], _e = _c[1], cornerMaxX = _e[0], cornerMaxY = _e[1];
28324 var basicWidth = cornerMaxX - cornerMinX;
28325 var basicHeight = cornerMaxY - cornerMinY;
28326 var pixelWidth = roi.pixelWidth / basicWidth;
28327 var pixelHeight = roi.pixelHeight / basicHeight;
28328 var minX = (basicWidth - 1) / (2 * basicWidth) + roi.bbox.minX / basicWidth;
28329 var maxX = (basicWidth - 1) / (2 * basicWidth) + roi.bbox.maxX / basicWidth;
28330 var minY = (basicHeight - 1) / (2 * basicHeight) + roi.bbox.minY / basicHeight;
28331 var maxY = (basicHeight - 1) / (2 * basicHeight) + roi.bbox.maxY / basicHeight;
28338 _this._clipBoundingBox(bbox);
28341 pixelHeight: pixelHeight,
28342 pixelWidth: pixelWidth,
28345 provider.setRegionOfInterest(shiftedRoi);
28347 var hasTexturePrev$ = textureProviderPrev$.pipe(operators_1.switchMap(function (provider) {
28348 return provider.hasTexture$;
28349 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
28350 this._hasTextureSubscriptionPrev = hasTexturePrev$.subscribe(function () { });
28351 var nodeImagePrev$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
28352 return frame.state.nodesAhead === 0 && !!frame.state.previousNode;
28353 }), operators_1.map(function (frame) {
28354 return frame.state.previousNode;
28355 }), operators_1.distinctUntilChanged(undefined, function (node) {
28357 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexturePrev$), operators_1.filter(function (args) {
28359 }), operators_1.map(function (args) {
28361 }), operators_1.filter(function (node) {
28363 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
28364 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
28365 }), operators_1.switchMap(function (node) {
28366 var baseImageSize = node.pano ?
28367 Utils_1.Settings.basePanoramaSize :
28368 Utils_1.Settings.baseImageSize;
28369 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
28370 return rxjs_1.empty();
28373 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
28374 return [n.image, n];
28376 return image$.pipe(operators_1.takeUntil(hasTexturePrev$.pipe(operators_1.filter(function (hasTexture) {
28378 }))), operators_1.catchError(function (error, caught) {
28379 console.error("Failed to fetch high res image (" + node.key + ")", error);
28380 return rxjs_1.empty();
28382 })).pipe(operators_1.publish(), operators_1.refCount());
28383 this._updateBackgroundSubscriptionPrev = nodeImagePrev$.pipe(operators_1.withLatestFrom(textureProviderPrev$))
28384 .subscribe(function (args) {
28385 if (args[0][1].key !== args[1].key ||
28386 args[1].disposed) {
28389 args[1].updateBackground(args[0][0]);
28391 this._updateTextureImageSubscriptionPrev = nodeImagePrev$.pipe(operators_1.map(function (imn) {
28392 return function (renderer) {
28393 renderer.updateTextureImage(imn[0], imn[1]);
28397 .subscribe(this._glRendererOperation$);
28399 SliderComponent.prototype._deactivate = function () {
28401 this._waitSubscription.unsubscribe();
28402 this._navigator.stateService.state$.pipe(operators_1.first())
28403 .subscribe(function (state) {
28404 if (state !== State_1.State.Traversing) {
28405 _this._navigator.stateService.traverse();
28408 this._glRendererDisposer$.next(null);
28409 this._domRenderer.deactivate();
28410 this._modeSubcription.unsubscribe();
28411 this._setKeysSubscription.unsubscribe();
28412 this._stateSubscription.unsubscribe();
28413 this._glRenderSubscription.unsubscribe();
28414 this._domRenderSubscription.unsubscribe();
28415 this._moveSubscription.unsubscribe();
28416 this._updateCurtainSubscription.unsubscribe();
28417 this._textureProviderSubscription.unsubscribe();
28418 this._setTextureProviderSubscription.unsubscribe();
28419 this._setTileSizeSubscription.unsubscribe();
28420 this._abortTextureProviderSubscription.unsubscribe();
28421 this._setRegionOfInterestSubscription.unsubscribe();
28422 this._hasTextureSubscription.unsubscribe();
28423 this._updateBackgroundSubscription.unsubscribe();
28424 this._updateTextureImageSubscription.unsubscribe();
28425 this._textureProviderSubscriptionPrev.unsubscribe();
28426 this._setTextureProviderSubscriptionPrev.unsubscribe();
28427 this._setTileSizeSubscriptionPrev.unsubscribe();
28428 this._abortTextureProviderSubscriptionPrev.unsubscribe();
28429 this._setRegionOfInterestSubscriptionPrev.unsubscribe();
28430 this._hasTextureSubscriptionPrev.unsubscribe();
28431 this._updateBackgroundSubscriptionPrev.unsubscribe();
28432 this._updateTextureImageSubscriptionPrev.unsubscribe();
28433 this.configure({ keys: null });
28435 SliderComponent.prototype._getDefaultConfiguration = function () {
28437 initialPosition: 1,
28438 mode: Component_1.SliderMode.Motion,
28439 sliderVisible: true,
28442 SliderComponent.prototype._catchCacheNode$ = function (key) {
28443 return this._navigator.graphService.cacheNode$(key).pipe(operators_1.catchError(function (error, caught) {
28444 console.error("Failed to cache slider node (" + key + ")", error);
28445 return rxjs_1.empty();
28448 SliderComponent.prototype._getBasicCorners = function (currentAspect, previousAspect) {
28451 if (currentAspect > previousAspect) {
28453 offsetY = 0.5 * currentAspect / previousAspect;
28456 offsetX = 0.5 * previousAspect / currentAspect;
28459 return [[0.5 - offsetX, 0.5 - offsetY], [0.5 + offsetX, 0.5 + offsetY]];
28461 SliderComponent.prototype._clipBoundingBox = function (bbox) {
28462 bbox.minX = Math.max(0, Math.min(1, bbox.minX));
28463 bbox.maxX = Math.max(0, Math.min(1, bbox.maxX));
28464 bbox.minY = Math.max(0, Math.min(1, bbox.minY));
28465 bbox.maxY = Math.max(0, Math.min(1, bbox.maxY));
28467 SliderComponent.componentName = "slider";
28468 return SliderComponent;
28469 }(Component_1.Component));
28470 exports.SliderComponent = SliderComponent;
28471 Component_1.ComponentService.register(SliderComponent);
28472 exports.default = SliderComponent;
28475 },{"../../Component":274,"../../Geo":277,"../../Render":280,"../../State":281,"../../Tiles":283,"../../Utils":284,"rxjs":26,"rxjs/operators":224}],337:[function(require,module,exports){
28477 Object.defineProperty(exports, "__esModule", { value: true });
28478 var rxjs_1 = require("rxjs");
28479 var operators_1 = require("rxjs/operators");
28480 var vd = require("virtual-dom");
28481 var Component_1 = require("../../Component");
28482 var SliderDOMRenderer = /** @class */ (function () {
28483 function SliderDOMRenderer(container) {
28484 this._container = container;
28485 this._interacting = false;
28486 this._notifyModeChanged$ = new rxjs_1.Subject();
28487 this._notifyPositionChanged$ = new rxjs_1.Subject();
28488 this._stopInteractionSubscription = null;
28490 Object.defineProperty(SliderDOMRenderer.prototype, "mode$", {
28492 return this._notifyModeChanged$;
28497 Object.defineProperty(SliderDOMRenderer.prototype, "position$", {
28499 return this._notifyPositionChanged$;
28504 SliderDOMRenderer.prototype.activate = function () {
28506 if (!!this._stopInteractionSubscription) {
28509 this._stopInteractionSubscription = rxjs_1.merge(this._container.mouseService.documentMouseUp$, this._container.touchService.touchEnd$.pipe(operators_1.filter(function (touchEvent) {
28510 return touchEvent.touches.length === 0;
28512 .subscribe(function (event) {
28513 if (_this._interacting) {
28514 _this._interacting = false;
28518 SliderDOMRenderer.prototype.deactivate = function () {
28519 if (!this._stopInteractionSubscription) {
28522 this._interacting = false;
28523 this._stopInteractionSubscription.unsubscribe();
28524 this._stopInteractionSubscription = null;
28526 SliderDOMRenderer.prototype.render = function (position, mode, motionless, pano, visible) {
28529 children.push(vd.h("div.SliderBorder", []));
28530 var modeVisible = !(motionless || pano);
28532 children.push(this._createModeButton(mode));
28534 children.push(this._createPositionInput(position, modeVisible));
28536 var boundingRect = this._container.domContainer.getBoundingClientRect();
28537 var width = Math.max(215, Math.min(400, boundingRect.width - 100));
28538 return vd.h("div.SliderContainer", { style: { width: width + "px" } }, children);
28540 SliderDOMRenderer.prototype._createModeButton = function (mode) {
28543 onclick: function () {
28544 _this._notifyModeChanged$.next(mode === Component_1.SliderMode.Motion ?
28545 Component_1.SliderMode.Stationary :
28546 Component_1.SliderMode.Motion);
28549 var className = mode === Component_1.SliderMode.Stationary ?
28550 "SliderModeButtonPressed" :
28551 "SliderModeButton";
28552 return vd.h("div." + className, properties, [vd.h("div.SliderModeIcon", [])]);
28554 SliderDOMRenderer.prototype._createPositionInput = function (position, modeVisible) {
28556 var onChange = function (e) {
28557 _this._notifyPositionChanged$.next(Number(e.target.value) / 1000);
28559 var onStart = function (e) {
28560 _this._interacting = true;
28561 e.stopPropagation();
28563 var onMove = function (e) {
28564 if (_this._interacting) {
28565 e.stopPropagation();
28568 var onKeyDown = function (e) {
28569 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
28570 e.key === "ArrowRight" || e.key === "ArrowUp") {
28571 e.preventDefault();
28574 var boundingRect = this._container.domContainer.getBoundingClientRect();
28575 var width = Math.max(215, Math.min(400, boundingRect.width - 105)) - 68 + (modeVisible ? 0 : 36);
28576 var positionInput = vd.h("input.SliderPosition", {
28579 onchange: onChange,
28581 onkeydown: onKeyDown,
28582 onmousedown: onStart,
28583 onmousemove: onMove,
28584 ontouchmove: onMove,
28585 ontouchstart: onStart,
28587 width: width + "px",
28590 value: 1000 * position,
28592 return vd.h("div.SliderPositionContainer", [positionInput]);
28594 return SliderDOMRenderer;
28596 exports.SliderDOMRenderer = SliderDOMRenderer;
28597 exports.default = SliderDOMRenderer;
28599 },{"../../Component":274,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],338:[function(require,module,exports){
28601 Object.defineProperty(exports, "__esModule", { value: true });
28602 var Component_1 = require("../../Component");
28603 var Geo_1 = require("../../Geo");
28604 var SliderGLRenderer = /** @class */ (function () {
28605 function SliderGLRenderer() {
28606 this._factory = new Component_1.MeshFactory();
28607 this._scene = new Component_1.MeshScene();
28608 this._spatial = new Geo_1.Spatial();
28609 this._currentKey = null;
28610 this._previousKey = null;
28611 this._disabled = false;
28614 this._needsRender = false;
28616 this._currentProviderDisposers = {};
28617 this._previousProviderDisposers = {};
28619 Object.defineProperty(SliderGLRenderer.prototype, "disabled", {
28621 return this._disabled;
28626 Object.defineProperty(SliderGLRenderer.prototype, "frameId", {
28628 return this._frameId;
28633 Object.defineProperty(SliderGLRenderer.prototype, "needsRender", {
28635 return this._needsRender;
28640 SliderGLRenderer.prototype.setTextureProvider = function (key, provider) {
28641 this._setTextureProvider(key, this._currentKey, provider, this._currentProviderDisposers, this._updateTexture.bind(this));
28643 SliderGLRenderer.prototype.setTextureProviderPrev = function (key, provider) {
28644 this._setTextureProvider(key, this._previousKey, provider, this._previousProviderDisposers, this._updateTexturePrev.bind(this));
28646 SliderGLRenderer.prototype.update = function (frame, mode) {
28647 this._updateFrameId(frame.id);
28648 this._updateImagePlanes(frame.state, mode);
28650 SliderGLRenderer.prototype.updateCurtain = function (curtain) {
28651 if (this._curtain === curtain) {
28654 this._curtain = curtain;
28655 this._updateCurtain();
28656 this._needsRender = true;
28658 SliderGLRenderer.prototype.updateTexture = function (image, node) {
28659 var imagePlanes = node.key === this._currentKey ?
28660 this._scene.imagePlanes :
28661 node.key === this._previousKey ?
28662 this._scene.imagePlanesOld :
28664 if (imagePlanes.length === 0) {
28667 this._needsRender = true;
28668 for (var _i = 0, imagePlanes_1 = imagePlanes; _i < imagePlanes_1.length; _i++) {
28669 var plane = imagePlanes_1[_i];
28670 var material = plane.material;
28671 var texture = material.uniforms.projectorTex.value;
28672 texture.image = image;
28673 texture.needsUpdate = true;
28676 SliderGLRenderer.prototype.updateTextureImage = function (image, node) {
28677 if (this._currentKey !== node.key) {
28680 this._needsRender = true;
28681 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
28682 var plane = _a[_i];
28683 var material = plane.material;
28684 var texture = material.uniforms.projectorTex.value;
28685 texture.image = image;
28686 texture.needsUpdate = true;
28689 SliderGLRenderer.prototype.render = function (perspectiveCamera, renderer) {
28690 if (!this.disabled) {
28691 renderer.render(this._scene.sceneOld, perspectiveCamera);
28693 renderer.render(this._scene.scene, perspectiveCamera);
28694 this._needsRender = false;
28696 SliderGLRenderer.prototype.dispose = function () {
28697 this._scene.clear();
28698 for (var key in this._currentProviderDisposers) {
28699 if (!this._currentProviderDisposers.hasOwnProperty(key)) {
28702 this._currentProviderDisposers[key]();
28704 for (var key in this._previousProviderDisposers) {
28705 if (!this._previousProviderDisposers.hasOwnProperty(key)) {
28708 this._previousProviderDisposers[key]();
28710 this._currentProviderDisposers = {};
28711 this._previousProviderDisposers = {};
28713 SliderGLRenderer.prototype._getBasicCorners = function (currentAspect, previousAspect) {
28716 if (currentAspect > previousAspect) {
28718 offsetY = 0.5 * currentAspect / previousAspect;
28721 offsetX = 0.5 * previousAspect / currentAspect;
28724 return [[0.5 - offsetX, 0.5 - offsetY], [0.5 + offsetX, 0.5 + offsetY]];
28726 SliderGLRenderer.prototype._setDisabled = function (state) {
28727 this._disabled = state.currentNode == null ||
28728 state.previousNode == null ||
28729 (state.currentNode.pano && !state.currentNode.fullPano) ||
28730 (state.previousNode.pano && !state.previousNode.fullPano) ||
28731 (state.currentNode.fullPano && !state.previousNode.fullPano);
28733 SliderGLRenderer.prototype._setTextureProvider = function (key, originalKey, provider, providerDisposers, updateTexture) {
28735 if (key !== originalKey) {
28738 var createdSubscription = provider.textureCreated$
28739 .subscribe(updateTexture);
28740 var updatedSubscription = provider.textureUpdated$
28741 .subscribe(function (updated) {
28742 _this._needsRender = true;
28744 var dispose = function () {
28745 createdSubscription.unsubscribe();
28746 updatedSubscription.unsubscribe();
28747 provider.dispose();
28749 if (key in providerDisposers) {
28750 var disposeProvider = providerDisposers[key];
28752 delete providerDisposers[key];
28754 providerDisposers[key] = dispose;
28756 SliderGLRenderer.prototype._updateCurtain = function () {
28757 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
28758 var plane = _a[_i];
28759 var shaderMaterial = plane.material;
28760 if (!!shaderMaterial.uniforms.curtain) {
28761 shaderMaterial.uniforms.curtain.value = this._curtain;
28765 SliderGLRenderer.prototype._updateFrameId = function (frameId) {
28766 this._frameId = frameId;
28768 SliderGLRenderer.prototype._updateImagePlanes = function (state, mode) {
28769 var currentChanged = state.currentNode != null && this._currentKey !== state.currentNode.key;
28770 var previousChanged = state.previousNode != null && this._previousKey !== state.previousNode.key;
28771 var modeChanged = this._mode !== mode;
28772 if (!(currentChanged || previousChanged || modeChanged)) {
28775 this._setDisabled(state);
28776 this._needsRender = true;
28778 var motionless = state.motionless || mode === Component_1.SliderMode.Stationary || state.currentNode.pano;
28779 if (this.disabled || previousChanged) {
28780 if (this._previousKey in this._previousProviderDisposers) {
28781 this._previousProviderDisposers[this._previousKey]();
28782 delete this._previousProviderDisposers[this._previousKey];
28785 if (this.disabled) {
28786 this._scene.setImagePlanesOld([]);
28789 if (previousChanged || modeChanged) {
28790 var previousNode = state.previousNode;
28791 this._previousKey = previousNode.key;
28792 var elements = state.currentTransform.rt.elements;
28793 var translation = [elements[12], elements[13], elements[14]];
28794 var currentAspect = state.currentTransform.basicAspect;
28795 var previousAspect = state.previousTransform.basicAspect;
28796 var textureScale = currentAspect > previousAspect ?
28797 [1, previousAspect / currentAspect] :
28798 [currentAspect / previousAspect, 1];
28799 var rotation = state.currentNode.rotation;
28800 var width = state.currentNode.width;
28801 var height = state.currentNode.height;
28802 if (previousNode.fullPano) {
28803 rotation = state.previousNode.rotation;
28804 translation = this._spatial
28805 .rotate(this._spatial
28806 .opticalCenter(state.currentNode.rotation, translation)
28807 .toArray(), rotation)
28808 .multiplyScalar(-1)
28810 width = state.previousNode.width;
28811 height = state.previousNode.height;
28813 var transform = new Geo_1.Transform(state.currentNode.orientation, width, height, state.currentNode.focal, state.currentNode.scale, previousNode.gpano, rotation, translation, previousNode.image, textureScale);
28814 var mesh = undefined;
28815 if (previousNode.fullPano) {
28816 mesh = this._factory.createMesh(previousNode, motionless || state.currentNode.fullPano ? transform : state.previousTransform);
28820 var _a = this._getBasicCorners(currentAspect, previousAspect), _b = _a[0], basicX0 = _b[0], basicY0 = _b[1], _c = _a[1], basicX1 = _c[0], basicY1 = _c[1];
28821 mesh = this._factory.createFlatMesh(state.previousNode, transform, basicX0, basicX1, basicY0, basicY1);
28824 mesh = this._factory.createMesh(state.previousNode, state.previousTransform);
28827 this._scene.setImagePlanesOld([mesh]);
28830 if (currentChanged || modeChanged) {
28831 if (this._currentKey in this._currentProviderDisposers) {
28832 this._currentProviderDisposers[this._currentKey]();
28833 delete this._currentProviderDisposers[this._currentKey];
28835 this._currentKey = state.currentNode.key;
28836 var imagePlanes = [];
28837 if (state.currentNode.fullPano) {
28838 imagePlanes.push(this._factory.createCurtainMesh(state.currentNode, state.currentTransform));
28840 else if (state.currentNode.pano && !state.currentNode.fullPano) {
28841 imagePlanes.push(this._factory.createMesh(state.currentNode, state.currentTransform));
28845 imagePlanes.push(this._factory.createDistortedCurtainMesh(state.currentNode, state.currentTransform));
28848 imagePlanes.push(this._factory.createCurtainMesh(state.currentNode, state.currentTransform));
28851 this._scene.setImagePlanes(imagePlanes);
28852 this._updateCurtain();
28855 SliderGLRenderer.prototype._updateTexture = function (texture) {
28856 this._needsRender = true;
28857 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
28858 var plane = _a[_i];
28859 var material = plane.material;
28860 var oldTexture = material.uniforms.projectorTex.value;
28861 material.uniforms.projectorTex.value = null;
28862 oldTexture.dispose();
28863 material.uniforms.projectorTex.value = texture;
28866 SliderGLRenderer.prototype._updateTexturePrev = function (texture) {
28867 this._needsRender = true;
28868 for (var _i = 0, _a = this._scene.imagePlanesOld; _i < _a.length; _i++) {
28869 var plane = _a[_i];
28870 var material = plane.material;
28871 var oldTexture = material.uniforms.projectorTex.value;
28872 material.uniforms.projectorTex.value = null;
28873 oldTexture.dispose();
28874 material.uniforms.projectorTex.value = texture;
28877 return SliderGLRenderer;
28879 exports.SliderGLRenderer = SliderGLRenderer;
28880 exports.default = SliderGLRenderer;
28883 },{"../../Component":274,"../../Geo":277}],339:[function(require,module,exports){
28885 Object.defineProperty(exports, "__esModule", { value: true });
28886 var geohash = require("latlon-geohash");
28887 var rxjs_1 = require("rxjs");
28888 var operators_1 = require("rxjs/operators");
28889 var Error_1 = require("../../Error");
28890 var Utils_1 = require("../../Utils");
28891 var SpatialDataCache = /** @class */ (function () {
28892 function SpatialDataCache(graphService) {
28893 this._graphService = graphService;
28895 this._cacheRequests = {};
28896 this._reconstructions = {};
28897 this._cachingReconstructions$ = {};
28898 this._cachingTiles$ = {};
28900 SpatialDataCache.prototype.cacheReconstructions$ = function (hash) {
28902 if (!(hash in this._tiles)) {
28903 throw new Error("Cannot cache reconstructions of a non-existing tile.");
28905 if (this.hasReconstructions(hash)) {
28906 throw new Error("Cannot cache reconstructions that already exists.");
28908 if (hash in this._cachingReconstructions$) {
28909 return this._cachingReconstructions$[hash];
28912 if (hash in this._reconstructions) {
28913 var reconstructionKeys = this.getReconstructions(hash)
28914 .map(function (reconstruction) {
28915 return reconstruction.data.key;
28917 for (var _i = 0, _a = this.getTile(hash); _i < _a.length; _i++) {
28919 if (reconstructionKeys.indexOf(node.key) === -1) {
28925 tile.push.apply(tile, this.getTile(hash));
28926 this._reconstructions[hash] = [];
28928 this._cacheRequests[hash] = [];
28929 this._cachingReconstructions$[hash] = rxjs_1.from(tile).pipe(operators_1.mergeMap(function (nodeData) {
28930 return !_this._cacheRequests[hash] ?
28932 rxjs_1.zip(rxjs_1.of(nodeData), _this._getAtomicReconstruction(nodeData.key, _this._cacheRequests[hash]))
28933 .pipe(operators_1.catchError(function (error) {
28934 if (error instanceof Error_1.AbortMapillaryError) {
28935 return rxjs_1.empty();
28937 console.error(error);
28938 return rxjs_1.of([nodeData, null]);
28940 }, 6), operators_1.map(function (_a) {
28941 var nodeData = _a[0], reconstruction = _a[1];
28942 return { data: nodeData, reconstruction: reconstruction };
28943 }), operators_1.filter(function () {
28944 return hash in _this._reconstructions;
28945 }), operators_1.tap(function (data) {
28946 _this._reconstructions[hash].push(data);
28947 }), operators_1.filter(function (data) {
28948 return !!data.reconstruction;
28949 }), operators_1.finalize(function () {
28950 if (hash in _this._cachingReconstructions$) {
28951 delete _this._cachingReconstructions$[hash];
28953 if (hash in _this._cacheRequests) {
28954 delete _this._cacheRequests[hash];
28956 }), operators_1.publish(), operators_1.refCount());
28957 return this._cachingReconstructions$[hash];
28959 SpatialDataCache.prototype.cacheTile$ = function (hash) {
28961 if (hash.length !== 8) {
28962 throw new Error("Hash needs to be level 8.");
28964 if (this.hasTile(hash)) {
28965 throw new Error("Cannot cache tile that already exists.");
28967 if (hash in this._cachingTiles$) {
28968 return this._cachingTiles$[hash];
28970 var bounds = geohash.bounds(hash);
28971 var sw = { lat: bounds.sw.lat, lon: bounds.sw.lon };
28972 var ne = { lat: bounds.ne.lat, lon: bounds.ne.lon };
28973 this._tiles[hash] = [];
28974 this._cachingTiles$[hash] = this._graphService.cacheBoundingBox$(sw, ne).pipe(operators_1.catchError(function () {
28975 delete _this._tiles[hash];
28976 return rxjs_1.empty();
28977 }), operators_1.map(function (nodes) {
28979 .map(function (n) {
28980 return _this._createNodeData(n);
28982 }), operators_1.filter(function () {
28983 return hash in _this._tiles;
28984 }), operators_1.tap(function (nodeData) {
28986 (_a = _this._tiles[hash]).push.apply(_a, nodeData);
28987 delete _this._cachingTiles$[hash];
28988 }), operators_1.finalize(function () {
28989 if (hash in _this._cachingTiles$) {
28990 delete _this._cachingTiles$[hash];
28992 }), operators_1.publish(), operators_1.refCount());
28993 return this._cachingTiles$[hash];
28995 SpatialDataCache.prototype.isCachingReconstructions = function (hash) {
28996 return hash in this._cachingReconstructions$;
28998 SpatialDataCache.prototype.isCachingTile = function (hash) {
28999 return hash in this._cachingTiles$;
29001 SpatialDataCache.prototype.hasReconstructions = function (hash) {
29002 return !(hash in this._cachingReconstructions$) &&
29003 hash in this._reconstructions &&
29004 this._reconstructions[hash].length === this._tiles[hash].length;
29006 SpatialDataCache.prototype.hasTile = function (hash) {
29007 return !(hash in this._cachingTiles$) && hash in this._tiles;
29009 SpatialDataCache.prototype.getReconstructions = function (hash) {
29010 return hash in this._reconstructions ?
29011 this._reconstructions[hash]
29012 .filter(function (data) {
29013 return !!data.reconstruction;
29017 SpatialDataCache.prototype.getTile = function (hash) {
29018 return hash in this._tiles ? this._tiles[hash] : [];
29020 SpatialDataCache.prototype.uncache = function (keepHashes) {
29021 for (var _i = 0, _a = Object.keys(this._cacheRequests); _i < _a.length; _i++) {
29023 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
29026 for (var _b = 0, _c = this._cacheRequests[hash]; _b < _c.length; _b++) {
29027 var request = _c[_b];
29030 delete this._cacheRequests[hash];
29032 for (var _d = 0, _e = Object.keys(this._reconstructions); _d < _e.length; _d++) {
29034 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
29037 delete this._reconstructions[hash];
29039 for (var _f = 0, _g = Object.keys(this._tiles); _f < _g.length; _f++) {
29041 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
29044 delete this._tiles[hash];
29047 SpatialDataCache.prototype._createNodeData = function (node) {
29052 height: node.height,
29056 lat: node.latLon.lat,
29057 lon: node.latLon.lon,
29058 mergeCC: node.mergeCC,
29059 orientation: node.orientation,
29060 originalLat: node.originalLatLon.lat,
29061 originalLon: node.originalLatLon.lon,
29062 rotation: [node.rotation[0], node.rotation[1], node.rotation[2]],
29067 SpatialDataCache.prototype._getAtomicReconstruction = function (key, requests) {
29068 return rxjs_1.Observable.create(function (subscriber) {
29069 var xmlHTTP = new XMLHttpRequest();
29070 xmlHTTP.open("GET", Utils_1.Urls.atomicReconstruction(key), true);
29071 xmlHTTP.responseType = "json";
29072 xmlHTTP.timeout = 15000;
29073 xmlHTTP.onload = function () {
29074 if (!xmlHTTP.response) {
29075 subscriber.error(new Error("Atomic reconstruction does not exist (" + key + ")"));
29078 subscriber.next(xmlHTTP.response);
29079 subscriber.complete();
29082 xmlHTTP.onerror = function () {
29083 subscriber.error(new Error("Failed to get atomic reconstruction (" + key + ")"));
29085 xmlHTTP.ontimeout = function () {
29086 subscriber.error(new Error("Atomic reconstruction request timed out (" + key + ")"));
29088 xmlHTTP.onabort = function () {
29089 subscriber.error(new Error_1.AbortMapillaryError("Atomic reconstruction request was aborted (" + key + ")"));
29091 requests.push(xmlHTTP);
29092 xmlHTTP.send(null);
29095 return SpatialDataCache;
29097 exports.SpatialDataCache = SpatialDataCache;
29098 exports.default = SpatialDataCache;
29100 },{"../../Error":276,"../../Utils":284,"latlon-geohash":21,"rxjs":26,"rxjs/operators":224}],340:[function(require,module,exports){
29102 var __extends = (this && this.__extends) || (function () {
29103 var extendStatics = function (d, b) {
29104 extendStatics = Object.setPrototypeOf ||
29105 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29106 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
29107 return extendStatics(d, b);
29109 return function (d, b) {
29110 extendStatics(d, b);
29111 function __() { this.constructor = d; }
29112 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29115 Object.defineProperty(exports, "__esModule", { value: true });
29116 var geohash = require("latlon-geohash");
29117 var rxjs_1 = require("rxjs");
29118 var operators_1 = require("rxjs/operators");
29119 var Component_1 = require("../../Component");
29120 var Geo_1 = require("../../Geo");
29121 var Render_1 = require("../../Render");
29122 var PlayService_1 = require("../../viewer/PlayService");
29123 var State_1 = require("../../state/State");
29124 var SpatialDataComponent = /** @class */ (function (_super) {
29125 __extends(SpatialDataComponent, _super);
29126 function SpatialDataComponent(name, container, navigator) {
29127 var _this = _super.call(this, name, container, navigator) || this;
29128 _this._cache = new Component_1.SpatialDataCache(navigator.graphService);
29129 _this._scene = new Component_1.SpatialDataScene(_this._getDefaultConfiguration());
29130 _this._viewportCoords = new Geo_1.ViewportCoords();
29131 _this._geoCoords = new Geo_1.GeoCoords();
29134 SpatialDataComponent.prototype._activate = function () {
29136 var direction$ = this._container.renderService.bearing$.pipe(operators_1.map(function (bearing) {
29137 var direction = "";
29138 if (bearing > 292.5 || bearing <= 67.5) {
29141 if (bearing > 112.5 && bearing <= 247.5) {
29144 if (bearing > 22.5 && bearing <= 157.5) {
29147 if (bearing > 202.5 && bearing <= 337.5) {
29151 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
29152 var hash$ = this._navigator.stateService.reference$.pipe(operators_1.tap(function () {
29153 _this._scene.uncache();
29154 }), operators_1.switchMap(function () {
29155 return _this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
29156 return geohash.encode(node.latLon.lat, node.latLon.lon, 8);
29157 }), operators_1.distinctUntilChanged());
29158 }), operators_1.publishReplay(1), operators_1.refCount());
29159 var sequencePlay$ = rxjs_1.combineLatest(this._navigator.playService.playing$, this._navigator.playService.speed$).pipe(operators_1.map(function (_a) {
29160 var playing = _a[0], speed = _a[1];
29161 return playing && speed > PlayService_1.default.sequenceSpeed;
29162 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
29163 this._addSubscription = this._navigator.stateService.state$.pipe(operators_1.map(function (state) {
29164 return state === State_1.default.Earth;
29165 }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (earth) {
29167 return rxjs_1.combineLatest(hash$, sequencePlay$).pipe(operators_1.mergeMap(function (_a) {
29168 var hash = _a[0], sequencePlay = _a[1];
29169 return sequencePlay ?
29170 rxjs_1.of([hash]) :
29171 rxjs_1.of(_this._adjacentComponent(hash, 4));
29174 return rxjs_1.combineLatest(hash$, sequencePlay$, direction$).pipe(operators_1.mergeMap(function (_a) {
29175 var hash = _a[0], sequencePlay = _a[1], direction = _a[2];
29176 return sequencePlay ?
29177 rxjs_1.of([hash, geohash.neighbours(hash)[direction]]) :
29178 rxjs_1.of(_this._computeTiles(hash, direction));
29180 }), operators_1.switchMap(function (hashes) {
29181 return rxjs_1.from(hashes).pipe(operators_1.mergeMap(function (h) {
29183 if (_this._cache.hasTile(h)) {
29184 tile$ = rxjs_1.of(_this._cache.getTile(h));
29186 else if (_this._cache.isCachingTile(h)) {
29187 tile$ = _this._cache.cacheTile$(h).pipe(operators_1.last(null, {}), operators_1.switchMap(function () {
29188 return rxjs_1.of(_this._cache.getTile(h));
29192 tile$ = _this._cache.cacheTile$(h);
29194 return rxjs_1.combineLatest(rxjs_1.of(h), tile$);
29195 }, 1), operators_1.map(function (_a) {
29199 }), operators_1.concatMap(function (hash) {
29200 var reconstructions$;
29201 if (_this._cache.hasReconstructions(hash)) {
29202 reconstructions$ = rxjs_1.from(_this._cache.getReconstructions(hash));
29204 else if (_this._cache.isCachingReconstructions(hash)) {
29205 reconstructions$ = _this._cache.cacheReconstructions$(hash).pipe(operators_1.last(null, {}), operators_1.switchMap(function () {
29206 return rxjs_1.from(_this._cache.getReconstructions(hash));
29209 else if (_this._cache.hasTile(hash)) {
29210 reconstructions$ = _this._cache.cacheReconstructions$(hash);
29213 reconstructions$ = rxjs_1.empty();
29215 return rxjs_1.combineLatest(rxjs_1.of(hash), reconstructions$);
29216 }), operators_1.withLatestFrom(this._navigator.stateService.reference$), operators_1.tap(function (_a) {
29217 var hash = _a[0][0], reference = _a[1];
29218 if (_this._scene.hasTile(hash)) {
29221 _this._scene.addTile(_this._computeTileBBox(hash, reference), hash);
29222 }), operators_1.filter(function (_a) {
29223 var _b = _a[0], hash = _b[0], data = _b[1];
29224 return !_this._scene.hasReconstruction(data.reconstruction.main_shot, hash);
29225 }), operators_1.map(function (_a) {
29226 var _b = _a[0], hash = _b[0], data = _b[1], reference = _a[1];
29229 _this._createTransform(data.data, reference),
29230 _this._computeOriginalPosition(data.data, reference),
29234 .subscribe(function (_a) {
29235 var data = _a[0], transform = _a[1], position = _a[2], hash = _a[3];
29236 _this._scene.addReconstruction(data.reconstruction, transform, position, !!data.data.mergeCC ? data.data.mergeCC.toString() : "", hash);
29238 this._cameraVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
29239 return configuration.camerasVisible;
29240 }), operators_1.distinctUntilChanged())
29241 .subscribe(function (visible) {
29242 _this._scene.setCameraVisibility(visible);
29244 this._pointVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
29245 return configuration.pointsVisible;
29246 }), operators_1.distinctUntilChanged())
29247 .subscribe(function (visible) {
29248 _this._scene.setPointVisibility(visible);
29250 this._positionVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
29251 return configuration.positionsVisible;
29252 }), operators_1.distinctUntilChanged())
29253 .subscribe(function (visible) {
29254 _this._scene.setPositionVisibility(visible);
29256 this._tileVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
29257 return configuration.tilesVisible;
29258 }), operators_1.distinctUntilChanged())
29259 .subscribe(function (visible) {
29260 _this._scene.setTileVisibility(visible);
29262 this._visualizeConnectedComponentSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
29263 return configuration.connectedComponents;
29264 }), operators_1.distinctUntilChanged())
29265 .subscribe(function (visualize) {
29266 _this._scene.setConnectedComponentVisualization(visualize);
29268 this._uncacheSubscription = hash$
29269 .subscribe(function (hash) {
29270 var keepHashes = _this._adjacentComponent(hash, 4);
29271 _this._scene.uncache(keepHashes);
29272 _this._cache.uncache(keepHashes);
29274 this._moveSubscription = this._navigator.playService.playing$.pipe(operators_1.switchMap(function (playing) {
29277 _this._container.mouseService.dblClick$;
29278 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$), operators_1.switchMap(function (_a) {
29279 var event = _a[0], render = _a[1];
29280 var element = _this._container.element;
29281 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
29282 var viewport = _this._viewportCoords.canvasToViewport(canvasX, canvasY, element);
29283 var key = _this._scene.intersectObjects(viewport, render.perspective);
29285 _this._navigator.moveToKey$(key).pipe(operators_1.catchError(function () {
29286 return rxjs_1.empty();
29291 this._renderSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
29292 var scene = _this._scene;
29297 needsRender: scene.needsRender,
29298 render: scene.render.bind(scene),
29299 stage: Render_1.GLRenderStage.Foreground,
29303 .subscribe(this._container.glRenderer.render$);
29304 this._earthControlsSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
29305 return configuration.earthControls;
29306 }), operators_1.distinctUntilChanged(), operators_1.withLatestFrom(this._navigator.stateService.state$))
29307 .subscribe(function (_a) {
29308 var earth = _a[0], state = _a[1];
29309 if (earth && state !== State_1.default.Earth) {
29310 _this._navigator.stateService.earth();
29312 else if (!earth && state === State_1.default.Earth) {
29313 _this._navigator.stateService.traverse();
29317 SpatialDataComponent.prototype._deactivate = function () {
29319 this._navigator.stateService.state$.pipe(operators_1.first())
29320 .subscribe(function (state) {
29321 if (state === State_1.default.Earth) {
29322 _this._navigator.stateService.traverse();
29325 this._cache.uncache();
29326 this._scene.uncache();
29327 this._addSubscription.unsubscribe();
29328 this._cameraVisibilitySubscription.unsubscribe();
29329 this._earthControlsSubscription.unsubscribe();
29330 this._moveSubscription.unsubscribe();
29331 this._pointVisibilitySubscription.unsubscribe();
29332 this._positionVisibilitySubscription.unsubscribe();
29333 this._renderSubscription.unsubscribe();
29334 this._tileVisibilitySubscription.unsubscribe();
29335 this._uncacheSubscription.unsubscribe();
29336 this._visualizeConnectedComponentSubscription.unsubscribe();
29338 SpatialDataComponent.prototype._getDefaultConfiguration = function () {
29339 return { camerasVisible: false, pointsVisible: true, positionsVisible: false, tilesVisible: false };
29341 SpatialDataComponent.prototype._adjacentComponent = function (hash, depth) {
29342 var hashSet = new Set();
29344 this._adjacentComponentRecursive(hashSet, [hash], 0, depth);
29345 return this._setToArray(hashSet);
29347 SpatialDataComponent.prototype._adjacentComponentRecursive = function (hashSet, currentHashes, currentDepth, maxDepth) {
29348 if (currentDepth === maxDepth) {
29351 var neighbours = [];
29352 for (var _i = 0, currentHashes_1 = currentHashes; _i < currentHashes_1.length; _i++) {
29353 var hash = currentHashes_1[_i];
29354 var hashNeighbours = geohash.neighbours(hash);
29355 for (var direction in hashNeighbours) {
29356 if (!hashNeighbours.hasOwnProperty(direction)) {
29359 neighbours.push(hashNeighbours[direction]);
29362 var newHashes = [];
29363 for (var _a = 0, neighbours_1 = neighbours; _a < neighbours_1.length; _a++) {
29364 var neighbour = neighbours_1[_a];
29365 if (!hashSet.has(neighbour)) {
29366 hashSet.add(neighbour);
29367 newHashes.push(neighbour);
29370 this._adjacentComponentRecursive(hashSet, newHashes, currentDepth + 1, maxDepth);
29372 SpatialDataComponent.prototype._computeOriginalPosition = function (data, reference) {
29373 return this._geoCoords.geodeticToEnu(data.originalLat, data.originalLon, data.alt, reference.lat, reference.lon, reference.alt);
29375 SpatialDataComponent.prototype._computeTileBBox = function (hash, reference) {
29376 var bounds = geohash.bounds(hash);
29377 var sw = this._geoCoords.geodeticToEnu(bounds.sw.lat, bounds.sw.lon, 0, reference.lat, reference.lon, reference.alt);
29378 var ne = this._geoCoords.geodeticToEnu(bounds.ne.lat, bounds.ne.lon, 0, reference.lat, reference.lon, reference.alt);
29381 SpatialDataComponent.prototype._createTransform = function (data, reference) {
29382 var translation = Geo_1.Geo.computeTranslation({ alt: data.alt, lat: data.lat, lon: data.lon }, data.rotation, reference);
29383 var transform = new Geo_1.Transform(data.orientation, data.width, data.height, data.focal, data.scale, data.gpano, data.rotation, translation, undefined, undefined, data.k1, data.k2);
29386 SpatialDataComponent.prototype._computeTiles = function (hash, direction) {
29387 var hashSet = new Set();
29388 var directions = ["n", "ne", "e", "se", "s", "sw", "w", "nw"];
29389 this._computeTilesRecursive(hashSet, hash, direction, directions, 0, 2);
29390 return this._setToArray(hashSet);
29392 SpatialDataComponent.prototype._computeTilesRecursive = function (hashSet, currentHash, direction, directions, currentDepth, maxDepth) {
29393 hashSet.add(currentHash);
29394 if (currentDepth === maxDepth) {
29397 var neighbours = geohash.neighbours(currentHash);
29398 var directionIndex = directions.indexOf(direction);
29399 var length = directions.length;
29400 var directionNeighbours = [
29401 neighbours[directions[this._modulo((directionIndex - 1), length)]],
29402 neighbours[direction],
29403 neighbours[directions[this._modulo((directionIndex + 1), length)]],
29405 for (var _i = 0, directionNeighbours_1 = directionNeighbours; _i < directionNeighbours_1.length; _i++) {
29406 var directionNeighbour = directionNeighbours_1[_i];
29407 this._computeTilesRecursive(hashSet, directionNeighbour, direction, directions, currentDepth + 1, maxDepth);
29410 SpatialDataComponent.prototype._modulo = function (a, n) {
29411 return ((a % n) + n) % n;
29413 SpatialDataComponent.prototype._setToArray = function (s) {
29415 s.forEach(function (value) {
29420 SpatialDataComponent.componentName = "spatialData";
29421 return SpatialDataComponent;
29422 }(Component_1.Component));
29423 exports.SpatialDataComponent = SpatialDataComponent;
29424 Component_1.ComponentService.register(SpatialDataComponent);
29425 exports.default = SpatialDataComponent;
29427 },{"../../Component":274,"../../Geo":277,"../../Render":280,"../../state/State":411,"../../viewer/PlayService":440,"latlon-geohash":21,"rxjs":26,"rxjs/operators":224}],341:[function(require,module,exports){
29429 Object.defineProperty(exports, "__esModule", { value: true });
29430 var THREE = require("three");
29431 var SpatialDataScene = /** @class */ (function () {
29432 function SpatialDataScene(configuration, scene, raycaster) {
29433 this._scene = !!scene ? scene : new THREE.Scene();
29434 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster(undefined, undefined, 0.8);
29435 this._connectedComponentColors = {};
29436 this._needsRender = false;
29437 this._interactiveObjects = [];
29438 this._reconstructions = {};
29440 this._camerasVisible = configuration.camerasVisible;
29441 this._pointsVisible = configuration.pointsVisible;
29442 this._positionsVisible = configuration.positionsVisible;
29443 this._tilesVisible = configuration.tilesVisible;
29444 this._visualizeConnectedComponents = configuration.connectedComponents;
29446 Object.defineProperty(SpatialDataScene.prototype, "needsRender", {
29448 return this._needsRender;
29453 SpatialDataScene.prototype.addReconstruction = function (reconstruction, transform, originalPosition, connectedComponent, hash) {
29454 if (!(hash in this._reconstructions)) {
29455 this._reconstructions[hash] = {
29457 cameras: new THREE.Object3D(),
29458 connectedComponents: {},
29460 points: new THREE.Object3D(),
29461 positions: new THREE.Object3D(),
29463 this._reconstructions[hash].cameras.visible = this._camerasVisible;
29464 this._reconstructions[hash].points.visible = this._pointsVisible;
29465 this._reconstructions[hash].positions.visible = this._positionsVisible;
29466 this._scene.add(this._reconstructions[hash].cameras, this._reconstructions[hash].points, this._reconstructions[hash].positions);
29468 if (!(connectedComponent in this._reconstructions[hash].connectedComponents)) {
29469 this._reconstructions[hash].connectedComponents[connectedComponent] = [];
29471 if (transform.hasValidScale) {
29472 this._reconstructions[hash].points.add(this._createPoints(reconstruction, transform));
29474 var camera = this._createCamera(transform);
29475 this._reconstructions[hash].cameras.add(camera);
29476 for (var _i = 0, _a = camera.children; _i < _a.length; _i++) {
29477 var child = _a[_i];
29478 this._reconstructions[hash].cameraKeys[child.uuid] = reconstruction.main_shot;
29479 this._interactiveObjects.push(child);
29481 this._reconstructions[hash].connectedComponents[connectedComponent].push(camera);
29482 var color = this._getColor(connectedComponent, this._visualizeConnectedComponents);
29483 this._setCameraColor(color, camera);
29484 this._reconstructions[hash].positions.add(this._createPosition(transform, originalPosition));
29485 this._reconstructions[hash].keys.push(reconstruction.main_shot);
29486 this._needsRender = true;
29488 SpatialDataScene.prototype.addTile = function (tileBBox, hash) {
29489 if (this.hasTile(hash)) {
29492 var sw = tileBBox[0];
29493 var ne = tileBBox[1];
29494 var geometry = new THREE.Geometry();
29495 geometry.vertices.push(new THREE.Vector3().fromArray(sw), new THREE.Vector3(sw[0], ne[1], (sw[2] + ne[2]) / 2), new THREE.Vector3().fromArray(ne), new THREE.Vector3(ne[0], sw[1], (sw[2] + ne[2]) / 2), new THREE.Vector3().fromArray(sw));
29496 var tile = new THREE.Line(geometry, new THREE.LineBasicMaterial());
29497 this._tiles[hash] = new THREE.Object3D();
29498 this._tiles[hash].visible = this._tilesVisible;
29499 this._tiles[hash].add(tile);
29500 this._scene.add(this._tiles[hash]);
29501 this._needsRender = true;
29503 SpatialDataScene.prototype.uncache = function (keepHashes) {
29504 for (var _i = 0, _a = Object.keys(this._reconstructions); _i < _a.length; _i++) {
29506 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
29509 this._disposeReconstruction(hash);
29511 for (var _b = 0, _c = Object.keys(this._tiles); _b < _c.length; _b++) {
29513 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
29516 this._disposeTile(hash);
29518 this._needsRender = true;
29520 SpatialDataScene.prototype.hasReconstruction = function (key, hash) {
29521 return hash in this._reconstructions && this._reconstructions[hash].keys.indexOf(key) !== -1;
29523 SpatialDataScene.prototype.hasTile = function (hash) {
29524 return hash in this._tiles;
29526 SpatialDataScene.prototype.intersectObjects = function (_a, camera) {
29527 var viewportX = _a[0], viewportY = _a[1];
29528 if (!this._camerasVisible) {
29531 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
29532 var intersects = this._raycaster.intersectObjects(this._interactiveObjects);
29533 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
29534 var intersect = intersects_1[_i];
29535 for (var hash in this._reconstructions) {
29536 if (!this._reconstructions.hasOwnProperty(hash)) {
29539 if (intersect.object.uuid in this._reconstructions[hash].cameraKeys) {
29540 return this._reconstructions[hash].cameraKeys[intersect.object.uuid];
29546 SpatialDataScene.prototype.setCameraVisibility = function (visible) {
29547 if (visible === this._camerasVisible) {
29550 for (var hash in this._reconstructions) {
29551 if (!this._reconstructions.hasOwnProperty(hash)) {
29554 this._reconstructions[hash].cameras.visible = visible;
29556 this._camerasVisible = visible;
29557 this._needsRender = true;
29559 SpatialDataScene.prototype.setPointVisibility = function (visible) {
29560 if (visible === this._pointsVisible) {
29563 for (var hash in this._reconstructions) {
29564 if (!this._reconstructions.hasOwnProperty(hash)) {
29567 this._reconstructions[hash].points.visible = visible;
29569 this._pointsVisible = visible;
29570 this._needsRender = true;
29572 SpatialDataScene.prototype.setPositionVisibility = function (visible) {
29573 if (visible === this._positionsVisible) {
29576 for (var hash in this._reconstructions) {
29577 if (!this._reconstructions.hasOwnProperty(hash)) {
29580 this._reconstructions[hash].positions.visible = visible;
29582 this._positionsVisible = visible;
29583 this._needsRender = true;
29585 SpatialDataScene.prototype.setTileVisibility = function (visible) {
29586 if (visible === this._tilesVisible) {
29589 for (var hash in this._tiles) {
29590 if (!this._tiles.hasOwnProperty(hash)) {
29593 this._tiles[hash].visible = visible;
29595 this._tilesVisible = visible;
29596 this._needsRender = true;
29598 SpatialDataScene.prototype.setConnectedComponentVisualization = function (visualize) {
29599 if (visualize === this._visualizeConnectedComponents) {
29602 for (var hash in this._reconstructions) {
29603 if (!this._reconstructions.hasOwnProperty(hash)) {
29606 var connectedComponents = this._reconstructions[hash].connectedComponents;
29607 for (var connectedComponent in connectedComponents) {
29608 if (!connectedComponents.hasOwnProperty(connectedComponent)) {
29611 var color = this._getColor(connectedComponent, visualize);
29612 for (var _i = 0, _a = connectedComponents[connectedComponent]; _i < _a.length; _i++) {
29613 var camera = _a[_i];
29614 this._setCameraColor(color, camera);
29618 this._visualizeConnectedComponents = visualize;
29619 this._needsRender = true;
29621 SpatialDataScene.prototype.render = function (perspectiveCamera, renderer) {
29622 renderer.render(this._scene, perspectiveCamera);
29623 this._needsRender = false;
29625 SpatialDataScene.prototype._arrayToFloatArray = function (a, columns) {
29627 var f = new Float32Array(n * columns);
29628 for (var i = 0; i < n; i++) {
29631 f[index + 0] = item[0];
29632 f[index + 1] = item[1];
29633 f[index + 2] = item[2];
29637 SpatialDataScene.prototype._createAxis = function (transform) {
29638 var north = transform.unprojectBasic([0.5, 0], 0.22);
29639 var south = transform.unprojectBasic([0.5, 1], 0.16);
29640 var axis = new THREE.BufferGeometry();
29641 axis.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray([north, south], 3), 3));
29642 return new THREE.Line(axis, new THREE.LineBasicMaterial());
29644 SpatialDataScene.prototype._createCamera = function (transform) {
29645 return !!transform.gpano ?
29646 this._createPanoCamera(transform) :
29647 this._createPrespectiveCamera(transform);
29649 SpatialDataScene.prototype._createDiagonals = function (transform, depth) {
29650 var origin = transform.unprojectBasic([0, 0], 0, true);
29651 var topLeft = transform.unprojectBasic([0, 0], depth, true);
29652 var topRight = transform.unprojectBasic([1, 0], depth, true);
29653 var bottomRight = transform.unprojectBasic([1, 1], depth, true);
29654 var bottomLeft = transform.unprojectBasic([0, 1], depth, true);
29658 origin, bottomRight,
29659 origin, bottomLeft,
29661 var diagonals = new THREE.BufferGeometry();
29662 diagonals.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices, 3), 3));
29663 return new THREE.LineSegments(diagonals, new THREE.LineBasicMaterial());
29665 SpatialDataScene.prototype._createFrame = function (transform, depth) {
29666 var vertices2d = [];
29667 vertices2d.push.apply(vertices2d, this._subsample([0, 1], [0, 0], 20));
29668 vertices2d.push.apply(vertices2d, this._subsample([0, 0], [1, 0], 20));
29669 vertices2d.push.apply(vertices2d, this._subsample([1, 0], [1, 1], 20));
29670 var vertices3d = vertices2d
29671 .map(function (basic) {
29672 return transform.unprojectBasic(basic, depth, true);
29674 var frame = new THREE.BufferGeometry();
29675 frame.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices3d, 3), 3));
29676 return new THREE.Line(frame, new THREE.LineBasicMaterial());
29678 SpatialDataScene.prototype._createLatitude = function (basicY, numVertices, transform) {
29679 var positions = new Float32Array((numVertices + 1) * 3);
29680 for (var i = 0; i <= numVertices; i++) {
29681 var position = transform.unprojectBasic([i / numVertices, basicY], 0.16);
29683 positions[index + 0] = position[0];
29684 positions[index + 1] = position[1];
29685 positions[index + 2] = position[2];
29687 var latitude = new THREE.BufferGeometry();
29688 latitude.addAttribute("position", new THREE.BufferAttribute(positions, 3));
29689 return new THREE.Line(latitude, new THREE.LineBasicMaterial());
29691 SpatialDataScene.prototype._createLongitude = function (basicX, numVertices, transform) {
29692 var positions = new Float32Array((numVertices + 1) * 3);
29693 for (var i = 0; i <= numVertices; i++) {
29694 var position = transform.unprojectBasic([basicX, i / numVertices], 0.16);
29696 positions[index + 0] = position[0];
29697 positions[index + 1] = position[1];
29698 positions[index + 2] = position[2];
29700 var latitude = new THREE.BufferGeometry();
29701 latitude.addAttribute("position", new THREE.BufferAttribute(positions, 3));
29702 return new THREE.Line(latitude, new THREE.LineBasicMaterial());
29704 SpatialDataScene.prototype._createPanoCamera = function (transform) {
29705 var camera = new THREE.Object3D();
29706 camera.children.push(this._createAxis(transform));
29707 camera.children.push(this._createLatitude(0.5, 10, transform));
29708 camera.children.push(this._createLongitude(0, 6, transform));
29709 camera.children.push(this._createLongitude(0.25, 6, transform));
29710 camera.children.push(this._createLongitude(0.5, 6, transform));
29711 camera.children.push(this._createLongitude(0.75, 6, transform));
29714 SpatialDataScene.prototype._createPoints = function (reconstruction, transform) {
29715 var srtInverse = new THREE.Matrix4().getInverse(transform.srt);
29716 var points = Object
29717 .keys(reconstruction.points)
29718 .map(function (key) {
29719 return reconstruction.points[key];
29721 var numPoints = points.length;
29722 var positions = new Float32Array(numPoints * 3);
29723 var colors = new Float32Array(numPoints * 3);
29724 for (var i = 0; i < numPoints; i++) {
29726 var coords = points[i].coordinates;
29727 var point = new THREE.Vector3(coords[0], coords[1], coords[2])
29728 .applyMatrix4(srtInverse);
29729 positions[index + 0] = point.x;
29730 positions[index + 1] = point.y;
29731 positions[index + 2] = point.z;
29732 var color = points[i].color;
29733 colors[index + 0] = color[0] / 255.0;
29734 colors[index + 1] = color[1] / 255.0;
29735 colors[index + 2] = color[2] / 255.0;
29737 var geometry = new THREE.BufferGeometry();
29738 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
29739 geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3));
29740 var material = new THREE.PointsMaterial({
29742 vertexColors: THREE.VertexColors,
29744 return new THREE.Points(geometry, material);
29746 SpatialDataScene.prototype._createPosition = function (transform, originalPosition) {
29747 var computedPosition = transform.unprojectBasic([0, 0], 0);
29748 var vertices = [originalPosition, computedPosition];
29749 var geometry = new THREE.BufferGeometry();
29750 geometry.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices, 3), 3));
29751 return new THREE.Line(geometry, new THREE.LineBasicMaterial({ color: new THREE.Color(1, 0, 0) }));
29753 SpatialDataScene.prototype._createPrespectiveCamera = function (transform) {
29755 var camera = new THREE.Object3D();
29756 camera.children.push(this._createDiagonals(transform, depth));
29757 camera.children.push(this._createFrame(transform, depth));
29760 SpatialDataScene.prototype._disposeCameras = function (hash) {
29761 var tileCameras = this._reconstructions[hash].cameras;
29762 for (var _i = 0, _a = tileCameras.children.slice(); _i < _a.length; _i++) {
29763 var camera = _a[_i];
29764 for (var _b = 0, _c = camera.children; _b < _c.length; _b++) {
29765 var child = _c[_b];
29766 child.geometry.dispose();
29767 child.material.dispose();
29768 var index = this._interactiveObjects.indexOf(child);
29769 if (index !== -1) {
29770 this._interactiveObjects.splice(index, 1);
29773 console.warn("Object does not exist (" + child.id + ") for " + hash);
29776 tileCameras.remove(camera);
29778 this._scene.remove(tileCameras);
29780 SpatialDataScene.prototype._disposePoints = function (hash) {
29781 var tilePoints = this._reconstructions[hash].points;
29782 for (var _i = 0, _a = tilePoints.children.slice(); _i < _a.length; _i++) {
29783 var points = _a[_i];
29784 points.geometry.dispose();
29785 points.material.dispose();
29786 tilePoints.remove(points);
29788 this._scene.remove(tilePoints);
29790 SpatialDataScene.prototype._disposePositions = function (hash) {
29791 var tilePositions = this._reconstructions[hash].positions;
29792 for (var _i = 0, _a = tilePositions.children.slice(); _i < _a.length; _i++) {
29793 var position = _a[_i];
29794 position.geometry.dispose();
29795 position.material.dispose();
29796 tilePositions.remove(position);
29798 this._scene.remove(tilePositions);
29800 SpatialDataScene.prototype._disposeReconstruction = function (hash) {
29801 this._disposeCameras(hash);
29802 this._disposePoints(hash);
29803 this._disposePositions(hash);
29804 delete this._reconstructions[hash];
29806 SpatialDataScene.prototype._disposeTile = function (hash) {
29807 var tile = this._tiles[hash];
29808 for (var _i = 0, _a = tile.children.slice(); _i < _a.length; _i++) {
29810 line.geometry.dispose();
29811 line.material.dispose();
29814 this._scene.remove(tile);
29815 delete this._tiles[hash];
29817 SpatialDataScene.prototype._getColor = function (connectedComponent, visualizeConnectedComponents) {
29818 return visualizeConnectedComponents ?
29819 this._getConnectedComponentColor(connectedComponent) :
29822 SpatialDataScene.prototype._getConnectedComponentColor = function (connectedComponent) {
29823 if (!(connectedComponent in this._connectedComponentColors)) {
29824 this._connectedComponentColors[connectedComponent] = this._randomColor();
29826 return this._connectedComponentColors[connectedComponent];
29828 SpatialDataScene.prototype._interpolate = function (a, b, alpha) {
29829 return a + alpha * (b - a);
29831 SpatialDataScene.prototype._randomColor = function () {
29832 return "hsl(" + Math.floor(360 * Math.random()) + ", 100%, 65%)";
29834 SpatialDataScene.prototype._setCameraColor = function (color, camera) {
29835 for (var _i = 0, _a = camera.children; _i < _a.length; _i++) {
29836 var child = _a[_i];
29837 child.material.color = new THREE.Color(color);
29840 SpatialDataScene.prototype._subsample = function (p1, p2, subsamples) {
29841 if (subsamples < 1) {
29845 for (var i = 0; i <= subsamples + 1; i++) {
29847 for (var j = 0; j < 3; j++) {
29848 p.push(this._interpolate(p1[j], p2[j], i / (subsamples + 1)));
29854 return SpatialDataScene;
29856 exports.SpatialDataScene = SpatialDataScene;
29857 exports.default = SpatialDataScene;
29859 },{"three":225}],342:[function(require,module,exports){
29861 Object.defineProperty(exports, "__esModule", { value: true });
29862 var GeometryTagError_1 = require("./error/GeometryTagError");
29863 exports.GeometryTagError = GeometryTagError_1.GeometryTagError;
29864 var PointGeometry_1 = require("./geometry/PointGeometry");
29865 exports.PointGeometry = PointGeometry_1.PointGeometry;
29866 var RectGeometry_1 = require("./geometry/RectGeometry");
29867 exports.RectGeometry = RectGeometry_1.RectGeometry;
29868 var PolygonGeometry_1 = require("./geometry/PolygonGeometry");
29869 exports.PolygonGeometry = PolygonGeometry_1.PolygonGeometry;
29870 var OutlineTag_1 = require("./tag/OutlineTag");
29871 exports.OutlineTag = OutlineTag_1.OutlineTag;
29872 var SpotTag_1 = require("./tag/SpotTag");
29873 exports.SpotTag = SpotTag_1.SpotTag;
29874 var TagDomain_1 = require("./tag/TagDomain");
29875 exports.TagDomain = TagDomain_1.TagDomain;
29876 var TagComponent_1 = require("./TagComponent");
29877 exports.TagComponent = TagComponent_1.TagComponent;
29878 var TagMode_1 = require("./TagMode");
29879 exports.TagMode = TagMode_1.TagMode;
29881 },{"./TagComponent":343,"./TagMode":346,"./error/GeometryTagError":350,"./geometry/PointGeometry":352,"./geometry/PolygonGeometry":353,"./geometry/RectGeometry":354,"./tag/OutlineTag":366,"./tag/SpotTag":369,"./tag/TagDomain":371}],343:[function(require,module,exports){
29883 var __extends = (this && this.__extends) || (function () {
29884 var extendStatics = function (d, b) {
29885 extendStatics = Object.setPrototypeOf ||
29886 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29887 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
29888 return extendStatics(d, b);
29890 return function (d, b) {
29891 extendStatics(d, b);
29892 function __() { this.constructor = d; }
29893 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29896 Object.defineProperty(exports, "__esModule", { value: true });
29897 var rxjs_1 = require("rxjs");
29898 var operators_1 = require("rxjs/operators");
29899 var when = require("when");
29900 var Component_1 = require("../../Component");
29901 var Geo_1 = require("../../Geo");
29902 var Render_1 = require("../../Render");
29904 * @class TagComponent
29906 * @classdesc Component for showing and editing tags with different
29907 * geometries composed from 2D basic image coordinates (see the
29908 * {@link Viewer} class documentation for more information about coordinate
29911 * The `add` method is used for adding new tags or replacing
29912 * tags already in the set. Tags are removed by id.
29914 * If a tag already in the set has the same
29915 * id as one of the tags added, the old tag will be removed and
29916 * the added tag will take its place.
29918 * The tag component mode can be set to either be non interactive or
29919 * to be in creating mode of a certain geometry type.
29921 * The tag properties can be updated at any time and the change will
29922 * be visibile immediately.
29924 * Tags are only relevant to a single image because they are based on
29925 * 2D basic image coordinates. Tags related to a certain image should
29926 * be removed when the viewer is moved to another node.
29928 * To retrive and use the tag component
29932 * var viewer = new Mapillary.Viewer(
29936 * { component: { tag: true } });
29938 * var tagComponent = viewer.getComponent("tag");
29941 var TagComponent = /** @class */ (function (_super) {
29942 __extends(TagComponent, _super);
29944 function TagComponent(name, container, navigator) {
29945 var _this = _super.call(this, name, container, navigator) || this;
29946 _this._tagDomRenderer = new Component_1.TagDOMRenderer();
29947 _this._tagScene = new Component_1.TagScene();
29948 _this._tagSet = new Component_1.TagSet();
29949 _this._tagCreator = new Component_1.TagCreator(_this, navigator);
29950 _this._viewportCoords = new Geo_1.ViewportCoords();
29951 _this._createHandlers = {
29952 "CreatePoint": new Component_1.CreatePointHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
29953 "CreatePolygon": new Component_1.CreatePolygonHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
29954 "CreateRect": new Component_1.CreateRectHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
29955 "CreateRectDrag": new Component_1.CreateRectDragHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
29956 "Default": undefined,
29958 _this._editVertexHandler = new Component_1.EditVertexHandler(_this, container, navigator, _this._viewportCoords, _this._tagSet);
29959 _this._renderTags$ = _this._tagSet.changed$.pipe(operators_1.map(function (tagSet) {
29960 var tags = tagSet.getAll();
29961 // ensure that tags are always rendered in the same order
29962 // to avoid hover tracking problems on first resize.
29963 tags.sort(function (t1, t2) {
29964 var id1 = t1.tag.id;
29965 var id2 = t2.tag.id;
29975 }), operators_1.share());
29976 _this._tagChanged$ = _this._renderTags$.pipe(operators_1.switchMap(function (tags) {
29977 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
29978 return rxjs_1.merge(tag.tag.changed$, tag.tag.geometryChanged$);
29980 }), operators_1.share());
29981 _this._renderTagGLChanged$ = _this._renderTags$.pipe(operators_1.switchMap(function (tags) {
29982 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
29983 return tag.glObjectsChanged$;
29985 }), operators_1.share());
29986 _this._createGeometryChanged$ = _this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
29987 return tag != null ?
29988 tag.geometryChanged$ :
29990 }), operators_1.share());
29991 _this._createGLObjectsChanged$ = _this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
29992 return tag != null ?
29993 tag.glObjectsChanged$ :
29995 }), operators_1.share());
29996 _this._creatingConfiguration$ = _this._configuration$.pipe(operators_1.distinctUntilChanged(function (c1, c2) {
29997 return c1.mode === c2.mode;
29998 }, function (configuration) {
30000 createColor: configuration.createColor,
30001 mode: configuration.mode,
30003 }), operators_1.publishReplay(1), operators_1.refCount());
30004 _this._creatingConfiguration$
30005 .subscribe(function (configuration) {
30006 _this.fire(TagComponent.modechanged, configuration.mode);
30011 * Add tags to the tag set or replace tags in the tag set.
30013 * @description If a tag already in the set has the same
30014 * id as one of the tags added, the old tag will be removed
30015 * the added tag will take its place.
30017 * @param {Array<Tag>} tags - Tags to add.
30019 * @example ```tagComponent.add([tag1, tag2]);```
30021 TagComponent.prototype.add = function (tags) {
30023 if (this._activated) {
30024 this._navigator.stateService.currentTransform$.pipe(operators_1.first())
30025 .subscribe(function (transform) {
30026 _this._tagSet.add(tags, transform);
30027 var renderTags = tags
30028 .map(function (tag) {
30029 return _this._tagSet.get(tag.id);
30031 _this._tagScene.add(renderTags);
30035 this._tagSet.addDeactivated(tags);
30039 * Change the current tag mode.
30041 * @description Change the tag mode to one of the create modes for creating new geometries.
30043 * @param {TagMode} mode - New tag mode.
30045 * @fires TagComponent#modechanged
30047 * @example ```tagComponent.changeMode(Mapillary.TagComponent.TagMode.CreateRect);```
30049 TagComponent.prototype.changeMode = function (mode) {
30050 this.configure({ mode: mode });
30053 * Returns the tag in the tag set with the specified id, or
30054 * undefined if the id matches no tag.
30056 * @param {string} tagId - Id of the tag.
30058 * @example ```var tag = tagComponent.get("tagId");```
30060 TagComponent.prototype.get = function (tagId) {
30061 if (this._activated) {
30062 var renderTag = this._tagSet.get(tagId);
30063 return renderTag !== undefined ? renderTag.tag : undefined;
30066 return this._tagSet.getDeactivated(tagId);
30070 * Returns an array of all tags.
30072 * @example ```var tags = tagComponent.getAll();```
30074 TagComponent.prototype.getAll = function () {
30075 if (this.activated) {
30076 return this._tagSet
30078 .map(function (renderTag) {
30079 return renderTag.tag;
30083 return this._tagSet.getAllDeactivated();
30087 * Returns an array of tag ids for tags that contain the specified point.
30089 * @description The pixel point must lie inside the polygon or rectangle
30090 * of an added tag for the tag id to be returned. Tag ids for
30091 * tags that do not have a fill will also be returned if the point is inside
30092 * the geometry of the tag. Tags with point geometries can not be retrieved.
30094 * No tag ids will be returned for panoramas.
30096 * Notice that the pixelPoint argument requires x, y coordinates from pixel space.
30098 * With this function, you can use the coordinates provided by mouse
30099 * events to get information out of the tag component.
30101 * If no tag at exist the pixel point, an empty array will be returned.
30103 * @param {Array<number>} pixelPoint - Pixel coordinates on the viewer element.
30104 * @returns {Array<string>} Ids of the tags that contain the specified pixel point.
30108 * tagComponent.getTagIdsAt([100, 100])
30109 * .then((tagIds) => { console.log(tagIds); });
30112 TagComponent.prototype.getTagIdsAt = function (pixelPoint) {
30114 return when.promise(function (resolve, reject) {
30115 _this._container.renderService.renderCamera$.pipe(operators_1.first(), operators_1.map(function (render) {
30116 var viewport = _this._viewportCoords
30117 .canvasToViewport(pixelPoint[0], pixelPoint[1], _this._container.element);
30118 var ids = _this._tagScene.intersectObjects(viewport, render.perspective);
30121 .subscribe(function (ids) {
30123 }, function (error) {
30129 * Check if a tag exist in the tag set.
30131 * @param {string} tagId - Id of the tag.
30133 * @example ```var tagExists = tagComponent.has("tagId");```
30135 TagComponent.prototype.has = function (tagId) {
30136 return this._activated ? this._tagSet.has(tagId) : this._tagSet.hasDeactivated(tagId);
30139 * Remove tags with the specified ids from the tag set.
30141 * @param {Array<string>} tagIds - Ids for tags to remove.
30143 * @example ```tagComponent.remove(["id-1", "id-2"]);```
30145 TagComponent.prototype.remove = function (tagIds) {
30146 if (this._activated) {
30147 this._tagSet.remove(tagIds);
30148 this._tagScene.remove(tagIds);
30151 this._tagSet.removeDeactivated(tagIds);
30155 * Remove all tags from the tag set.
30157 * @example ```tagComponent.removeAll();```
30159 TagComponent.prototype.removeAll = function () {
30160 if (this._activated) {
30161 this._tagSet.removeAll();
30162 this._tagScene.removeAll();
30165 this._tagSet.removeAllDeactivated();
30168 TagComponent.prototype._activate = function () {
30170 this._editVertexHandler.enable();
30171 var handlerGeometryCreated$ = rxjs_1.from(Object.keys(this._createHandlers)).pipe(operators_1.map(function (key) {
30172 return _this._createHandlers[key];
30173 }), operators_1.filter(function (handler) {
30175 }), operators_1.mergeMap(function (handler) {
30176 return handler.geometryCreated$;
30177 }), operators_1.share());
30178 this._fireGeometryCreatedSubscription = handlerGeometryCreated$
30179 .subscribe(function (geometry) {
30180 _this.fire(TagComponent.geometrycreated, geometry);
30182 this._fireCreateGeometryEventSubscription = this._tagCreator.tag$.pipe(operators_1.skipWhile(function (tag) {
30183 return tag == null;
30184 }), operators_1.distinctUntilChanged())
30185 .subscribe(function (tag) {
30186 var eventType = tag != null ?
30187 TagComponent.creategeometrystart :
30188 TagComponent.creategeometryend;
30189 _this.fire(eventType, _this);
30191 this._handlerStopCreateSubscription = handlerGeometryCreated$
30192 .subscribe(function () {
30193 _this.changeMode(Component_1.TagMode.Default);
30195 this._handlerEnablerSubscription = this._creatingConfiguration$
30196 .subscribe(function (configuration) {
30197 _this._disableCreateHandlers();
30198 var mode = Component_1.TagMode[configuration.mode];
30199 var handler = _this._createHandlers[mode];
30204 this._fireTagsChangedSubscription = this._renderTags$
30205 .subscribe(function (tags) {
30206 _this.fire(TagComponent.tagschanged, _this);
30208 this._stopCreateSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
30209 return tag != null ?
30210 tag.aborted$.pipe(operators_1.map(function (t) { return null; })) :
30213 .subscribe(function () { _this.changeMode(Component_1.TagMode.Default); });
30214 this._setGLCreateTagSubscription = this._tagCreator.tag$
30215 .subscribe(function (tag) {
30216 if (_this._tagScene.hasCreateTag()) {
30217 _this._tagScene.removeCreateTag();
30220 _this._tagScene.addCreateTag(tag);
30223 this._createGLObjectsChangedSubscription = this._createGLObjectsChanged$
30224 .subscribe(function (tag) {
30225 _this._tagScene.updateCreateTagObjects(tag);
30227 this._updateGLObjectsSubscription = this._renderTagGLChanged$
30228 .subscribe(function (tag) {
30229 _this._tagScene.updateObjects(tag);
30231 this._updateTagSceneSubscription = this._tagChanged$
30232 .subscribe(function (tag) {
30233 _this._tagScene.update();
30235 this._domSubscription = rxjs_1.combineLatest(this._renderTags$.pipe(operators_1.startWith([]), operators_1.tap(function (tags) {
30236 _this._container.domRenderer.render$.next({
30238 vnode: _this._tagDomRenderer.clear(),
30240 })), this._container.renderService.renderCamera$, this._container.spriteService.spriteAtlas$, this._container.renderService.size$, this._tagChanged$.pipe(operators_1.startWith(null)), rxjs_1.merge(this._tagCreator.tag$, this._createGeometryChanged$).pipe(operators_1.startWith(null))).pipe(operators_1.map(function (_a) {
30241 var renderTags = _a[0], rc = _a[1], atlas = _a[2], size = _a[3], tag = _a[4], ct = _a[5];
30244 vnode: _this._tagDomRenderer.render(renderTags, ct, atlas, rc.perspective, size),
30247 .subscribe(this._container.domRenderer.render$);
30248 this._glSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
30249 var tagScene = _this._tagScene;
30254 needsRender: tagScene.needsRender,
30255 render: tagScene.render.bind(tagScene),
30256 stage: Render_1.GLRenderStage.Foreground,
30260 .subscribe(this._container.glRenderer.render$);
30261 this._navigator.stateService.currentTransform$.pipe(operators_1.first())
30262 .subscribe(function (transform) {
30263 _this._tagSet.activate(transform);
30264 _this._tagScene.add(_this._tagSet.getAll());
30267 TagComponent.prototype._deactivate = function () {
30268 this._editVertexHandler.disable();
30269 this._disableCreateHandlers();
30270 this._tagScene.clear();
30271 this._tagSet.deactivate();
30272 this._tagCreator.delete$.next(null);
30273 this._updateGLObjectsSubscription.unsubscribe();
30274 this._updateTagSceneSubscription.unsubscribe();
30275 this._stopCreateSubscription.unsubscribe();
30276 this._setGLCreateTagSubscription.unsubscribe();
30277 this._createGLObjectsChangedSubscription.unsubscribe();
30278 this._domSubscription.unsubscribe();
30279 this._glSubscription.unsubscribe();
30280 this._fireCreateGeometryEventSubscription.unsubscribe();
30281 this._fireGeometryCreatedSubscription.unsubscribe();
30282 this._fireTagsChangedSubscription.unsubscribe();
30283 this._handlerStopCreateSubscription.unsubscribe();
30284 this._handlerEnablerSubscription.unsubscribe();
30285 this._container.element.classList.remove("component-tag-create");
30287 TagComponent.prototype._getDefaultConfiguration = function () {
30289 createColor: 0xFFFFFF,
30290 mode: Component_1.TagMode.Default,
30293 TagComponent.prototype._disableCreateHandlers = function () {
30294 var createHandlers = this._createHandlers;
30295 for (var key in createHandlers) {
30296 if (!createHandlers.hasOwnProperty(key)) {
30299 var handler = createHandlers[key];
30306 TagComponent.componentName = "tag";
30308 * Event fired when an interaction to create a geometry ends.
30310 * @description A create interaction can by a geometry being created
30311 * or by the creation being aborted.
30313 * @event TagComponent#creategeometryend
30314 * @type {TagComponent} Tag component.
30317 * tagComponent.on("creategeometryend", function(component) {
30318 * console.log(component);
30322 TagComponent.creategeometryend = "creategeometryend";
30324 * Event fired when an interaction to create a geometry starts.
30326 * @description A create interaction starts when the first vertex
30327 * is created in the geometry.
30329 * @event TagComponent#creategeometrystart
30330 * @type {TagComponent} Tag component.
30333 * tagComponent.on("creategeometrystart", function(component) {
30334 * console.log(component);
30338 TagComponent.creategeometrystart = "creategeometrystart";
30340 * Event fired when the create mode is changed.
30342 * @event TagComponent#modechanged
30343 * @type {TagMode} Tag mode
30346 * tagComponent.on("modechanged", function(mode) {
30347 * console.log(mode);
30351 TagComponent.modechanged = "modechanged";
30353 * Event fired when a geometry has been created.
30355 * @event TagComponent#geometrycreated
30356 * @type {Geometry} Created geometry.
30359 * tagComponent.on("geometrycreated", function(geometry) {
30360 * console.log(geometry);
30364 TagComponent.geometrycreated = "geometrycreated";
30366 * Event fired when the tags collection has changed.
30368 * @event TagComponent#tagschanged
30369 * @type {TagComponent} Tag component.
30372 * tagComponent.on("tagschanged", function(component) {
30373 * console.log(component.getAll());
30377 TagComponent.tagschanged = "tagschanged";
30378 return TagComponent;
30379 }(Component_1.Component));
30380 exports.TagComponent = TagComponent;
30381 Component_1.ComponentService.register(TagComponent);
30382 exports.default = TagComponent;
30384 },{"../../Component":274,"../../Geo":277,"../../Render":280,"rxjs":26,"rxjs/operators":224,"when":271}],344:[function(require,module,exports){
30386 Object.defineProperty(exports, "__esModule", { value: true });
30387 var operators_1 = require("rxjs/operators");
30388 var rxjs_1 = require("rxjs");
30389 var Component_1 = require("../../Component");
30390 var TagCreator = /** @class */ (function () {
30391 function TagCreator(component, navigator) {
30392 this._component = component;
30393 this._navigator = navigator;
30394 this._tagOperation$ = new rxjs_1.Subject();
30395 this._createPolygon$ = new rxjs_1.Subject();
30396 this._createRect$ = new rxjs_1.Subject();
30397 this._delete$ = new rxjs_1.Subject();
30398 this._tag$ = this._tagOperation$.pipe(operators_1.scan(function (tag, operation) {
30399 return operation(tag);
30400 }, null), operators_1.share());
30401 this._createRect$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
30402 var coord = _a[0], conf = _a[1], transform = _a[2];
30403 return function (tag) {
30404 var geometry = new Component_1.RectGeometry([
30410 return new Component_1.OutlineCreateTag(geometry, { color: conf.createColor }, transform);
30413 .subscribe(this._tagOperation$);
30414 this._createPolygon$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
30415 var coord = _a[0], conf = _a[1], transform = _a[2];
30416 return function (tag) {
30417 var geometry = new Component_1.PolygonGeometry([
30418 [coord[0], coord[1]],
30419 [coord[0], coord[1]],
30420 [coord[0], coord[1]],
30422 return new Component_1.OutlineCreateTag(geometry, { color: conf.createColor }, transform);
30425 .subscribe(this._tagOperation$);
30426 this._delete$.pipe(operators_1.map(function () {
30427 return function (tag) {
30431 .subscribe(this._tagOperation$);
30433 Object.defineProperty(TagCreator.prototype, "createRect$", {
30435 return this._createRect$;
30440 Object.defineProperty(TagCreator.prototype, "createPolygon$", {
30442 return this._createPolygon$;
30447 Object.defineProperty(TagCreator.prototype, "delete$", {
30449 return this._delete$;
30454 Object.defineProperty(TagCreator.prototype, "tag$", {
30463 exports.TagCreator = TagCreator;
30464 exports.default = TagCreator;
30466 },{"../../Component":274,"rxjs":26,"rxjs/operators":224}],345:[function(require,module,exports){
30468 Object.defineProperty(exports, "__esModule", { value: true });
30469 var vd = require("virtual-dom");
30470 var TagDOMRenderer = /** @class */ (function () {
30471 function TagDOMRenderer() {
30473 TagDOMRenderer.prototype.render = function (tags, createTag, atlas, camera, size) {
30475 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
30476 var tag = tags_1[_i];
30477 vNodes = vNodes.concat(tag.getDOMObjects(atlas, camera, size));
30479 if (createTag != null) {
30480 vNodes = vNodes.concat(createTag.getDOMObjects(camera, size));
30482 return vd.h("div.TagContainer", {}, vNodes);
30484 TagDOMRenderer.prototype.clear = function () {
30485 return vd.h("div", {}, []);
30487 return TagDOMRenderer;
30489 exports.TagDOMRenderer = TagDOMRenderer;
30491 },{"virtual-dom":230}],346:[function(require,module,exports){
30493 Object.defineProperty(exports, "__esModule", { value: true });
30495 * Enumeration for tag modes
30498 * @description Modes for the interaction in the tag component.
30501 (function (TagMode) {
30503 * Disables creating tags.
30505 TagMode[TagMode["Default"] = 0] = "Default";
30507 * Create a point geometry through a click.
30509 TagMode[TagMode["CreatePoint"] = 1] = "CreatePoint";
30511 * Create a polygon geometry through clicks.
30513 TagMode[TagMode["CreatePolygon"] = 2] = "CreatePolygon";
30515 * Create a rect geometry through clicks.
30517 TagMode[TagMode["CreateRect"] = 3] = "CreateRect";
30519 * Create a rect geometry through drag.
30521 * @description Claims the mouse which results in mouse handlers like
30522 * drag pan and scroll zoom becoming inactive.
30524 TagMode[TagMode["CreateRectDrag"] = 4] = "CreateRectDrag";
30525 })(TagMode = exports.TagMode || (exports.TagMode = {}));
30526 exports.default = TagMode;
30528 },{}],347:[function(require,module,exports){
30530 Object.defineProperty(exports, "__esModule", { value: true });
30532 (function (TagOperation) {
30533 TagOperation[TagOperation["None"] = 0] = "None";
30534 TagOperation[TagOperation["Centroid"] = 1] = "Centroid";
30535 TagOperation[TagOperation["Vertex"] = 2] = "Vertex";
30536 })(TagOperation = exports.TagOperation || (exports.TagOperation = {}));
30537 exports.default = TagOperation;
30539 },{}],348:[function(require,module,exports){
30541 Object.defineProperty(exports, "__esModule", { value: true });
30542 var THREE = require("three");
30543 var TagScene = /** @class */ (function () {
30544 function TagScene(scene, raycaster) {
30545 this._createTag = null;
30546 this._needsRender = false;
30547 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster();
30548 this._scene = !!scene ? scene : new THREE.Scene();
30549 this._objectTags = {};
30550 this._retrievableObjects = [];
30553 Object.defineProperty(TagScene.prototype, "needsRender", {
30555 return this._needsRender;
30560 TagScene.prototype.add = function (tags) {
30561 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
30562 var tag = tags_1[_i];
30563 if (tag.tag.id in this._tags) {
30564 this._remove(tag.tag.id);
30568 this._needsRender = true;
30570 TagScene.prototype.addCreateTag = function (tag) {
30571 for (var _i = 0, _a = tag.glObjects; _i < _a.length; _i++) {
30572 var object = _a[_i];
30573 this._scene.add(object);
30575 this._createTag = { tag: tag, objects: tag.glObjects };
30576 this._needsRender = true;
30578 TagScene.prototype.clear = function () {
30579 for (var _i = 0, _a = Object.keys(this._tags); _i < _a.length; _i++) {
30583 this._needsRender = false;
30585 TagScene.prototype.get = function (id) {
30586 return this.has(id) ? this._tags[id].tag : undefined;
30588 TagScene.prototype.has = function (id) {
30589 return id in this._tags;
30591 TagScene.prototype.hasCreateTag = function () {
30592 return this._createTag != null;
30594 TagScene.prototype.intersectObjects = function (_a, camera) {
30595 var viewportX = _a[0], viewportY = _a[1];
30596 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
30597 var intersects = this._raycaster.intersectObjects(this._retrievableObjects);
30598 var intersectedIds = [];
30599 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
30600 var intersect = intersects_1[_i];
30601 if (intersect.object.uuid in this._objectTags) {
30602 intersectedIds.push(this._objectTags[intersect.object.uuid]);
30605 return intersectedIds;
30607 TagScene.prototype.remove = function (ids) {
30608 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
30609 var id = ids_1[_i];
30612 this._needsRender = true;
30614 TagScene.prototype.removeAll = function () {
30615 for (var _i = 0, _a = Object.keys(this._tags); _i < _a.length; _i++) {
30619 this._needsRender = true;
30621 TagScene.prototype.removeCreateTag = function () {
30622 if (this._createTag == null) {
30625 for (var _i = 0, _a = this._createTag.objects; _i < _a.length; _i++) {
30626 var object = _a[_i];
30627 this._scene.remove(object);
30629 this._createTag.tag.dispose();
30630 this._createTag = null;
30631 this._needsRender = true;
30633 TagScene.prototype.render = function (perspectiveCamera, renderer) {
30634 renderer.render(this._scene, perspectiveCamera);
30635 this._needsRender = false;
30637 TagScene.prototype.update = function () {
30638 this._needsRender = true;
30640 TagScene.prototype.updateCreateTagObjects = function (tag) {
30641 if (this._createTag.tag !== tag) {
30642 throw new Error("Create tags do not have the same reference.");
30644 for (var _i = 0, _a = this._createTag.objects; _i < _a.length; _i++) {
30645 var object = _a[_i];
30646 this._scene.remove(object);
30648 for (var _b = 0, _c = tag.glObjects; _b < _c.length; _b++) {
30649 var object = _c[_b];
30650 this._scene.add(object);
30652 this._createTag.objects = tag.glObjects;
30653 this._needsRender = true;
30655 TagScene.prototype.updateObjects = function (tag) {
30656 var id = tag.tag.id;
30657 if (this._tags[id].tag !== tag) {
30658 throw new Error("Tags do not have the same reference.");
30660 var tagObjects = this._tags[id];
30661 this._removeObjects(tagObjects);
30662 delete this._tags[id];
30664 this._needsRender = true;
30666 TagScene.prototype._add = function (tag) {
30667 var id = tag.tag.id;
30668 var tagObjects = { tag: tag, objects: [], retrievableObjects: [] };
30669 this._tags[id] = tagObjects;
30670 for (var _i = 0, _a = tag.getGLObjects(); _i < _a.length; _i++) {
30671 var object = _a[_i];
30672 tagObjects.objects.push(object);
30673 this._scene.add(object);
30675 for (var _b = 0, _c = tag.getRetrievableObjects(); _b < _c.length; _b++) {
30676 var retrievableObject = _c[_b];
30677 tagObjects.retrievableObjects.push(retrievableObject);
30678 this._retrievableObjects.push(retrievableObject);
30679 this._objectTags[retrievableObject.uuid] = tag.tag.id;
30682 TagScene.prototype._remove = function (id) {
30683 var tagObjects = this._tags[id];
30684 this._removeObjects(tagObjects);
30685 tagObjects.tag.dispose();
30686 delete this._tags[id];
30688 TagScene.prototype._removeObjects = function (tagObjects) {
30689 for (var _i = 0, _a = tagObjects.objects; _i < _a.length; _i++) {
30690 var object = _a[_i];
30691 this._scene.remove(object);
30693 for (var _b = 0, _c = tagObjects.retrievableObjects; _b < _c.length; _b++) {
30694 var retrievableObject = _c[_b];
30695 var index = this._retrievableObjects.indexOf(retrievableObject);
30696 if (index !== -1) {
30697 this._retrievableObjects.splice(index, 1);
30703 exports.TagScene = TagScene;
30704 exports.default = TagScene;
30706 },{"three":225}],349:[function(require,module,exports){
30708 Object.defineProperty(exports, "__esModule", { value: true });
30709 var rxjs_1 = require("rxjs");
30710 var Component_1 = require("../../Component");
30711 var TagSet = /** @class */ (function () {
30712 function TagSet() {
30713 this._active = false;
30715 this._hashDeactivated = {};
30716 this._notifyChanged$ = new rxjs_1.Subject();
30718 Object.defineProperty(TagSet.prototype, "active", {
30720 return this._active;
30725 Object.defineProperty(TagSet.prototype, "changed$", {
30727 return this._notifyChanged$;
30732 TagSet.prototype.activate = function (transform) {
30733 if (this._active) {
30736 for (var id in this._hashDeactivated) {
30737 if (!this._hashDeactivated.hasOwnProperty(id)) {
30740 var tag = this._hashDeactivated[id];
30741 this._add(tag, transform);
30743 this._hashDeactivated = {};
30744 this._active = true;
30745 this._notifyChanged$.next(this);
30747 TagSet.prototype.deactivate = function () {
30748 if (!this._active) {
30751 for (var id in this._hash) {
30752 if (!this._hash.hasOwnProperty(id)) {
30755 this._hashDeactivated[id] = this._hash[id].tag;
30758 this._active = false;
30760 TagSet.prototype.add = function (tags, transform) {
30761 this._assertActivationState(true);
30762 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
30763 var tag = tags_1[_i];
30764 this._add(tag, transform);
30766 this._notifyChanged$.next(this);
30768 TagSet.prototype.addDeactivated = function (tags) {
30769 this._assertActivationState(false);
30770 for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
30771 var tag = tags_2[_i];
30772 if (!(tag instanceof Component_1.OutlineTag || tag instanceof Component_1.SpotTag)) {
30773 throw new Error("Tag type not supported");
30775 this._hashDeactivated[tag.id] = tag;
30778 TagSet.prototype.get = function (id) {
30779 return this.has(id) ? this._hash[id] : undefined;
30781 TagSet.prototype.getAll = function () {
30782 var hash = this._hash;
30783 return Object.keys(hash)
30784 .map(function (id) {
30788 TagSet.prototype.getAllDeactivated = function () {
30789 var hashDeactivated = this._hashDeactivated;
30790 return Object.keys(hashDeactivated)
30791 .map(function (id) {
30792 return hashDeactivated[id];
30795 TagSet.prototype.getDeactivated = function (id) {
30796 return this.hasDeactivated(id) ? this._hashDeactivated[id] : undefined;
30798 TagSet.prototype.has = function (id) {
30799 return id in this._hash;
30801 TagSet.prototype.hasDeactivated = function (id) {
30802 return id in this._hashDeactivated;
30804 TagSet.prototype.remove = function (ids) {
30805 this._assertActivationState(true);
30806 var hash = this._hash;
30807 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
30808 var id = ids_1[_i];
30809 if (!(id in hash)) {
30814 this._notifyChanged$.next(this);
30816 TagSet.prototype.removeAll = function () {
30817 this._assertActivationState(true);
30819 this._notifyChanged$.next(this);
30821 TagSet.prototype.removeAllDeactivated = function () {
30822 this._assertActivationState(false);
30823 this._hashDeactivated = {};
30825 TagSet.prototype.removeDeactivated = function (ids) {
30826 this._assertActivationState(false);
30827 var hashDeactivated = this._hashDeactivated;
30828 for (var _i = 0, ids_2 = ids; _i < ids_2.length; _i++) {
30829 var id = ids_2[_i];
30830 if (!(id in hashDeactivated)) {
30833 delete hashDeactivated[id];
30836 TagSet.prototype._add = function (tag, transform) {
30837 if (tag instanceof Component_1.OutlineTag) {
30838 this._hash[tag.id] = new Component_1.OutlineRenderTag(tag, transform);
30840 else if (tag instanceof Component_1.SpotTag) {
30841 this._hash[tag.id] = new Component_1.SpotRenderTag(tag, transform);
30844 throw new Error("Tag type not supported");
30847 TagSet.prototype._assertActivationState = function (should) {
30848 if (should !== this._active) {
30849 throw new Error("Tag set not in correct state for operation.");
30854 exports.TagSet = TagSet;
30855 exports.default = TagSet;
30857 },{"../../Component":274,"rxjs":26}],350:[function(require,module,exports){
30859 var __extends = (this && this.__extends) || (function () {
30860 var extendStatics = function (d, b) {
30861 extendStatics = Object.setPrototypeOf ||
30862 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30863 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30864 return extendStatics(d, b);
30866 return function (d, b) {
30867 extendStatics(d, b);
30868 function __() { this.constructor = d; }
30869 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30872 Object.defineProperty(exports, "__esModule", { value: true });
30873 var Error_1 = require("../../../Error");
30874 var GeometryTagError = /** @class */ (function (_super) {
30875 __extends(GeometryTagError, _super);
30876 function GeometryTagError(message) {
30877 var _this = _super.call(this, message != null ? message : "The provided geometry value is incorrect") || this;
30878 _this.name = "GeometryTagError";
30881 return GeometryTagError;
30882 }(Error_1.MapillaryError));
30883 exports.GeometryTagError = GeometryTagError;
30884 exports.default = Error_1.MapillaryError;
30886 },{"../../../Error":276}],351:[function(require,module,exports){
30888 Object.defineProperty(exports, "__esModule", { value: true });
30889 var rxjs_1 = require("rxjs");
30893 * @classdesc Represents a geometry.
30895 var Geometry = /** @class */ (function () {
30897 * Create a geometry.
30902 function Geometry() {
30903 this._notifyChanged$ = new rxjs_1.Subject();
30905 Object.defineProperty(Geometry.prototype, "changed$", {
30907 * Get changed observable.
30909 * @description Emits the geometry itself every time the geometry
30912 * @returns {Observable<Geometry>} Observable emitting the geometry instance.
30916 return this._notifyChanged$;
30923 exports.Geometry = Geometry;
30924 exports.default = Geometry;
30926 },{"rxjs":26}],352:[function(require,module,exports){
30928 var __extends = (this && this.__extends) || (function () {
30929 var extendStatics = function (d, b) {
30930 extendStatics = Object.setPrototypeOf ||
30931 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30932 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30933 return extendStatics(d, b);
30935 return function (d, b) {
30936 extendStatics(d, b);
30937 function __() { this.constructor = d; }
30938 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30941 Object.defineProperty(exports, "__esModule", { value: true });
30942 var Component_1 = require("../../../Component");
30944 * @class PointGeometry
30946 * @classdesc Represents a point geometry in the 2D basic image coordinate system.
30950 * var basicPoint = [0.5, 0.7];
30951 * var pointGeometry = new Mapillary.TagComponent.PointGeometry(basicPoint);
30954 var PointGeometry = /** @class */ (function (_super) {
30955 __extends(PointGeometry, _super);
30957 * Create a point geometry.
30960 * @param {Array<number>} point - An array representing the basic coordinates of
30963 * @throws {GeometryTagError} Point coordinates must be valid basic coordinates.
30965 function PointGeometry(point) {
30966 var _this = _super.call(this) || this;
30969 if (x < 0 || x > 1 || y < 0 || y > 1) {
30970 throw new Component_1.GeometryTagError("Basic coordinates must be on the interval [0, 1].");
30972 _this._point = point.slice();
30975 Object.defineProperty(PointGeometry.prototype, "point", {
30977 * Get point property.
30978 * @returns {Array<number>} Array representing the basic coordinates of the point.
30981 return this._point;
30987 * Get the 2D basic coordinates for the centroid of the point, i.e. the 2D
30988 * basic coordinates of the point itself.
30990 * @returns {Array<number>} 2D basic coordinates representing the centroid.
30993 PointGeometry.prototype.getCentroid2d = function () {
30994 return this._point.slice();
30997 * Get the 3D world coordinates for the centroid of the point, i.e. the 3D
30998 * world coordinates of the point itself.
31000 * @param {Transform} transform - The transform of the node related to the point.
31001 * @returns {Array<number>} 3D world coordinates representing the centroid.
31004 PointGeometry.prototype.getCentroid3d = function (transform) {
31005 return transform.unprojectBasic(this._point, 200);
31008 * Set the centroid of the point, i.e. the point coordinates.
31010 * @param {Array<number>} value - The new value of the centroid.
31011 * @param {Transform} transform - The transform of the node related to the point.
31014 PointGeometry.prototype.setCentroid2d = function (value, transform) {
31016 Math.max(0, Math.min(1, value[0])),
31017 Math.max(0, Math.min(1, value[1])),
31019 this._point[0] = changed[0];
31020 this._point[1] = changed[1];
31021 this._notifyChanged$.next(this);
31023 return PointGeometry;
31024 }(Component_1.Geometry));
31025 exports.PointGeometry = PointGeometry;
31027 },{"../../../Component":274}],353:[function(require,module,exports){
31029 var __extends = (this && this.__extends) || (function () {
31030 var extendStatics = function (d, b) {
31031 extendStatics = Object.setPrototypeOf ||
31032 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31033 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
31034 return extendStatics(d, b);
31036 return function (d, b) {
31037 extendStatics(d, b);
31038 function __() { this.constructor = d; }
31039 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31042 Object.defineProperty(exports, "__esModule", { value: true });
31043 var Component_1 = require("../../../Component");
31045 * @class PolygonGeometry
31047 * @classdesc Represents a polygon geometry in the 2D basic image coordinate system.
31048 * All polygons and holes provided to the constructor needs to be closed.
31052 * var basicPolygon = [[0.5, 0.3], [0.7, 0.3], [0.6, 0.5], [0.5, 0.3]];
31053 * var polygonGeometry = new Mapillary.TagComponent.PolygonGeometry(basicPolygon);
31056 var PolygonGeometry = /** @class */ (function (_super) {
31057 __extends(PolygonGeometry, _super);
31059 * Create a polygon geometry.
31062 * @param {Array<Array<number>>} polygon - Array of polygon vertices. Must be closed.
31063 * @param {Array<Array<Array<number>>>} [holes] - Array of arrays of hole vertices.
31064 * Each array of holes vertices must be closed.
31066 * @throws {GeometryTagError} Polygon coordinates must be valid basic coordinates.
31068 function PolygonGeometry(polygon, holes) {
31069 var _this = _super.call(this) || this;
31070 _this._subsampleThreshold = 0.01;
31071 var polygonLength = polygon.length;
31072 if (polygonLength < 3) {
31073 throw new Component_1.GeometryTagError("A polygon must have three or more positions.");
31075 if (polygon[0][0] !== polygon[polygonLength - 1][0] ||
31076 polygon[0][1] !== polygon[polygonLength - 1][1]) {
31077 throw new Component_1.GeometryTagError("First and last positions must be equivalent.");
31079 _this._polygon = [];
31080 for (var _i = 0, polygon_1 = polygon; _i < polygon_1.length; _i++) {
31081 var vertex = polygon_1[_i];
31082 if (vertex[0] < 0 || vertex[0] > 1 ||
31083 vertex[1] < 0 || vertex[1] > 1) {
31084 throw new Component_1.GeometryTagError("Basic coordinates of polygon must be on the interval [0, 1].");
31086 _this._polygon.push(vertex.slice());
31089 if (holes == null) {
31092 for (var i = 0; i < holes.length; i++) {
31093 var hole = holes[i];
31094 var holeLength = hole.length;
31095 if (holeLength < 3) {
31096 throw new Component_1.GeometryTagError("A polygon hole must have three or more positions.");
31098 if (hole[0][0] !== hole[holeLength - 1][0] ||
31099 hole[0][1] !== hole[holeLength - 1][1]) {
31100 throw new Component_1.GeometryTagError("First and last positions of hole must be equivalent.");
31102 _this._holes.push([]);
31103 for (var _a = 0, hole_1 = hole; _a < hole_1.length; _a++) {
31104 var vertex = hole_1[_a];
31105 if (vertex[0] < 0 || vertex[0] > 1 ||
31106 vertex[1] < 0 || vertex[1] > 1) {
31107 throw new Component_1.GeometryTagError("Basic coordinates of hole must be on the interval [0, 1].");
31109 _this._holes[i].push(vertex.slice());
31114 Object.defineProperty(PolygonGeometry.prototype, "polygon", {
31116 * Get polygon property.
31117 * @returns {Array<Array<number>>} Closed 2d polygon.
31120 return this._polygon;
31125 Object.defineProperty(PolygonGeometry.prototype, "holes", {
31127 * Get holes property.
31128 * @returns {Array<Array<Array<number>>>} Holes of 2d polygon.
31131 return this._holes;
31137 * Add a vertex to the polygon by appending it after the last vertex.
31139 * @param {Array<number>} vertex - Vertex to add.
31142 PolygonGeometry.prototype.addVertex2d = function (vertex) {
31144 Math.max(0, Math.min(1, vertex[0])),
31145 Math.max(0, Math.min(1, vertex[1])),
31147 this._polygon.splice(this._polygon.length - 1, 0, clamped);
31148 this._notifyChanged$.next(this);
31151 * Get the coordinates of a vertex from the polygon representation of the geometry.
31153 * @description The first vertex represents the bottom-left corner with the rest of
31154 * the vertices following in clockwise order.
31156 * @param {number} index - Vertex index.
31157 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
31160 PolygonGeometry.prototype.getVertex2d = function (index) {
31161 return this._polygon[index].slice();
31164 * Remove a vertex from the polygon.
31166 * @param {number} index - The index of the vertex to remove.
31169 PolygonGeometry.prototype.removeVertex2d = function (index) {
31171 index >= this._polygon.length ||
31172 this._polygon.length < 4) {
31173 throw new Component_1.GeometryTagError("Index for removed vertex must be valid.");
31175 if (index > 0 && index < this._polygon.length - 1) {
31176 this._polygon.splice(index, 1);
31179 this._polygon.splice(0, 1);
31180 this._polygon.pop();
31181 var closing = this._polygon[0].slice();
31182 this._polygon.push(closing);
31184 this._notifyChanged$.next(this);
31187 PolygonGeometry.prototype.setVertex2d = function (index, value, transform) {
31189 Math.max(0, Math.min(1, value[0])),
31190 Math.max(0, Math.min(1, value[1])),
31192 if (index === 0 || index === this._polygon.length - 1) {
31193 this._polygon[0] = changed.slice();
31194 this._polygon[this._polygon.length - 1] = changed.slice();
31197 this._polygon[index] = changed.slice();
31199 this._notifyChanged$.next(this);
31202 PolygonGeometry.prototype.setCentroid2d = function (value, transform) {
31203 var xs = this._polygon.map(function (point) { return point[0]; });
31204 var ys = this._polygon.map(function (point) { return point[1]; });
31205 var minX = Math.min.apply(Math, xs);
31206 var maxX = Math.max.apply(Math, xs);
31207 var minY = Math.min.apply(Math, ys);
31208 var maxY = Math.max.apply(Math, ys);
31209 var centroid = this.getCentroid2d();
31210 var minTranslationX = -minX;
31211 var maxTranslationX = 1 - maxX;
31212 var minTranslationY = -minY;
31213 var maxTranslationY = 1 - maxY;
31214 var translationX = Math.max(minTranslationX, Math.min(maxTranslationX, value[0] - centroid[0]));
31215 var translationY = Math.max(minTranslationY, Math.min(maxTranslationY, value[1] - centroid[1]));
31216 for (var _i = 0, _a = this._polygon; _i < _a.length; _i++) {
31217 var point = _a[_i];
31218 point[0] += translationX;
31219 point[1] += translationY;
31221 this._notifyChanged$.next(this);
31224 PolygonGeometry.prototype.getPoints3d = function (transform) {
31225 return this._getPoints3d(this._subsample(this._polygon, this._subsampleThreshold), transform);
31228 PolygonGeometry.prototype.getVertex3d = function (index, transform) {
31229 return transform.unprojectBasic(this._polygon[index], 200);
31232 PolygonGeometry.prototype.getVertices2d = function () {
31233 return this._polygon.slice();
31236 PolygonGeometry.prototype.getVertices3d = function (transform) {
31237 return this._getPoints3d(this._polygon, transform);
31240 * Get a polygon representation of the 3D coordinates for the vertices of each hole
31241 * of the geometry. Line segments between vertices will possibly be subsampled
31242 * resulting in a larger number of points than the total number of vertices.
31244 * @param {Transform} transform - The transform of the node related to the geometry.
31245 * @returns {Array<Array<Array<number>>>} Array of hole polygons in 3D world coordinates
31246 * representing the vertices of each hole of the geometry.
31249 PolygonGeometry.prototype.getHolePoints3d = function (transform) {
31252 .map(function (hole2d) {
31253 return _this._getPoints3d(_this._subsample(hole2d, _this._subsampleThreshold), transform);
31257 * Get a polygon representation of the 3D coordinates for the vertices of each hole
31260 * @param {Transform} transform - The transform of the node related to the geometry.
31261 * @returns {Array<Array<Array<number>>>} Array of hole polygons in 3D world coordinates
31262 * representing the vertices of each hole of the geometry.
31265 PolygonGeometry.prototype.getHoleVertices3d = function (transform) {
31268 .map(function (hole2d) {
31269 return _this._getPoints3d(hole2d, transform);
31273 PolygonGeometry.prototype.getCentroid2d = function () {
31274 var polygon = this._polygon;
31278 for (var i = 0; i < polygon.length - 1; i++) {
31279 var xi = polygon[i][0];
31280 var yi = polygon[i][1];
31281 var xi1 = polygon[i + 1][0];
31282 var yi1 = polygon[i + 1][1];
31283 var a = xi * yi1 - xi1 * yi;
31285 centroidX += (xi + xi1) * a;
31286 centroidY += (yi + yi1) * a;
31289 centroidX /= 6 * area;
31290 centroidY /= 6 * area;
31291 return [centroidX, centroidY];
31294 PolygonGeometry.prototype.getCentroid3d = function (transform) {
31295 var centroid2d = this.getCentroid2d();
31296 return transform.unprojectBasic(centroid2d, 200);
31299 PolygonGeometry.prototype.get3dDomainTriangles3d = function (transform) {
31301 return this._triangulate(this._project(this._polygon, transform), this.getVertices3d(transform), this._holes
31302 .map(function (hole2d) {
31303 return _this._project(hole2d, transform);
31304 }), this.getHoleVertices3d(transform));
31307 PolygonGeometry.prototype.getTriangles3d = function (transform) {
31309 var threshold = this._subsampleThreshold;
31310 var points2d = this._project(this._subsample(this._polygon, threshold), transform);
31311 var points3d = this.getPoints3d(transform);
31312 var holes2d = this._holes
31313 .map(function (hole) {
31314 return _this._project(_this._subsample(hole, threshold), transform);
31316 var holes3d = this.getHolePoints3d(transform);
31317 return this._triangulate(points2d, points3d, holes2d, holes3d);
31320 PolygonGeometry.prototype.getPoleOfInaccessibility2d = function () {
31321 return this._getPoleOfInaccessibility2d(this._polygon.slice());
31324 PolygonGeometry.prototype.getPoleOfInaccessibility3d = function (transform) {
31325 var pole2d = this._getPoleOfInaccessibility2d(this._polygon.slice());
31326 return transform.unprojectBasic(pole2d, 200);
31328 PolygonGeometry.prototype._getPoints3d = function (points2d, transform) {
31330 .map(function (point) {
31331 return transform.unprojectBasic(point, 200);
31334 PolygonGeometry.prototype._subsample = function (points2d, threshold) {
31335 var subsampled = [];
31336 var length = points2d.length;
31337 for (var index = 0; index < length; index++) {
31338 var p1 = points2d[index];
31339 var p2 = points2d[(index + 1) % length];
31340 subsampled.push(p1);
31341 var dist = Math.sqrt(Math.pow((p2[0] - p1[0]), 2) + Math.pow((p2[1] - p1[1]), 2));
31342 var subsamples = Math.floor(dist / threshold);
31343 var coeff = 1 / (subsamples + 1);
31344 for (var i = 1; i <= subsamples; i++) {
31345 var alpha = i * coeff;
31347 (1 - alpha) * p1[0] + alpha * p2[0],
31348 (1 - alpha) * p1[1] + alpha * p2[1],
31350 subsampled.push(subsample);
31355 return PolygonGeometry;
31356 }(Component_1.VertexGeometry));
31357 exports.PolygonGeometry = PolygonGeometry;
31358 exports.default = PolygonGeometry;
31360 },{"../../../Component":274}],354:[function(require,module,exports){
31362 var __extends = (this && this.__extends) || (function () {
31363 var extendStatics = function (d, b) {
31364 extendStatics = Object.setPrototypeOf ||
31365 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31366 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
31367 return extendStatics(d, b);
31369 return function (d, b) {
31370 extendStatics(d, b);
31371 function __() { this.constructor = d; }
31372 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31375 Object.defineProperty(exports, "__esModule", { value: true });
31376 var Component_1 = require("../../../Component");
31378 * @class RectGeometry
31380 * @classdesc Represents a rectangle geometry in the 2D basic image coordinate system.
31384 * var basicRect = [0.5, 0.3, 0.7, 0.4];
31385 * var rectGeometry = new Mapillary.TagComponent.RectGeometry(basicRect);
31388 var RectGeometry = /** @class */ (function (_super) {
31389 __extends(RectGeometry, _super);
31391 * Create a rectangle geometry.
31394 * @param {Array<number>} rect - An array representing the top-left and bottom-right
31395 * corners of the rectangle in basic coordinates. Ordered according to [x0, y0, x1, y1].
31397 * @throws {GeometryTagError} Rectangle coordinates must be valid basic coordinates.
31399 function RectGeometry(rect) {
31400 var _this = _super.call(this) || this;
31401 if (rect[1] > rect[3]) {
31402 throw new Component_1.GeometryTagError("Basic Y coordinates values can not be inverted.");
31404 for (var _i = 0, rect_1 = rect; _i < rect_1.length; _i++) {
31405 var coord = rect_1[_i];
31406 if (coord < 0 || coord > 1) {
31407 throw new Component_1.GeometryTagError("Basic coordinates must be on the interval [0, 1].");
31410 _this._anchorIndex = undefined;
31411 _this._rect = rect.slice(0, 4);
31412 _this._inverted = _this._rect[0] > _this._rect[2];
31415 Object.defineProperty(RectGeometry.prototype, "anchorIndex", {
31417 * Get anchor index property.
31419 * @returns {number} Index representing the current anchor property if
31420 * achoring indexing has been initialized. If anchor indexing has not been
31421 * initialized or has been terminated undefined will be returned.
31425 return this._anchorIndex;
31430 Object.defineProperty(RectGeometry.prototype, "inverted", {
31432 * Get inverted property.
31434 * @returns {boolean} Boolean determining whether the rect geometry is
31435 * inverted. For panoramas the rect geometrye may be inverted.
31439 return this._inverted;
31444 Object.defineProperty(RectGeometry.prototype, "rect", {
31446 * Get rect property.
31448 * @returns {Array<number>} Array representing the top-left and bottom-right
31449 * corners of the rectangle in basic coordinates.
31458 * Initialize anchor indexing to enable setting opposite vertex.
31460 * @param {number} [index] - The index of the vertex to use as anchor.
31462 * @throws {Error} If anchor indexing has already been initialized.
31463 * @throws {Error} If index is not valid (0 to 3).
31466 RectGeometry.prototype.initializeAnchorIndexing = function (index) {
31467 if (this._anchorIndex !== undefined) {
31468 throw new Error("Anchor indexing is already initialized.");
31470 if (index < 0 || index > 3) {
31471 throw new Error("Invalid anchor index: " + index + ".");
31473 this._anchorIndex = index === undefined ? 0 : index;
31476 * Terminate anchor indexing to disable setting pposite vertex.
31479 RectGeometry.prototype.terminateAnchorIndexing = function () {
31480 this._anchorIndex = undefined;
31483 * Set the value of the vertex opposite to the anchor in the polygon
31484 * representation of the rectangle.
31486 * @description Setting the opposite vertex may change the anchor index.
31488 * @param {Array<number>} opposite - The new value of the vertex opposite to the anchor.
31489 * @param {Transform} transform - The transform of the node related to the rectangle.
31491 * @throws {Error} When anchor indexing has not been initialized.
31494 RectGeometry.prototype.setOppositeVertex2d = function (opposite, transform) {
31495 if (this._anchorIndex === undefined) {
31496 throw new Error("Anchor indexing needs to be initialized.");
31499 Math.max(0, Math.min(1, opposite[0])),
31500 Math.max(0, Math.min(1, opposite[1])),
31502 var original = this._rect.slice();
31503 var anchor = this._anchorIndex === 0 ? [original[0], original[3]] :
31504 this._anchorIndex === 1 ? [original[0], original[1]] :
31505 this._anchorIndex === 2 ? [original[2], original[1]] :
31506 [original[2], original[3]];
31507 if (transform.fullPano) {
31508 var deltaX = this._anchorIndex < 2 ?
31509 changed[0] - original[2] :
31510 changed[0] - original[0];
31511 if (!this._inverted && this._anchorIndex < 2 && changed[0] < 0.25 && original[2] > 0.75 && deltaX < -0.5) {
31512 // right side passes boundary rightward
31513 this._inverted = true;
31514 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
31516 else if (!this._inverted && this._anchorIndex >= 2 && changed[0] < 0.25 && original[2] > 0.75 && deltaX < -0.5) {
31517 // left side passes right side and boundary rightward
31518 this._inverted = true;
31519 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
31521 else if (this._inverted && this._anchorIndex >= 2 && changed[0] < 0.25 && original[0] > 0.75 && deltaX < -0.5) {
31522 this._inverted = false;
31523 if (anchor[0] > changed[0]) {
31524 // left side passes boundary rightward
31525 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
31528 // left side passes right side and boundary rightward
31529 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
31532 else if (!this._inverted && this._anchorIndex >= 2 && changed[0] > 0.75 && original[0] < 0.25 && deltaX > 0.5) {
31533 // left side passes boundary leftward
31534 this._inverted = true;
31535 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
31537 else if (!this._inverted && this._anchorIndex < 2 && changed[0] > 0.75 && original[0] < 0.25 && deltaX > 0.5) {
31538 // right side passes left side and boundary leftward
31539 this._inverted = true;
31540 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
31542 else if (this._inverted && this._anchorIndex < 2 && changed[0] > 0.75 && original[2] < 0.25 && deltaX > 0.5) {
31543 this._inverted = false;
31544 if (anchor[0] > changed[0]) {
31545 // right side passes boundary leftward
31546 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
31549 // right side passes left side and boundary leftward
31550 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
31553 else if (this._inverted && this._anchorIndex < 2 && changed[0] > original[0]) {
31554 // inverted and right side passes left side completing a loop
31555 this._inverted = false;
31556 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
31558 else if (this._inverted && this._anchorIndex >= 2 && changed[0] < original[2]) {
31559 // inverted and left side passes right side completing a loop
31560 this._inverted = false;
31561 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
31563 else if (this._inverted) {
31564 // if still inverted only top and bottom can switch
31565 if (this._anchorIndex < 2) {
31566 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
31569 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
31573 // if still not inverted treat as non full pano
31574 if (anchor[0] <= changed[0] && anchor[1] > changed[1]) {
31575 this._anchorIndex = 0;
31577 else if (anchor[0] <= changed[0] && anchor[1] <= changed[1]) {
31578 this._anchorIndex = 1;
31580 else if (anchor[0] > changed[0] && anchor[1] <= changed[1]) {
31581 this._anchorIndex = 2;
31584 this._anchorIndex = 3;
31588 if (this._anchorIndex === 0) {
31589 rect[0] = anchor[0];
31590 rect[1] = changed[1];
31591 rect[2] = changed[0];
31592 rect[3] = anchor[1];
31594 else if (this._anchorIndex === 1) {
31595 rect[0] = anchor[0];
31596 rect[1] = anchor[1];
31597 rect[2] = changed[0];
31598 rect[3] = changed[1];
31600 else if (this._anchorIndex === 2) {
31601 rect[0] = changed[0];
31602 rect[1] = anchor[1];
31603 rect[2] = anchor[0];
31604 rect[3] = changed[1];
31607 rect[0] = changed[0];
31608 rect[1] = changed[1];
31609 rect[2] = anchor[0];
31610 rect[3] = anchor[1];
31612 if (!this._inverted && rect[0] > rect[2] ||
31613 this._inverted && rect[0] < rect[2]) {
31614 rect[0] = original[0];
31615 rect[2] = original[2];
31617 if (rect[1] > rect[3]) {
31618 rect[1] = original[1];
31619 rect[3] = original[3];
31621 this._rect[0] = rect[0];
31622 this._rect[1] = rect[1];
31623 this._rect[2] = rect[2];
31624 this._rect[3] = rect[3];
31627 if (anchor[0] <= changed[0] && anchor[1] > changed[1]) {
31628 this._anchorIndex = 0;
31630 else if (anchor[0] <= changed[0] && anchor[1] <= changed[1]) {
31631 this._anchorIndex = 1;
31633 else if (anchor[0] > changed[0] && anchor[1] <= changed[1]) {
31634 this._anchorIndex = 2;
31637 this._anchorIndex = 3;
31640 if (this._anchorIndex === 0) {
31641 rect[0] = anchor[0];
31642 rect[1] = changed[1];
31643 rect[2] = changed[0];
31644 rect[3] = anchor[1];
31646 else if (this._anchorIndex === 1) {
31647 rect[0] = anchor[0];
31648 rect[1] = anchor[1];
31649 rect[2] = changed[0];
31650 rect[3] = changed[1];
31652 else if (this._anchorIndex === 2) {
31653 rect[0] = changed[0];
31654 rect[1] = anchor[1];
31655 rect[2] = anchor[0];
31656 rect[3] = changed[1];
31659 rect[0] = changed[0];
31660 rect[1] = changed[1];
31661 rect[2] = anchor[0];
31662 rect[3] = anchor[1];
31664 if (rect[0] > rect[2]) {
31665 rect[0] = original[0];
31666 rect[2] = original[2];
31668 if (rect[1] > rect[3]) {
31669 rect[1] = original[1];
31670 rect[3] = original[3];
31672 this._rect[0] = rect[0];
31673 this._rect[1] = rect[1];
31674 this._rect[2] = rect[2];
31675 this._rect[3] = rect[3];
31677 this._notifyChanged$.next(this);
31680 * Set the value of a vertex in the polygon representation of the rectangle.
31682 * @description The polygon is defined to have the first vertex at the
31683 * bottom-left corner with the rest of the vertices following in clockwise order.
31685 * @param {number} index - The index of the vertex to be set.
31686 * @param {Array<number>} value - The new value of the vertex.
31687 * @param {Transform} transform - The transform of the node related to the rectangle.
31690 RectGeometry.prototype.setVertex2d = function (index, value, transform) {
31691 var original = this._rect.slice();
31693 Math.max(0, Math.min(1, value[0])),
31694 Math.max(0, Math.min(1, value[1])),
31698 rect[0] = changed[0];
31699 rect[1] = original[1];
31700 rect[2] = original[2];
31701 rect[3] = changed[1];
31703 else if (index === 1) {
31704 rect[0] = changed[0];
31705 rect[1] = changed[1];
31706 rect[2] = original[2];
31707 rect[3] = original[3];
31709 else if (index === 2) {
31710 rect[0] = original[0];
31711 rect[1] = changed[1];
31712 rect[2] = changed[0];
31713 rect[3] = original[3];
31715 else if (index === 3) {
31716 rect[0] = original[0];
31717 rect[1] = original[1];
31718 rect[2] = changed[0];
31719 rect[3] = changed[1];
31721 if (transform.fullPano) {
31722 var passingBoundaryLeftward = index < 2 && changed[0] > 0.75 && original[0] < 0.25 ||
31723 index >= 2 && this._inverted && changed[0] > 0.75 && original[2] < 0.25;
31724 var passingBoundaryRightward = index < 2 && this._inverted && changed[0] < 0.25 && original[0] > 0.75 ||
31725 index >= 2 && changed[0] < 0.25 && original[2] > 0.75;
31726 if (passingBoundaryLeftward || passingBoundaryRightward) {
31727 this._inverted = !this._inverted;
31730 if (rect[0] - original[0] < -0.25) {
31731 rect[0] = original[0];
31733 if (rect[2] - original[2] > 0.25) {
31734 rect[2] = original[2];
31737 if (!this._inverted && rect[0] > rect[2] ||
31738 this._inverted && rect[0] < rect[2]) {
31739 rect[0] = original[0];
31740 rect[2] = original[2];
31744 if (rect[0] > rect[2]) {
31745 rect[0] = original[0];
31746 rect[2] = original[2];
31749 if (rect[1] > rect[3]) {
31750 rect[1] = original[1];
31751 rect[3] = original[3];
31753 this._rect[0] = rect[0];
31754 this._rect[1] = rect[1];
31755 this._rect[2] = rect[2];
31756 this._rect[3] = rect[3];
31757 this._notifyChanged$.next(this);
31760 RectGeometry.prototype.setCentroid2d = function (value, transform) {
31761 var original = this._rect.slice();
31762 var x0 = original[0];
31763 var x1 = this._inverted ? original[2] + 1 : original[2];
31764 var y0 = original[1];
31765 var y1 = original[3];
31766 var centerX = x0 + (x1 - x0) / 2;
31767 var centerY = y0 + (y1 - y0) / 2;
31768 var translationX = 0;
31769 if (transform.gpano != null &&
31770 transform.gpano.CroppedAreaImageWidthPixels === transform.gpano.FullPanoWidthPixels) {
31771 translationX = this._inverted ? value[0] + 1 - centerX : value[0] - centerX;
31774 var minTranslationX = -x0;
31775 var maxTranslationX = 1 - x1;
31776 translationX = Math.max(minTranslationX, Math.min(maxTranslationX, value[0] - centerX));
31778 var minTranslationY = -y0;
31779 var maxTranslationY = 1 - y1;
31780 var translationY = Math.max(minTranslationY, Math.min(maxTranslationY, value[1] - centerY));
31781 this._rect[0] = original[0] + translationX;
31782 this._rect[1] = original[1] + translationY;
31783 this._rect[2] = original[2] + translationX;
31784 this._rect[3] = original[3] + translationY;
31785 if (this._rect[0] < 0) {
31786 this._rect[0] += 1;
31787 this._inverted = !this._inverted;
31789 else if (this._rect[0] > 1) {
31790 this._rect[0] -= 1;
31791 this._inverted = !this._inverted;
31793 if (this._rect[2] < 0) {
31794 this._rect[2] += 1;
31795 this._inverted = !this._inverted;
31797 else if (this._rect[2] > 1) {
31798 this._rect[2] -= 1;
31799 this._inverted = !this._inverted;
31801 this._notifyChanged$.next(this);
31804 * Get the 3D coordinates for the vertices of the rectangle with
31805 * interpolated points along the lines.
31807 * @param {Transform} transform - The transform of the node related to
31809 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates
31810 * representing the rectangle.
31813 RectGeometry.prototype.getPoints3d = function (transform) {
31814 return this._getPoints2d()
31815 .map(function (point) {
31816 return transform.unprojectBasic(point, 200);
31820 * Get the coordinates of a vertex from the polygon representation of the geometry.
31822 * @description The first vertex represents the bottom-left corner with the rest of
31823 * the vertices following in clockwise order. The method shifts the right side
31824 * coordinates of the rectangle by one unit to ensure that the vertices are ordered
31827 * @param {number} index - Vertex index.
31828 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
31831 RectGeometry.prototype.getVertex2d = function (index) {
31832 return this._rectToVertices2d(this._rect)[index];
31835 * Get the coordinates of a vertex from the polygon representation of the geometry.
31837 * @description The first vertex represents the bottom-left corner with the rest of
31838 * the vertices following in clockwise order. The coordinates will not be shifted
31839 * so they may not appear in clockwise order when layed out on the plane.
31841 * @param {number} index - Vertex index.
31842 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
31845 RectGeometry.prototype.getNonAdjustedVertex2d = function (index) {
31846 return this._rectToNonAdjustedVertices2d(this._rect)[index];
31849 * Get a vertex from the polygon representation of the 3D coordinates for the
31850 * vertices of the geometry.
31852 * @description The first vertex represents the bottom-left corner with the rest of
31853 * the vertices following in clockwise order.
31855 * @param {number} index - Vertex index.
31856 * @param {Transform} transform - The transform of the node related to the geometry.
31857 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates representing
31858 * the vertices of the geometry.
31861 RectGeometry.prototype.getVertex3d = function (index, transform) {
31862 return transform.unprojectBasic(this._rectToVertices2d(this._rect)[index], 200);
31865 * Get a polygon representation of the 2D basic coordinates for the vertices of the rectangle.
31867 * @description The first vertex represents the bottom-left corner with the rest of
31868 * the vertices following in clockwise order.
31870 * @returns {Array<Array<number>>} Polygon array of 2D basic coordinates representing
31871 * the rectangle vertices.
31874 RectGeometry.prototype.getVertices2d = function () {
31875 return this._rectToVertices2d(this._rect);
31878 * Get a polygon representation of the 3D coordinates for the vertices of the rectangle.
31880 * @description The first vertex represents the bottom-left corner with the rest of
31881 * the vertices following in clockwise order.
31883 * @param {Transform} transform - The transform of the node related to the rectangle.
31884 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates representing
31885 * the rectangle vertices.
31888 RectGeometry.prototype.getVertices3d = function (transform) {
31889 return this._rectToVertices2d(this._rect)
31890 .map(function (vertex) {
31891 return transform.unprojectBasic(vertex, 200);
31895 RectGeometry.prototype.getCentroid2d = function () {
31896 var rect = this._rect;
31898 var x1 = this._inverted ? rect[2] + 1 : rect[2];
31901 var centroidX = (x0 + x1) / 2;
31902 var centroidY = (y0 + y1) / 2;
31903 return [centroidX, centroidY];
31906 RectGeometry.prototype.getCentroid3d = function (transform) {
31907 var centroid2d = this.getCentroid2d();
31908 return transform.unprojectBasic(centroid2d, 200);
31913 RectGeometry.prototype.getPoleOfInaccessibility2d = function () {
31914 return this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));
31917 RectGeometry.prototype.getPoleOfInaccessibility3d = function (transform) {
31918 var pole2d = this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));
31919 return transform.unprojectBasic(pole2d, 200);
31922 RectGeometry.prototype.getTriangles3d = function (transform) {
31923 return this._triangulate(this._project(this._getPoints2d(), transform), this.getPoints3d(transform));
31926 * Check if a particular bottom-right value is valid according to the current
31927 * rectangle coordinates.
31929 * @param {Array<number>} bottomRight - The bottom-right coordinates to validate
31930 * @returns {boolean} Value indicating whether the provided bottom-right coordinates
31934 RectGeometry.prototype.validate = function (bottomRight) {
31935 var rect = this._rect;
31936 if (!this._inverted && bottomRight[0] < rect[0] ||
31937 bottomRight[0] - rect[2] > 0.25 ||
31938 bottomRight[1] < rect[1]) {
31944 * Get the 2D coordinates for the vertices of the rectangle with
31945 * interpolated points along the lines.
31947 * @returns {Array<Array<number>>} Polygon array of 2D basic coordinates
31948 * representing the rectangle.
31950 RectGeometry.prototype._getPoints2d = function () {
31951 var vertices2d = this._rectToVertices2d(this._rect);
31952 var sides = vertices2d.length - 1;
31955 for (var i = 0; i < sides; ++i) {
31956 var startX = vertices2d[i][0];
31957 var startY = vertices2d[i][1];
31958 var endX = vertices2d[i + 1][0];
31959 var endY = vertices2d[i + 1][1];
31960 var intervalX = (endX - startX) / (sections - 1);
31961 var intervalY = (endY - startY) / (sections - 1);
31962 for (var j = 0; j < sections; ++j) {
31964 startX + j * intervalX,
31965 startY + j * intervalY,
31967 points2d.push(point);
31973 * Convert the top-left, bottom-right representation of a rectangle to a polygon
31974 * representation of the vertices starting at the bottom-left corner going
31977 * @description The method shifts the right side coordinates of the rectangle
31978 * by one unit to ensure that the vertices are ordered clockwise.
31980 * @param {Array<number>} rect - Top-left, bottom-right representation of a
31982 * @returns {Array<Array<number>>} Polygon representation of the vertices of the
31985 RectGeometry.prototype._rectToVertices2d = function (rect) {
31987 [rect[0], rect[3]],
31988 [rect[0], rect[1]],
31989 [this._inverted ? rect[2] + 1 : rect[2], rect[1]],
31990 [this._inverted ? rect[2] + 1 : rect[2], rect[3]],
31991 [rect[0], rect[3]],
31995 * Convert the top-left, bottom-right representation of a rectangle to a polygon
31996 * representation of the vertices starting at the bottom-left corner going
31999 * @description The first vertex represents the bottom-left corner with the rest of
32000 * the vertices following in clockwise order. The coordinates will not be shifted
32001 * to ensure that the vertices are ordered clockwise when layed out on the plane.
32003 * @param {Array<number>} rect - Top-left, bottom-right representation of a
32005 * @returns {Array<Array<number>>} Polygon representation of the vertices of the
32008 RectGeometry.prototype._rectToNonAdjustedVertices2d = function (rect) {
32010 [rect[0], rect[3]],
32011 [rect[0], rect[1]],
32012 [rect[2], rect[1]],
32013 [rect[2], rect[3]],
32014 [rect[0], rect[3]],
32017 return RectGeometry;
32018 }(Component_1.VertexGeometry));
32019 exports.RectGeometry = RectGeometry;
32020 exports.default = RectGeometry;
32022 },{"../../../Component":274}],355:[function(require,module,exports){
32024 var __extends = (this && this.__extends) || (function () {
32025 var extendStatics = function (d, b) {
32026 extendStatics = Object.setPrototypeOf ||
32027 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32028 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32029 return extendStatics(d, b);
32031 return function (d, b) {
32032 extendStatics(d, b);
32033 function __() { this.constructor = d; }
32034 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32037 Object.defineProperty(exports, "__esModule", { value: true });
32038 var earcut_1 = require("earcut");
32039 var polylabel = require("@mapbox/polylabel");
32040 var THREE = require("three");
32041 var Component_1 = require("../../../Component");
32043 * @class VertexGeometry
32045 * @classdesc Represents a vertex geometry.
32047 var VertexGeometry = /** @class */ (function (_super) {
32048 __extends(VertexGeometry, _super);
32050 * Create a vertex geometry.
32055 function VertexGeometry() {
32056 return _super.call(this) || this;
32059 * Finds the polygon pole of inaccessibility, the most distant internal
32060 * point from the polygon outline.
32062 * @param {Array<Array<number>>} points2d - 2d points of outline to triangulate.
32063 * @returns {Array<number>} Point of inaccessibility.
32066 VertexGeometry.prototype._getPoleOfInaccessibility2d = function (points2d) {
32067 var pole2d = polylabel([points2d], 3e-2);
32071 * Triangulates a 2d polygon and returns the triangle
32072 * representation as a flattened array of 3d points.
32074 * @param {Array<Array<number>>} points2d - 2d points of outline to triangulate.
32075 * @param {Array<Array<number>>} points3d - 3d points of outline corresponding to the 2d points.
32076 * @param {Array<Array<Array<number>>>} [holes2d] - 2d points of holes to triangulate.
32077 * @param {Array<Array<Array<number>>>} [holes3d] - 3d points of holes corresponding to the 2d points.
32078 * @returns {Array<number>} Flattened array of 3d points ordered based on the triangles.
32081 VertexGeometry.prototype._triangulate = function (points2d, points3d, holes2d, holes3d) {
32082 var data = [points2d.slice(0, -1)];
32083 for (var _i = 0, _a = holes2d != null ? holes2d : []; _i < _a.length; _i++) {
32084 var hole2d = _a[_i];
32085 data.push(hole2d.slice(0, -1));
32087 var points = points3d.slice(0, -1);
32088 for (var _b = 0, _c = holes3d != null ? holes3d : []; _b < _c.length; _b++) {
32089 var hole3d = _c[_b];
32090 points = points.concat(hole3d.slice(0, -1));
32092 var flattened = earcut_1.default.flatten(data);
32093 var indices = earcut_1.default(flattened.vertices, flattened.holes, flattened.dimensions);
32094 var triangles = [];
32095 for (var i = 0; i < indices.length; ++i) {
32096 var point = points[indices[i]];
32097 triangles.push(point[0]);
32098 triangles.push(point[1]);
32099 triangles.push(point[2]);
32103 VertexGeometry.prototype._project = function (points2d, transform) {
32104 var camera = new THREE.Camera();
32105 camera.up.copy(transform.upVector());
32106 camera.position.copy(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0)));
32107 camera.lookAt(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10)));
32108 camera.updateMatrix();
32109 camera.updateMatrixWorld(true);
32110 var projected = points2d
32111 .map(function (point2d) {
32112 var pointWorld = transform.unprojectBasic(point2d, 10000);
32113 var pointCamera = new THREE.Vector3(pointWorld[0], pointWorld[1], pointWorld[2])
32114 .applyMatrix4(camera.matrixWorldInverse);
32115 return [pointCamera.x / pointCamera.z, pointCamera.y / pointCamera.z];
32119 return VertexGeometry;
32120 }(Component_1.Geometry));
32121 exports.VertexGeometry = VertexGeometry;
32122 exports.default = VertexGeometry;
32124 },{"../../../Component":274,"@mapbox/polylabel":1,"earcut":8,"three":225}],356:[function(require,module,exports){
32126 var __extends = (this && this.__extends) || (function () {
32127 var extendStatics = function (d, b) {
32128 extendStatics = Object.setPrototypeOf ||
32129 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32130 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32131 return extendStatics(d, b);
32133 return function (d, b) {
32134 extendStatics(d, b);
32135 function __() { this.constructor = d; }
32136 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32139 Object.defineProperty(exports, "__esModule", { value: true });
32140 var operators_1 = require("rxjs/operators");
32141 var rxjs_1 = require("rxjs");
32142 var Component_1 = require("../../../Component");
32143 var CreateHandlerBase = /** @class */ (function (_super) {
32144 __extends(CreateHandlerBase, _super);
32145 function CreateHandlerBase(component, container, navigator, viewportCoords, tagCreator) {
32146 var _this = _super.call(this, component, container, navigator, viewportCoords) || this;
32147 _this._tagCreator = tagCreator;
32148 _this._geometryCreated$ = new rxjs_1.Subject();
32151 Object.defineProperty(CreateHandlerBase.prototype, "geometryCreated$", {
32153 return this._geometryCreated$;
32158 CreateHandlerBase.prototype._enable = function () {
32159 this._enableCreate();
32160 this._container.element.classList.add("component-tag-create");
32162 CreateHandlerBase.prototype._disable = function () {
32163 this._container.element.classList.remove("component-tag-create");
32164 this._disableCreate();
32166 CreateHandlerBase.prototype._validateBasic = function (basic) {
32169 return 0 <= x && x <= 1 && 0 <= y && y <= 1;
32171 CreateHandlerBase.prototype._mouseEventToBasic$ = function (mouseEvent$) {
32173 return mouseEvent$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
32174 var event = _a[0], camera = _a[1], transform = _a[2];
32175 return _this._mouseEventToBasic(event, _this._container.element, camera, transform);
32178 return CreateHandlerBase;
32179 }(Component_1.TagHandlerBase));
32180 exports.CreateHandlerBase = CreateHandlerBase;
32181 exports.default = CreateHandlerBase;
32183 },{"../../../Component":274,"rxjs":26,"rxjs/operators":224}],357:[function(require,module,exports){
32185 var __extends = (this && this.__extends) || (function () {
32186 var extendStatics = function (d, b) {
32187 extendStatics = Object.setPrototypeOf ||
32188 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32189 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32190 return extendStatics(d, b);
32192 return function (d, b) {
32193 extendStatics(d, b);
32194 function __() { this.constructor = d; }
32195 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32198 Object.defineProperty(exports, "__esModule", { value: true });
32199 var operators_1 = require("rxjs/operators");
32200 var Component_1 = require("../../../Component");
32201 var CreatePointHandler = /** @class */ (function (_super) {
32202 __extends(CreatePointHandler, _super);
32203 function CreatePointHandler() {
32204 return _super !== null && _super.apply(this, arguments) || this;
32206 CreatePointHandler.prototype._enableCreate = function () {
32207 this._container.mouseService.deferPixels(this._name, 4);
32208 this._geometryCreatedSubscription = this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(operators_1.filter(this._validateBasic), operators_1.map(function (basic) {
32209 return new Component_1.PointGeometry(basic);
32211 .subscribe(this._geometryCreated$);
32213 CreatePointHandler.prototype._disableCreate = function () {
32214 this._container.mouseService.undeferPixels(this._name);
32215 this._geometryCreatedSubscription.unsubscribe();
32217 CreatePointHandler.prototype._getNameExtension = function () {
32218 return "create-point";
32220 return CreatePointHandler;
32221 }(Component_1.CreateHandlerBase));
32222 exports.CreatePointHandler = CreatePointHandler;
32223 exports.default = CreatePointHandler;
32225 },{"../../../Component":274,"rxjs/operators":224}],358:[function(require,module,exports){
32227 var __extends = (this && this.__extends) || (function () {
32228 var extendStatics = function (d, b) {
32229 extendStatics = Object.setPrototypeOf ||
32230 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32231 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32232 return extendStatics(d, b);
32234 return function (d, b) {
32235 extendStatics(d, b);
32236 function __() { this.constructor = d; }
32237 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32240 Object.defineProperty(exports, "__esModule", { value: true });
32241 var Component_1 = require("../../../Component");
32242 var CreatePolygonHandler = /** @class */ (function (_super) {
32243 __extends(CreatePolygonHandler, _super);
32244 function CreatePolygonHandler() {
32245 return _super !== null && _super.apply(this, arguments) || this;
32247 CreatePolygonHandler.prototype._addPoint = function (tag, basicPoint) {
32248 tag.addPoint(basicPoint);
32250 Object.defineProperty(CreatePolygonHandler.prototype, "_create$", {
32252 return this._tagCreator.createPolygon$;
32257 CreatePolygonHandler.prototype._getNameExtension = function () {
32258 return "create-polygon";
32260 CreatePolygonHandler.prototype._setVertex2d = function (tag, basicPoint, transform) {
32261 tag.geometry.setVertex2d(tag.geometry.polygon.length - 2, basicPoint, transform);
32263 return CreatePolygonHandler;
32264 }(Component_1.CreateVertexHandler));
32265 exports.CreatePolygonHandler = CreatePolygonHandler;
32266 exports.default = CreatePolygonHandler;
32268 },{"../../../Component":274}],359:[function(require,module,exports){
32270 var __extends = (this && this.__extends) || (function () {
32271 var extendStatics = function (d, b) {
32272 extendStatics = Object.setPrototypeOf ||
32273 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32274 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32275 return extendStatics(d, b);
32277 return function (d, b) {
32278 extendStatics(d, b);
32279 function __() { this.constructor = d; }
32280 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32283 Object.defineProperty(exports, "__esModule", { value: true });
32284 var rxjs_1 = require("rxjs");
32285 var operators_1 = require("rxjs/operators");
32286 var Component_1 = require("../../../Component");
32287 var CreateRectDragHandler = /** @class */ (function (_super) {
32288 __extends(CreateRectDragHandler, _super);
32289 function CreateRectDragHandler() {
32290 return _super !== null && _super.apply(this, arguments) || this;
32292 CreateRectDragHandler.prototype._enableCreate = function () {
32294 this._container.mouseService.claimMouse(this._name, 2);
32295 this._deleteSubscription = this._navigator.stateService.currentTransform$.pipe(operators_1.map(function (transform) { return null; }), operators_1.skip(1))
32296 .subscribe(this._tagCreator.delete$);
32297 this._createSubscription = this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name, this._container.mouseService.mouseDragStart$)).pipe(operators_1.filter(this._validateBasic))
32298 .subscribe(this._tagCreator.createRect$);
32299 this._initializeAnchorIndexingSubscription = this._tagCreator.tag$.pipe(operators_1.filter(function (tag) {
32302 .subscribe(function (tag) {
32303 tag.geometry.initializeAnchorIndexing();
32305 var basicMouse$ = rxjs_1.combineLatest(rxjs_1.merge(this._container.mouseService.filtered$(this._name, this._container.mouseService.mouseMove$), this._container.mouseService.filtered$(this._name, this._container.mouseService.domMouseMove$)), this._container.renderService.renderCamera$).pipe(operators_1.withLatestFrom(this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
32306 var _b = _a[0], event = _b[0], camera = _b[1], transform = _a[1];
32307 return _this._mouseEventToBasic(event, _this._container.element, camera, transform);
32309 this._setVertexSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
32311 rxjs_1.combineLatest(rxjs_1.of(tag), basicMouse$, _this._navigator.stateService.currentTransform$) :
32314 .subscribe(function (_a) {
32315 var tag = _a[0], basicPoint = _a[1], transform = _a[2];
32316 tag.geometry.setOppositeVertex2d(basicPoint, transform);
32318 var basicMouseDragEnd$ = this._container.mouseService.mouseDragEnd$.pipe(operators_1.withLatestFrom(this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name, this._container.mouseService.mouseDrag$)).pipe(operators_1.filter(this._validateBasic)), function (event, basicPoint) {
32320 }), operators_1.share());
32321 this._addPointSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
32323 rxjs_1.combineLatest(rxjs_1.of(tag), basicMouseDragEnd$) :
32326 .subscribe(function (_a) {
32327 var tag = _a[0], basicPoint = _a[1];
32328 var rectGeometry = tag.geometry;
32329 if (!rectGeometry.validate(basicPoint)) {
32330 basicPoint = rectGeometry.getNonAdjustedVertex2d(3);
32332 tag.addPoint(basicPoint);
32334 this._geometryCreatedSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
32336 tag.created$.pipe(operators_1.map(function (t) {
32341 .subscribe(this._geometryCreated$);
32343 CreateRectDragHandler.prototype._disableCreate = function () {
32344 this._container.mouseService.unclaimMouse(this._name);
32345 this._tagCreator.delete$.next(null);
32346 this._addPointSubscription.unsubscribe();
32347 this._createSubscription.unsubscribe();
32348 this._deleteSubscription.unsubscribe();
32349 this._geometryCreatedSubscription.unsubscribe();
32350 this._initializeAnchorIndexingSubscription.unsubscribe();
32351 this._setVertexSubscription.unsubscribe();
32353 CreateRectDragHandler.prototype._getNameExtension = function () {
32354 return "create-rect-drag";
32356 return CreateRectDragHandler;
32357 }(Component_1.CreateHandlerBase));
32358 exports.CreateRectDragHandler = CreateRectDragHandler;
32359 exports.default = CreateRectDragHandler;
32361 },{"../../../Component":274,"rxjs":26,"rxjs/operators":224}],360:[function(require,module,exports){
32363 var __extends = (this && this.__extends) || (function () {
32364 var extendStatics = function (d, b) {
32365 extendStatics = Object.setPrototypeOf ||
32366 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32367 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32368 return extendStatics(d, b);
32370 return function (d, b) {
32371 extendStatics(d, b);
32372 function __() { this.constructor = d; }
32373 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32376 Object.defineProperty(exports, "__esModule", { value: true });
32377 var operators_1 = require("rxjs/operators");
32378 var Component_1 = require("../../../Component");
32379 var CreateRectHandler = /** @class */ (function (_super) {
32380 __extends(CreateRectHandler, _super);
32381 function CreateRectHandler() {
32382 return _super !== null && _super.apply(this, arguments) || this;
32384 Object.defineProperty(CreateRectHandler.prototype, "_create$", {
32386 return this._tagCreator.createRect$;
32391 CreateRectHandler.prototype._addPoint = function (tag, basicPoint) {
32392 var rectGeometry = tag.geometry;
32393 if (!rectGeometry.validate(basicPoint)) {
32394 basicPoint = rectGeometry.getNonAdjustedVertex2d(3);
32396 tag.addPoint(basicPoint);
32398 CreateRectHandler.prototype._enable = function () {
32399 _super.prototype._enable.call(this);
32400 this._initializeAnchorIndexingSubscription = this._tagCreator.tag$.pipe(operators_1.filter(function (tag) {
32403 .subscribe(function (tag) {
32404 tag.geometry.initializeAnchorIndexing();
32407 CreateRectHandler.prototype._disable = function () {
32408 _super.prototype._disable.call(this);
32409 this._initializeAnchorIndexingSubscription.unsubscribe();
32411 CreateRectHandler.prototype._getNameExtension = function () {
32412 return "create-rect";
32414 CreateRectHandler.prototype._setVertex2d = function (tag, basicPoint, transform) {
32415 tag.geometry.setOppositeVertex2d(basicPoint, transform);
32417 return CreateRectHandler;
32418 }(Component_1.CreateVertexHandler));
32419 exports.CreateRectHandler = CreateRectHandler;
32420 exports.default = CreateRectHandler;
32422 },{"../../../Component":274,"rxjs/operators":224}],361:[function(require,module,exports){
32424 var __extends = (this && this.__extends) || (function () {
32425 var extendStatics = function (d, b) {
32426 extendStatics = Object.setPrototypeOf ||
32427 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32428 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32429 return extendStatics(d, b);
32431 return function (d, b) {
32432 extendStatics(d, b);
32433 function __() { this.constructor = d; }
32434 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32437 Object.defineProperty(exports, "__esModule", { value: true });
32438 var rxjs_1 = require("rxjs");
32439 var operators_1 = require("rxjs/operators");
32440 var Component_1 = require("../../../Component");
32441 var CreateVertexHandler = /** @class */ (function (_super) {
32442 __extends(CreateVertexHandler, _super);
32443 function CreateVertexHandler() {
32444 return _super !== null && _super.apply(this, arguments) || this;
32446 CreateVertexHandler.prototype._enableCreate = function () {
32448 this._container.mouseService.deferPixels(this._name, 4);
32449 var transformChanged$ = this._navigator.stateService.currentTransform$.pipe(operators_1.map(function (transform) { }), operators_1.publishReplay(1), operators_1.refCount());
32450 this._deleteSubscription = transformChanged$.pipe(operators_1.skip(1))
32451 .subscribe(this._tagCreator.delete$);
32452 var basicClick$ = this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(operators_1.share());
32453 this._createSubscription = transformChanged$.pipe(operators_1.switchMap(function () {
32454 return basicClick$.pipe(operators_1.filter(_this._validateBasic), operators_1.take(1));
32456 .subscribe(this._create$);
32457 this._setVertexSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
32459 rxjs_1.combineLatest(rxjs_1.of(tag), rxjs_1.merge(_this._container.mouseService.mouseMove$, _this._container.mouseService.domMouseMove$), _this._container.renderService.renderCamera$, _this._navigator.stateService.currentTransform$) :
32462 .subscribe(function (_a) {
32463 var tag = _a[0], event = _a[1], camera = _a[2], transform = _a[3];
32464 var basicPoint = _this._mouseEventToBasic(event, _this._container.element, camera, transform);
32465 _this._setVertex2d(tag, basicPoint, transform);
32467 this._addPointSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
32469 rxjs_1.combineLatest(rxjs_1.of(tag), basicClick$) :
32472 .subscribe(function (_a) {
32473 var tag = _a[0], basicPoint = _a[1];
32474 _this._addPoint(tag, basicPoint);
32476 this._geometryCreateSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
32478 tag.created$.pipe(operators_1.map(function (t) {
32483 .subscribe(this._geometryCreated$);
32485 CreateVertexHandler.prototype._disableCreate = function () {
32486 this._container.mouseService.undeferPixels(this._name);
32487 this._tagCreator.delete$.next(null);
32488 this._addPointSubscription.unsubscribe();
32489 this._createSubscription.unsubscribe();
32490 this._deleteSubscription.unsubscribe();
32491 this._geometryCreateSubscription.unsubscribe();
32492 this._setVertexSubscription.unsubscribe();
32494 return CreateVertexHandler;
32495 }(Component_1.CreateHandlerBase));
32496 exports.CreateVertexHandler = CreateVertexHandler;
32497 exports.default = CreateVertexHandler;
32499 },{"../../../Component":274,"rxjs":26,"rxjs/operators":224}],362:[function(require,module,exports){
32501 var __extends = (this && this.__extends) || (function () {
32502 var extendStatics = function (d, b) {
32503 extendStatics = Object.setPrototypeOf ||
32504 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32505 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32506 return extendStatics(d, b);
32508 return function (d, b) {
32509 extendStatics(d, b);
32510 function __() { this.constructor = d; }
32511 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32514 Object.defineProperty(exports, "__esModule", { value: true });
32515 var rxjs_1 = require("rxjs");
32516 var operators_1 = require("rxjs/operators");
32517 var Component_1 = require("../../../Component");
32518 var EditVertexHandler = /** @class */ (function (_super) {
32519 __extends(EditVertexHandler, _super);
32520 function EditVertexHandler(component, container, navigator, viewportCoords, tagSet) {
32521 var _this = _super.call(this, component, container, navigator, viewportCoords) || this;
32522 _this._tagSet = tagSet;
32525 EditVertexHandler.prototype._enable = function () {
32527 var interaction$ = this._tagSet.changed$.pipe(operators_1.map(function (tagSet) {
32528 return tagSet.getAll();
32529 }), operators_1.switchMap(function (tags) {
32530 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
32531 return tag.interact$;
32533 }), operators_1.switchMap(function (interaction) {
32534 return rxjs_1.concat(rxjs_1.of(interaction), _this._container.mouseService.documentMouseUp$.pipe(operators_1.map(function () {
32535 return { offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: null };
32536 }), operators_1.first()));
32537 }), operators_1.share());
32538 var mouseMove$ = rxjs_1.merge(this._container.mouseService.mouseMove$, this._container.mouseService.domMouseMove$).pipe(operators_1.share());
32539 this._claimMouseSubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
32540 return !!interaction.tag ? _this._container.mouseService.domMouseDragStart$ : rxjs_1.empty();
32542 .subscribe(function () {
32543 _this._container.mouseService.claimMouse(_this._name, 3);
32545 this._cursorSubscription = interaction$.pipe(operators_1.map(function (interaction) {
32546 return interaction.cursor;
32547 }), operators_1.distinctUntilChanged())
32548 .subscribe(function (cursor) {
32549 var interactionCursors = ["crosshair", "move", "nesw-resize", "nwse-resize"];
32550 for (var _i = 0, interactionCursors_1 = interactionCursors; _i < interactionCursors_1.length; _i++) {
32551 var interactionCursor = interactionCursors_1[_i];
32552 _this._container.element.classList.remove("component-tag-edit-" + interactionCursor);
32555 _this._container.element.classList.add("component-tag-edit-" + cursor);
32558 this._unclaimMouseSubscription = this._container.mouseService
32559 .filtered$(this._name, this._container.mouseService.domMouseDragEnd$)
32560 .subscribe(function (e) {
32561 _this._container.mouseService.unclaimMouse(_this._name);
32563 this._preventDefaultSubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
32564 return !!interaction.tag ?
32565 _this._container.mouseService.documentMouseMove$ :
32568 .subscribe(function (event) {
32569 event.preventDefault(); // prevent selection of content outside the viewer
32571 this._updateGeometrySubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
32572 if (interaction.operation === Component_1.TagOperation.None || !interaction.tag) {
32573 return rxjs_1.empty();
32575 var mouseDrag$ = _this._container.mouseService
32576 .filtered$(_this._name, _this._container.mouseService.domMouseDrag$).pipe(operators_1.filter(function (event) {
32577 return _this._viewportCoords.insideElement(event, _this._container.element);
32579 return rxjs_1.combineLatest(mouseDrag$, _this._container.renderService.renderCamera$).pipe(operators_1.withLatestFrom(rxjs_1.of(interaction), _this._navigator.stateService.currentTransform$, function (_a, i, transform) {
32580 var event = _a[0], render = _a[1];
32581 return [event, render, i, transform];
32584 .subscribe(function (_a) {
32585 var mouseEvent = _a[0], renderCamera = _a[1], interaction = _a[2], transform = _a[3];
32586 var basic = _this._mouseEventToBasic(mouseEvent, _this._container.element, renderCamera, transform, interaction.offsetX, interaction.offsetY);
32587 var geometry = interaction.tag.geometry;
32588 if (interaction.operation === Component_1.TagOperation.Centroid) {
32589 geometry.setCentroid2d(basic, transform);
32591 else if (interaction.operation === Component_1.TagOperation.Vertex) {
32592 geometry.setVertex2d(interaction.vertexIndex, basic, transform);
32596 EditVertexHandler.prototype._disable = function () {
32597 this._claimMouseSubscription.unsubscribe();
32598 this._cursorSubscription.unsubscribe();
32599 this._preventDefaultSubscription.unsubscribe();
32600 this._unclaimMouseSubscription.unsubscribe();
32601 this._updateGeometrySubscription.unsubscribe();
32603 EditVertexHandler.prototype._getNameExtension = function () {
32604 return "edit-vertex";
32606 return EditVertexHandler;
32607 }(Component_1.TagHandlerBase));
32608 exports.EditVertexHandler = EditVertexHandler;
32609 exports.default = EditVertexHandler;
32612 },{"../../../Component":274,"rxjs":26,"rxjs/operators":224}],363:[function(require,module,exports){
32614 var __extends = (this && this.__extends) || (function () {
32615 var extendStatics = function (d, b) {
32616 extendStatics = Object.setPrototypeOf ||
32617 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32618 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32619 return extendStatics(d, b);
32621 return function (d, b) {
32622 extendStatics(d, b);
32623 function __() { this.constructor = d; }
32624 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32627 Object.defineProperty(exports, "__esModule", { value: true });
32628 var Component_1 = require("../../../Component");
32629 var TagHandlerBase = /** @class */ (function (_super) {
32630 __extends(TagHandlerBase, _super);
32631 function TagHandlerBase(component, container, navigator, viewportCoords) {
32632 var _this = _super.call(this, component, container, navigator) || this;
32633 _this._name = _this._component.name + "-" + _this._getNameExtension();
32634 _this._viewportCoords = viewportCoords;
32637 TagHandlerBase.prototype._getConfiguration = function (enable) {
32640 TagHandlerBase.prototype._mouseEventToBasic = function (event, element, camera, transform, offsetX, offsetY) {
32641 offsetX = offsetX != null ? offsetX : 0;
32642 offsetY = offsetY != null ? offsetY : 0;
32643 var _a = this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
32644 var basic = this._viewportCoords.canvasToBasic(canvasX - offsetX, canvasY - offsetY, element, transform, camera.perspective);
32647 return TagHandlerBase;
32648 }(Component_1.HandlerBase));
32649 exports.TagHandlerBase = TagHandlerBase;
32650 exports.default = TagHandlerBase;
32653 },{"../../../Component":274}],364:[function(require,module,exports){
32655 Object.defineProperty(exports, "__esModule", { value: true });
32656 var operators_1 = require("rxjs/operators");
32657 var THREE = require("three");
32658 var vd = require("virtual-dom");
32659 var rxjs_1 = require("rxjs");
32660 var Component_1 = require("../../../Component");
32661 var Geo_1 = require("../../../Geo");
32662 var OutlineCreateTag = /** @class */ (function () {
32663 function OutlineCreateTag(geometry, options, transform, viewportCoords) {
32665 this._geometry = geometry;
32666 this._options = { color: options.color == null ? 0xFFFFFF : options.color };
32667 this._transform = transform;
32668 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
32669 this._outline = this._createOutine();
32670 this._glObjects = [this._outline];
32671 this._aborted$ = new rxjs_1.Subject();
32672 this._created$ = new rxjs_1.Subject();
32673 this._glObjectsChanged$ = new rxjs_1.Subject();
32674 this._geometryChangedSubscription = this._geometry.changed$
32675 .subscribe(function (vertexGeometry) {
32676 _this._disposeOutline();
32677 _this._outline = _this._createOutine();
32678 _this._glObjects = [_this._outline];
32679 _this._glObjectsChanged$.next(_this);
32682 Object.defineProperty(OutlineCreateTag.prototype, "geometry", {
32684 return this._geometry;
32689 Object.defineProperty(OutlineCreateTag.prototype, "glObjects", {
32691 return this._glObjects;
32696 Object.defineProperty(OutlineCreateTag.prototype, "aborted$", {
32698 return this._aborted$;
32703 Object.defineProperty(OutlineCreateTag.prototype, "created$", {
32705 return this._created$;
32710 Object.defineProperty(OutlineCreateTag.prototype, "glObjectsChanged$", {
32712 return this._glObjectsChanged$;
32717 Object.defineProperty(OutlineCreateTag.prototype, "geometryChanged$", {
32720 return this._geometry.changed$.pipe(operators_1.map(function (geometry) {
32727 OutlineCreateTag.prototype.dispose = function () {
32728 this._disposeOutline();
32729 this._geometryChangedSubscription.unsubscribe();
32731 OutlineCreateTag.prototype.getDOMObjects = function (camera, size) {
32735 offsetHeight: size.height, offsetWidth: size.width,
32737 var abort = function (e) {
32738 e.stopPropagation();
32739 _this._aborted$.next(_this);
32741 if (this._geometry instanceof Component_1.RectGeometry) {
32742 var anchorIndex = this._geometry.anchorIndex;
32743 var vertexIndex = anchorIndex === undefined ? 1 : anchorIndex;
32744 var _a = this._geometry.getVertex2d(vertexIndex), basicX = _a[0], basicY = _a[1];
32745 var canvasPoint = this._viewportCoords.basicToCanvasSafe(basicX, basicY, container, this._transform, camera);
32746 if (canvasPoint != null) {
32747 var background = this._colorToBackground(this._options.color);
32748 var transform = this._canvasToTransform(canvasPoint);
32749 var pointProperties = {
32750 style: { background: background, transform: transform },
32752 var completerProperties = {
32754 style: { transform: transform },
32756 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
32757 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
32760 else if (this._geometry instanceof Component_1.PolygonGeometry) {
32761 var polygonGeometry_1 = this._geometry;
32762 var _b = polygonGeometry_1.getVertex2d(0), firstVertexBasicX = _b[0], firstVertexBasicY = _b[1];
32763 var firstVertexCanvas = this._viewportCoords.basicToCanvasSafe(firstVertexBasicX, firstVertexBasicY, container, this._transform, camera);
32764 if (firstVertexCanvas != null) {
32765 var firstOnclick = polygonGeometry_1.polygon.length > 4 ?
32767 e.stopPropagation();
32768 polygonGeometry_1.removeVertex2d(polygonGeometry_1.polygon.length - 2);
32769 _this._created$.next(_this);
32772 var transform = this._canvasToTransform(firstVertexCanvas);
32773 var completerProperties = {
32774 onclick: firstOnclick,
32775 style: { transform: transform },
32777 var firstClass = polygonGeometry_1.polygon.length > 4 ?
32780 vNodes.push(vd.h("div." + firstClass, completerProperties, []));
32782 if (polygonGeometry_1.polygon.length > 3) {
32783 var _c = polygonGeometry_1.getVertex2d(polygonGeometry_1.polygon.length - 3), lastVertexBasicX = _c[0], lastVertexBasicY = _c[1];
32784 var lastVertexCanvas = this._viewportCoords.basicToCanvasSafe(lastVertexBasicX, lastVertexBasicY, container, this._transform, camera);
32785 if (lastVertexCanvas != null) {
32786 var remove = function (e) {
32787 e.stopPropagation();
32788 polygonGeometry_1.removeVertex2d(polygonGeometry_1.polygon.length - 3);
32790 var transform = this._canvasToTransform(lastVertexCanvas);
32791 var completerProperties = {
32793 style: { transform: transform },
32795 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
32798 var verticesBasic = polygonGeometry_1.polygon.slice();
32799 verticesBasic.splice(-2, 2);
32800 for (var _i = 0, verticesBasic_1 = verticesBasic; _i < verticesBasic_1.length; _i++) {
32801 var vertexBasic = verticesBasic_1[_i];
32802 var vertexCanvas = this._viewportCoords.basicToCanvasSafe(vertexBasic[0], vertexBasic[1], container, this._transform, camera);
32803 if (vertexCanvas != null) {
32804 var background = this._colorToBackground(this._options.color);
32805 var transform = this._canvasToTransform(vertexCanvas);
32806 var pointProperties = {
32808 background: background,
32809 transform: transform,
32812 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
32818 OutlineCreateTag.prototype.addPoint = function (point) {
32819 if (this._geometry instanceof Component_1.RectGeometry) {
32820 var rectGeometry = this._geometry;
32821 if (!rectGeometry.validate(point)) {
32824 this._created$.next(this);
32826 else if (this._geometry instanceof Component_1.PolygonGeometry) {
32827 var polygonGeometry = this._geometry;
32828 polygonGeometry.addVertex2d(point);
32831 OutlineCreateTag.prototype._canvasToTransform = function (canvas) {
32832 var canvasX = Math.round(canvas[0]);
32833 var canvasY = Math.round(canvas[1]);
32834 var transform = "translate(-50%,-50%) translate(" + canvasX + "px," + canvasY + "px)";
32837 OutlineCreateTag.prototype._colorToBackground = function (color) {
32838 return "#" + ("000000" + color.toString(16)).substr(-6);
32840 OutlineCreateTag.prototype._createOutine = function () {
32841 var polygon3d = this._geometry instanceof Component_1.RectGeometry ?
32842 this._geometry.getPoints3d(this._transform) :
32843 this._geometry.getVertices3d(this._transform);
32844 var positions = this._getLinePositions(polygon3d);
32845 var geometry = new THREE.BufferGeometry();
32846 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
32847 var material = new THREE.LineBasicMaterial({
32848 color: this._options.color,
32851 return new THREE.Line(geometry, material);
32853 OutlineCreateTag.prototype._disposeOutline = function () {
32854 if (this._outline == null) {
32857 var line = this._outline;
32858 line.geometry.dispose();
32859 line.material.dispose();
32860 this._outline = null;
32861 this._glObjects = [];
32863 OutlineCreateTag.prototype._getLinePositions = function (polygon3d) {
32864 var length = polygon3d.length;
32865 var positions = new Float32Array(length * 3);
32866 for (var i = 0; i < length; ++i) {
32868 var position = polygon3d[i];
32869 positions[index] = position[0];
32870 positions[index + 1] = position[1];
32871 positions[index + 2] = position[2];
32875 return OutlineCreateTag;
32877 exports.OutlineCreateTag = OutlineCreateTag;
32878 exports.default = OutlineCreateTag;
32881 },{"../../../Component":274,"../../../Geo":277,"rxjs":26,"rxjs/operators":224,"three":225,"virtual-dom":230}],365:[function(require,module,exports){
32883 var __extends = (this && this.__extends) || (function () {
32884 var extendStatics = function (d, b) {
32885 extendStatics = Object.setPrototypeOf ||
32886 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32887 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32888 return extendStatics(d, b);
32890 return function (d, b) {
32891 extendStatics(d, b);
32892 function __() { this.constructor = d; }
32893 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32896 Object.defineProperty(exports, "__esModule", { value: true });
32897 var THREE = require("three");
32898 var vd = require("virtual-dom");
32899 var Component_1 = require("../../../Component");
32901 * @class OutlineRenderTag
32902 * @classdesc Tag visualizing the properties of an OutlineTag.
32904 var OutlineRenderTag = /** @class */ (function (_super) {
32905 __extends(OutlineRenderTag, _super);
32906 function OutlineRenderTag(tag, transform) {
32907 var _this = _super.call(this, tag, transform) || this;
32908 _this._fill = !transform.gpano ?
32909 _this._createFill() :
32911 _this._holes = _this._tag.lineWidth >= 1 ?
32912 _this._createHoles() :
32914 _this._outline = _this._tag.lineWidth >= 1 ?
32915 _this._createOutline() :
32917 _this._geometryChangedSubscription = _this._tag.geometry.changed$
32918 .subscribe(function (geometry) {
32919 if (_this._fill != null) {
32920 _this._updateFillGeometry();
32922 if (_this._holes.length > 0) {
32923 _this._updateHoleGeometries();
32925 if (_this._outline != null) {
32926 _this._updateOulineGeometry();
32929 _this._changedSubscription = _this._tag.changed$
32930 .subscribe(function (changedTag) {
32931 var glObjectsChanged = false;
32932 if (_this._fill != null) {
32933 _this._updateFillMaterial(_this._fill.material);
32935 if (_this._outline == null) {
32936 if (_this._tag.lineWidth >= 1) {
32937 _this._holes = _this._createHoles();
32938 _this._outline = _this._createOutline();
32939 glObjectsChanged = true;
32943 _this._updateHoleMaterials();
32944 _this._updateOutlineMaterial();
32946 if (glObjectsChanged) {
32947 _this._glObjectsChanged$.next(_this);
32952 OutlineRenderTag.prototype.dispose = function () {
32953 this._disposeFill();
32954 this._disposeHoles();
32955 this._disposeOutline();
32956 this._changedSubscription.unsubscribe();
32957 this._geometryChangedSubscription.unsubscribe();
32959 OutlineRenderTag.prototype.getDOMObjects = function (atlas, camera, size) {
32962 var isRect = this._tag.geometry instanceof Component_1.RectGeometry;
32963 var isPerspective = !this._transform.gpano;
32965 offsetHeight: size.height, offsetWidth: size.width,
32967 if (this._tag.icon != null && (isRect || isPerspective)) {
32968 var _a = this._tag.geometry instanceof Component_1.RectGeometry ?
32969 this._tag.geometry.getVertex2d(this._tag.iconIndex) :
32970 this._tag.geometry.getPoleOfInaccessibility2d(), iconBasicX = _a[0], iconBasicY = _a[1];
32971 var iconCanvas = this._viewportCoords.basicToCanvasSafe(iconBasicX, iconBasicY, container, this._transform, camera);
32972 if (iconCanvas != null) {
32973 var interact = function (e) {
32974 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
32976 if (atlas.loaded) {
32977 var sprite = atlas.getDOMSprite(this._tag.icon, this._tag.iconFloat);
32978 var iconCanvasX = Math.round(iconCanvas[0]);
32979 var iconCanvasY = Math.round(iconCanvas[1]);
32980 var transform = "translate(" + iconCanvasX + "px," + iconCanvasY + "px)";
32981 var click = function (e) {
32982 e.stopPropagation();
32983 _this._tag.click$.next(_this._tag);
32987 onmousedown: interact,
32988 style: { transform: transform },
32990 vNodes.push(vd.h("div.TagSymbol", properties, [sprite]));
32994 else if (this._tag.text != null && (isRect || isPerspective)) {
32995 var _b = this._tag.geometry instanceof Component_1.RectGeometry ?
32996 this._tag.geometry.getVertex2d(3) :
32997 this._tag.geometry.getPoleOfInaccessibility2d(), textBasicX = _b[0], textBasicY = _b[1];
32998 var textCanvas = this._viewportCoords.basicToCanvasSafe(textBasicX, textBasicY, container, this._transform, camera);
32999 if (textCanvas != null) {
33000 var textCanvasX = Math.round(textCanvas[0]);
33001 var textCanvasY = Math.round(textCanvas[1]);
33002 var transform = this._tag.geometry instanceof Component_1.RectGeometry ?
33003 "translate(" + textCanvasX + "px," + textCanvasY + "px)" :
33004 "translate(-50%, -50%) translate(" + textCanvasX + "px," + textCanvasY + "px)";
33005 var interact = function (e) {
33006 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
33009 onmousedown: interact,
33011 color: this._colorToCss(this._tag.textColor),
33012 transform: transform,
33014 textContent: this._tag.text,
33016 vNodes.push(vd.h("span.TagSymbol", properties, []));
33019 if (!this._tag.editable) {
33022 var lineColor = this._colorToCss(this._tag.lineColor);
33023 if (this._tag.geometry instanceof Component_1.RectGeometry) {
33024 var _c = this._tag.geometry.getCentroid2d(), centroidBasicX = _c[0], centroidBasicY = _c[1];
33025 var centroidCanvas = this._viewportCoords.basicToCanvasSafe(centroidBasicX, centroidBasicY, container, this._transform, camera);
33026 if (centroidCanvas != null) {
33027 var interact = this._interact(Component_1.TagOperation.Centroid, "move");
33028 var centroidCanvasX = Math.round(centroidCanvas[0]);
33029 var centroidCanvasY = Math.round(centroidCanvas[1]);
33030 var transform = "translate(-50%, -50%) translate(" + centroidCanvasX + "px," + centroidCanvasY + "px)";
33032 onmousedown: interact,
33033 style: { background: lineColor, transform: transform },
33035 vNodes.push(vd.h("div.TagMover", properties, []));
33038 var vertices2d = this._tag.geometry.getVertices2d();
33039 for (var i = 0; i < vertices2d.length - 1; i++) {
33041 ((this._tag.icon != null && i === this._tag.iconIndex) ||
33042 (this._tag.icon == null && this._tag.text != null && i === 3))) {
33045 var _d = vertices2d[i], vertexBasicX = _d[0], vertexBasicY = _d[1];
33046 var vertexCanvas = this._viewportCoords.basicToCanvasSafe(vertexBasicX, vertexBasicY, container, this._transform, camera);
33047 if (vertexCanvas == null) {
33050 var cursor = isRect ?
33051 i % 2 === 0 ? "nesw-resize" : "nwse-resize" :
33053 var interact = this._interact(Component_1.TagOperation.Vertex, cursor, i);
33054 var vertexCanvasX = Math.round(vertexCanvas[0]);
33055 var vertexCanvasY = Math.round(vertexCanvas[1]);
33056 var transform = "translate(-50%, -50%) translate(" + vertexCanvasX + "px," + vertexCanvasY + "px)";
33058 onmousedown: interact,
33059 style: { background: lineColor, transform: transform, cursor: cursor },
33061 vNodes.push(vd.h("div.TagResizer", properties, []));
33062 if (!this._tag.indicateVertices) {
33065 var pointProperties = {
33066 style: { background: lineColor, transform: transform },
33068 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
33072 OutlineRenderTag.prototype.getGLObjects = function () {
33073 var glObjects = [];
33074 if (this._fill != null) {
33075 glObjects.push(this._fill);
33077 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
33079 glObjects.push(hole);
33081 if (this._outline != null) {
33082 glObjects.push(this._outline);
33086 OutlineRenderTag.prototype.getRetrievableObjects = function () {
33087 return this._fill != null ? [this._fill] : [];
33089 OutlineRenderTag.prototype._colorToCss = function (color) {
33090 return "#" + ("000000" + color.toString(16)).substr(-6);
33092 OutlineRenderTag.prototype._createFill = function () {
33093 var triangles = this._getTriangles();
33094 var positions = new Float32Array(triangles);
33095 var geometry = new THREE.BufferGeometry();
33096 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
33097 geometry.computeBoundingSphere();
33098 var material = new THREE.MeshBasicMaterial({ side: THREE.DoubleSide, transparent: true });
33099 this._updateFillMaterial(material);
33100 return new THREE.Mesh(geometry, material);
33102 OutlineRenderTag.prototype._createHoles = function () {
33104 if (this._tag.geometry instanceof Component_1.PolygonGeometry) {
33105 var holes3d = this._getHoles3d();
33106 for (var _i = 0, holes3d_1 = holes3d; _i < holes3d_1.length; _i++) {
33107 var holePoints3d = holes3d_1[_i];
33108 var hole = this._createLine(holePoints3d);
33114 OutlineRenderTag.prototype._createLine = function (points3d) {
33115 var positions = this._getLinePositions(points3d);
33116 var geometry = new THREE.BufferGeometry();
33117 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
33118 geometry.computeBoundingSphere();
33119 var material = new THREE.LineBasicMaterial();
33120 this._updateLineBasicMaterial(material);
33121 var line = new THREE.Line(geometry, material);
33122 line.renderOrder = 1;
33125 OutlineRenderTag.prototype._createOutline = function () {
33126 return this._createLine(this._getPoints3d());
33128 OutlineRenderTag.prototype._disposeFill = function () {
33129 if (this._fill == null) {
33132 this._fill.geometry.dispose();
33133 this._fill.material.dispose();
33136 OutlineRenderTag.prototype._disposeHoles = function () {
33137 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
33139 hole.geometry.dispose();
33140 hole.material.dispose();
33144 OutlineRenderTag.prototype._disposeOutline = function () {
33145 if (this._outline == null) {
33148 this._outline.geometry.dispose();
33149 this._outline.material.dispose();
33150 this._outline = null;
33152 OutlineRenderTag.prototype._getLinePositions = function (points3d) {
33153 var length = points3d.length;
33154 var positions = new Float32Array(length * 3);
33155 for (var i = 0; i < length; ++i) {
33157 var position = points3d[i];
33158 positions[index + 0] = position[0];
33159 positions[index + 1] = position[1];
33160 positions[index + 2] = position[2];
33164 OutlineRenderTag.prototype._getHoles3d = function () {
33165 var polygonGeometry = this._tag.geometry;
33166 return this._in3dDomain() ?
33167 polygonGeometry.getHoleVertices3d(this._transform) :
33168 polygonGeometry.getHolePoints3d(this._transform);
33170 OutlineRenderTag.prototype._getPoints3d = function () {
33171 return this._in3dDomain() ?
33172 this._tag.geometry.getVertices3d(this._transform) :
33173 this._tag.geometry.getPoints3d(this._transform);
33175 OutlineRenderTag.prototype._getTriangles = function () {
33176 return this._in3dDomain() ?
33177 this._tag.geometry.get3dDomainTriangles3d(this._transform) :
33178 this._tag.geometry.getTriangles3d(this._transform);
33180 OutlineRenderTag.prototype._in3dDomain = function () {
33181 return this._tag.geometry instanceof Component_1.PolygonGeometry && this._tag.domain === Component_1.TagDomain.ThreeDimensional;
33183 OutlineRenderTag.prototype._interact = function (operation, cursor, vertexIndex) {
33185 return function (e) {
33186 var offsetX = e.offsetX - e.target.offsetWidth / 2;
33187 var offsetY = e.offsetY - e.target.offsetHeight / 2;
33188 _this._interact$.next({
33192 operation: operation,
33194 vertexIndex: vertexIndex,
33198 OutlineRenderTag.prototype._updateFillGeometry = function () {
33199 var triangles = this._getTriangles();
33200 var positions = new Float32Array(triangles);
33201 var geometry = this._fill.geometry;
33202 var attribute = geometry.getAttribute("position");
33203 if (attribute.array.length === positions.length) {
33204 attribute.set(positions);
33205 attribute.needsUpdate = true;
33208 geometry.removeAttribute("position");
33209 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
33211 geometry.computeBoundingSphere();
33213 OutlineRenderTag.prototype._updateFillMaterial = function (material) {
33214 material.color = new THREE.Color(this._tag.fillColor);
33215 material.opacity = this._tag.fillOpacity;
33216 material.needsUpdate = true;
33218 OutlineRenderTag.prototype._updateHoleGeometries = function () {
33219 var holes3d = this._getHoles3d();
33220 if (holes3d.length !== this._holes.length) {
33221 throw new Error("Changing the number of holes is not supported.");
33223 for (var i = 0; i < this._holes.length; i++) {
33224 var holePoints3d = holes3d[i];
33225 var hole = this._holes[i];
33226 this._updateLine(hole, holePoints3d);
33229 OutlineRenderTag.prototype._updateHoleMaterials = function () {
33230 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
33232 var material = hole.material;
33233 this._updateLineBasicMaterial(material);
33236 OutlineRenderTag.prototype._updateLine = function (line, points3d) {
33237 var positions = this._getLinePositions(points3d);
33238 var geometry = line.geometry;
33239 var attribute = geometry.getAttribute("position");
33240 attribute.set(positions);
33241 attribute.needsUpdate = true;
33242 geometry.computeBoundingSphere();
33244 OutlineRenderTag.prototype._updateOulineGeometry = function () {
33245 this._updateLine(this._outline, this._getPoints3d());
33247 OutlineRenderTag.prototype._updateOutlineMaterial = function () {
33248 var material = this._outline.material;
33249 this._updateLineBasicMaterial(material);
33251 OutlineRenderTag.prototype._updateLineBasicMaterial = function (material) {
33252 material.color = new THREE.Color(this._tag.lineColor);
33253 material.linewidth = Math.max(this._tag.lineWidth, 1);
33254 material.visible = this._tag.lineWidth >= 1 && this._tag.lineOpacity > 0;
33255 material.opacity = this._tag.lineOpacity;
33256 material.transparent = this._tag.lineOpacity < 1;
33257 material.needsUpdate = true;
33259 return OutlineRenderTag;
33260 }(Component_1.RenderTag));
33261 exports.OutlineRenderTag = OutlineRenderTag;
33264 },{"../../../Component":274,"three":225,"virtual-dom":230}],366:[function(require,module,exports){
33266 var __extends = (this && this.__extends) || (function () {
33267 var extendStatics = function (d, b) {
33268 extendStatics = Object.setPrototypeOf ||
33269 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33270 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33271 return extendStatics(d, b);
33273 return function (d, b) {
33274 extendStatics(d, b);
33275 function __() { this.constructor = d; }
33276 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33279 Object.defineProperty(exports, "__esModule", { value: true });
33280 var rxjs_1 = require("rxjs");
33281 var Component_1 = require("../../../Component");
33282 var Viewer_1 = require("../../../Viewer");
33284 * @class OutlineTag
33286 * @classdesc Tag holding properties for visualizing a geometry outline.
33290 * var geometry = new Mapillary.TagComponent.RectGeometry([0.3, 0.3, 0.5, 0.4]);
33291 * var tag = new Mapillary.TagComponent.OutlineTag(
33294 * { editable: true, lineColor: 0xff0000 });
33296 * tagComponent.add([tag]);
33299 var OutlineTag = /** @class */ (function (_super) {
33300 __extends(OutlineTag, _super);
33302 * Create an outline tag.
33306 * @param {string} id - Unique identifier of the tag.
33307 * @param {VertexGeometry} geometry - Geometry defining vertices of tag.
33308 * @param {IOutlineTagOptions} options - Options defining the visual appearance and
33309 * behavior of the outline tag.
33311 function OutlineTag(id, geometry, options) {
33312 var _this = _super.call(this, id, geometry) || this;
33313 options = !!options ? options : {};
33314 var domain = options.domain != null && geometry instanceof Component_1.PolygonGeometry ?
33315 options.domain : Component_1.TagDomain.TwoDimensional;
33316 var twoDimensionalPolygon = _this._twoDimensionalPolygon(domain, geometry);
33317 _this._domain = domain;
33318 _this._editable = options.editable == null || twoDimensionalPolygon ? false : options.editable;
33319 _this._fillColor = options.fillColor == null ? 0xFFFFFF : options.fillColor;
33320 _this._fillOpacity = options.fillOpacity == null ? 0.0 : options.fillOpacity;
33321 _this._icon = options.icon === undefined ? null : options.icon;
33322 _this._iconFloat = options.iconFloat == null ? Viewer_1.Alignment.Center : options.iconFloat;
33323 _this._iconIndex = options.iconIndex == null ? 3 : options.iconIndex;
33324 _this._indicateVertices = options.indicateVertices == null ? true : options.indicateVertices;
33325 _this._lineColor = options.lineColor == null ? 0xFFFFFF : options.lineColor;
33326 _this._lineOpacity = options.lineOpacity == null ? 1 : options.lineOpacity;
33327 _this._lineWidth = options.lineWidth == null ? 1 : options.lineWidth;
33328 _this._text = options.text === undefined ? null : options.text;
33329 _this._textColor = options.textColor == null ? 0xFFFFFF : options.textColor;
33330 _this._click$ = new rxjs_1.Subject();
33332 .subscribe(function (t) {
33333 _this.fire(OutlineTag.click, _this);
33337 Object.defineProperty(OutlineTag.prototype, "click$", {
33339 * Click observable.
33341 * @description An observable emitting the tag when the icon of the
33342 * tag has been clicked.
33344 * @returns {Observable<Tag>}
33347 return this._click$;
33352 Object.defineProperty(OutlineTag.prototype, "domain", {
33354 * Get domain property.
33356 * @description Readonly property that can only be set in constructor.
33358 * @returns Value indicating the domain of the tag.
33361 return this._domain;
33366 Object.defineProperty(OutlineTag.prototype, "editable", {
33368 * Get editable property.
33369 * @returns {boolean} Value indicating if tag is editable.
33372 return this._editable;
33375 * Set editable property.
33378 * @fires Tag#changed
33380 set: function (value) {
33381 if (this._twoDimensionalPolygon(this._domain, this._geometry)) {
33384 this._editable = value;
33385 this._notifyChanged$.next(this);
33390 Object.defineProperty(OutlineTag.prototype, "fillColor", {
33392 * Get fill color property.
33393 * @returns {number}
33396 return this._fillColor;
33399 * Set fill color property.
33402 * @fires Tag#changed
33404 set: function (value) {
33405 this._fillColor = value;
33406 this._notifyChanged$.next(this);
33411 Object.defineProperty(OutlineTag.prototype, "fillOpacity", {
33413 * Get fill opacity property.
33414 * @returns {number}
33417 return this._fillOpacity;
33420 * Set fill opacity property.
33423 * @fires Tag#changed
33425 set: function (value) {
33426 this._fillOpacity = value;
33427 this._notifyChanged$.next(this);
33432 Object.defineProperty(OutlineTag.prototype, "geometry", {
33435 return this._geometry;
33440 Object.defineProperty(OutlineTag.prototype, "icon", {
33442 * Get icon property.
33443 * @returns {string}
33449 * Set icon property.
33452 * @fires Tag#changed
33454 set: function (value) {
33455 this._icon = value;
33456 this._notifyChanged$.next(this);
33461 Object.defineProperty(OutlineTag.prototype, "iconFloat", {
33463 * Get icon float property.
33464 * @returns {Alignment}
33467 return this._iconFloat;
33470 * Set icon float property.
33471 * @param {Alignment}
33473 * @fires Tag#changed
33475 set: function (value) {
33476 this._iconFloat = value;
33477 this._notifyChanged$.next(this);
33482 Object.defineProperty(OutlineTag.prototype, "iconIndex", {
33484 * Get icon index property.
33485 * @returns {number}
33488 return this._iconIndex;
33491 * Set icon index property.
33494 * @fires Tag#changed
33496 set: function (value) {
33497 this._iconIndex = value;
33498 this._notifyChanged$.next(this);
33503 Object.defineProperty(OutlineTag.prototype, "indicateVertices", {
33505 * Get indicate vertices property.
33506 * @returns {boolean} Value indicating if vertices should be indicated
33507 * when tag is editable.
33510 return this._indicateVertices;
33513 * Set indicate vertices property.
33516 * @fires Tag#changed
33518 set: function (value) {
33519 this._indicateVertices = value;
33520 this._notifyChanged$.next(this);
33525 Object.defineProperty(OutlineTag.prototype, "lineColor", {
33527 * Get line color property.
33528 * @returns {number}
33531 return this._lineColor;
33534 * Set line color property.
33537 * @fires Tag#changed
33539 set: function (value) {
33540 this._lineColor = value;
33541 this._notifyChanged$.next(this);
33546 Object.defineProperty(OutlineTag.prototype, "lineOpacity", {
33548 * Get line opacity property.
33549 * @returns {number}
33552 return this._lineOpacity;
33555 * Set line opacity property.
33558 * @fires Tag#changed
33560 set: function (value) {
33561 this._lineOpacity = value;
33562 this._notifyChanged$.next(this);
33567 Object.defineProperty(OutlineTag.prototype, "lineWidth", {
33569 * Get line width property.
33570 * @returns {number}
33573 return this._lineWidth;
33576 * Set line width property.
33579 * @fires Tag#changed
33581 set: function (value) {
33582 this._lineWidth = value;
33583 this._notifyChanged$.next(this);
33588 Object.defineProperty(OutlineTag.prototype, "text", {
33590 * Get text property.
33591 * @returns {string}
33597 * Set text property.
33600 * @fires Tag#changed
33602 set: function (value) {
33603 this._text = value;
33604 this._notifyChanged$.next(this);
33609 Object.defineProperty(OutlineTag.prototype, "textColor", {
33611 * Get text color property.
33612 * @returns {number}
33615 return this._textColor;
33618 * Set text color property.
33621 * @fires Tag#changed
33623 set: function (value) {
33624 this._textColor = value;
33625 this._notifyChanged$.next(this);
33631 * Set options for tag.
33633 * @description Sets all the option properties provided and keeps
33634 * the rest of the values as is.
33636 * @param {IOutlineTagOptions} options - Outline tag options
33638 * @fires {Tag#changed}
33640 OutlineTag.prototype.setOptions = function (options) {
33641 var twoDimensionalPolygon = this._twoDimensionalPolygon(this._domain, this._geometry);
33642 this._editable = twoDimensionalPolygon || options.editable == null ? this._editable : options.editable;
33643 this._icon = options.icon === undefined ? this._icon : options.icon;
33644 this._iconFloat = options.iconFloat == null ? this._iconFloat : options.iconFloat;
33645 this._iconIndex = options.iconIndex == null ? this._iconIndex : options.iconIndex;
33646 this._indicateVertices = options.indicateVertices == null ? this._indicateVertices : options.indicateVertices;
33647 this._lineColor = options.lineColor == null ? this._lineColor : options.lineColor;
33648 this._lineWidth = options.lineWidth == null ? this._lineWidth : options.lineWidth;
33649 this._fillColor = options.fillColor == null ? this._fillColor : options.fillColor;
33650 this._fillOpacity = options.fillOpacity == null ? this._fillOpacity : options.fillOpacity;
33651 this._text = options.text === undefined ? this._text : options.text;
33652 this._textColor = options.textColor == null ? this._textColor : options.textColor;
33653 this._notifyChanged$.next(this);
33655 OutlineTag.prototype._twoDimensionalPolygon = function (domain, geometry) {
33656 return domain !== Component_1.TagDomain.ThreeDimensional && geometry instanceof Component_1.PolygonGeometry;
33659 * Event fired when the icon of the outline tag is clicked.
33661 * @event OutlineTag#click
33662 * @type {OutlineTag} The tag instance that was clicked.
33664 OutlineTag.click = "click";
33666 }(Component_1.Tag));
33667 exports.OutlineTag = OutlineTag;
33668 exports.default = OutlineTag;
33670 },{"../../../Component":274,"../../../Viewer":285,"rxjs":26}],367:[function(require,module,exports){
33672 Object.defineProperty(exports, "__esModule", { value: true });
33673 var rxjs_1 = require("rxjs");
33674 var Geo_1 = require("../../../Geo");
33675 var RenderTag = /** @class */ (function () {
33676 function RenderTag(tag, transform, viewportCoords) {
33678 this._transform = transform;
33679 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
33680 this._glObjectsChanged$ = new rxjs_1.Subject();
33681 this._interact$ = new rxjs_1.Subject();
33683 Object.defineProperty(RenderTag.prototype, "glObjectsChanged$", {
33685 return this._glObjectsChanged$;
33690 Object.defineProperty(RenderTag.prototype, "interact$", {
33692 return this._interact$;
33697 Object.defineProperty(RenderTag.prototype, "tag", {
33706 exports.RenderTag = RenderTag;
33707 exports.default = RenderTag;
33709 },{"../../../Geo":277,"rxjs":26}],368:[function(require,module,exports){
33711 var __extends = (this && this.__extends) || (function () {
33712 var extendStatics = function (d, b) {
33713 extendStatics = Object.setPrototypeOf ||
33714 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33715 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33716 return extendStatics(d, b);
33718 return function (d, b) {
33719 extendStatics(d, b);
33720 function __() { this.constructor = d; }
33721 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33724 Object.defineProperty(exports, "__esModule", { value: true });
33725 var vd = require("virtual-dom");
33726 var Component_1 = require("../../../Component");
33727 var Viewer_1 = require("../../../Viewer");
33729 * @class SpotRenderTag
33730 * @classdesc Tag visualizing the properties of a SpotTag.
33732 var SpotRenderTag = /** @class */ (function (_super) {
33733 __extends(SpotRenderTag, _super);
33734 function SpotRenderTag() {
33735 return _super !== null && _super.apply(this, arguments) || this;
33737 SpotRenderTag.prototype.dispose = function () { };
33738 SpotRenderTag.prototype.getDOMObjects = function (atlas, camera, size) {
33740 var tag = this._tag;
33742 offsetHeight: size.height, offsetWidth: size.width,
33745 var _a = tag.geometry.getCentroid2d(), centroidBasicX = _a[0], centroidBasicY = _a[1];
33746 var centroidCanvas = this._viewportCoords.basicToCanvasSafe(centroidBasicX, centroidBasicY, container, this._transform, camera);
33747 if (centroidCanvas != null) {
33748 var interactNone = function (e) {
33749 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: tag });
33751 var canvasX = Math.round(centroidCanvas[0]);
33752 var canvasY = Math.round(centroidCanvas[1]);
33753 if (tag.icon != null) {
33754 if (atlas.loaded) {
33755 var sprite = atlas.getDOMSprite(tag.icon, Viewer_1.Alignment.Bottom);
33756 var iconTransform = "translate(" + canvasX + "px," + (canvasY + 8) + "px)";
33758 onmousedown: interactNone,
33760 pointerEvents: "all",
33761 transform: iconTransform,
33764 vNodes.push(vd.h("div", properties, [sprite]));
33767 else if (tag.text != null) {
33768 var textTransform = "translate(-50%,0%) translate(" + canvasX + "px," + (canvasY + 8) + "px)";
33770 onmousedown: interactNone,
33772 color: this._colorToCss(tag.textColor),
33773 transform: textTransform,
33775 textContent: tag.text,
33777 vNodes.push(vd.h("span.TagSymbol", properties, []));
33779 var interact = this._interact(Component_1.TagOperation.Centroid, tag, "move");
33780 var background = this._colorToCss(tag.color);
33781 var transform = "translate(-50%,-50%) translate(" + canvasX + "px," + canvasY + "px)";
33782 if (tag.editable) {
33783 var interactorProperties = {
33784 onmousedown: interact,
33786 background: background,
33787 transform: transform,
33790 vNodes.push(vd.h("div.TagSpotInteractor", interactorProperties, []));
33792 var pointProperties = {
33794 background: background,
33795 transform: transform,
33798 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
33802 SpotRenderTag.prototype.getGLObjects = function () { return []; };
33803 SpotRenderTag.prototype.getRetrievableObjects = function () { return []; };
33804 SpotRenderTag.prototype._colorToCss = function (color) {
33805 return "#" + ("000000" + color.toString(16)).substr(-6);
33807 SpotRenderTag.prototype._interact = function (operation, tag, cursor, vertexIndex) {
33809 return function (e) {
33810 var offsetX = e.offsetX - e.target.offsetWidth / 2;
33811 var offsetY = e.offsetY - e.target.offsetHeight / 2;
33812 _this._interact$.next({
33816 operation: operation,
33818 vertexIndex: vertexIndex,
33822 return SpotRenderTag;
33823 }(Component_1.RenderTag));
33824 exports.SpotRenderTag = SpotRenderTag;
33827 },{"../../../Component":274,"../../../Viewer":285,"virtual-dom":230}],369:[function(require,module,exports){
33829 var __extends = (this && this.__extends) || (function () {
33830 var extendStatics = function (d, b) {
33831 extendStatics = Object.setPrototypeOf ||
33832 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33833 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33834 return extendStatics(d, b);
33836 return function (d, b) {
33837 extendStatics(d, b);
33838 function __() { this.constructor = d; }
33839 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33842 Object.defineProperty(exports, "__esModule", { value: true });
33843 var Component_1 = require("../../../Component");
33847 * @classdesc Tag holding properties for visualizing the centroid of a geometry.
33851 * var geometry = new Mapillary.TagComponent.PointGeometry([0.3, 0.3]);
33852 * var tag = new Mapillary.TagComponent.SpotTag(
33855 * { editable: true, color: 0xff0000 });
33857 * tagComponent.add([tag]);
33860 var SpotTag = /** @class */ (function (_super) {
33861 __extends(SpotTag, _super);
33863 * Create a spot tag.
33867 * @param {string} id
33868 * @param {Geometry} geometry
33869 * @param {IOutlineTagOptions} options - Options defining the visual appearance and
33870 * behavior of the spot tag.
33872 function SpotTag(id, geometry, options) {
33873 var _this = _super.call(this, id, geometry) || this;
33874 options = !!options ? options : {};
33875 _this._color = options.color == null ? 0xFFFFFF : options.color;
33876 _this._editable = options.editable == null ? false : options.editable;
33877 _this._icon = options.icon === undefined ? null : options.icon;
33878 _this._text = options.text === undefined ? null : options.text;
33879 _this._textColor = options.textColor == null ? 0xFFFFFF : options.textColor;
33882 Object.defineProperty(SpotTag.prototype, "color", {
33884 * Get color property.
33885 * @returns {number} The color of the spot as a hexagonal number;
33888 return this._color;
33891 * Set color property.
33894 * @fires Tag#changed
33896 set: function (value) {
33897 this._color = value;
33898 this._notifyChanged$.next(this);
33903 Object.defineProperty(SpotTag.prototype, "editable", {
33905 * Get editable property.
33906 * @returns {boolean} Value indicating if tag is editable.
33909 return this._editable;
33912 * Set editable property.
33915 * @fires Tag#changed
33917 set: function (value) {
33918 this._editable = value;
33919 this._notifyChanged$.next(this);
33924 Object.defineProperty(SpotTag.prototype, "icon", {
33926 * Get icon property.
33927 * @returns {string}
33933 * Set icon property.
33936 * @fires Tag#changed
33938 set: function (value) {
33939 this._icon = value;
33940 this._notifyChanged$.next(this);
33945 Object.defineProperty(SpotTag.prototype, "text", {
33947 * Get text property.
33948 * @returns {string}
33954 * Set text property.
33957 * @fires Tag#changed
33959 set: function (value) {
33960 this._text = value;
33961 this._notifyChanged$.next(this);
33966 Object.defineProperty(SpotTag.prototype, "textColor", {
33968 * Get text color property.
33969 * @returns {number}
33972 return this._textColor;
33975 * Set text color property.
33978 * @fires Tag#changed
33980 set: function (value) {
33981 this._textColor = value;
33982 this._notifyChanged$.next(this);
33988 * Set options for tag.
33990 * @description Sets all the option properties provided and keps
33991 * the rest of the values as is.
33993 * @param {ISpotTagOptions} options - Spot tag options
33995 * @fires {Tag#changed}
33997 SpotTag.prototype.setOptions = function (options) {
33998 this._color = options.color == null ? this._color : options.color;
33999 this._editable = options.editable == null ? this._editable : options.editable;
34000 this._icon = options.icon === undefined ? this._icon : options.icon;
34001 this._text = options.text === undefined ? this._text : options.text;
34002 this._textColor = options.textColor == null ? this._textColor : options.textColor;
34003 this._notifyChanged$.next(this);
34006 }(Component_1.Tag));
34007 exports.SpotTag = SpotTag;
34008 exports.default = SpotTag;
34010 },{"../../../Component":274}],370:[function(require,module,exports){
34012 var __extends = (this && this.__extends) || (function () {
34013 var extendStatics = function (d, b) {
34014 extendStatics = Object.setPrototypeOf ||
34015 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34016 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34017 return extendStatics(d, b);
34019 return function (d, b) {
34020 extendStatics(d, b);
34021 function __() { this.constructor = d; }
34022 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34025 Object.defineProperty(exports, "__esModule", { value: true });
34026 var operators_1 = require("rxjs/operators");
34027 var rxjs_1 = require("rxjs");
34028 var Utils_1 = require("../../../Utils");
34032 * @classdesc Abstract class representing the basic functionality of for a tag.
34034 var Tag = /** @class */ (function (_super) {
34035 __extends(Tag, _super);
34040 * @param {string} id
34041 * @param {Geometry} geometry
34043 function Tag(id, geometry) {
34044 var _this = _super.call(this) || this;
34046 _this._geometry = geometry;
34047 _this._notifyChanged$ = new rxjs_1.Subject();
34048 _this._notifyChanged$
34049 .subscribe(function (t) {
34050 _this.fire(Tag.changed, _this);
34052 _this._geometry.changed$
34053 .subscribe(function (g) {
34054 _this.fire(Tag.geometrychanged, _this);
34058 Object.defineProperty(Tag.prototype, "id", {
34061 * @returns {string}
34069 Object.defineProperty(Tag.prototype, "geometry", {
34071 * Get geometry property.
34072 * @returns {Geometry} The geometry of the tag.
34075 return this._geometry;
34080 Object.defineProperty(Tag.prototype, "changed$", {
34082 * Get changed observable.
34083 * @returns {Observable<Tag>}
34087 return this._notifyChanged$;
34092 Object.defineProperty(Tag.prototype, "geometryChanged$", {
34094 * Get geometry changed observable.
34095 * @returns {Observable<Tag>}
34100 return this._geometry.changed$.pipe(operators_1.map(function (geometry) {
34102 }), operators_1.share());
34108 * Event fired when a property related to the visual appearance of the
34111 * @event Tag#changed
34112 * @type {Tag} The tag instance that has changed.
34114 Tag.changed = "changed";
34116 * Event fired when the geometry of the tag has changed.
34118 * @event Tag#geometrychanged
34119 * @type {Tag} The tag instance whose geometry has changed.
34121 Tag.geometrychanged = "geometrychanged";
34123 }(Utils_1.EventEmitter));
34125 exports.default = Tag;
34127 },{"../../../Utils":284,"rxjs":26,"rxjs/operators":224}],371:[function(require,module,exports){
34129 Object.defineProperty(exports, "__esModule", { value: true });
34131 * Enumeration for tag domains.
34134 * @description Defines where lines between two vertices are treated
34137 * Only applicable for polygons. For rectangles lines between
34138 * vertices are always treated as straight in the distorted 2D
34139 * projection and bended in the undistorted 3D space.
34142 (function (TagDomain) {
34144 * Treats lines between two vertices as straight in the
34145 * distorted 2D projection, i.e. on the image. If the image
34146 * is distorted this will result in bended lines when rendered
34147 * in the undistorted 3D space.
34149 TagDomain[TagDomain["TwoDimensional"] = 0] = "TwoDimensional";
34151 * Treats lines as straight in the undistorted 3D space. If the
34152 * image is distorted this will result in bended lines when rendered
34153 * on the distorted 2D projection of the image.
34155 TagDomain[TagDomain["ThreeDimensional"] = 1] = "ThreeDimensional";
34156 })(TagDomain = exports.TagDomain || (exports.TagDomain = {}));
34157 exports.default = TagDomain;
34159 },{}],372:[function(require,module,exports){
34161 Object.defineProperty(exports, "__esModule", { value: true });
34162 var HandlerBase = /** @class */ (function () {
34164 function HandlerBase(component, container, navigator) {
34165 this._component = component;
34166 this._container = container;
34167 this._navigator = navigator;
34168 this._enabled = false;
34170 Object.defineProperty(HandlerBase.prototype, "isEnabled", {
34172 * Returns a Boolean indicating whether the interaction is enabled.
34174 * @returns {boolean} `true` if the interaction is enabled.
34177 return this._enabled;
34183 * Enables the interaction.
34185 * @example ```<component-name>.<handler-name>.enable();```
34187 HandlerBase.prototype.enable = function () {
34188 if (this._enabled || !this._component.activated) {
34192 this._enabled = true;
34193 this._component.configure(this._getConfiguration(true));
34196 * Disables the interaction.
34198 * @example ```<component-name>.<handler-name>.disable();```
34200 HandlerBase.prototype.disable = function () {
34201 if (!this._enabled) {
34205 this._enabled = false;
34206 if (this._component.activated) {
34207 this._component.configure(this._getConfiguration(false));
34210 return HandlerBase;
34212 exports.HandlerBase = HandlerBase;
34213 exports.default = HandlerBase;
34215 },{}],373:[function(require,module,exports){
34217 Object.defineProperty(exports, "__esModule", { value: true });
34218 var THREE = require("three");
34219 var Component_1 = require("../../Component");
34220 var MeshFactory = /** @class */ (function () {
34221 function MeshFactory(imagePlaneDepth, imageSphereRadius) {
34222 this._imagePlaneDepth = imagePlaneDepth != null ? imagePlaneDepth : 200;
34223 this._imageSphereRadius = imageSphereRadius != null ? imageSphereRadius : 200;
34225 MeshFactory.prototype.createMesh = function (node, transform) {
34226 var mesh = node.pano ?
34227 this._createImageSphere(node, transform) :
34228 this._createImagePlane(node, transform);
34231 MeshFactory.prototype.createFlatMesh = function (node, transform, basicX0, basicX1, basicY0, basicY1) {
34232 var texture = this._createTexture(node.image);
34233 var materialParameters = this._createDistortedPlaneMaterialParameters(transform, texture);
34234 var material = new THREE.ShaderMaterial(materialParameters);
34235 var geometry = this._getFlatImagePlaneGeoFromBasic(transform, basicX0, basicX1, basicY0, basicY1);
34236 return new THREE.Mesh(geometry, material);
34238 MeshFactory.prototype.createCurtainMesh = function (node, transform) {
34239 if (node.pano && !node.fullPano) {
34240 throw new Error("Cropped panoramas cannot have curtain.");
34243 this._createSphereCurtainMesh(node, transform) :
34244 this._createCurtainMesh(node, transform);
34246 MeshFactory.prototype.createDistortedCurtainMesh = function (node, transform) {
34248 throw new Error("Cropped panoramas cannot have curtain.");
34250 return this._createDistortedCurtainMesh(node, transform);
34252 MeshFactory.prototype._createCurtainMesh = function (node, transform) {
34253 var texture = this._createTexture(node.image);
34254 var materialParameters = this._createCurtainPlaneMaterialParameters(transform, texture);
34255 var material = new THREE.ShaderMaterial(materialParameters);
34256 var geometry = this._useMesh(transform, node) ?
34257 this._getImagePlaneGeo(transform, node) :
34258 this._getRegularFlatImagePlaneGeo(transform);
34259 return new THREE.Mesh(geometry, material);
34261 MeshFactory.prototype._createDistortedCurtainMesh = function (node, transform) {
34262 var texture = this._createTexture(node.image);
34263 var materialParameters = this._createDistortedCurtainPlaneMaterialParameters(transform, texture);
34264 var material = new THREE.ShaderMaterial(materialParameters);
34265 var geometry = this._getRegularFlatImagePlaneGeo(transform);
34266 return new THREE.Mesh(geometry, material);
34268 MeshFactory.prototype._createSphereCurtainMesh = function (node, transform) {
34269 var texture = this._createTexture(node.image);
34270 var materialParameters = this._createCurtainSphereMaterialParameters(transform, texture);
34271 var material = new THREE.ShaderMaterial(materialParameters);
34272 return this._useMesh(transform, node) ?
34273 new THREE.Mesh(this._getImageSphereGeo(transform, node), material) :
34274 new THREE.Mesh(this._getFlatImageSphereGeo(transform), material);
34276 MeshFactory.prototype._createImageSphere = function (node, transform) {
34277 var texture = this._createTexture(node.image);
34278 var materialParameters = this._createSphereMaterialParameters(transform, texture);
34279 var material = new THREE.ShaderMaterial(materialParameters);
34280 var mesh = this._useMesh(transform, node) ?
34281 new THREE.Mesh(this._getImageSphereGeo(transform, node), material) :
34282 new THREE.Mesh(this._getFlatImageSphereGeo(transform), material);
34285 MeshFactory.prototype._createImagePlane = function (node, transform) {
34286 var texture = this._createTexture(node.image);
34287 var materialParameters = this._createPlaneMaterialParameters(transform, texture);
34288 var material = new THREE.ShaderMaterial(materialParameters);
34289 var geometry = this._useMesh(transform, node) ?
34290 this._getImagePlaneGeo(transform, node) :
34291 this._getRegularFlatImagePlaneGeo(transform);
34292 return new THREE.Mesh(geometry, material);
34294 MeshFactory.prototype._createSphereMaterialParameters = function (transform, texture) {
34295 var gpano = transform.gpano;
34296 var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2;
34297 var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels;
34298 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
34299 var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2;
34300 var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels;
34301 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
34302 var materialParameters = {
34304 fragmentShader: Component_1.Shaders.equirectangular.fragment,
34305 side: THREE.DoubleSide,
34322 value: transform.rt,
34330 value: thetaLength,
34337 vertexShader: Component_1.Shaders.equirectangular.vertex,
34339 return materialParameters;
34341 MeshFactory.prototype._createCurtainSphereMaterialParameters = function (transform, texture) {
34342 var gpano = transform.gpano;
34343 var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2;
34344 var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels;
34345 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
34346 var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2;
34347 var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels;
34348 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
34349 var materialParameters = {
34351 fragmentShader: Component_1.Shaders.equirectangularCurtain.fragment,
34352 side: THREE.DoubleSide,
34373 value: transform.rt,
34381 value: thetaLength,
34388 vertexShader: Component_1.Shaders.equirectangularCurtain.vertex,
34390 return materialParameters;
34392 MeshFactory.prototype._createPlaneMaterialParameters = function (transform, texture) {
34393 var materialParameters = {
34395 fragmentShader: Component_1.Shaders.perspective.fragment,
34396 side: THREE.DoubleSide,
34401 value: transform.focal,
34405 value: transform.ck1,
34409 value: transform.ck2,
34417 value: transform.basicRt,
34425 value: !!transform.radialPeak ? transform.radialPeak : 0,
34429 value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth,
34433 value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight,
34436 vertexShader: Component_1.Shaders.perspective.vertex,
34438 return materialParameters;
34440 MeshFactory.prototype._createCurtainPlaneMaterialParameters = function (transform, texture) {
34441 var materialParameters = {
34443 fragmentShader: Component_1.Shaders.perspectiveCurtain.fragment,
34444 side: THREE.DoubleSide,
34453 value: transform.focal,
34457 value: transform.ck1,
34461 value: transform.ck2,
34469 value: transform.basicRt,
34477 value: !!transform.radialPeak ? transform.radialPeak : 0,
34481 value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth,
34485 value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight,
34488 vertexShader: Component_1.Shaders.perspectiveCurtain.vertex,
34490 return materialParameters;
34492 MeshFactory.prototype._createDistortedCurtainPlaneMaterialParameters = function (transform, texture) {
34493 var materialParameters = {
34495 fragmentShader: Component_1.Shaders.perspectiveDistortedCurtain.fragment,
34496 side: THREE.DoubleSide,
34509 value: transform.projectorMatrix(),
34516 vertexShader: Component_1.Shaders.perspectiveDistortedCurtain.vertex,
34518 return materialParameters;
34520 MeshFactory.prototype._createDistortedPlaneMaterialParameters = function (transform, texture) {
34521 var materialParameters = {
34523 fragmentShader: Component_1.Shaders.perspectiveDistorted.fragment,
34524 side: THREE.DoubleSide,
34533 value: transform.projectorMatrix(),
34540 vertexShader: Component_1.Shaders.perspectiveDistorted.vertex,
34542 return materialParameters;
34544 MeshFactory.prototype._createTexture = function (image) {
34545 var texture = new THREE.Texture(image);
34546 texture.minFilter = THREE.LinearFilter;
34547 texture.needsUpdate = true;
34550 MeshFactory.prototype._useMesh = function (transform, node) {
34551 return node.mesh.vertices.length && transform.hasValidScale;
34553 MeshFactory.prototype._getImageSphereGeo = function (transform, node) {
34554 var t = new THREE.Matrix4().getInverse(transform.srt);
34555 // push everything at least 5 meters in front of the camera
34556 var minZ = 5.0 * transform.scale;
34557 var maxZ = this._imageSphereRadius * transform.scale;
34558 var vertices = node.mesh.vertices;
34559 var numVertices = vertices.length / 3;
34560 var positions = new Float32Array(vertices.length);
34561 for (var i = 0; i < numVertices; ++i) {
34563 var x = vertices[index + 0];
34564 var y = vertices[index + 1];
34565 var z = vertices[index + 2];
34566 var l = Math.sqrt(x * x + y * y + z * z);
34567 var boundedL = Math.max(minZ, Math.min(l, maxZ));
34568 var factor = boundedL / l;
34569 var p = new THREE.Vector3(x * factor, y * factor, z * factor);
34571 positions[index + 0] = p.x;
34572 positions[index + 1] = p.y;
34573 positions[index + 2] = p.z;
34575 var faces = node.mesh.faces;
34576 var indices = new Uint16Array(faces.length);
34577 for (var i = 0; i < faces.length; ++i) {
34578 indices[i] = faces[i];
34580 var geometry = new THREE.BufferGeometry();
34581 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
34582 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
34585 MeshFactory.prototype._getImagePlaneGeo = function (transform, node) {
34586 var undistortionMarginFactor = 3;
34587 var t = new THREE.Matrix4().getInverse(transform.srt);
34588 // push everything at least 5 meters in front of the camera
34589 var minZ = 5.0 * transform.scale;
34590 var maxZ = this._imagePlaneDepth * transform.scale;
34591 var vertices = node.mesh.vertices;
34592 var numVertices = vertices.length / 3;
34593 var positions = new Float32Array(vertices.length);
34594 for (var i = 0; i < numVertices; ++i) {
34596 var x = vertices[index + 0];
34597 var y = vertices[index + 1];
34598 var z = vertices[index + 2];
34600 x *= undistortionMarginFactor;
34601 y *= undistortionMarginFactor;
34603 var boundedZ = Math.max(minZ, Math.min(z, maxZ));
34604 var factor = boundedZ / z;
34605 var p = new THREE.Vector3(x * factor, y * factor, boundedZ);
34607 positions[index + 0] = p.x;
34608 positions[index + 1] = p.y;
34609 positions[index + 2] = p.z;
34611 var faces = node.mesh.faces;
34612 var indices = new Uint16Array(faces.length);
34613 for (var i = 0; i < faces.length; ++i) {
34614 indices[i] = faces[i];
34616 var geometry = new THREE.BufferGeometry();
34617 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
34618 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
34621 MeshFactory.prototype._getFlatImageSphereGeo = function (transform) {
34622 var gpano = transform.gpano;
34623 var phiStart = 2 * Math.PI * gpano.CroppedAreaLeftPixels / gpano.FullPanoWidthPixels;
34624 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
34625 var thetaStart = Math.PI *
34626 (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels - gpano.CroppedAreaTopPixels) /
34627 gpano.FullPanoHeightPixels;
34628 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
34629 var geometry = new THREE.SphereGeometry(this._imageSphereRadius, 20, 40, phiStart - Math.PI / 2, phiLength, thetaStart, thetaLength);
34630 geometry.applyMatrix(new THREE.Matrix4().getInverse(transform.rt));
34633 MeshFactory.prototype._getRegularFlatImagePlaneGeo = function (transform) {
34634 var width = transform.width;
34635 var height = transform.height;
34636 var size = Math.max(width, height);
34637 var dx = width / 2.0 / size;
34638 var dy = height / 2.0 / size;
34639 return this._getFlatImagePlaneGeo(transform, dx, dy);
34641 MeshFactory.prototype._getFlatImagePlaneGeo = function (transform, dx, dy) {
34643 vertices.push(transform.unprojectSfM([-dx, -dy], this._imagePlaneDepth));
34644 vertices.push(transform.unprojectSfM([dx, -dy], this._imagePlaneDepth));
34645 vertices.push(transform.unprojectSfM([dx, dy], this._imagePlaneDepth));
34646 vertices.push(transform.unprojectSfM([-dx, dy], this._imagePlaneDepth));
34647 return this._createFlatGeometry(vertices);
34649 MeshFactory.prototype._getFlatImagePlaneGeoFromBasic = function (transform, basicX0, basicX1, basicY0, basicY1) {
34651 vertices.push(transform.unprojectBasic([basicX0, basicY0], this._imagePlaneDepth));
34652 vertices.push(transform.unprojectBasic([basicX1, basicY0], this._imagePlaneDepth));
34653 vertices.push(transform.unprojectBasic([basicX1, basicY1], this._imagePlaneDepth));
34654 vertices.push(transform.unprojectBasic([basicX0, basicY1], this._imagePlaneDepth));
34655 return this._createFlatGeometry(vertices);
34657 MeshFactory.prototype._createFlatGeometry = function (vertices) {
34658 var positions = new Float32Array(12);
34659 for (var i = 0; i < vertices.length; i++) {
34661 positions[index + 0] = vertices[i][0];
34662 positions[index + 1] = vertices[i][1];
34663 positions[index + 2] = vertices[i][2];
34665 var indices = new Uint16Array(6);
34672 var geometry = new THREE.BufferGeometry();
34673 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
34674 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
34677 return MeshFactory;
34679 exports.MeshFactory = MeshFactory;
34680 exports.default = MeshFactory;
34682 },{"../../Component":274,"three":225}],374:[function(require,module,exports){
34684 Object.defineProperty(exports, "__esModule", { value: true });
34685 var THREE = require("three");
34686 var MeshScene = /** @class */ (function () {
34687 function MeshScene() {
34688 this.scene = new THREE.Scene();
34689 this.sceneOld = new THREE.Scene();
34690 this.imagePlanes = [];
34691 this.imagePlanesOld = [];
34693 MeshScene.prototype.updateImagePlanes = function (planes) {
34694 this._dispose(this.imagePlanesOld, this.sceneOld);
34695 for (var _i = 0, _a = this.imagePlanes; _i < _a.length; _i++) {
34696 var plane = _a[_i];
34697 this.scene.remove(plane);
34698 this.sceneOld.add(plane);
34700 for (var _b = 0, planes_1 = planes; _b < planes_1.length; _b++) {
34701 var plane = planes_1[_b];
34702 this.scene.add(plane);
34704 this.imagePlanesOld = this.imagePlanes;
34705 this.imagePlanes = planes;
34707 MeshScene.prototype.addImagePlanes = function (planes) {
34708 for (var _i = 0, planes_2 = planes; _i < planes_2.length; _i++) {
34709 var plane = planes_2[_i];
34710 this.scene.add(plane);
34711 this.imagePlanes.push(plane);
34714 MeshScene.prototype.addImagePlanesOld = function (planes) {
34715 for (var _i = 0, planes_3 = planes; _i < planes_3.length; _i++) {
34716 var plane = planes_3[_i];
34717 this.sceneOld.add(plane);
34718 this.imagePlanesOld.push(plane);
34721 MeshScene.prototype.setImagePlanes = function (planes) {
34723 this.addImagePlanes(planes);
34725 MeshScene.prototype.setImagePlanesOld = function (planes) {
34727 this.addImagePlanesOld(planes);
34729 MeshScene.prototype.clear = function () {
34733 MeshScene.prototype._clear = function () {
34734 this._dispose(this.imagePlanes, this.scene);
34735 this.imagePlanes.length = 0;
34737 MeshScene.prototype._clearOld = function () {
34738 this._dispose(this.imagePlanesOld, this.sceneOld);
34739 this.imagePlanesOld.length = 0;
34741 MeshScene.prototype._dispose = function (planes, scene) {
34742 for (var _i = 0, planes_4 = planes; _i < planes_4.length; _i++) {
34743 var plane = planes_4[_i];
34744 scene.remove(plane);
34745 plane.geometry.dispose();
34746 plane.material.dispose();
34747 var texture = plane.material.uniforms.projectorTex.value;
34748 if (texture != null) {
34755 exports.MeshScene = MeshScene;
34756 exports.default = MeshScene;
34758 },{"three":225}],375:[function(require,module,exports){
34760 Object.defineProperty(exports, "__esModule", { value: true });
34761 var rxjs_1 = require("rxjs");
34762 var operators_1 = require("rxjs/operators");
34763 var MouseOperator = /** @class */ (function () {
34764 function MouseOperator() {
34766 MouseOperator.filteredPairwiseMouseDrag$ = function (name, mouseService) {
34767 return mouseService
34768 .filtered$(name, mouseService.mouseDragStart$).pipe(operators_1.switchMap(function (mouseDragStart) {
34769 var mouseDragging$ = rxjs_1.concat(rxjs_1.of(mouseDragStart), mouseService
34770 .filtered$(name, mouseService.mouseDrag$));
34771 var mouseDragEnd$ = mouseService
34772 .filtered$(name, mouseService.mouseDragEnd$).pipe(operators_1.map(function () {
34775 return rxjs_1.merge(mouseDragging$, mouseDragEnd$).pipe(operators_1.takeWhile(function (e) {
34777 }), operators_1.startWith(null));
34778 }), operators_1.pairwise(), operators_1.filter(function (pair) {
34779 return pair[0] != null && pair[1] != null;
34782 return MouseOperator;
34784 exports.MouseOperator = MouseOperator;
34785 exports.default = MouseOperator;
34787 },{"rxjs":26,"rxjs/operators":224}],376:[function(require,module,exports){
34789 var __extends = (this && this.__extends) || (function () {
34790 var extendStatics = function (d, b) {
34791 extendStatics = Object.setPrototypeOf ||
34792 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34793 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34794 return extendStatics(d, b);
34796 return function (d, b) {
34797 extendStatics(d, b);
34798 function __() { this.constructor = d; }
34799 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34802 Object.defineProperty(exports, "__esModule", { value: true });
34803 var rxjs_1 = require("rxjs");
34804 var operators_1 = require("rxjs/operators");
34805 var vd = require("virtual-dom");
34806 var Component_1 = require("../../Component");
34807 var Geo_1 = require("../../Geo");
34808 var State_1 = require("../../State");
34809 var ZoomComponent = /** @class */ (function (_super) {
34810 __extends(ZoomComponent, _super);
34811 function ZoomComponent(name, container, navigator) {
34812 var _this = _super.call(this, name, container, navigator) || this;
34813 _this._viewportCoords = new Geo_1.ViewportCoords();
34814 _this._zoomDelta$ = new rxjs_1.Subject();
34817 ZoomComponent.prototype._activate = function () {
34819 this._renderSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentState$, this._navigator.stateService.state$).pipe(operators_1.map(function (_a) {
34820 var frame = _a[0], state = _a[1];
34821 return [frame.state.zoom, state];
34822 }), operators_1.map(function (_a) {
34823 var zoom = _a[0], state = _a[1];
34824 var zoomInIcon = vd.h("div.ZoomInIcon", []);
34825 var zoomInButton = zoom >= 3 || state === State_1.State.Waiting ?
34826 vd.h("div.ZoomInButtonDisabled", [zoomInIcon]) :
34827 vd.h("div.ZoomInButton", { onclick: function () { _this._zoomDelta$.next(1); } }, [zoomInIcon]);
34828 var zoomOutIcon = vd.h("div.ZoomOutIcon", []);
34829 var zoomOutButton = zoom <= 0 || state === State_1.State.Waiting ?
34830 vd.h("div.ZoomOutButtonDisabled", [zoomOutIcon]) :
34831 vd.h("div.ZoomOutButton", { onclick: function () { _this._zoomDelta$.next(-1); } }, [zoomOutIcon]);
34834 vnode: vd.h("div.ZoomContainer", { oncontextmenu: function (event) { event.preventDefault(); } }, [zoomInButton, zoomOutButton]),
34837 .subscribe(this._container.domRenderer.render$);
34838 this._zoomSubscription = this._zoomDelta$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
34839 .subscribe(function (_a) {
34840 var zoomDelta = _a[0], render = _a[1], transform = _a[2];
34841 var unprojected = _this._viewportCoords.unprojectFromViewport(0, 0, render.perspective);
34842 var reference = transform.projectBasic(unprojected.toArray());
34843 _this._navigator.stateService.zoomIn(zoomDelta, reference);
34846 ZoomComponent.prototype._deactivate = function () {
34847 this._renderSubscription.unsubscribe();
34848 this._zoomSubscription.unsubscribe();
34850 ZoomComponent.prototype._getDefaultConfiguration = function () {
34853 ZoomComponent.componentName = "zoom";
34854 return ZoomComponent;
34855 }(Component_1.Component));
34856 exports.ZoomComponent = ZoomComponent;
34857 Component_1.ComponentService.register(ZoomComponent);
34858 exports.default = ZoomComponent;
34860 },{"../../Component":274,"../../Geo":277,"../../State":281,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],377:[function(require,module,exports){
34862 var __extends = (this && this.__extends) || (function () {
34863 var extendStatics = function (d, b) {
34864 extendStatics = Object.setPrototypeOf ||
34865 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34866 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34867 return extendStatics(d, b);
34869 return function (d, b) {
34870 extendStatics(d, b);
34871 function __() { this.constructor = d; }
34872 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34875 Object.defineProperty(exports, "__esModule", { value: true });
34876 var MapillaryError_1 = require("./MapillaryError");
34878 * @class AbortMapillaryError
34880 * @classdesc Error thrown when a move to request has been
34881 * aborted before completing because of a subsequent request.
34883 var AbortMapillaryError = /** @class */ (function (_super) {
34884 __extends(AbortMapillaryError, _super);
34885 function AbortMapillaryError(message) {
34886 var _this = _super.call(this, message != null ? message : "The request was aborted.") || this;
34887 Object.setPrototypeOf(_this, AbortMapillaryError.prototype);
34888 _this.name = "AbortMapillaryError";
34891 return AbortMapillaryError;
34892 }(MapillaryError_1.MapillaryError));
34893 exports.AbortMapillaryError = AbortMapillaryError;
34894 exports.default = AbortMapillaryError;
34896 },{"./MapillaryError":380}],378:[function(require,module,exports){
34898 var __extends = (this && this.__extends) || (function () {
34899 var extendStatics = function (d, b) {
34900 extendStatics = Object.setPrototypeOf ||
34901 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34902 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34903 return extendStatics(d, b);
34905 return function (d, b) {
34906 extendStatics(d, b);
34907 function __() { this.constructor = d; }
34908 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34911 Object.defineProperty(exports, "__esModule", { value: true });
34912 var MapillaryError_1 = require("./MapillaryError");
34913 var ArgumentMapillaryError = /** @class */ (function (_super) {
34914 __extends(ArgumentMapillaryError, _super);
34915 function ArgumentMapillaryError(message) {
34916 var _this = _super.call(this, message != null ? message : "The argument is not valid.") || this;
34917 Object.setPrototypeOf(_this, ArgumentMapillaryError.prototype);
34918 _this.name = "ArgumentMapillaryError";
34921 return ArgumentMapillaryError;
34922 }(MapillaryError_1.MapillaryError));
34923 exports.ArgumentMapillaryError = ArgumentMapillaryError;
34924 exports.default = ArgumentMapillaryError;
34926 },{"./MapillaryError":380}],379:[function(require,module,exports){
34928 var __extends = (this && this.__extends) || (function () {
34929 var extendStatics = function (d, b) {
34930 extendStatics = Object.setPrototypeOf ||
34931 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34932 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34933 return extendStatics(d, b);
34935 return function (d, b) {
34936 extendStatics(d, b);
34937 function __() { this.constructor = d; }
34938 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34941 Object.defineProperty(exports, "__esModule", { value: true });
34942 var MapillaryError_1 = require("./MapillaryError");
34943 var GraphMapillaryError = /** @class */ (function (_super) {
34944 __extends(GraphMapillaryError, _super);
34945 function GraphMapillaryError(message) {
34946 var _this = _super.call(this, message) || this;
34947 Object.setPrototypeOf(_this, GraphMapillaryError.prototype);
34948 _this.name = "GraphMapillaryError";
34951 return GraphMapillaryError;
34952 }(MapillaryError_1.MapillaryError));
34953 exports.GraphMapillaryError = GraphMapillaryError;
34954 exports.default = GraphMapillaryError;
34956 },{"./MapillaryError":380}],380:[function(require,module,exports){
34958 var __extends = (this && this.__extends) || (function () {
34959 var extendStatics = function (d, b) {
34960 extendStatics = Object.setPrototypeOf ||
34961 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34962 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34963 return extendStatics(d, b);
34965 return function (d, b) {
34966 extendStatics(d, b);
34967 function __() { this.constructor = d; }
34968 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34971 Object.defineProperty(exports, "__esModule", { value: true });
34972 var MapillaryError = /** @class */ (function (_super) {
34973 __extends(MapillaryError, _super);
34974 function MapillaryError(message) {
34975 var _this = _super.call(this, message) || this;
34976 Object.setPrototypeOf(_this, MapillaryError.prototype);
34977 _this.name = "MapillaryError";
34980 return MapillaryError;
34982 exports.MapillaryError = MapillaryError;
34983 exports.default = MapillaryError;
34985 },{}],381:[function(require,module,exports){
34987 Object.defineProperty(exports, "__esModule", { value: true });
34988 var THREE = require("three");
34992 * @classdesc Holds information about a camera.
34994 var Camera = /** @class */ (function () {
34996 * Create a new camera instance.
34997 * @param {Transform} [transform] - Optional transform instance.
34999 function Camera(transform) {
35000 if (transform != null) {
35001 this._position = new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0));
35002 this._lookat = new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10));
35003 this._up = transform.upVector();
35004 this._focal = this._getFocal(transform);
35007 this._position = new THREE.Vector3(0, 0, 0);
35008 this._lookat = new THREE.Vector3(0, 0, 1);
35009 this._up = new THREE.Vector3(0, -1, 0);
35013 Object.defineProperty(Camera.prototype, "position", {
35016 * @returns {THREE.Vector3} The position vector.
35019 return this._position;
35024 Object.defineProperty(Camera.prototype, "lookat", {
35027 * @returns {THREE.Vector3} The lookat vector.
35030 return this._lookat;
35035 Object.defineProperty(Camera.prototype, "up", {
35038 * @returns {THREE.Vector3} The up vector.
35046 Object.defineProperty(Camera.prototype, "focal", {
35049 * @returns {number} The focal length.
35052 return this._focal;
35057 set: function (value) {
35058 this._focal = value;
35064 * Update this camera to the linearly interpolated value of two other cameras.
35066 * @param {Camera} a - First camera.
35067 * @param {Camera} b - Second camera.
35068 * @param {number} alpha - Interpolation value on the interval [0, 1].
35070 Camera.prototype.lerpCameras = function (a, b, alpha) {
35071 this._position.subVectors(b.position, a.position).multiplyScalar(alpha).add(a.position);
35072 this._lookat.subVectors(b.lookat, a.lookat).multiplyScalar(alpha).add(a.lookat);
35073 this._up.subVectors(b.up, a.up).multiplyScalar(alpha).add(a.up);
35074 this._focal = (1 - alpha) * a.focal + alpha * b.focal;
35077 * Copy the properties of another camera to this camera.
35079 * @param {Camera} other - Another camera.
35081 Camera.prototype.copy = function (other) {
35082 this._position.copy(other.position);
35083 this._lookat.copy(other.lookat);
35084 this._up.copy(other.up);
35085 this._focal = other.focal;
35088 * Clone this camera.
35090 * @returns {Camera} A camera with cloned properties equal to this camera.
35092 Camera.prototype.clone = function () {
35093 var camera = new Camera();
35094 camera.position.copy(this._position);
35095 camera.lookat.copy(this._lookat);
35096 camera.up.copy(this._up);
35097 camera.focal = this._focal;
35101 * Determine the distance between this camera and another camera.
35103 * @param {Camera} other - Another camera.
35104 * @returns {number} The distance between the cameras.
35106 Camera.prototype.diff = function (other) {
35107 var pd = this._position.distanceToSquared(other.position);
35108 var ld = this._lookat.distanceToSquared(other.lookat);
35109 var ud = this._up.distanceToSquared(other.up);
35110 var fd = 100 * Math.abs(this._focal - other.focal);
35111 return Math.max(pd, ld, ud, fd);
35114 * Get the focal length based on the transform.
35116 * @description Returns the focal length of the transform if gpano info is not available.
35117 * Returns a focal length corresponding to a vertical fov clamped to [45, 90] degrees based on
35118 * the gpano information if available.
35120 * @returns {number} Focal length.
35122 Camera.prototype._getFocal = function (transform) {
35123 if (transform.gpano == null) {
35124 return transform.focal;
35126 var vFov = Math.PI * transform.gpano.CroppedAreaImageHeightPixels / transform.gpano.FullPanoHeightPixels;
35127 var focal = 0.5 / Math.tan(vFov / 2);
35128 return Math.min(1 / (2 * (Math.sqrt(2) - 1)), Math.max(0.5, focal));
35132 exports.Camera = Camera;
35134 },{"three":225}],382:[function(require,module,exports){
35136 Object.defineProperty(exports, "__esModule", { value: true });
35137 var Geo_1 = require("../Geo");
35138 var geoCoords = new Geo_1.GeoCoords();
35139 var spatial = new Geo_1.Spatial();
35140 function computeTranslation(position, rotation, reference) {
35141 var C = geoCoords.geodeticToEnu(position.lat, position.lon, position.alt, reference.lat, reference.lon, reference.alt);
35142 var RC = spatial.rotate(C, rotation);
35143 var translation = [-RC.x, -RC.y, -RC.z];
35144 return translation;
35146 exports.computeTranslation = computeTranslation;
35148 },{"../Geo":277}],383:[function(require,module,exports){
35150 Object.defineProperty(exports, "__esModule", { value: true });
35154 * @classdesc Converts coordinates between the geodetic (WGS84),
35155 * Earth-Centered, Earth-Fixed (ECEF) and local topocentric
35156 * East, North, Up (ENU) reference frames.
35158 * The WGS84 has latitude (degrees), longitude (degrees) and
35159 * altitude (meters) values.
35161 * The ECEF Z-axis pierces the north pole and the
35162 * XY-axis defines the equatorial plane. The X-axis extends
35163 * from the geocenter to the intersection of the Equator and
35164 * the Greenwich Meridian. All values in meters.
35166 * The WGS84 parameters are:
35170 * f = 1 / 298.257223563
35171 * e = Math.sqrt((a^2 - b^2) / a^2)
35172 * e' = Math.sqrt((a^2 - b^2) / b^2)
35174 * The WGS84 to ECEF conversion is performed using the following:
35176 * X = (N - h) * cos(phi) * cos(lambda)
35177 * Y = (N + h) * cos(phi) * sin(lambda)
35178 * Z = (b^2 * N / a^2 + h) * sin(phi)
35183 * lambda = longitude
35184 * h = height above ellipsoid (altitude)
35185 * N = Radius of curvature (meters)
35186 * = a / Math.sqrt(1 - e^2 * sin(phi)^2)
35188 * The ECEF to WGS84 conversion is performed using the following:
35190 * phi = arctan((Z + e'^2 * b * sin(theta)^3) / (p - e^2 * a * cos(theta)^3))
35191 * lambda = arctan(Y / X)
35192 * h = p / cos(phi) - N
35196 * p = Math.sqrt(X^2 + Y^2)
35197 * theta = arctan(Z * a / p * b)
35199 * In the ENU reference frame the x-axis points to the
35200 * East, the y-axis to the North and the z-axis Up. All values
35203 * The ECEF to ENU conversion is performed using the following:
35205 * | x | | -sin(lambda_r) cos(lambda_r) 0 | | X - X_r |
35206 * | y | = | -sin(phi_r) * cos(lambda_r) -sin(phi_r) * sin(lambda_r) cos(phi_r) | | Y - Y_r |
35207 * | z | | cos(phi_r) * cos(lambda_r) cos(phi_r) * sin(lambda_r) sin(phi_r) | | Z - Z_r |
35211 * phi_r = latitude of reference
35212 * lambda_r = longitude of reference
35213 * X_r, Y_r, Z_r = ECEF coordinates of reference
35215 * The ENU to ECEF conversion is performed by solving the above equation for X, Y, Z.
35217 * WGS84 to ENU and ENU to WGS84 are two step conversions with ECEF calculated in
35218 * the first step for both conversions.
35220 var GeoCoords = /** @class */ (function () {
35221 function GeoCoords() {
35222 this._wgs84a = 6378137.0;
35223 this._wgs84b = 6356752.31424518;
35226 * Convert coordinates from geodetic (WGS84) reference to local topocentric
35229 * @param {number} lat Latitude in degrees.
35230 * @param {number} lon Longitude in degrees.
35231 * @param {number} alt Altitude in meters.
35232 * @param {number} refLat Reference latitude in degrees.
35233 * @param {number} refLon Reference longitude in degrees.
35234 * @param {number} refAlt Reference altitude in meters.
35235 * @returns {Array<number>} The x, y, z local topocentric ENU coordinates.
35237 GeoCoords.prototype.geodeticToEnu = function (lat, lon, alt, refLat, refLon, refAlt) {
35238 var ecef = this.geodeticToEcef(lat, lon, alt);
35239 return this.ecefToEnu(ecef[0], ecef[1], ecef[2], refLat, refLon, refAlt);
35242 * Convert coordinates from local topocentric (ENU) reference to
35243 * geodetic (WGS84) reference.
35245 * @param {number} x Topocentric ENU coordinate in East direction.
35246 * @param {number} y Topocentric ENU coordinate in North direction.
35247 * @param {number} z Topocentric ENU coordinate in Up direction.
35248 * @param {number} refLat Reference latitude in degrees.
35249 * @param {number} refLon Reference longitude in degrees.
35250 * @param {number} refAlt Reference altitude in meters.
35251 * @returns {Array<number>} The latitude and longitude in degrees
35252 * as well as altitude in meters.
35254 GeoCoords.prototype.enuToGeodetic = function (x, y, z, refLat, refLon, refAlt) {
35255 var ecef = this.enuToEcef(x, y, z, refLat, refLon, refAlt);
35256 return this.ecefToGeodetic(ecef[0], ecef[1], ecef[2]);
35259 * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference
35260 * to local topocentric (ENU) reference.
35262 * @param {number} X ECEF X-value.
35263 * @param {number} Y ECEF Y-value.
35264 * @param {number} Z ECEF Z-value.
35265 * @param {number} refLat Reference latitude in degrees.
35266 * @param {number} refLon Reference longitude in degrees.
35267 * @param {number} refAlt Reference altitude in meters.
35268 * @returns {Array<number>} The x, y, z topocentric ENU coordinates in East, North
35269 * and Up directions respectively.
35271 GeoCoords.prototype.ecefToEnu = function (X, Y, Z, refLat, refLon, refAlt) {
35272 var refEcef = this.geodeticToEcef(refLat, refLon, refAlt);
35273 var V = [X - refEcef[0], Y - refEcef[1], Z - refEcef[2]];
35274 refLat = refLat * Math.PI / 180.0;
35275 refLon = refLon * Math.PI / 180.0;
35276 var cosLat = Math.cos(refLat);
35277 var sinLat = Math.sin(refLat);
35278 var cosLon = Math.cos(refLon);
35279 var sinLon = Math.sin(refLon);
35280 var x = -sinLon * V[0] + cosLon * V[1];
35281 var y = -sinLat * cosLon * V[0] - sinLat * sinLon * V[1] + cosLat * V[2];
35282 var z = cosLat * cosLon * V[0] + cosLat * sinLon * V[1] + sinLat * V[2];
35286 * Convert coordinates from local topocentric (ENU) reference
35287 * to Earth-Centered, Earth-Fixed (ECEF) reference.
35289 * @param {number} x Topocentric ENU coordinate in East direction.
35290 * @param {number} y Topocentric ENU coordinate in North direction.
35291 * @param {number} z Topocentric ENU coordinate in Up direction.
35292 * @param {number} refLat Reference latitude in degrees.
35293 * @param {number} refLon Reference longitude in degrees.
35294 * @param {number} refAlt Reference altitude in meters.
35295 * @returns {Array<number>} The X, Y, Z ECEF coordinates.
35297 GeoCoords.prototype.enuToEcef = function (x, y, z, refLat, refLon, refAlt) {
35298 var refEcef = this.geodeticToEcef(refLat, refLon, refAlt);
35299 refLat = refLat * Math.PI / 180.0;
35300 refLon = refLon * Math.PI / 180.0;
35301 var cosLat = Math.cos(refLat);
35302 var sinLat = Math.sin(refLat);
35303 var cosLon = Math.cos(refLon);
35304 var sinLon = Math.sin(refLon);
35305 var X = -sinLon * x - sinLat * cosLon * y + cosLat * cosLon * z + refEcef[0];
35306 var Y = cosLon * x - sinLat * sinLon * y + cosLat * sinLon * z + refEcef[1];
35307 var Z = cosLat * y + sinLat * z + refEcef[2];
35311 * Convert coordinates from geodetic reference (WGS84) to Earth-Centered,
35312 * Earth-Fixed (ECEF) reference.
35314 * @param {number} lat Latitude in degrees.
35315 * @param {number} lon Longitude in degrees.
35316 * @param {number} alt Altitude in meters.
35317 * @returns {Array<number>} The X, Y, Z ECEF coordinates.
35319 GeoCoords.prototype.geodeticToEcef = function (lat, lon, alt) {
35320 var a = this._wgs84a;
35321 var b = this._wgs84b;
35322 lat = lat * Math.PI / 180.0;
35323 lon = lon * Math.PI / 180.0;
35324 var cosLat = Math.cos(lat);
35325 var sinLat = Math.sin(lat);
35326 var cosLon = Math.cos(lon);
35327 var sinLon = Math.sin(lon);
35330 var L = 1.0 / Math.sqrt(a2 * cosLat * cosLat + b2 * sinLat * sinLat);
35331 var nhcl = (a2 * L + alt) * cosLat;
35332 var X = nhcl * cosLon;
35333 var Y = nhcl * sinLon;
35334 var Z = (b2 * L + alt) * sinLat;
35338 * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference
35339 * to geodetic reference (WGS84).
35341 * @param {number} X ECEF X-value.
35342 * @param {number} Y ECEF Y-value.
35343 * @param {number} Z ECEF Z-value.
35344 * @returns {Array<number>} The latitude and longitude in degrees
35345 * as well as altitude in meters.
35347 GeoCoords.prototype.ecefToGeodetic = function (X, Y, Z) {
35348 var a = this._wgs84a;
35349 var b = this._wgs84b;
35352 var a2mb2 = a2 - b2;
35353 var ea = Math.sqrt(a2mb2 / a2);
35354 var eb = Math.sqrt(a2mb2 / b2);
35355 var p = Math.sqrt(X * X + Y * Y);
35356 var theta = Math.atan2(Z * a, p * b);
35357 var sinTheta = Math.sin(theta);
35358 var cosTheta = Math.cos(theta);
35359 var lon = Math.atan2(Y, X);
35360 var lat = Math.atan2(Z + eb * eb * b * sinTheta * sinTheta * sinTheta, p - ea * ea * a * cosTheta * cosTheta * cosTheta);
35361 var sinLat = Math.sin(lat);
35362 var cosLat = Math.cos(lat);
35363 var N = a / Math.sqrt(1 - ea * ea * sinLat * sinLat);
35364 var alt = p / cosLat - N;
35365 return [lat * 180.0 / Math.PI, lon * 180.0 / Math.PI, alt];
35369 exports.GeoCoords = GeoCoords;
35370 exports.default = GeoCoords;
35372 },{}],384:[function(require,module,exports){
35374 Object.defineProperty(exports, "__esModule", { value: true });
35376 return n > 0 ? 1 : n < 0 ? -1 : 0;
35378 function colinearPointOnSegment(p, s) {
35379 return p.x <= Math.max(s.p1.x, s.p2.x) &&
35380 p.x >= Math.min(s.p1.x, s.p2.x) &&
35381 p.y >= Math.max(s.p1.y, s.p2.y) &&
35382 p.y >= Math.min(s.p1.y, s.p2.y);
35384 function parallel(s1, s2) {
35385 var ux = s1.p2.x - s1.p1.x;
35386 var uy = s1.p2.y - s1.p1.y;
35387 var vx = s2.p2.x - s2.p1.x;
35388 var vy = s2.p2.y - s2.p1.y;
35389 var cross = ux * vy - uy * vx;
35390 var u2 = ux * ux + uy * uy;
35391 var v2 = vx * vx + vy * vy;
35392 var epsilon2 = 1e-10;
35393 return cross * cross < epsilon2 * u2 * v2;
35395 function tripletOrientation(p1, p2, p3) {
35396 var orientation = (p2.y - p1.y) * (p3.x - p2.x) -
35397 (p3.y - p2.y) * (p2.x - p1.x);
35398 return sign(orientation);
35400 function segmentsIntersect(s1, s2) {
35401 if (parallel(s1, s2)) {
35404 var o1 = tripletOrientation(s1.p1, s1.p2, s2.p1);
35405 var o2 = tripletOrientation(s1.p1, s1.p2, s2.p2);
35406 var o3 = tripletOrientation(s2.p1, s2.p2, s1.p1);
35407 var o4 = tripletOrientation(s2.p1, s2.p2, s1.p2);
35408 if (o1 !== o2 && o3 !== o4) {
35411 if (o1 === 0 && colinearPointOnSegment(s2.p1, s1)) {
35414 if (o2 === 0 && colinearPointOnSegment(s2.p2, s1)) {
35417 if (o3 === 0 && colinearPointOnSegment(s1.p1, s2)) {
35420 if (o4 === 0 && colinearPointOnSegment(s1.p2, s2)) {
35425 exports.segmentsIntersect = segmentsIntersect;
35426 function segmentIntersection(s1, s2) {
35427 if (parallel(s1, s2)) {
35438 var den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
35439 var xNum = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
35440 var yNum = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
35441 return { x: xNum / den, y: yNum / den };
35443 exports.segmentIntersection = segmentIntersection;
35445 },{}],385:[function(require,module,exports){
35447 Object.defineProperty(exports, "__esModule", { value: true });
35448 var THREE = require("three");
35452 * @classdesc Provides methods for scalar, vector and matrix calculations.
35454 var Spatial = /** @class */ (function () {
35455 function Spatial() {
35456 this._epsilon = 1e-9;
35459 * Converts azimuthal phi rotation (counter-clockwise with origin on X-axis) to
35460 * bearing (clockwise with origin at north or Y-axis).
35462 * @param {number} phi - Azimuthal phi angle in radians.
35463 * @returns {number} Bearing in radians.
35465 Spatial.prototype.azimuthalToBearing = function (phi) {
35466 return -phi + Math.PI / 2;
35469 * Converts degrees to radians.
35471 * @param {number} deg - Degrees.
35472 * @returns {number} Radians.
35474 Spatial.prototype.degToRad = function (deg) {
35475 return Math.PI * deg / 180;
35478 * Converts radians to degrees.
35480 * @param {number} rad - Radians.
35481 * @returns {number} Degrees.
35483 Spatial.prototype.radToDeg = function (rad) {
35484 return 180 * rad / Math.PI;
35487 * Creates a rotation matrix from an angle-axis vector.
35489 * @param {Array<number>} angleAxis - Angle-axis representation of a rotation.
35490 * @returns {THREE.Matrix4} Rotation matrix.
35492 Spatial.prototype.rotationMatrix = function (angleAxis) {
35493 var axis = new THREE.Vector3(angleAxis[0], angleAxis[1], angleAxis[2]);
35494 var angle = axis.length();
35498 return new THREE.Matrix4().makeRotationAxis(axis, angle);
35501 * Rotates a vector according to a angle-axis rotation vector.
35503 * @param {Array<number>} vector - Vector to rotate.
35504 * @param {Array<number>} angleAxis - Angle-axis representation of a rotation.
35505 * @returns {THREE.Vector3} Rotated vector.
35507 Spatial.prototype.rotate = function (vector, angleAxis) {
35508 var v = new THREE.Vector3(vector[0], vector[1], vector[2]);
35509 var rotationMatrix = this.rotationMatrix(angleAxis);
35510 v.applyMatrix4(rotationMatrix);
35514 * Calculates the optical center from a rotation vector
35515 * on the angle-axis representation and a translation vector
35516 * according to C = -R^T t.
35518 * @param {Array<number>} rotation - Angle-axis representation of a rotation.
35519 * @param {Array<number>} translation - Translation vector.
35520 * @returns {THREE.Vector3} Optical center.
35522 Spatial.prototype.opticalCenter = function (rotation, translation) {
35523 var angleAxis = [-rotation[0], -rotation[1], -rotation[2]];
35524 var vector = [-translation[0], -translation[1], -translation[2]];
35525 return this.rotate(vector, angleAxis);
35528 * Calculates the viewing direction from a rotation vector
35529 * on the angle-axis representation.
35531 * @param {number[]} rotation - Angle-axis representation of a rotation.
35532 * @returns {THREE.Vector3} Viewing direction.
35534 Spatial.prototype.viewingDirection = function (rotation) {
35535 var angleAxis = [-rotation[0], -rotation[1], -rotation[2]];
35536 return this.rotate([0, 0, 1], angleAxis);
35539 * Wrap a number on the interval [min, max].
35541 * @param {number} value - Value to wrap.
35542 * @param {number} min - Lower endpoint of interval.
35543 * @param {number} max - Upper endpoint of interval.
35544 * @returns {number} The wrapped number.
35546 Spatial.prototype.wrap = function (value, min, max) {
35548 throw new Error("Invalid arguments: max must be larger than min.");
35550 var interval = (max - min);
35551 while (value > max || value < min) {
35553 value = value - interval;
35555 else if (value < min) {
35556 value = value + interval;
35562 * Wrap an angle on the interval [-Pi, Pi].
35564 * @param {number} angle - Value to wrap.
35565 * @returns {number} Wrapped angle.
35567 Spatial.prototype.wrapAngle = function (angle) {
35568 return this.wrap(angle, -Math.PI, Math.PI);
35571 * Limit the value to the interval [min, max] by changing the value to
35572 * the nearest available one when it is outside the interval.
35574 * @param {number} value - Value to clamp.
35575 * @param {number} min - Minimum of the interval.
35576 * @param {number} max - Maximum of the interval.
35577 * @returns {number} Clamped value.
35579 Spatial.prototype.clamp = function (value, min, max) {
35589 * Calculates the counter-clockwise angle from the first
35590 * vector (x1, y1)^T to the second (x2, y2)^T.
35592 * @param {number} x1 - X coordinate of first vector.
35593 * @param {number} y1 - Y coordinate of first vector.
35594 * @param {number} x2 - X coordinate of second vector.
35595 * @param {number} y2 - Y coordinate of second vector.
35596 * @returns {number} Counter clockwise angle between the vectors.
35598 Spatial.prototype.angleBetweenVector2 = function (x1, y1, x2, y2) {
35599 var angle = Math.atan2(y2, x2) - Math.atan2(y1, x1);
35600 return this.wrapAngle(angle);
35603 * Calculates the minimum (absolute) angle change for rotation
35604 * from one angle to another on the [-Pi, Pi] interval.
35606 * @param {number} angle1 - Start angle.
35607 * @param {number} angle2 - Destination angle.
35608 * @returns {number} Absolute angle change between angles.
35610 Spatial.prototype.angleDifference = function (angle1, angle2) {
35611 var angle = angle2 - angle1;
35612 return this.wrapAngle(angle);
35615 * Calculates the relative rotation angle between two
35616 * angle-axis vectors.
35618 * @param {number} rotation1 - First angle-axis vector.
35619 * @param {number} rotation2 - Second angle-axis vector.
35620 * @returns {number} Relative rotation angle.
35622 Spatial.prototype.relativeRotationAngle = function (rotation1, rotation2) {
35623 var R1T = this.rotationMatrix([-rotation1[0], -rotation1[1], -rotation1[2]]);
35624 var R2 = this.rotationMatrix(rotation2);
35625 var R = R1T.multiply(R2);
35626 var elements = R.elements;
35627 // from Tr(R) = 1 + 2 * cos(theta)
35628 var tr = elements[0] + elements[5] + elements[10];
35629 var theta = Math.acos(Math.max(Math.min((tr - 1) / 2, 1), -1));
35633 * Calculates the angle from a vector to a plane.
35635 * @param {Array<number>} vector - The vector.
35636 * @param {Array<number>} planeNormal - Normal of the plane.
35637 * @returns {number} Angle from between plane and vector.
35639 Spatial.prototype.angleToPlane = function (vector, planeNormal) {
35640 var v = new THREE.Vector3().fromArray(vector);
35641 var norm = v.length();
35642 if (norm < this._epsilon) {
35645 var projection = v.dot(new THREE.Vector3().fromArray(planeNormal));
35646 return Math.asin(projection / norm);
35649 * Calculates the distance between two coordinates
35650 * (latitude longitude pairs) in meters according to
35651 * the haversine formula.
35653 * @param {number} lat1 - Latitude of the first coordinate in degrees.
35654 * @param {number} lon1 - Longitude of the first coordinate in degrees.
35655 * @param {number} lat2 - Latitude of the second coordinate in degrees.
35656 * @param {number} lon2 - Longitude of the second coordinate in degrees.
35657 * @returns {number} Distance between lat lon positions in meters.
35659 Spatial.prototype.distanceFromLatLon = function (lat1, lon1, lat2, lon2) {
35661 var dLat = this.degToRad(lat2 - lat1);
35662 var dLon = this.degToRad(lon2 - lon1);
35663 var hav = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
35664 Math.cos(this.degToRad(lat1)) * Math.cos(this.degToRad(lat2)) *
35665 Math.sin(dLon / 2) * Math.sin(dLon / 2);
35666 var d = 2 * r * Math.atan2(Math.sqrt(hav), Math.sqrt(1 - hav));
35671 exports.Spatial = Spatial;
35672 exports.default = Spatial;
35674 },{"three":225}],386:[function(require,module,exports){
35676 Object.defineProperty(exports, "__esModule", { value: true });
35677 var THREE = require("three");
35681 * @classdesc Class used for calculating coordinate transformations
35684 var Transform = /** @class */ (function () {
35686 * Create a new transform instance.
35687 * @param {number} orientation - Image orientation.
35688 * @param {number} width - Image height.
35689 * @param {number} height - Image width.
35690 * @param {number} focal - Focal length.
35691 * @param {number} scale - Atomic scale.
35692 * @param {IGPano} gpano - Panorama properties.
35693 * @param {Array<number>} rotation - Rotation vector in three dimensions.
35694 * @param {Array<number>} translation - Translation vector in three dimensions.
35695 * @param {HTMLImageElement} image - Image for fallback size calculations.
35697 function Transform(orientation, width, height, focal, scale, gpano, rotation, translation, image, textureScale, ck1, ck2) {
35698 this._orientation = this._getValue(orientation, 1);
35699 var imageWidth = image != null ? image.width : 4;
35700 var imageHeight = image != null ? image.height : 3;
35701 var keepOrientation = this._orientation < 5;
35702 this._width = this._getValue(width, keepOrientation ? imageWidth : imageHeight);
35703 this._height = this._getValue(height, keepOrientation ? imageHeight : imageWidth);
35704 this._basicAspect = keepOrientation ?
35705 this._width / this._height :
35706 this._height / this._width;
35707 this._basicWidth = keepOrientation ? width : height;
35708 this._basicHeight = keepOrientation ? height : width;
35709 this._focal = this._getValue(focal, 1);
35710 this._scale = this._getValue(scale, 0);
35711 this._gpano = gpano != null ? gpano : null;
35712 this._rt = this._getRt(rotation, translation);
35713 this._srt = this._getSrt(this._rt, this._scale);
35714 this._basicRt = this._getBasicRt(this._rt, orientation);
35715 this._textureScale = !!textureScale ? textureScale : [1, 1];
35716 this._ck1 = !!ck1 ? ck1 : 0;
35717 this._ck2 = !!ck2 ? ck2 : 0;
35718 this._radialPeak = this._getRadialPeak(this._ck1, this._ck2);
35720 Object.defineProperty(Transform.prototype, "ck1", {
35727 Object.defineProperty(Transform.prototype, "ck2", {
35734 Object.defineProperty(Transform.prototype, "basicAspect", {
35736 * Get basic aspect.
35737 * @returns {number} The orientation adjusted aspect ratio.
35740 return this._basicAspect;
35745 Object.defineProperty(Transform.prototype, "basicHeight", {
35747 * Get basic height.
35749 * @description Does not fall back to node image height but
35750 * uses original value from API so can be faulty.
35752 * @returns {number} The height of the basic version image
35753 * (adjusted for orientation).
35756 return this._basicHeight;
35761 Object.defineProperty(Transform.prototype, "basicRt", {
35763 return this._basicRt;
35768 Object.defineProperty(Transform.prototype, "basicWidth", {
35772 * @description Does not fall back to node image width but
35773 * uses original value from API so can be faulty.
35775 * @returns {number} The width of the basic version image
35776 * (adjusted for orientation).
35779 return this._basicWidth;
35784 Object.defineProperty(Transform.prototype, "focal", {
35787 * @returns {number} The node focal length.
35790 return this._focal;
35795 Object.defineProperty(Transform.prototype, "fullPano", {
35799 * @returns {boolean} Value indicating whether the node is a complete
35803 return this._gpano != null &&
35804 this._gpano.CroppedAreaLeftPixels === 0 &&
35805 this._gpano.CroppedAreaTopPixels === 0 &&
35806 this._gpano.CroppedAreaImageWidthPixels === this._gpano.FullPanoWidthPixels &&
35807 this._gpano.CroppedAreaImageHeightPixels === this._gpano.FullPanoHeightPixels;
35812 Object.defineProperty(Transform.prototype, "gpano", {
35815 * @returns {number} The node gpano information.
35818 return this._gpano;
35823 Object.defineProperty(Transform.prototype, "height", {
35827 * @description Falls back to the node image height if
35828 * the API data is faulty.
35830 * @returns {number} The orientation adjusted image height.
35833 return this._height;
35838 Object.defineProperty(Transform.prototype, "orientation", {
35841 * @returns {number} The image orientation.
35844 return this._orientation;
35849 Object.defineProperty(Transform.prototype, "rt", {
35852 * @returns {THREE.Matrix4} The extrinsic camera matrix.
35860 Object.defineProperty(Transform.prototype, "srt", {
35863 * @returns {THREE.Matrix4} The scaled extrinsic camera matrix.
35871 Object.defineProperty(Transform.prototype, "scale", {
35874 * @returns {number} The node atomic reconstruction scale.
35877 return this._scale;
35882 Object.defineProperty(Transform.prototype, "hasValidScale", {
35884 * Get has valid scale.
35885 * @returns {boolean} Value indicating if the scale of the transform is valid.
35888 return this._scale > 1e-2 && this._scale < 50;
35893 Object.defineProperty(Transform.prototype, "radialPeak", {
35896 * @returns {number} Value indicating the radius where the radial
35897 * undistortion function peaks.
35900 return this._radialPeak;
35905 Object.defineProperty(Transform.prototype, "width", {
35909 * @description Falls back to the node image width if
35910 * the API data is faulty.
35912 * @returns {number} The orientation adjusted image width.
35915 return this._width;
35921 * Calculate the up vector for the node transform.
35923 * @returns {THREE.Vector3} Normalized and orientation adjusted up vector.
35925 Transform.prototype.upVector = function () {
35926 var rte = this._rt.elements;
35927 switch (this._orientation) {
35929 return new THREE.Vector3(-rte[1], -rte[5], -rte[9]);
35931 return new THREE.Vector3(rte[1], rte[5], rte[9]);
35933 return new THREE.Vector3(-rte[0], -rte[4], -rte[8]);
35935 return new THREE.Vector3(rte[0], rte[4], rte[8]);
35937 return new THREE.Vector3(-rte[1], -rte[5], -rte[9]);
35941 * Calculate projector matrix for projecting 3D points to texture map
35942 * coordinates (u and v).
35944 * @returns {THREE.Matrix4} Projection matrix for 3D point to texture
35945 * map coordinate calculations.
35947 Transform.prototype.projectorMatrix = function () {
35948 var projector = this._normalizedToTextureMatrix();
35949 var f = this._focal;
35950 var projection = new THREE.Matrix4().set(f, 0, 0, 0, 0, f, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0);
35951 projector.multiply(projection);
35952 projector.multiply(this._rt);
35956 * Project 3D world coordinates to basic coordinates.
35958 * @param {Array<number>} point3d - 3D world coordinates.
35959 * @return {Array<number>} 2D basic coordinates.
35961 Transform.prototype.projectBasic = function (point3d) {
35962 var sfm = this.projectSfM(point3d);
35963 return this._sfmToBasic(sfm);
35966 * Unproject basic coordinates to 3D world coordinates.
35968 * @param {Array<number>} basic - 2D basic coordinates.
35969 * @param {Array<number>} distance - Distance to unproject from camera center.
35970 * @param {boolean} [depth] - Treat the distance value as depth from camera center.
35971 * Only applicable for perspective images. Will be
35972 * ignored for panoramas.
35973 * @returns {Array<number>} Unprojected 3D world coordinates.
35975 Transform.prototype.unprojectBasic = function (basic, distance, depth) {
35976 var sfm = this._basicToSfm(basic);
35977 return this.unprojectSfM(sfm, distance, depth);
35980 * Project 3D world coordinates to SfM coordinates.
35982 * @param {Array<number>} point3d - 3D world coordinates.
35983 * @return {Array<number>} 2D SfM coordinates.
35985 Transform.prototype.projectSfM = function (point3d) {
35986 var v = new THREE.Vector4(point3d[0], point3d[1], point3d[2], 1);
35987 v.applyMatrix4(this._rt);
35988 return this._bearingToSfm([v.x, v.y, v.z]);
35991 * Unproject SfM coordinates to a 3D world coordinates.
35993 * @param {Array<number>} sfm - 2D SfM coordinates.
35994 * @param {Array<number>} distance - Distance to unproject from camera center.
35995 * @param {boolean} [depth] - Treat the distance value as depth from camera center.
35996 * Only applicable for perspective images. Will be
35997 * ignored for panoramas.
35998 * @returns {Array<number>} Unprojected 3D world coordinates.
36000 Transform.prototype.unprojectSfM = function (sfm, distance, depth) {
36001 var bearing = this._sfmToBearing(sfm);
36002 var v = depth && !this.gpano ?
36003 new THREE.Vector4(distance * bearing[0] / bearing[2], distance * bearing[1] / bearing[2], distance, 1) :
36004 new THREE.Vector4(distance * bearing[0], distance * bearing[1], distance * bearing[2], 1);
36005 v.applyMatrix4(new THREE.Matrix4().getInverse(this._rt));
36006 return [v.x / v.w, v.y / v.w, v.z / v.w];
36009 * Transform SfM coordinates to bearing vector (3D cartesian
36010 * coordinates on the unit sphere).
36012 * @param {Array<number>} sfm - 2D SfM coordinates.
36013 * @returns {Array<number>} Bearing vector (3D cartesian coordinates
36014 * on the unit sphere).
36016 Transform.prototype._sfmToBearing = function (sfm) {
36017 if (this._fullPano()) {
36018 var lon = sfm[0] * 2 * Math.PI;
36019 var lat = -sfm[1] * 2 * Math.PI;
36020 var x = Math.cos(lat) * Math.sin(lon);
36021 var y = -Math.sin(lat);
36022 var z = Math.cos(lat) * Math.cos(lon);
36025 else if (this._gpano) {
36026 var size = Math.max(this.gpano.CroppedAreaImageWidthPixels, this.gpano.CroppedAreaImageHeightPixels);
36027 var fullPanoPixel = [
36028 sfm[0] * size + this.gpano.CroppedAreaImageWidthPixels / 2 + this.gpano.CroppedAreaLeftPixels,
36029 sfm[1] * size + this.gpano.CroppedAreaImageHeightPixels / 2 + this.gpano.CroppedAreaTopPixels,
36031 var lon = 2 * Math.PI * (fullPanoPixel[0] / this.gpano.FullPanoWidthPixels - 0.5);
36032 var lat = -Math.PI * (fullPanoPixel[1] / this.gpano.FullPanoHeightPixels - 0.5);
36033 var x = Math.cos(lat) * Math.sin(lon);
36034 var y = -Math.sin(lat);
36035 var z = Math.cos(lat) * Math.cos(lon);
36039 var _a = [sfm[0] / this._focal, sfm[1] / this._focal], dxn = _a[0], dyn = _a[1];
36040 var rp = this._radialPeak;
36041 var dr = Math.sqrt(dxn * dxn + dyn * dyn);
36043 for (var i = 0; i < 10; i++) {
36048 d = 1 + this._ck1 * Math.pow(r, 2) + this._ck2 * Math.pow(r, 4);
36052 var v = new THREE.Vector3(xn, yn, 1);
36054 return [v.x, v.y, v.z];
36058 * Transform bearing vector (3D cartesian coordiantes on the unit sphere) to
36061 * @param {Array<number>} bearing - Bearing vector (3D cartesian coordinates on the
36063 * @returns {Array<number>} 2D SfM coordinates.
36065 Transform.prototype._bearingToSfm = function (bearing) {
36066 if (this._fullPano()) {
36067 var x = bearing[0];
36068 var y = bearing[1];
36069 var z = bearing[2];
36070 var lon = Math.atan2(x, z);
36071 var lat = Math.atan2(-y, Math.sqrt(x * x + z * z));
36072 return [lon / (2 * Math.PI), -lat / (2 * Math.PI)];
36074 else if (this._gpano) {
36075 var x = bearing[0];
36076 var y = bearing[1];
36077 var z = bearing[2];
36078 var lon = Math.atan2(x, z);
36079 var lat = Math.atan2(-y, Math.sqrt(x * x + z * z));
36080 var fullPanoPixel = [
36081 (lon / (2 * Math.PI) + 0.5) * this.gpano.FullPanoWidthPixels,
36082 (-lat / Math.PI + 0.5) * this.gpano.FullPanoHeightPixels,
36084 var size = Math.max(this.gpano.CroppedAreaImageWidthPixels, this.gpano.CroppedAreaImageHeightPixels);
36086 (fullPanoPixel[0] - this.gpano.CroppedAreaLeftPixels - this.gpano.CroppedAreaImageWidthPixels / 2) / size,
36087 (fullPanoPixel[1] - this.gpano.CroppedAreaTopPixels - this.gpano.CroppedAreaImageHeightPixels / 2) / size,
36091 if (bearing[2] > 0) {
36092 var _a = [bearing[0] / bearing[2], bearing[1] / bearing[2]], xn = _a[0], yn = _a[1];
36093 var r2 = xn * xn + yn * yn;
36094 var rp2 = Math.pow(this._radialPeak, 2);
36098 var d = 1 + this._ck1 * r2 + this._ck2 * Math.pow(r2, 2);
36100 this._focal * d * xn,
36101 this._focal * d * yn,
36106 bearing[0] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
36107 bearing[1] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
36113 * Convert basic coordinates to SfM coordinates.
36115 * @param {Array<number>} basic - 2D basic coordinates.
36116 * @returns {Array<number>} 2D SfM coordinates.
36118 Transform.prototype._basicToSfm = function (basic) {
36121 switch (this._orientation) {
36123 rotatedX = basic[0];
36124 rotatedY = basic[1];
36127 rotatedX = 1 - basic[0];
36128 rotatedY = 1 - basic[1];
36131 rotatedX = basic[1];
36132 rotatedY = 1 - basic[0];
36135 rotatedX = 1 - basic[1];
36136 rotatedY = basic[0];
36139 rotatedX = basic[0];
36140 rotatedY = basic[1];
36143 var w = this._width;
36144 var h = this._height;
36145 var s = Math.max(w, h);
36146 var sfmX = rotatedX * w / s - w / s / 2;
36147 var sfmY = rotatedY * h / s - h / s / 2;
36148 return [sfmX, sfmY];
36151 * Convert SfM coordinates to basic coordinates.
36153 * @param {Array<number>} sfm - 2D SfM coordinates.
36154 * @returns {Array<number>} 2D basic coordinates.
36156 Transform.prototype._sfmToBasic = function (sfm) {
36157 var w = this._width;
36158 var h = this._height;
36159 var s = Math.max(w, h);
36160 var rotatedX = (sfm[0] + w / s / 2) / w * s;
36161 var rotatedY = (sfm[1] + h / s / 2) / h * s;
36164 switch (this._orientation) {
36170 basicX = 1 - rotatedX;
36171 basicY = 1 - rotatedY;
36174 basicX = 1 - rotatedY;
36179 basicY = 1 - rotatedX;
36186 return [basicX, basicY];
36189 * Determines if the gpano information indicates a full panorama.
36191 * @returns {boolean} Value determining if the gpano information indicates
36194 Transform.prototype._fullPano = function () {
36195 return this.gpano != null &&
36196 this.gpano.CroppedAreaLeftPixels === 0 &&
36197 this.gpano.CroppedAreaTopPixels === 0 &&
36198 this.gpano.CroppedAreaImageWidthPixels === this.gpano.FullPanoWidthPixels &&
36199 this.gpano.CroppedAreaImageHeightPixels === this.gpano.FullPanoHeightPixels;
36202 * Checks a value and returns it if it exists and is larger than 0.
36203 * Fallbacks if it is null.
36205 * @param {number} value - Value to check.
36206 * @param {number} fallback - Value to fall back to.
36207 * @returns {number} The value or its fallback value if it is not defined or negative.
36209 Transform.prototype._getValue = function (value, fallback) {
36210 return value != null && value > 0 ? value : fallback;
36213 * Creates the extrinsic camera matrix [ R | t ].
36215 * @param {Array<number>} rotation - Rotation vector in angle axis representation.
36216 * @param {Array<number>} translation - Translation vector.
36217 * @returns {THREE.Matrix4} Extrisic camera matrix.
36219 Transform.prototype._getRt = function (rotation, translation) {
36220 var axis = new THREE.Vector3(rotation[0], rotation[1], rotation[2]);
36221 var angle = axis.length();
36225 var rt = new THREE.Matrix4();
36226 rt.makeRotationAxis(axis, angle);
36227 rt.setPosition(new THREE.Vector3(translation[0], translation[1], translation[2]));
36231 * Calculates the scaled extrinsic camera matrix scale * [ R | t ].
36233 * @param {THREE.Matrix4} rt - Extrisic camera matrix.
36234 * @param {number} scale - Scale factor.
36235 * @returns {THREE.Matrix4} Scaled extrisic camera matrix.
36237 Transform.prototype._getSrt = function (rt, scale) {
36238 var srt = rt.clone();
36239 var elements = srt.elements;
36240 elements[12] = scale * elements[12];
36241 elements[13] = scale * elements[13];
36242 elements[14] = scale * elements[14];
36243 srt.scale(new THREE.Vector3(scale, scale, scale));
36246 Transform.prototype._getBasicRt = function (rt, orientation) {
36247 var axis = new THREE.Vector3(0, 0, 1);
36249 switch (orientation) {
36254 angle = Math.PI / 2;
36257 angle = 3 * Math.PI / 2;
36262 return new THREE.Matrix4()
36263 .makeRotationAxis(axis, angle)
36266 Transform.prototype._getRadialPeak = function (k1, k2) {
36270 var d = Math.pow(b, 2) - 4 * a * c;
36274 var root1 = (-b - Math.sqrt(d)) / 2 / a;
36275 var root2 = (-b + Math.sqrt(d)) / 2 / a;
36276 var minRoot = Math.min(root1, root2);
36277 var maxRoot = Math.max(root1, root2);
36278 return minRoot > 0 ?
36279 Math.sqrt(minRoot) :
36281 Math.sqrt(maxRoot) :
36285 * Calculate a transformation matrix from normalized coordinates for
36286 * texture map coordinates.
36288 * @returns {THREE.Matrix4} Normalized coordinates to texture map
36289 * coordinates transformation matrix.
36291 Transform.prototype._normalizedToTextureMatrix = function () {
36292 var size = Math.max(this._width, this._height);
36293 var scaleX = this._orientation < 5 ? this._textureScale[0] : this._textureScale[1];
36294 var scaleY = this._orientation < 5 ? this._textureScale[1] : this._textureScale[0];
36295 var w = size / this._width * scaleX;
36296 var h = size / this._height * scaleY;
36297 switch (this._orientation) {
36299 return new THREE.Matrix4().set(w, 0, 0, 0.5, 0, -h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
36301 return new THREE.Matrix4().set(-w, 0, 0, 0.5, 0, h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
36303 return new THREE.Matrix4().set(0, -h, 0, 0.5, -w, 0, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
36305 return new THREE.Matrix4().set(0, h, 0, 0.5, w, 0, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
36307 return new THREE.Matrix4().set(w, 0, 0, 0.5, 0, -h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
36312 exports.Transform = Transform;
36314 },{"three":225}],387:[function(require,module,exports){
36316 Object.defineProperty(exports, "__esModule", { value: true });
36317 var THREE = require("three");
36319 * @class ViewportCoords
36321 * @classdesc Provides methods for calculating 2D coordinate conversions
36322 * as well as 3D projection and unprojection.
36324 * Basic coordinates are 2D coordinates on the [0, 1] interval and
36325 * have the origin point, (0, 0), at the top left corner and the
36326 * maximum value, (1, 1), at the bottom right corner of the original
36329 * Viewport coordinates are 2D coordinates on the [-1, 1] interval and
36330 * have the origin point in the center. The bottom left corner point is
36331 * (-1, -1) and the top right corner point is (1, 1).
36333 * Canvas coordiantes are 2D pixel coordinates on the [0, canvasWidth] and
36334 * [0, canvasHeight] intervals. The origin point (0, 0) is in the top left
36335 * corner and the maximum value is (canvasWidth, canvasHeight) is in the
36336 * bottom right corner.
36338 * 3D coordinates are in the topocentric world reference frame.
36340 var ViewportCoords = /** @class */ (function () {
36341 function ViewportCoords() {
36342 this._unprojectDepth = 200;
36345 * Convert basic coordinates to canvas coordinates.
36347 * @description Transform origin and camera position needs to be the
36348 * equal for reliable return value.
36350 * @param {number} basicX - Basic X coordinate.
36351 * @param {number} basicY - Basic Y coordinate.
36352 * @param {HTMLElement} container - The viewer container.
36353 * @param {Transform} transform - Transform of the node to unproject from.
36354 * @param {THREE.Camera} camera - Camera used in rendering.
36355 * @returns {Array<number>} 2D canvas coordinates.
36357 ViewportCoords.prototype.basicToCanvas = function (basicX, basicY, container, transform, camera) {
36358 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
36359 var canvas = this.projectToCanvas(point3d, container, camera);
36363 * Convert basic coordinates to canvas coordinates safely. If 3D point is
36364 * behind camera null will be returned.
36366 * @description Transform origin and camera position needs to be the
36367 * equal for reliable return value.
36369 * @param {number} basicX - Basic X coordinate.
36370 * @param {number} basicY - Basic Y coordinate.
36371 * @param {HTMLElement} container - The viewer container.
36372 * @param {Transform} transform - Transform of the node to unproject from.
36373 * @param {THREE.Camera} camera - Camera used in rendering.
36374 * @returns {Array<number>} 2D canvas coordinates if the basic point represents a 3D point
36375 * in front of the camera, otherwise null.
36377 ViewportCoords.prototype.basicToCanvasSafe = function (basicX, basicY, container, transform, camera) {
36378 var viewport = this.basicToViewportSafe(basicX, basicY, transform, camera);
36379 if (viewport === null) {
36382 var canvas = this.viewportToCanvas(viewport[0], viewport[1], container);
36386 * Convert basic coordinates to viewport coordinates.
36388 * @description Transform origin and camera position needs to be the
36389 * equal for reliable return value.
36391 * @param {number} basicX - Basic X coordinate.
36392 * @param {number} basicY - Basic Y coordinate.
36393 * @param {Transform} transform - Transform of the node to unproject from.
36394 * @param {THREE.Camera} camera - Camera used in rendering.
36395 * @returns {Array<number>} 2D viewport coordinates.
36397 ViewportCoords.prototype.basicToViewport = function (basicX, basicY, transform, camera) {
36398 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
36399 var viewport = this.projectToViewport(point3d, camera);
36403 * Convert basic coordinates to viewport coordinates safely. If 3D point is
36404 * behind camera null will be returned.
36406 * @description Transform origin and camera position needs to be the
36407 * equal for reliable return value.
36409 * @param {number} basicX - Basic X coordinate.
36410 * @param {number} basicY - Basic Y coordinate.
36411 * @param {Transform} transform - Transform of the node to unproject from.
36412 * @param {THREE.Camera} camera - Camera used in rendering.
36413 * @returns {Array<number>} 2D viewport coordinates.
36415 ViewportCoords.prototype.basicToViewportSafe = function (basicX, basicY, transform, camera) {
36416 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
36417 var pointCamera = this.worldToCamera(point3d, camera);
36418 if (pointCamera[2] > 0) {
36421 var viewport = this.projectToViewport(point3d, camera);
36425 * Convert camera 3D coordinates to viewport coordinates.
36427 * @param {number} pointCamera - 3D point in camera coordinate system.
36428 * @param {THREE.Camera} camera - Camera used in rendering.
36429 * @returns {Array<number>} 2D viewport coordinates.
36431 ViewportCoords.prototype.cameraToViewport = function (pointCamera, camera) {
36432 var viewport = new THREE.Vector3().fromArray(pointCamera)
36433 .applyMatrix4(camera.projectionMatrix);
36434 return [viewport.x, viewport.y];
36437 * Get canvas pixel position from event.
36439 * @param {Event} event - Event containing clientX and clientY properties.
36440 * @param {HTMLElement} element - HTML element.
36441 * @returns {Array<number>} 2D canvas coordinates.
36443 ViewportCoords.prototype.canvasPosition = function (event, element) {
36444 var clientRect = element.getBoundingClientRect();
36445 var canvasX = event.clientX - clientRect.left - element.clientLeft;
36446 var canvasY = event.clientY - clientRect.top - element.clientTop;
36447 return [canvasX, canvasY];
36450 * Convert canvas coordinates to basic coordinates.
36452 * @description Transform origin and camera position needs to be the
36453 * equal for reliable return value.
36455 * @param {number} canvasX - Canvas X coordinate.
36456 * @param {number} canvasY - Canvas Y coordinate.
36457 * @param {HTMLElement} container - The viewer container.
36458 * @param {Transform} transform - Transform of the node to unproject from.
36459 * @param {THREE.Camera} camera - Camera used in rendering.
36460 * @returns {Array<number>} 2D basic coordinates.
36462 ViewportCoords.prototype.canvasToBasic = function (canvasX, canvasY, container, transform, camera) {
36463 var point3d = this.unprojectFromCanvas(canvasX, canvasY, container, camera)
36465 var basic = transform.projectBasic(point3d);
36469 * Convert canvas coordinates to viewport coordinates.
36471 * @param {number} canvasX - Canvas X coordinate.
36472 * @param {number} canvasY - Canvas Y coordinate.
36473 * @param {HTMLElement} container - The viewer container.
36474 * @returns {Array<number>} 2D viewport coordinates.
36476 ViewportCoords.prototype.canvasToViewport = function (canvasX, canvasY, container) {
36477 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
36478 var viewportX = 2 * canvasX / canvasWidth - 1;
36479 var viewportY = 1 - 2 * canvasY / canvasHeight;
36480 return [viewportX, viewportY];
36483 * Determines the width and height of the container in canvas coordinates.
36485 * @param {HTMLElement} container - The viewer container.
36486 * @returns {Array<number>} 2D canvas coordinates.
36488 ViewportCoords.prototype.containerToCanvas = function (container) {
36489 return [container.offsetWidth, container.offsetHeight];
36492 * Determine basic distances from image to canvas corners.
36494 * @description Transform origin and camera position needs to be the
36495 * equal for reliable return value.
36497 * Determines the smallest basic distance for every side of the canvas.
36499 * @param {Transform} transform - Transform of the node to unproject from.
36500 * @param {THREE.Camera} camera - Camera used in rendering.
36501 * @returns {Array<number>} Array of basic distances as [top, right, bottom, left].
36503 ViewportCoords.prototype.getBasicDistances = function (transform, camera) {
36504 var topLeftBasic = this.viewportToBasic(-1, 1, transform, camera);
36505 var topRightBasic = this.viewportToBasic(1, 1, transform, camera);
36506 var bottomRightBasic = this.viewportToBasic(1, -1, transform, camera);
36507 var bottomLeftBasic = this.viewportToBasic(-1, -1, transform, camera);
36508 var topBasicDistance = 0;
36509 var rightBasicDistance = 0;
36510 var bottomBasicDistance = 0;
36511 var leftBasicDistance = 0;
36512 if (topLeftBasic[1] < 0 && topRightBasic[1] < 0) {
36513 topBasicDistance = topLeftBasic[1] > topRightBasic[1] ?
36517 if (topRightBasic[0] > 1 && bottomRightBasic[0] > 1) {
36518 rightBasicDistance = topRightBasic[0] < bottomRightBasic[0] ?
36519 topRightBasic[0] - 1 :
36520 bottomRightBasic[0] - 1;
36522 if (bottomRightBasic[1] > 1 && bottomLeftBasic[1] > 1) {
36523 bottomBasicDistance = bottomRightBasic[1] < bottomLeftBasic[1] ?
36524 bottomRightBasic[1] - 1 :
36525 bottomLeftBasic[1] - 1;
36527 if (bottomLeftBasic[0] < 0 && topLeftBasic[0] < 0) {
36528 leftBasicDistance = bottomLeftBasic[0] > topLeftBasic[0] ?
36529 -bottomLeftBasic[0] :
36532 return [topBasicDistance, rightBasicDistance, bottomBasicDistance, leftBasicDistance];
36535 * Determine pixel distances from image to canvas corners.
36537 * @description Transform origin and camera position needs to be the
36538 * equal for reliable return value.
36540 * Determines the smallest pixel distance for every side of the canvas.
36542 * @param {HTMLElement} container - The viewer container.
36543 * @param {Transform} transform - Transform of the node to unproject from.
36544 * @param {THREE.Camera} camera - Camera used in rendering.
36545 * @returns {Array<number>} Array of pixel distances as [top, right, bottom, left].
36547 ViewportCoords.prototype.getPixelDistances = function (container, transform, camera) {
36548 var topLeftBasic = this.viewportToBasic(-1, 1, transform, camera);
36549 var topRightBasic = this.viewportToBasic(1, 1, transform, camera);
36550 var bottomRightBasic = this.viewportToBasic(1, -1, transform, camera);
36551 var bottomLeftBasic = this.viewportToBasic(-1, -1, transform, camera);
36552 var topPixelDistance = 0;
36553 var rightPixelDistance = 0;
36554 var bottomPixelDistance = 0;
36555 var leftPixelDistance = 0;
36556 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
36557 if (topLeftBasic[1] < 0 && topRightBasic[1] < 0) {
36558 var basicX = topLeftBasic[1] > topRightBasic[1] ?
36561 var canvas = this.basicToCanvas(basicX, 0, container, transform, camera);
36562 topPixelDistance = canvas[1] > 0 ? canvas[1] : 0;
36564 if (topRightBasic[0] > 1 && bottomRightBasic[0] > 1) {
36565 var basicY = topRightBasic[0] < bottomRightBasic[0] ?
36567 bottomRightBasic[1];
36568 var canvas = this.basicToCanvas(1, basicY, container, transform, camera);
36569 rightPixelDistance = canvas[0] < canvasWidth ? canvasWidth - canvas[0] : 0;
36571 if (bottomRightBasic[1] > 1 && bottomLeftBasic[1] > 1) {
36572 var basicX = bottomRightBasic[1] < bottomLeftBasic[1] ?
36573 bottomRightBasic[0] :
36574 bottomLeftBasic[0];
36575 var canvas = this.basicToCanvas(basicX, 1, container, transform, camera);
36576 bottomPixelDistance = canvas[1] < canvasHeight ? canvasHeight - canvas[1] : 0;
36578 if (bottomLeftBasic[0] < 0 && topLeftBasic[0] < 0) {
36579 var basicY = bottomLeftBasic[0] > topLeftBasic[0] ?
36580 bottomLeftBasic[1] :
36582 var canvas = this.basicToCanvas(0, basicY, container, transform, camera);
36583 leftPixelDistance = canvas[0] > 0 ? canvas[0] : 0;
36585 return [topPixelDistance, rightPixelDistance, bottomPixelDistance, leftPixelDistance];
36588 * Determine if an event occured inside an element.
36590 * @param {Event} event - Event containing clientX and clientY properties.
36591 * @param {HTMLElement} element - HTML element.
36592 * @returns {boolean} Value indicating if the event occured inside the element or not.
36594 ViewportCoords.prototype.insideElement = function (event, element) {
36595 var clientRect = element.getBoundingClientRect();
36596 var minX = clientRect.left + element.clientLeft;
36597 var maxX = minX + element.clientWidth;
36598 var minY = clientRect.top + element.clientTop;
36599 var maxY = minY + element.clientHeight;
36600 return event.clientX > minX &&
36601 event.clientX < maxX &&
36602 event.clientY > minY &&
36603 event.clientY < maxY;
36606 * Project 3D world coordinates to canvas coordinates.
36608 * @param {Array<number>} point3D - 3D world coordinates.
36609 * @param {HTMLElement} container - The viewer container.
36610 * @param {THREE.Camera} camera - Camera used in rendering.
36611 * @returns {Array<number>} 2D canvas coordinates.
36613 ViewportCoords.prototype.projectToCanvas = function (point3d, container, camera) {
36614 var viewport = this.projectToViewport(point3d, camera);
36615 var canvas = this.viewportToCanvas(viewport[0], viewport[1], container);
36619 * Project 3D world coordinates to viewport coordinates.
36621 * @param {Array<number>} point3D - 3D world coordinates.
36622 * @param {THREE.Camera} camera - Camera used in rendering.
36623 * @returns {Array<number>} 2D viewport coordinates.
36625 ViewportCoords.prototype.projectToViewport = function (point3d, camera) {
36626 var viewport = new THREE.Vector3(point3d[0], point3d[1], point3d[2])
36628 return [viewport.x, viewport.y];
36631 * Uproject canvas coordinates to 3D world coordinates.
36633 * @param {number} canvasX - Canvas X coordinate.
36634 * @param {number} canvasY - Canvas Y coordinate.
36635 * @param {HTMLElement} container - The viewer container.
36636 * @param {THREE.Camera} camera - Camera used in rendering.
36637 * @returns {Array<number>} 3D world coordinates.
36639 ViewportCoords.prototype.unprojectFromCanvas = function (canvasX, canvasY, container, camera) {
36640 var viewport = this.canvasToViewport(canvasX, canvasY, container);
36641 var point3d = this.unprojectFromViewport(viewport[0], viewport[1], camera);
36645 * Unproject viewport coordinates to 3D world coordinates.
36647 * @param {number} viewportX - Viewport X coordinate.
36648 * @param {number} viewportY - Viewport Y coordinate.
36649 * @param {THREE.Camera} camera - Camera used in rendering.
36650 * @returns {Array<number>} 3D world coordinates.
36652 ViewportCoords.prototype.unprojectFromViewport = function (viewportX, viewportY, camera) {
36653 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
36654 .unproject(camera);
36658 * Convert viewport coordinates to basic coordinates.
36660 * @description Transform origin and camera position needs to be the
36661 * equal for reliable return value.
36663 * @param {number} viewportX - Viewport X coordinate.
36664 * @param {number} viewportY - Viewport Y coordinate.
36665 * @param {Transform} transform - Transform of the node to unproject from.
36666 * @param {THREE.Camera} camera - Camera used in rendering.
36667 * @returns {Array<number>} 2D basic coordinates.
36669 ViewportCoords.prototype.viewportToBasic = function (viewportX, viewportY, transform, camera) {
36670 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
36673 var basic = transform.projectBasic(point3d);
36677 * Convert viewport coordinates to canvas coordinates.
36679 * @param {number} viewportX - Viewport X coordinate.
36680 * @param {number} viewportY - Viewport Y coordinate.
36681 * @param {HTMLElement} container - The viewer container.
36682 * @returns {Array<number>} 2D canvas coordinates.
36684 ViewportCoords.prototype.viewportToCanvas = function (viewportX, viewportY, container) {
36685 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
36686 var canvasX = canvasWidth * (viewportX + 1) / 2;
36687 var canvasY = -canvasHeight * (viewportY - 1) / 2;
36688 return [canvasX, canvasY];
36691 * Convert 3D world coordinates to 3D camera coordinates.
36693 * @param {number} point3D - 3D point in world coordinate system.
36694 * @param {THREE.Camera} camera - Camera used in rendering.
36695 * @returns {Array<number>} 3D camera coordinates.
36697 ViewportCoords.prototype.worldToCamera = function (point3d, camera) {
36698 var pointCamera = new THREE.Vector3(point3d[0], point3d[1], point3d[2])
36699 .applyMatrix4(camera.matrixWorldInverse);
36700 return pointCamera.toArray();
36702 return ViewportCoords;
36704 exports.ViewportCoords = ViewportCoords;
36705 exports.default = ViewportCoords;
36708 },{"three":225}],388:[function(require,module,exports){
36710 Object.defineProperty(exports, "__esModule", { value: true });
36714 * @classdesc Represents a class for creating node filters. Implementation and
36715 * definitions based on https://github.com/mapbox/feature-filter.
36717 var FilterCreator = /** @class */ (function () {
36718 function FilterCreator() {
36721 * Create a filter from a filter expression.
36723 * @description The following filters are supported:
36740 * @param {FilterExpression} filter - Comparison, set membership or combinding filter
36742 * @returns {FilterFunction} Function taking a node and returning a boolean that
36743 * indicates whether the node passed the test or not.
36745 FilterCreator.prototype.createFilter = function (filter) {
36746 return new Function("node", "return " + this._compile(filter) + ";");
36748 FilterCreator.prototype._compile = function (filter) {
36749 if (filter == null || filter.length <= 1) {
36752 var operator = filter[0];
36753 var operation = operator === "==" ? this._compileComparisonOp("===", filter[1], filter[2], false) :
36754 operator === "!=" ? this._compileComparisonOp("!==", filter[1], filter[2], false) :
36755 operator === ">" ||
36756 operator === ">=" ||
36757 operator === "<" ||
36758 operator === "<=" ? this._compileComparisonOp(operator, filter[1], filter[2], true) :
36759 operator === "in" ?
36760 this._compileInOp(filter[1], filter.slice(2)) :
36761 operator === "!in" ?
36762 this._compileNegation(this._compileInOp(filter[1], filter.slice(2))) :
36763 operator === "all" ? this._compileLogicalOp(filter.slice(1), "&&") :
36765 return "(" + operation + ")";
36767 FilterCreator.prototype._compare = function (a, b) {
36768 return a < b ? -1 : a > b ? 1 : 0;
36770 FilterCreator.prototype._compileComparisonOp = function (operator, property, value, checkType) {
36771 var left = this._compilePropertyReference(property);
36772 var right = JSON.stringify(value);
36773 return (checkType ? "typeof " + left + "===typeof " + right + "&&" : "") + left + operator + right;
36775 FilterCreator.prototype._compileInOp = function (property, values) {
36776 var compare = this._compare;
36777 var left = JSON.stringify(values.sort(compare));
36778 var right = this._compilePropertyReference(property);
36779 return left + ".indexOf(" + right + ")!==-1";
36781 FilterCreator.prototype._compileLogicalOp = function (filters, operator) {
36782 var compile = this._compile.bind(this);
36783 return filters.map(compile).join(operator);
36785 FilterCreator.prototype._compileNegation = function (expression) {
36786 return "!(" + expression + ")";
36788 FilterCreator.prototype._compilePropertyReference = function (property) {
36789 return "node[" + JSON.stringify(property) + "]";
36791 return FilterCreator;
36793 exports.FilterCreator = FilterCreator;
36794 exports.default = FilterCreator;
36796 },{}],389:[function(require,module,exports){
36798 Object.defineProperty(exports, "__esModule", { value: true });
36799 var rxjs_1 = require("rxjs");
36800 var operators_1 = require("rxjs/operators");
36801 var rbush = require("rbush");
36802 var Edge_1 = require("../Edge");
36803 var Error_1 = require("../Error");
36804 var Graph_1 = require("../Graph");
36808 * @classdesc Represents a graph of nodes with edges.
36810 var Graph = /** @class */ (function () {
36812 * Create a new graph instance.
36814 * @param {APIv3} [apiV3] - API instance for retrieving data.
36815 * @param {rbush.RBush<NodeIndexItem>} [nodeIndex] - Node index for fast spatial retreival.
36816 * @param {GraphCalculator} [graphCalculator] - Instance for graph calculations.
36817 * @param {EdgeCalculator} [edgeCalculator] - Instance for edge calculations.
36818 * @param {FilterCreator} [filterCreator] - Instance for filter creation.
36819 * @param {IGraphConfiguration} [configuration] - Configuration struct.
36821 function Graph(apiV3, nodeIndex, graphCalculator, edgeCalculator, filterCreator, configuration) {
36822 this._apiV3 = apiV3;
36823 this._cachedNodes = {};
36824 this._cachedNodeTiles = {};
36825 this._cachedSequenceNodes = {};
36826 this._cachedSpatialEdges = {};
36827 this._cachedTiles = {};
36828 this._cachingFill$ = {};
36829 this._cachingFull$ = {};
36830 this._cachingSequenceNodes$ = {};
36831 this._cachingSequences$ = {};
36832 this._cachingSpatialArea$ = {};
36833 this._cachingTiles$ = {};
36834 this._changed$ = new rxjs_1.Subject();
36835 this._defaultAlt = 2;
36836 this._edgeCalculator = edgeCalculator != null ? edgeCalculator : new Edge_1.EdgeCalculator();
36837 this._filterCreator = filterCreator != null ? filterCreator : new Graph_1.FilterCreator();
36838 this._filter = this._filterCreator.createFilter(undefined);
36839 this._graphCalculator = graphCalculator != null ? graphCalculator : new Graph_1.GraphCalculator();
36840 this._configuration = configuration != null ?
36844 maxUnusedNodes: 100,
36845 maxUnusedPreStoredNodes: 30,
36846 maxUnusedTiles: 20,
36849 this._nodeIndex = nodeIndex != null ? nodeIndex : rbush(16, [".lat", ".lon", ".lat", ".lon"]);
36850 this._nodeIndexTiles = {};
36851 this._nodeToTile = {};
36852 this._preStored = {};
36853 this._requiredNodeTiles = {};
36854 this._requiredSpatialArea = {};
36855 this._sequences = {};
36856 this._tilePrecision = 7;
36857 this._tileThreshold = 20;
36859 Object.defineProperty(Graph.prototype, "changed$", {
36863 * @returns {Observable<Graph>} Observable emitting
36864 * the graph every time it has changed.
36867 return this._changed$;
36873 * Caches the full node data for all images within a bounding
36876 * @description The node assets are not cached.
36878 * @param {ILatLon} sw - South west corner of bounding box.
36879 * @param {ILatLon} ne - North east corner of bounding box.
36880 * @returns {Observable<Graph>} Observable emitting the full
36881 * nodes in the bounding box.
36883 Graph.prototype.cacheBoundingBox$ = function (sw, ne) {
36885 var cacheTiles$ = this._graphCalculator.encodeHsFromBoundingBox(sw, ne)
36886 .filter(function (h) {
36887 return !(h in _this._cachedTiles);
36889 .map(function (h) {
36890 return h in _this._cachingTiles$ ?
36891 _this._cachingTiles$[h] :
36892 _this._cacheTile$(h);
36894 if (cacheTiles$.length === 0) {
36895 cacheTiles$.push(rxjs_1.of(this));
36897 return rxjs_1.from(cacheTiles$).pipe(operators_1.mergeAll(), operators_1.last(), operators_1.mergeMap(function (graph) {
36898 var nodes = _this._nodeIndex
36905 .map(function (item) {
36908 var fullNodes = [];
36909 var coreNodes = [];
36910 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
36911 var node = nodes_1[_i];
36913 fullNodes.push(node);
36916 coreNodes.push(node.key);
36919 var coreNodeBatches = [];
36920 var batchSize = 200;
36921 while (coreNodes.length > 0) {
36922 coreNodeBatches.push(coreNodes.splice(0, batchSize));
36924 var fullNodes$ = rxjs_1.of(fullNodes);
36925 var fillNodes$ = coreNodeBatches
36926 .map(function (batch) {
36927 return _this._apiV3.imageByKeyFill$(batch).pipe(operators_1.map(function (imageByKeyFill) {
36928 var filledNodes = [];
36929 for (var fillKey in imageByKeyFill) {
36930 if (!imageByKeyFill.hasOwnProperty(fillKey)) {
36933 if (_this.hasNode(fillKey)) {
36934 var node = _this.getNode(fillKey);
36936 _this._makeFull(node, imageByKeyFill[fillKey]);
36938 filledNodes.push(node);
36941 return filledNodes;
36944 return rxjs_1.merge(fullNodes$, rxjs_1.from(fillNodes$).pipe(operators_1.mergeAll()));
36945 }), operators_1.reduce(function (acc, value) {
36946 return acc.concat(value);
36950 * Retrieve and cache node fill properties.
36952 * @param {string} key - Key of node to fill.
36953 * @returns {Observable<Graph>} Observable emitting the graph
36954 * when the node has been updated.
36955 * @throws {GraphMapillaryError} When the operation is not valid on the
36958 Graph.prototype.cacheFill$ = function (key) {
36960 if (key in this._cachingFull$) {
36961 throw new Error_1.GraphMapillaryError("Cannot fill node while caching full (" + key + ").");
36963 if (!this.hasNode(key)) {
36964 throw new Error_1.GraphMapillaryError("Cannot fill node that does not exist in graph (" + key + ").");
36966 if (key in this._cachingFill$) {
36967 return this._cachingFill$[key];
36969 var node = this.getNode(key);
36971 throw new Error_1.GraphMapillaryError("Cannot fill node that is already full (" + key + ").");
36973 this._cachingFill$[key] = this._apiV3.imageByKeyFill$([key]).pipe(operators_1.tap(function (imageByKeyFill) {
36975 _this._makeFull(node, imageByKeyFill[key]);
36977 delete _this._cachingFill$[key];
36978 }), operators_1.map(function (imageByKeyFill) {
36980 }), operators_1.finalize(function () {
36981 if (key in _this._cachingFill$) {
36982 delete _this._cachingFill$[key];
36984 _this._changed$.next(_this);
36985 }), operators_1.publish(), operators_1.refCount());
36986 return this._cachingFill$[key];
36989 * Retrieve and cache full node properties.
36991 * @param {string} key - Key of node to fill.
36992 * @returns {Observable<Graph>} Observable emitting the graph
36993 * when the node has been updated.
36994 * @throws {GraphMapillaryError} When the operation is not valid on the
36997 Graph.prototype.cacheFull$ = function (key) {
36999 if (key in this._cachingFull$) {
37000 return this._cachingFull$[key];
37002 if (this.hasNode(key)) {
37003 throw new Error_1.GraphMapillaryError("Cannot cache full node that already exist in graph (" + key + ").");
37005 this._cachingFull$[key] = this._apiV3.imageByKeyFull$([key]).pipe(operators_1.tap(function (imageByKeyFull) {
37006 var fn = imageByKeyFull[key];
37007 if (_this.hasNode(key)) {
37008 var node = _this.getNode(key);
37010 _this._makeFull(node, fn);
37014 if (fn.sequence_key == null) {
37015 throw new Error_1.GraphMapillaryError("Node has no sequence key (" + key + ").");
37017 var node = new Graph_1.Node(fn);
37018 _this._makeFull(node, fn);
37019 var h = _this._graphCalculator.encodeH(node.originalLatLon, _this._tilePrecision);
37020 _this._preStore(h, node);
37021 _this._setNode(node);
37022 delete _this._cachingFull$[key];
37024 }), operators_1.map(function (imageByKeyFull) {
37026 }), operators_1.finalize(function () {
37027 if (key in _this._cachingFull$) {
37028 delete _this._cachingFull$[key];
37030 _this._changed$.next(_this);
37031 }), operators_1.publish(), operators_1.refCount());
37032 return this._cachingFull$[key];
37035 * Retrieve and cache a node sequence.
37037 * @param {string} key - Key of node for which to retrieve sequence.
37038 * @returns {Observable<Graph>} Observable emitting the graph
37039 * when the sequence has been retrieved.
37040 * @throws {GraphMapillaryError} When the operation is not valid on the
37043 Graph.prototype.cacheNodeSequence$ = function (key) {
37044 if (!this.hasNode(key)) {
37045 throw new Error_1.GraphMapillaryError("Cannot cache sequence edges of node that does not exist in graph (" + key + ").");
37047 var node = this.getNode(key);
37048 if (node.sequenceKey in this._sequences) {
37049 throw new Error_1.GraphMapillaryError("Sequence already cached (" + key + "), (" + node.sequenceKey + ").");
37051 return this._cacheSequence$(node.sequenceKey);
37054 * Retrieve and cache a sequence.
37056 * @param {string} sequenceKey - Key of sequence to cache.
37057 * @returns {Observable<Graph>} Observable emitting the graph
37058 * when the sequence has been retrieved.
37059 * @throws {GraphMapillaryError} When the operation is not valid on the
37062 Graph.prototype.cacheSequence$ = function (sequenceKey) {
37063 if (sequenceKey in this._sequences) {
37064 throw new Error_1.GraphMapillaryError("Sequence already cached (" + sequenceKey + ")");
37066 return this._cacheSequence$(sequenceKey);
37069 * Cache sequence edges for a node.
37071 * @param {string} key - Key of node.
37072 * @throws {GraphMapillaryError} When the operation is not valid on the
37075 Graph.prototype.cacheSequenceEdges = function (key) {
37076 var node = this.getNode(key);
37077 if (!(node.sequenceKey in this._sequences)) {
37078 throw new Error_1.GraphMapillaryError("Sequence is not cached (" + key + "), (" + node.sequenceKey + ")");
37080 var sequence = this._sequences[node.sequenceKey].sequence;
37081 var edges = this._edgeCalculator.computeSequenceEdges(node, sequence);
37082 node.cacheSequenceEdges(edges);
37085 * Retrieve and cache full nodes for all keys in a sequence.
37087 * @param {string} sequenceKey - Key of sequence.
37088 * @param {string} referenceNodeKey - Key of node to use as reference
37089 * for optimized caching.
37090 * @returns {Observable<Graph>} Observable emitting the graph
37091 * when the nodes of the sequence has been cached.
37093 Graph.prototype.cacheSequenceNodes$ = function (sequenceKey, referenceNodeKey) {
37095 if (!this.hasSequence(sequenceKey)) {
37096 throw new Error_1.GraphMapillaryError("Cannot cache sequence nodes of sequence that does not exist in graph (" + sequenceKey + ").");
37098 if (this.hasSequenceNodes(sequenceKey)) {
37099 throw new Error_1.GraphMapillaryError("Sequence nodes already cached (" + sequenceKey + ").");
37101 var sequence = this.getSequence(sequenceKey);
37102 if (sequence.key in this._cachingSequenceNodes$) {
37103 return this._cachingSequenceNodes$[sequence.key];
37106 var keys = sequence.keys.slice();
37107 var referenceBatchSize = 50;
37108 if (!!referenceNodeKey && keys.length > referenceBatchSize) {
37109 var referenceIndex = keys.indexOf(referenceNodeKey);
37110 var startIndex = Math.max(0, Math.min(referenceIndex - referenceBatchSize / 2, keys.length - referenceBatchSize));
37111 batches.push(keys.splice(startIndex, referenceBatchSize));
37113 var batchSize = 200;
37114 while (keys.length > 0) {
37115 batches.push(keys.splice(0, batchSize));
37117 var batchesToCache = batches.length;
37118 var sequenceNodes$ = rxjs_1.from(batches).pipe(operators_1.mergeMap(function (batch) {
37119 return _this._apiV3.imageByKeyFull$(batch).pipe(operators_1.tap(function (imageByKeyFull) {
37120 for (var fullKey in imageByKeyFull) {
37121 if (!imageByKeyFull.hasOwnProperty(fullKey)) {
37124 var fn = imageByKeyFull[fullKey];
37125 if (_this.hasNode(fullKey)) {
37126 var node = _this.getNode(fn.key);
37128 _this._makeFull(node, fn);
37132 if (fn.sequence_key == null) {
37133 console.warn("Sequence missing, discarding node (" + fn.key + ")");
37135 var node = new Graph_1.Node(fn);
37136 _this._makeFull(node, fn);
37137 var h = _this._graphCalculator.encodeH(node.originalLatLon, _this._tilePrecision);
37138 _this._preStore(h, node);
37139 _this._setNode(node);
37143 }), operators_1.map(function (imageByKeyFull) {
37146 }, 6), operators_1.last(), operators_1.finalize(function () {
37147 delete _this._cachingSequenceNodes$[sequence.key];
37148 if (batchesToCache === 0) {
37149 _this._cachedSequenceNodes[sequence.key] = true;
37151 }), operators_1.publish(), operators_1.refCount());
37152 this._cachingSequenceNodes$[sequence.key] = sequenceNodes$;
37153 return sequenceNodes$;
37156 * Retrieve and cache full nodes for a node spatial area.
37158 * @param {string} key - Key of node for which to retrieve sequence.
37159 * @returns {Observable<Graph>} Observable emitting the graph
37160 * when the nodes in the spatial area has been made full.
37161 * @throws {GraphMapillaryError} When the operation is not valid on the
37164 Graph.prototype.cacheSpatialArea$ = function (key) {
37166 if (!this.hasNode(key)) {
37167 throw new Error_1.GraphMapillaryError("Cannot cache spatial area of node that does not exist in graph (" + key + ").");
37169 if (key in this._cachedSpatialEdges) {
37170 throw new Error_1.GraphMapillaryError("Node already spatially cached (" + key + ").");
37172 if (!(key in this._requiredSpatialArea)) {
37173 throw new Error_1.GraphMapillaryError("Spatial area not determined (" + key + ").");
37175 var spatialArea = this._requiredSpatialArea[key];
37176 if (Object.keys(spatialArea.cacheNodes).length === 0) {
37177 throw new Error_1.GraphMapillaryError("Spatial nodes already cached (" + key + ").");
37179 if (key in this._cachingSpatialArea$) {
37180 return this._cachingSpatialArea$[key];
37183 while (spatialArea.cacheKeys.length > 0) {
37184 batches.push(spatialArea.cacheKeys.splice(0, 200));
37186 var batchesToCache = batches.length;
37187 var spatialNodes$ = [];
37188 var _loop_1 = function (batch) {
37189 var spatialNodeBatch$ = this_1._apiV3.imageByKeyFill$(batch).pipe(operators_1.tap(function (imageByKeyFill) {
37190 for (var fillKey in imageByKeyFill) {
37191 if (!imageByKeyFill.hasOwnProperty(fillKey)) {
37194 var spatialNode = spatialArea.cacheNodes[fillKey];
37195 if (spatialNode.full) {
37196 delete spatialArea.cacheNodes[fillKey];
37199 var fillNode = imageByKeyFill[fillKey];
37200 _this._makeFull(spatialNode, fillNode);
37201 delete spatialArea.cacheNodes[fillKey];
37203 if (--batchesToCache === 0) {
37204 delete _this._cachingSpatialArea$[key];
37206 }), operators_1.map(function (imageByKeyFill) {
37208 }), operators_1.catchError(function (error) {
37209 for (var _i = 0, batch_1 = batch; _i < batch_1.length; _i++) {
37210 var batchKey = batch_1[_i];
37211 if (batchKey in spatialArea.all) {
37212 delete spatialArea.all[batchKey];
37214 if (batchKey in spatialArea.cacheNodes) {
37215 delete spatialArea.cacheNodes[batchKey];
37218 if (--batchesToCache === 0) {
37219 delete _this._cachingSpatialArea$[key];
37222 }), operators_1.finalize(function () {
37223 if (Object.keys(spatialArea.cacheNodes).length === 0) {
37224 _this._changed$.next(_this);
37226 }), operators_1.publish(), operators_1.refCount());
37227 spatialNodes$.push(spatialNodeBatch$);
37230 for (var _i = 0, batches_1 = batches; _i < batches_1.length; _i++) {
37231 var batch = batches_1[_i];
37234 this._cachingSpatialArea$[key] = spatialNodes$;
37235 return spatialNodes$;
37238 * Cache spatial edges for a node.
37240 * @param {string} key - Key of node.
37241 * @throws {GraphMapillaryError} When the operation is not valid on the
37244 Graph.prototype.cacheSpatialEdges = function (key) {
37245 if (key in this._cachedSpatialEdges) {
37246 throw new Error_1.GraphMapillaryError("Spatial edges already cached (" + key + ").");
37248 var node = this.getNode(key);
37249 var sequence = this._sequences[node.sequenceKey].sequence;
37250 var fallbackKeys = [];
37251 var prevKey = sequence.findPrevKey(node.key);
37252 if (prevKey != null) {
37253 fallbackKeys.push(prevKey);
37255 var nextKey = sequence.findNextKey(node.key);
37256 if (nextKey != null) {
37257 fallbackKeys.push(nextKey);
37259 var allSpatialNodes = this._requiredSpatialArea[key].all;
37260 var potentialNodes = [];
37261 var filter = this._filter;
37262 for (var spatialNodeKey in allSpatialNodes) {
37263 if (!allSpatialNodes.hasOwnProperty(spatialNodeKey)) {
37266 var spatialNode = allSpatialNodes[spatialNodeKey];
37267 if (filter(spatialNode)) {
37268 potentialNodes.push(spatialNode);
37271 var potentialEdges = this._edgeCalculator.getPotentialEdges(node, potentialNodes, fallbackKeys);
37272 var edges = this._edgeCalculator.computeStepEdges(node, potentialEdges, prevKey, nextKey);
37273 edges = edges.concat(this._edgeCalculator.computeTurnEdges(node, potentialEdges));
37274 edges = edges.concat(this._edgeCalculator.computePanoEdges(node, potentialEdges));
37275 edges = edges.concat(this._edgeCalculator.computePerspectiveToPanoEdges(node, potentialEdges));
37276 edges = edges.concat(this._edgeCalculator.computeSimilarEdges(node, potentialEdges));
37277 node.cacheSpatialEdges(edges);
37278 this._cachedSpatialEdges[key] = node;
37279 delete this._requiredSpatialArea[key];
37280 delete this._cachedNodeTiles[key];
37283 * Retrieve and cache geohash tiles for a node.
37285 * @param {string} key - Key of node for which to retrieve tiles.
37286 * @returns {Array<Observable<Graph>>} Array of observables emitting
37287 * the graph for each tile required for the node has been cached.
37288 * @throws {GraphMapillaryError} When the operation is not valid on the
37291 Graph.prototype.cacheTiles$ = function (key) {
37293 if (key in this._cachedNodeTiles) {
37294 throw new Error_1.GraphMapillaryError("Tiles already cached (" + key + ").");
37296 if (key in this._cachedSpatialEdges) {
37297 throw new Error_1.GraphMapillaryError("Spatial edges already cached so tiles considered cached (" + key + ").");
37299 if (!(key in this._requiredNodeTiles)) {
37300 throw new Error_1.GraphMapillaryError("Tiles have not been determined (" + key + ").");
37302 var nodeTiles = this._requiredNodeTiles[key];
37303 if (nodeTiles.cache.length === 0 &&
37304 nodeTiles.caching.length === 0) {
37305 throw new Error_1.GraphMapillaryError("Tiles already cached (" + key + ").");
37307 if (!this.hasNode(key)) {
37308 throw new Error_1.GraphMapillaryError("Cannot cache tiles of node that does not exist in graph (" + key + ").");
37310 var hs = nodeTiles.cache.slice();
37311 nodeTiles.caching = this._requiredNodeTiles[key].caching.concat(hs);
37312 nodeTiles.cache = [];
37313 var cacheTiles$ = [];
37314 var _loop_2 = function (h) {
37315 var cacheTile$ = h in this_2._cachingTiles$ ?
37316 this_2._cachingTiles$[h] :
37317 this_2._cacheTile$(h);
37318 cacheTiles$.push(cacheTile$.pipe(operators_1.tap(function (graph) {
37319 var index = nodeTiles.caching.indexOf(h);
37321 nodeTiles.caching.splice(index, 1);
37323 if (nodeTiles.caching.length === 0 &&
37324 nodeTiles.cache.length === 0) {
37325 delete _this._requiredNodeTiles[key];
37326 _this._cachedNodeTiles[key] = true;
37328 }), operators_1.catchError(function (error) {
37329 var index = nodeTiles.caching.indexOf(h);
37331 nodeTiles.caching.splice(index, 1);
37333 if (nodeTiles.caching.length === 0 &&
37334 nodeTiles.cache.length === 0) {
37335 delete _this._requiredNodeTiles[key];
37336 _this._cachedNodeTiles[key] = true;
37339 }), operators_1.finalize(function () {
37340 _this._changed$.next(_this);
37341 }), operators_1.publish(), operators_1.refCount()));
37344 for (var _i = 0, _a = nodeTiles.caching; _i < _a.length; _i++) {
37348 return cacheTiles$;
37351 * Initialize the cache for a node.
37353 * @param {string} key - Key of node.
37354 * @throws {GraphMapillaryError} When the operation is not valid on the
37357 Graph.prototype.initializeCache = function (key) {
37358 if (key in this._cachedNodes) {
37359 throw new Error_1.GraphMapillaryError("Node already in cache (" + key + ").");
37361 var node = this.getNode(key);
37362 node.initializeCache(new Graph_1.NodeCache());
37363 var accessed = new Date().getTime();
37364 this._cachedNodes[key] = { accessed: accessed, node: node };
37365 this._updateCachedTileAccess(key, accessed);
37368 * Get a value indicating if the graph is fill caching a node.
37370 * @param {string} key - Key of node.
37371 * @returns {boolean} Value indicating if the node is being fill cached.
37373 Graph.prototype.isCachingFill = function (key) {
37374 return key in this._cachingFill$;
37377 * Get a value indicating if the graph is fully caching a node.
37379 * @param {string} key - Key of node.
37380 * @returns {boolean} Value indicating if the node is being fully cached.
37382 Graph.prototype.isCachingFull = function (key) {
37383 return key in this._cachingFull$;
37386 * Get a value indicating if the graph is caching a sequence of a node.
37388 * @param {string} key - Key of node.
37389 * @returns {boolean} Value indicating if the sequence of a node is
37392 Graph.prototype.isCachingNodeSequence = function (key) {
37393 var node = this.getNode(key);
37394 return node.sequenceKey in this._cachingSequences$;
37397 * Get a value indicating if the graph is caching a sequence.
37399 * @param {string} sequenceKey - Key of sequence.
37400 * @returns {boolean} Value indicating if the sequence is
37403 Graph.prototype.isCachingSequence = function (sequenceKey) {
37404 return sequenceKey in this._cachingSequences$;
37407 * Get a value indicating if the graph is caching sequence nodes.
37409 * @param {string} sequenceKey - Key of sequence.
37410 * @returns {boolean} Value indicating if the sequence nodes are
37413 Graph.prototype.isCachingSequenceNodes = function (sequenceKey) {
37414 return sequenceKey in this._cachingSequenceNodes$;
37417 * Get a value indicating if the graph is caching the tiles
37418 * required for calculating spatial edges of a node.
37420 * @param {string} key - Key of node.
37421 * @returns {boolean} Value indicating if the tiles of
37422 * a node are being cached.
37424 Graph.prototype.isCachingTiles = function (key) {
37425 return key in this._requiredNodeTiles &&
37426 this._requiredNodeTiles[key].cache.length === 0 &&
37427 this._requiredNodeTiles[key].caching.length > 0;
37430 * Get a value indicating if the cache has been initialized
37433 * @param {string} key - Key of node.
37434 * @returns {boolean} Value indicating if the cache has been
37435 * initialized for a node.
37437 Graph.prototype.hasInitializedCache = function (key) {
37438 return key in this._cachedNodes;
37441 * Get a value indicating if a node exist in the graph.
37443 * @param {string} key - Key of node.
37444 * @returns {boolean} Value indicating if a node exist in the graph.
37446 Graph.prototype.hasNode = function (key) {
37447 var accessed = new Date().getTime();
37448 this._updateCachedNodeAccess(key, accessed);
37449 this._updateCachedTileAccess(key, accessed);
37450 return key in this._nodes;
37453 * Get a value indicating if a node sequence exist in the graph.
37455 * @param {string} key - Key of node.
37456 * @returns {boolean} Value indicating if a node sequence exist
37459 Graph.prototype.hasNodeSequence = function (key) {
37460 var node = this.getNode(key);
37461 var sequenceKey = node.sequenceKey;
37462 var hasNodeSequence = sequenceKey in this._sequences;
37463 if (hasNodeSequence) {
37464 this._sequences[sequenceKey].accessed = new Date().getTime();
37466 return hasNodeSequence;
37469 * Get a value indicating if a sequence exist in the graph.
37471 * @param {string} sequenceKey - Key of sequence.
37472 * @returns {boolean} Value indicating if a sequence exist
37475 Graph.prototype.hasSequence = function (sequenceKey) {
37476 var hasSequence = sequenceKey in this._sequences;
37478 this._sequences[sequenceKey].accessed = new Date().getTime();
37480 return hasSequence;
37483 * Get a value indicating if sequence nodes has been cached in the graph.
37485 * @param {string} sequenceKey - Key of sequence.
37486 * @returns {boolean} Value indicating if a sequence nodes has been
37487 * cached in the graph.
37489 Graph.prototype.hasSequenceNodes = function (sequenceKey) {
37490 return sequenceKey in this._cachedSequenceNodes;
37493 * Get a value indicating if the graph has fully cached
37494 * all nodes in the spatial area of a node.
37496 * @param {string} key - Key of node.
37497 * @returns {boolean} Value indicating if the spatial area
37498 * of a node has been cached.
37500 Graph.prototype.hasSpatialArea = function (key) {
37501 if (!this.hasNode(key)) {
37502 throw new Error_1.GraphMapillaryError("Spatial area nodes cannot be determined if node not in graph (" + key + ").");
37504 if (key in this._cachedSpatialEdges) {
37507 if (key in this._requiredSpatialArea) {
37508 return Object.keys(this._requiredSpatialArea[key].cacheNodes).length === 0;
37510 var node = this.getNode(key);
37511 var bbox = this._graphCalculator.boundingBoxCorners(node.latLon, this._tileThreshold);
37512 var spatialItems = this._nodeIndex.search({
37518 var spatialNodes = {
37523 for (var _i = 0, spatialItems_1 = spatialItems; _i < spatialItems_1.length; _i++) {
37524 var spatialItem = spatialItems_1[_i];
37525 spatialNodes.all[spatialItem.node.key] = spatialItem.node;
37526 if (!spatialItem.node.full) {
37527 spatialNodes.cacheKeys.push(spatialItem.node.key);
37528 spatialNodes.cacheNodes[spatialItem.node.key] = spatialItem.node;
37531 this._requiredSpatialArea[key] = spatialNodes;
37532 return spatialNodes.cacheKeys.length === 0;
37535 * Get a value indicating if the graph has a tiles required
37538 * @param {string} key - Key of node.
37539 * @returns {boolean} Value indicating if the the tiles required
37540 * by a node has been cached.
37542 Graph.prototype.hasTiles = function (key) {
37544 if (key in this._cachedNodeTiles) {
37547 if (key in this._cachedSpatialEdges) {
37550 if (!this.hasNode(key)) {
37551 throw new Error_1.GraphMapillaryError("Node does not exist in graph (" + key + ").");
37553 var nodeTiles = { cache: [], caching: [] };
37554 if (!(key in this._requiredNodeTiles)) {
37555 var node = this.getNode(key);
37556 nodeTiles.cache = this._graphCalculator
37557 .encodeHs(node.latLon, this._tilePrecision, this._tileThreshold)
37558 .filter(function (h) {
37559 return !(h in _this._cachedTiles);
37561 if (nodeTiles.cache.length > 0) {
37562 this._requiredNodeTiles[key] = nodeTiles;
37566 nodeTiles = this._requiredNodeTiles[key];
37568 return nodeTiles.cache.length === 0 && nodeTiles.caching.length === 0;
37573 * @param {string} key - Key of node.
37574 * @returns {Node} Retrieved node.
37576 Graph.prototype.getNode = function (key) {
37577 var accessed = new Date().getTime();
37578 this._updateCachedNodeAccess(key, accessed);
37579 this._updateCachedTileAccess(key, accessed);
37580 return this._nodes[key];
37585 * @param {string} sequenceKey - Key of sequence.
37586 * @returns {Node} Retrieved sequence.
37588 Graph.prototype.getSequence = function (sequenceKey) {
37589 var sequenceAccess = this._sequences[sequenceKey];
37590 sequenceAccess.accessed = new Date().getTime();
37591 return sequenceAccess.sequence;
37594 * Reset all spatial edges of the graph nodes.
37596 Graph.prototype.resetSpatialEdges = function () {
37597 var cachedKeys = Object.keys(this._cachedSpatialEdges);
37598 for (var _i = 0, cachedKeys_1 = cachedKeys; _i < cachedKeys_1.length; _i++) {
37599 var cachedKey = cachedKeys_1[_i];
37600 var node = this._cachedSpatialEdges[cachedKey];
37601 node.resetSpatialEdges();
37602 delete this._cachedSpatialEdges[cachedKey];
37606 * Reset the complete graph but keep the nodes corresponding
37607 * to the supplied keys. All other nodes will be disposed.
37609 * @param {Array<string>} keepKeys - Keys for nodes to keep
37610 * in graph after reset.
37612 Graph.prototype.reset = function (keepKeys) {
37614 for (var _i = 0, keepKeys_1 = keepKeys; _i < keepKeys_1.length; _i++) {
37615 var key = keepKeys_1[_i];
37616 if (!this.hasNode(key)) {
37617 throw new Error("Node does not exist " + key);
37619 var node = this.getNode(key);
37620 node.resetSequenceEdges();
37621 node.resetSpatialEdges();
37624 for (var _a = 0, _b = Object.keys(this._cachedNodes); _a < _b.length; _a++) {
37625 var cachedKey = _b[_a];
37626 if (keepKeys.indexOf(cachedKey) !== -1) {
37629 this._cachedNodes[cachedKey].node.dispose();
37630 delete this._cachedNodes[cachedKey];
37632 this._cachedNodeTiles = {};
37633 this._cachedSpatialEdges = {};
37634 this._cachedTiles = {};
37635 this._cachingFill$ = {};
37636 this._cachingFull$ = {};
37637 this._cachingSequences$ = {};
37638 this._cachingSpatialArea$ = {};
37639 this._cachingTiles$ = {};
37641 this._nodeToTile = {};
37642 this._preStored = {};
37643 for (var _c = 0, nodes_2 = nodes; _c < nodes_2.length; _c++) {
37644 var node = nodes_2[_c];
37645 this._nodes[node.key] = node;
37646 var h = this._graphCalculator.encodeH(node.originalLatLon, this._tilePrecision);
37647 this._preStore(h, node);
37649 this._requiredNodeTiles = {};
37650 this._requiredSpatialArea = {};
37651 this._sequences = {};
37652 this._nodeIndexTiles = {};
37653 this._nodeIndex.clear();
37656 * Set the spatial node filter.
37658 * @param {FilterExpression} filter - Filter expression to be applied
37659 * when calculating spatial edges.
37661 Graph.prototype.setFilter = function (filter) {
37662 this._filter = this._filterCreator.createFilter(filter);
37665 * Uncache the graph according to the graph configuration.
37667 * @description Uncaches unused tiles, unused nodes and
37668 * sequences according to the numbers specified in the
37669 * graph configuration. Sequences does not have a direct
37670 * reference to either tiles or nodes and may be uncached
37671 * even if they are related to the nodes that should be kept.
37673 * @param {Array<string>} keepKeys - Keys of nodes to keep in
37674 * graph unrelated to last access. Tiles related to those keys
37675 * will also be kept in graph.
37676 * @param {string} keepSequenceKey - Optional key of sequence
37677 * for which the belonging nodes should not be disposed or
37678 * removed from the graph. These nodes may still be uncached if
37679 * not specified in keep keys param.
37681 Graph.prototype.uncache = function (keepKeys, keepSequenceKey) {
37682 var keysInUse = {};
37683 this._addNewKeys(keysInUse, this._cachingFull$);
37684 this._addNewKeys(keysInUse, this._cachingFill$);
37685 this._addNewKeys(keysInUse, this._cachingSpatialArea$);
37686 this._addNewKeys(keysInUse, this._requiredNodeTiles);
37687 this._addNewKeys(keysInUse, this._requiredSpatialArea);
37688 for (var _i = 0, keepKeys_2 = keepKeys; _i < keepKeys_2.length; _i++) {
37689 var key = keepKeys_2[_i];
37690 if (key in keysInUse) {
37693 keysInUse[key] = true;
37696 for (var key in keysInUse) {
37697 if (!keysInUse.hasOwnProperty(key)) {
37700 var node = this._nodes[key];
37701 var nodeHs = this._graphCalculator.encodeHs(node.latLon);
37702 for (var _a = 0, nodeHs_1 = nodeHs; _a < nodeHs_1.length; _a++) {
37703 var nodeH = nodeHs_1[_a];
37704 if (!(nodeH in keepHs)) {
37705 keepHs[nodeH] = true;
37709 var potentialHs = [];
37710 for (var h in this._cachedTiles) {
37711 if (!this._cachedTiles.hasOwnProperty(h) || h in keepHs) {
37714 potentialHs.push([h, this._cachedTiles[h]]);
37716 var uncacheHs = potentialHs
37717 .sort(function (h1, h2) {
37718 return h2[1].accessed - h1[1].accessed;
37720 .slice(this._configuration.maxUnusedTiles)
37721 .map(function (h) {
37724 for (var _b = 0, uncacheHs_1 = uncacheHs; _b < uncacheHs_1.length; _b++) {
37725 var uncacheH = uncacheHs_1[_b];
37726 this._uncacheTile(uncacheH, keepSequenceKey);
37728 var potentialPreStored = [];
37729 var nonCachedPreStored = [];
37730 for (var h in this._preStored) {
37731 if (!this._preStored.hasOwnProperty(h) || h in this._cachingTiles$) {
37734 var prestoredNodes = this._preStored[h];
37735 for (var key in prestoredNodes) {
37736 if (!prestoredNodes.hasOwnProperty(key) || key in keysInUse) {
37739 if (prestoredNodes[key].sequenceKey === keepSequenceKey) {
37742 if (key in this._cachedNodes) {
37743 potentialPreStored.push([this._cachedNodes[key], h]);
37746 nonCachedPreStored.push([key, h]);
37750 var uncachePreStored = potentialPreStored
37751 .sort(function (_a, _b) {
37752 var na1 = _a[0], h1 = _a[1];
37753 var na2 = _b[0], h2 = _b[1];
37754 return na2.accessed - na1.accessed;
37756 .slice(this._configuration.maxUnusedPreStoredNodes)
37757 .map(function (_a) {
37758 var na = _a[0], h = _a[1];
37759 return [na.node.key, h];
37761 this._uncachePreStored(nonCachedPreStored);
37762 this._uncachePreStored(uncachePreStored);
37763 var potentialNodes = [];
37764 for (var key in this._cachedNodes) {
37765 if (!this._cachedNodes.hasOwnProperty(key) || key in keysInUse) {
37768 potentialNodes.push(this._cachedNodes[key]);
37770 var uncacheNodes = potentialNodes
37771 .sort(function (n1, n2) {
37772 return n2.accessed - n1.accessed;
37774 .slice(this._configuration.maxUnusedNodes);
37775 for (var _c = 0, uncacheNodes_1 = uncacheNodes; _c < uncacheNodes_1.length; _c++) {
37776 var nodeAccess = uncacheNodes_1[_c];
37777 nodeAccess.node.uncache();
37778 var key = nodeAccess.node.key;
37779 delete this._cachedNodes[key];
37780 if (key in this._cachedNodeTiles) {
37781 delete this._cachedNodeTiles[key];
37783 if (key in this._cachedSpatialEdges) {
37784 delete this._cachedSpatialEdges[key];
37787 var potentialSequences = [];
37788 for (var sequenceKey in this._sequences) {
37789 if (!this._sequences.hasOwnProperty(sequenceKey) ||
37790 sequenceKey in this._cachingSequences$ ||
37791 sequenceKey === keepSequenceKey) {
37794 potentialSequences.push(this._sequences[sequenceKey]);
37796 var uncacheSequences = potentialSequences
37797 .sort(function (s1, s2) {
37798 return s2.accessed - s1.accessed;
37800 .slice(this._configuration.maxSequences);
37801 for (var _d = 0, uncacheSequences_1 = uncacheSequences; _d < uncacheSequences_1.length; _d++) {
37802 var sequenceAccess = uncacheSequences_1[_d];
37803 var sequenceKey = sequenceAccess.sequence.key;
37804 delete this._sequences[sequenceKey];
37805 if (sequenceKey in this._cachedSequenceNodes) {
37806 delete this._cachedSequenceNodes[sequenceKey];
37808 sequenceAccess.sequence.dispose();
37811 Graph.prototype._addNewKeys = function (keys, dict) {
37812 for (var key in dict) {
37813 if (!dict.hasOwnProperty(key) || !this.hasNode(key)) {
37816 if (!(key in keys)) {
37821 Graph.prototype._cacheSequence$ = function (sequenceKey) {
37823 if (sequenceKey in this._cachingSequences$) {
37824 return this._cachingSequences$[sequenceKey];
37826 this._cachingSequences$[sequenceKey] = this._apiV3.sequenceByKey$([sequenceKey]).pipe(operators_1.tap(function (sequenceByKey) {
37827 if (!(sequenceKey in _this._sequences)) {
37828 _this._sequences[sequenceKey] = {
37829 accessed: new Date().getTime(),
37830 sequence: new Graph_1.Sequence(sequenceByKey[sequenceKey]),
37833 delete _this._cachingSequences$[sequenceKey];
37834 }), operators_1.map(function (sequenceByKey) {
37836 }), operators_1.finalize(function () {
37837 if (sequenceKey in _this._cachingSequences$) {
37838 delete _this._cachingSequences$[sequenceKey];
37840 _this._changed$.next(_this);
37841 }), operators_1.publish(), operators_1.refCount());
37842 return this._cachingSequences$[sequenceKey];
37844 Graph.prototype._cacheTile$ = function (h) {
37846 this._cachingTiles$[h] = this._apiV3.imagesByH$([h]).pipe(operators_1.tap(function (imagesByH) {
37847 var coreNodes = imagesByH[h];
37848 if (h in _this._cachedTiles) {
37851 _this._nodeIndexTiles[h] = [];
37852 _this._cachedTiles[h] = { accessed: new Date().getTime(), nodes: [] };
37853 var hCache = _this._cachedTiles[h].nodes;
37854 var preStored = _this._removeFromPreStore(h);
37855 for (var index in coreNodes) {
37856 if (!coreNodes.hasOwnProperty(index)) {
37859 var coreNode = coreNodes[index];
37860 if (coreNode == null) {
37863 if (coreNode.sequence_key == null) {
37864 console.warn("Sequence missing, discarding node (" + coreNode.key + ")");
37867 if (preStored != null && coreNode.key in preStored) {
37868 var preStoredNode = preStored[coreNode.key];
37869 delete preStored[coreNode.key];
37870 hCache.push(preStoredNode);
37871 var preStoredNodeIndexItem = {
37872 lat: preStoredNode.latLon.lat,
37873 lon: preStoredNode.latLon.lon,
37874 node: preStoredNode,
37876 _this._nodeIndex.insert(preStoredNodeIndexItem);
37877 _this._nodeIndexTiles[h].push(preStoredNodeIndexItem);
37878 _this._nodeToTile[preStoredNode.key] = h;
37881 var node = new Graph_1.Node(coreNode);
37883 var nodeIndexItem = {
37884 lat: node.latLon.lat,
37885 lon: node.latLon.lon,
37888 _this._nodeIndex.insert(nodeIndexItem);
37889 _this._nodeIndexTiles[h].push(nodeIndexItem);
37890 _this._nodeToTile[node.key] = h;
37891 _this._setNode(node);
37893 delete _this._cachingTiles$[h];
37894 }), operators_1.map(function (imagesByH) {
37896 }), operators_1.catchError(function (error) {
37897 delete _this._cachingTiles$[h];
37899 }), operators_1.publish(), operators_1.refCount());
37900 return this._cachingTiles$[h];
37902 Graph.prototype._makeFull = function (node, fillNode) {
37903 if (fillNode.calt == null) {
37904 fillNode.calt = this._defaultAlt;
37906 if (fillNode.c_rotation == null) {
37907 fillNode.c_rotation = this._graphCalculator.rotationFromCompass(fillNode.ca, fillNode.orientation);
37909 node.makeFull(fillNode);
37911 Graph.prototype._preStore = function (h, node) {
37912 if (!(h in this._preStored)) {
37913 this._preStored[h] = {};
37915 this._preStored[h][node.key] = node;
37917 Graph.prototype._removeFromPreStore = function (h) {
37918 var preStored = null;
37919 if (h in this._preStored) {
37920 preStored = this._preStored[h];
37921 delete this._preStored[h];
37925 Graph.prototype._setNode = function (node) {
37926 var key = node.key;
37927 if (this.hasNode(key)) {
37928 throw new Error_1.GraphMapillaryError("Node already exist (" + key + ").");
37930 this._nodes[key] = node;
37932 Graph.prototype._uncacheTile = function (h, keepSequenceKey) {
37933 for (var _i = 0, _a = this._cachedTiles[h].nodes; _i < _a.length; _i++) {
37935 var key = node.key;
37936 delete this._nodeToTile[key];
37937 if (key in this._cachedNodes) {
37938 delete this._cachedNodes[key];
37940 if (key in this._cachedNodeTiles) {
37941 delete this._cachedNodeTiles[key];
37943 if (key in this._cachedSpatialEdges) {
37944 delete this._cachedSpatialEdges[key];
37946 if (node.sequenceKey === keepSequenceKey) {
37947 this._preStore(h, node);
37951 delete this._nodes[key];
37952 if (node.sequenceKey in this._cachedSequenceNodes) {
37953 delete this._cachedSequenceNodes[node.sequenceKey];
37958 for (var _b = 0, _c = this._nodeIndexTiles[h]; _b < _c.length; _b++) {
37959 var nodeIndexItem = _c[_b];
37960 this._nodeIndex.remove(nodeIndexItem);
37962 delete this._nodeIndexTiles[h];
37963 delete this._cachedTiles[h];
37965 Graph.prototype._uncachePreStored = function (preStored) {
37967 for (var _i = 0, preStored_1 = preStored; _i < preStored_1.length; _i++) {
37968 var _a = preStored_1[_i], key = _a[0], h = _a[1];
37969 if (key in this._nodes) {
37970 delete this._nodes[key];
37972 if (key in this._cachedNodes) {
37973 delete this._cachedNodes[key];
37975 var node = this._preStored[h][key];
37976 if (node.sequenceKey in this._cachedSequenceNodes) {
37977 delete this._cachedSequenceNodes[node.sequenceKey];
37979 delete this._preStored[h][key];
37983 for (var h in hs) {
37984 if (!hs.hasOwnProperty(h)) {
37987 if (Object.keys(this._preStored[h]).length === 0) {
37988 delete this._preStored[h];
37992 Graph.prototype._updateCachedTileAccess = function (key, accessed) {
37993 if (key in this._nodeToTile) {
37994 this._cachedTiles[this._nodeToTile[key]].accessed = accessed;
37997 Graph.prototype._updateCachedNodeAccess = function (key, accessed) {
37998 if (key in this._cachedNodes) {
37999 this._cachedNodes[key].accessed = accessed;
38004 exports.Graph = Graph;
38005 exports.default = Graph;
38007 },{"../Edge":275,"../Error":276,"../Graph":278,"rbush":25,"rxjs":26,"rxjs/operators":224}],390:[function(require,module,exports){
38009 Object.defineProperty(exports, "__esModule", { value: true });
38010 var geohash = require("latlon-geohash");
38011 var THREE = require("three");
38012 var Error_1 = require("../Error");
38013 var Geo_1 = require("../Geo");
38015 * @class GraphCalculator
38017 * @classdesc Represents a calculator for graph entities.
38019 var GraphCalculator = /** @class */ (function () {
38021 * Create a new graph calculator instance.
38023 * @param {GeoCoords} geoCoords - Geo coords instance.
38025 function GraphCalculator(geoCoords) {
38026 this._geoCoords = geoCoords != null ? geoCoords : new Geo_1.GeoCoords();
38029 * Encode the geohash tile for geodetic coordinates.
38031 * @param {ILatLon} latlon - Latitude and longitude to encode.
38032 * @param {number} precision - Precision of the encoding.
38034 * @returns {string} The geohash tile for the lat, lon and precision.
38036 GraphCalculator.prototype.encodeH = function (latLon, precision) {
38037 if (precision === void 0) { precision = 7; }
38038 return geohash.encode(latLon.lat, latLon.lon, precision);
38041 * Encode the geohash tiles within a threshold from a position
38042 * using Manhattan distance.
38044 * @param {ILatLon} latlon - Latitude and longitude to encode.
38045 * @param {number} precision - Precision of the encoding.
38046 * @param {number} threshold - Threshold of the encoding in meters.
38048 * @returns {string} The geohash tiles reachable within the threshold.
38050 GraphCalculator.prototype.encodeHs = function (latLon, precision, threshold) {
38051 if (precision === void 0) { precision = 7; }
38052 if (threshold === void 0) { threshold = 20; }
38053 var h = geohash.encode(latLon.lat, latLon.lon, precision);
38054 var bounds = geohash.bounds(h);
38055 var ne = bounds.ne;
38056 var sw = bounds.sw;
38057 var neighbours = geohash.neighbours(h);
38058 var bl = [0, 0, 0];
38059 var tr = this._geoCoords.geodeticToEnu(ne.lat, ne.lon, 0, sw.lat, sw.lon, 0);
38060 var position = this._geoCoords.geodeticToEnu(latLon.lat, latLon.lon, 0, sw.lat, sw.lon, 0);
38061 var left = position[0] - bl[0];
38062 var right = tr[0] - position[0];
38063 var bottom = position[1] - bl[1];
38064 var top = tr[1] - position[1];
38065 var l = left < threshold;
38066 var r = right < threshold;
38067 var b = bottom < threshold;
38068 var t = top < threshold;
38071 hs.push(neighbours.n);
38074 hs.push(neighbours.nw);
38077 hs.push(neighbours.w);
38080 hs.push(neighbours.sw);
38083 hs.push(neighbours.s);
38086 hs.push(neighbours.se);
38089 hs.push(neighbours.e);
38092 hs.push(neighbours.ne);
38097 * Encode the minimum set of geohash tiles containing a bounding box.
38099 * @description The current algorithm does expect the bounding box
38100 * to be sufficiently small to be contained in an area with the size
38101 * of maximally four tiles. Up to nine adjacent tiles may be returned.
38102 * The method currently uses the largest side as the threshold leading to
38103 * more tiles being returned than needed in edge cases.
38105 * @param {ILatLon} sw - South west corner of bounding box.
38106 * @param {ILatLon} ne - North east corner of bounding box.
38107 * @param {number} precision - Precision of the encoding.
38109 * @returns {string} The geohash tiles containing the bounding box.
38111 GraphCalculator.prototype.encodeHsFromBoundingBox = function (sw, ne, precision) {
38112 if (precision === void 0) { precision = 7; }
38113 if (ne.lat <= sw.lat || ne.lon <= sw.lon) {
38114 throw new Error_1.GraphMapillaryError("North east needs to be top right of south west");
38116 var centerLat = (sw.lat + ne.lat) / 2;
38117 var centerLon = (sw.lon + ne.lon) / 2;
38118 var enu = this._geoCoords.geodeticToEnu(ne.lat, ne.lon, 0, centerLat, centerLon, 0);
38119 var threshold = Math.max(enu[0], enu[1]);
38120 return this.encodeHs({ lat: centerLat, lon: centerLon }, precision, threshold);
38123 * Get the bounding box corners for a circle with radius of a threshold
38124 * with center in a geodetic position.
38126 * @param {ILatLon} latlon - Latitude and longitude to encode.
38127 * @param {number} threshold - Threshold distance from the position in meters.
38129 * @returns {Array<ILatLon>} The south west and north east corners of the
38132 GraphCalculator.prototype.boundingBoxCorners = function (latLon, threshold) {
38133 var bl = this._geoCoords.enuToGeodetic(-threshold, -threshold, 0, latLon.lat, latLon.lon, 0);
38134 var tr = this._geoCoords.enuToGeodetic(threshold, threshold, 0, latLon.lat, latLon.lon, 0);
38136 { lat: bl[0], lon: bl[1] },
38137 { lat: tr[0], lon: tr[1] },
38141 * Convert a compass angle to an angle axis rotation vector.
38143 * @param {number} compassAngle - The compass angle in degrees.
38144 * @param {number} orientation - The orientation of the original image.
38146 * @returns {Array<number>} Angle axis rotation vector.
38148 GraphCalculator.prototype.rotationFromCompass = function (compassAngle, orientation) {
38152 switch (orientation) {
38171 var rz = new THREE.Matrix4().makeRotationZ(z);
38172 var euler = new THREE.Euler(x, y, compassAngle * Math.PI / 180, "XYZ");
38173 var re = new THREE.Matrix4().makeRotationFromEuler(euler);
38174 var rotation = new THREE.Vector4().setAxisAngleFromRotationMatrix(re.multiply(rz));
38175 return rotation.multiplyScalar(rotation.w).toArray().slice(0, 3);
38177 return GraphCalculator;
38179 exports.GraphCalculator = GraphCalculator;
38180 exports.default = GraphCalculator;
38182 },{"../Error":276,"../Geo":277,"latlon-geohash":21,"three":225}],391:[function(require,module,exports){
38184 Object.defineProperty(exports, "__esModule", { value: true });
38186 * Enumeration for graph modes.
38189 * @description Modes for the retrieval and caching performed
38190 * by the graph service on the graph.
38193 (function (GraphMode) {
38195 * Caching is performed on sequences only and sequence edges are
38196 * calculated. Spatial tiles
38197 * are not retrieved and spatial edges are not calculated when
38198 * caching nodes. Complete sequences are being cached for requested
38199 * nodes within the graph.
38201 GraphMode[GraphMode["Sequence"] = 0] = "Sequence";
38203 * Caching is performed with emphasis on spatial data. Sequence edges
38204 * as well as spatial edges are cached. Sequence data
38205 * is still requested but complete sequences are not being cached
38206 * for requested nodes.
38208 * This is the initial mode of the graph service.
38210 GraphMode[GraphMode["Spatial"] = 1] = "Spatial";
38211 })(GraphMode = exports.GraphMode || (exports.GraphMode = {}));
38212 exports.default = GraphMode;
38214 },{}],392:[function(require,module,exports){
38216 Object.defineProperty(exports, "__esModule", { value: true });
38217 var rxjs_1 = require("rxjs");
38218 var operators_1 = require("rxjs/operators");
38219 var Graph_1 = require("../Graph");
38221 * @class GraphService
38223 * @classdesc Represents a service for graph operations.
38225 var GraphService = /** @class */ (function () {
38227 * Create a new graph service instance.
38229 * @param {Graph} graph - Graph instance to be operated on.
38231 function GraphService(graph, imageLoadingService) {
38232 this._graph$ = rxjs_1.concat(rxjs_1.of(graph), graph.changed$).pipe(operators_1.publishReplay(1), operators_1.refCount());
38233 this._graph$.subscribe(function () { });
38234 this._graphMode = Graph_1.GraphMode.Spatial;
38235 this._graphModeSubject$ = new rxjs_1.Subject();
38236 this._graphMode$ = this._graphModeSubject$.pipe(operators_1.startWith(this._graphMode), operators_1.publishReplay(1), operators_1.refCount());
38237 this._graphMode$.subscribe(function () { });
38238 this._imageLoadingService = imageLoadingService;
38239 this._firstGraphSubjects$ = [];
38240 this._initializeCacheSubscriptions = [];
38241 this._sequenceSubscriptions = [];
38242 this._spatialSubscriptions = [];
38244 Object.defineProperty(GraphService.prototype, "graphMode$", {
38246 * Get graph mode observable.
38248 * @description Emits the current graph mode.
38250 * @returns {Observable<GraphMode>} Observable
38251 * emitting the current graph mode when it changes.
38254 return this._graphMode$;
38260 * Cache full nodes in a bounding box.
38262 * @description When called, the full properties of
38263 * the node are retrieved. The node cache is not initialized
38264 * for any new nodes retrieved and the node assets are not
38265 * retrieved, {@link cacheNode$} needs to be called for caching
38268 * @param {ILatLon} sw - South west corner of bounding box.
38269 * @param {ILatLon} ne - North east corner of bounding box.
38270 * @return {Observable<Array<Node>>} Observable emitting a single item,
38271 * the nodes of the bounding box, when they have all been retrieved.
38272 * @throws {Error} Propagates any IO node caching errors to the caller.
38274 GraphService.prototype.cacheBoundingBox$ = function (sw, ne) {
38275 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
38276 return graph.cacheBoundingBox$(sw, ne);
38280 * Cache a node in the graph and retrieve it.
38282 * @description When called, the full properties of
38283 * the node are retrieved and the node cache is initialized.
38284 * After that the node assets are cached and the node
38285 * is emitted to the observable when.
38286 * In parallel to caching the node assets, the sequence and
38287 * spatial edges of the node are cached. For this, the sequence
38288 * of the node and the required tiles and spatial nodes are
38289 * retrieved. The sequence and spatial edges may be set before
38290 * or after the node is returned.
38292 * @param {string} key - Key of the node to cache.
38293 * @return {Observable<Node>} Observable emitting a single item,
38294 * the node, when it has been retrieved and its assets are cached.
38295 * @throws {Error} Propagates any IO node caching errors to the caller.
38297 GraphService.prototype.cacheNode$ = function (key) {
38299 var firstGraphSubject$ = new rxjs_1.Subject();
38300 this._firstGraphSubjects$.push(firstGraphSubject$);
38301 var firstGraph$ = firstGraphSubject$.pipe(operators_1.publishReplay(1), operators_1.refCount());
38302 var node$ = firstGraph$.pipe(operators_1.map(function (graph) {
38303 return graph.getNode(key);
38304 }), operators_1.mergeMap(function (node) {
38305 return node.assetsCached ?
38307 node.cacheAssets$();
38308 }), operators_1.publishReplay(1), operators_1.refCount());
38309 node$.subscribe(function (node) {
38310 _this._imageLoadingService.loadnode$.next(node);
38311 }, function (error) {
38312 console.error("Failed to cache node (" + key + ")", error);
38314 var initializeCacheSubscription = this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
38315 if (graph.isCachingFull(key) || !graph.hasNode(key)) {
38316 return graph.cacheFull$(key);
38318 if (graph.isCachingFill(key) || !graph.getNode(key).full) {
38319 return graph.cacheFill$(key);
38321 return rxjs_1.of(graph);
38322 }), operators_1.tap(function (graph) {
38323 if (!graph.hasInitializedCache(key)) {
38324 graph.initializeCache(key);
38326 }), operators_1.finalize(function () {
38327 if (initializeCacheSubscription == null) {
38330 _this._removeFromArray(initializeCacheSubscription, _this._initializeCacheSubscriptions);
38331 _this._removeFromArray(firstGraphSubject$, _this._firstGraphSubjects$);
38333 .subscribe(function (graph) {
38334 firstGraphSubject$.next(graph);
38335 firstGraphSubject$.complete();
38336 }, function (error) {
38337 firstGraphSubject$.error(error);
38339 if (!initializeCacheSubscription.closed) {
38340 this._initializeCacheSubscriptions.push(initializeCacheSubscription);
38342 var graphSequence$ = firstGraph$.pipe(operators_1.mergeMap(function (graph) {
38343 if (graph.isCachingNodeSequence(key) || !graph.hasNodeSequence(key)) {
38344 return graph.cacheNodeSequence$(key);
38346 return rxjs_1.of(graph);
38347 }), operators_1.publishReplay(1), operators_1.refCount());
38348 var sequenceSubscription = graphSequence$.pipe(operators_1.tap(function (graph) {
38349 if (!graph.getNode(key).sequenceEdges.cached) {
38350 graph.cacheSequenceEdges(key);
38352 }), operators_1.finalize(function () {
38353 if (sequenceSubscription == null) {
38356 _this._removeFromArray(sequenceSubscription, _this._sequenceSubscriptions);
38358 .subscribe(function (graph) { return; }, function (error) {
38359 console.error("Failed to cache sequence edges (" + key + ").", error);
38361 if (!sequenceSubscription.closed) {
38362 this._sequenceSubscriptions.push(sequenceSubscription);
38364 if (this._graphMode === Graph_1.GraphMode.Spatial) {
38365 var spatialSubscription_1 = firstGraph$.pipe(operators_1.expand(function (graph) {
38366 if (graph.hasTiles(key)) {
38367 return rxjs_1.empty();
38369 return rxjs_1.from(graph.cacheTiles$(key)).pipe(operators_1.mergeMap(function (graph$) {
38370 return graph$.pipe(operators_1.mergeMap(function (g) {
38371 if (g.isCachingTiles(key)) {
38372 return rxjs_1.empty();
38374 return rxjs_1.of(g);
38375 }), operators_1.catchError(function (error, caught$) {
38376 console.error("Failed to cache tile data (" + key + ").", error);
38377 return rxjs_1.empty();
38380 }), operators_1.last(), operators_1.mergeMap(function (graph) {
38381 if (graph.hasSpatialArea(key)) {
38382 return rxjs_1.of(graph);
38384 return rxjs_1.from(graph.cacheSpatialArea$(key)).pipe(operators_1.mergeMap(function (graph$) {
38385 return graph$.pipe(operators_1.catchError(function (error, caught$) {
38386 console.error("Failed to cache spatial nodes (" + key + ").", error);
38387 return rxjs_1.empty();
38390 }), operators_1.last(), operators_1.mergeMap(function (graph) {
38391 return graph.hasNodeSequence(key) ?
38393 graph.cacheNodeSequence$(key);
38394 }), operators_1.tap(function (graph) {
38395 if (!graph.getNode(key).spatialEdges.cached) {
38396 graph.cacheSpatialEdges(key);
38398 }), operators_1.finalize(function () {
38399 if (spatialSubscription_1 == null) {
38402 _this._removeFromArray(spatialSubscription_1, _this._spatialSubscriptions);
38404 .subscribe(function (graph) { return; }, function (error) {
38405 console.error("Failed to cache spatial edges (" + key + ").", error);
38407 if (!spatialSubscription_1.closed) {
38408 this._spatialSubscriptions.push(spatialSubscription_1);
38411 return node$.pipe(operators_1.first(function (node) {
38412 return node.assetsCached;
38416 * Cache a sequence in the graph and retrieve it.
38418 * @param {string} sequenceKey - Sequence key.
38419 * @returns {Observable<Sequence>} Observable emitting a single item,
38420 * the sequence, when it has been retrieved and its assets are cached.
38421 * @throws {Error} Propagates any IO node caching errors to the caller.
38423 GraphService.prototype.cacheSequence$ = function (sequenceKey) {
38424 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
38425 if (graph.isCachingSequence(sequenceKey) || !graph.hasSequence(sequenceKey)) {
38426 return graph.cacheSequence$(sequenceKey);
38428 return rxjs_1.of(graph);
38429 }), operators_1.map(function (graph) {
38430 return graph.getSequence(sequenceKey);
38434 * Cache a sequence and its nodes in the graph and retrieve the sequence.
38436 * @description Caches a sequence and its assets are cached and
38437 * retrieves all nodes belonging to the sequence. The node assets
38438 * or edges will not be cached.
38440 * @param {string} sequenceKey - Sequence key.
38441 * @param {string} referenceNodeKey - Key of node to use as reference
38442 * for optimized caching.
38443 * @returns {Observable<Sequence>} Observable emitting a single item,
38444 * the sequence, when it has been retrieved, its assets are cached and
38445 * all nodes belonging to the sequence has been retrieved.
38446 * @throws {Error} Propagates any IO node caching errors to the caller.
38448 GraphService.prototype.cacheSequenceNodes$ = function (sequenceKey, referenceNodeKey) {
38449 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
38450 if (graph.isCachingSequence(sequenceKey) || !graph.hasSequence(sequenceKey)) {
38451 return graph.cacheSequence$(sequenceKey);
38453 return rxjs_1.of(graph);
38454 }), operators_1.mergeMap(function (graph) {
38455 if (graph.isCachingSequenceNodes(sequenceKey) || !graph.hasSequenceNodes(sequenceKey)) {
38456 return graph.cacheSequenceNodes$(sequenceKey, referenceNodeKey);
38458 return rxjs_1.of(graph);
38459 }), operators_1.map(function (graph) {
38460 return graph.getSequence(sequenceKey);
38464 * Set a spatial edge filter on the graph.
38466 * @description Resets the spatial edges of all cached nodes.
38468 * @param {FilterExpression} filter - Filter expression to be applied.
38469 * @return {Observable<Graph>} Observable emitting a single item,
38470 * the graph, when the spatial edges have been reset.
38472 GraphService.prototype.setFilter$ = function (filter) {
38473 this._resetSubscriptions(this._spatialSubscriptions);
38474 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
38475 graph.resetSpatialEdges();
38476 graph.setFilter(filter);
38477 }), operators_1.map(function (graph) {
38482 * Set the graph mode.
38484 * @description If graph mode is set to spatial, caching
38485 * is performed with emphasis on spatial edges. If graph
38486 * mode is set to sequence no tile data is requested and
38487 * no spatial edges are computed.
38489 * When setting graph mode to sequence all spatial
38490 * subscriptions are aborted.
38492 * @param {GraphMode} mode - Graph mode to set.
38494 GraphService.prototype.setGraphMode = function (mode) {
38495 if (this._graphMode === mode) {
38498 if (mode === Graph_1.GraphMode.Sequence) {
38499 this._resetSubscriptions(this._spatialSubscriptions);
38501 this._graphMode = mode;
38502 this._graphModeSubject$.next(this._graphMode);
38507 * @description Resets the graph but keeps the nodes of the
38510 * @param {Array<string>} keepKeys - Keys of nodes to keep in graph.
38511 * @return {Observable<Node>} Observable emitting a single item,
38512 * the graph, when it has been reset.
38514 GraphService.prototype.reset$ = function (keepKeys) {
38515 this._abortSubjects(this._firstGraphSubjects$);
38516 this._resetSubscriptions(this._initializeCacheSubscriptions);
38517 this._resetSubscriptions(this._sequenceSubscriptions);
38518 this._resetSubscriptions(this._spatialSubscriptions);
38519 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
38520 graph.reset(keepKeys);
38521 }), operators_1.map(function (graph) {
38526 * Uncache the graph.
38528 * @description Uncaches the graph by removing tiles, nodes and
38529 * sequences. Keeps the nodes of the supplied keys and the tiles
38530 * related to those nodes.
38532 * @param {Array<string>} keepKeys - Keys of nodes to keep in graph.
38533 * @param {string} keepSequenceKey - Optional key of sequence
38534 * for which the belonging nodes should not be disposed or
38535 * removed from the graph. These nodes may still be uncached if
38536 * not specified in keep keys param.
38537 * @return {Observable<Graph>} Observable emitting a single item,
38538 * the graph, when the graph has been uncached.
38540 GraphService.prototype.uncache$ = function (keepKeys, keepSequenceKey) {
38541 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
38542 graph.uncache(keepKeys, keepSequenceKey);
38543 }), operators_1.map(function (graph) {
38547 GraphService.prototype._abortSubjects = function (subjects) {
38548 for (var _i = 0, _a = subjects.slice(); _i < _a.length; _i++) {
38549 var subject = _a[_i];
38550 this._removeFromArray(subject, subjects);
38551 subject.error(new Error("Cache node request was aborted."));
38554 GraphService.prototype._removeFromArray = function (object, objects) {
38555 var index = objects.indexOf(object);
38556 if (index !== -1) {
38557 objects.splice(index, 1);
38560 GraphService.prototype._resetSubscriptions = function (subscriptions) {
38561 for (var _i = 0, _a = subscriptions.slice(); _i < _a.length; _i++) {
38562 var subscription = _a[_i];
38563 this._removeFromArray(subscription, subscriptions);
38564 if (!subscription.closed) {
38565 subscription.unsubscribe();
38569 return GraphService;
38571 exports.GraphService = GraphService;
38572 exports.default = GraphService;
38574 },{"../Graph":278,"rxjs":26,"rxjs/operators":224}],393:[function(require,module,exports){
38576 Object.defineProperty(exports, "__esModule", { value: true });
38577 var operators_1 = require("rxjs/operators");
38578 var rxjs_1 = require("rxjs");
38579 var ImageLoadingService = /** @class */ (function () {
38580 function ImageLoadingService() {
38581 this._loadnode$ = new rxjs_1.Subject();
38582 this._loadstatus$ = this._loadnode$.pipe(operators_1.scan(function (_a, node) {
38584 var changed = false;
38585 if (node.loadStatus.total === 0 || node.loadStatus.loaded === node.loadStatus.total) {
38586 if (node.key in nodes) {
38587 delete nodes[node.key];
38592 nodes[node.key] = node.loadStatus;
38595 return [nodes, changed];
38596 }, [{}, false]), operators_1.filter(function (_a) {
38597 var nodes = _a[0], changed = _a[1];
38599 }), operators_1.map(function (_a) {
38602 }), operators_1.publishReplay(1), operators_1.refCount());
38603 this._loadstatus$.subscribe(function () { });
38605 Object.defineProperty(ImageLoadingService.prototype, "loadnode$", {
38607 return this._loadnode$;
38612 Object.defineProperty(ImageLoadingService.prototype, "loadstatus$", {
38614 return this._loadstatus$;
38619 return ImageLoadingService;
38621 exports.ImageLoadingService = ImageLoadingService;
38623 },{"rxjs":26,"rxjs/operators":224}],394:[function(require,module,exports){
38625 Object.defineProperty(exports, "__esModule", { value: true });
38626 var Pbf = require("pbf");
38627 var MeshReader = /** @class */ (function () {
38628 function MeshReader() {
38630 MeshReader.read = function (buffer) {
38631 var pbf = new Pbf(buffer);
38632 return pbf.readFields(MeshReader._readMeshField, { faces: [], vertices: [] });
38634 MeshReader._readMeshField = function (tag, mesh, pbf) {
38636 mesh.vertices.push(pbf.readFloat());
38638 else if (tag === 2) {
38639 mesh.faces.push(pbf.readVarint());
38644 exports.MeshReader = MeshReader;
38646 },{"pbf":23}],395:[function(require,module,exports){
38648 Object.defineProperty(exports, "__esModule", { value: true });
38649 var operators_1 = require("rxjs/operators");
38653 * @classdesc Represents a node in the navigation graph.
38655 * Explanation of position and bearing properties:
38657 * When images are uploaded they will have GPS information in the EXIF, this is what
38658 * is called `originalLatLon` {@link Node.originalLatLon}.
38660 * When Structure from Motions has been run for a node a `computedLatLon` that
38661 * differs from the `originalLatLon` will be created. It is different because
38662 * GPS positions are not very exact and SfM aligns the camera positions according
38663 * to the 3D reconstruction {@link Node.computedLatLon}.
38665 * At last there exist a `latLon` property which evaluates to
38666 * the `computedLatLon` from SfM if it exists but falls back
38667 * to the `originalLatLon` from the EXIF GPS otherwise {@link Node.latLon}.
38669 * Everything that is done in in the Viewer is based on the SfM positions,
38670 * i.e. `computedLatLon`. That is why the smooth transitions go in the right
38671 * direction (nd not in strange directions because of bad GPS).
38673 * E.g. when placing a marker in the Viewer it is relative to the SfM
38674 * position i.e. the `computedLatLon`.
38676 * The same concept as above also applies to the compass angle (or bearing) properties
38677 * `originalCa`, `computedCa` and `ca`.
38679 var Node = /** @class */ (function () {
38681 * Create a new node instance.
38683 * @description Nodes are always created internally by the library.
38684 * Nodes can not be added to the library through any API method.
38686 * @param {ICoreNode} coreNode - Raw core node data.
38689 function Node(core) {
38690 this._cache = null;
38694 Object.defineProperty(Node.prototype, "assetsCached", {
38696 * Get assets cached.
38698 * @description The assets that need to be cached for this property
38699 * to report true are the following: fill properties, image and mesh.
38700 * The library ensures that the current node will always have the
38703 * @returns {boolean} Value indicating whether all assets have been
38709 return this._core != null &&
38710 this._fill != null &&
38711 this._cache != null &&
38712 this._cache.image != null &&
38713 this._cache.mesh != null;
38718 Object.defineProperty(Node.prototype, "alt", {
38722 * @description If SfM has not been run the computed altitude is
38723 * set to a default value of two meters.
38725 * @returns {number} Altitude, in meters.
38728 return this._fill.calt;
38733 Object.defineProperty(Node.prototype, "ca", {
38737 * @description If the SfM computed compass angle exists it will
38738 * be returned, otherwise the original EXIF compass angle.
38740 * @returns {number} Compass angle, measured in degrees
38741 * clockwise with respect to north.
38744 return this._fill.cca != null ? this._fill.cca : this._fill.ca;
38749 Object.defineProperty(Node.prototype, "capturedAt", {
38753 * @returns {number} Timestamp when the image was captured.
38756 return this._fill.captured_at;
38761 Object.defineProperty(Node.prototype, "cameraUuid", {
38765 * @description Will be undefined if the camera uuid was not
38766 * recorded in the image exif information.
38768 * @returns {string} Universally unique id for camera used
38769 * when capturing image.
38772 return this._fill.captured_with_camera_uuid;
38777 Object.defineProperty(Node.prototype, "ck1", {
38781 * @description Will not be set if SfM has not been run.
38783 * @returns {number} SfM computed radial distortion parameter
38787 return this._fill.ck1;
38792 Object.defineProperty(Node.prototype, "ck2", {
38796 * @description Will not be set if SfM has not been run.
38798 * @returns {number} SfM computed radial distortion parameter
38802 return this._fill.ck2;
38807 Object.defineProperty(Node.prototype, "computedCA", {
38811 * @description Will not be set if SfM has not been run.
38813 * @returns {number} SfM computed compass angle, measured
38814 * in degrees clockwise with respect to north.
38817 return this._fill.cca;
38822 Object.defineProperty(Node.prototype, "computedLatLon", {
38824 * Get computedLatLon.
38826 * @description Will not be set if SfM has not been run.
38828 * @returns {ILatLon} SfM computed latitude longitude in WGS84 datum,
38829 * measured in degrees.
38832 return this._core.cl;
38837 Object.defineProperty(Node.prototype, "focal", {
38841 * @description Will not be set if SfM has not been run.
38843 * @returns {number} SfM computed focal length.
38846 return this._fill.cfocal;
38851 Object.defineProperty(Node.prototype, "full", {
38855 * @description The library ensures that the current node will
38858 * @returns {boolean} Value indicating whether the node has all
38859 * properties filled.
38864 return this._fill != null;
38869 Object.defineProperty(Node.prototype, "fullPano", {
38873 * @returns {boolean} Value indicating whether the node is a complete
38877 return this._fill.gpano != null &&
38878 this._fill.gpano.CroppedAreaLeftPixels === 0 &&
38879 this._fill.gpano.CroppedAreaTopPixels === 0 &&
38880 this._fill.gpano.CroppedAreaImageWidthPixels === this._fill.gpano.FullPanoWidthPixels &&
38881 this._fill.gpano.CroppedAreaImageHeightPixels === this._fill.gpano.FullPanoHeightPixels;
38886 Object.defineProperty(Node.prototype, "gpano", {
38890 * @description Will not be set for non panoramic images.
38892 * @returns {IGPano} Panorama information for panorama images.
38895 return this._fill.gpano;
38900 Object.defineProperty(Node.prototype, "height", {
38904 * @returns {number} Height of original image, not adjusted
38908 return this._fill.height;
38913 Object.defineProperty(Node.prototype, "image", {
38917 * @description The image will always be set on the current node.
38919 * @returns {HTMLImageElement} Cached image element of the node.
38922 return this._cache.image;
38927 Object.defineProperty(Node.prototype, "image$", {
38931 * @returns {Observable<HTMLImageElement>} Observable emitting
38932 * the cached image when it is updated.
38937 return this._cache.image$;
38942 Object.defineProperty(Node.prototype, "key", {
38946 * @returns {string} Unique key of the node.
38949 return this._core.key;
38954 Object.defineProperty(Node.prototype, "latLon", {
38958 * @description If the SfM computed latitude longitude exist
38959 * it will be returned, otherwise the original EXIF latitude
38962 * @returns {ILatLon} Latitude longitude in WGS84 datum,
38963 * measured in degrees.
38966 return this._core.cl != null ? this._core.cl : this._core.l;
38971 Object.defineProperty(Node.prototype, "loadStatus", {
38975 * @returns {ILoadStatus} Value indicating the load status
38976 * of the mesh and image.
38979 return this._cache.loadStatus;
38984 Object.defineProperty(Node.prototype, "merged", {
38988 * @returns {boolean} Value indicating whether SfM has been
38989 * run on the node and the node has been merged into a
38990 * connected component.
38993 return this._fill != null &&
38994 this._fill.merge_version != null &&
38995 this._fill.merge_version > 0;
39000 Object.defineProperty(Node.prototype, "mergeCC", {
39004 * @description Will not be set if SfM has not yet been run on
39007 * @returns {number} SfM connected component key to which
39011 return this._fill.merge_cc;
39016 Object.defineProperty(Node.prototype, "mergeVersion", {
39018 * Get mergeVersion.
39020 * @returns {number} Version for which SfM was run and image was merged.
39023 return this._fill.merge_version;
39028 Object.defineProperty(Node.prototype, "mesh", {
39032 * @description The mesh will always be set on the current node.
39034 * @returns {IMesh} SfM triangulated mesh of reconstructed
39035 * atomic 3D points.
39038 return this._cache.mesh;
39043 Object.defineProperty(Node.prototype, "organizationKey", {
39045 * Get organizationKey.
39047 * @returns {string} Unique key of the organization to which
39048 * the node belongs. If the node does not belong to an
39049 * organization the organization key will be undefined.
39052 return this._fill.organization_key;
39057 Object.defineProperty(Node.prototype, "orientation", {
39061 * @returns {number} EXIF orientation of original image.
39064 return this._fill.orientation;
39069 Object.defineProperty(Node.prototype, "originalCA", {
39073 * @returns {number} Original EXIF compass angle, measured in
39077 return this._fill.ca;
39082 Object.defineProperty(Node.prototype, "originalLatLon", {
39084 * Get originalLatLon.
39086 * @returns {ILatLon} Original EXIF latitude longitude in
39087 * WGS84 datum, measured in degrees.
39090 return this._core.l;
39095 Object.defineProperty(Node.prototype, "pano", {
39099 * @returns {boolean} Value indicating whether the node is a panorama.
39100 * It could be a cropped or full panorama.
39103 return this._fill.gpano != null &&
39104 this._fill.gpano.FullPanoWidthPixels != null;
39109 Object.defineProperty(Node.prototype, "private", {
39113 * @returns {boolean} Value specifying if image is accessible to
39114 * organization members only or to everyone.
39117 return this._fill.private;
39122 Object.defineProperty(Node.prototype, "projectKey", {
39126 * @returns {string} Unique key of the project to which
39127 * the node belongs. If the node does not belong to a
39128 * project the project key will be undefined.
39130 * @deprecated This property will be deprecated in favor
39131 * of the organization key and private properties.
39134 return this._fill.project != null ?
39135 this._fill.project.key :
39141 Object.defineProperty(Node.prototype, "rotation", {
39145 * @description Will not be set if SfM has not been run.
39147 * @returns {Array<number>} Rotation vector in angle axis representation.
39150 return this._fill.c_rotation;
39155 Object.defineProperty(Node.prototype, "scale", {
39159 * @description Will not be set if SfM has not been run.
39161 * @returns {number} Scale of atomic reconstruction.
39164 return this._fill.atomic_scale;
39169 Object.defineProperty(Node.prototype, "sequenceKey", {
39173 * @returns {string} Unique key of the sequence to which
39174 * the node belongs.
39177 return this._core.sequence_key;
39182 Object.defineProperty(Node.prototype, "sequenceEdges", {
39184 * Get sequenceEdges.
39186 * @returns {IEdgeStatus} Value describing the status of the
39190 return this._cache.sequenceEdges;
39195 Object.defineProperty(Node.prototype, "sequenceEdges$", {
39197 * Get sequenceEdges$.
39199 * @description Internal observable, should not be used as an API.
39201 * @returns {Observable<IEdgeStatus>} Observable emitting
39202 * values describing the status of the sequence edges.
39207 return this._cache.sequenceEdges$;
39212 Object.defineProperty(Node.prototype, "spatialEdges", {
39214 * Get spatialEdges.
39216 * @returns {IEdgeStatus} Value describing the status of the
39220 return this._cache.spatialEdges;
39225 Object.defineProperty(Node.prototype, "spatialEdges$", {
39227 * Get spatialEdges$.
39229 * @description Internal observable, should not be used as an API.
39231 * @returns {Observable<IEdgeStatus>} Observable emitting
39232 * values describing the status of the spatial edges.
39237 return this._cache.spatialEdges$;
39242 Object.defineProperty(Node.prototype, "userKey", {
39246 * @returns {string} Unique key of the user who uploaded
39250 return this._fill.user.key;
39255 Object.defineProperty(Node.prototype, "username", {
39259 * @returns {string} Username of the user who uploaded
39263 return this._fill.user.username;
39268 Object.defineProperty(Node.prototype, "width", {
39272 * @returns {number} Width of original image, not
39273 * adjusted for orientation.
39276 return this._fill.width;
39282 * Cache the image and mesh assets.
39284 * @description The assets are always cached internally by the
39285 * library prior to setting a node as the current node.
39287 * @returns {Observable<Node>} Observable emitting this node whenever the
39288 * load status has changed and when the mesh or image has been fully loaded.
39292 Node.prototype.cacheAssets$ = function () {
39294 return this._cache.cacheAssets$(this.key, this.pano, this.merged).pipe(operators_1.map(function () {
39299 * Cache the image asset.
39301 * @description Use for caching a differently sized image than
39302 * the one currently held by the node.
39304 * @returns {Observable<Node>} Observable emitting this node whenever the
39305 * load status has changed and when the mesh or image has been fully loaded.
39309 Node.prototype.cacheImage$ = function (imageSize) {
39311 return this._cache.cacheImage$(this.key, imageSize).pipe(operators_1.map(function () {
39316 * Cache the sequence edges.
39318 * @description The sequence edges are cached asynchronously
39319 * internally by the library.
39321 * @param {Array<IEdge>} edges - Sequence edges to cache.
39324 Node.prototype.cacheSequenceEdges = function (edges) {
39325 this._cache.cacheSequenceEdges(edges);
39328 * Cache the spatial edges.
39330 * @description The spatial edges are cached asynchronously
39331 * internally by the library.
39333 * @param {Array<IEdge>} edges - Spatial edges to cache.
39336 Node.prototype.cacheSpatialEdges = function (edges) {
39337 this._cache.cacheSpatialEdges(edges);
39340 * Dispose the node.
39342 * @description Disposes all cached assets.
39345 Node.prototype.dispose = function () {
39346 if (this._cache != null) {
39347 this._cache.dispose();
39348 this._cache = null;
39354 * Initialize the node cache.
39356 * @description The node cache is initialized internally by
39359 * @param {NodeCache} cache - The node cache to set as cache.
39362 Node.prototype.initializeCache = function (cache) {
39363 if (this._cache != null) {
39364 throw new Error("Node cache already initialized (" + this.key + ").");
39366 this._cache = cache;
39369 * Fill the node with all properties.
39371 * @description The node is filled internally by
39374 * @param {IFillNode} fill - The fill node struct.
39377 Node.prototype.makeFull = function (fill) {
39378 if (fill == null) {
39379 throw new Error("Fill can not be null.");
39384 * Reset the sequence edges.
39388 Node.prototype.resetSequenceEdges = function () {
39389 this._cache.resetSequenceEdges();
39392 * Reset the spatial edges.
39396 Node.prototype.resetSpatialEdges = function () {
39397 this._cache.resetSpatialEdges();
39400 * Clears the image and mesh assets, aborts
39401 * any outstanding requests and resets edges.
39405 Node.prototype.uncache = function () {
39406 if (this._cache == null) {
39409 this._cache.dispose();
39410 this._cache = null;
39414 exports.Node = Node;
39415 exports.default = Node;
39417 },{"rxjs/operators":224}],396:[function(require,module,exports){
39418 (function (Buffer){
39420 Object.defineProperty(exports, "__esModule", { value: true });
39421 var rxjs_1 = require("rxjs");
39422 var operators_1 = require("rxjs/operators");
39423 var Graph_1 = require("../Graph");
39424 var Utils_1 = require("../Utils");
39428 * @classdesc Represents the cached properties of a node.
39430 var NodeCache = /** @class */ (function () {
39432 * Create a new node cache instance.
39434 function NodeCache() {
39435 this._disposed = false;
39436 this._image = null;
39437 this._loadStatus = { loaded: 0, total: 0 };
39439 this._sequenceEdges = { cached: false, edges: [] };
39440 this._spatialEdges = { cached: false, edges: [] };
39441 this._imageChanged$ = new rxjs_1.Subject();
39442 this._image$ = this._imageChanged$.pipe(operators_1.startWith(null), operators_1.publishReplay(1), operators_1.refCount());
39443 this._iamgeSubscription = this._image$.subscribe();
39444 this._sequenceEdgesChanged$ = new rxjs_1.Subject();
39445 this._sequenceEdges$ = this._sequenceEdgesChanged$.pipe(operators_1.startWith(this._sequenceEdges), operators_1.publishReplay(1), operators_1.refCount());
39446 this._sequenceEdgesSubscription = this._sequenceEdges$.subscribe(function () { });
39447 this._spatialEdgesChanged$ = new rxjs_1.Subject();
39448 this._spatialEdges$ = this._spatialEdgesChanged$.pipe(operators_1.startWith(this._spatialEdges), operators_1.publishReplay(1), operators_1.refCount());
39449 this._spatialEdgesSubscription = this._spatialEdges$.subscribe(function () { });
39450 this._cachingAssets$ = null;
39452 Object.defineProperty(NodeCache.prototype, "image", {
39456 * @description Will not be set when assets have not been cached
39457 * or when the object has been disposed.
39459 * @returns {HTMLImageElement} Cached image element of the node.
39462 return this._image;
39467 Object.defineProperty(NodeCache.prototype, "image$", {
39471 * @returns {Observable<HTMLImageElement>} Observable emitting
39472 * the cached image when it is updated.
39475 return this._image$;
39480 Object.defineProperty(NodeCache.prototype, "loadStatus", {
39484 * @returns {ILoadStatus} Value indicating the load status
39485 * of the mesh and image.
39488 return this._loadStatus;
39493 Object.defineProperty(NodeCache.prototype, "mesh", {
39497 * @description Will not be set when assets have not been cached
39498 * or when the object has been disposed.
39500 * @returns {IMesh} SfM triangulated mesh of reconstructed
39501 * atomic 3D points.
39509 Object.defineProperty(NodeCache.prototype, "sequenceEdges", {
39511 * Get sequenceEdges.
39513 * @returns {IEdgeStatus} Value describing the status of the
39517 return this._sequenceEdges;
39522 Object.defineProperty(NodeCache.prototype, "sequenceEdges$", {
39524 * Get sequenceEdges$.
39526 * @returns {Observable<IEdgeStatus>} Observable emitting
39527 * values describing the status of the sequence edges.
39530 return this._sequenceEdges$;
39535 Object.defineProperty(NodeCache.prototype, "spatialEdges", {
39537 * Get spatialEdges.
39539 * @returns {IEdgeStatus} Value describing the status of the
39543 return this._spatialEdges;
39548 Object.defineProperty(NodeCache.prototype, "spatialEdges$", {
39550 * Get spatialEdges$.
39552 * @returns {Observable<IEdgeStatus>} Observable emitting
39553 * values describing the status of the spatial edges.
39556 return this._spatialEdges$;
39562 * Cache the image and mesh assets.
39564 * @param {string} key - Key of the node to cache.
39565 * @param {boolean} pano - Value indicating whether node is a panorama.
39566 * @param {boolean} merged - Value indicating whether node is merged.
39567 * @returns {Observable<NodeCache>} Observable emitting this node
39568 * cache whenever the load status has changed and when the mesh or image
39569 * has been fully loaded.
39571 NodeCache.prototype.cacheAssets$ = function (key, pano, merged) {
39573 if (this._cachingAssets$ != null) {
39574 return this._cachingAssets$;
39576 var imageSize = pano ?
39577 Utils_1.Settings.basePanoramaSize :
39578 Utils_1.Settings.baseImageSize;
39579 this._cachingAssets$ = rxjs_1.combineLatest(this._cacheImage$(key, imageSize), this._cacheMesh$(key, merged)).pipe(operators_1.map(function (_a) {
39580 var imageStatus = _a[0], meshStatus = _a[1];
39581 _this._loadStatus.loaded = 0;
39582 _this._loadStatus.total = 0;
39584 _this._mesh = meshStatus.object;
39585 _this._loadStatus.loaded += meshStatus.loaded.loaded;
39586 _this._loadStatus.total += meshStatus.loaded.total;
39589 _this._image = imageStatus.object;
39590 _this._loadStatus.loaded += imageStatus.loaded.loaded;
39591 _this._loadStatus.total += imageStatus.loaded.total;
39594 }), operators_1.finalize(function () {
39595 _this._cachingAssets$ = null;
39596 }), operators_1.publishReplay(1), operators_1.refCount());
39597 this._cachingAssets$.pipe(operators_1.first(function (nodeCache) {
39598 return !!nodeCache._image;
39600 .subscribe(function (nodeCache) {
39601 _this._imageChanged$.next(_this._image);
39602 }, function (error) { });
39603 return this._cachingAssets$;
39606 * Cache an image with a higher resolution than the current one.
39608 * @param {string} key - Key of the node to cache.
39609 * @param {ImageSize} imageSize - The size to cache.
39610 * @returns {Observable<NodeCache>} Observable emitting a single item,
39611 * the node cache, when the image has been cached. If supplied image
39612 * size is not larger than the current image size the node cache is
39613 * returned immediately.
39615 NodeCache.prototype.cacheImage$ = function (key, imageSize) {
39617 if (this._image != null && imageSize <= Math.max(this._image.width, this._image.height)) {
39618 return rxjs_1.of(this);
39620 var cacheImage$ = this._cacheImage$(key, imageSize).pipe(operators_1.first(function (status) {
39621 return status.object != null;
39622 }), operators_1.tap(function (status) {
39623 _this._disposeImage();
39624 _this._image = status.object;
39625 }), operators_1.map(function (imageStatus) {
39627 }), operators_1.publishReplay(1), operators_1.refCount());
39629 .subscribe(function (nodeCache) {
39630 _this._imageChanged$.next(_this._image);
39631 }, function (error) { });
39632 return cacheImage$;
39635 * Cache the sequence edges.
39637 * @param {Array<IEdge>} edges - Sequence edges to cache.
39639 NodeCache.prototype.cacheSequenceEdges = function (edges) {
39640 this._sequenceEdges = { cached: true, edges: edges };
39641 this._sequenceEdgesChanged$.next(this._sequenceEdges);
39644 * Cache the spatial edges.
39646 * @param {Array<IEdge>} edges - Spatial edges to cache.
39648 NodeCache.prototype.cacheSpatialEdges = function (edges) {
39649 this._spatialEdges = { cached: true, edges: edges };
39650 this._spatialEdgesChanged$.next(this._spatialEdges);
39653 * Dispose the node cache.
39655 * @description Disposes all cached assets and unsubscribes to
39658 NodeCache.prototype.dispose = function () {
39659 this._iamgeSubscription.unsubscribe();
39660 this._sequenceEdgesSubscription.unsubscribe();
39661 this._spatialEdgesSubscription.unsubscribe();
39662 this._disposeImage();
39664 this._loadStatus.loaded = 0;
39665 this._loadStatus.total = 0;
39666 this._sequenceEdges = { cached: false, edges: [] };
39667 this._spatialEdges = { cached: false, edges: [] };
39668 this._imageChanged$.next(null);
39669 this._sequenceEdgesChanged$.next(this._sequenceEdges);
39670 this._spatialEdgesChanged$.next(this._spatialEdges);
39671 this._disposed = true;
39672 if (this._imageRequest != null) {
39673 this._imageRequest.abort();
39675 if (this._meshRequest != null) {
39676 this._meshRequest.abort();
39680 * Reset the sequence edges.
39682 NodeCache.prototype.resetSequenceEdges = function () {
39683 this._sequenceEdges = { cached: false, edges: [] };
39684 this._sequenceEdgesChanged$.next(this._sequenceEdges);
39687 * Reset the spatial edges.
39689 NodeCache.prototype.resetSpatialEdges = function () {
39690 this._spatialEdges = { cached: false, edges: [] };
39691 this._spatialEdgesChanged$.next(this._spatialEdges);
39696 * @param {string} key - Key of the node to cache.
39697 * @param {boolean} pano - Value indicating whether node is a panorama.
39698 * @returns {Observable<ILoadStatusObject<HTMLImageElement>>} Observable
39699 * emitting a load status object every time the load status changes
39700 * and completes when the image is fully loaded.
39702 NodeCache.prototype._cacheImage$ = function (key, imageSize) {
39704 return rxjs_1.Observable.create(function (subscriber) {
39705 var xmlHTTP = new XMLHttpRequest();
39706 xmlHTTP.open("GET", Utils_1.Urls.thumbnail(key, imageSize, Utils_1.Urls.origin), true);
39707 xmlHTTP.responseType = "arraybuffer";
39708 xmlHTTP.timeout = 15000;
39709 xmlHTTP.onload = function (pe) {
39710 if (xmlHTTP.status !== 200) {
39711 _this._imageRequest = null;
39712 subscriber.error(new Error("Failed to fetch image (" + key + "). Status: " + xmlHTTP.status + ", " + xmlHTTP.statusText));
39715 var image = new Image();
39716 image.crossOrigin = "Anonymous";
39717 image.onload = function (e) {
39718 _this._imageRequest = null;
39719 if (_this._disposed) {
39720 window.URL.revokeObjectURL(image.src);
39721 subscriber.error(new Error("Image load was aborted (" + key + ")"));
39724 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: image });
39725 subscriber.complete();
39727 image.onerror = function (error) {
39728 _this._imageRequest = null;
39729 subscriber.error(new Error("Failed to load image (" + key + ")"));
39731 var blob = new Blob([xmlHTTP.response]);
39732 image.src = window.URL.createObjectURL(blob);
39734 xmlHTTP.onprogress = function (pe) {
39735 if (_this._disposed) {
39738 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: null });
39740 xmlHTTP.onerror = function (error) {
39741 _this._imageRequest = null;
39742 subscriber.error(new Error("Failed to fetch image (" + key + ")"));
39744 xmlHTTP.ontimeout = function (e) {
39745 _this._imageRequest = null;
39746 subscriber.error(new Error("Image request timed out (" + key + ")"));
39748 xmlHTTP.onabort = function (event) {
39749 _this._imageRequest = null;
39750 subscriber.error(new Error("Image request was aborted (" + key + ")"));
39752 _this._imageRequest = xmlHTTP;
39753 xmlHTTP.send(null);
39759 * @param {string} key - Key of the node to cache.
39760 * @param {boolean} merged - Value indicating whether node is merged.
39761 * @returns {Observable<ILoadStatusObject<IMesh>>} Observable emitting
39762 * a load status object every time the load status changes and completes
39763 * when the mesh is fully loaded.
39765 NodeCache.prototype._cacheMesh$ = function (key, merged) {
39767 return rxjs_1.Observable.create(function (subscriber) {
39769 subscriber.next(_this._createEmptyMeshLoadStatus());
39770 subscriber.complete();
39773 var xmlHTTP = new XMLHttpRequest();
39774 xmlHTTP.open("GET", Utils_1.Urls.protoMesh(key), true);
39775 xmlHTTP.responseType = "arraybuffer";
39776 xmlHTTP.timeout = 15000;
39777 xmlHTTP.onload = function (pe) {
39778 _this._meshRequest = null;
39779 if (_this._disposed) {
39782 var mesh = xmlHTTP.status === 200 ?
39783 Graph_1.MeshReader.read(new Buffer(xmlHTTP.response)) :
39784 { faces: [], vertices: [] };
39785 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: mesh });
39786 subscriber.complete();
39788 xmlHTTP.onprogress = function (pe) {
39789 if (_this._disposed) {
39792 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: null });
39794 xmlHTTP.onerror = function (e) {
39795 _this._meshRequest = null;
39796 console.error("Failed to cache mesh (" + key + ")");
39797 subscriber.next(_this._createEmptyMeshLoadStatus());
39798 subscriber.complete();
39800 xmlHTTP.ontimeout = function (e) {
39801 _this._meshRequest = null;
39802 console.error("Mesh request timed out (" + key + ")");
39803 subscriber.next(_this._createEmptyMeshLoadStatus());
39804 subscriber.complete();
39806 xmlHTTP.onabort = function (e) {
39807 _this._meshRequest = null;
39808 subscriber.error(new Error("Mesh request was aborted (" + key + ")"));
39810 _this._meshRequest = xmlHTTP;
39811 xmlHTTP.send(null);
39815 * Create a load status object with an empty mesh.
39817 * @returns {ILoadStatusObject<IMesh>} Load status object
39820 NodeCache.prototype._createEmptyMeshLoadStatus = function () {
39822 loaded: { loaded: 0, total: 0 },
39823 object: { faces: [], vertices: [] },
39826 NodeCache.prototype._disposeImage = function () {
39827 if (this._image != null) {
39828 window.URL.revokeObjectURL(this._image.src);
39830 this._image = null;
39834 exports.NodeCache = NodeCache;
39835 exports.default = NodeCache;
39837 }).call(this,require("buffer").Buffer)
39839 },{"../Graph":278,"../Utils":284,"buffer":7,"rxjs":26,"rxjs/operators":224}],397:[function(require,module,exports){
39841 Object.defineProperty(exports, "__esModule", { value: true });
39845 * @classdesc Represents a sequence of ordered nodes.
39847 var Sequence = /** @class */ (function () {
39849 * Create a new sequene instance.
39851 * @param {ISequence} sequence - Raw sequence data.
39853 function Sequence(sequence) {
39854 this._key = sequence.key;
39855 this._keys = sequence.keys;
39857 Object.defineProperty(Sequence.prototype, "key", {
39861 * @returns {string} Unique sequence key.
39869 Object.defineProperty(Sequence.prototype, "keys", {
39873 * @returns {Array<string>} Array of ordered node keys in the sequence.
39882 * Dispose the sequence.
39884 * @description Disposes all cached assets.
39886 Sequence.prototype.dispose = function () {
39891 * Find the next node key in the sequence with respect to
39892 * the provided node key.
39894 * @param {string} key - Reference node key.
39895 * @returns {string} Next key in sequence if it exists, null otherwise.
39897 Sequence.prototype.findNextKey = function (key) {
39898 var i = this._keys.indexOf(key);
39899 if ((i + 1) >= this._keys.length || i === -1) {
39903 return this._keys[i + 1];
39907 * Find the previous node key in the sequence with respect to
39908 * the provided node key.
39910 * @param {string} key - Reference node key.
39911 * @returns {string} Previous key in sequence if it exists, null otherwise.
39913 Sequence.prototype.findPrevKey = function (key) {
39914 var i = this._keys.indexOf(key);
39915 if (i === 0 || i === -1) {
39919 return this._keys[i - 1];
39924 exports.Sequence = Sequence;
39925 exports.default = Sequence;
39927 },{}],398:[function(require,module,exports){
39929 Object.defineProperty(exports, "__esModule", { value: true });
39930 var THREE = require("three");
39931 var Edge_1 = require("../../Edge");
39932 var Error_1 = require("../../Error");
39933 var Geo_1 = require("../../Geo");
39935 * @class EdgeCalculator
39937 * @classdesc Represents a class for calculating node edges.
39939 var EdgeCalculator = /** @class */ (function () {
39941 * Create a new edge calculator instance.
39943 * @param {EdgeCalculatorSettings} settings - Settings struct.
39944 * @param {EdgeCalculatorDirections} directions - Directions struct.
39945 * @param {EdgeCalculatorCoefficients} coefficients - Coefficients struct.
39947 function EdgeCalculator(settings, directions, coefficients) {
39948 this._spatial = new Geo_1.Spatial();
39949 this._geoCoords = new Geo_1.GeoCoords();
39950 this._settings = settings != null ? settings : new Edge_1.EdgeCalculatorSettings();
39951 this._directions = directions != null ? directions : new Edge_1.EdgeCalculatorDirections();
39952 this._coefficients = coefficients != null ? coefficients : new Edge_1.EdgeCalculatorCoefficients();
39955 * Returns the potential edges to destination nodes for a set
39956 * of nodes with respect to a source node.
39958 * @param {Node} node - Source node.
39959 * @param {Array<Node>} nodes - Potential destination nodes.
39960 * @param {Array<string>} fallbackKeys - Keys for destination nodes that should
39961 * be returned even if they do not meet the criteria for a potential edge.
39962 * @throws {ArgumentMapillaryError} If node is not full.
39964 EdgeCalculator.prototype.getPotentialEdges = function (node, potentialNodes, fallbackKeys) {
39966 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
39968 if (!node.merged) {
39971 var currentDirection = this._spatial.viewingDirection(node.rotation);
39972 var currentVerticalDirection = this._spatial.angleToPlane(currentDirection.toArray(), [0, 0, 1]);
39973 var potentialEdges = [];
39974 for (var _i = 0, potentialNodes_1 = potentialNodes; _i < potentialNodes_1.length; _i++) {
39975 var potential = potentialNodes_1[_i];
39976 if (!potential.merged ||
39977 potential.key === node.key) {
39980 var enu = this._geoCoords.geodeticToEnu(potential.latLon.lat, potential.latLon.lon, potential.alt, node.latLon.lat, node.latLon.lon, node.alt);
39981 var motion = new THREE.Vector3(enu[0], enu[1], enu[2]);
39982 var distance = motion.length();
39983 if (distance > this._settings.maxDistance &&
39984 fallbackKeys.indexOf(potential.key) < 0) {
39987 var motionChange = this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, motion.x, motion.y);
39988 var verticalMotion = this._spatial.angleToPlane(motion.toArray(), [0, 0, 1]);
39989 var direction = this._spatial.viewingDirection(potential.rotation);
39990 var directionChange = this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, direction.x, direction.y);
39991 var verticalDirection = this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
39992 var verticalDirectionChange = verticalDirection - currentVerticalDirection;
39993 var rotation = this._spatial.relativeRotationAngle(node.rotation, potential.rotation);
39994 var worldMotionAzimuth = this._spatial.angleBetweenVector2(1, 0, motion.x, motion.y);
39995 var sameSequence = potential.sequenceKey != null &&
39996 node.sequenceKey != null &&
39997 potential.sequenceKey === node.sequenceKey;
39998 var sameMergeCC = (potential.mergeCC == null && node.mergeCC == null) ||
39999 potential.mergeCC === node.mergeCC;
40000 var sameUser = potential.userKey === node.userKey;
40001 var potentialEdge = {
40002 capturedAt: potential.capturedAt,
40003 croppedPano: potential.pano && !potential.fullPano,
40004 directionChange: directionChange,
40005 distance: distance,
40006 fullPano: potential.fullPano,
40007 key: potential.key,
40008 motionChange: motionChange,
40009 rotation: rotation,
40010 sameMergeCC: sameMergeCC,
40011 sameSequence: sameSequence,
40012 sameUser: sameUser,
40013 sequenceKey: potential.sequenceKey,
40014 verticalDirectionChange: verticalDirectionChange,
40015 verticalMotion: verticalMotion,
40016 worldMotionAzimuth: worldMotionAzimuth,
40018 potentialEdges.push(potentialEdge);
40020 return potentialEdges;
40023 * Computes the sequence edges for a node.
40025 * @param {Node} node - Source node.
40026 * @throws {ArgumentMapillaryError} If node is not full.
40028 EdgeCalculator.prototype.computeSequenceEdges = function (node, sequence) {
40030 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
40032 if (node.sequenceKey !== sequence.key) {
40033 throw new Error_1.ArgumentMapillaryError("Node and sequence does not correspond.");
40036 var nextKey = sequence.findNextKey(node.key);
40037 if (nextKey != null) {
40040 direction: Edge_1.EdgeDirection.Next,
40041 worldMotionAzimuth: Number.NaN,
40047 var prevKey = sequence.findPrevKey(node.key);
40048 if (prevKey != null) {
40051 direction: Edge_1.EdgeDirection.Prev,
40052 worldMotionAzimuth: Number.NaN,
40061 * Computes the similar edges for a node.
40063 * @description Similar edges for perspective images and cropped panoramas
40064 * look roughly in the same direction and are positioned closed to the node.
40065 * Similar edges for full panoramas only target other full panoramas.
40067 * @param {Node} node - Source node.
40068 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
40069 * @throws {ArgumentMapillaryError} If node is not full.
40071 EdgeCalculator.prototype.computeSimilarEdges = function (node, potentialEdges) {
40074 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
40076 var nodeFullPano = node.fullPano;
40077 var sequenceGroups = {};
40078 for (var _i = 0, potentialEdges_1 = potentialEdges; _i < potentialEdges_1.length; _i++) {
40079 var potentialEdge = potentialEdges_1[_i];
40080 if (potentialEdge.sequenceKey == null) {
40083 if (potentialEdge.sameSequence) {
40086 if (nodeFullPano) {
40087 if (!potentialEdge.fullPano) {
40092 if (!potentialEdge.fullPano &&
40093 Math.abs(potentialEdge.directionChange) > this._settings.similarMaxDirectionChange) {
40097 if (potentialEdge.distance > this._settings.similarMaxDistance) {
40100 if (potentialEdge.sameUser &&
40101 Math.abs(potentialEdge.capturedAt - node.capturedAt) <
40102 this._settings.similarMinTimeDifference) {
40105 if (sequenceGroups[potentialEdge.sequenceKey] == null) {
40106 sequenceGroups[potentialEdge.sequenceKey] = [];
40108 sequenceGroups[potentialEdge.sequenceKey].push(potentialEdge);
40110 var similarEdges = [];
40111 var calculateScore = node.fullPano ?
40112 function (potentialEdge) {
40113 return potentialEdge.distance;
40115 function (potentialEdge) {
40116 return _this._coefficients.similarDistance * potentialEdge.distance +
40117 _this._coefficients.similarRotation * potentialEdge.rotation;
40119 for (var sequenceKey in sequenceGroups) {
40120 if (!sequenceGroups.hasOwnProperty(sequenceKey)) {
40123 var lowestScore = Number.MAX_VALUE;
40124 var similarEdge = null;
40125 for (var _a = 0, _b = sequenceGroups[sequenceKey]; _a < _b.length; _a++) {
40126 var potentialEdge = _b[_a];
40127 var score = calculateScore(potentialEdge);
40128 if (score < lowestScore) {
40129 lowestScore = score;
40130 similarEdge = potentialEdge;
40133 if (similarEdge == null) {
40136 similarEdges.push(similarEdge);
40138 return similarEdges
40139 .map(function (potentialEdge) {
40142 direction: Edge_1.EdgeDirection.Similar,
40143 worldMotionAzimuth: potentialEdge.worldMotionAzimuth,
40146 to: potentialEdge.key,
40151 * Computes the step edges for a perspective node.
40153 * @description Step edge targets can only be other perspective nodes.
40154 * Returns an empty array for cropped and full panoramas.
40156 * @param {Node} node - Source node.
40157 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
40158 * @param {string} prevKey - Key of previous node in sequence.
40159 * @param {string} prevKey - Key of next node in sequence.
40160 * @throws {ArgumentMapillaryError} If node is not full.
40162 EdgeCalculator.prototype.computeStepEdges = function (node, potentialEdges, prevKey, nextKey) {
40164 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
40170 for (var k in this._directions.steps) {
40171 if (!this._directions.steps.hasOwnProperty(k)) {
40174 var step = this._directions.steps[k];
40175 var lowestScore = Number.MAX_VALUE;
40177 var fallback = null;
40178 for (var _i = 0, potentialEdges_2 = potentialEdges; _i < potentialEdges_2.length; _i++) {
40179 var potential = potentialEdges_2[_i];
40180 if (potential.croppedPano || potential.fullPano) {
40183 if (Math.abs(potential.directionChange) > this._settings.stepMaxDirectionChange) {
40186 var motionDifference = this._spatial.angleDifference(step.motionChange, potential.motionChange);
40187 var directionMotionDifference = this._spatial.angleDifference(potential.directionChange, motionDifference);
40188 var drift = Math.max(Math.abs(motionDifference), Math.abs(directionMotionDifference));
40189 if (Math.abs(drift) > this._settings.stepMaxDrift) {
40192 var potentialKey = potential.key;
40193 if (step.useFallback && (potentialKey === prevKey || potentialKey === nextKey)) {
40194 fallback = potential;
40196 if (potential.distance > this._settings.stepMaxDistance) {
40199 motionDifference = Math.sqrt(motionDifference * motionDifference +
40200 potential.verticalMotion * potential.verticalMotion);
40201 var score = this._coefficients.stepPreferredDistance *
40202 Math.abs(potential.distance - this._settings.stepPreferredDistance) /
40203 this._settings.stepMaxDistance +
40204 this._coefficients.stepMotion * motionDifference / this._settings.stepMaxDrift +
40205 this._coefficients.stepRotation * potential.rotation / this._settings.stepMaxDirectionChange +
40206 this._coefficients.stepSequencePenalty * (potential.sameSequence ? 0 : 1) +
40207 this._coefficients.stepMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
40208 if (score < lowestScore) {
40209 lowestScore = score;
40213 edge = edge == null ? fallback : edge;
40214 if (edge != null) {
40217 direction: step.direction,
40218 worldMotionAzimuth: edge.worldMotionAzimuth,
40228 * Computes the turn edges for a perspective node.
40230 * @description Turn edge targets can only be other perspective images.
40231 * Returns an empty array for cropped and full panoramas.
40233 * @param {Node} node - Source node.
40234 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
40235 * @throws {ArgumentMapillaryError} If node is not full.
40237 EdgeCalculator.prototype.computeTurnEdges = function (node, potentialEdges) {
40239 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
40245 for (var k in this._directions.turns) {
40246 if (!this._directions.turns.hasOwnProperty(k)) {
40249 var turn = this._directions.turns[k];
40250 var lowestScore = Number.MAX_VALUE;
40252 for (var _i = 0, potentialEdges_3 = potentialEdges; _i < potentialEdges_3.length; _i++) {
40253 var potential = potentialEdges_3[_i];
40254 if (potential.croppedPano || potential.fullPano) {
40257 if (potential.distance > this._settings.turnMaxDistance) {
40260 var rig = turn.direction !== Edge_1.EdgeDirection.TurnU &&
40261 potential.distance < this._settings.turnMaxRigDistance &&
40262 Math.abs(potential.directionChange) > this._settings.turnMinRigDirectionChange;
40263 var directionDifference = this._spatial.angleDifference(turn.directionChange, potential.directionChange);
40264 var score = void 0;
40266 potential.directionChange * turn.directionChange > 0 &&
40267 Math.abs(potential.directionChange) < Math.abs(turn.directionChange)) {
40268 score = -Math.PI / 2 + Math.abs(potential.directionChange);
40271 if (Math.abs(directionDifference) > this._settings.turnMaxDirectionChange) {
40274 var motionDifference = turn.motionChange ?
40275 this._spatial.angleDifference(turn.motionChange, potential.motionChange) : 0;
40276 motionDifference = Math.sqrt(motionDifference * motionDifference +
40277 potential.verticalMotion * potential.verticalMotion);
40279 this._coefficients.turnDistance * potential.distance /
40280 this._settings.turnMaxDistance +
40281 this._coefficients.turnMotion * motionDifference / Math.PI +
40282 this._coefficients.turnSequencePenalty * (potential.sameSequence ? 0 : 1) +
40283 this._coefficients.turnMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
40285 if (score < lowestScore) {
40286 lowestScore = score;
40290 if (edge != null) {
40293 direction: turn.direction,
40294 worldMotionAzimuth: edge.worldMotionAzimuth,
40304 * Computes the pano edges for a perspective node.
40306 * @description Perspective to pano edge targets can only be
40307 * full pano nodes. Returns an empty array for cropped and full panoramas.
40309 * @param {Node} node - Source node.
40310 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
40311 * @throws {ArgumentMapillaryError} If node is not full.
40313 EdgeCalculator.prototype.computePerspectiveToPanoEdges = function (node, potentialEdges) {
40315 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
40320 var lowestScore = Number.MAX_VALUE;
40322 for (var _i = 0, potentialEdges_4 = potentialEdges; _i < potentialEdges_4.length; _i++) {
40323 var potential = potentialEdges_4[_i];
40324 if (!potential.fullPano) {
40327 var score = this._coefficients.panoPreferredDistance *
40328 Math.abs(potential.distance - this._settings.panoPreferredDistance) /
40329 this._settings.panoMaxDistance +
40330 this._coefficients.panoMotion * Math.abs(potential.motionChange) / Math.PI +
40331 this._coefficients.panoMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
40332 if (score < lowestScore) {
40333 lowestScore = score;
40337 if (edge == null) {
40343 direction: Edge_1.EdgeDirection.Pano,
40344 worldMotionAzimuth: edge.worldMotionAzimuth,
40352 * Computes the full pano and step edges for a full pano node.
40354 * @description Pano to pano edge targets can only be
40355 * full pano nodes. Pano to step edge targets can only be perspective
40357 * Returns an empty array for cropped panoramas and perspective nodes.
40359 * @param {Node} node - Source node.
40360 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
40361 * @throws {ArgumentMapillaryError} If node is not full.
40363 EdgeCalculator.prototype.computePanoEdges = function (node, potentialEdges) {
40365 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
40367 if (!node.fullPano) {
40370 var panoEdges = [];
40371 var potentialPanos = [];
40372 var potentialSteps = [];
40373 for (var _i = 0, potentialEdges_5 = potentialEdges; _i < potentialEdges_5.length; _i++) {
40374 var potential = potentialEdges_5[_i];
40375 if (potential.distance > this._settings.panoMaxDistance) {
40378 if (potential.fullPano) {
40379 if (potential.distance < this._settings.panoMinDistance) {
40382 potentialPanos.push(potential);
40385 if (potential.croppedPano) {
40388 for (var k in this._directions.panos) {
40389 if (!this._directions.panos.hasOwnProperty(k)) {
40392 var pano = this._directions.panos[k];
40393 var turn = this._spatial.angleDifference(potential.directionChange, potential.motionChange);
40394 var turnChange = this._spatial.angleDifference(pano.directionChange, turn);
40395 if (Math.abs(turnChange) > this._settings.panoMaxStepTurnChange) {
40398 potentialSteps.push([pano.direction, potential]);
40399 // break if step direction found
40404 var maxRotationDifference = Math.PI / this._settings.panoMaxItems;
40405 var occupiedAngles = [];
40406 var stepAngles = [];
40407 for (var index = 0; index < this._settings.panoMaxItems; index++) {
40408 var rotation = index / this._settings.panoMaxItems * 2 * Math.PI;
40409 var lowestScore = Number.MAX_VALUE;
40411 for (var _a = 0, potentialPanos_1 = potentialPanos; _a < potentialPanos_1.length; _a++) {
40412 var potential = potentialPanos_1[_a];
40413 var motionDifference = this._spatial.angleDifference(rotation, potential.motionChange);
40414 if (Math.abs(motionDifference) > maxRotationDifference) {
40417 var occupiedDifference = Number.MAX_VALUE;
40418 for (var _b = 0, occupiedAngles_1 = occupiedAngles; _b < occupiedAngles_1.length; _b++) {
40419 var occupiedAngle = occupiedAngles_1[_b];
40420 var difference = Math.abs(this._spatial.angleDifference(occupiedAngle, potential.motionChange));
40421 if (difference < occupiedDifference) {
40422 occupiedDifference = difference;
40425 if (occupiedDifference <= maxRotationDifference) {
40428 var score = this._coefficients.panoPreferredDistance *
40429 Math.abs(potential.distance - this._settings.panoPreferredDistance) /
40430 this._settings.panoMaxDistance +
40431 this._coefficients.panoMotion * Math.abs(motionDifference) / maxRotationDifference +
40432 this._coefficients.panoSequencePenalty * (potential.sameSequence ? 0 : 1) +
40433 this._coefficients.panoMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
40434 if (score < lowestScore) {
40435 lowestScore = score;
40439 if (edge != null) {
40440 occupiedAngles.push(edge.motionChange);
40443 direction: Edge_1.EdgeDirection.Pano,
40444 worldMotionAzimuth: edge.worldMotionAzimuth,
40451 stepAngles.push(rotation);
40454 var occupiedStepAngles = {};
40455 occupiedStepAngles[Edge_1.EdgeDirection.Pano] = occupiedAngles;
40456 occupiedStepAngles[Edge_1.EdgeDirection.StepForward] = [];
40457 occupiedStepAngles[Edge_1.EdgeDirection.StepLeft] = [];
40458 occupiedStepAngles[Edge_1.EdgeDirection.StepBackward] = [];
40459 occupiedStepAngles[Edge_1.EdgeDirection.StepRight] = [];
40460 for (var _c = 0, stepAngles_1 = stepAngles; _c < stepAngles_1.length; _c++) {
40461 var stepAngle = stepAngles_1[_c];
40462 var occupations = [];
40463 for (var k in this._directions.panos) {
40464 if (!this._directions.panos.hasOwnProperty(k)) {
40467 var pano = this._directions.panos[k];
40468 var allOccupiedAngles = occupiedStepAngles[Edge_1.EdgeDirection.Pano]
40469 .concat(occupiedStepAngles[pano.direction])
40470 .concat(occupiedStepAngles[pano.prev])
40471 .concat(occupiedStepAngles[pano.next]);
40472 var lowestScore = Number.MAX_VALUE;
40474 for (var _d = 0, potentialSteps_1 = potentialSteps; _d < potentialSteps_1.length; _d++) {
40475 var potential = potentialSteps_1[_d];
40476 if (potential[0] !== pano.direction) {
40479 var motionChange = this._spatial.angleDifference(stepAngle, potential[1].motionChange);
40480 if (Math.abs(motionChange) > maxRotationDifference) {
40483 var minOccupiedDifference = Number.MAX_VALUE;
40484 for (var _e = 0, allOccupiedAngles_1 = allOccupiedAngles; _e < allOccupiedAngles_1.length; _e++) {
40485 var occupiedAngle = allOccupiedAngles_1[_e];
40486 var occupiedDifference = Math.abs(this._spatial.angleDifference(occupiedAngle, potential[1].motionChange));
40487 if (occupiedDifference < minOccupiedDifference) {
40488 minOccupiedDifference = occupiedDifference;
40491 if (minOccupiedDifference <= maxRotationDifference) {
40494 var score = this._coefficients.panoPreferredDistance *
40495 Math.abs(potential[1].distance - this._settings.panoPreferredDistance) /
40496 this._settings.panoMaxDistance +
40497 this._coefficients.panoMotion * Math.abs(motionChange) / maxRotationDifference +
40498 this._coefficients.panoMergeCCPenalty * (potential[1].sameMergeCC ? 0 : 1);
40499 if (score < lowestScore) {
40500 lowestScore = score;
40504 if (edge != null) {
40505 occupations.push(edge);
40508 direction: edge[0],
40509 worldMotionAzimuth: edge[1].worldMotionAzimuth,
40516 for (var _f = 0, occupations_1 = occupations; _f < occupations_1.length; _f++) {
40517 var occupation = occupations_1[_f];
40518 occupiedStepAngles[occupation[0]].push(occupation[1].motionChange);
40523 return EdgeCalculator;
40525 exports.EdgeCalculator = EdgeCalculator;
40526 exports.default = EdgeCalculator;
40528 },{"../../Edge":275,"../../Error":276,"../../Geo":277,"three":225}],399:[function(require,module,exports){
40530 Object.defineProperty(exports, "__esModule", { value: true });
40531 var EdgeCalculatorCoefficients = /** @class */ (function () {
40532 function EdgeCalculatorCoefficients() {
40533 this.panoPreferredDistance = 2;
40534 this.panoMotion = 2;
40535 this.panoSequencePenalty = 1;
40536 this.panoMergeCCPenalty = 4;
40537 this.stepPreferredDistance = 4;
40538 this.stepMotion = 3;
40539 this.stepRotation = 4;
40540 this.stepSequencePenalty = 2;
40541 this.stepMergeCCPenalty = 6;
40542 this.similarDistance = 2;
40543 this.similarRotation = 3;
40544 this.turnDistance = 4;
40545 this.turnMotion = 2;
40546 this.turnSequencePenalty = 1;
40547 this.turnMergeCCPenalty = 4;
40549 return EdgeCalculatorCoefficients;
40551 exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients;
40552 exports.default = EdgeCalculatorCoefficients;
40554 },{}],400:[function(require,module,exports){
40556 Object.defineProperty(exports, "__esModule", { value: true });
40557 var Edge_1 = require("../../Edge");
40558 var EdgeCalculatorDirections = /** @class */ (function () {
40559 function EdgeCalculatorDirections() {
40563 this.steps[Edge_1.EdgeDirection.StepForward] = {
40564 direction: Edge_1.EdgeDirection.StepForward,
40568 this.steps[Edge_1.EdgeDirection.StepBackward] = {
40569 direction: Edge_1.EdgeDirection.StepBackward,
40570 motionChange: Math.PI,
40573 this.steps[Edge_1.EdgeDirection.StepLeft] = {
40574 direction: Edge_1.EdgeDirection.StepLeft,
40575 motionChange: Math.PI / 2,
40576 useFallback: false,
40578 this.steps[Edge_1.EdgeDirection.StepRight] = {
40579 direction: Edge_1.EdgeDirection.StepRight,
40580 motionChange: -Math.PI / 2,
40581 useFallback: false,
40583 this.turns[Edge_1.EdgeDirection.TurnLeft] = {
40584 direction: Edge_1.EdgeDirection.TurnLeft,
40585 directionChange: Math.PI / 2,
40586 motionChange: Math.PI / 4,
40588 this.turns[Edge_1.EdgeDirection.TurnRight] = {
40589 direction: Edge_1.EdgeDirection.TurnRight,
40590 directionChange: -Math.PI / 2,
40591 motionChange: -Math.PI / 4,
40593 this.turns[Edge_1.EdgeDirection.TurnU] = {
40594 direction: Edge_1.EdgeDirection.TurnU,
40595 directionChange: Math.PI,
40596 motionChange: null,
40598 this.panos[Edge_1.EdgeDirection.StepForward] = {
40599 direction: Edge_1.EdgeDirection.StepForward,
40600 directionChange: 0,
40601 next: Edge_1.EdgeDirection.StepLeft,
40602 prev: Edge_1.EdgeDirection.StepRight,
40604 this.panos[Edge_1.EdgeDirection.StepBackward] = {
40605 direction: Edge_1.EdgeDirection.StepBackward,
40606 directionChange: Math.PI,
40607 next: Edge_1.EdgeDirection.StepRight,
40608 prev: Edge_1.EdgeDirection.StepLeft,
40610 this.panos[Edge_1.EdgeDirection.StepLeft] = {
40611 direction: Edge_1.EdgeDirection.StepLeft,
40612 directionChange: Math.PI / 2,
40613 next: Edge_1.EdgeDirection.StepBackward,
40614 prev: Edge_1.EdgeDirection.StepForward,
40616 this.panos[Edge_1.EdgeDirection.StepRight] = {
40617 direction: Edge_1.EdgeDirection.StepRight,
40618 directionChange: -Math.PI / 2,
40619 next: Edge_1.EdgeDirection.StepForward,
40620 prev: Edge_1.EdgeDirection.StepBackward,
40623 return EdgeCalculatorDirections;
40625 exports.EdgeCalculatorDirections = EdgeCalculatorDirections;
40627 },{"../../Edge":275}],401:[function(require,module,exports){
40629 Object.defineProperty(exports, "__esModule", { value: true });
40630 var EdgeCalculatorSettings = /** @class */ (function () {
40631 function EdgeCalculatorSettings() {
40632 this.panoMinDistance = 0.1;
40633 this.panoMaxDistance = 20;
40634 this.panoPreferredDistance = 5;
40635 this.panoMaxItems = 4;
40636 this.panoMaxStepTurnChange = Math.PI / 8;
40637 this.rotationMaxDistance = this.turnMaxRigDistance;
40638 this.rotationMaxDirectionChange = Math.PI / 6;
40639 this.rotationMaxVerticalDirectionChange = Math.PI / 8;
40640 this.similarMaxDirectionChange = Math.PI / 8;
40641 this.similarMaxDistance = 12;
40642 this.similarMinTimeDifference = 12 * 3600 * 1000;
40643 this.stepMaxDistance = 20;
40644 this.stepMaxDirectionChange = Math.PI / 6;
40645 this.stepMaxDrift = Math.PI / 6;
40646 this.stepPreferredDistance = 4;
40647 this.turnMaxDistance = 15;
40648 this.turnMaxDirectionChange = 2 * Math.PI / 9;
40649 this.turnMaxRigDistance = 0.65;
40650 this.turnMinRigDirectionChange = Math.PI / 6;
40652 Object.defineProperty(EdgeCalculatorSettings.prototype, "maxDistance", {
40654 return Math.max(this.panoMaxDistance, this.similarMaxDistance, this.stepMaxDistance, this.turnMaxDistance);
40659 return EdgeCalculatorSettings;
40661 exports.EdgeCalculatorSettings = EdgeCalculatorSettings;
40662 exports.default = EdgeCalculatorSettings;
40664 },{}],402:[function(require,module,exports){
40666 Object.defineProperty(exports, "__esModule", { value: true });
40668 * Enumeration for edge directions
40671 * @description Directions for edges in node graph describing
40672 * sequence, spatial and node type relations between nodes.
40675 (function (EdgeDirection) {
40677 * Next node in the sequence.
40679 EdgeDirection[EdgeDirection["Next"] = 0] = "Next";
40681 * Previous node in the sequence.
40683 EdgeDirection[EdgeDirection["Prev"] = 1] = "Prev";
40685 * Step to the left keeping viewing direction.
40687 EdgeDirection[EdgeDirection["StepLeft"] = 2] = "StepLeft";
40689 * Step to the right keeping viewing direction.
40691 EdgeDirection[EdgeDirection["StepRight"] = 3] = "StepRight";
40693 * Step forward keeping viewing direction.
40695 EdgeDirection[EdgeDirection["StepForward"] = 4] = "StepForward";
40697 * Step backward keeping viewing direction.
40699 EdgeDirection[EdgeDirection["StepBackward"] = 5] = "StepBackward";
40701 * Turn 90 degrees counter clockwise.
40703 EdgeDirection[EdgeDirection["TurnLeft"] = 6] = "TurnLeft";
40705 * Turn 90 degrees clockwise.
40707 EdgeDirection[EdgeDirection["TurnRight"] = 7] = "TurnRight";
40709 * Turn 180 degrees.
40711 EdgeDirection[EdgeDirection["TurnU"] = 8] = "TurnU";
40713 * Panorama in general direction.
40715 EdgeDirection[EdgeDirection["Pano"] = 9] = "Pano";
40717 * Looking in roughly the same direction at rougly the same position.
40719 EdgeDirection[EdgeDirection["Similar"] = 10] = "Similar";
40720 })(EdgeDirection = exports.EdgeDirection || (exports.EdgeDirection = {}));
40722 },{}],403:[function(require,module,exports){
40724 Object.defineProperty(exports, "__esModule", { value: true });
40725 var rxjs_1 = require("rxjs");
40726 var operators_1 = require("rxjs/operators");
40727 var vd = require("virtual-dom");
40728 var rxjs_2 = require("rxjs");
40729 var Render_1 = require("../Render");
40730 var DOMRenderer = /** @class */ (function () {
40731 function DOMRenderer(element, renderService, currentFrame$) {
40732 this._adaptiveOperation$ = new rxjs_2.Subject();
40733 this._render$ = new rxjs_2.Subject();
40734 this._renderAdaptive$ = new rxjs_2.Subject();
40735 this._renderService = renderService;
40736 this._currentFrame$ = currentFrame$;
40737 var rootNode = vd.create(vd.h("div.domRenderer", []));
40738 element.appendChild(rootNode);
40739 this._offset$ = this._adaptiveOperation$.pipe(operators_1.scan(function (adaptive, operation) {
40740 return operation(adaptive);
40742 elementHeight: element.offsetHeight,
40743 elementWidth: element.offsetWidth,
40745 renderMode: Render_1.RenderMode.Fill,
40746 }), operators_1.filter(function (adaptive) {
40747 return adaptive.imageAspect > 0 && adaptive.elementWidth > 0 && adaptive.elementHeight > 0;
40748 }), operators_1.map(function (adaptive) {
40749 var elementAspect = adaptive.elementWidth / adaptive.elementHeight;
40750 var ratio = adaptive.imageAspect / elementAspect;
40751 var verticalOffset = 0;
40752 var horizontalOffset = 0;
40753 if (adaptive.renderMode === Render_1.RenderMode.Letterbox) {
40754 if (adaptive.imageAspect > elementAspect) {
40755 verticalOffset = adaptive.elementHeight * (1 - 1 / ratio) / 2;
40758 horizontalOffset = adaptive.elementWidth * (1 - ratio) / 2;
40762 if (adaptive.imageAspect > elementAspect) {
40763 horizontalOffset = -adaptive.elementWidth * (ratio - 1) / 2;
40766 verticalOffset = -adaptive.elementHeight * (1 / ratio - 1) / 2;
40770 bottom: verticalOffset,
40771 left: horizontalOffset,
40772 right: horizontalOffset,
40773 top: verticalOffset,
40776 this._currentFrame$.pipe(operators_1.filter(function (frame) {
40777 return frame.state.currentNode != null;
40778 }), operators_1.distinctUntilChanged(function (k1, k2) {
40780 }, function (frame) {
40781 return frame.state.currentNode.key;
40782 }), operators_1.map(function (frame) {
40783 return frame.state.currentTransform.basicAspect;
40784 }), operators_1.map(function (aspect) {
40785 return function (adaptive) {
40786 adaptive.imageAspect = aspect;
40790 .subscribe(this._adaptiveOperation$);
40791 rxjs_1.combineLatest(this._renderAdaptive$.pipe(operators_1.scan(function (vNodeHashes, vNodeHash) {
40792 if (vNodeHash.vnode == null) {
40793 delete vNodeHashes[vNodeHash.name];
40796 vNodeHashes[vNodeHash.name] = vNodeHash.vnode;
40798 return vNodeHashes;
40799 }, {})), this._offset$).pipe(operators_1.map(function (vo) {
40801 var hashes = vo[0];
40802 for (var name_1 in hashes) {
40803 if (!hashes.hasOwnProperty(name_1)) {
40806 vNodes.push(hashes[name_1]);
40808 var offset = vo[1];
40811 bottom: offset.bottom + "px",
40812 left: offset.left + "px",
40813 "pointer-events": "none",
40814 position: "absolute",
40815 right: offset.right + "px",
40816 top: offset.top + "px",
40820 name: "adaptiveDomRenderer",
40821 vnode: vd.h("div.adaptiveDomRenderer", properties, vNodes),
40824 .subscribe(this._render$);
40825 this._vNode$ = this._render$.pipe(operators_1.scan(function (vNodeHashes, vNodeHash) {
40826 if (vNodeHash.vnode == null) {
40827 delete vNodeHashes[vNodeHash.name];
40830 vNodeHashes[vNodeHash.name] = vNodeHash.vnode;
40832 return vNodeHashes;
40833 }, {}), operators_1.map(function (hashes) {
40835 for (var name_2 in hashes) {
40836 if (!hashes.hasOwnProperty(name_2)) {
40839 vNodes.push(hashes[name_2]);
40841 return vd.h("div.domRenderer", vNodes);
40843 this._vPatch$ = this._vNode$.pipe(operators_1.scan(function (nodePatch, vNode) {
40844 nodePatch.vpatch = vd.diff(nodePatch.vnode, vNode);
40845 nodePatch.vnode = vNode;
40847 }, { vnode: vd.h("div.domRenderer", []), vpatch: null }), operators_1.pluck("vpatch"));
40848 this._element$ = this._vPatch$.pipe(operators_1.scan(function (oldElement, vPatch) {
40849 return vd.patch(oldElement, vPatch);
40850 }, rootNode), operators_1.publishReplay(1), operators_1.refCount());
40851 this._element$.subscribe(function () { });
40852 this._renderService.size$.pipe(operators_1.map(function (size) {
40853 return function (adaptive) {
40854 adaptive.elementWidth = size.width;
40855 adaptive.elementHeight = size.height;
40859 .subscribe(this._adaptiveOperation$);
40860 this._renderService.renderMode$.pipe(operators_1.map(function (renderMode) {
40861 return function (adaptive) {
40862 adaptive.renderMode = renderMode;
40866 .subscribe(this._adaptiveOperation$);
40868 Object.defineProperty(DOMRenderer.prototype, "element$", {
40870 return this._element$;
40875 Object.defineProperty(DOMRenderer.prototype, "render$", {
40877 return this._render$;
40882 Object.defineProperty(DOMRenderer.prototype, "renderAdaptive$", {
40884 return this._renderAdaptive$;
40889 DOMRenderer.prototype.clear = function (name) {
40890 this._renderAdaptive$.next({ name: name, vnode: null });
40891 this._render$.next({ name: name, vnode: null });
40893 return DOMRenderer;
40895 exports.DOMRenderer = DOMRenderer;
40896 exports.default = DOMRenderer;
40899 },{"../Render":280,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],404:[function(require,module,exports){
40901 Object.defineProperty(exports, "__esModule", { value: true });
40903 (function (GLRenderStage) {
40904 GLRenderStage[GLRenderStage["Background"] = 0] = "Background";
40905 GLRenderStage[GLRenderStage["Foreground"] = 1] = "Foreground";
40906 })(GLRenderStage = exports.GLRenderStage || (exports.GLRenderStage = {}));
40907 exports.default = GLRenderStage;
40909 },{}],405:[function(require,module,exports){
40911 Object.defineProperty(exports, "__esModule", { value: true });
40912 var rxjs_1 = require("rxjs");
40913 var operators_1 = require("rxjs/operators");
40914 var THREE = require("three");
40915 var Render_1 = require("../Render");
40916 var Utils_1 = require("../Utils");
40917 var GLRenderer = /** @class */ (function () {
40918 function GLRenderer(canvasContainer, renderService, dom) {
40920 this._renderFrame$ = new rxjs_1.Subject();
40921 this._renderCameraOperation$ = new rxjs_1.Subject();
40922 this._render$ = new rxjs_1.Subject();
40923 this._clear$ = new rxjs_1.Subject();
40924 this._renderOperation$ = new rxjs_1.Subject();
40925 this._rendererOperation$ = new rxjs_1.Subject();
40926 this._eraserOperation$ = new rxjs_1.Subject();
40927 this._renderService = renderService;
40928 this._dom = !!dom ? dom : new Utils_1.DOM();
40929 this._renderer$ = this._rendererOperation$.pipe(operators_1.scan(function (renderer, operation) {
40930 return operation(renderer);
40931 }, { needsRender: false, renderer: null }), operators_1.filter(function (renderer) {
40932 return !!renderer.renderer;
40934 this._renderCollection$ = this._renderOperation$.pipe(operators_1.scan(function (hashes, operation) {
40935 return operation(hashes);
40936 }, {}), operators_1.share());
40937 this._renderCamera$ = this._renderCameraOperation$.pipe(operators_1.scan(function (rc, operation) {
40938 return operation(rc);
40939 }, { frameId: -1, needsRender: false, perspective: null }));
40940 this._eraser$ = this._eraserOperation$.pipe(operators_1.startWith(function (eraser) {
40942 }), operators_1.scan(function (eraser, operation) {
40943 return operation(eraser);
40944 }, { needsRender: false }));
40945 rxjs_1.combineLatest(this._renderer$, this._renderCollection$, this._renderCamera$, this._eraser$).pipe(operators_1.map(function (_a) {
40946 var renderer = _a[0], hashes = _a[1], rc = _a[2], eraser = _a[3];
40947 var renders = Object.keys(hashes)
40948 .map(function (key) {
40949 return hashes[key];
40951 return { camera: rc, eraser: eraser, renderer: renderer, renders: renders };
40952 }), operators_1.filter(function (co) {
40953 var needsRender = co.renderer.needsRender ||
40954 co.camera.needsRender ||
40955 co.eraser.needsRender;
40956 var frameId = co.camera.frameId;
40957 for (var _i = 0, _a = co.renders; _i < _a.length; _i++) {
40958 var render = _a[_i];
40959 if (render.frameId !== frameId) {
40962 needsRender = needsRender || render.needsRender;
40964 return needsRender;
40965 }), operators_1.distinctUntilChanged(function (n1, n2) {
40968 return co.eraser.needsRender ? -1 : co.camera.frameId;
40970 .subscribe(function (co) {
40971 co.renderer.needsRender = false;
40972 co.camera.needsRender = false;
40973 co.eraser.needsRender = false;
40974 var perspectiveCamera = co.camera.perspective;
40975 var backgroundRenders = [];
40976 var foregroundRenders = [];
40977 for (var _i = 0, _a = co.renders; _i < _a.length; _i++) {
40978 var render = _a[_i];
40979 if (render.stage === Render_1.GLRenderStage.Background) {
40980 backgroundRenders.push(render.render);
40982 else if (render.stage === Render_1.GLRenderStage.Foreground) {
40983 foregroundRenders.push(render.render);
40986 var renderer = co.renderer.renderer;
40988 for (var _b = 0, backgroundRenders_1 = backgroundRenders; _b < backgroundRenders_1.length; _b++) {
40989 var render = backgroundRenders_1[_b];
40990 render(perspectiveCamera, renderer);
40992 renderer.clearDepth();
40993 for (var _c = 0, foregroundRenders_1 = foregroundRenders; _c < foregroundRenders_1.length; _c++) {
40994 var render = foregroundRenders_1[_c];
40995 render(perspectiveCamera, renderer);
40998 this._renderFrame$.pipe(operators_1.map(function (rc) {
40999 return function (irc) {
41000 irc.frameId = rc.frameId;
41001 irc.perspective = rc.perspective;
41002 if (rc.changed === true) {
41003 irc.needsRender = true;
41008 .subscribe(this._renderCameraOperation$);
41009 this._renderFrameSubscribe();
41010 var renderHash$ = this._render$.pipe(operators_1.map(function (hash) {
41011 return function (hashes) {
41012 hashes[hash.name] = hash.render;
41016 var clearHash$ = this._clear$.pipe(operators_1.map(function (name) {
41017 return function (hashes) {
41018 delete hashes[name];
41022 rxjs_1.merge(renderHash$, clearHash$)
41023 .subscribe(this._renderOperation$);
41024 this._webGLRenderer$ = this._render$.pipe(operators_1.first(), operators_1.map(function (hash) {
41025 var canvas = _this._dom.createElement("canvas", "mapillary-js-canvas");
41026 canvas.style.position = "absolute";
41027 canvas.setAttribute("tabindex", "0");
41028 canvasContainer.appendChild(canvas);
41029 var element = renderService.element;
41030 var webGLRenderer = new THREE.WebGLRenderer({ canvas: canvas });
41031 webGLRenderer.setPixelRatio(window.devicePixelRatio);
41032 webGLRenderer.setSize(element.offsetWidth, element.offsetHeight);
41033 webGLRenderer.setClearColor(new THREE.Color(0x202020), 1.0);
41034 webGLRenderer.autoClear = false;
41035 return webGLRenderer;
41036 }), operators_1.publishReplay(1), operators_1.refCount());
41037 this._webGLRenderer$.subscribe(function () { });
41038 var createRenderer$ = this._webGLRenderer$.pipe(operators_1.first(), operators_1.map(function (webGLRenderer) {
41039 return function (renderer) {
41040 renderer.needsRender = true;
41041 renderer.renderer = webGLRenderer;
41045 var resizeRenderer$ = this._renderService.size$.pipe(operators_1.map(function (size) {
41046 return function (renderer) {
41047 if (renderer.renderer == null) {
41050 renderer.renderer.setSize(size.width, size.height);
41051 renderer.needsRender = true;
41055 var clearRenderer$ = this._clear$.pipe(operators_1.map(function (name) {
41056 return function (renderer) {
41057 if (renderer.renderer == null) {
41060 renderer.needsRender = true;
41064 rxjs_1.merge(createRenderer$, resizeRenderer$, clearRenderer$)
41065 .subscribe(this._rendererOperation$);
41066 var renderCollectionEmpty$ = this._renderCollection$.pipe(operators_1.filter(function (hashes) {
41067 return Object.keys(hashes).length === 0;
41068 }), operators_1.share());
41069 renderCollectionEmpty$
41070 .subscribe(function (hashes) {
41071 if (_this._renderFrameSubscription == null) {
41074 _this._renderFrameSubscription.unsubscribe();
41075 _this._renderFrameSubscription = null;
41076 _this._renderFrameSubscribe();
41078 renderCollectionEmpty$.pipe(operators_1.map(function (hashes) {
41079 return function (eraser) {
41080 eraser.needsRender = true;
41084 .subscribe(this._eraserOperation$);
41086 Object.defineProperty(GLRenderer.prototype, "render$", {
41088 return this._render$;
41093 Object.defineProperty(GLRenderer.prototype, "webGLRenderer$", {
41095 return this._webGLRenderer$;
41100 GLRenderer.prototype.clear = function (name) {
41101 this._clear$.next(name);
41103 GLRenderer.prototype._renderFrameSubscribe = function () {
41105 this._render$.pipe(operators_1.first(), operators_1.map(function (renderHash) {
41106 return function (irc) {
41107 irc.needsRender = true;
41111 .subscribe(function (operation) {
41112 _this._renderCameraOperation$.next(operation);
41114 this._renderFrameSubscription = this._render$.pipe(operators_1.first(), operators_1.mergeMap(function (hash) {
41115 return _this._renderService.renderCameraFrame$;
41117 .subscribe(this._renderFrame$);
41121 exports.GLRenderer = GLRenderer;
41122 exports.default = GLRenderer;
41125 },{"../Render":280,"../Utils":284,"rxjs":26,"rxjs/operators":224,"three":225}],406:[function(require,module,exports){
41127 Object.defineProperty(exports, "__esModule", { value: true });
41128 var THREE = require("three");
41129 var Geo_1 = require("../Geo");
41130 var Render_1 = require("../Render");
41131 var State_1 = require("../State");
41132 var RenderCamera = /** @class */ (function () {
41133 function RenderCamera(elementWidth, elementHeight, renderMode) {
41134 this._spatial = new Geo_1.Spatial();
41135 this._viewportCoords = new Geo_1.ViewportCoords();
41136 this._initialFov = 50;
41138 this._renderMode = renderMode;
41140 this._frameId = -1;
41141 this._changed = false;
41142 this._changedForFrame = -1;
41143 this._currentNodeId = null;
41144 this._previousNodeId = null;
41145 this._currentPano = false;
41146 this._previousPano = false;
41147 this._state = null;
41148 this._currentProjectedPoints = [];
41149 this._previousProjectedPoints = [];
41150 this._currentFov = this._initialFov;
41151 this._previousFov = this._initialFov;
41152 this._camera = new Geo_1.Camera();
41153 this._perspective = new THREE.PerspectiveCamera(this._initialFov, this._computeAspect(elementWidth, elementHeight), 0.16, 10000);
41154 this._perspective.matrixAutoUpdate = false;
41155 this._rotation = { phi: 0, theta: 0 };
41157 Object.defineProperty(RenderCamera.prototype, "alpha", {
41159 return this._alpha;
41164 Object.defineProperty(RenderCamera.prototype, "camera", {
41166 return this._camera;
41171 Object.defineProperty(RenderCamera.prototype, "changed", {
41173 return this._frameId === this._changedForFrame;
41178 Object.defineProperty(RenderCamera.prototype, "frameId", {
41180 return this._frameId;
41185 Object.defineProperty(RenderCamera.prototype, "perspective", {
41187 return this._perspective;
41192 Object.defineProperty(RenderCamera.prototype, "renderMode", {
41194 return this._renderMode;
41199 Object.defineProperty(RenderCamera.prototype, "rotation", {
41201 return this._rotation;
41206 Object.defineProperty(RenderCamera.prototype, "zoom", {
41213 RenderCamera.prototype.setFrame = function (frame) {
41214 var state = frame.state;
41215 if (state.state !== this._state) {
41216 this._state = state.state;
41217 this._changed = true;
41219 var currentNodeId = state.currentNode.key;
41220 var previousNodeId = !!state.previousNode ? state.previousNode.key : null;
41221 if (currentNodeId !== this._currentNodeId) {
41222 this._currentNodeId = currentNodeId;
41223 this._currentPano = !!state.currentTransform.gpano;
41224 this._currentProjectedPoints = this._computeProjectedPoints(state.currentTransform);
41225 this._changed = true;
41227 if (previousNodeId !== this._previousNodeId) {
41228 this._previousNodeId = previousNodeId;
41229 this._previousPano = !!state.previousTransform.gpano;
41230 this._previousProjectedPoints = this._computeProjectedPoints(state.previousTransform);
41231 this._changed = true;
41233 var zoom = state.zoom;
41234 if (zoom !== this._zoom) {
41236 this._changed = true;
41238 if (this._changed) {
41239 this._currentFov = this._computeCurrentFov();
41240 this._previousFov = this._computePreviousFov();
41242 var alpha = state.alpha;
41243 if (this._changed || alpha !== this._alpha) {
41244 this._alpha = alpha;
41245 this._perspective.fov = this._state === State_1.State.Earth ?
41247 this._interpolateFov(this._currentFov, this._previousFov, this._alpha);
41248 this._changed = true;
41250 var camera = state.camera;
41251 if (this._camera.diff(camera) > 1e-9) {
41252 this._camera.copy(camera);
41253 this._rotation = this._computeRotation(camera);
41254 this._perspective.up.copy(camera.up);
41255 this._perspective.position.copy(camera.position);
41256 this._perspective.lookAt(camera.lookat);
41257 this._perspective.updateMatrix();
41258 this._perspective.updateMatrixWorld(false);
41259 this._changed = true;
41261 if (this._changed) {
41262 this._perspective.updateProjectionMatrix();
41264 this._setFrameId(frame.id);
41266 RenderCamera.prototype.setRenderMode = function (renderMode) {
41267 this._renderMode = renderMode;
41268 this._perspective.fov = this._computeFov();
41269 this._perspective.updateProjectionMatrix();
41270 this._changed = true;
41272 RenderCamera.prototype.setSize = function (size) {
41273 this._perspective.aspect = this._computeAspect(size.width, size.height);
41274 this._perspective.fov = this._computeFov();
41275 this._perspective.updateProjectionMatrix();
41276 this._changed = true;
41278 RenderCamera.prototype._computeAspect = function (elementWidth, elementHeight) {
41279 return elementWidth === 0 ? 0 : elementWidth / elementHeight;
41281 RenderCamera.prototype._computeCurrentFov = function () {
41282 if (!this._currentNodeId) {
41283 return this._initialFov;
41285 return this._currentPano ?
41286 this._yToFov(1, this._zoom) :
41287 this._computeVerticalFov(this._currentProjectedPoints, this._renderMode, this._zoom, this.perspective.aspect);
41289 RenderCamera.prototype._computeFov = function () {
41290 this._currentFov = this._computeCurrentFov();
41291 this._previousFov = this._computePreviousFov();
41292 return this._interpolateFov(this._currentFov, this._previousFov, this._alpha);
41294 RenderCamera.prototype._computePreviousFov = function () {
41295 if (!this._currentNodeId) {
41296 return this._initialFov;
41298 return !this._previousNodeId ?
41300 this._previousPano ?
41301 this._yToFov(1, this._zoom) :
41302 this._computeVerticalFov(this._previousProjectedPoints, this._renderMode, this._zoom, this.perspective.aspect);
41304 RenderCamera.prototype._computeProjectedPoints = function (transform) {
41306 var os = [[0.5, 0], [1, 0]];
41307 var ds = [[0.5, 0], [0, 0.5]];
41308 var pointsPerSide = 100;
41309 var basicPoints = [];
41310 for (var side = 0; side < os.length; ++side) {
41313 for (var i = 0; i <= pointsPerSide; ++i) {
41314 basicPoints.push([o[0] + d[0] * i / pointsPerSide,
41315 o[1] + d[1] * i / pointsPerSide]);
41318 var camera = new THREE.Camera();
41319 camera.up.copy(transform.upVector());
41320 camera.position.copy(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0)));
41321 camera.lookAt(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10)));
41322 camera.updateMatrix();
41323 camera.updateMatrixWorld(true);
41324 var projectedPoints = basicPoints
41325 .map(function (basicPoint) {
41326 var worldPoint = transform.unprojectBasic(basicPoint, 10000);
41327 var cameraPoint = _this._viewportCoords.worldToCamera(worldPoint, camera);
41329 Math.abs(cameraPoint[0] / cameraPoint[2]),
41330 Math.abs(cameraPoint[1] / cameraPoint[2]),
41333 return projectedPoints;
41335 RenderCamera.prototype._computeRequiredVerticalFov = function (projectedPoint, zoom, aspect) {
41336 var maxY = Math.max(projectedPoint[0] / aspect, projectedPoint[1]);
41337 return this._yToFov(maxY, zoom);
41339 RenderCamera.prototype._computeRotation = function (camera) {
41340 var direction = camera.lookat.clone().sub(camera.position);
41341 var up = camera.up.clone();
41342 var upProjection = direction.clone().dot(up);
41343 var planeProjection = direction.clone().sub(up.clone().multiplyScalar(upProjection));
41344 var phi = Math.atan2(planeProjection.y, planeProjection.x);
41345 var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
41346 return { phi: phi, theta: theta };
41348 RenderCamera.prototype._computeVerticalFov = function (projectedPoints, renderMode, zoom, aspect) {
41350 var fovs = projectedPoints
41351 .map(function (projectedPoint) {
41352 return _this._computeRequiredVerticalFov(projectedPoint, zoom, aspect);
41354 var fov = renderMode === Render_1.RenderMode.Fill ?
41355 Math.min.apply(Math, fovs) * 0.995 : Math.max.apply(Math, fovs);
41358 RenderCamera.prototype._yToFov = function (y, zoom) {
41359 return 2 * Math.atan(y / Math.pow(2, zoom)) * 180 / Math.PI;
41361 RenderCamera.prototype._interpolateFov = function (v1, v2, alpha) {
41362 return alpha * v1 + (1 - alpha) * v2;
41364 RenderCamera.prototype._setFrameId = function (frameId) {
41365 this._frameId = frameId;
41366 if (this._changed) {
41367 this._changed = false;
41368 this._changedForFrame = frameId;
41371 return RenderCamera;
41373 exports.RenderCamera = RenderCamera;
41374 exports.default = RenderCamera;
41376 },{"../Geo":277,"../Render":280,"../State":281,"three":225}],407:[function(require,module,exports){
41378 Object.defineProperty(exports, "__esModule", { value: true });
41380 * Enumeration for render mode
41383 * @description Modes for specifying how rendering is done
41384 * in the viewer. All modes preserves the original aspect
41385 * ratio of the images.
41388 (function (RenderMode) {
41390 * Displays all content within the viewer.
41392 * @description Black bars shown on both
41393 * sides of the content. Bars are shown
41394 * either below and above or to the left
41395 * and right of the content depending on
41396 * the aspect ratio relation between the
41397 * image and the viewer.
41399 RenderMode[RenderMode["Letterbox"] = 0] = "Letterbox";
41401 * Fills the viewer by cropping content.
41403 * @description Cropping is done either
41404 * in horizontal or vertical direction
41405 * depending on the aspect ratio relation
41406 * between the image and the viewer.
41408 RenderMode[RenderMode["Fill"] = 1] = "Fill";
41409 })(RenderMode = exports.RenderMode || (exports.RenderMode = {}));
41410 exports.default = RenderMode;
41412 },{}],408:[function(require,module,exports){
41414 Object.defineProperty(exports, "__esModule", { value: true });
41415 var operators_1 = require("rxjs/operators");
41416 var rxjs_1 = require("rxjs");
41417 var Geo_1 = require("../Geo");
41418 var Render_1 = require("../Render");
41419 var RenderService = /** @class */ (function () {
41420 function RenderService(element, currentFrame$, renderMode, renderCamera) {
41422 this._element = element;
41423 this._currentFrame$ = currentFrame$;
41424 this._spatial = new Geo_1.Spatial();
41425 renderMode = renderMode != null ? renderMode : Render_1.RenderMode.Fill;
41426 this._resize$ = new rxjs_1.Subject();
41427 this._renderCameraOperation$ = new rxjs_1.Subject();
41429 new rxjs_1.BehaviorSubject({
41430 height: this._element.offsetHeight,
41431 width: this._element.offsetWidth,
41433 this._resize$.pipe(operators_1.map(function () {
41434 return { height: _this._element.offsetHeight, width: _this._element.offsetWidth };
41436 .subscribe(this._size$);
41437 this._renderMode$ = new rxjs_1.BehaviorSubject(renderMode);
41438 this._renderCameraHolder$ = this._renderCameraOperation$.pipe(operators_1.startWith(function (rc) {
41440 }), operators_1.scan(function (rc, operation) {
41441 return operation(rc);
41442 }, !!renderCamera ? renderCamera : new Render_1.RenderCamera(this._element.offsetWidth, this._element.offsetHeight, renderMode)), operators_1.publishReplay(1), operators_1.refCount());
41443 this._renderCameraFrame$ = this._currentFrame$.pipe(operators_1.withLatestFrom(this._renderCameraHolder$), operators_1.tap(function (_a) {
41444 var frame = _a[0], rc = _a[1];
41445 rc.setFrame(frame);
41446 }), operators_1.map(function (args) {
41448 }), operators_1.publishReplay(1), operators_1.refCount());
41449 this._renderCamera$ = this._renderCameraFrame$.pipe(operators_1.filter(function (rc) {
41451 }), operators_1.publishReplay(1), operators_1.refCount());
41452 this._bearing$ = this._renderCamera$.pipe(operators_1.map(function (rc) {
41453 var bearing = _this._spatial.radToDeg(_this._spatial.azimuthalToBearing(rc.rotation.phi));
41454 return _this._spatial.wrap(bearing, 0, 360);
41455 }), operators_1.publishReplay(1), operators_1.refCount());
41456 this._size$.pipe(operators_1.skip(1), operators_1.map(function (size) {
41457 return function (rc) {
41462 .subscribe(this._renderCameraOperation$);
41463 this._renderMode$.pipe(operators_1.skip(1), operators_1.map(function (rm) {
41464 return function (rc) {
41465 rc.setRenderMode(rm);
41469 .subscribe(this._renderCameraOperation$);
41470 this._bearing$.subscribe(function () { });
41471 this._renderCameraHolder$.subscribe(function () { });
41472 this._size$.subscribe(function () { });
41473 this._renderMode$.subscribe(function () { });
41474 this._renderCamera$.subscribe(function () { });
41475 this._renderCameraFrame$.subscribe(function () { });
41477 Object.defineProperty(RenderService.prototype, "bearing$", {
41479 return this._bearing$;
41484 Object.defineProperty(RenderService.prototype, "element", {
41486 return this._element;
41491 Object.defineProperty(RenderService.prototype, "resize$", {
41493 return this._resize$;
41498 Object.defineProperty(RenderService.prototype, "size$", {
41500 return this._size$;
41505 Object.defineProperty(RenderService.prototype, "renderMode$", {
41507 return this._renderMode$;
41512 Object.defineProperty(RenderService.prototype, "renderCameraFrame$", {
41514 return this._renderCameraFrame$;
41519 Object.defineProperty(RenderService.prototype, "renderCamera$", {
41521 return this._renderCamera$;
41526 return RenderService;
41528 exports.RenderService = RenderService;
41529 exports.default = RenderService;
41532 },{"../Geo":277,"../Render":280,"rxjs":26,"rxjs/operators":224}],409:[function(require,module,exports){
41534 Object.defineProperty(exports, "__esModule", { value: true });
41535 var FrameGenerator = /** @class */ (function () {
41536 function FrameGenerator(root) {
41537 if (root.requestAnimationFrame) {
41538 this._cancelAnimationFrame = root.cancelAnimationFrame.bind(root);
41539 this._requestAnimationFrame = root.requestAnimationFrame.bind(root);
41541 else if (root.mozRequestAnimationFrame) {
41542 this._cancelAnimationFrame = root.mozCancelAnimationFrame.bind(root);
41543 this._requestAnimationFrame = root.mozRequestAnimationFrame.bind(root);
41545 else if (root.webkitRequestAnimationFrame) {
41546 this._cancelAnimationFrame = root.webkitCancelAnimationFrame.bind(root);
41547 this._requestAnimationFrame = root.webkitRequestAnimationFrame.bind(root);
41549 else if (root.msRequestAnimationFrame) {
41550 this._cancelAnimationFrame = root.msCancelAnimationFrame.bind(root);
41551 this._requestAnimationFrame = root.msRequestAnimationFrame.bind(root);
41553 else if (root.oRequestAnimationFrame) {
41554 this._cancelAnimationFrame = root.oCancelAnimationFrame.bind(root);
41555 this._requestAnimationFrame = root.oRequestAnimationFrame.bind(root);
41558 this._cancelAnimationFrame = root.clearTimeout.bind(root);
41559 this._requestAnimationFrame = function (cb) { return root.setTimeout(cb, 1000 / 60); };
41562 Object.defineProperty(FrameGenerator.prototype, "cancelAnimationFrame", {
41564 return this._cancelAnimationFrame;
41569 Object.defineProperty(FrameGenerator.prototype, "requestAnimationFrame", {
41571 return this._requestAnimationFrame;
41576 return FrameGenerator;
41578 exports.FrameGenerator = FrameGenerator;
41579 exports.default = FrameGenerator;
41581 },{}],410:[function(require,module,exports){
41583 Object.defineProperty(exports, "__esModule", { value: true });
41584 var RotationDelta = /** @class */ (function () {
41585 function RotationDelta(phi, theta) {
41587 this._theta = theta;
41589 Object.defineProperty(RotationDelta.prototype, "phi", {
41593 set: function (value) {
41599 Object.defineProperty(RotationDelta.prototype, "theta", {
41601 return this._theta;
41603 set: function (value) {
41604 this._theta = value;
41609 Object.defineProperty(RotationDelta.prototype, "isZero", {
41611 return this._phi === 0 && this._theta === 0;
41616 RotationDelta.prototype.copy = function (delta) {
41617 this._phi = delta.phi;
41618 this._theta = delta.theta;
41620 RotationDelta.prototype.lerp = function (other, alpha) {
41621 this._phi = (1 - alpha) * this._phi + alpha * other.phi;
41622 this._theta = (1 - alpha) * this._theta + alpha * other.theta;
41624 RotationDelta.prototype.multiply = function (value) {
41625 this._phi *= value;
41626 this._theta *= value;
41628 RotationDelta.prototype.threshold = function (value) {
41629 this._phi = Math.abs(this._phi) > value ? this._phi : 0;
41630 this._theta = Math.abs(this._theta) > value ? this._theta : 0;
41632 RotationDelta.prototype.lengthSquared = function () {
41633 return this._phi * this._phi + this._theta * this._theta;
41635 RotationDelta.prototype.reset = function () {
41639 return RotationDelta;
41641 exports.RotationDelta = RotationDelta;
41642 exports.default = RotationDelta;
41644 },{}],411:[function(require,module,exports){
41646 Object.defineProperty(exports, "__esModule", { value: true });
41648 (function (State) {
41649 State[State["Earth"] = 0] = "Earth";
41650 State[State["Traversing"] = 1] = "Traversing";
41651 State[State["Waiting"] = 2] = "Waiting";
41652 State[State["WaitingInteractively"] = 3] = "WaitingInteractively";
41653 })(State = exports.State || (exports.State = {}));
41654 exports.default = State;
41656 },{}],412:[function(require,module,exports){
41658 Object.defineProperty(exports, "__esModule", { value: true });
41659 var State_1 = require("../State");
41660 var Geo_1 = require("../Geo");
41661 var StateContext = /** @class */ (function () {
41662 function StateContext(transitionMode) {
41663 this._state = new State_1.TraversingState({
41665 camera: new Geo_1.Camera(),
41667 reference: { alt: 0, lat: 0, lon: 0 },
41669 transitionMode: transitionMode == null ? State_1.TransitionMode.Default : transitionMode,
41673 StateContext.prototype.earth = function () {
41674 this._state = this._state.earth();
41676 StateContext.prototype.traverse = function () {
41677 this._state = this._state.traverse();
41679 StateContext.prototype.wait = function () {
41680 this._state = this._state.wait();
41682 StateContext.prototype.waitInteractively = function () {
41683 this._state = this._state.waitInteractively();
41685 Object.defineProperty(StateContext.prototype, "state", {
41687 if (this._state instanceof State_1.EarthState) {
41688 return State_1.State.Earth;
41690 else if (this._state instanceof State_1.TraversingState) {
41691 return State_1.State.Traversing;
41693 else if (this._state instanceof State_1.WaitingState) {
41694 return State_1.State.Waiting;
41696 else if (this._state instanceof State_1.InteractiveWaitingState) {
41697 return State_1.State.WaitingInteractively;
41699 throw new Error("Invalid state");
41704 Object.defineProperty(StateContext.prototype, "reference", {
41706 return this._state.reference;
41711 Object.defineProperty(StateContext.prototype, "alpha", {
41713 return this._state.alpha;
41718 Object.defineProperty(StateContext.prototype, "camera", {
41720 return this._state.camera;
41725 Object.defineProperty(StateContext.prototype, "zoom", {
41727 return this._state.zoom;
41732 Object.defineProperty(StateContext.prototype, "currentNode", {
41734 return this._state.currentNode;
41739 Object.defineProperty(StateContext.prototype, "previousNode", {
41741 return this._state.previousNode;
41746 Object.defineProperty(StateContext.prototype, "currentCamera", {
41748 return this._state.currentCamera;
41753 Object.defineProperty(StateContext.prototype, "currentTransform", {
41755 return this._state.currentTransform;
41760 Object.defineProperty(StateContext.prototype, "previousTransform", {
41762 return this._state.previousTransform;
41767 Object.defineProperty(StateContext.prototype, "trajectory", {
41769 return this._state.trajectory;
41774 Object.defineProperty(StateContext.prototype, "currentIndex", {
41776 return this._state.currentIndex;
41781 Object.defineProperty(StateContext.prototype, "lastNode", {
41783 return this._state.trajectory[this._state.trajectory.length - 1];
41788 Object.defineProperty(StateContext.prototype, "nodesAhead", {
41790 return this._state.trajectory.length - 1 - this._state.currentIndex;
41795 Object.defineProperty(StateContext.prototype, "motionless", {
41797 return this._state.motionless;
41802 StateContext.prototype.getCenter = function () {
41803 return this._state.getCenter();
41805 StateContext.prototype.setCenter = function (center) {
41806 this._state.setCenter(center);
41808 StateContext.prototype.setZoom = function (zoom) {
41809 this._state.setZoom(zoom);
41811 StateContext.prototype.update = function (fps) {
41812 this._state.update(fps);
41814 StateContext.prototype.append = function (nodes) {
41815 this._state.append(nodes);
41817 StateContext.prototype.prepend = function (nodes) {
41818 this._state.prepend(nodes);
41820 StateContext.prototype.remove = function (n) {
41821 this._state.remove(n);
41823 StateContext.prototype.clear = function () {
41824 this._state.clear();
41826 StateContext.prototype.clearPrior = function () {
41827 this._state.clearPrior();
41829 StateContext.prototype.cut = function () {
41832 StateContext.prototype.set = function (nodes) {
41833 this._state.set(nodes);
41835 StateContext.prototype.rotate = function (delta) {
41836 this._state.rotate(delta);
41838 StateContext.prototype.rotateUnbounded = function (delta) {
41839 this._state.rotateUnbounded(delta);
41841 StateContext.prototype.rotateWithoutInertia = function (delta) {
41842 this._state.rotateWithoutInertia(delta);
41844 StateContext.prototype.rotateBasic = function (basicRotation) {
41845 this._state.rotateBasic(basicRotation);
41847 StateContext.prototype.rotateBasicUnbounded = function (basicRotation) {
41848 this._state.rotateBasicUnbounded(basicRotation);
41850 StateContext.prototype.rotateBasicWithoutInertia = function (basicRotation) {
41851 this._state.rotateBasicWithoutInertia(basicRotation);
41853 StateContext.prototype.rotateToBasic = function (basic) {
41854 this._state.rotateToBasic(basic);
41856 StateContext.prototype.move = function (delta) {
41857 this._state.move(delta);
41859 StateContext.prototype.moveTo = function (delta) {
41860 this._state.moveTo(delta);
41862 StateContext.prototype.zoomIn = function (delta, reference) {
41863 this._state.zoomIn(delta, reference);
41865 StateContext.prototype.setSpeed = function (speed) {
41866 this._state.setSpeed(speed);
41868 StateContext.prototype.setTransitionMode = function (mode) {
41869 this._state.setTransitionMode(mode);
41871 StateContext.prototype.dolly = function (delta) {
41872 this._state.dolly(delta);
41874 StateContext.prototype.orbit = function (rotation) {
41875 this._state.orbit(rotation);
41877 StateContext.prototype.truck = function (direction) {
41878 this._state.truck(direction);
41880 return StateContext;
41882 exports.StateContext = StateContext;
41884 },{"../Geo":277,"../State":281}],413:[function(require,module,exports){
41886 Object.defineProperty(exports, "__esModule", { value: true });
41887 var rxjs_1 = require("rxjs");
41888 var operators_1 = require("rxjs/operators");
41889 var State_1 = require("../State");
41890 var StateService = /** @class */ (function () {
41891 function StateService(transitionMode) {
41893 this._appendNode$ = new rxjs_1.Subject();
41894 this._start$ = new rxjs_1.Subject();
41895 this._frame$ = new rxjs_1.Subject();
41896 this._fpsSampleRate = 30;
41897 this._contextOperation$ = new rxjs_1.BehaviorSubject(function (context) {
41900 this._context$ = this._contextOperation$.pipe(operators_1.scan(function (context, operation) {
41901 return operation(context);
41902 }, new State_1.StateContext(transitionMode)), operators_1.publishReplay(1), operators_1.refCount());
41903 this._state$ = this._context$.pipe(operators_1.map(function (context) {
41904 return context.state;
41905 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
41906 this._fps$ = this._start$.pipe(operators_1.switchMap(function () {
41907 return _this._frame$.pipe(operators_1.bufferCount(1, _this._fpsSampleRate), operators_1.map(function (frameIds) {
41908 return new Date().getTime();
41909 }), operators_1.pairwise(), operators_1.map(function (times) {
41910 return Math.max(20, 1000 * _this._fpsSampleRate / (times[1] - times[0]));
41911 }), operators_1.startWith(60));
41912 }), operators_1.share());
41913 this._currentState$ = this._frame$.pipe(operators_1.withLatestFrom(this._fps$, this._context$, function (frameId, fps, context) {
41914 return [frameId, fps, context];
41915 }), operators_1.filter(function (fc) {
41916 return fc[2].currentNode != null;
41917 }), operators_1.tap(function (fc) {
41918 fc[2].update(fc[1]);
41919 }), operators_1.map(function (fc) {
41920 return { fps: fc[1], id: fc[0], state: fc[2] };
41921 }), operators_1.share());
41922 this._lastState$ = this._currentState$.pipe(operators_1.publishReplay(1), operators_1.refCount());
41923 var nodeChanged$ = this._currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (f) {
41924 return f.state.currentNode.key;
41925 }), operators_1.publishReplay(1), operators_1.refCount());
41926 var nodeChangedSubject$ = new rxjs_1.Subject();
41928 .subscribe(nodeChangedSubject$);
41929 this._currentKey$ = new rxjs_1.BehaviorSubject(null);
41930 nodeChangedSubject$.pipe(operators_1.map(function (f) {
41931 return f.state.currentNode.key;
41933 .subscribe(this._currentKey$);
41934 this._currentNode$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
41935 return f.state.currentNode;
41936 }), operators_1.publishReplay(1), operators_1.refCount());
41937 this._currentCamera$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
41938 return f.state.currentCamera;
41939 }), operators_1.publishReplay(1), operators_1.refCount());
41940 this._currentTransform$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
41941 return f.state.currentTransform;
41942 }), operators_1.publishReplay(1), operators_1.refCount());
41943 this._reference$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
41944 return f.state.reference;
41945 }), operators_1.distinctUntilChanged(function (r1, r2) {
41946 return r1.lat === r2.lat && r1.lon === r2.lon;
41947 }, function (reference) {
41948 return { lat: reference.lat, lon: reference.lon };
41949 }), operators_1.publishReplay(1), operators_1.refCount());
41950 this._currentNodeExternal$ = nodeChanged$.pipe(operators_1.map(function (f) {
41951 return f.state.currentNode;
41952 }), operators_1.publishReplay(1), operators_1.refCount());
41953 this._appendNode$.pipe(operators_1.map(function (node) {
41954 return function (context) {
41955 context.append([node]);
41959 .subscribe(this._contextOperation$);
41960 this._inMotionOperation$ = new rxjs_1.Subject();
41961 nodeChanged$.pipe(operators_1.map(function (frame) {
41964 .subscribe(this._inMotionOperation$);
41965 this._inMotionOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.filter(function (moving) {
41967 }), operators_1.switchMap(function (moving) {
41968 return _this._currentState$.pipe(operators_1.filter(function (frame) {
41969 return frame.state.nodesAhead === 0;
41970 }), operators_1.map(function (frame) {
41971 return [frame.state.camera.clone(), frame.state.zoom];
41972 }), operators_1.pairwise(), operators_1.map(function (pair) {
41973 var c1 = pair[0][0];
41974 var c2 = pair[1][0];
41975 var z1 = pair[0][1];
41976 var z2 = pair[1][1];
41977 return c1.diff(c2) > 1e-5 || Math.abs(z1 - z2) > 1e-5;
41978 }), operators_1.first(function (changed) {
41982 .subscribe(this._inMotionOperation$);
41983 this._inMotion$ = this._inMotionOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
41984 this._inTranslationOperation$ = new rxjs_1.Subject();
41985 nodeChanged$.pipe(operators_1.map(function (frame) {
41988 .subscribe(this._inTranslationOperation$);
41989 this._inTranslationOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.filter(function (inTranslation) {
41990 return inTranslation;
41991 }), operators_1.switchMap(function (inTranslation) {
41992 return _this._currentState$.pipe(operators_1.filter(function (frame) {
41993 return frame.state.nodesAhead === 0;
41994 }), operators_1.map(function (frame) {
41995 return frame.state.camera.position.clone();
41996 }), operators_1.pairwise(), operators_1.map(function (pair) {
41997 return pair[0].distanceToSquared(pair[1]) !== 0;
41998 }), operators_1.first(function (changed) {
42002 .subscribe(this._inTranslationOperation$);
42003 this._inTranslation$ = this._inTranslationOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
42004 this._state$.subscribe(function () { });
42005 this._currentNode$.subscribe(function () { });
42006 this._currentCamera$.subscribe(function () { });
42007 this._currentTransform$.subscribe(function () { });
42008 this._reference$.subscribe(function () { });
42009 this._currentNodeExternal$.subscribe(function () { });
42010 this._lastState$.subscribe(function () { });
42011 this._inMotion$.subscribe(function () { });
42012 this._inTranslation$.subscribe(function () { });
42013 this._frameId = null;
42014 this._frameGenerator = new State_1.FrameGenerator(window);
42016 Object.defineProperty(StateService.prototype, "currentState$", {
42018 return this._currentState$;
42023 Object.defineProperty(StateService.prototype, "currentNode$", {
42025 return this._currentNode$;
42030 Object.defineProperty(StateService.prototype, "currentKey$", {
42032 return this._currentKey$;
42037 Object.defineProperty(StateService.prototype, "currentNodeExternal$", {
42039 return this._currentNodeExternal$;
42044 Object.defineProperty(StateService.prototype, "currentCamera$", {
42046 return this._currentCamera$;
42051 Object.defineProperty(StateService.prototype, "currentTransform$", {
42053 return this._currentTransform$;
42058 Object.defineProperty(StateService.prototype, "state$", {
42060 return this._state$;
42065 Object.defineProperty(StateService.prototype, "reference$", {
42067 return this._reference$;
42072 Object.defineProperty(StateService.prototype, "inMotion$", {
42074 return this._inMotion$;
42079 Object.defineProperty(StateService.prototype, "inTranslation$", {
42081 return this._inTranslation$;
42086 Object.defineProperty(StateService.prototype, "appendNode$", {
42088 return this._appendNode$;
42093 StateService.prototype.earth = function () {
42094 this._inMotionOperation$.next(true);
42095 this._invokeContextOperation(function (context) { context.earth(); });
42097 StateService.prototype.traverse = function () {
42098 this._inMotionOperation$.next(true);
42099 this._invokeContextOperation(function (context) { context.traverse(); });
42101 StateService.prototype.wait = function () {
42102 this._invokeContextOperation(function (context) { context.wait(); });
42104 StateService.prototype.waitInteractively = function () {
42105 this._invokeContextOperation(function (context) { context.waitInteractively(); });
42107 StateService.prototype.appendNodes = function (nodes) {
42108 this._invokeContextOperation(function (context) { context.append(nodes); });
42110 StateService.prototype.prependNodes = function (nodes) {
42111 this._invokeContextOperation(function (context) { context.prepend(nodes); });
42113 StateService.prototype.removeNodes = function (n) {
42114 this._invokeContextOperation(function (context) { context.remove(n); });
42116 StateService.prototype.clearNodes = function () {
42117 this._invokeContextOperation(function (context) { context.clear(); });
42119 StateService.prototype.clearPriorNodes = function () {
42120 this._invokeContextOperation(function (context) { context.clearPrior(); });
42122 StateService.prototype.cutNodes = function () {
42123 this._invokeContextOperation(function (context) { context.cut(); });
42125 StateService.prototype.setNodes = function (nodes) {
42126 this._invokeContextOperation(function (context) { context.set(nodes); });
42128 StateService.prototype.rotate = function (delta) {
42129 this._inMotionOperation$.next(true);
42130 this._invokeContextOperation(function (context) { context.rotate(delta); });
42132 StateService.prototype.rotateUnbounded = function (delta) {
42133 this._inMotionOperation$.next(true);
42134 this._invokeContextOperation(function (context) { context.rotateUnbounded(delta); });
42136 StateService.prototype.rotateWithoutInertia = function (delta) {
42137 this._inMotionOperation$.next(true);
42138 this._invokeContextOperation(function (context) { context.rotateWithoutInertia(delta); });
42140 StateService.prototype.rotateBasic = function (basicRotation) {
42141 this._inMotionOperation$.next(true);
42142 this._invokeContextOperation(function (context) { context.rotateBasic(basicRotation); });
42144 StateService.prototype.rotateBasicUnbounded = function (basicRotation) {
42145 this._inMotionOperation$.next(true);
42146 this._invokeContextOperation(function (context) { context.rotateBasicUnbounded(basicRotation); });
42148 StateService.prototype.rotateBasicWithoutInertia = function (basicRotation) {
42149 this._inMotionOperation$.next(true);
42150 this._invokeContextOperation(function (context) { context.rotateBasicWithoutInertia(basicRotation); });
42152 StateService.prototype.rotateToBasic = function (basic) {
42153 this._inMotionOperation$.next(true);
42154 this._invokeContextOperation(function (context) { context.rotateToBasic(basic); });
42156 StateService.prototype.move = function (delta) {
42157 this._inMotionOperation$.next(true);
42158 this._invokeContextOperation(function (context) { context.move(delta); });
42160 StateService.prototype.moveTo = function (position) {
42161 this._inMotionOperation$.next(true);
42162 this._invokeContextOperation(function (context) { context.moveTo(position); });
42164 StateService.prototype.dolly = function (delta) {
42165 this._inMotionOperation$.next(true);
42166 this._invokeContextOperation(function (context) { context.dolly(delta); });
42168 StateService.prototype.orbit = function (rotation) {
42169 this._inMotionOperation$.next(true);
42170 this._invokeContextOperation(function (context) { context.orbit(rotation); });
42172 StateService.prototype.truck = function (direction) {
42173 this._inMotionOperation$.next(true);
42174 this._invokeContextOperation(function (context) { context.truck(direction); });
42177 * Change zoom level while keeping the reference point position approximately static.
42179 * @parameter {number} delta - Change in zoom level.
42180 * @parameter {Array<number>} reference - Reference point in basic coordinates.
42182 StateService.prototype.zoomIn = function (delta, reference) {
42183 this._inMotionOperation$.next(true);
42184 this._invokeContextOperation(function (context) { context.zoomIn(delta, reference); });
42186 StateService.prototype.getCenter = function () {
42187 return this._lastState$.pipe(operators_1.first(), operators_1.map(function (frame) {
42188 return frame.state.getCenter();
42191 StateService.prototype.getZoom = function () {
42192 return this._lastState$.pipe(operators_1.first(), operators_1.map(function (frame) {
42193 return frame.state.zoom;
42196 StateService.prototype.setCenter = function (center) {
42197 this._inMotionOperation$.next(true);
42198 this._invokeContextOperation(function (context) { context.setCenter(center); });
42200 StateService.prototype.setSpeed = function (speed) {
42201 this._invokeContextOperation(function (context) { context.setSpeed(speed); });
42203 StateService.prototype.setTransitionMode = function (mode) {
42204 this._invokeContextOperation(function (context) { context.setTransitionMode(mode); });
42206 StateService.prototype.setZoom = function (zoom) {
42207 this._inMotionOperation$.next(true);
42208 this._invokeContextOperation(function (context) { context.setZoom(zoom); });
42210 StateService.prototype.start = function () {
42211 if (this._frameId == null) {
42212 this._start$.next(null);
42213 this._frameId = this._frameGenerator.requestAnimationFrame(this._frame.bind(this));
42214 this._frame$.next(this._frameId);
42217 StateService.prototype.stop = function () {
42218 if (this._frameId != null) {
42219 this._frameGenerator.cancelAnimationFrame(this._frameId);
42220 this._frameId = null;
42223 StateService.prototype._invokeContextOperation = function (action) {
42224 this._contextOperation$
42225 .next(function (context) {
42230 StateService.prototype._frame = function (time) {
42231 this._frameId = this._frameGenerator.requestAnimationFrame(this._frame.bind(this));
42232 this._frame$.next(this._frameId);
42234 return StateService;
42236 exports.StateService = StateService;
42238 },{"../State":281,"rxjs":26,"rxjs/operators":224}],414:[function(require,module,exports){
42240 Object.defineProperty(exports, "__esModule", { value: true });
42242 * Enumeration for transition mode
42245 * @description Modes for specifying how transitions
42246 * between nodes are performed.
42248 var TransitionMode;
42249 (function (TransitionMode) {
42251 * Default transitions.
42253 * @description The viewer dynamically determines
42254 * whether transitions should be performed with or
42255 * without motion and blending for each transition
42256 * based on the underlying data.
42258 TransitionMode[TransitionMode["Default"] = 0] = "Default";
42260 * Instantaneous transitions.
42262 * @description All transitions are performed
42263 * without motion or blending.
42265 TransitionMode[TransitionMode["Instantaneous"] = 1] = "Instantaneous";
42266 })(TransitionMode = exports.TransitionMode || (exports.TransitionMode = {}));
42267 exports.default = TransitionMode;
42269 },{}],415:[function(require,module,exports){
42271 var __extends = (this && this.__extends) || (function () {
42272 var extendStatics = function (d, b) {
42273 extendStatics = Object.setPrototypeOf ||
42274 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42275 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42276 return extendStatics(d, b);
42278 return function (d, b) {
42279 extendStatics(d, b);
42280 function __() { this.constructor = d; }
42281 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42284 Object.defineProperty(exports, "__esModule", { value: true });
42285 var THREE = require("three");
42286 var State_1 = require("../../State");
42287 var EarthState = /** @class */ (function (_super) {
42288 __extends(EarthState, _super);
42289 function EarthState(state) {
42290 var _this = _super.call(this, state) || this;
42291 var viewingDirection = _this._camera.lookat
42293 .sub(_this._camera.position)
42295 _this._camera.lookat.copy(_this._camera.position);
42296 _this._camera.position.z = state.camera.position.z + 20;
42297 _this._camera.position.x = state.camera.position.x - 16 * viewingDirection.x;
42298 _this._camera.position.y = state.camera.position.y - 16 * viewingDirection.y;
42299 _this._camera.up.set(0, 0, 1);
42302 EarthState.prototype.traverse = function () {
42303 return new State_1.TraversingState(this);
42305 EarthState.prototype.wait = function () {
42306 return new State_1.WaitingState(this);
42308 EarthState.prototype.waitInteractively = function () {
42309 return new State_1.InteractiveWaitingState(this);
42311 EarthState.prototype.dolly = function (delta) {
42312 var camera = this._camera;
42313 var offset = new THREE.Vector3()
42314 .copy(camera.position)
42315 .sub(camera.lookat);
42316 var length = offset.length();
42317 var scaled = length * Math.pow(2, -delta);
42318 var clipped = Math.max(1, Math.min(scaled, 1000));
42319 offset.normalize();
42320 offset.multiplyScalar(clipped);
42321 camera.position.copy(camera.lookat).add(offset);
42323 EarthState.prototype.orbit = function (rotation) {
42324 var camera = this._camera;
42325 var q = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
42326 var qInverse = q.clone().inverse();
42327 var offset = new THREE.Vector3();
42328 offset.copy(camera.position).sub(camera.lookat);
42329 offset.applyQuaternion(q);
42330 var length = offset.length();
42331 var phi = Math.atan2(offset.y, offset.x);
42332 phi += rotation.phi;
42333 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
42334 theta += rotation.theta;
42335 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
42336 offset.x = Math.sin(theta) * Math.cos(phi);
42337 offset.y = Math.sin(theta) * Math.sin(phi);
42338 offset.z = Math.cos(theta);
42339 offset.applyQuaternion(qInverse);
42340 camera.position.copy(camera.lookat).add(offset.multiplyScalar(length));
42342 EarthState.prototype.truck = function (direction) {
42343 this._camera.position.add(new THREE.Vector3().fromArray(direction));
42344 this._camera.lookat.add(new THREE.Vector3().fromArray(direction));
42346 EarthState.prototype.update = function () { };
42348 }(State_1.StateBase));
42349 exports.EarthState = EarthState;
42350 exports.default = EarthState;
42353 },{"../../State":281,"three":225}],416:[function(require,module,exports){
42355 var __extends = (this && this.__extends) || (function () {
42356 var extendStatics = function (d, b) {
42357 extendStatics = Object.setPrototypeOf ||
42358 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42359 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42360 return extendStatics(d, b);
42362 return function (d, b) {
42363 extendStatics(d, b);
42364 function __() { this.constructor = d; }
42365 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42368 Object.defineProperty(exports, "__esModule", { value: true });
42369 var THREE = require("three");
42370 var State_1 = require("../../State");
42371 var InteractiveStateBase = /** @class */ (function (_super) {
42372 __extends(InteractiveStateBase, _super);
42373 function InteractiveStateBase(state) {
42374 var _this = _super.call(this, state) || this;
42375 _this._animationSpeed = 1 / 40;
42376 _this._rotationDelta = new State_1.RotationDelta(0, 0);
42377 _this._requestedRotationDelta = null;
42378 _this._basicRotation = [0, 0];
42379 _this._requestedBasicRotation = null;
42380 _this._requestedBasicRotationUnbounded = null;
42381 _this._rotationAcceleration = 0.86;
42382 _this._rotationIncreaseAlpha = 0.97;
42383 _this._rotationDecreaseAlpha = 0.9;
42384 _this._rotationThreshold = 1e-3;
42385 _this._unboundedRotationAlpha = 0.8;
42386 _this._desiredZoom = state.zoom;
42387 _this._minZoom = 0;
42388 _this._maxZoom = 3;
42389 _this._lookatDepth = 10;
42390 _this._desiredLookat = null;
42391 _this._desiredCenter = null;
42394 InteractiveStateBase.prototype.rotate = function (rotationDelta) {
42395 if (this._currentNode == null) {
42398 this._desiredZoom = this._zoom;
42399 this._desiredLookat = null;
42400 this._requestedBasicRotation = null;
42401 if (this._requestedRotationDelta != null) {
42402 this._requestedRotationDelta.phi = this._requestedRotationDelta.phi + rotationDelta.phi;
42403 this._requestedRotationDelta.theta = this._requestedRotationDelta.theta + rotationDelta.theta;
42406 this._requestedRotationDelta = new State_1.RotationDelta(rotationDelta.phi, rotationDelta.theta);
42409 InteractiveStateBase.prototype.rotateUnbounded = function (delta) {
42410 if (this._currentNode == null) {
42413 this._requestedBasicRotation = null;
42414 this._requestedRotationDelta = null;
42415 this._applyRotation(delta, this._currentCamera);
42416 this._applyRotation(delta, this._previousCamera);
42417 if (!this._desiredLookat) {
42420 var q = new THREE.Quaternion().setFromUnitVectors(this._currentCamera.up, new THREE.Vector3(0, 0, 1));
42421 var qInverse = q.clone().inverse();
42422 var offset = new THREE.Vector3()
42423 .copy(this._desiredLookat)
42424 .sub(this._camera.position)
42425 .applyQuaternion(q);
42426 var length = offset.length();
42427 var phi = Math.atan2(offset.y, offset.x);
42429 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
42430 theta += delta.theta;
42431 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
42432 offset.x = Math.sin(theta) * Math.cos(phi);
42433 offset.y = Math.sin(theta) * Math.sin(phi);
42434 offset.z = Math.cos(theta);
42435 offset.applyQuaternion(qInverse);
42436 this._desiredLookat
42437 .copy(this._camera.position)
42438 .add(offset.multiplyScalar(length));
42440 InteractiveStateBase.prototype.rotateWithoutInertia = function (rotationDelta) {
42441 if (this._currentNode == null) {
42444 this._desiredZoom = this._zoom;
42445 this._desiredLookat = null;
42446 this._requestedBasicRotation = null;
42447 this._requestedRotationDelta = null;
42448 var threshold = Math.PI / (10 * Math.pow(2, this._zoom));
42450 phi: this._spatial.clamp(rotationDelta.phi, -threshold, threshold),
42451 theta: this._spatial.clamp(rotationDelta.theta, -threshold, threshold),
42453 this._applyRotation(delta, this._currentCamera);
42454 this._applyRotation(delta, this._previousCamera);
42456 InteractiveStateBase.prototype.rotateBasic = function (basicRotation) {
42457 if (this._currentNode == null) {
42460 this._desiredZoom = this._zoom;
42461 this._desiredLookat = null;
42462 this._requestedRotationDelta = null;
42463 if (this._requestedBasicRotation != null) {
42464 this._requestedBasicRotation[0] += basicRotation[0];
42465 this._requestedBasicRotation[1] += basicRotation[1];
42466 var threshold = 0.05 / Math.pow(2, this._zoom);
42467 this._requestedBasicRotation[0] =
42468 this._spatial.clamp(this._requestedBasicRotation[0], -threshold, threshold);
42469 this._requestedBasicRotation[1] =
42470 this._spatial.clamp(this._requestedBasicRotation[1], -threshold, threshold);
42473 this._requestedBasicRotation = basicRotation.slice();
42476 InteractiveStateBase.prototype.rotateBasicUnbounded = function (basicRotation) {
42477 if (this._currentNode == null) {
42480 if (this._requestedBasicRotationUnbounded != null) {
42481 this._requestedBasicRotationUnbounded[0] += basicRotation[0];
42482 this._requestedBasicRotationUnbounded[1] += basicRotation[1];
42485 this._requestedBasicRotationUnbounded = basicRotation.slice();
42488 InteractiveStateBase.prototype.rotateBasicWithoutInertia = function (basic) {
42489 if (this._currentNode == null) {
42492 this._desiredZoom = this._zoom;
42493 this._desiredLookat = null;
42494 this._requestedRotationDelta = null;
42495 this._requestedBasicRotation = null;
42496 var threshold = 0.05 / Math.pow(2, this._zoom);
42497 var basicRotation = basic.slice();
42498 basicRotation[0] = this._spatial.clamp(basicRotation[0], -threshold, threshold);
42499 basicRotation[1] = this._spatial.clamp(basicRotation[1], -threshold, threshold);
42500 this._applyRotationBasic(basicRotation);
42502 InteractiveStateBase.prototype.rotateToBasic = function (basic) {
42503 if (this._currentNode == null) {
42506 this._desiredZoom = this._zoom;
42507 this._desiredLookat = null;
42508 basic[0] = this._spatial.clamp(basic[0], 0, 1);
42509 basic[1] = this._spatial.clamp(basic[1], 0, 1);
42510 var lookat = this.currentTransform.unprojectBasic(basic, this._lookatDepth);
42511 this._currentCamera.lookat.fromArray(lookat);
42513 InteractiveStateBase.prototype.zoomIn = function (delta, reference) {
42514 if (this._currentNode == null) {
42517 this._desiredZoom = Math.max(this._minZoom, Math.min(this._maxZoom, this._desiredZoom + delta));
42518 var currentCenter = this.currentTransform.projectBasic(this._currentCamera.lookat.toArray());
42519 var currentCenterX = currentCenter[0];
42520 var currentCenterY = currentCenter[1];
42521 var zoom0 = Math.pow(2, this._zoom);
42522 var zoom1 = Math.pow(2, this._desiredZoom);
42523 var refX = reference[0];
42524 var refY = reference[1];
42525 if (this.currentTransform.gpano != null &&
42526 this.currentTransform.gpano.CroppedAreaImageWidthPixels === this.currentTransform.gpano.FullPanoWidthPixels) {
42527 if (refX - currentCenterX > 0.5) {
42530 else if (currentCenterX - refX > 0.5) {
42534 var newCenterX = refX - zoom0 / zoom1 * (refX - currentCenterX);
42535 var newCenterY = refY - zoom0 / zoom1 * (refY - currentCenterY);
42536 var gpano = this.currentTransform.gpano;
42537 if (this._currentNode.fullPano) {
42538 newCenterX = this._spatial.wrap(newCenterX + this._basicRotation[0], 0, 1);
42539 newCenterY = this._spatial.clamp(newCenterY + this._basicRotation[1], 0.05, 0.95);
42541 else if (gpano != null &&
42542 this.currentTransform.gpano.CroppedAreaImageWidthPixels === this.currentTransform.gpano.FullPanoWidthPixels) {
42543 newCenterX = this._spatial.wrap(newCenterX + this._basicRotation[0], 0, 1);
42544 newCenterY = this._spatial.clamp(newCenterY + this._basicRotation[1], 0, 1);
42547 newCenterX = this._spatial.clamp(newCenterX, 0, 1);
42548 newCenterY = this._spatial.clamp(newCenterY, 0, 1);
42550 this._desiredLookat = new THREE.Vector3()
42551 .fromArray(this.currentTransform.unprojectBasic([newCenterX, newCenterY], this._lookatDepth));
42553 InteractiveStateBase.prototype.setCenter = function (center) {
42554 this._desiredLookat = null;
42555 this._requestedRotationDelta = null;
42556 this._requestedBasicRotation = null;
42557 this._desiredZoom = this._zoom;
42559 this._spatial.clamp(center[0], 0, 1),
42560 this._spatial.clamp(center[1], 0, 1),
42562 if (this._currentNode == null) {
42563 this._desiredCenter = clamped;
42566 this._desiredCenter = null;
42567 var currentLookat = new THREE.Vector3()
42568 .fromArray(this.currentTransform.unprojectBasic(clamped, this._lookatDepth));
42569 var previousTransform = this.previousTransform != null ?
42570 this.previousTransform :
42571 this.currentTransform;
42572 var previousLookat = new THREE.Vector3()
42573 .fromArray(previousTransform.unprojectBasic(clamped, this._lookatDepth));
42574 this._currentCamera.lookat.copy(currentLookat);
42575 this._previousCamera.lookat.copy(previousLookat);
42577 InteractiveStateBase.prototype.setZoom = function (zoom) {
42578 this._desiredLookat = null;
42579 this._requestedRotationDelta = null;
42580 this._requestedBasicRotation = null;
42581 this._zoom = this._spatial.clamp(zoom, this._minZoom, this._maxZoom);
42582 this._desiredZoom = this._zoom;
42584 InteractiveStateBase.prototype._applyRotation = function (delta, camera) {
42585 if (camera == null) {
42588 var q = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
42589 var qInverse = q.clone().inverse();
42590 var offset = new THREE.Vector3();
42591 offset.copy(camera.lookat).sub(camera.position);
42592 offset.applyQuaternion(q);
42593 var length = offset.length();
42594 var phi = Math.atan2(offset.y, offset.x);
42596 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
42597 theta += delta.theta;
42598 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
42599 offset.x = Math.sin(theta) * Math.cos(phi);
42600 offset.y = Math.sin(theta) * Math.sin(phi);
42601 offset.z = Math.cos(theta);
42602 offset.applyQuaternion(qInverse);
42603 camera.lookat.copy(camera.position).add(offset.multiplyScalar(length));
42605 InteractiveStateBase.prototype._applyRotationBasic = function (basicRotation) {
42606 var currentNode = this._currentNode;
42607 var previousNode = this._previousNode != null ?
42608 this.previousNode :
42610 var currentCamera = this._currentCamera;
42611 var previousCamera = this._previousCamera;
42612 var currentTransform = this.currentTransform;
42613 var previousTransform = this.previousTransform != null ?
42614 this.previousTransform :
42615 this.currentTransform;
42616 var currentBasic = currentTransform.projectBasic(currentCamera.lookat.toArray());
42617 var previousBasic = previousTransform.projectBasic(previousCamera.lookat.toArray());
42618 var currentGPano = currentTransform.gpano;
42619 var previousGPano = previousTransform.gpano;
42620 if (currentNode.fullPano) {
42621 currentBasic[0] = this._spatial.wrap(currentBasic[0] + basicRotation[0], 0, 1);
42622 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0.05, 0.95);
42624 else if (currentGPano != null &&
42625 currentTransform.gpano.CroppedAreaImageWidthPixels === currentTransform.gpano.FullPanoWidthPixels) {
42626 currentBasic[0] = this._spatial.wrap(currentBasic[0] + basicRotation[0], 0, 1);
42627 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
42630 currentBasic[0] = this._spatial.clamp(currentBasic[0] + basicRotation[0], 0, 1);
42631 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
42633 if (previousNode.fullPano) {
42634 previousBasic[0] = this._spatial.wrap(previousBasic[0] + basicRotation[0], 0, 1);
42635 previousBasic[1] = this._spatial.clamp(previousBasic[1] + basicRotation[1], 0.05, 0.95);
42637 else if (previousGPano != null &&
42638 previousTransform.gpano.CroppedAreaImageWidthPixels === previousTransform.gpano.FullPanoWidthPixels) {
42639 previousBasic[0] = this._spatial.wrap(previousBasic[0] + basicRotation[0], 0, 1);
42640 previousBasic[1] = this._spatial.clamp(previousBasic[1] + basicRotation[1], 0, 1);
42643 previousBasic[0] = this._spatial.clamp(previousBasic[0] + basicRotation[0], 0, 1);
42644 previousBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
42646 var currentLookat = currentTransform.unprojectBasic(currentBasic, this._lookatDepth);
42647 currentCamera.lookat.fromArray(currentLookat);
42648 var previousLookat = previousTransform.unprojectBasic(previousBasic, this._lookatDepth);
42649 previousCamera.lookat.fromArray(previousLookat);
42651 InteractiveStateBase.prototype._updateZoom = function (animationSpeed) {
42652 var diff = this._desiredZoom - this._zoom;
42653 var sign = diff > 0 ? 1 : diff < 0 ? -1 : 0;
42657 else if (Math.abs(diff) < 2e-3) {
42658 this._zoom = this._desiredZoom;
42659 if (this._desiredLookat != null) {
42660 this._desiredLookat = null;
42664 this._zoom += sign * Math.max(Math.abs(5 * animationSpeed * diff), 2e-3);
42667 InteractiveStateBase.prototype._updateLookat = function (animationSpeed) {
42668 if (this._desiredLookat === null) {
42671 var diff = this._desiredLookat.distanceToSquared(this._currentCamera.lookat);
42672 if (Math.abs(diff) < 1e-6) {
42673 this._currentCamera.lookat.copy(this._desiredLookat);
42674 this._desiredLookat = null;
42677 this._currentCamera.lookat.lerp(this._desiredLookat, 5 * animationSpeed);
42680 InteractiveStateBase.prototype._updateRotation = function () {
42681 if (this._requestedRotationDelta != null) {
42682 var length_1 = this._rotationDelta.lengthSquared();
42683 var requestedLength = this._requestedRotationDelta.lengthSquared();
42684 if (requestedLength > length_1) {
42685 this._rotationDelta.lerp(this._requestedRotationDelta, this._rotationIncreaseAlpha);
42688 this._rotationDelta.lerp(this._requestedRotationDelta, this._rotationDecreaseAlpha);
42690 this._requestedRotationDelta = null;
42693 if (this._rotationDelta.isZero) {
42696 this._rotationDelta.multiply(this._rotationAcceleration);
42697 this._rotationDelta.threshold(this._rotationThreshold);
42699 InteractiveStateBase.prototype._updateRotationBasic = function () {
42700 if (this._requestedBasicRotation != null) {
42701 var x = this._basicRotation[0];
42702 var y = this._basicRotation[1];
42703 var reqX = this._requestedBasicRotation[0];
42704 var reqY = this._requestedBasicRotation[1];
42705 if (Math.abs(reqX) > Math.abs(x)) {
42706 this._basicRotation[0] = (1 - this._rotationIncreaseAlpha) * x + this._rotationIncreaseAlpha * reqX;
42709 this._basicRotation[0] = (1 - this._rotationDecreaseAlpha) * x + this._rotationDecreaseAlpha * reqX;
42711 if (Math.abs(reqY) > Math.abs(y)) {
42712 this._basicRotation[1] = (1 - this._rotationIncreaseAlpha) * y + this._rotationIncreaseAlpha * reqY;
42715 this._basicRotation[1] = (1 - this._rotationDecreaseAlpha) * y + this._rotationDecreaseAlpha * reqY;
42717 this._requestedBasicRotation = null;
42720 if (this._requestedBasicRotationUnbounded != null) {
42721 var reqX = this._requestedBasicRotationUnbounded[0];
42722 var reqY = this._requestedBasicRotationUnbounded[1];
42723 if (Math.abs(reqX) > 0) {
42724 this._basicRotation[0] = (1 - this._unboundedRotationAlpha) * this._basicRotation[0] + this._unboundedRotationAlpha * reqX;
42726 if (Math.abs(reqY) > 0) {
42727 this._basicRotation[1] = (1 - this._unboundedRotationAlpha) * this._basicRotation[1] + this._unboundedRotationAlpha * reqY;
42729 if (this._desiredLookat != null) {
42730 var desiredBasicLookat = this.currentTransform.projectBasic(this._desiredLookat.toArray());
42731 desiredBasicLookat[0] += reqX;
42732 desiredBasicLookat[1] += reqY;
42733 this._desiredLookat = new THREE.Vector3()
42734 .fromArray(this.currentTransform.unprojectBasic(desiredBasicLookat, this._lookatDepth));
42736 this._requestedBasicRotationUnbounded = null;
42738 if (this._basicRotation[0] === 0 && this._basicRotation[1] === 0) {
42741 this._basicRotation[0] = this._rotationAcceleration * this._basicRotation[0];
42742 this._basicRotation[1] = this._rotationAcceleration * this._basicRotation[1];
42743 if (Math.abs(this._basicRotation[0]) < this._rotationThreshold / Math.pow(2, this._zoom) &&
42744 Math.abs(this._basicRotation[1]) < this._rotationThreshold / Math.pow(2, this._zoom)) {
42745 this._basicRotation = [0, 0];
42748 InteractiveStateBase.prototype._clearRotation = function () {
42749 if (this._currentNode.fullPano) {
42752 if (this._requestedRotationDelta != null) {
42753 this._requestedRotationDelta = null;
42755 if (!this._rotationDelta.isZero) {
42756 this._rotationDelta.reset();
42758 if (this._requestedBasicRotation != null) {
42759 this._requestedBasicRotation = null;
42761 if (this._basicRotation[0] > 0 || this._basicRotation[1] > 0) {
42762 this._basicRotation = [0, 0];
42765 InteractiveStateBase.prototype._setDesiredCenter = function () {
42766 if (this._desiredCenter == null) {
42769 var lookatDirection = new THREE.Vector3()
42770 .fromArray(this.currentTransform.unprojectBasic(this._desiredCenter, this._lookatDepth))
42771 .sub(this._currentCamera.position);
42772 this._currentCamera.lookat.copy(this._currentCamera.position.clone().add(lookatDirection));
42773 this._previousCamera.lookat.copy(this._previousCamera.position.clone().add(lookatDirection));
42774 this._desiredCenter = null;
42776 InteractiveStateBase.prototype._setDesiredZoom = function () {
42777 this._desiredZoom =
42778 this._currentNode.fullPano || this._previousNode == null ?
42781 return InteractiveStateBase;
42782 }(State_1.StateBase));
42783 exports.InteractiveStateBase = InteractiveStateBase;
42784 exports.default = InteractiveStateBase;
42787 },{"../../State":281,"three":225}],417:[function(require,module,exports){
42789 var __extends = (this && this.__extends) || (function () {
42790 var extendStatics = function (d, b) {
42791 extendStatics = Object.setPrototypeOf ||
42792 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42793 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42794 return extendStatics(d, b);
42796 return function (d, b) {
42797 extendStatics(d, b);
42798 function __() { this.constructor = d; }
42799 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42802 Object.defineProperty(exports, "__esModule", { value: true });
42803 var State_1 = require("../../State");
42804 var InteractiveWaitingState = /** @class */ (function (_super) {
42805 __extends(InteractiveWaitingState, _super);
42806 function InteractiveWaitingState(state) {
42807 var _this = _super.call(this, state) || this;
42808 _this._adjustCameras();
42809 _this._motionless = _this._motionlessTransition();
42812 InteractiveWaitingState.prototype.traverse = function () {
42813 return new State_1.TraversingState(this);
42815 InteractiveWaitingState.prototype.wait = function () {
42816 return new State_1.WaitingState(this);
42818 InteractiveWaitingState.prototype.prepend = function (nodes) {
42819 _super.prototype.prepend.call(this, nodes);
42820 this._motionless = this._motionlessTransition();
42822 InteractiveWaitingState.prototype.set = function (nodes) {
42823 _super.prototype.set.call(this, nodes);
42824 this._motionless = this._motionlessTransition();
42826 InteractiveWaitingState.prototype.move = function (delta) {
42827 this._alpha = Math.max(0, Math.min(1, this._alpha + delta));
42829 InteractiveWaitingState.prototype.moveTo = function (position) {
42830 this._alpha = Math.max(0, Math.min(1, position));
42832 InteractiveWaitingState.prototype.update = function (fps) {
42833 this._updateRotation();
42834 if (!this._rotationDelta.isZero) {
42835 this._applyRotation(this._rotationDelta, this._previousCamera);
42836 this._applyRotation(this._rotationDelta, this._currentCamera);
42838 this._updateRotationBasic();
42839 if (this._basicRotation[0] !== 0 || this._basicRotation[1] !== 0) {
42840 this._applyRotationBasic(this._basicRotation);
42842 var animationSpeed = this._animationSpeed * (60 / fps);
42843 this._updateZoom(animationSpeed);
42844 this._updateLookat(animationSpeed);
42845 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
42847 InteractiveWaitingState.prototype._getAlpha = function () {
42848 return this._motionless ? Math.round(this._alpha) : this._alpha;
42850 InteractiveWaitingState.prototype._setCurrentCamera = function () {
42851 _super.prototype._setCurrentCamera.call(this);
42852 this._adjustCameras();
42854 InteractiveWaitingState.prototype._adjustCameras = function () {
42855 if (this._previousNode == null) {
42858 if (this._currentNode.fullPano) {
42859 var lookat = this._camera.lookat.clone().sub(this._camera.position);
42860 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
42862 if (this._previousNode.fullPano) {
42863 var lookat = this._currentCamera.lookat.clone().sub(this._currentCamera.position);
42864 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
42867 return InteractiveWaitingState;
42868 }(State_1.InteractiveStateBase));
42869 exports.InteractiveWaitingState = InteractiveWaitingState;
42870 exports.default = InteractiveWaitingState;
42872 },{"../../State":281}],418:[function(require,module,exports){
42874 Object.defineProperty(exports, "__esModule", { value: true });
42875 var Error_1 = require("../../Error");
42876 var Geo_1 = require("../../Geo");
42877 var State_1 = require("../../State");
42878 var StateBase = /** @class */ (function () {
42879 function StateBase(state) {
42880 this._spatial = new Geo_1.Spatial();
42881 this._geoCoords = new Geo_1.GeoCoords();
42882 this._referenceThreshold = 0.01;
42883 this._transitionMode = state.transitionMode;
42884 this._reference = state.reference;
42885 this._alpha = state.alpha;
42886 this._camera = state.camera.clone();
42887 this._zoom = state.zoom;
42888 this._currentIndex = state.currentIndex;
42889 this._trajectory = state.trajectory.slice();
42890 this._trajectoryTransforms = [];
42891 this._trajectoryCameras = [];
42892 for (var _i = 0, _a = this._trajectory; _i < _a.length; _i++) {
42894 var translation = this._nodeToTranslation(node, this._reference);
42895 var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2);
42896 this._trajectoryTransforms.push(transform);
42897 this._trajectoryCameras.push(new Geo_1.Camera(transform));
42899 this._currentNode = this._trajectory.length > 0 ?
42900 this._trajectory[this._currentIndex] :
42902 this._previousNode = this._trajectory.length > 1 && this.currentIndex > 0 ?
42903 this._trajectory[this._currentIndex - 1] :
42905 this._currentCamera = this._trajectoryCameras.length > 0 ?
42906 this._trajectoryCameras[this._currentIndex].clone() :
42907 new Geo_1.Camera();
42908 this._previousCamera = this._trajectoryCameras.length > 1 && this.currentIndex > 0 ?
42909 this._trajectoryCameras[this._currentIndex - 1].clone() :
42910 this._currentCamera.clone();
42912 Object.defineProperty(StateBase.prototype, "reference", {
42914 return this._reference;
42919 Object.defineProperty(StateBase.prototype, "alpha", {
42921 return this._getAlpha();
42926 Object.defineProperty(StateBase.prototype, "camera", {
42928 return this._camera;
42933 Object.defineProperty(StateBase.prototype, "zoom", {
42940 Object.defineProperty(StateBase.prototype, "trajectory", {
42942 return this._trajectory;
42947 Object.defineProperty(StateBase.prototype, "currentIndex", {
42949 return this._currentIndex;
42954 Object.defineProperty(StateBase.prototype, "currentNode", {
42956 return this._currentNode;
42961 Object.defineProperty(StateBase.prototype, "previousNode", {
42963 return this._previousNode;
42968 Object.defineProperty(StateBase.prototype, "currentCamera", {
42970 return this._currentCamera;
42975 Object.defineProperty(StateBase.prototype, "currentTransform", {
42977 return this._trajectoryTransforms.length > 0 ?
42978 this._trajectoryTransforms[this.currentIndex] : null;
42983 Object.defineProperty(StateBase.prototype, "previousTransform", {
42985 return this._trajectoryTransforms.length > 1 && this.currentIndex > 0 ?
42986 this._trajectoryTransforms[this.currentIndex - 1] : null;
42991 Object.defineProperty(StateBase.prototype, "motionless", {
42993 return this._motionless;
42998 Object.defineProperty(StateBase.prototype, "transitionMode", {
43000 return this._transitionMode;
43005 StateBase.prototype.earth = function () { throw new Error("Not implemented"); };
43006 StateBase.prototype.traverse = function () { throw new Error("Not implemented"); };
43007 StateBase.prototype.wait = function () { throw new Error("Not implemented"); };
43008 StateBase.prototype.waitInteractively = function () { throw new Error("Not implemented"); };
43009 StateBase.prototype.move = function (delta) { };
43010 StateBase.prototype.moveTo = function (position) { };
43011 StateBase.prototype.rotate = function (delta) { };
43012 StateBase.prototype.rotateUnbounded = function (delta) { };
43013 StateBase.prototype.rotateWithoutInertia = function (delta) { };
43014 StateBase.prototype.rotateBasic = function (basicRotation) { };
43015 StateBase.prototype.rotateBasicUnbounded = function (basicRotation) { };
43016 StateBase.prototype.rotateBasicWithoutInertia = function (basicRotation) { };
43017 StateBase.prototype.rotateToBasic = function (basic) { };
43018 StateBase.prototype.setSpeed = function (speed) { };
43019 StateBase.prototype.zoomIn = function (delta, reference) { };
43020 StateBase.prototype.update = function (fps) { };
43021 StateBase.prototype.setCenter = function (center) { };
43022 StateBase.prototype.setZoom = function (zoom) { };
43023 StateBase.prototype.dolly = function (delta) { };
43024 StateBase.prototype.orbit = function (rotation) { };
43025 StateBase.prototype.truck = function (direction) { };
43026 StateBase.prototype.append = function (nodes) {
43027 if (nodes.length < 1) {
43028 throw Error("Trajectory can not be empty");
43030 if (this._currentIndex < 0) {
43034 this._trajectory = this._trajectory.concat(nodes);
43035 this._appendToTrajectories(nodes);
43038 StateBase.prototype.prepend = function (nodes) {
43039 if (nodes.length < 1) {
43040 throw Error("Trajectory can not be empty");
43042 this._trajectory = nodes.slice().concat(this._trajectory);
43043 this._currentIndex += nodes.length;
43044 this._setCurrentNode();
43045 var referenceReset = this._setReference(this._currentNode);
43046 if (referenceReset) {
43047 this._setTrajectories();
43050 this._prependToTrajectories(nodes);
43052 this._setCurrentCamera();
43054 StateBase.prototype.remove = function (n) {
43056 throw Error("n must be a positive integer");
43058 if (this._currentIndex - 1 < n) {
43059 throw Error("Current and previous nodes can not be removed");
43061 for (var i = 0; i < n; i++) {
43062 this._trajectory.shift();
43063 this._trajectoryTransforms.shift();
43064 this._trajectoryCameras.shift();
43065 this._currentIndex--;
43067 this._setCurrentNode();
43069 StateBase.prototype.clearPrior = function () {
43070 if (this._currentIndex > 0) {
43071 this.remove(this._currentIndex - 1);
43074 StateBase.prototype.clear = function () {
43076 if (this._currentIndex > 0) {
43077 this.remove(this._currentIndex - 1);
43080 StateBase.prototype.cut = function () {
43081 while (this._trajectory.length - 1 > this._currentIndex) {
43082 this._trajectory.pop();
43083 this._trajectoryTransforms.pop();
43084 this._trajectoryCameras.pop();
43087 StateBase.prototype.set = function (nodes) {
43088 this._setTrajectory(nodes);
43089 this._setCurrentNode();
43090 this._setReference(this._currentNode);
43091 this._setTrajectories();
43092 this._setCurrentCamera();
43094 StateBase.prototype.getCenter = function () {
43095 return this._currentNode != null ?
43096 this.currentTransform.projectBasic(this._camera.lookat.toArray()) :
43099 StateBase.prototype.setTransitionMode = function (mode) {
43100 this._transitionMode = mode;
43102 StateBase.prototype._getAlpha = function () { return 1; };
43103 StateBase.prototype._setCurrent = function () {
43104 this._setCurrentNode();
43105 var referenceReset = this._setReference(this._currentNode);
43106 if (referenceReset) {
43107 this._setTrajectories();
43109 this._setCurrentCamera();
43111 StateBase.prototype._setCurrentCamera = function () {
43112 this._currentCamera = this._trajectoryCameras[this._currentIndex].clone();
43113 this._previousCamera = this._currentIndex > 0 ?
43114 this._trajectoryCameras[this._currentIndex - 1].clone() :
43115 this._currentCamera.clone();
43117 StateBase.prototype._motionlessTransition = function () {
43118 var nodesSet = this._currentNode != null && this._previousNode != null;
43119 return nodesSet && (this._transitionMode === State_1.TransitionMode.Instantaneous || !(this._currentNode.merged &&
43120 this._previousNode.merged &&
43121 this._withinOriginalDistance() &&
43122 this._sameConnectedComponent()));
43124 StateBase.prototype._setReference = function (node) {
43125 // do not reset reference if node is within threshold distance
43126 if (Math.abs(node.latLon.lat - this.reference.lat) < this._referenceThreshold &&
43127 Math.abs(node.latLon.lon - this.reference.lon) < this._referenceThreshold) {
43130 // do not reset reference if previous node exist and transition is with motion
43131 if (this._previousNode != null && !this._motionlessTransition()) {
43134 this._reference.lat = node.latLon.lat;
43135 this._reference.lon = node.latLon.lon;
43136 this._reference.alt = node.alt;
43139 StateBase.prototype._setCurrentNode = function () {
43140 this._currentNode = this._trajectory.length > 0 ?
43141 this._trajectory[this._currentIndex] :
43143 this._previousNode = this._currentIndex > 0 ?
43144 this._trajectory[this._currentIndex - 1] :
43147 StateBase.prototype._setTrajectory = function (nodes) {
43148 if (nodes.length < 1) {
43149 throw new Error_1.ArgumentMapillaryError("Trajectory can not be empty");
43151 if (this._currentNode != null) {
43152 this._trajectory = [this._currentNode].concat(nodes);
43153 this._currentIndex = 1;
43156 this._trajectory = nodes.slice();
43157 this._currentIndex = 0;
43160 StateBase.prototype._setTrajectories = function () {
43161 this._trajectoryTransforms.length = 0;
43162 this._trajectoryCameras.length = 0;
43163 this._appendToTrajectories(this._trajectory);
43165 StateBase.prototype._appendToTrajectories = function (nodes) {
43166 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
43167 var node = nodes_1[_i];
43168 if (!node.assetsCached) {
43169 throw new Error_1.ArgumentMapillaryError("Assets must be cached when node is added to trajectory");
43171 var translation = this._nodeToTranslation(node, this.reference);
43172 var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2);
43173 this._trajectoryTransforms.push(transform);
43174 this._trajectoryCameras.push(new Geo_1.Camera(transform));
43177 StateBase.prototype._prependToTrajectories = function (nodes) {
43178 for (var _i = 0, _a = nodes.reverse(); _i < _a.length; _i++) {
43180 if (!node.assetsCached) {
43181 throw new Error_1.ArgumentMapillaryError("Assets must be cached when added to trajectory");
43183 var translation = this._nodeToTranslation(node, this.reference);
43184 var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2);
43185 this._trajectoryTransforms.unshift(transform);
43186 this._trajectoryCameras.unshift(new Geo_1.Camera(transform));
43189 StateBase.prototype._nodeToTranslation = function (node, reference) {
43190 return Geo_1.Geo.computeTranslation({ alt: node.alt, lat: node.latLon.lat, lon: node.latLon.lon }, node.rotation, reference);
43192 StateBase.prototype._sameConnectedComponent = function () {
43193 var current = this._currentNode;
43194 var previous = this._previousNode;
43195 return !!current && !!previous &&
43196 current.mergeCC === previous.mergeCC;
43198 StateBase.prototype._withinOriginalDistance = function () {
43199 var current = this._currentNode;
43200 var previous = this._previousNode;
43201 if (!current || !previous) {
43204 // 50 km/h moves 28m in 2s
43205 var distance = this._spatial.distanceFromLatLon(current.originalLatLon.lat, current.originalLatLon.lon, previous.originalLatLon.lat, previous.originalLatLon.lon);
43206 return distance < 25;
43210 exports.StateBase = StateBase;
43212 },{"../../Error":276,"../../Geo":277,"../../State":281}],419:[function(require,module,exports){
43214 var __extends = (this && this.__extends) || (function () {
43215 var extendStatics = function (d, b) {
43216 extendStatics = Object.setPrototypeOf ||
43217 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
43218 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
43219 return extendStatics(d, b);
43221 return function (d, b) {
43222 extendStatics(d, b);
43223 function __() { this.constructor = d; }
43224 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
43227 Object.defineProperty(exports, "__esModule", { value: true });
43228 var UnitBezier = require("@mapbox/unitbezier");
43229 var State_1 = require("../../State");
43230 var TraversingState = /** @class */ (function (_super) {
43231 __extends(TraversingState, _super);
43232 function TraversingState(state) {
43233 var _this = _super.call(this, state) || this;
43234 _this._adjustCameras();
43235 _this._motionless = _this._motionlessTransition();
43236 _this._baseAlpha = _this._alpha;
43237 _this._speedCoefficient = 1;
43238 _this._unitBezier = new UnitBezier(0.74, 0.67, 0.38, 0.96);
43239 _this._useBezier = false;
43242 TraversingState.prototype.earth = function () {
43243 return new State_1.EarthState(this);
43245 TraversingState.prototype.wait = function () {
43246 return new State_1.WaitingState(this);
43248 TraversingState.prototype.waitInteractively = function () {
43249 return new State_1.InteractiveWaitingState(this);
43251 TraversingState.prototype.append = function (nodes) {
43252 var emptyTrajectory = this._trajectory.length === 0;
43253 if (emptyTrajectory) {
43254 this._resetTransition();
43256 _super.prototype.append.call(this, nodes);
43257 if (emptyTrajectory) {
43258 this._setDesiredCenter();
43259 this._setDesiredZoom();
43262 TraversingState.prototype.prepend = function (nodes) {
43263 var emptyTrajectory = this._trajectory.length === 0;
43264 if (emptyTrajectory) {
43265 this._resetTransition();
43267 _super.prototype.prepend.call(this, nodes);
43268 if (emptyTrajectory) {
43269 this._setDesiredCenter();
43270 this._setDesiredZoom();
43273 TraversingState.prototype.set = function (nodes) {
43274 _super.prototype.set.call(this, nodes);
43275 this._desiredLookat = null;
43276 this._resetTransition();
43277 this._clearRotation();
43278 this._setDesiredCenter();
43279 this._setDesiredZoom();
43280 if (this._trajectory.length < 3) {
43281 this._useBezier = true;
43284 TraversingState.prototype.setSpeed = function (speed) {
43285 this._speedCoefficient = this._spatial.clamp(speed, 0, 10);
43287 TraversingState.prototype.update = function (fps) {
43288 if (this._alpha === 1 && this._currentIndex + this._alpha < this._trajectory.length) {
43289 this._currentIndex += 1;
43290 this._useBezier = this._trajectory.length < 3 &&
43291 this._currentIndex + 1 === this._trajectory.length;
43292 this._setCurrent();
43293 this._resetTransition();
43294 this._clearRotation();
43295 this._desiredZoom = this._currentNode.fullPano ? this._zoom : 0;
43296 this._desiredLookat = null;
43298 var animationSpeed = this._animationSpeed * (60 / fps);
43299 this._baseAlpha = Math.min(1, this._baseAlpha + this._speedCoefficient * animationSpeed);
43300 if (this._useBezier) {
43301 this._alpha = this._unitBezier.solve(this._baseAlpha);
43304 this._alpha = this._baseAlpha;
43306 this._updateRotation();
43307 if (!this._rotationDelta.isZero) {
43308 this._applyRotation(this._rotationDelta, this._previousCamera);
43309 this._applyRotation(this._rotationDelta, this._currentCamera);
43311 this._updateRotationBasic();
43312 if (this._basicRotation[0] !== 0 || this._basicRotation[1] !== 0) {
43313 this._applyRotationBasic(this._basicRotation);
43315 this._updateZoom(animationSpeed);
43316 this._updateLookat(animationSpeed);
43317 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
43319 TraversingState.prototype._getAlpha = function () {
43320 return this._motionless ? Math.ceil(this._alpha) : this._alpha;
43322 TraversingState.prototype._setCurrentCamera = function () {
43323 _super.prototype._setCurrentCamera.call(this);
43324 this._adjustCameras();
43326 TraversingState.prototype._adjustCameras = function () {
43327 if (this._previousNode == null) {
43330 var lookat = this._camera.lookat.clone().sub(this._camera.position);
43331 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
43332 if (this._currentNode.fullPano) {
43333 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
43336 TraversingState.prototype._resetTransition = function () {
43338 this._baseAlpha = 0;
43339 this._motionless = this._motionlessTransition();
43341 return TraversingState;
43342 }(State_1.InteractiveStateBase));
43343 exports.TraversingState = TraversingState;
43344 exports.default = TraversingState;
43346 },{"../../State":281,"@mapbox/unitbezier":2}],420:[function(require,module,exports){
43348 var __extends = (this && this.__extends) || (function () {
43349 var extendStatics = function (d, b) {
43350 extendStatics = Object.setPrototypeOf ||
43351 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
43352 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
43353 return extendStatics(d, b);
43355 return function (d, b) {
43356 extendStatics(d, b);
43357 function __() { this.constructor = d; }
43358 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
43361 Object.defineProperty(exports, "__esModule", { value: true });
43362 var State_1 = require("../../State");
43363 var WaitingState = /** @class */ (function (_super) {
43364 __extends(WaitingState, _super);
43365 function WaitingState(state) {
43366 var _this = _super.call(this, state) || this;
43368 _this._adjustCameras();
43369 _this._motionless = _this._motionlessTransition();
43372 WaitingState.prototype.traverse = function () {
43373 return new State_1.TraversingState(this);
43375 WaitingState.prototype.waitInteractively = function () {
43376 return new State_1.InteractiveWaitingState(this);
43378 WaitingState.prototype.prepend = function (nodes) {
43379 _super.prototype.prepend.call(this, nodes);
43380 this._motionless = this._motionlessTransition();
43382 WaitingState.prototype.set = function (nodes) {
43383 _super.prototype.set.call(this, nodes);
43384 this._motionless = this._motionlessTransition();
43386 WaitingState.prototype.move = function (delta) {
43387 this._alpha = Math.max(0, Math.min(1, this._alpha + delta));
43389 WaitingState.prototype.moveTo = function (position) {
43390 this._alpha = Math.max(0, Math.min(1, position));
43392 WaitingState.prototype.update = function (fps) {
43393 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
43395 WaitingState.prototype._getAlpha = function () {
43396 return this._motionless ? Math.round(this._alpha) : this._alpha;
43398 WaitingState.prototype._setCurrentCamera = function () {
43399 _super.prototype._setCurrentCamera.call(this);
43400 this._adjustCameras();
43402 WaitingState.prototype._adjustCameras = function () {
43403 if (this._previousNode == null) {
43406 if (this._currentNode.fullPano) {
43407 var lookat = this._camera.lookat.clone().sub(this._camera.position);
43408 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
43410 if (this._previousNode.fullPano) {
43411 var lookat = this._currentCamera.lookat.clone().sub(this._currentCamera.position);
43412 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
43415 return WaitingState;
43416 }(State_1.StateBase));
43417 exports.WaitingState = WaitingState;
43418 exports.default = WaitingState;
43420 },{"../../State":281}],421:[function(require,module,exports){
43422 Object.defineProperty(exports, "__esModule", { value: true });
43423 var rxjs_1 = require("rxjs");
43425 * @class ImageTileLoader
43427 * @classdesc Represents a loader of image tiles.
43429 var ImageTileLoader = /** @class */ (function () {
43431 * Create a new node image tile loader instance.
43433 * @param {string} scheme - The URI scheme.
43434 * @param {string} host - The URI host.
43435 * @param {string} [origin] - The origin query param.
43437 function ImageTileLoader(scheme, host, origin) {
43438 this._scheme = scheme;
43440 this._origin = origin != null ? "?origin=" + origin : "";
43443 * Retrieve an image tile.
43445 * @description Retrieve an image tile by specifying the area
43446 * as well as the scaled size.
43448 * @param {string} identifier - The identifier of the image.
43449 * @param {number} x - The top left x pixel coordinate for the tile
43450 * in the original image.
43451 * @param {number} y - The top left y pixel coordinate for the tile
43452 * in the original image.
43453 * @param {number} w - The pixel width of the tile in the original image.
43454 * @param {number} h - The pixel height of the tile in the original image.
43455 * @param {number} scaledW - The scaled width of the returned tile.
43456 * @param {number} scaledH - The scaled height of the returned tile.
43458 ImageTileLoader.prototype.getTile = function (identifier, x, y, w, h, scaledW, scaledH) {
43459 var characteristics = "/" + identifier + "/" + x + "," + y + "," + w + "," + h + "/" + scaledW + "," + scaledH + "/0/default.jpg";
43460 var url = this._scheme +
43465 var xmlHTTP = null;
43466 return [rxjs_1.Observable.create(function (subscriber) {
43467 xmlHTTP = new XMLHttpRequest();
43468 xmlHTTP.open("GET", url, true);
43469 xmlHTTP.responseType = "arraybuffer";
43470 xmlHTTP.timeout = 15000;
43471 xmlHTTP.onload = function (event) {
43472 if (xmlHTTP.status !== 200) {
43473 subscriber.error(new Error("Failed to fetch tile (" + identifier + ": " + x + "," + y + "," + w + "," + h + "). " +
43474 ("Status: " + xmlHTTP.status + ", " + xmlHTTP.statusText)));
43477 var image = new Image();
43478 image.crossOrigin = "Anonymous";
43479 image.onload = function (e) {
43480 subscriber.next(image);
43481 subscriber.complete();
43483 image.onerror = function (error) {
43484 subscriber.error(new Error("Failed to load tile image (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
43486 var blob = new Blob([xmlHTTP.response]);
43487 image.src = window.URL.createObjectURL(blob);
43489 xmlHTTP.onerror = function (error) {
43490 subscriber.error(new Error("Failed to fetch tile (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
43492 xmlHTTP.ontimeout = function (error) {
43493 subscriber.error(new Error("Tile request timed out (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
43495 xmlHTTP.onabort = function (event) {
43496 subscriber.error(new Error("Tile request was aborted (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
43498 xmlHTTP.send(null);
43501 if (xmlHTTP != null) {
43507 return ImageTileLoader;
43509 exports.ImageTileLoader = ImageTileLoader;
43510 exports.default = ImageTileLoader;
43512 },{"rxjs":26}],422:[function(require,module,exports){
43514 Object.defineProperty(exports, "__esModule", { value: true });
43516 * @class ImageTileStore
43518 * @classdesc Represents a store for image tiles.
43520 var ImageTileStore = /** @class */ (function () {
43522 * Create a new node image tile store instance.
43524 function ImageTileStore() {
43528 * Add an image tile to the store.
43530 * @param {HTMLImageElement} image - The image tile.
43531 * @param {string} key - The identifier for the tile.
43532 * @param {number} level - The level of the tile.
43534 ImageTileStore.prototype.addImage = function (image, key, level) {
43535 if (!(level in this._images)) {
43536 this._images[level] = {};
43538 this._images[level][key] = image;
43541 * Dispose the store.
43543 * @description Disposes all cached assets.
43545 ImageTileStore.prototype.dispose = function () {
43546 for (var _i = 0, _a = Object.keys(this._images); _i < _a.length; _i++) {
43547 var level = _a[_i];
43548 var levelImages = this._images[level];
43549 for (var _b = 0, _c = Object.keys(levelImages); _b < _c.length; _b++) {
43551 window.URL.revokeObjectURL(levelImages[key].src);
43552 delete levelImages[key];
43554 delete this._images[level];
43558 * Get an image tile from the store.
43560 * @param {string} key - The identifier for the tile.
43561 * @param {number} level - The level of the tile.
43563 ImageTileStore.prototype.getImage = function (key, level) {
43564 return this._images[level][key];
43567 * Check if an image tile exist in the store.
43569 * @param {string} key - The identifier for the tile.
43570 * @param {number} level - The level of the tile.
43572 ImageTileStore.prototype.hasImage = function (key, level) {
43573 return level in this._images && key in this._images[level];
43575 return ImageTileStore;
43577 exports.ImageTileStore = ImageTileStore;
43578 exports.default = ImageTileStore;
43580 },{}],423:[function(require,module,exports){
43582 Object.defineProperty(exports, "__esModule", { value: true });
43583 var Geo_1 = require("../Geo");
43585 * @class RegionOfInterestCalculator
43587 * @classdesc Represents a calculator for regions of interest.
43589 var RegionOfInterestCalculator = /** @class */ (function () {
43590 function RegionOfInterestCalculator() {
43591 this._viewportCoords = new Geo_1.ViewportCoords();
43594 * Compute a region of interest based on the current render camera
43595 * and the viewport size.
43597 * @param {RenderCamera} renderCamera - Render camera used for unprojections.
43598 * @param {ISize} size - Viewport size in pixels.
43599 * @param {Transform} transform - Transform used for projections.
43601 * @returns {IRegionOfInterest} A region of interest.
43603 RegionOfInterestCalculator.prototype.computeRegionOfInterest = function (renderCamera, size, transform) {
43604 var viewportBoundaryPoints = this._viewportBoundaryPoints(4);
43605 var bbox = this._viewportPointsBoundingBox(viewportBoundaryPoints, renderCamera, transform);
43606 this._clipBoundingBox(bbox);
43607 var viewportPixelWidth = 2 / size.width;
43608 var viewportPixelHeight = 2 / size.height;
43609 var centralViewportPixel = [
43610 [-0.5 * viewportPixelWidth, 0.5 * viewportPixelHeight],
43611 [0.5 * viewportPixelWidth, 0.5 * viewportPixelHeight],
43612 [0.5 * viewportPixelWidth, -0.5 * viewportPixelHeight],
43613 [-0.5 * viewportPixelWidth, -0.5 * viewportPixelHeight],
43615 var cpbox = this._viewportPointsBoundingBox(centralViewportPixel, renderCamera, transform);
43618 pixelHeight: cpbox.maxY - cpbox.minY,
43619 pixelWidth: cpbox.maxX - cpbox.minX + (cpbox.minX < cpbox.maxX ? 0 : 1),
43622 RegionOfInterestCalculator.prototype._viewportBoundaryPoints = function (pointsPerSide) {
43624 var os = [[-1, 1], [1, 1], [1, -1], [-1, -1]];
43625 var ds = [[2, 0], [0, -2], [-2, 0], [0, 2]];
43626 for (var side = 0; side < 4; ++side) {
43629 for (var i = 0; i < pointsPerSide; ++i) {
43630 points.push([o[0] + d[0] * i / pointsPerSide,
43631 o[1] + d[1] * i / pointsPerSide]);
43636 RegionOfInterestCalculator.prototype._viewportPointsBoundingBox = function (viewportPoints, renderCamera, transform) {
43638 var basicPoints = viewportPoints
43639 .map(function (point) {
43640 return _this._viewportCoords
43641 .viewportToBasic(point[0], point[1], transform, renderCamera.perspective);
43643 if (transform.gpano != null) {
43644 return this._boundingBoxPano(basicPoints);
43647 return this._boundingBox(basicPoints);
43650 RegionOfInterestCalculator.prototype._boundingBox = function (points) {
43652 maxX: Number.NEGATIVE_INFINITY,
43653 maxY: Number.NEGATIVE_INFINITY,
43654 minX: Number.POSITIVE_INFINITY,
43655 minY: Number.POSITIVE_INFINITY,
43657 for (var i = 0; i < points.length; ++i) {
43658 bbox.minX = Math.min(bbox.minX, points[i][0]);
43659 bbox.maxX = Math.max(bbox.maxX, points[i][0]);
43660 bbox.minY = Math.min(bbox.minY, points[i][1]);
43661 bbox.maxY = Math.max(bbox.maxY, points[i][1]);
43665 RegionOfInterestCalculator.prototype._boundingBoxPano = function (points) {
43669 for (var i = 0; i < points.length; ++i) {
43670 xs.push(points[i][0]);
43671 ys.push(points[i][1]);
43673 xs.sort(function (a, b) { return _this._sign(a - b); });
43674 ys.sort(function (a, b) { return _this._sign(a - b); });
43675 var intervalX = this._intervalPano(xs);
43677 maxX: intervalX[1],
43678 maxY: ys[ys.length - 1],
43679 minX: intervalX[0],
43684 * Find the max interval between consecutive numbers.
43685 * Assumes numbers are between 0 and 1, sorted and that
43686 * x is equivalent to x + 1.
43688 RegionOfInterestCalculator.prototype._intervalPano = function (xs) {
43691 for (var i = 0; i < xs.length - 1; ++i) {
43692 var dx = xs[i + 1] - xs[i];
43698 var loopdx = xs[0] + 1 - xs[xs.length - 1];
43699 if (loopdx > maxdx) {
43700 return [xs[0], xs[xs.length - 1]];
43703 return [xs[maxi + 1], xs[maxi]];
43706 RegionOfInterestCalculator.prototype._clipBoundingBox = function (bbox) {
43707 bbox.minX = Math.max(0, Math.min(1, bbox.minX));
43708 bbox.maxX = Math.max(0, Math.min(1, bbox.maxX));
43709 bbox.minY = Math.max(0, Math.min(1, bbox.minY));
43710 bbox.maxY = Math.max(0, Math.min(1, bbox.maxY));
43712 RegionOfInterestCalculator.prototype._sign = function (n) {
43713 return n > 0 ? 1 : n < 0 ? -1 : 0;
43715 return RegionOfInterestCalculator;
43717 exports.RegionOfInterestCalculator = RegionOfInterestCalculator;
43718 exports.default = RegionOfInterestCalculator;
43720 },{"../Geo":277}],424:[function(require,module,exports){
43722 Object.defineProperty(exports, "__esModule", { value: true });
43723 var operators_1 = require("rxjs/operators");
43724 var THREE = require("three");
43725 var rxjs_1 = require("rxjs");
43727 * @class TextureProvider
43729 * @classdesc Represents a provider of textures.
43731 var TextureProvider = /** @class */ (function () {
43733 * Create a new node texture provider instance.
43735 * @param {string} key - The identifier of the image for which to request tiles.
43736 * @param {number} width - The full width of the original image.
43737 * @param {number} height - The full height of the original image.
43738 * @param {number} tileSize - The size used when requesting tiles.
43739 * @param {HTMLImageElement} background - Image to use as background.
43740 * @param {ImageTileLoader} imageTileLoader - Loader for retrieving tiles.
43741 * @param {ImageTileStore} imageTileStore - Store for saving tiles.
43742 * @param {THREE.WebGLRenderer} renderer - Renderer used for rendering tiles to texture.
43744 function TextureProvider(key, width, height, tileSize, background, imageTileLoader, imageTileStore, renderer) {
43745 this._disposed = false;
43747 if (width <= 0 || height <= 0) {
43748 console.warn("Original image size (" + width + ", " + height + ") is invalid (" + key + "). Tiles will not be loaded.");
43750 this._width = width;
43751 this._height = height;
43752 this._maxLevel = Math.ceil(Math.log(Math.max(height, width)) / Math.log(2));
43753 this._currentLevel = -1;
43754 this._tileSize = tileSize;
43755 this._updated$ = new rxjs_1.Subject();
43756 this._createdSubject$ = new rxjs_1.Subject();
43757 this._created$ = this._createdSubject$.pipe(operators_1.publishReplay(1), operators_1.refCount());
43758 this._createdSubscription = this._created$.subscribe(function () { });
43759 this._hasSubject$ = new rxjs_1.Subject();
43760 this._has$ = this._hasSubject$.pipe(operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
43761 this._hasSubscription = this._has$.subscribe(function () { });
43762 this._abortFunctions = [];
43763 this._tileSubscriptions = {};
43764 this._renderedCurrentLevelTiles = {};
43765 this._renderedTiles = {};
43766 this._background = background;
43767 this._camera = null;
43768 this._imageTileLoader = imageTileLoader;
43769 this._imageTileStore = imageTileStore;
43770 this._renderer = renderer;
43771 this._renderTarget = null;
43774 Object.defineProperty(TextureProvider.prototype, "disposed", {
43778 * @returns {boolean} Value indicating whether provider has
43782 return this._disposed;
43787 Object.defineProperty(TextureProvider.prototype, "hasTexture$", {
43791 * @returns {Observable<boolean>} Observable emitting
43792 * values indicating when the existance of a texture
43801 Object.defineProperty(TextureProvider.prototype, "key", {
43805 * @returns {boolean} The identifier of the image for
43806 * which to render textures.
43814 Object.defineProperty(TextureProvider.prototype, "textureUpdated$", {
43816 * Get textureUpdated$.
43818 * @returns {Observable<boolean>} Observable emitting
43819 * values when an existing texture has been updated.
43822 return this._updated$;
43827 Object.defineProperty(TextureProvider.prototype, "textureCreated$", {
43829 * Get textureCreated$.
43831 * @returns {Observable<boolean>} Observable emitting
43832 * values when a new texture has been created.
43835 return this._created$;
43841 * Abort all outstanding image tile requests.
43843 TextureProvider.prototype.abort = function () {
43844 for (var key in this._tileSubscriptions) {
43845 if (!this._tileSubscriptions.hasOwnProperty(key)) {
43848 this._tileSubscriptions[key].unsubscribe();
43850 this._tileSubscriptions = {};
43851 for (var _i = 0, _a = this._abortFunctions; _i < _a.length; _i++) {
43852 var abort = _a[_i];
43855 this._abortFunctions = [];
43858 * Dispose the provider.
43860 * @description Disposes all cached assets and
43861 * aborts all outstanding image tile requests.
43863 TextureProvider.prototype.dispose = function () {
43864 if (this._disposed) {
43865 console.warn("Texture already disposed (" + this._key + ")");
43869 if (this._renderTarget != null) {
43870 this._renderTarget.dispose();
43871 this._renderTarget = null;
43873 this._imageTileStore.dispose();
43874 this._imageTileStore = null;
43875 this._background = null;
43876 this._camera = null;
43877 this._imageTileLoader = null;
43878 this._renderer = null;
43880 this._createdSubscription.unsubscribe();
43881 this._hasSubscription.unsubscribe();
43882 this._disposed = true;
43885 * Set the region of interest.
43887 * @description When the region of interest is set the
43888 * the tile level is determined and tiles for the region
43889 * are fetched from the store or the loader and renderedLevel
43892 * @param {IRegionOfInterest} roi - Spatial edges to cache.
43894 TextureProvider.prototype.setRegionOfInterest = function (roi) {
43895 if (this._width <= 0 || this._height <= 0) {
43899 var width = 1 / this._roi.pixelWidth;
43900 var height = 1 / this._roi.pixelHeight;
43901 var size = Math.max(height, width);
43902 var currentLevel = Math.max(0, Math.min(this._maxLevel, Math.ceil(Math.log(size) / Math.log(2))));
43903 if (currentLevel !== this._currentLevel) {
43905 this._currentLevel = currentLevel;
43906 if (!(this._currentLevel in this._renderedTiles)) {
43907 this._renderedTiles[this._currentLevel] = [];
43909 this._renderedCurrentLevelTiles = {};
43910 for (var _i = 0, _a = this._renderedTiles[this._currentLevel]; _i < _a.length; _i++) {
43912 this._renderedCurrentLevelTiles[this._tileKey(this._tileSize, tile)] = true;
43915 var topLeft = this._getTileCoords([this._roi.bbox.minX, this._roi.bbox.minY]);
43916 var bottomRight = this._getTileCoords([this._roi.bbox.maxX, this._roi.bbox.maxY]);
43917 var tiles = this._getTiles(topLeft, bottomRight);
43918 if (this._camera == null) {
43919 this._camera = new THREE.OrthographicCamera(-this._width / 2, this._width / 2, this._height / 2, -this._height / 2, -1, 1);
43920 this._camera.position.z = 1;
43921 var gl = this._renderer.getContext();
43922 var maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
43923 var backgroundSize = Math.max(this._width, this._height);
43924 var scale = maxTextureSize > backgroundSize ? 1 : maxTextureSize / backgroundSize;
43925 var targetWidth = Math.floor(scale * this._width);
43926 var targetHeight = Math.floor(scale * this._height);
43927 this._renderTarget = new THREE.WebGLRenderTarget(targetWidth, targetHeight, {
43928 depthBuffer: false,
43929 format: THREE.RGBFormat,
43930 magFilter: THREE.LinearFilter,
43931 minFilter: THREE.LinearFilter,
43932 stencilBuffer: false,
43934 this._renderToTarget(0, 0, this._width, this._height, this._background);
43935 this._createdSubject$.next(this._renderTarget.texture);
43936 this._hasSubject$.next(true);
43938 this._fetchTiles(tiles);
43940 TextureProvider.prototype.setTileSize = function (tileSize) {
43941 this._tileSize = tileSize;
43944 * Update the image used as background for the texture.
43946 * @param {HTMLImageElement} background - The background image.
43948 TextureProvider.prototype.updateBackground = function (background) {
43949 this._background = background;
43952 * Retrieve an image tile.
43954 * @description Retrieve an image tile and render it to the
43955 * texture. Add the tile to the store and emit to the updated
43958 * @param {Array<number>} tile - The tile coordinates.
43959 * @param {number} level - The tile level.
43960 * @param {number} x - The top left x pixel coordinate of the tile.
43961 * @param {number} y - The top left y pixel coordinate of the tile.
43962 * @param {number} w - The pixel width of the tile.
43963 * @param {number} h - The pixel height of the tile.
43964 * @param {number} scaledW - The scaled width of the returned tile.
43965 * @param {number} scaledH - The scaled height of the returned tile.
43967 TextureProvider.prototype._fetchTile = function (tile, level, x, y, w, h, scaledX, scaledY) {
43969 var getTile = this._imageTileLoader.getTile(this._key, x, y, w, h, scaledX, scaledY);
43970 var tile$ = getTile[0];
43971 var abort = getTile[1];
43972 this._abortFunctions.push(abort);
43973 var tileKey = this._tileKey(this._tileSize, tile);
43974 var subscription = tile$
43975 .subscribe(function (image) {
43976 _this._renderToTarget(x, y, w, h, image);
43977 _this._removeFromDictionary(tileKey, _this._tileSubscriptions);
43978 _this._removeFromArray(abort, _this._abortFunctions);
43979 _this._setTileRendered(tile, _this._currentLevel);
43980 _this._imageTileStore.addImage(image, tileKey, level);
43981 _this._updated$.next(true);
43982 }, function (error) {
43983 _this._removeFromDictionary(tileKey, _this._tileSubscriptions);
43984 _this._removeFromArray(abort, _this._abortFunctions);
43985 console.error(error);
43987 if (!subscription.closed) {
43988 this._tileSubscriptions[tileKey] = subscription;
43992 * Retrieve image tiles.
43994 * @description Retrieve a image tiles and render them to the
43995 * texture. Retrieve from store if it exists, otherwise Retrieve
43998 * @param {Array<Array<number>>} tiles - Array of tile coordinates to
44001 TextureProvider.prototype._fetchTiles = function (tiles) {
44002 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
44003 for (var _i = 0, tiles_1 = tiles; _i < tiles_1.length; _i++) {
44004 var tile = tiles_1[_i];
44005 var tileKey = this._tileKey(this._tileSize, tile);
44006 if (tileKey in this._renderedCurrentLevelTiles ||
44007 tileKey in this._tileSubscriptions) {
44010 var tileX = tileSize * tile[0];
44011 var tileY = tileSize * tile[1];
44012 var tileWidth = tileX + tileSize > this._width ? this._width - tileX : tileSize;
44013 var tileHeight = tileY + tileSize > this._height ? this._height - tileY : tileSize;
44014 if (this._imageTileStore.hasImage(tileKey, this._currentLevel)) {
44015 this._renderToTarget(tileX, tileY, tileWidth, tileHeight, this._imageTileStore.getImage(tileKey, this._currentLevel));
44016 this._setTileRendered(tile, this._currentLevel);
44017 this._updated$.next(true);
44020 var scaledX = Math.floor(tileWidth / tileSize * this._tileSize);
44021 var scaledY = Math.floor(tileHeight / tileSize * this._tileSize);
44022 this._fetchTile(tile, this._currentLevel, tileX, tileY, tileWidth, tileHeight, scaledX, scaledY);
44026 * Get tile coordinates for a point using the current level.
44028 * @param {Array<number>} point - Point in basic coordinates.
44030 * @returns {Array<number>} x and y tile coodinates.
44032 TextureProvider.prototype._getTileCoords = function (point) {
44033 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
44034 var maxX = Math.ceil(this._width / tileSize) - 1;
44035 var maxY = Math.ceil(this._height / tileSize) - 1;
44037 Math.min(Math.floor(this._width * point[0] / tileSize), maxX),
44038 Math.min(Math.floor(this._height * point[1] / tileSize), maxY),
44042 * Get tile coordinates for all tiles contained in a bounding
44045 * @param {Array<number>} topLeft - Top left tile coordinate of bounding box.
44046 * @param {Array<number>} bottomRight - Bottom right tile coordinate of bounding box.
44048 * @returns {Array<Array<number>>} Array of x, y tile coodinates.
44050 TextureProvider.prototype._getTiles = function (topLeft, bottomRight) {
44052 if (topLeft[0] > bottomRight[0]) {
44053 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
44054 var maxX = Math.ceil(this._width / tileSize) - 1;
44055 for (var x = topLeft[0]; x <= maxX; x++) {
44058 for (var x = 0; x <= bottomRight[0]; x++) {
44063 for (var x = topLeft[0]; x <= bottomRight[0]; x++) {
44068 for (var _i = 0, xs_1 = xs; _i < xs_1.length; _i++) {
44070 for (var y = topLeft[1]; y <= bottomRight[1]; y++) {
44071 tiles.push([x, y]);
44077 * Remove an item from an array if it exists in array.
44079 * @param {T} item - Item to remove.
44080 * @param {Array<T>} array - Array from which item should be removed.
44082 TextureProvider.prototype._removeFromArray = function (item, array) {
44083 var index = array.indexOf(item);
44084 if (index !== -1) {
44085 array.splice(index, 1);
44089 * Remove an item from a dictionary.
44091 * @param {string} key - Key of the item to remove.
44092 * @param {Object} dict - Dictionary from which item should be removed.
44094 TextureProvider.prototype._removeFromDictionary = function (key, dict) {
44100 * Render an image tile to the target texture.
44102 * @param {number} x - The top left x pixel coordinate of the tile.
44103 * @param {number} y - The top left y pixel coordinate of the tile.
44104 * @param {number} w - The pixel width of the tile.
44105 * @param {number} h - The pixel height of the tile.
44106 * @param {HTMLImageElement} background - The image tile to render.
44108 TextureProvider.prototype._renderToTarget = function (x, y, w, h, image) {
44109 var texture = new THREE.Texture(image);
44110 texture.minFilter = THREE.LinearFilter;
44111 texture.needsUpdate = true;
44112 var geometry = new THREE.PlaneGeometry(w, h);
44113 var material = new THREE.MeshBasicMaterial({ map: texture, side: THREE.FrontSide });
44114 var mesh = new THREE.Mesh(geometry, material);
44115 mesh.position.x = -this._width / 2 + x + w / 2;
44116 mesh.position.y = this._height / 2 - y - h / 2;
44117 var scene = new THREE.Scene();
44119 this._renderer.render(scene, this._camera, this._renderTarget);
44120 this._renderer.setRenderTarget(undefined);
44121 scene.remove(mesh);
44122 geometry.dispose();
44123 material.dispose();
44127 * Mark a tile as rendered.
44129 * @description Clears tiles marked as rendered in other
44130 * levels of the tile pyramid if they were rendered on
44131 * top of or below the tile.
44133 * @param {Arrary<number>} tile - The tile coordinates.
44134 * @param {number} level - Tile level of the tile coordinates.
44136 TextureProvider.prototype._setTileRendered = function (tile, level) {
44137 var otherLevels = Object.keys(this._renderedTiles)
44138 .map(function (key) {
44139 return parseInt(key, 10);
44141 .filter(function (renderedLevel) {
44142 return renderedLevel !== level;
44144 for (var _i = 0, otherLevels_1 = otherLevels; _i < otherLevels_1.length; _i++) {
44145 var otherLevel = otherLevels_1[_i];
44146 var scale = Math.pow(2, otherLevel - level);
44147 if (otherLevel < level) {
44148 var x = Math.floor(scale * tile[0]);
44149 var y = Math.floor(scale * tile[1]);
44150 for (var _a = 0, _b = this._renderedTiles[otherLevel].slice(); _a < _b.length; _a++) {
44151 var otherTile = _b[_a];
44152 if (otherTile[0] === x && otherTile[1] === y) {
44153 var index = this._renderedTiles[otherLevel].indexOf(otherTile);
44154 this._renderedTiles[otherLevel].splice(index, 1);
44159 var startX = scale * tile[0];
44160 var endX = startX + scale - 1;
44161 var startY = scale * tile[1];
44162 var endY = startY + scale - 1;
44163 for (var _c = 0, _d = this._renderedTiles[otherLevel].slice(); _c < _d.length; _c++) {
44164 var otherTile = _d[_c];
44165 if (otherTile[0] >= startX && otherTile[0] <= endX &&
44166 otherTile[1] >= startY && otherTile[1] <= endY) {
44167 var index = this._renderedTiles[otherLevel].indexOf(otherTile);
44168 this._renderedTiles[otherLevel].splice(index, 1);
44172 if (this._renderedTiles[otherLevel].length === 0) {
44173 delete this._renderedTiles[otherLevel];
44176 this._renderedTiles[level].push(tile);
44177 this._renderedCurrentLevelTiles[this._tileKey(this._tileSize, tile)] = true;
44180 * Create a tile key from a tile coordinates.
44182 * @description Tile keys are used as a hash for
44183 * storing the tile in a dictionary.
44185 * @param {number} tileSize - The tile size.
44186 * @param {Arrary<number>} tile - The tile coordinates.
44188 TextureProvider.prototype._tileKey = function (tileSize, tile) {
44189 return tileSize + "-" + tile[0] + "-" + tile[1];
44191 return TextureProvider;
44193 exports.TextureProvider = TextureProvider;
44194 exports.default = TextureProvider;
44196 },{"rxjs":26,"rxjs/operators":224,"three":225}],425:[function(require,module,exports){
44198 Object.defineProperty(exports, "__esModule", { value: true });
44199 var DOM = /** @class */ (function () {
44200 function DOM(doc) {
44201 this._document = !!doc ? doc : document;
44203 Object.defineProperty(DOM.prototype, "document", {
44205 return this._document;
44210 DOM.prototype.createElement = function (tagName, className, container) {
44211 var element = this._document.createElement(tagName);
44213 element.className = className;
44216 container.appendChild(element);
44223 exports.default = DOM;
44225 },{}],426:[function(require,module,exports){
44227 Object.defineProperty(exports, "__esModule", { value: true });
44228 var EventEmitter = /** @class */ (function () {
44229 function EventEmitter() {
44233 * Subscribe to an event by its name.
44234 * @param {string }eventType - The name of the event to subscribe to.
44235 * @param {any} fn - The handler called when the event occurs.
44237 EventEmitter.prototype.on = function (eventType, fn) {
44238 this._events[eventType] = this._events[eventType] || [];
44239 this._events[eventType].push(fn);
44243 * Unsubscribe from an event by its name.
44244 * @param {string} eventType - The name of the event to subscribe to.
44245 * @param {any} fn - The handler to remove.
44247 EventEmitter.prototype.off = function (eventType, fn) {
44252 if (!this._listens(eventType)) {
44253 var idx = this._events[eventType].indexOf(fn);
44255 this._events[eventType].splice(idx, 1);
44257 if (this._events[eventType].length) {
44258 delete this._events[eventType];
44262 delete this._events[eventType];
44266 EventEmitter.prototype.fire = function (eventType, data) {
44267 if (!this._listens(eventType)) {
44270 for (var _i = 0, _a = this._events[eventType]; _i < _a.length; _i++) {
44272 fn.call(this, data);
44276 EventEmitter.prototype._listens = function (eventType) {
44277 return !!(this._events && this._events[eventType]);
44279 return EventEmitter;
44281 exports.EventEmitter = EventEmitter;
44282 exports.default = EventEmitter;
44284 },{}],427:[function(require,module,exports){
44286 Object.defineProperty(exports, "__esModule", { value: true });
44287 var Viewer_1 = require("../Viewer");
44288 var Settings = /** @class */ (function () {
44289 function Settings() {
44291 Settings.setOptions = function (options) {
44292 Settings._baseImageSize = options.baseImageSize != null ?
44293 options.baseImageSize :
44294 Viewer_1.ImageSize.Size640;
44295 Settings._basePanoramaSize = options.basePanoramaSize != null ?
44296 options.basePanoramaSize :
44297 Viewer_1.ImageSize.Size2048;
44298 Settings._maxImageSize = options.maxImageSize != null ?
44299 options.maxImageSize :
44300 Viewer_1.ImageSize.Size2048;
44302 Object.defineProperty(Settings, "baseImageSize", {
44304 return Settings._baseImageSize;
44309 Object.defineProperty(Settings, "basePanoramaSize", {
44311 return Settings._basePanoramaSize;
44316 Object.defineProperty(Settings, "maxImageSize", {
44318 return Settings._maxImageSize;
44325 exports.Settings = Settings;
44326 exports.default = Settings;
44328 },{"../Viewer":285}],428:[function(require,module,exports){
44330 Object.defineProperty(exports, "__esModule", { value: true });
44331 function isBrowser() {
44332 return typeof window !== "undefined" && typeof document !== "undefined";
44334 exports.isBrowser = isBrowser;
44335 function isArraySupported() {
44336 return !!(Array.prototype &&
44337 Array.prototype.filter &&
44338 Array.prototype.indexOf &&
44339 Array.prototype.map &&
44340 Array.prototype.reverse);
44342 exports.isArraySupported = isArraySupported;
44343 function isFunctionSupported() {
44344 return !!(Function.prototype && Function.prototype.bind);
44346 exports.isFunctionSupported = isFunctionSupported;
44347 function isJSONSupported() {
44348 return "JSON" in window && "parse" in JSON && "stringify" in JSON;
44350 exports.isJSONSupported = isJSONSupported;
44351 function isObjectSupported() {
44352 return !!(Object.keys &&
44355 exports.isObjectSupported = isObjectSupported;
44356 function isBlobSupported() {
44357 return "Blob" in window && "URL" in window;
44359 exports.isBlobSupported = isBlobSupported;
44360 var isWebGLSupportedCache = undefined;
44361 function isWebGLSupportedCached() {
44362 if (isWebGLSupportedCache === undefined) {
44363 isWebGLSupportedCache = isWebGLSupported();
44365 return isWebGLSupportedCache;
44367 exports.isWebGLSupportedCached = isWebGLSupportedCached;
44368 function isWebGLSupported() {
44369 var webGLContextAttributes = {
44373 failIfMajorPerformanceCaveat: false,
44374 premultipliedAlpha: true,
44375 preserveDrawingBuffer: false,
44378 var canvas = document.createElement("canvas");
44379 var context = canvas.getContext("webgl", webGLContextAttributes) ||
44380 canvas.getContext("experimental-webgl", webGLContextAttributes);
44384 var requiredExtensions = [
44385 "OES_standard_derivatives",
44387 var supportedExtensions = context.getSupportedExtensions();
44388 for (var _i = 0, requiredExtensions_1 = requiredExtensions; _i < requiredExtensions_1.length; _i++) {
44389 var requiredExtension = requiredExtensions_1[_i];
44390 if (supportedExtensions.indexOf(requiredExtension) === -1) {
44396 exports.isWebGLSupported = isWebGLSupported;
44398 },{}],429:[function(require,module,exports){
44400 Object.defineProperty(exports, "__esModule", { value: true });
44401 var Urls = /** @class */ (function () {
44404 Object.defineProperty(Urls, "explore", {
44406 return Urls._scheme + "://" + Urls._exploreHost;
44411 Object.defineProperty(Urls, "origin", {
44413 return Urls._origin;
44418 Object.defineProperty(Urls, "tileScheme", {
44420 return Urls._scheme;
44425 Object.defineProperty(Urls, "tileDomain", {
44427 return Urls._imageTileHost;
44432 Urls.atomicReconstruction = function (key) {
44433 return Urls._scheme + "://" + Urls._atomicReconstructionHost + "/" + key + "/sfm/v1.0/atomic_reconstruction.json";
44435 Urls.exporeImage = function (key) {
44436 return Urls._scheme + "://" + Urls._exploreHost + "/app/?pKey=" + key + "&focus=photo";
44438 Urls.exporeUser = function (username) {
44439 return Urls._scheme + "://" + Urls._exploreHost + "/app/user/" + username;
44441 Urls.falcorModel = function (clientId) {
44442 return Urls._scheme + "://" + Urls._apiHost + "/v3/model.json?client_id=" + clientId;
44444 Urls.protoMesh = function (key) {
44445 return Urls._scheme + "://" + Urls._meshHost + "/v2/mesh/" + key;
44447 Urls.thumbnail = function (key, size, origin) {
44448 var query = !!origin ? "?origin=" + origin : "";
44449 return Urls._scheme + "://" + Urls._imageHost + "/" + key + "/thumb-" + size + ".jpg" + query;
44451 Urls.setOptions = function (options) {
44455 if (!!options.apiHost) {
44456 Urls._apiHost = options.apiHost;
44458 if (!!options.atomicReconstructionHost) {
44459 Urls._atomicReconstructionHost = options.atomicReconstructionHost;
44461 if (!!options.exploreHost) {
44462 Urls._exploreHost = options.exploreHost;
44464 if (!!options.imageHost) {
44465 Urls._imageHost = options.imageHost;
44467 if (!!options.imageTileHost) {
44468 Urls._imageTileHost = options.imageTileHost;
44470 if (!!options.meshHost) {
44471 Urls._meshHost = options.meshHost;
44473 if (!!options.scheme) {
44474 Urls._scheme = options.scheme;
44477 Urls._apiHost = "a.mapillary.com";
44478 Urls._atomicReconstructionHost = "d3necqxnn15whe.cloudfront.net";
44479 Urls._exploreHost = "www.mapillary.com";
44480 Urls._imageHost = "d1cuyjsrcm0gby.cloudfront.net";
44481 Urls._imageTileHost = "d2qb1440i7l50o.cloudfront.net";
44482 Urls._meshHost = "d1brzeo354iq2l.cloudfront.net";
44483 Urls._origin = "mapillary.webgl";
44484 Urls._scheme = "https";
44487 exports.Urls = Urls;
44488 exports.default = Urls;
44490 },{}],430:[function(require,module,exports){
44492 Object.defineProperty(exports, "__esModule", { value: true });
44494 * Enumeration for alignments
44499 (function (Alignment) {
44503 Alignment[Alignment["Bottom"] = 0] = "Bottom";
44505 * Align to bottom left
44507 Alignment[Alignment["BottomLeft"] = 1] = "BottomLeft";
44509 * Align to bottom right
44511 Alignment[Alignment["BottomRight"] = 2] = "BottomRight";
44515 Alignment[Alignment["Center"] = 3] = "Center";
44519 Alignment[Alignment["Left"] = 4] = "Left";
44523 Alignment[Alignment["Right"] = 5] = "Right";
44527 Alignment[Alignment["Top"] = 6] = "Top";
44529 * Align to top left
44531 Alignment[Alignment["TopLeft"] = 7] = "TopLeft";
44533 * Align to top right
44535 Alignment[Alignment["TopRight"] = 8] = "TopRight";
44536 })(Alignment = exports.Alignment || (exports.Alignment = {}));
44537 exports.default = Alignment;
44539 },{}],431:[function(require,module,exports){
44541 Object.defineProperty(exports, "__esModule", { value: true });
44542 var rxjs_1 = require("rxjs");
44543 var operators_1 = require("rxjs/operators");
44544 var Graph_1 = require("../Graph");
44545 var CacheService = /** @class */ (function () {
44546 function CacheService(graphService, stateService) {
44547 this._graphService = graphService;
44548 this._stateService = stateService;
44549 this._started = false;
44551 Object.defineProperty(CacheService.prototype, "started", {
44553 return this._started;
44558 CacheService.prototype.start = function () {
44560 if (this._started) {
44563 this._uncacheSubscription = this._stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
44564 return frame.state.currentNode.key;
44565 }), operators_1.map(function (frame) {
44566 var trajectory = frame.state.trajectory;
44567 var trajectoryKeys = trajectory
44568 .map(function (n) {
44571 var sequenceKey = trajectory[trajectory.length - 1].sequenceKey;
44572 return [trajectoryKeys, sequenceKey];
44573 }), operators_1.bufferCount(1, 5), operators_1.withLatestFrom(this._graphService.graphMode$), operators_1.switchMap(function (_a) {
44574 var keepBuffer = _a[0], graphMode = _a[1];
44575 var keepKeys = keepBuffer[0][0];
44576 var keepSequenceKey = graphMode === Graph_1.GraphMode.Sequence ?
44577 keepBuffer[0][1] : undefined;
44578 return _this._graphService.uncache$(keepKeys, keepSequenceKey);
44580 .subscribe(function () { });
44581 this._cacheNodeSubscription = this._graphService.graphMode$.pipe(operators_1.skip(1), operators_1.withLatestFrom(this._stateService.currentState$), operators_1.switchMap(function (_a) {
44582 var mode = _a[0], frame = _a[1];
44583 return mode === Graph_1.GraphMode.Sequence ?
44584 _this._keyToEdges(frame.state.currentNode.key, function (node) {
44585 return node.sequenceEdges$;
44587 rxjs_1.from(frame.state.trajectory
44588 .map(function (node) {
44591 .slice(frame.state.currentIndex)).pipe(operators_1.mergeMap(function (key) {
44592 return _this._keyToEdges(key, function (node) {
44593 return node.spatialEdges$;
44597 .subscribe(function () { });
44598 this._started = true;
44600 CacheService.prototype.stop = function () {
44601 if (!this._started) {
44604 this._uncacheSubscription.unsubscribe();
44605 this._uncacheSubscription = null;
44606 this._cacheNodeSubscription.unsubscribe();
44607 this._cacheNodeSubscription = null;
44608 this._started = false;
44610 CacheService.prototype._keyToEdges = function (key, nodeToEdgeMap) {
44611 return this._graphService.cacheNode$(key).pipe(operators_1.switchMap(nodeToEdgeMap), operators_1.first(function (status) {
44612 return status.cached;
44613 }), operators_1.timeout(15000), operators_1.catchError(function (error) {
44614 console.error("Failed to cache edges (" + key + ").", error);
44615 return rxjs_1.empty();
44618 return CacheService;
44620 exports.CacheService = CacheService;
44621 exports.default = CacheService;
44623 },{"../Graph":278,"rxjs":26,"rxjs/operators":224}],432:[function(require,module,exports){
44625 Object.defineProperty(exports, "__esModule", { value: true });
44626 var operators_1 = require("rxjs/operators");
44627 var Component_1 = require("../Component");
44628 var ComponentController = /** @class */ (function () {
44629 function ComponentController(container, navigator, observer, key, options, componentService) {
44631 this._container = container;
44632 this._observer = observer;
44633 this._navigator = navigator;
44634 this._options = options != null ? options : {};
44636 this._navigable = key == null;
44637 this._componentService = !!componentService ?
44639 new Component_1.ComponentService(this._container, this._navigator);
44640 this._coverComponent = this._componentService.getCover();
44641 this._initializeComponents();
44643 this._initilizeCoverComponent();
44644 this._subscribeCoverComponent();
44647 this._navigator.movedToKey$.pipe(operators_1.first(function (k) {
44650 .subscribe(function (k) {
44652 _this._componentService.deactivateCover();
44653 _this._coverComponent.configure({ key: _this._key, state: Component_1.CoverState.Hidden });
44654 _this._subscribeCoverComponent();
44655 _this._navigator.stateService.start();
44656 _this._navigator.cacheService.start();
44657 _this._observer.startEmit();
44661 Object.defineProperty(ComponentController.prototype, "navigable", {
44663 return this._navigable;
44668 ComponentController.prototype.get = function (name) {
44669 return this._componentService.get(name);
44671 ComponentController.prototype.activate = function (name) {
44672 this._componentService.activate(name);
44674 ComponentController.prototype.activateCover = function () {
44675 this._coverComponent.configure({ state: Component_1.CoverState.Visible });
44677 ComponentController.prototype.deactivate = function (name) {
44678 this._componentService.deactivate(name);
44680 ComponentController.prototype.deactivateCover = function () {
44681 this._coverComponent.configure({ state: Component_1.CoverState.Loading });
44683 ComponentController.prototype.resize = function () {
44684 this._componentService.resize();
44686 ComponentController.prototype._initializeComponents = function () {
44687 var options = this._options;
44688 this._uFalse(options.background, "background");
44689 this._uFalse(options.debug, "debug");
44690 this._uFalse(options.image, "image");
44691 this._uFalse(options.marker, "marker");
44692 this._uFalse(options.navigation, "navigation");
44693 this._uFalse(options.popup, "popup");
44694 this._uFalse(options.route, "route");
44695 this._uFalse(options.slider, "slider");
44696 this._uFalse(options.spatialData, "spatialData");
44697 this._uFalse(options.tag, "tag");
44698 this._uTrue(options.attribution, "attribution");
44699 this._uTrue(options.bearing, "bearing");
44700 this._uTrue(options.cache, "cache");
44701 this._uTrue(options.direction, "direction");
44702 this._uTrue(options.imagePlane, "imagePlane");
44703 this._uTrue(options.keyboard, "keyboard");
44704 this._uTrue(options.loading, "loading");
44705 this._uTrue(options.mouse, "mouse");
44706 this._uTrue(options.sequence, "sequence");
44707 this._uTrue(options.stats, "stats");
44708 this._uTrue(options.zoom, "zoom");
44710 ComponentController.prototype._initilizeCoverComponent = function () {
44711 var options = this._options;
44712 this._coverComponent.configure({ key: this._key });
44713 if (options.cover === undefined || options.cover) {
44714 this.activateCover();
44717 this.deactivateCover();
44720 ComponentController.prototype._setNavigable = function (navigable) {
44721 if (this._navigable === navigable) {
44724 this._navigable = navigable;
44725 this._observer.navigable$.next(navigable);
44727 ComponentController.prototype._subscribeCoverComponent = function () {
44729 this._coverComponent.configuration$.pipe(operators_1.distinctUntilChanged(undefined, function (c) {
44732 .subscribe(function (conf) {
44733 if (conf.state === Component_1.CoverState.Loading) {
44734 _this._navigator.stateService.currentKey$.pipe(operators_1.first(), operators_1.switchMap(function (key) {
44735 var keyChanged = key == null || key !== conf.key;
44737 _this._setNavigable(false);
44739 return keyChanged ?
44740 _this._navigator.moveToKey$(conf.key) :
44741 _this._navigator.stateService.currentNode$.pipe(operators_1.first());
44743 .subscribe(function () {
44744 _this._navigator.stateService.start();
44745 _this._navigator.cacheService.start();
44746 _this._observer.startEmit();
44747 _this._coverComponent.configure({ state: Component_1.CoverState.Hidden });
44748 _this._componentService.deactivateCover();
44749 _this._setNavigable(true);
44750 }, function (error) {
44751 console.error("Failed to deactivate cover.", error);
44752 _this._coverComponent.configure({ state: Component_1.CoverState.Visible });
44755 else if (conf.state === Component_1.CoverState.Visible) {
44756 _this._observer.stopEmit();
44757 _this._navigator.stateService.stop();
44758 _this._navigator.cacheService.stop();
44759 _this._navigator.playService.stop();
44760 _this._componentService.activateCover();
44761 _this._setNavigable(conf.key == null);
44765 ComponentController.prototype._uFalse = function (option, name) {
44766 if (option === undefined) {
44767 this._componentService.deactivate(name);
44770 if (typeof option === "boolean") {
44772 this._componentService.activate(name);
44775 this._componentService.deactivate(name);
44779 this._componentService.configure(name, option);
44780 this._componentService.activate(name);
44782 ComponentController.prototype._uTrue = function (option, name) {
44783 if (option === undefined) {
44784 this._componentService.activate(name);
44787 if (typeof option === "boolean") {
44789 this._componentService.activate(name);
44792 this._componentService.deactivate(name);
44796 this._componentService.configure(name, option);
44797 this._componentService.activate(name);
44799 return ComponentController;
44801 exports.ComponentController = ComponentController;
44803 },{"../Component":274,"rxjs/operators":224}],433:[function(require,module,exports){
44805 Object.defineProperty(exports, "__esModule", { value: true });
44806 var Render_1 = require("../Render");
44807 var Utils_1 = require("../Utils");
44808 var Viewer_1 = require("../Viewer");
44809 var Container = /** @class */ (function () {
44810 function Container(id, stateService, options, dom) {
44812 this._dom = !!dom ? dom : new Utils_1.DOM();
44813 this._container = this._dom.document.getElementById(id);
44814 if (!this._container) {
44815 throw new Error("Container '" + id + "' not found.");
44817 this._container.classList.add("mapillary-js");
44818 this._canvasContainer = this._dom.createElement("div", "mapillary-js-interactive", this._container);
44819 this._domContainer = this._dom.createElement("div", "mapillary-js-dom", this._container);
44820 this.renderService = new Render_1.RenderService(this._container, stateService.currentState$, options.renderMode);
44821 this.glRenderer = new Render_1.GLRenderer(this._canvasContainer, this.renderService, this._dom);
44822 this.domRenderer = new Render_1.DOMRenderer(this._domContainer, this.renderService, stateService.currentState$);
44823 this.keyboardService = new Viewer_1.KeyboardService(this._canvasContainer);
44824 this.mouseService = new Viewer_1.MouseService(this._container, this._canvasContainer, this._domContainer, document);
44825 this.touchService = new Viewer_1.TouchService(this._canvasContainer, this._domContainer);
44826 this.spriteService = new Viewer_1.SpriteService(options.sprite);
44828 Object.defineProperty(Container.prototype, "element", {
44830 return this._container;
44835 Object.defineProperty(Container.prototype, "canvasContainer", {
44837 return this._canvasContainer;
44842 Object.defineProperty(Container.prototype, "domContainer", {
44844 return this._domContainer;
44851 exports.Container = Container;
44852 exports.default = Container;
44854 },{"../Render":280,"../Utils":284,"../Viewer":285}],434:[function(require,module,exports){
44856 Object.defineProperty(exports, "__esModule", { value: true });
44858 * Enumeration for image sizes
44861 * @description Image sizes in pixels for the long side of the image.
44864 (function (ImageSize) {
44866 * 320 pixels image size
44868 ImageSize[ImageSize["Size320"] = 320] = "Size320";
44870 * 640 pixels image size
44872 ImageSize[ImageSize["Size640"] = 640] = "Size640";
44874 * 1024 pixels image size
44876 ImageSize[ImageSize["Size1024"] = 1024] = "Size1024";
44878 * 2048 pixels image size
44880 ImageSize[ImageSize["Size2048"] = 2048] = "Size2048";
44881 })(ImageSize = exports.ImageSize || (exports.ImageSize = {}));
44883 },{}],435:[function(require,module,exports){
44885 Object.defineProperty(exports, "__esModule", { value: true });
44886 var rxjs_1 = require("rxjs");
44887 var KeyboardService = /** @class */ (function () {
44888 function KeyboardService(canvasContainer) {
44889 this._keyDown$ = rxjs_1.fromEvent(canvasContainer, "keydown");
44890 this._keyUp$ = rxjs_1.fromEvent(canvasContainer, "keyup");
44892 Object.defineProperty(KeyboardService.prototype, "keyDown$", {
44894 return this._keyDown$;
44899 Object.defineProperty(KeyboardService.prototype, "keyUp$", {
44901 return this._keyUp$;
44906 return KeyboardService;
44908 exports.KeyboardService = KeyboardService;
44909 exports.default = KeyboardService;
44911 },{"rxjs":26}],436:[function(require,module,exports){
44913 Object.defineProperty(exports, "__esModule", { value: true });
44914 var operators_1 = require("rxjs/operators");
44915 var rxjs_1 = require("rxjs");
44916 var LoadingService = /** @class */ (function () {
44917 function LoadingService() {
44918 this._loadersSubject$ = new rxjs_1.Subject();
44919 this._loaders$ = this._loadersSubject$.pipe(operators_1.scan(function (loaders, loader) {
44920 if (loader.task !== undefined) {
44921 loaders[loader.task] = loader.loading;
44924 }, {}), operators_1.startWith({}), operators_1.publishReplay(1), operators_1.refCount());
44926 Object.defineProperty(LoadingService.prototype, "loading$", {
44928 return this._loaders$.pipe(operators_1.map(function (loaders) {
44929 for (var key in loaders) {
44930 if (!loaders.hasOwnProperty(key)) {
44933 if (loaders[key]) {
44938 }), operators_1.debounceTime(100), operators_1.distinctUntilChanged());
44943 LoadingService.prototype.taskLoading$ = function (task) {
44944 return this._loaders$.pipe(operators_1.map(function (loaders) {
44945 return !!loaders[task];
44946 }), operators_1.debounceTime(100), operators_1.distinctUntilChanged());
44948 LoadingService.prototype.startLoading = function (task) {
44949 this._loadersSubject$.next({ loading: true, task: task });
44951 LoadingService.prototype.stopLoading = function (task) {
44952 this._loadersSubject$.next({ loading: false, task: task });
44954 return LoadingService;
44956 exports.LoadingService = LoadingService;
44957 exports.default = LoadingService;
44959 },{"rxjs":26,"rxjs/operators":224}],437:[function(require,module,exports){
44961 Object.defineProperty(exports, "__esModule", { value: true });
44962 var rxjs_1 = require("rxjs");
44963 var operators_1 = require("rxjs/operators");
44964 var Geo_1 = require("../Geo");
44965 var MouseService = /** @class */ (function () {
44966 function MouseService(container, canvasContainer, domContainer, doc, viewportCoords) {
44968 viewportCoords = viewportCoords != null ? viewportCoords : new Geo_1.ViewportCoords();
44969 this._activeSubject$ = new rxjs_1.BehaviorSubject(false);
44970 this._active$ = this._activeSubject$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
44971 this._claimMouse$ = new rxjs_1.Subject();
44972 this._claimWheel$ = new rxjs_1.Subject();
44973 this._deferPixelClaims$ = new rxjs_1.Subject();
44974 this._deferPixels$ = this._deferPixelClaims$.pipe(operators_1.scan(function (claims, claim) {
44975 if (claim.deferPixels == null) {
44976 delete claims[claim.name];
44979 claims[claim.name] = claim.deferPixels;
44982 }, {}), operators_1.map(function (claims) {
44983 var deferPixelMax = -1;
44984 for (var key in claims) {
44985 if (!claims.hasOwnProperty(key)) {
44988 var deferPixels = claims[key];
44989 if (deferPixels > deferPixelMax) {
44990 deferPixelMax = deferPixels;
44993 return deferPixelMax;
44994 }), operators_1.startWith(-1), operators_1.publishReplay(1), operators_1.refCount());
44995 this._deferPixels$.subscribe(function () { });
44996 this._documentMouseMove$ = rxjs_1.fromEvent(doc, "mousemove");
44997 this._documentMouseUp$ = rxjs_1.fromEvent(doc, "mouseup");
44998 this._mouseDown$ = rxjs_1.fromEvent(canvasContainer, "mousedown");
44999 this._mouseLeave$ = rxjs_1.fromEvent(canvasContainer, "mouseleave");
45000 this._mouseMove$ = rxjs_1.fromEvent(canvasContainer, "mousemove");
45001 this._mouseUp$ = rxjs_1.fromEvent(canvasContainer, "mouseup");
45002 this._mouseOut$ = rxjs_1.fromEvent(canvasContainer, "mouseout");
45003 this._mouseOver$ = rxjs_1.fromEvent(canvasContainer, "mouseover");
45004 this._domMouseDown$ = rxjs_1.fromEvent(domContainer, "mousedown");
45005 this._domMouseMove$ = rxjs_1.fromEvent(domContainer, "mousemove");
45006 this._click$ = rxjs_1.fromEvent(canvasContainer, "click");
45007 this._contextMenu$ = rxjs_1.fromEvent(canvasContainer, "contextmenu");
45008 this._dblClick$ = rxjs_1.merge(rxjs_1.fromEvent(container, "click"), rxjs_1.fromEvent(canvasContainer, "dblclick")).pipe(operators_1.bufferCount(3, 1), operators_1.filter(function (events) {
45009 var event1 = events[0];
45010 var event2 = events[1];
45011 var event3 = events[2];
45012 return event1.type === "click" &&
45013 event2.type === "click" &&
45014 event3.type === "dblclick" &&
45015 event1.target.parentNode === canvasContainer &&
45016 event2.target.parentNode === canvasContainer;
45017 }), operators_1.map(function (events) {
45019 }), operators_1.share());
45020 rxjs_1.merge(this._domMouseDown$, this._domMouseMove$, this._dblClick$, this._contextMenu$)
45021 .subscribe(function (event) {
45022 event.preventDefault();
45024 this._mouseWheel$ = rxjs_1.merge(rxjs_1.fromEvent(canvasContainer, "wheel"), rxjs_1.fromEvent(domContainer, "wheel")).pipe(operators_1.share());
45025 this._consistentContextMenu$ = rxjs_1.merge(this._mouseDown$, this._mouseMove$, this._mouseOut$, this._mouseUp$, this._contextMenu$).pipe(operators_1.bufferCount(3, 1), operators_1.filter(function (events) {
45026 // fire context menu on mouse up both on mac and windows
45027 return events[0].type === "mousedown" &&
45028 events[1].type === "contextmenu" &&
45029 events[2].type === "mouseup";
45030 }), operators_1.map(function (events) {
45032 }), operators_1.share());
45033 var dragStop$ = rxjs_1.merge(rxjs_1.fromEvent(window, "blur"), this._documentMouseUp$.pipe(operators_1.filter(function (e) {
45034 return e.button === 0;
45035 }))).pipe(operators_1.share());
45036 var mouseDragInitiate$ = this._createMouseDragInitiate$(this._mouseDown$, dragStop$, true).pipe(operators_1.share());
45037 this._mouseDragStart$ = this._createMouseDragStart$(mouseDragInitiate$).pipe(operators_1.share());
45038 this._mouseDrag$ = this._createMouseDrag$(mouseDragInitiate$, dragStop$).pipe(operators_1.share());
45039 this._mouseDragEnd$ = this._createMouseDragEnd$(this._mouseDragStart$, dragStop$).pipe(operators_1.share());
45040 var domMouseDragInitiate$ = this._createMouseDragInitiate$(this._domMouseDown$, dragStop$, false).pipe(operators_1.share());
45041 this._domMouseDragStart$ = this._createMouseDragStart$(domMouseDragInitiate$).pipe(operators_1.share());
45042 this._domMouseDrag$ = this._createMouseDrag$(domMouseDragInitiate$, dragStop$).pipe(operators_1.share());
45043 this._domMouseDragEnd$ = this._createMouseDragEnd$(this._domMouseDragStart$, dragStop$).pipe(operators_1.share());
45044 this._proximateClick$ = this._mouseDown$.pipe(operators_1.switchMap(function (mouseDown) {
45045 return _this._click$.pipe(operators_1.takeUntil(_this._createDeferredMouseMove$(mouseDown, _this._documentMouseMove$)), operators_1.take(1));
45046 }), operators_1.share());
45047 this._staticClick$ = this._mouseDown$.pipe(operators_1.switchMap(function (e) {
45048 return _this._click$.pipe(operators_1.takeUntil(_this._documentMouseMove$), operators_1.take(1));
45049 }), operators_1.share());
45050 this._mouseDragStart$.subscribe();
45051 this._mouseDrag$.subscribe();
45052 this._mouseDragEnd$.subscribe();
45053 this._domMouseDragStart$.subscribe();
45054 this._domMouseDrag$.subscribe();
45055 this._domMouseDragEnd$.subscribe();
45056 this._staticClick$.subscribe();
45057 this._mouseOwner$ = this._createOwner$(this._claimMouse$).pipe(operators_1.publishReplay(1), operators_1.refCount());
45058 this._wheelOwner$ = this._createOwner$(this._claimWheel$).pipe(operators_1.publishReplay(1), operators_1.refCount());
45059 this._mouseOwner$.subscribe(function () { });
45060 this._wheelOwner$.subscribe(function () { });
45062 Object.defineProperty(MouseService.prototype, "active$", {
45064 return this._active$;
45069 Object.defineProperty(MouseService.prototype, "activate$", {
45071 return this._activeSubject$;
45076 Object.defineProperty(MouseService.prototype, "documentMouseMove$", {
45078 return this._documentMouseMove$;
45083 Object.defineProperty(MouseService.prototype, "documentMouseUp$", {
45085 return this._documentMouseUp$;
45090 Object.defineProperty(MouseService.prototype, "domMouseDragStart$", {
45092 return this._domMouseDragStart$;
45097 Object.defineProperty(MouseService.prototype, "domMouseDrag$", {
45099 return this._domMouseDrag$;
45104 Object.defineProperty(MouseService.prototype, "domMouseDragEnd$", {
45106 return this._domMouseDragEnd$;
45111 Object.defineProperty(MouseService.prototype, "domMouseDown$", {
45113 return this._domMouseDown$;
45118 Object.defineProperty(MouseService.prototype, "domMouseMove$", {
45120 return this._domMouseMove$;
45125 Object.defineProperty(MouseService.prototype, "mouseOwner$", {
45127 return this._mouseOwner$;
45132 Object.defineProperty(MouseService.prototype, "mouseDown$", {
45134 return this._mouseDown$;
45139 Object.defineProperty(MouseService.prototype, "mouseMove$", {
45141 return this._mouseMove$;
45146 Object.defineProperty(MouseService.prototype, "mouseLeave$", {
45148 return this._mouseLeave$;
45153 Object.defineProperty(MouseService.prototype, "mouseOut$", {
45155 return this._mouseOut$;
45160 Object.defineProperty(MouseService.prototype, "mouseOver$", {
45162 return this._mouseOver$;
45167 Object.defineProperty(MouseService.prototype, "mouseUp$", {
45169 return this._mouseUp$;
45174 Object.defineProperty(MouseService.prototype, "click$", {
45176 return this._click$;
45181 Object.defineProperty(MouseService.prototype, "dblClick$", {
45183 return this._dblClick$;
45188 Object.defineProperty(MouseService.prototype, "contextMenu$", {
45190 return this._consistentContextMenu$;
45195 Object.defineProperty(MouseService.prototype, "mouseWheel$", {
45197 return this._mouseWheel$;
45202 Object.defineProperty(MouseService.prototype, "mouseDragStart$", {
45204 return this._mouseDragStart$;
45209 Object.defineProperty(MouseService.prototype, "mouseDrag$", {
45211 return this._mouseDrag$;
45216 Object.defineProperty(MouseService.prototype, "mouseDragEnd$", {
45218 return this._mouseDragEnd$;
45223 Object.defineProperty(MouseService.prototype, "proximateClick$", {
45225 return this._proximateClick$;
45230 Object.defineProperty(MouseService.prototype, "staticClick$", {
45232 return this._staticClick$;
45237 MouseService.prototype.claimMouse = function (name, zindex) {
45238 this._claimMouse$.next({ name: name, zindex: zindex });
45240 MouseService.prototype.unclaimMouse = function (name) {
45241 this._claimMouse$.next({ name: name, zindex: null });
45243 MouseService.prototype.deferPixels = function (name, deferPixels) {
45244 this._deferPixelClaims$.next({ name: name, deferPixels: deferPixels });
45246 MouseService.prototype.undeferPixels = function (name) {
45247 this._deferPixelClaims$.next({ name: name, deferPixels: null });
45249 MouseService.prototype.claimWheel = function (name, zindex) {
45250 this._claimWheel$.next({ name: name, zindex: zindex });
45252 MouseService.prototype.unclaimWheel = function (name) {
45253 this._claimWheel$.next({ name: name, zindex: null });
45255 MouseService.prototype.filtered$ = function (name, observable$) {
45256 return this._filtered(name, observable$, this._mouseOwner$);
45258 MouseService.prototype.filteredWheel$ = function (name, observable$) {
45259 return this._filtered(name, observable$, this._wheelOwner$);
45261 MouseService.prototype._createDeferredMouseMove$ = function (origin, mouseMove$) {
45262 return mouseMove$.pipe(operators_1.map(function (mouseMove) {
45263 var deltaX = mouseMove.clientX - origin.clientX;
45264 var deltaY = mouseMove.clientY - origin.clientY;
45265 return [mouseMove, Math.sqrt(deltaX * deltaX + deltaY * deltaY)];
45266 }), operators_1.withLatestFrom(this._deferPixels$), operators_1.filter(function (_a) {
45267 var _b = _a[0], mouseMove = _b[0], delta = _b[1], deferPixels = _a[1];
45268 return delta > deferPixels;
45269 }), operators_1.map(function (_a) {
45270 var _b = _a[0], mouseMove = _b[0], delta = _b[1], deferPixels = _a[1];
45274 MouseService.prototype._createMouseDrag$ = function (mouseDragStartInitiate$, stop$) {
45276 return mouseDragStartInitiate$.pipe(operators_1.map(function (_a) {
45277 var mouseDown = _a[0], mouseMove = _a[1];
45279 }), operators_1.switchMap(function (mouseMove) {
45280 return rxjs_1.concat(rxjs_1.of(mouseMove), _this._documentMouseMove$).pipe(operators_1.takeUntil(stop$));
45283 MouseService.prototype._createMouseDragEnd$ = function (mouseDragStart$, stop$) {
45284 return mouseDragStart$.pipe(operators_1.switchMap(function (event) {
45285 return stop$.pipe(operators_1.first());
45288 MouseService.prototype._createMouseDragStart$ = function (mouseDragStartInitiate$) {
45289 return mouseDragStartInitiate$.pipe(operators_1.map(function (_a) {
45290 var mouseDown = _a[0], mouseMove = _a[1];
45294 MouseService.prototype._createMouseDragInitiate$ = function (mouseDown$, stop$, defer) {
45296 return mouseDown$.pipe(operators_1.filter(function (mouseDown) {
45297 return mouseDown.button === 0;
45298 }), operators_1.switchMap(function (mouseDown) {
45299 return rxjs_1.combineLatest(rxjs_1.of(mouseDown), defer ?
45300 _this._createDeferredMouseMove$(mouseDown, _this._documentMouseMove$) :
45301 _this._documentMouseMove$).pipe(operators_1.takeUntil(stop$), operators_1.take(1));
45304 MouseService.prototype._createOwner$ = function (claim$) {
45305 return claim$.pipe(operators_1.scan(function (claims, claim) {
45306 if (claim.zindex == null) {
45307 delete claims[claim.name];
45310 claims[claim.name] = claim.zindex;
45313 }, {}), operators_1.map(function (claims) {
45315 var zIndexMax = -1;
45316 for (var name_1 in claims) {
45317 if (!claims.hasOwnProperty(name_1)) {
45320 if (claims[name_1] > zIndexMax) {
45321 zIndexMax = claims[name_1];
45326 }), operators_1.startWith(null));
45328 MouseService.prototype._filtered = function (name, observable$, owner$) {
45329 return observable$.pipe(operators_1.withLatestFrom(owner$), operators_1.filter(function (_a) {
45330 var item = _a[0], owner = _a[1];
45331 return owner === name;
45332 }), operators_1.map(function (_a) {
45333 var item = _a[0], owner = _a[1];
45337 return MouseService;
45339 exports.MouseService = MouseService;
45340 exports.default = MouseService;
45342 },{"../Geo":277,"rxjs":26,"rxjs/operators":224}],438:[function(require,module,exports){
45344 Object.defineProperty(exports, "__esModule", { value: true });
45345 var rxjs_1 = require("rxjs");
45346 var operators_1 = require("rxjs/operators");
45347 var API_1 = require("../API");
45348 var Graph_1 = require("../Graph");
45349 var Edge_1 = require("../Edge");
45350 var Error_1 = require("../Error");
45351 var State_1 = require("../State");
45352 var Viewer_1 = require("../Viewer");
45353 var Navigator = /** @class */ (function () {
45354 function Navigator(clientId, options, token, apiV3, graphService, imageLoadingService, loadingService, stateService, cacheService, playService) {
45355 this._apiV3 = apiV3 != null ? apiV3 : new API_1.APIv3(clientId, token);
45356 this._imageLoadingService = imageLoadingService != null ? imageLoadingService : new Graph_1.ImageLoadingService();
45357 this._graphService = graphService != null ?
45359 new Graph_1.GraphService(new Graph_1.Graph(this.apiV3), this._imageLoadingService);
45360 this._loadingService = loadingService != null ? loadingService : new Viewer_1.LoadingService();
45361 this._loadingName = "navigator";
45362 this._stateService = stateService != null ? stateService : new State_1.StateService(options.transitionMode);
45363 this._cacheService = cacheService != null ?
45365 new Viewer_1.CacheService(this._graphService, this._stateService);
45366 this._playService = playService != null ?
45368 new Viewer_1.PlayService(this._graphService, this._stateService);
45369 this._keyRequested$ = new rxjs_1.BehaviorSubject(null);
45370 this._movedToKey$ = new rxjs_1.BehaviorSubject(null);
45371 this._request$ = null;
45372 this._requestSubscription = null;
45373 this._nodeRequestSubscription = null;
45375 Object.defineProperty(Navigator.prototype, "apiV3", {
45377 return this._apiV3;
45382 Object.defineProperty(Navigator.prototype, "cacheService", {
45384 return this._cacheService;
45389 Object.defineProperty(Navigator.prototype, "graphService", {
45391 return this._graphService;
45396 Object.defineProperty(Navigator.prototype, "imageLoadingService", {
45398 return this._imageLoadingService;
45403 Object.defineProperty(Navigator.prototype, "loadingService", {
45405 return this._loadingService;
45410 Object.defineProperty(Navigator.prototype, "movedToKey$", {
45412 return this._movedToKey$;
45417 Object.defineProperty(Navigator.prototype, "playService", {
45419 return this._playService;
45424 Object.defineProperty(Navigator.prototype, "stateService", {
45426 return this._stateService;
45431 Navigator.prototype.moveToKey$ = function (key) {
45432 this._abortRequest("to key " + key);
45433 this._loadingService.startLoading(this._loadingName);
45434 var node$ = this._moveToKey$(key);
45435 return this._makeRequest$(node$);
45437 Navigator.prototype.moveDir$ = function (direction) {
45439 this._abortRequest("in dir " + Edge_1.EdgeDirection[direction]);
45440 this._loadingService.startLoading(this._loadingName);
45441 var node$ = this.stateService.currentNode$.pipe(operators_1.first(), operators_1.mergeMap(function (node) {
45442 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
45443 node.sequenceEdges$ :
45444 node.spatialEdges$).pipe(operators_1.first(), operators_1.map(function (status) {
45445 for (var _i = 0, _a = status.edges; _i < _a.length; _i++) {
45447 if (edge.data.direction === direction) {
45453 }), operators_1.mergeMap(function (directionKey) {
45454 if (directionKey == null) {
45455 _this._loadingService.stopLoading(_this._loadingName);
45456 return rxjs_1.throwError(new Error("Direction (" + direction + ") does not exist for current node."));
45458 return _this._moveToKey$(directionKey);
45460 return this._makeRequest$(node$);
45462 Navigator.prototype.moveCloseTo$ = function (lat, lon) {
45464 this._abortRequest("to lat " + lat + ", lon " + lon);
45465 this._loadingService.startLoading(this._loadingName);
45466 var node$ = this.apiV3.imageCloseTo$(lat, lon).pipe(operators_1.mergeMap(function (fullNode) {
45467 if (fullNode == null) {
45468 _this._loadingService.stopLoading(_this._loadingName);
45469 return rxjs_1.throwError(new Error("No image found close to lat " + lat + ", lon " + lon + "."));
45471 return _this._moveToKey$(fullNode.key);
45473 return this._makeRequest$(node$);
45475 Navigator.prototype.setFilter$ = function (filter) {
45477 this._stateService.clearNodes();
45478 return this._movedToKey$.pipe(operators_1.first(), operators_1.mergeMap(function (key) {
45480 return _this._trajectoryKeys$().pipe(operators_1.mergeMap(function (keys) {
45481 return _this._graphService.setFilter$(filter).pipe(operators_1.mergeMap(function () {
45482 return _this._cacheKeys$(keys);
45484 }), operators_1.last());
45486 return _this._keyRequested$.pipe(operators_1.first(), operators_1.mergeMap(function (requestedKey) {
45487 if (requestedKey != null) {
45488 return _this._graphService.setFilter$(filter).pipe(operators_1.mergeMap(function () {
45489 return _this._graphService.cacheNode$(requestedKey);
45492 return _this._graphService.setFilter$(filter).pipe(operators_1.map(function () {
45496 }), operators_1.map(function (node) {
45500 Navigator.prototype.setToken$ = function (token) {
45502 this._abortRequest("to set token");
45503 this._stateService.clearNodes();
45504 return this._movedToKey$.pipe(operators_1.first(), operators_1.tap(function (key) {
45505 _this._apiV3.setToken(token);
45506 }), operators_1.mergeMap(function (key) {
45507 return key == null ?
45508 _this._graphService.reset$([]) :
45509 _this._trajectoryKeys$().pipe(operators_1.mergeMap(function (keys) {
45510 return _this._graphService.reset$(keys).pipe(operators_1.mergeMap(function () {
45511 return _this._cacheKeys$(keys);
45513 }), operators_1.last(), operators_1.map(function (node) {
45518 Navigator.prototype._cacheKeys$ = function (keys) {
45520 var cacheNodes$ = keys
45521 .map(function (key) {
45522 return _this._graphService.cacheNode$(key);
45524 return rxjs_1.from(cacheNodes$).pipe(operators_1.mergeAll());
45526 Navigator.prototype._abortRequest = function (reason) {
45527 if (this._requestSubscription != null) {
45528 this._requestSubscription.unsubscribe();
45529 this._requestSubscription = null;
45531 if (this._nodeRequestSubscription != null) {
45532 this._nodeRequestSubscription.unsubscribe();
45533 this._nodeRequestSubscription = null;
45535 if (this._request$ != null) {
45536 if (!(this._request$.isStopped || this._request$.hasError)) {
45537 this._request$.error(new Error_1.AbortMapillaryError("Request aborted by a subsequent request " + reason + "."));
45539 this._request$ = null;
45542 Navigator.prototype._makeRequest$ = function (node$) {
45544 var request$ = new rxjs_1.ReplaySubject(1);
45545 this._requestSubscription = request$
45546 .subscribe(undefined, function () { });
45547 this._request$ = request$;
45548 this._nodeRequestSubscription = node$
45549 .subscribe(function (node) {
45550 _this._request$ = null;
45551 request$.next(node);
45552 request$.complete();
45553 }, function (error) {
45554 _this._request$ = null;
45555 request$.error(error);
45559 Navigator.prototype._moveToKey$ = function (key) {
45561 this._keyRequested$.next(key);
45562 return this._graphService.cacheNode$(key).pipe(operators_1.tap(function (node) {
45563 _this._stateService.setNodes([node]);
45564 _this._movedToKey$.next(node.key);
45565 }), operators_1.finalize(function () {
45566 _this._loadingService.stopLoading(_this._loadingName);
45569 Navigator.prototype._trajectoryKeys$ = function () {
45570 return this._stateService.currentState$.pipe(operators_1.first(), operators_1.map(function (frame) {
45571 return frame.state.trajectory
45572 .map(function (node) {
45579 exports.Navigator = Navigator;
45580 exports.default = Navigator;
45582 },{"../API":273,"../Edge":275,"../Error":276,"../Graph":278,"../State":281,"../Viewer":285,"rxjs":26,"rxjs/operators":224}],439:[function(require,module,exports){
45584 Object.defineProperty(exports, "__esModule", { value: true });
45585 var rxjs_1 = require("rxjs");
45586 var operators_1 = require("rxjs/operators");
45587 var Viewer_1 = require("../Viewer");
45588 var Observer = /** @class */ (function () {
45589 function Observer(eventEmitter, navigator, container) {
45591 this._container = container;
45592 this._eventEmitter = eventEmitter;
45593 this._navigator = navigator;
45594 this._projection = new Viewer_1.Projection();
45595 this._started = false;
45596 this._navigable$ = new rxjs_1.Subject();
45597 // navigable and loading should always emit, also when cover is activated.
45599 .subscribe(function (navigable) {
45600 _this._eventEmitter.fire(Viewer_1.Viewer.navigablechanged, navigable);
45602 this._navigator.loadingService.loading$
45603 .subscribe(function (loading) {
45604 _this._eventEmitter.fire(Viewer_1.Viewer.loadingchanged, loading);
45607 Object.defineProperty(Observer.prototype, "started", {
45609 return this._started;
45614 Object.defineProperty(Observer.prototype, "navigable$", {
45616 return this._navigable$;
45621 Observer.prototype.projectBasic$ = function (basicPoint) {
45623 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) {
45624 var render = _a[0], transform = _a[1];
45625 var canvasPoint = _this._projection.basicToCanvas(basicPoint, _this._container.element, render, transform);
45626 return [Math.round(canvasPoint[0]), Math.round(canvasPoint[1])];
45629 Observer.prototype.startEmit = function () {
45631 if (this._started) {
45634 this._started = true;
45635 this._currentNodeSubscription = this._navigator.stateService.currentNodeExternal$
45636 .subscribe(function (node) {
45637 _this._eventEmitter.fire(Viewer_1.Viewer.nodechanged, node);
45639 this._sequenceEdgesSubscription = this._navigator.stateService.currentNodeExternal$.pipe(operators_1.switchMap(function (node) {
45640 return node.sequenceEdges$;
45642 .subscribe(function (status) {
45643 _this._eventEmitter.fire(Viewer_1.Viewer.sequenceedgeschanged, status);
45645 this._spatialEdgesSubscription = this._navigator.stateService.currentNodeExternal$.pipe(operators_1.switchMap(function (node) {
45646 return node.spatialEdges$;
45648 .subscribe(function (status) {
45649 _this._eventEmitter.fire(Viewer_1.Viewer.spatialedgeschanged, status);
45651 this._moveSubscription = rxjs_1.combineLatest(this._navigator.stateService.inMotion$, this._container.mouseService.active$, this._container.touchService.active$).pipe(operators_1.map(function (values) {
45652 return values[0] || values[1] || values[2];
45653 }), operators_1.distinctUntilChanged())
45654 .subscribe(function (started) {
45656 _this._eventEmitter.fire(Viewer_1.Viewer.movestart, null);
45659 _this._eventEmitter.fire(Viewer_1.Viewer.moveend, null);
45662 this._bearingSubscription = this._container.renderService.bearing$.pipe(operators_1.auditTime(100), operators_1.distinctUntilChanged(function (b1, b2) {
45663 return Math.abs(b2 - b1) < 1;
45665 .subscribe(function (bearing) {
45666 _this._eventEmitter.fire(Viewer_1.Viewer.bearingchanged, bearing);
45668 var mouseMove$ = this._container.mouseService.active$.pipe(operators_1.switchMap(function (active) {
45671 _this._container.mouseService.mouseMove$;
45673 this._viewerMouseEventSubscription = rxjs_1.merge(this._mapMouseEvent$(Viewer_1.Viewer.click, this._container.mouseService.staticClick$), this._mapMouseEvent$(Viewer_1.Viewer.contextmenu, this._container.mouseService.contextMenu$), this._mapMouseEvent$(Viewer_1.Viewer.dblclick, this._container.mouseService.dblClick$), this._mapMouseEvent$(Viewer_1.Viewer.mousedown, this._container.mouseService.mouseDown$), this._mapMouseEvent$(Viewer_1.Viewer.mousemove, mouseMove$), this._mapMouseEvent$(Viewer_1.Viewer.mouseout, this._container.mouseService.mouseOut$), this._mapMouseEvent$(Viewer_1.Viewer.mouseover, this._container.mouseService.mouseOver$), this._mapMouseEvent$(Viewer_1.Viewer.mouseup, this._container.mouseService.mouseUp$)).pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.reference$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
45674 var _b = _a[0], type = _b[0], event = _b[1], render = _a[1], reference = _a[2], transform = _a[3];
45675 var unprojection = _this._projection.eventToUnprojection(event, _this._container.element, render, reference, transform);
45677 basicPoint: unprojection.basicPoint,
45678 latLon: unprojection.latLon,
45679 originalEvent: event,
45680 pixelPoint: unprojection.pixelPoint,
45681 target: _this._eventEmitter,
45685 .subscribe(function (event) {
45686 _this._eventEmitter.fire(event.type, event);
45689 Observer.prototype.stopEmit = function () {
45690 if (!this.started) {
45693 this._started = false;
45694 this._bearingSubscription.unsubscribe();
45695 this._currentNodeSubscription.unsubscribe();
45696 this._moveSubscription.unsubscribe();
45697 this._sequenceEdgesSubscription.unsubscribe();
45698 this._spatialEdgesSubscription.unsubscribe();
45699 this._viewerMouseEventSubscription.unsubscribe();
45700 this._bearingSubscription = null;
45701 this._currentNodeSubscription = null;
45702 this._moveSubscription = null;
45703 this._sequenceEdgesSubscription = null;
45704 this._spatialEdgesSubscription = null;
45705 this._viewerMouseEventSubscription = null;
45707 Observer.prototype.unproject$ = function (canvasPoint) {
45709 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.reference$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) {
45710 var render = _a[0], reference = _a[1], transform = _a[2];
45711 var unprojection = _this._projection.canvasToUnprojection(canvasPoint, _this._container.element, render, reference, transform);
45712 return unprojection.latLon;
45715 Observer.prototype.unprojectBasic$ = function (canvasPoint) {
45717 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) {
45718 var render = _a[0], transform = _a[1];
45719 return _this._projection.canvasToBasic(canvasPoint, _this._container.element, render, transform);
45722 Observer.prototype._mapMouseEvent$ = function (type, mouseEvent$) {
45723 return mouseEvent$.pipe(operators_1.map(function (event) {
45724 return [type, event];
45729 exports.Observer = Observer;
45730 exports.default = Observer;
45732 },{"../Viewer":285,"rxjs":26,"rxjs/operators":224}],440:[function(require,module,exports){
45734 Object.defineProperty(exports, "__esModule", { value: true });
45735 var rxjs_1 = require("rxjs");
45736 var operators_1 = require("rxjs/operators");
45737 var Edge_1 = require("../Edge");
45738 var Graph_1 = require("../Graph");
45739 var PlayService = /** @class */ (function () {
45740 function PlayService(graphService, stateService, graphCalculator) {
45741 this._graphService = graphService;
45742 this._stateService = stateService;
45743 this._graphCalculator = !!graphCalculator ? graphCalculator : new Graph_1.GraphCalculator();
45744 this._directionSubject$ = new rxjs_1.Subject();
45745 this._direction$ = this._directionSubject$.pipe(operators_1.startWith(Edge_1.EdgeDirection.Next), operators_1.publishReplay(1), operators_1.refCount());
45746 this._direction$.subscribe();
45747 this._playing = false;
45748 this._playingSubject$ = new rxjs_1.Subject();
45749 this._playing$ = this._playingSubject$.pipe(operators_1.startWith(this._playing), operators_1.publishReplay(1), operators_1.refCount());
45750 this._playing$.subscribe();
45752 this._speedSubject$ = new rxjs_1.Subject();
45753 this._speed$ = this._speedSubject$.pipe(operators_1.startWith(this._speed), operators_1.publishReplay(1), operators_1.refCount());
45754 this._speed$.subscribe();
45755 this._nodesAhead = this._mapNodesAhead(this._mapSpeed(this._speed));
45756 this._bridging$ = null;
45758 Object.defineProperty(PlayService.prototype, "playing", {
45760 return this._playing;
45765 Object.defineProperty(PlayService.prototype, "direction$", {
45767 return this._direction$;
45772 Object.defineProperty(PlayService.prototype, "playing$", {
45774 return this._playing$;
45779 Object.defineProperty(PlayService.prototype, "speed$", {
45781 return this._speed$;
45786 PlayService.prototype.play = function () {
45788 if (this._playing) {
45791 this._stateService.cutNodes();
45792 var stateSpeed = this._setSpeed(this._speed);
45793 this._stateService.setSpeed(stateSpeed);
45794 this._graphModeSubscription = this._speed$.pipe(operators_1.map(function (speed) {
45795 return speed > PlayService.sequenceSpeed ? Graph_1.GraphMode.Sequence : Graph_1.GraphMode.Spatial;
45796 }), operators_1.distinctUntilChanged())
45797 .subscribe(function (mode) {
45798 _this._graphService.setGraphMode(mode);
45800 this._cacheSubscription = rxjs_1.combineLatest(this._stateService.currentNode$.pipe(operators_1.map(function (node) {
45801 return [node.sequenceKey, node.key];
45802 }), operators_1.distinctUntilChanged(undefined, function (_a) {
45803 var sequenceKey = _a[0], nodeKey = _a[1];
45804 return sequenceKey;
45805 })), this._graphService.graphMode$, this._direction$).pipe(operators_1.switchMap(function (_a) {
45806 var _b = _a[0], sequenceKey = _b[0], nodeKey = _b[1], mode = _a[1], direction = _a[2];
45807 if (direction !== Edge_1.EdgeDirection.Next && direction !== Edge_1.EdgeDirection.Prev) {
45808 return rxjs_1.of([undefined, direction]);
45810 var sequence$ = (mode === Graph_1.GraphMode.Sequence ?
45811 _this._graphService.cacheSequenceNodes$(sequenceKey, nodeKey) :
45812 _this._graphService.cacheSequence$(sequenceKey)).pipe(operators_1.retry(3), operators_1.catchError(function (error) {
45813 console.error(error);
45814 return rxjs_1.of(undefined);
45816 return rxjs_1.combineLatest(sequence$, rxjs_1.of(direction));
45817 }), operators_1.switchMap(function (_a) {
45818 var sequence = _a[0], direction = _a[1];
45819 if (sequence === undefined) {
45820 return rxjs_1.empty();
45822 var sequenceKeys = sequence.keys.slice();
45823 if (direction === Edge_1.EdgeDirection.Prev) {
45824 sequenceKeys.reverse();
45826 return _this._stateService.currentState$.pipe(operators_1.map(function (frame) {
45827 return [frame.state.trajectory[frame.state.trajectory.length - 1].key, frame.state.nodesAhead];
45828 }), operators_1.scan(function (_a, _b) {
45829 var lastRequestKey = _a[0], previousRequestKeys = _a[1];
45830 var lastTrajectoryKey = _b[0], nodesAhead = _b[1];
45831 if (lastRequestKey === undefined) {
45832 lastRequestKey = lastTrajectoryKey;
45834 var lastIndex = sequenceKeys.length - 1;
45835 if (nodesAhead >= _this._nodesAhead || sequenceKeys[lastIndex] === lastRequestKey) {
45836 return [lastRequestKey, []];
45838 var current = sequenceKeys.indexOf(lastTrajectoryKey);
45839 var start = sequenceKeys.indexOf(lastRequestKey) + 1;
45840 var end = Math.min(lastIndex, current + _this._nodesAhead - nodesAhead) + 1;
45841 if (end <= start) {
45842 return [lastRequestKey, []];
45844 return [sequenceKeys[end - 1], sequenceKeys.slice(start, end)];
45845 }, [undefined, []]), operators_1.mergeMap(function (_a) {
45846 var lastRequestKey = _a[0], newRequestKeys = _a[1];
45847 return rxjs_1.from(newRequestKeys);
45849 }), operators_1.mergeMap(function (key) {
45850 return _this._graphService.cacheNode$(key).pipe(operators_1.catchError(function () {
45851 return rxjs_1.empty();
45855 this._playingSubscription = this._stateService.currentState$.pipe(operators_1.filter(function (frame) {
45856 return frame.state.nodesAhead < _this._nodesAhead;
45857 }), operators_1.distinctUntilChanged(undefined, function (frame) {
45858 return frame.state.lastNode.key;
45859 }), operators_1.map(function (frame) {
45860 var lastNode = frame.state.lastNode;
45861 var trajectory = frame.state.trajectory;
45862 var increasingTime = undefined;
45863 for (var i = trajectory.length - 2; i >= 0; i--) {
45864 var node = trajectory[i];
45865 if (node.sequenceKey !== lastNode.sequenceKey) {
45868 if (node.capturedAt !== lastNode.capturedAt) {
45869 increasingTime = node.capturedAt < lastNode.capturedAt;
45873 return [frame.state.lastNode, increasingTime];
45874 }), operators_1.withLatestFrom(this._direction$), operators_1.switchMap(function (_a) {
45875 var _b = _a[0], node = _b[0], increasingTime = _b[1], direction = _a[1];
45876 return rxjs_1.zip(([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
45877 node.sequenceEdges$ :
45878 node.spatialEdges$).pipe(operators_1.first(function (status) {
45879 return status.cached;
45880 }), operators_1.timeout(15000)), rxjs_1.of(direction)).pipe(operators_1.map(function (_a) {
45881 var s = _a[0], d = _a[1];
45882 for (var _i = 0, _b = s.edges; _i < _b.length; _i++) {
45884 if (edge.data.direction === d) {
45889 }), operators_1.switchMap(function (key) {
45890 return key != null ?
45891 _this._graphService.cacheNode$(key) :
45892 _this._bridge$(node, increasingTime).pipe(operators_1.filter(function (n) {
45897 .subscribe(function (node) {
45898 _this._stateService.appendNodes([node]);
45899 }, function (error) {
45900 console.error(error);
45903 this._clearSubscription = this._stateService.currentNode$.pipe(operators_1.bufferCount(1, 10))
45904 .subscribe(function (nodes) {
45905 _this._stateService.clearPriorNodes();
45907 this._setPlaying(true);
45908 var currentLastNodes$ = this._stateService.currentState$.pipe(operators_1.map(function (frame) {
45909 return frame.state;
45910 }), operators_1.distinctUntilChanged(function (_a, _b) {
45911 var kc1 = _a[0], kl1 = _a[1];
45912 var kc2 = _b[0], kl2 = _b[1];
45913 return kc1 === kc2 && kl1 === kl2;
45914 }, function (state) {
45915 return [state.currentNode.key, state.lastNode.key];
45916 }), operators_1.filter(function (state) {
45917 return state.currentNode.key === state.lastNode.key &&
45918 state.currentIndex === state.trajectory.length - 1;
45919 }), operators_1.map(function (state) {
45920 return state.currentNode;
45922 this._stopSubscription = rxjs_1.combineLatest(currentLastNodes$, this._direction$).pipe(operators_1.switchMap(function (_a) {
45923 var node = _a[0], direction = _a[1];
45924 var edgeStatus$ = ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
45925 node.sequenceEdges$ :
45926 node.spatialEdges$).pipe(operators_1.first(function (status) {
45927 return status.cached;
45928 }), operators_1.timeout(15000), operators_1.catchError(function (error) {
45929 console.error(error);
45930 return rxjs_1.of({ cached: false, edges: [] });
45932 return rxjs_1.combineLatest(rxjs_1.of(direction), edgeStatus$).pipe(operators_1.map(function (_a) {
45933 var d = _a[0], es = _a[1];
45934 for (var _i = 0, _b = es.edges; _i < _b.length; _i++) {
45936 if (edge.data.direction === d) {
45942 }), operators_1.mergeMap(function (hasEdge) {
45943 if (hasEdge || !_this._bridging$) {
45944 return rxjs_1.of(hasEdge);
45946 return _this._bridging$.pipe(operators_1.map(function (node) {
45947 return node != null;
45948 }), operators_1.catchError(function (error) {
45949 console.error(error);
45950 return rxjs_1.of(false);
45952 }), operators_1.first(function (hasEdge) {
45955 .subscribe(undefined, undefined, function () { _this.stop(); });
45956 if (this._stopSubscription.closed) {
45957 this._stopSubscription = null;
45960 PlayService.prototype.setDirection = function (direction) {
45961 this._directionSubject$.next(direction);
45963 PlayService.prototype.setSpeed = function (speed) {
45964 speed = Math.max(0, Math.min(1, speed));
45965 if (speed === this._speed) {
45968 var stateSpeed = this._setSpeed(speed);
45969 if (this._playing) {
45970 this._stateService.setSpeed(stateSpeed);
45972 this._speedSubject$.next(this._speed);
45974 PlayService.prototype.stop = function () {
45975 if (!this._playing) {
45978 if (!!this._stopSubscription) {
45979 if (!this._stopSubscription.closed) {
45980 this._stopSubscription.unsubscribe();
45982 this._stopSubscription = null;
45984 this._graphModeSubscription.unsubscribe();
45985 this._graphModeSubscription = null;
45986 this._cacheSubscription.unsubscribe();
45987 this._cacheSubscription = null;
45988 this._playingSubscription.unsubscribe();
45989 this._playingSubscription = null;
45990 this._clearSubscription.unsubscribe();
45991 this._clearSubscription = null;
45992 this._stateService.setSpeed(1);
45993 this._stateService.cutNodes();
45994 this._graphService.setGraphMode(Graph_1.GraphMode.Spatial);
45995 this._setPlaying(false);
45997 PlayService.prototype._bridge$ = function (node, increasingTime) {
45999 if (increasingTime === undefined) {
46000 return rxjs_1.of(null);
46002 var boundingBox = this._graphCalculator.boundingBoxCorners(node.latLon, 25);
46003 this._bridging$ = this._graphService.cacheBoundingBox$(boundingBox[0], boundingBox[1]).pipe(operators_1.mergeMap(function (nodes) {
46004 var nextNode = null;
46005 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
46006 var n = nodes_1[_i];
46007 if (n.sequenceKey === node.sequenceKey ||
46009 n.cameraUuid !== node.cameraUuid ||
46010 n.capturedAt === node.capturedAt ||
46011 n.capturedAt > node.capturedAt !== increasingTime) {
46014 var delta = Math.abs(n.capturedAt - node.capturedAt);
46015 if (delta > 15000) {
46018 if (!nextNode || delta < Math.abs(nextNode.capturedAt - node.capturedAt)) {
46022 return !!nextNode ?
46023 _this._graphService.cacheNode$(nextNode.key) :
46025 }), operators_1.finalize(function () {
46026 _this._bridging$ = null;
46027 }), operators_1.publish(), operators_1.refCount());
46028 return this._bridging$;
46030 PlayService.prototype._mapSpeed = function (speed) {
46031 var x = 2 * speed - 1;
46032 return Math.pow(10, x) - 0.2 * x;
46034 PlayService.prototype._mapNodesAhead = function (stateSpeed) {
46035 return Math.round(Math.max(10, Math.min(50, 8 + 6 * stateSpeed)));
46037 PlayService.prototype._setPlaying = function (playing) {
46038 this._playing = playing;
46039 this._playingSubject$.next(playing);
46041 PlayService.prototype._setSpeed = function (speed) {
46042 this._speed = speed;
46043 var stateSpeed = this._mapSpeed(this._speed);
46044 this._nodesAhead = this._mapNodesAhead(stateSpeed);
46047 PlayService.sequenceSpeed = 0.54;
46048 return PlayService;
46050 exports.PlayService = PlayService;
46051 exports.default = PlayService;
46053 },{"../Edge":275,"../Graph":278,"rxjs":26,"rxjs/operators":224}],441:[function(require,module,exports){
46055 Object.defineProperty(exports, "__esModule", { value: true });
46056 var THREE = require("three");
46057 var Geo_1 = require("../Geo");
46058 var Projection = /** @class */ (function () {
46059 function Projection(geoCoords, viewportCoords) {
46060 this._geoCoords = !!geoCoords ? geoCoords : new Geo_1.GeoCoords();
46061 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
46063 Projection.prototype.basicToCanvas = function (basicPoint, container, render, transform) {
46064 return this._viewportCoords
46065 .basicToCanvas(basicPoint[0], basicPoint[1], container, transform, render.perspective);
46067 Projection.prototype.canvasToBasic = function (canvasPoint, container, render, transform) {
46068 var basicPoint = this._viewportCoords
46069 .canvasToBasic(canvasPoint[0], canvasPoint[1], container, transform, render.perspective);
46070 if (basicPoint[0] < 0 || basicPoint[0] > 1 || basicPoint[1] < 0 || basicPoint[1] > 1) {
46075 Projection.prototype.eventToUnprojection = function (event, container, render, reference, transform) {
46076 var pixelPoint = this._viewportCoords.canvasPosition(event, container);
46077 return this.canvasToUnprojection(pixelPoint, container, render, reference, transform);
46079 Projection.prototype.canvasToUnprojection = function (canvasPoint, container, render, reference, transform) {
46080 var canvasX = canvasPoint[0];
46081 var canvasY = canvasPoint[1];
46082 var _a = this._viewportCoords.canvasToViewport(canvasX, canvasY, container), viewportX = _a[0], viewportY = _a[1];
46083 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
46084 .unproject(render.perspective);
46085 var basicPoint = transform.projectBasic(point3d.toArray());
46086 if (basicPoint[0] < 0 || basicPoint[0] > 1 || basicPoint[1] < 0 || basicPoint[1] > 1) {
46089 var direction3d = point3d.clone().sub(render.camera.position).normalize();
46090 var dist = -2 / direction3d.z;
46092 if (dist > 0 && dist < 100 && !!basicPoint) {
46093 var point = direction3d.clone().multiplyScalar(dist).add(render.camera.position);
46094 var latLonArray = this._geoCoords
46095 .enuToGeodetic(point.x, point.y, point.z, reference.lat, reference.lon, reference.alt)
46097 latLon = { lat: latLonArray[0], lon: latLonArray[1] };
46099 var unprojection = {
46100 basicPoint: basicPoint,
46102 pixelPoint: [canvasX, canvasY],
46104 return unprojection;
46108 exports.Projection = Projection;
46109 exports.default = Projection;
46111 },{"../Geo":277,"three":225}],442:[function(require,module,exports){
46113 Object.defineProperty(exports, "__esModule", { value: true });
46114 var operators_1 = require("rxjs/operators");
46115 var THREE = require("three");
46116 var vd = require("virtual-dom");
46117 var rxjs_1 = require("rxjs");
46118 var Viewer_1 = require("../Viewer");
46119 var SpriteAtlas = /** @class */ (function () {
46120 function SpriteAtlas() {
46122 Object.defineProperty(SpriteAtlas.prototype, "json", {
46123 set: function (value) {
46124 this._json = value;
46129 Object.defineProperty(SpriteAtlas.prototype, "image", {
46130 set: function (value) {
46131 this._image = value;
46132 this._texture = new THREE.Texture(this._image);
46133 this._texture.minFilter = THREE.NearestFilter;
46138 Object.defineProperty(SpriteAtlas.prototype, "loaded", {
46140 return !!(this._image && this._json);
46145 SpriteAtlas.prototype.getGLSprite = function (name) {
46146 if (!this.loaded) {
46147 throw new Error("Sprites cannot be retrieved before the atlas is loaded.");
46149 var definition = this._json[name];
46151 console.warn("Sprite with key" + name + "does not exist in sprite definition.");
46152 return new THREE.Object3D();
46154 var texture = this._texture.clone();
46155 texture.needsUpdate = true;
46156 var width = this._image.width;
46157 var height = this._image.height;
46158 texture.offset.x = definition.x / width;
46159 texture.offset.y = (height - definition.y - definition.height) / height;
46160 texture.repeat.x = definition.width / width;
46161 texture.repeat.y = definition.height / height;
46162 var material = new THREE.SpriteMaterial({ map: texture });
46163 return new THREE.Sprite(material);
46165 SpriteAtlas.prototype.getDOMSprite = function (name, float) {
46166 if (!this.loaded) {
46167 throw new Error("Sprites cannot be retrieved before the atlas is loaded.");
46169 if (float == null) {
46170 float = Viewer_1.Alignment.Center;
46172 var definition = this._json[name];
46174 console.warn("Sprite with key" + name + "does not exist in sprite definition.");
46175 return vd.h("div", {}, []);
46177 var clipTop = definition.y;
46178 var clipRigth = definition.x + definition.width;
46179 var clipBottom = definition.y + definition.height;
46180 var clipLeft = definition.x;
46181 var left = -definition.x;
46182 var top = -definition.y;
46183 var height = this._image.height;
46184 var width = this._image.width;
46186 case Viewer_1.Alignment.Bottom:
46187 case Viewer_1.Alignment.Center:
46188 case Viewer_1.Alignment.Top:
46189 left -= definition.width / 2;
46191 case Viewer_1.Alignment.BottomLeft:
46192 case Viewer_1.Alignment.Left:
46193 case Viewer_1.Alignment.TopLeft:
46194 left -= definition.width;
46196 case Viewer_1.Alignment.BottomRight:
46197 case Viewer_1.Alignment.Right:
46198 case Viewer_1.Alignment.TopRight:
46203 case Viewer_1.Alignment.Center:
46204 case Viewer_1.Alignment.Left:
46205 case Viewer_1.Alignment.Right:
46206 top -= definition.height / 2;
46208 case Viewer_1.Alignment.Top:
46209 case Viewer_1.Alignment.TopLeft:
46210 case Viewer_1.Alignment.TopRight:
46211 top -= definition.height;
46213 case Viewer_1.Alignment.Bottom:
46214 case Viewer_1.Alignment.BottomLeft:
46215 case Viewer_1.Alignment.BottomRight:
46219 var pixelRatioInverse = 1 / definition.pixelRatio;
46220 clipTop *= pixelRatioInverse;
46221 clipRigth *= pixelRatioInverse;
46222 clipBottom *= pixelRatioInverse;
46223 clipLeft *= pixelRatioInverse;
46224 left *= pixelRatioInverse;
46225 top *= pixelRatioInverse;
46226 height *= pixelRatioInverse;
46227 width *= pixelRatioInverse;
46229 src: this._image.src,
46231 clip: "rect(" + clipTop + "px, " + clipRigth + "px, " + clipBottom + "px, " + clipLeft + "px)",
46232 height: height + "px",
46234 position: "absolute",
46236 width: width + "px",
46239 return vd.h("img", properties, []);
46241 return SpriteAtlas;
46243 var SpriteService = /** @class */ (function () {
46244 function SpriteService(sprite) {
46246 this._retina = window.devicePixelRatio > 1;
46247 this._spriteAtlasOperation$ = new rxjs_1.Subject();
46248 this._spriteAtlas$ = this._spriteAtlasOperation$.pipe(operators_1.startWith(function (atlas) {
46250 }), operators_1.scan(function (atlas, operation) {
46251 return operation(atlas);
46252 }, new SpriteAtlas()), operators_1.publishReplay(1), operators_1.refCount());
46253 this._spriteAtlas$.subscribe(function () { });
46254 if (sprite == null) {
46257 var format = this._retina ? "@2x" : "";
46258 var imageXmlHTTP = new XMLHttpRequest();
46259 imageXmlHTTP.open("GET", sprite + format + ".png", true);
46260 imageXmlHTTP.responseType = "arraybuffer";
46261 imageXmlHTTP.onload = function () {
46262 var image = new Image();
46263 image.onload = function () {
46264 _this._spriteAtlasOperation$.next(function (atlas) {
46265 atlas.image = image;
46269 var blob = new Blob([imageXmlHTTP.response]);
46270 image.src = window.URL.createObjectURL(blob);
46272 imageXmlHTTP.onerror = function (error) {
46273 console.error(new Error("Failed to fetch sprite sheet (" + sprite + format + ".png)"));
46275 imageXmlHTTP.send();
46276 var jsonXmlHTTP = new XMLHttpRequest();
46277 jsonXmlHTTP.open("GET", sprite + format + ".json", true);
46278 jsonXmlHTTP.responseType = "text";
46279 jsonXmlHTTP.onload = function () {
46280 var json = JSON.parse(jsonXmlHTTP.response);
46281 _this._spriteAtlasOperation$.next(function (atlas) {
46286 jsonXmlHTTP.onerror = function (error) {
46287 console.error(new Error("Failed to fetch sheet (" + sprite + format + ".json)"));
46289 jsonXmlHTTP.send();
46291 Object.defineProperty(SpriteService.prototype, "spriteAtlas$", {
46293 return this._spriteAtlas$;
46298 return SpriteService;
46300 exports.SpriteService = SpriteService;
46301 exports.default = SpriteService;
46304 },{"../Viewer":285,"rxjs":26,"rxjs/operators":224,"three":225,"virtual-dom":230}],443:[function(require,module,exports){
46306 Object.defineProperty(exports, "__esModule", { value: true });
46307 var rxjs_1 = require("rxjs");
46308 var operators_1 = require("rxjs/operators");
46309 var TouchService = /** @class */ (function () {
46310 function TouchService(canvasContainer, domContainer) {
46312 this._activeSubject$ = new rxjs_1.BehaviorSubject(false);
46313 this._active$ = this._activeSubject$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
46314 rxjs_1.fromEvent(domContainer, "touchmove")
46315 .subscribe(function (event) {
46316 event.preventDefault();
46318 this._touchStart$ = rxjs_1.fromEvent(canvasContainer, "touchstart");
46319 this._touchMove$ = rxjs_1.fromEvent(canvasContainer, "touchmove");
46320 this._touchEnd$ = rxjs_1.fromEvent(canvasContainer, "touchend");
46321 this._touchCancel$ = rxjs_1.fromEvent(canvasContainer, "touchcancel");
46322 var tapStart$ = this._touchStart$.pipe(operators_1.filter(function (te) {
46323 return te.touches.length === 1 && te.targetTouches.length === 1;
46324 }), operators_1.share());
46325 this._doubleTap$ = tapStart$.pipe(operators_1.bufferWhen(function () {
46326 return tapStart$.pipe(operators_1.first(), operators_1.switchMap(function (event) {
46327 return rxjs_1.merge(rxjs_1.timer(300), tapStart$).pipe(operators_1.take(1));
46329 }), operators_1.filter(function (events) {
46330 return events.length === 2;
46331 }), operators_1.map(function (events) {
46332 return events[events.length - 1];
46333 }), operators_1.share());
46335 .subscribe(function (event) {
46336 event.preventDefault();
46338 this._singleTouchMove$ = this._touchMove$.pipe(operators_1.filter(function (te) {
46339 return te.touches.length === 1 && te.targetTouches.length === 1;
46340 }), operators_1.share());
46341 var singleTouchStart$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
46342 return te.touches.length === 1 && te.targetTouches.length === 1;
46344 var multipleTouchStart$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
46345 return te.touches.length >= 1;
46347 var touchStop$ = rxjs_1.merge(this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
46348 return te.touches.length === 0;
46350 this._singleTouchDragStart$ = singleTouchStart$.pipe(operators_1.mergeMap(function (e) {
46351 return _this._singleTouchMove$.pipe(operators_1.takeUntil(rxjs_1.merge(touchStop$, multipleTouchStart$)), operators_1.take(1));
46353 this._singleTouchDragEnd$ = singleTouchStart$.pipe(operators_1.mergeMap(function (e) {
46354 return rxjs_1.merge(touchStop$, multipleTouchStart$).pipe(operators_1.first());
46356 this._singleTouchDrag$ = singleTouchStart$.pipe(operators_1.switchMap(function (te) {
46357 return _this._singleTouchMove$.pipe(operators_1.skip(1), operators_1.takeUntil(rxjs_1.merge(multipleTouchStart$, touchStop$)));
46359 var touchesChanged$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$);
46360 this._pinchStart$ = touchesChanged$.pipe(operators_1.filter(function (te) {
46361 return te.touches.length === 2 && te.targetTouches.length === 2;
46363 this._pinchEnd$ = touchesChanged$.pipe(operators_1.filter(function (te) {
46364 return te.touches.length !== 2 || te.targetTouches.length !== 2;
46366 this._pinchOperation$ = new rxjs_1.Subject();
46367 this._pinch$ = this._pinchOperation$.pipe(operators_1.scan(function (pinch, operation) {
46368 return operation(pinch);
46378 originalEvent: null,
46386 this._touchMove$.pipe(operators_1.filter(function (te) {
46387 return te.touches.length === 2 && te.targetTouches.length === 2;
46388 }), operators_1.map(function (te) {
46389 return function (previous) {
46390 var touch1 = te.touches[0];
46391 var touch2 = te.touches[1];
46392 var minX = Math.min(touch1.clientX, touch2.clientX);
46393 var maxX = Math.max(touch1.clientX, touch2.clientX);
46394 var minY = Math.min(touch1.clientY, touch2.clientY);
46395 var maxY = Math.max(touch1.clientY, touch2.clientY);
46396 var centerClientX = minX + (maxX - minX) / 2;
46397 var centerClientY = minY + (maxY - minY) / 2;
46398 var centerPageX = centerClientX + touch1.pageX - touch1.clientX;
46399 var centerPageY = centerClientY + touch1.pageY - touch1.clientY;
46400 var centerScreenX = centerClientX + touch1.screenX - touch1.clientX;
46401 var centerScreenY = centerClientY + touch1.screenY - touch1.clientY;
46402 var distanceX = Math.abs(touch1.clientX - touch2.clientX);
46403 var distanceY = Math.abs(touch1.clientY - touch2.clientY);
46404 var distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
46405 var distanceChange = distance - previous.distance;
46406 var changeX = distanceX - previous.distanceX;
46407 var changeY = distanceY - previous.distanceY;
46411 clientX: centerClientX,
46412 clientY: centerClientY,
46413 distance: distance,
46414 distanceChange: distanceChange,
46415 distanceX: distanceX,
46416 distanceY: distanceY,
46418 pageX: centerPageX,
46419 pageY: centerPageY,
46420 screenX: centerScreenX,
46421 screenY: centerScreenY,
46428 .subscribe(this._pinchOperation$);
46429 this._pinchChange$ = this._pinchStart$.pipe(operators_1.switchMap(function (te) {
46430 return _this._pinch$.pipe(operators_1.skip(1), operators_1.takeUntil(_this._pinchEnd$));
46433 Object.defineProperty(TouchService.prototype, "active$", {
46435 return this._active$;
46440 Object.defineProperty(TouchService.prototype, "activate$", {
46442 return this._activeSubject$;
46447 Object.defineProperty(TouchService.prototype, "doubleTap$", {
46449 return this._doubleTap$;
46454 Object.defineProperty(TouchService.prototype, "touchStart$", {
46456 return this._touchStart$;
46461 Object.defineProperty(TouchService.prototype, "touchMove$", {
46463 return this._touchMove$;
46468 Object.defineProperty(TouchService.prototype, "touchEnd$", {
46470 return this._touchEnd$;
46475 Object.defineProperty(TouchService.prototype, "touchCancel$", {
46477 return this._touchCancel$;
46482 Object.defineProperty(TouchService.prototype, "singleTouchDragStart$", {
46484 return this._singleTouchDragStart$;
46489 Object.defineProperty(TouchService.prototype, "singleTouchDrag$", {
46491 return this._singleTouchDrag$;
46496 Object.defineProperty(TouchService.prototype, "singleTouchDragEnd$", {
46498 return this._singleTouchDragEnd$;
46503 Object.defineProperty(TouchService.prototype, "pinch$", {
46505 return this._pinchChange$;
46510 Object.defineProperty(TouchService.prototype, "pinchStart$", {
46512 return this._pinchStart$;
46517 Object.defineProperty(TouchService.prototype, "pinchEnd$", {
46519 return this._pinchEnd$;
46524 return TouchService;
46526 exports.TouchService = TouchService;
46528 },{"rxjs":26,"rxjs/operators":224}],444:[function(require,module,exports){
46530 var __extends = (this && this.__extends) || (function () {
46531 var extendStatics = function (d, b) {
46532 extendStatics = Object.setPrototypeOf ||
46533 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
46534 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
46535 return extendStatics(d, b);
46537 return function (d, b) {
46538 extendStatics(d, b);
46539 function __() { this.constructor = d; }
46540 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
46543 Object.defineProperty(exports, "__esModule", { value: true });
46544 var rxjs_1 = require("rxjs");
46545 var operators_1 = require("rxjs/operators");
46546 var when = require("when");
46547 var Viewer_1 = require("../Viewer");
46548 var Utils_1 = require("../Utils");
46552 * @classdesc The Viewer object represents the navigable image viewer.
46553 * Create a Viewer by specifying a container, client ID, image key and
46554 * other options. The viewer exposes methods and events for programmatic
46557 * In the case of asynchronous methods, MapillaryJS returns promises to
46558 * the results. Notifications are always emitted through JavaScript events.
46560 * The viewer works with a few different coordinate systems.
46562 * Container pixel coordinates
46564 * Pixel coordinates are coordinates on the viewer container. The origin is
46565 * in the top left corner of the container. The axes are
46566 * directed according to the following for a viewer container with a width
46567 * of 640 pixels and height of 480 pixels.
46571 * +------------------------>
46576 * (0, 480) (640, 480)
46579 * Basic image coordinates
46581 * Basic image coordinates represents points in the original image adjusted for
46582 * orientation. They range from 0 to 1 on both axes. The origin is in the top left
46583 * corner of the image and the axes are directed
46584 * according to the following for all image types.
46588 * +------------------------>
46596 * For every camera viewing direction it is possible to convert between these
46597 * two coordinate systems for the current node. The image can be panned and
46598 * zoomed independently of the size of the viewer container resulting in
46599 * different conversion results for different viewing directions.
46601 var Viewer = /** @class */ (function (_super) {
46602 __extends(Viewer, _super);
46604 * Create a new viewer instance.
46606 * @description It is possible to initialize the viewer with or
46609 * When you want to show a specific image in the viewer from
46610 * the start you should initialize it with a key.
46612 * When you do not know the first image key at implementation
46613 * time, e.g. in a map-viewer application you should initialize
46614 * the viewer without a key and call `moveToKey` instead.
46616 * When initializing with a key the viewer is bound to that key
46617 * until the node for that key has been successfully loaded.
46618 * Also, a cover with the image of the key will be shown.
46619 * If the data for that key can not be loaded because the key is
46620 * faulty or other errors occur it is not possible to navigate
46621 * to another key because the viewer is not navigable. The viewer
46622 * becomes navigable when the data for the key has been loaded and
46623 * the image is shown in the viewer. This way of initializing
46624 * the viewer is mostly for embedding in blog posts and similar
46625 * where one wants to show a specific image initially.
46627 * If the viewer is initialized without a key (with null or
46628 * undefined) it is not bound to any particular key and it is
46629 * possible to move to any key with `viewer.moveToKey("<my-image-key>")`.
46630 * If the first move to a key fails it is possible to move to another
46631 * key. The viewer will show a black background until a move
46632 * succeeds. This way of intitializing is suited for a map-viewer
46633 * application when the initial key is not known at implementation
46636 * @param {string} id - Required `id` of a DOM element which will
46637 * be transformed into the viewer.
46638 * @param {string} clientId - Required `Mapillary API ClientID`. Can
46639 * be obtained from https://www.mapillary.com/app/settings/developers.
46640 * @param {string} key - Optional `image-key` to start from. The key
46641 * can be any Mapillary image. If a key is provided the viewer is
46642 * bound to that key until it has been fully loaded. If null is provided
46643 * no image is loaded at viewer initialization and the viewer is not
46644 * bound to any particular key. Any image can then be navigated to
46645 * with e.g. `viewer.moveToKey("<my-image-key>")`.
46646 * @param {IViewerOptions} options - Optional configuration object
46647 * specifing Viewer's and the components' initial setup.
46648 * @param {string} token - Optional bearer token for API requests of
46649 * protected resources.
46653 * var viewer = new Mapillary.Viewer("<element-id>", "<client-id>", "<image-key>");
46656 function Viewer(id, clientId, key, options, token) {
46657 var _this = _super.call(this) || this;
46658 options = options != null ? options : {};
46659 Utils_1.Settings.setOptions(options);
46660 Utils_1.Urls.setOptions(options.url);
46661 _this._navigator = new Viewer_1.Navigator(clientId, options, token);
46662 _this._container = new Viewer_1.Container(id, _this._navigator.stateService, options);
46663 _this._observer = new Viewer_1.Observer(_this, _this._navigator, _this._container);
46664 _this._componentController = new Viewer_1.ComponentController(_this._container, _this._navigator, _this._observer, key, options.component);
46667 Object.defineProperty(Viewer.prototype, "isNavigable", {
46669 * Return a boolean indicating if the viewer is in a navigable state.
46671 * @description The navigable state indicates if the viewer supports
46672 * moving, i.e. calling the {@link moveToKey}, {@link moveDir`}
46673 * and {@link moveCloseTo} methods or changing the authentication state,
46674 * i.e. calling {@link setAuthToken}. The viewer will not be in a navigable
46675 * state if the cover is activated and the viewer has been supplied a key.
46676 * When the cover is deactivated or the viewer is activated without being
46677 * supplied a key it will be navigable.
46679 * @returns {boolean} Boolean indicating whether the viewer is navigable.
46682 return this._componentController.navigable;
46688 * Activate a component.
46690 * @param {string} name - Name of the component which will become active.
46694 * viewer.activateComponent("marker");
46697 Viewer.prototype.activateComponent = function (name) {
46698 this._componentController.activate(name);
46701 * Activate the cover (deactivates all other components).
46703 Viewer.prototype.activateCover = function () {
46704 this._componentController.activateCover();
46707 * Deactivate a component.
46709 * @param {string} name - Name of component which become inactive.
46713 * viewer.deactivateComponent("mouse");
46716 Viewer.prototype.deactivateComponent = function (name) {
46717 this._componentController.deactivate(name);
46720 * Deactivate the cover (activates all components marked as active).
46722 Viewer.prototype.deactivateCover = function () {
46723 this._componentController.deactivateCover();
46726 * Get the bearing of the current viewer camera.
46728 * @description The bearing depends on how the camera
46729 * is currently rotated and does not correspond
46730 * to the compass angle of the current node if the view
46733 * Bearing is measured in degrees clockwise with respect to
46736 * @returns {Promise<number>} Promise to the bearing
46737 * of the current viewer camera.
46741 * viewer.getBearing().then((b) => { console.log(b); });
46744 Viewer.prototype.getBearing = function () {
46746 return when.promise(function (resolve, reject) {
46747 _this._container.renderService.bearing$.pipe(operators_1.first())
46748 .subscribe(function (bearing) {
46750 }, function (error) {
46756 * Get the basic coordinates of the current image that is
46757 * at the center of the viewport.
46759 * @description Basic coordinates are 2D coordinates on the [0, 1] interval
46760 * and have the origin point, (0, 0), at the top left corner and the
46761 * maximum value, (1, 1), at the bottom right corner of the original
46764 * @returns {Promise<number[]>} Promise to the basic coordinates
46765 * of the current image at the center for the viewport.
46769 * viewer.getCenter().then((c) => { console.log(c); });
46772 Viewer.prototype.getCenter = function () {
46774 return when.promise(function (resolve, reject) {
46775 _this._navigator.stateService.getCenter()
46776 .subscribe(function (center) {
46778 }, function (error) {
46786 * @param {string} name - Name of component.
46787 * @returns {Component} The requested component.
46791 * var mouseComponent = viewer.getComponent("mouse");
46794 Viewer.prototype.getComponent = function (name) {
46795 return this._componentController.get(name);
46798 * Returns the viewer's containing HTML element.
46800 * @returns {HTMLElement} The viewer's container.
46802 Viewer.prototype.getContainer = function () {
46803 return this._container.element;
46806 * Get the image's current zoom level.
46808 * @returns {Promise<number>} Promise to the viewers's current
46813 * viewer.getZoom().then((z) => { console.log(z); });
46816 Viewer.prototype.getZoom = function () {
46818 return when.promise(function (resolve, reject) {
46819 _this._navigator.stateService.getZoom()
46820 .subscribe(function (zoom) {
46822 }, function (error) {
46828 * Move close to given latitude and longitude.
46830 * @description Because the method propagates IO errors, these potential errors
46831 * need to be handled by the method caller (see example).
46833 * @param {Number} lat - Latitude, in degrees.
46834 * @param {Number} lon - Longitude, in degrees.
46835 * @returns {Promise<Node>} Promise to the node that was navigated to.
46836 * @throws {Error} If no nodes exist close to provided latitude
46838 * @throws {Error} Propagates any IO errors to the caller.
46839 * @throws {Error} When viewer is not navigable.
46840 * @throws {AbortMapillaryError} When a subsequent move request is made
46841 * before the move close to call has completed.
46845 * viewer.moveCloseTo(0, 0).then(
46846 * (n) => { console.log(n); },
46847 * (e) => { console.error(e); });
46850 Viewer.prototype.moveCloseTo = function (lat, lon) {
46851 var moveCloseTo$ = this.isNavigable ?
46852 this._navigator.moveCloseTo$(lat, lon) :
46853 rxjs_1.throwError(new Error("Calling moveCloseTo is not supported when viewer is not navigable."));
46854 return when.promise(function (resolve, reject) {
46855 moveCloseTo$.subscribe(function (node) {
46857 }, function (error) {
46863 * Navigate in a given direction.
46865 * @description This method has to be called through EdgeDirection enumeration as in the example.
46867 * @param {EdgeDirection} dir - Direction in which which to move.
46868 * @returns {Promise<Node>} Promise to the node that was navigated to.
46869 * @throws {Error} If the current node does not have the edge direction
46870 * or the edges has not yet been cached.
46871 * @throws {Error} Propagates any IO errors to the caller.
46872 * @throws {Error} When viewer is not navigable.
46873 * @throws {AbortMapillaryError} When a subsequent move request is made
46874 * before the move dir call has completed.
46878 * viewer.moveDir(Mapillary.EdgeDirection.Next).then(
46879 * (n) => { console.log(n); },
46880 * (e) => { console.error(e); });
46883 Viewer.prototype.moveDir = function (dir) {
46884 var moveDir$ = this.isNavigable ?
46885 this._navigator.moveDir$(dir) :
46886 rxjs_1.throwError(new Error("Calling moveDir is not supported when viewer is not navigable."));
46887 return when.promise(function (resolve, reject) {
46888 moveDir$.subscribe(function (node) {
46890 }, function (error) {
46896 * Navigate to a given image key.
46898 * @param {string} key - A valid Mapillary image key.
46899 * @returns {Promise<Node>} Promise to the node that was navigated to.
46900 * @throws {Error} Propagates any IO errors to the caller.
46901 * @throws {Error} When viewer is not navigable.
46902 * @throws {AbortMapillaryError} When a subsequent move request is made
46903 * before the move to key call has completed.
46907 * viewer.moveToKey("<my key>").then(
46908 * (n) => { console.log(n); },
46909 * (e) => { console.error(e); });
46912 Viewer.prototype.moveToKey = function (key) {
46913 var moveToKey$ = this.isNavigable ?
46914 this._navigator.moveToKey$(key) :
46915 rxjs_1.throwError(new Error("Calling moveToKey is not supported when viewer is not navigable."));
46916 return when.promise(function (resolve, reject) {
46917 moveToKey$.subscribe(function (node) {
46919 }, function (error) {
46925 * Project basic image coordinates for the current node to canvas pixel
46928 * @description The basic image coordinates may not always correspond to a
46929 * pixel point that lies in the visible area of the viewer container.
46931 * @param {Array<number>} basicPoint - Basic images coordinates to project.
46932 * @returns {Promise<Array<number>>} Promise to the pixel coordinates corresponding
46933 * to the basic image point.
46937 * viewer.projectFromBasic([0.3, 0.7])
46938 * .then((pixelPoint) => { console.log(pixelPoint); });
46941 Viewer.prototype.projectFromBasic = function (basicPoint) {
46943 return when.promise(function (resolve, reject) {
46944 _this._observer.projectBasic$(basicPoint)
46945 .subscribe(function (pixelPoint) {
46946 resolve(pixelPoint);
46947 }, function (error) {
46953 * Detect the viewer's new width and height and resize it.
46955 * @description The components will also detect the viewer's
46956 * new size and resize their rendered elements if needed.
46963 Viewer.prototype.resize = function () {
46964 this._container.renderService.resize$.next(null);
46965 this._componentController.resize();
46968 * Set a bearer token for authenticated API requests of
46969 * protected resources.
46971 * @description When the supplied token is null or undefined,
46972 * any previously set bearer token will be cleared and the
46973 * viewer will make unauthenticated requests.
46975 * Calling setAuthToken aborts all outstanding move requests.
46976 * The promises of those move requests will be rejected with a
46977 * {@link AbortMapillaryError} the rejections need to be caught.
46979 * Calling setAuthToken also resets the complete viewer cache
46980 * so it should not be called repeatedly.
46982 * @param {string} [token] token - Bearer token.
46983 * @returns {Promise<void>} Promise that resolves after token
46986 * @throws {Error} When viewer is not navigable.
46990 * viewer.setAuthToken("<my token>")
46991 * .then(() => { console.log("token set"); });
46994 Viewer.prototype.setAuthToken = function (token) {
46995 var setToken$ = this.isNavigable ?
46996 this._navigator.setToken$(token) :
46997 rxjs_1.throwError(new Error("Calling setAuthToken is not supported when viewer is not navigable."));
46998 return when.promise(function (resolve, reject) {
47000 .subscribe(function () {
47001 resolve(undefined);
47002 }, function (error) {
47008 * Set the basic coordinates of the current image to be in the
47009 * center of the viewport.
47011 * @description Basic coordinates are 2D coordinates on the [0, 1] interval
47012 * and has the origin point, (0, 0), at the top left corner and the
47013 * maximum value, (1, 1), at the bottom right corner of the original
47016 * @param {number[]} The basic coordinates of the current
47017 * image to be at the center for the viewport.
47021 * viewer.setCenter([0.5, 0.5]);
47024 Viewer.prototype.setCenter = function (center) {
47025 this._navigator.stateService.setCenter(center);
47028 * Set the filter selecting nodes to use when calculating
47029 * the spatial edges.
47031 * @description The following filter types are supported:
47035 * `["==", key, value]` equality: `node[key] = value`
47037 * `["!=", key, value]` inequality: `node[key] ≠value`
47039 * `["<", key, value]` less than: `node[key] < value`
47041 * `["<=", key, value]` less than or equal: `node[key] ≤ value`
47043 * `[">", key, value]` greater than: `node[key] > value`
47045 * `[">=", key, value]` greater than or equal: `node[key] ≥ value`
47049 * `["in", key, v0, ..., vn]` set inclusion: `node[key] ∈ {v0, ..., vn}`
47051 * `["!in", key, v0, ..., vn]` set exclusion: `node[key] ∉ {v0, ..., vn}`
47055 * `["all", f0, ..., fn]` logical `AND`: `f0 ∧ ... ∧ fn`
47057 * A key must be a string that identifies a property name of a
47058 * simple {@link Node} property. A value must be a string, number, or
47059 * boolean. Strictly-typed comparisons are used. The values
47060 * `f0, ..., fn` of the combining filter must be filter expressions.
47062 * Clear the filter by setting it to null or empty array.
47064 * @param {FilterExpression} filter - The filter expression.
47065 * @returns {Promise<void>} Promise that resolves after filter is applied.
47069 * viewer.setFilter(["==", "sequenceKey", "<my sequence key>"]);
47072 Viewer.prototype.setFilter = function (filter) {
47074 return when.promise(function (resolve, reject) {
47075 _this._navigator.setFilter$(filter)
47076 .subscribe(function () {
47077 resolve(undefined);
47078 }, function (error) {
47084 * Set the viewer's render mode.
47086 * @param {RenderMode} renderMode - Render mode.
47090 * viewer.setRenderMode(Mapillary.RenderMode.Letterbox);
47093 Viewer.prototype.setRenderMode = function (renderMode) {
47094 this._container.renderService.renderMode$.next(renderMode);
47097 * Set the viewer's transition mode.
47099 * @param {TransitionMode} transitionMode - Transition mode.
47103 * viewer.setTransitionMode(Mapillary.TransitionMode.Instantaneous);
47106 Viewer.prototype.setTransitionMode = function (transitionMode) {
47107 this._navigator.stateService.setTransitionMode(transitionMode);
47110 * Set the image's current zoom level.
47112 * @description Possible zoom level values are on the [0, 3] interval.
47113 * Zero means zooming out to fit the image to the view whereas three
47114 * shows the highest level of detail.
47116 * @param {number} The image's current zoom level.
47120 * viewer.setZoom(2);
47123 Viewer.prototype.setZoom = function (zoom) {
47124 this._navigator.stateService.setZoom(zoom);
47127 * Unproject canvas pixel coordinates to an ILatLon representing geographical
47130 * @description The pixel point may not always correspond to geographical
47131 * coordinates. In the case of no correspondence the returned value will
47134 * @param {Array<number>} pixelPoint - Pixel coordinates to unproject.
47135 * @returns {Promise<ILatLon>} Promise to the latLon corresponding to the pixel point.
47139 * viewer.unproject([100, 100])
47140 * .then((latLon) => { console.log(latLon); });
47143 Viewer.prototype.unproject = function (pixelPoint) {
47145 return when.promise(function (resolve, reject) {
47146 _this._observer.unproject$(pixelPoint)
47147 .subscribe(function (latLon) {
47149 }, function (error) {
47155 * Unproject canvas pixel coordinates to basic image coordinates for the
47158 * @description The pixel point may not always correspond to basic image
47159 * coordinates. In the case of no correspondence the returned value will
47162 * @param {Array<number>} pixelPoint - Pixel coordinates to unproject.
47163 * @returns {Promise<ILatLon>} Promise to the basic coordinates corresponding
47164 * to the pixel point.
47168 * viewer.unprojectToBasic([100, 100])
47169 * .then((basicPoint) => { console.log(basicPoint); });
47172 Viewer.prototype.unprojectToBasic = function (pixelPoint) {
47174 return when.promise(function (resolve, reject) {
47175 _this._observer.unprojectBasic$(pixelPoint)
47176 .subscribe(function (basicPoint) {
47177 resolve(basicPoint);
47178 }, function (error) {
47184 * Fired when the viewing direction of the camera changes.
47186 * @description Related to the computed compass angle
47187 * ({@link Node.computedCa}) from SfM, not the original EXIF compass
47191 * @type {number} bearing - Value indicating the current bearing
47192 * measured in degrees clockwise with respect to north.
47194 Viewer.bearingchanged = "bearingchanged";
47196 * Fired when a pointing device (usually a mouse) is pressed and released at
47197 * the same point in the viewer.
47199 * @type {IViewerMouseEvent} event - Viewer mouse event data.
47201 Viewer.click = "click";
47203 * Fired when the right button of the mouse is clicked within the viewer.
47205 * @type {IViewerMouseEvent} event - Viewer mouse event data.
47207 Viewer.contextmenu = "contextmenu";
47209 * Fired when a pointing device (usually a mouse) is clicked twice at
47210 * the same point in the viewer.
47212 * @type {IViewerMouseEvent} event - Viewer mouse event data.
47214 Viewer.dblclick = "dblclick";
47216 * Fired when the viewer is loading more data.
47218 * @type {boolean} loading - Boolean indicating whether the viewer is loading.
47220 Viewer.loadingchanged = "loadingchanged";
47222 * Fired when a pointing device (usually a mouse) is pressed within the viewer.
47224 * @type {IViewerMouseEvent} event - Viewer mouse event data.
47226 Viewer.mousedown = "mousedown";
47228 * Fired when a pointing device (usually a mouse) is moved within the viewer.
47229 * @description Will not fire when the mouse is actively used, e.g. for drag pan.
47231 * @type {IViewerMouseEvent} event - Viewer mouse event data.
47233 Viewer.mousemove = "mousemove";
47235 * Fired when a pointing device (usually a mouse) leaves the viewer's canvas.
47237 * @type {IViewerMouseEvent} event - Viewer mouse event data.
47239 Viewer.mouseout = "mouseout";
47241 * Fired when a pointing device (usually a mouse) is moved onto the viewer's canvas.
47243 * @type {IViewerMouseEvent} event - Viewer mouse event data.
47245 Viewer.mouseover = "mouseover";
47247 * Fired when a pointing device (usually a mouse) is released within the viewer.
47249 * @type {IViewerMouseEvent} event - Viewer mouse event data.
47251 Viewer.mouseup = "mouseup";
47253 * Fired when the viewer motion stops and it is in a fixed
47254 * position with a fixed point of view.
47257 Viewer.moveend = "moveend";
47259 * Fired when the motion from one view to another start,
47260 * either by changing the position (e.g. when changing node) or
47261 * when changing point of view (e.g. by interaction such as pan and zoom).
47264 Viewer.movestart = "movestart";
47266 * Fired when the navigable state of the viewer changes.
47268 * @description The navigable state indicates if the viewer supports
47269 * moving, i.e. calling the `moveToKey`, `moveDir` and `moveCloseTo`
47270 * methods. The viewer will not be in a navigable state if the cover
47271 * is activated and the viewer has been supplied a key. When the cover
47272 * is deactivated or activated without being supplied a key it will
47276 * @type {boolean} navigable - Boolean indicating whether the viewer is navigable.
47278 Viewer.navigablechanged = "navigablechanged";
47280 * Fired every time the viewer navigates to a new node.
47282 * @type {Node} node - Current node.
47284 Viewer.nodechanged = "nodechanged";
47286 * Fired every time the sequence edges of the current node changes.
47288 * @type {IEdgeStatus} status - The edge status object.
47290 Viewer.sequenceedgeschanged = "sequenceedgeschanged";
47292 * Fired every time the spatial edges of the current node changes.
47294 * @type {IEdgeStatus} status - The edge status object.
47296 Viewer.spatialedgeschanged = "spatialedgeschanged";
47298 }(Utils_1.EventEmitter));
47299 exports.Viewer = Viewer;
47301 },{"../Utils":284,"../Viewer":285,"rxjs":26,"rxjs/operators":224,"when":271}]},{},[279])(279)
47303 //# sourceMappingURL=mapillary.js.map