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":227}],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){
3888 * Martinez polygon clipping algorithm, does boolean operation on polygons (multipolygons, polygons with holes etc): intersection, union, difference, xor
3890 * @author Alex Milevski <info@w8r.name>
3895 (function (global, factory) {
3896 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3897 typeof define === 'function' && define.amd ? define(['exports'], factory) :
3898 (factory((global.martinez = {})));
3899 }(this, (function (exports) { 'use strict';
3901 function DEFAULT_COMPARE (a, b) { return a > b ? 1 : a < b ? -1 : 0; }
3903 var SplayTree = function SplayTree(compare, noDuplicates) {
3904 if ( compare === void 0 ) compare = DEFAULT_COMPARE;
3905 if ( noDuplicates === void 0 ) noDuplicates = false;
3907 this._compare = compare;
3910 this._noDuplicates = !!noDuplicates;
3913 var prototypeAccessors = { size: { configurable: true } };
3916 SplayTree.prototype.rotateLeft = function rotateLeft (x) {
3920 if (y.left) { y.left.parent = x; }
3921 y.parent = x.parent;
3924 if (!x.parent) { this._root = y; }
3925 else if (x === x.parent.left) { x.parent.left = y; }
3926 else { x.parent.right = y; }
3927 if (y) { y.left = x; }
3932 SplayTree.prototype.rotateRight = function rotateRight (x) {
3936 if (y.right) { y.right.parent = x; }
3937 y.parent = x.parent;
3940 if (!x.parent) { this._root = y; }
3941 else if(x === x.parent.left) { x.parent.left = y; }
3942 else { x.parent.right = y; }
3943 if (y) { y.right = x; }
3948 SplayTree.prototype._splay = function _splay (x) {
3954 if (p.left === x) { this$1.rotateRight(p); }
3955 else { this$1.rotateLeft(p); }
3956 } else if (p.left === x && p.parent.left === p) {
3957 this$1.rotateRight(p.parent);
3958 this$1.rotateRight(p);
3959 } else if (p.right === x && p.parent.right === p) {
3960 this$1.rotateLeft(p.parent);
3961 this$1.rotateLeft(p);
3962 } else if (p.left === x && p.parent.right === p) {
3963 this$1.rotateRight(p);
3964 this$1.rotateLeft(p);
3966 this$1.rotateLeft(p);
3967 this$1.rotateRight(p);
3973 SplayTree.prototype.splay = function splay (x) {
3976 var p, gp, ggp, l, r;
3982 if (gp && gp.parent) {
3984 if (ggp.left === gp) { ggp.left= x; }
3985 else { ggp.right = x; }
3992 l = x.left; r = x.right;
3994 if (x === p.left) { // left
3996 if (gp.left === p) {
4000 gp.left.parent = gp;
4001 } else { gp.left = null; }
4010 } else { gp.right = null; }
4019 } else { p.left = null; }
4025 if (gp.right === p) {
4029 gp.right.parent = gp;
4030 } else { gp.right = null; }
4039 } else { gp.left = null; }
4048 } else { p.right = null; }
4057 SplayTree.prototype.replace = function replace (u, v) {
4058 if (!u.parent) { this._root = v; }
4059 else if (u === u.parent.left) { u.parent.left = v; }
4060 else { u.parent.right = v; }
4061 if (v) { v.parent = u.parent; }
4065 SplayTree.prototype.minNode = function minNode (u) {
4066 if ( u === void 0 ) u = this._root;
4068 if (u) { while (u.left) { u = u.left; } }
4073 SplayTree.prototype.maxNode = function maxNode (u) {
4074 if ( u === void 0 ) u = this._root;
4076 if (u) { while (u.right) { u = u.right; } }
4081 SplayTree.prototype.insert = function insert (key, data) {
4084 var comp = this._compare;
4087 if (this._noDuplicates) {
4090 cmp = comp(z.key, key);
4091 if (cmp === 0) { return; }
4092 else if (comp(z.key, key) < 0) { z = z.right; }
4093 else { z = z.left; }
4098 if (comp(z.key, key) < 0) { z = z.right; }
4099 else { z = z.left; }
4103 z = { key: key, data: data, left: null, right: null, parent: p };
4105 if (!p) { this._root = z; }
4106 else if (comp(p.key, z.key) < 0) { p.right = z; }
4115 SplayTree.prototype.find = function find (key) {
4117 var comp = this._compare;
4119 var cmp = comp(z.key, key);
4120 if (cmp < 0) { z = z.right; }
4121 else if (cmp > 0) { z = z.left; }
4128 * Whether the tree contains a node with the given key
4130 * @return {boolean} true/false
4132 SplayTree.prototype.contains = function contains (key) {
4133 var node = this._root;
4134 var comparator = this._compare;
4136 var cmp = comparator(key, node.key);
4137 if (cmp === 0) { return true; }
4138 else if (cmp < 0) { node = node.left; }
4139 else { node = node.right; }
4146 SplayTree.prototype.remove = function remove (key) {
4147 var z = this.find(key);
4149 if (!z) { return false; }
4153 if (!z.left) { this.replace(z, z.right); }
4154 else if (!z.right) { this.replace(z, z.left); }
4156 var y = this.minNode(z.right);
4157 if (y.parent !== z) {
4158 this.replace(y, y.right);
4172 SplayTree.prototype.removeNode = function removeNode (z) {
4173 if (!z) { return false; }
4177 if (!z.left) { this.replace(z, z.right); }
4178 else if (!z.right) { this.replace(z, z.left); }
4180 var y = this.minNode(z.right);
4181 if (y.parent !== z) {
4182 this.replace(y, y.right);
4196 SplayTree.prototype.erase = function erase (key) {
4197 var z = this.find(key);
4208 sMax = this.maxNode(s);
4213 if (s) { sMax.right = t; }
4214 else { this._root = t; }
4222 * Removes and returns the node with smallest key
4225 SplayTree.prototype.pop = function pop () {
4226 var node = this._root, returnValue = null;
4228 while (node.left) { node = node.left; }
4229 returnValue = { key: node.key, data: node.data };
4230 this.remove(node.key);
4236 /* eslint-disable class-methods-use-this */
4243 SplayTree.prototype.next = function next (node) {
4244 var successor = node;
4246 if (successor.right) {
4247 successor = successor.right;
4248 while (successor && successor.left) { successor = successor.left; }
4250 successor = node.parent;
4251 while (successor && successor.right === node) {
4252 node = successor; successor = successor.parent;
4265 SplayTree.prototype.prev = function prev (node) {
4266 var predecessor = node;
4268 if (predecessor.left) {
4269 predecessor = predecessor.left;
4270 while (predecessor && predecessor.right) { predecessor = predecessor.right; }
4272 predecessor = node.parent;
4273 while (predecessor && predecessor.left === node) {
4275 predecessor = predecessor.parent;
4281 /* eslint-enable class-methods-use-this */
4285 * @param{forEachCallback} callback
4286 * @return {SplayTree}
4288 SplayTree.prototype.forEach = function forEach (callback) {
4289 var current = this._root;
4290 var s = [], done = false, i = 0;
4293 // Reach the left most Node of the current Node
4295 // Place pointer to a tree node on the stack
4296 // before traversing the node's left subtree
4298 current = current.left;
4300 // BackTrack from the empty subtree and visit the Node
4301 // at the top of the stack; however, if the stack is
4302 // empty you are done
4305 callback(current, i++);
4307 // We have visited the node and its left
4308 // subtree. Now, it's right subtree's turn
4309 current = current.right;
4310 } else { done = true; }
4318 * Walk key range from `low` to `high`. Stops if `fn` returns a value.
4321 * @param{Function} fn
4323 * @return {SplayTree}
4325 SplayTree.prototype.range = function range (low, high, fn, ctx) {
4329 var compare = this._compare;
4330 var node = this._root, cmp;
4332 while (Q.length !== 0 || node) {
4338 cmp = compare(node.key, high);
4341 } else if (compare(node.key, low) >= 0) {
4342 if (fn.call(ctx, node)) { return this$1; } // stop if smth is returned
4351 * Returns all keys in order
4352 * @return {Array<Key>}
4354 SplayTree.prototype.keys = function keys () {
4355 var current = this._root;
4356 var s = [], r = [], done = false;
4361 current = current.left;
4365 r.push(current.key);
4366 current = current.right;
4367 } else { done = true; }
4375 * Returns `data` fields of all nodes in order.
4376 * @return {Array<Value>}
4378 SplayTree.prototype.values = function values () {
4379 var current = this._root;
4380 var s = [], r = [], done = false;
4385 current = current.left;
4389 r.push(current.data);
4390 current = current.right;
4391 } else { done = true; }
4399 * Returns node at given index
4400 * @param{number} index
4403 SplayTree.prototype.at = function at (index) {
4404 // removed after a consideration, more misleading than useful
4405 // index = index % this.size;
4406 // if (index < 0) index = this.size - index;
4408 var current = this._root;
4409 var s = [], done = false, i = 0;
4414 current = current.left;
4418 if (i === index) { return current; }
4420 current = current.right;
4421 } else { done = true; }
4428 * Bulk-load items. Both array have to be same size
4429 * @param{Array<Key>} keys
4430 * @param{Array<Value>}[values]
4431 * @param{Boolean} [presort=false] Pre-sort keys and values, using
4432 * tree's comparator. Sorting is done
4436 SplayTree.prototype.load = function load (keys, values, presort) {
4437 if ( keys === void 0 ) keys = [];
4438 if ( values === void 0 ) values = [];
4439 if ( presort === void 0 ) presort = false;
4441 if (this._size !== 0) { throw new Error('bulk-load: tree is not empty'); }
4442 var size = keys.length;
4443 if (presort) { sort(keys, values, 0, size - 1, this._compare); }
4444 this._root = loadRecursive(null, keys, values, 0, size);
4450 SplayTree.prototype.min = function min () {
4451 var node = this.minNode(this._root);
4452 if (node) { return node.key; }
4453 else { return null; }
4457 SplayTree.prototype.max = function max () {
4458 var node = this.maxNode(this._root);
4459 if (node) { return node.key; }
4460 else { return null; }
4463 SplayTree.prototype.isEmpty = function isEmpty () { return this._root === null; };
4464 prototypeAccessors.size.get = function () { return this._size; };
4468 * Create a tree and load it with items
4469 * @param{Array<Key>} keys
4470 * @param{Array<Value>?} [values]
4472 * @param{Function?} [comparator]
4473 * @param{Boolean?} [presort=false] Pre-sort keys and values, using
4474 * tree's comparator. Sorting is done
4476 * @param{Boolean?} [noDuplicates=false] Allow duplicates
4477 * @return {SplayTree}
4479 SplayTree.createTree = function createTree (keys, values, comparator, presort, noDuplicates) {
4480 return new SplayTree(comparator, noDuplicates).load(keys, values, presort);
4483 Object.defineProperties( SplayTree.prototype, prototypeAccessors );
4486 function loadRecursive (parent, keys, values, start, end) {
4487 var size = end - start;
4489 var middle = start + Math.floor(size / 2);
4490 var key = keys[middle];
4491 var data = values[middle];
4492 var node = { key: key, data: data, parent: parent };
4493 node.left = loadRecursive(node, keys, values, start, middle);
4494 node.right = loadRecursive(node, keys, values, middle + 1, end);
4501 function sort(keys, values, left, right, compare) {
4502 if (left >= right) { return; }
4504 var pivot = keys[(left + right) >> 1];
4509 do { i++; } while (compare(keys[i], pivot) < 0);
4510 do { j--; } while (compare(keys[j], pivot) > 0);
4511 if (i >= j) { break; }
4518 values[i] = values[j];
4522 sort(keys, values, left, j, compare);
4523 sort(keys, values, j + 1, right, compare);
4527 var NON_CONTRIBUTING = 1;
4528 var SAME_TRANSITION = 2;
4529 var DIFFERENT_TRANSITION = 3;
4531 var INTERSECTION = 0;
4537 * @param {SweepEvent} event
4538 * @param {SweepEvent} prev
4539 * @param {Operation} operation
4541 function computeFields (event, prev, operation) {
4542 // compute inOut and otherInOut fields
4543 if (prev === null) {
4544 event.inOut = false;
4545 event.otherInOut = true;
4547 // previous line segment in sweepline belongs to the same polygon
4549 if (event.isSubject === prev.isSubject) {
4550 event.inOut = !prev.inOut;
4551 event.otherInOut = prev.otherInOut;
4553 // previous line segment in sweepline belongs to the clipping polygon
4555 event.inOut = !prev.otherInOut;
4556 event.otherInOut = prev.isVertical() ? !prev.inOut : prev.inOut;
4559 // compute prevInResult field
4561 event.prevInResult = (!inResult(prev, operation) || prev.isVertical())
4562 ? prev.prevInResult : prev;
4566 // check if the line segment belongs to the Boolean operation
4567 event.inResult = inResult(event, operation);
4571 /* eslint-disable indent */
4572 function inResult(event, operation) {
4573 switch (event.type) {
4575 switch (operation) {
4577 return !event.otherInOut;
4579 return event.otherInOut;
4581 // return (event.isSubject && !event.otherInOut) ||
4582 // (!event.isSubject && event.otherInOut);
4583 return (event.isSubject && event.otherInOut) ||
4584 (!event.isSubject && !event.otherInOut);
4589 case SAME_TRANSITION:
4590 return operation === INTERSECTION || operation === UNION;
4591 case DIFFERENT_TRANSITION:
4592 return operation === DIFFERENCE;
4593 case NON_CONTRIBUTING:
4598 /* eslint-enable indent */
4600 var SweepEvent = function SweepEvent (point, left, otherEvent, isSubject, edgeType) {
4609 * @type {Array.<Number>}
4614 * Other edge reference
4615 * @type {SweepEvent}
4617 this.otherEvent = otherEvent;
4620 * Belongs to source or clipping polygon
4623 this.isSubject = isSubject;
4626 * Edge contribution type
4629 this.type = edgeType || NORMAL;
4633 * In-out transition for the sweepline crossing polygon
4642 this.otherInOut = false;
4645 * Previous event in result?
4646 * @type {SweepEvent}
4648 this.prevInResult = null;
4651 * Does event belong to result?
4654 this.inResult = false;
4662 this.resultInOut = false;
4664 this.isExteriorRing = true;
4669 * @param{Array.<Number>}p
4672 SweepEvent.prototype.isBelow = function isBelow (p) {
4673 var p0 = this.point, p1 = this.otherEvent.point;
4675 ? (p0[0] - p[0]) * (p1[1] - p[1]) - (p1[0] - p[0]) * (p0[1] - p[1]) > 0
4676 // signedArea(this.point, this.otherEvent.point, p) > 0 :
4677 : (p1[0] - p[0]) * (p0[1] - p[1]) - (p0[0] - p[0]) * (p1[1] - p[1]) > 0;
4678 //signedArea(this.otherEvent.point, this.point, p) > 0;
4683 * @param{Array.<Number>}p
4686 SweepEvent.prototype.isAbove = function isAbove (p) {
4687 return !this.isBelow(p);
4694 SweepEvent.prototype.isVertical = function isVertical () {
4695 return this.point[0] === this.otherEvent.point[0];
4699 SweepEvent.prototype.clone = function clone () {
4700 var copy = new SweepEvent(
4701 this.point, this.left, this.otherEvent, this.isSubject, this.type);
4703 copy.inResult = this.inResult;
4704 copy.prevInResult = this.prevInResult;
4705 copy.isExteriorRing = this.isExteriorRing;
4706 copy.inOut = this.inOut;
4707 copy.otherInOut = this.otherInOut;
4712 function equals(p1, p2) {
4713 if (p1[0] === p2[0]) {
4714 if (p1[1] === p2[1]) {
4723 // const EPSILON = 1e-9;
4724 // const abs = Math.abs;
4725 // TODO https://github.com/w8r/martinez/issues/6#issuecomment-262847164
4726 // Precision problem.
4728 // module.exports = function equals(p1, p2) {
4729 // return abs(p1[0] - p2[0]) <= EPSILON && abs(p1[1] - p2[1]) <= EPSILON;
4733 * Signed area of the triangle (p0, p1, p2)
4734 * @param {Array.<Number>} p0
4735 * @param {Array.<Number>} p1
4736 * @param {Array.<Number>} p2
4739 function signedArea(p0, p1, p2) {
4740 return (p0[0] - p2[0]) * (p1[1] - p2[1]) - (p1[0] - p2[0]) * (p0[1] - p2[1]);
4744 * @param {SweepEvent} e1
4745 * @param {SweepEvent} e2
4748 function compareEvents(e1, e2) {
4752 // Different x-coordinate
4753 if (p1[0] > p2[0]) { return 1; }
4754 if (p1[0] < p2[0]) { return -1; }
4756 // Different points, but same x-coordinate
4757 // Event with lower y-coordinate is processed first
4758 if (p1[1] !== p2[1]) { return p1[1] > p2[1] ? 1 : -1; }
4760 return specialCases(e1, e2, p1, p2);
4764 /* eslint-disable no-unused-vars */
4765 function specialCases(e1, e2, p1, p2) {
4766 // Same coordinates, but one is a left endpoint and the other is
4767 // a right endpoint. The right endpoint is processed first
4768 if (e1.left !== e2.left)
4769 { return e1.left ? 1 : -1; }
4771 // const p2 = e1.otherEvent.point, p3 = e2.otherEvent.point;
4772 // const sa = (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1])
4773 // Same coordinates, both events
4774 // are left endpoints or right endpoints.
4776 if (signedArea(p1, e1.otherEvent.point, e2.otherEvent.point) !== 0) {
4777 // the event associate to the bottom segment is processed first
4778 return (!e1.isBelow(e2.otherEvent.point)) ? 1 : -1;
4781 return (!e1.isSubject && e2.isSubject) ? 1 : -1;
4783 /* eslint-enable no-unused-vars */
4786 * @param {SweepEvent} se
4787 * @param {Array.<Number>} p
4788 * @param {Queue} queue
4791 function divideSegment(se, p, queue) {
4792 var r = new SweepEvent(p, false, se, se.isSubject);
4793 var l = new SweepEvent(p, true, se.otherEvent, se.isSubject);
4795 /* eslint-disable no-console */
4796 if (equals(se.point, se.otherEvent.point)) {
4798 console.warn('what is that, a collapsed segment?', se);
4800 /* eslint-enable no-console */
4802 r.contourId = l.contourId = se.contourId;
4804 // avoid a rounding error. The left event would be processed after the right event
4805 if (compareEvents(l, se.otherEvent) > 0) {
4806 se.otherEvent.left = true;
4810 // avoid a rounding error. The left event would be processed after the right event
4811 // if (compareEvents(se, r) > 0) {}
4813 se.otherEvent.otherEvent = l;
4825 * Finds the magnitude of the cross product of two vectors (if we pretend
4826 * they're in three dimensions)
4828 * @param {Object} a First vector
4829 * @param {Object} b Second vector
4831 * @returns {Number} The magnitude of the cross product
4833 function crossProduct(a, b) {
4834 return (a[0] * b[1]) - (a[1] * b[0]);
4838 * Finds the dot product of two vectors.
4840 * @param {Object} a First vector
4841 * @param {Object} b Second vector
4843 * @returns {Number} The dot product
4845 function dotProduct(a, b) {
4846 return (a[0] * b[0]) + (a[1] * b[1]);
4850 * Finds the intersection (if any) between two line segments a and b, given the
4851 * line segments' end points a1, a2 and b1, b2.
4853 * This algorithm is based on Schneider and Eberly.
4854 * http://www.cimec.org.ar/~ncalvo/Schneider_Eberly.pdf
4857 * @param {Array.<Number>} a1 point of first line
4858 * @param {Array.<Number>} a2 point of first line
4859 * @param {Array.<Number>} b1 point of second line
4860 * @param {Array.<Number>} b2 point of second line
4861 * @param {Boolean=} noEndpointTouch whether to skip single touchpoints
4862 * (meaning connected segments) as
4864 * @returns {Array.<Array.<Number>>|Null} If the lines intersect, the point of
4865 * intersection. If they overlap, the two end points of the overlapping segment.
4868 function intersection (a1, a2, b1, b2, noEndpointTouch) {
4869 // The algorithm expects our lines in the form P + sd, where P is a point,
4870 // s is on the interval [0, 1], and d is a vector.
4871 // We are passed two points. P can be the first point of each pair. The
4872 // vector, then, could be thought of as the distance (in x and y components)
4873 // from the first point to the second point.
4874 // So first, let's make our vectors:
4875 var va = [a2[0] - a1[0], a2[1] - a1[1]];
4876 var vb = [b2[0] - b1[0], b2[1] - b1[1]];
4877 // We also define a function to convert back to regular point form:
4879 /* eslint-disable arrow-body-style */
4881 function toPoint(p, s, d) {
4888 /* eslint-enable arrow-body-style */
4890 // The rest is pretty much a straight port of the algorithm.
4891 var e = [b1[0] - a1[0], b1[1] - a1[1]];
4892 var kross = crossProduct(va, vb);
4893 var sqrKross = kross * kross;
4894 var sqrLenA = dotProduct(va, va);
4895 //const sqrLenB = dotProduct(vb, vb);
4897 // Check for line intersection. This works because of the properties of the
4898 // cross product -- specifically, two vectors are parallel if and only if the
4899 // cross product is the 0 vector. The full calculation involves relative error
4900 // to account for possible very small line segments. See Schneider & Eberly
4902 if (sqrKross > 0/* EPS * sqrLenB * sqLenA */) {
4903 // If they're not parallel, then (because these are line segments) they
4904 // still might not actually intersect. This code checks that the
4905 // intersection point of the lines is actually on both line segments.
4906 var s = crossProduct(e, vb) / kross;
4907 if (s < 0 || s > 1) {
4908 // not on line segment a
4911 var t = crossProduct(e, va) / kross;
4912 if (t < 0 || t > 1) {
4913 // not on line segment b
4916 if (s === 0 || s === 1) {
4917 // on an endpoint of line segment a
4918 return noEndpointTouch ? null : [toPoint(a1, s, va)];
4920 if (t === 0 || t === 1) {
4921 // on an endpoint of line segment b
4922 return noEndpointTouch ? null : [toPoint(b1, t, vb)];
4924 return [toPoint(a1, s, va)];
4927 // If we've reached this point, then the lines are either parallel or the
4928 // same, but the segments could overlap partially or fully, or not at all.
4929 // So we need to find the overlap, if any. To do that, we can use e, which is
4930 // the (vector) difference between the two initial points. If this is parallel
4931 // with the line itself, then the two lines are the same line, and there will
4933 //const sqrLenE = dotProduct(e, e);
4934 kross = crossProduct(e, va);
4935 sqrKross = kross * kross;
4937 if (sqrKross > 0 /* EPS * sqLenB * sqLenE */) {
4938 // Lines are just parallel, not the same. No overlap.
4942 var sa = dotProduct(va, e) / sqrLenA;
4943 var sb = sa + dotProduct(va, vb) / sqrLenA;
4944 var smin = Math.min(sa, sb);
4945 var smax = Math.max(sa, sb);
4947 // this is, essentially, the FindIntersection acting on floats from
4948 // Schneider & Eberly, just inlined into this function.
4949 if (smin <= 1 && smax >= 0) {
4951 // overlap on an end point
4953 return noEndpointTouch ? null : [toPoint(a1, smin > 0 ? smin : 0, va)];
4957 return noEndpointTouch ? null : [toPoint(a1, smax < 1 ? smax : 1, va)];
4960 if (noEndpointTouch && smin === 0 && smax === 1) { return null; }
4962 // There's overlap on a segment -- two points of intersection. Return both.
4964 toPoint(a1, smin > 0 ? smin : 0, va),
4965 toPoint(a1, smax < 1 ? smax : 1, va)
4973 * @param {SweepEvent} se1
4974 * @param {SweepEvent} se2
4975 * @param {Queue} queue
4978 function possibleIntersection (se1, se2, queue) {
4979 // that disallows self-intersecting polygons,
4980 // did cost us half a day, so I'll leave it
4982 // if (se1.isSubject === se2.isSubject) return;
4983 var inter = intersection(
4984 se1.point, se1.otherEvent.point,
4985 se2.point, se2.otherEvent.point
4988 var nintersections = inter ? inter.length : 0;
4989 if (nintersections === 0) { return 0; } // no intersection
4991 // the line segments intersect at an endpoint of both line segments
4992 if ((nintersections === 1) &&
4993 (equals(se1.point, se2.point) ||
4994 equals(se1.otherEvent.point, se2.otherEvent.point))) {
4998 if (nintersections === 2 && se1.isSubject === se2.isSubject) {
4999 // if(se1.contourId === se2.contourId){
5000 // console.warn('Edges of the same polygon overlap',
5001 // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point);
5003 //throw new Error('Edges of the same polygon overlap');
5007 // The line segments associated to se1 and se2 intersect
5008 if (nintersections === 1) {
5010 // if the intersection point is not an endpoint of se1
5011 if (!equals(se1.point, inter[0]) && !equals(se1.otherEvent.point, inter[0])) {
5012 divideSegment(se1, inter[0], queue);
5015 // if the intersection point is not an endpoint of se2
5016 if (!equals(se2.point, inter[0]) && !equals(se2.otherEvent.point, inter[0])) {
5017 divideSegment(se2, inter[0], queue);
5022 // The line segments associated to se1 and se2 overlap
5024 var leftCoincide = false;
5025 var rightCoincide = false;
5027 if (equals(se1.point, se2.point)) {
5028 leftCoincide = true; // linked
5029 } else if (compareEvents(se1, se2) === 1) {
5030 events.push(se2, se1);
5032 events.push(se1, se2);
5035 if (equals(se1.otherEvent.point, se2.otherEvent.point)) {
5036 rightCoincide = true;
5037 } else if (compareEvents(se1.otherEvent, se2.otherEvent) === 1) {
5038 events.push(se2.otherEvent, se1.otherEvent);
5040 events.push(se1.otherEvent, se2.otherEvent);
5043 if ((leftCoincide && rightCoincide) || leftCoincide) {
5044 // both line segments are equal or share the left endpoint
5045 se2.type = NON_CONTRIBUTING;
5046 se1.type = (se2.inOut === se1.inOut)
5047 ? SAME_TRANSITION : DIFFERENT_TRANSITION;
5049 if (leftCoincide && !rightCoincide) {
5050 // honestly no idea, but changing events selection from [2, 1]
5051 // to [0, 1] fixes the overlapping self-intersecting polygons issue
5052 divideSegment(events[1].otherEvent, events[0].point, queue);
5057 // the line segments share the right endpoint
5058 if (rightCoincide) {
5059 divideSegment(events[0], events[1].point, queue);
5063 // no line segment includes totally the other one
5064 if (events[0] !== events[3].otherEvent) {
5065 divideSegment(events[0], events[1].point, queue);
5066 divideSegment(events[1], events[2].point, queue);
5070 // one line segment includes the other one
5071 divideSegment(events[0], events[1].point, queue);
5072 divideSegment(events[3].otherEvent, events[2].point, queue);
5078 * @param {SweepEvent} le1
5079 * @param {SweepEvent} le2
5082 function compareSegments(le1, le2) {
5083 if (le1 === le2) { return 0; }
5085 // Segments are not collinear
5086 if (signedArea(le1.point, le1.otherEvent.point, le2.point) !== 0 ||
5087 signedArea(le1.point, le1.otherEvent.point, le2.otherEvent.point) !== 0) {
5089 // If they share their left endpoint use the right endpoint to sort
5090 if (equals(le1.point, le2.point)) { return le1.isBelow(le2.otherEvent.point) ? -1 : 1; }
5092 // Different left endpoint: use the left endpoint to sort
5093 if (le1.point[0] === le2.point[0]) { return le1.point[1] < le2.point[1] ? -1 : 1; }
5095 // has the line segment associated to e1 been inserted
5096 // into S after the line segment associated to e2 ?
5097 if (compareEvents(le1, le2) === 1) { return le2.isAbove(le1.point) ? -1 : 1; }
5099 // The line segment associated to e2 has been inserted
5100 // into S after the line segment associated to e1
5101 return le1.isBelow(le2.point) ? -1 : 1;
5104 if (le1.isSubject === le2.isSubject) { // same polygon
5105 var p1 = le1.point, p2 = le2.point;
5106 if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) {
5107 p1 = le1.otherEvent.point; p2 = le2.otherEvent.point;
5108 if (p1[0] === p2[0] && p1[1] === p2[1]) { return 0; }
5109 else { return le1.contourId > le2.contourId ? 1 : -1; }
5111 } else { // Segments are collinear, but belong to separate polygons
5112 return le1.isSubject ? -1 : 1;
5115 return compareEvents(le1, le2) === 1 ? 1 : -1;
5118 function subdivide(eventQueue, subject, clipping, sbbox, cbbox, operation) {
5119 var sweepLine = new SplayTree(compareSegments);
5120 var sortedEvents = [];
5122 var rightbound = Math.min(sbbox[2], cbbox[2]);
5124 var prev, next, begin;
5126 while (eventQueue.length !== 0) {
5127 var event = eventQueue.pop();
5128 sortedEvents.push(event);
5130 // optimization by bboxes for intersection and difference goes here
5131 if ((operation === INTERSECTION && event.point[0] > rightbound) ||
5132 (operation === DIFFERENCE && event.point[0] > sbbox[2])) {
5137 next = prev = sweepLine.insert(event);
5138 begin = sweepLine.minNode();
5140 if (prev !== begin) { prev = sweepLine.prev(prev); }
5141 else { prev = null; }
5143 next = sweepLine.next(next);
5145 var prevEvent = prev ? prev.key : null;
5146 var prevprevEvent = (void 0);
5147 computeFields(event, prevEvent, operation);
5149 if (possibleIntersection(event, next.key, eventQueue) === 2) {
5150 computeFields(event, prevEvent, operation);
5151 computeFields(event, next.key, operation);
5156 if (possibleIntersection(prev.key, event, eventQueue) === 2) {
5157 var prevprev = prev;
5158 if (prevprev !== begin) { prevprev = sweepLine.prev(prevprev); }
5159 else { prevprev = null; }
5161 prevprevEvent = prevprev ? prevprev.key : null;
5162 computeFields(prevEvent, prevprevEvent, operation);
5163 computeFields(event, prevEvent, operation);
5167 event = event.otherEvent;
5168 next = prev = sweepLine.find(event);
5172 if (prev !== begin) { prev = sweepLine.prev(prev); }
5173 else { prev = null; }
5175 next = sweepLine.next(next);
5176 sweepLine.remove(event);
5179 possibleIntersection(prev.key, next.key, eventQueue);
5184 return sortedEvents;
5188 * @param {Array.<SweepEvent>} sortedEvents
5189 * @return {Array.<SweepEvent>}
5191 function orderEvents(sortedEvents) {
5192 var event, i, len, tmp;
5193 var resultEvents = [];
5194 for (i = 0, len = sortedEvents.length; i < len; i++) {
5195 event = sortedEvents[i];
5196 if ((event.left && event.inResult) ||
5197 (!event.left && event.otherEvent.inResult)) {
5198 resultEvents.push(event);
5201 // Due to overlapping edges the resultEvents array can be not wholly sorted
5205 for (i = 0, len = resultEvents.length; i < len; i++) {
5206 if ((i + 1) < len &&
5207 compareEvents(resultEvents[i], resultEvents[i + 1]) === 1) {
5208 tmp = resultEvents[i];
5209 resultEvents[i] = resultEvents[i + 1];
5210 resultEvents[i + 1] = tmp;
5217 for (i = 0, len = resultEvents.length; i < len; i++) {
5218 event = resultEvents[i];
5222 // imagine, the right event is found in the beginning of the queue,
5223 // when his left counterpart is not marked yet
5224 for (i = 0, len = resultEvents.length; i < len; i++) {
5225 event = resultEvents[i];
5228 event.pos = event.otherEvent.pos;
5229 event.otherEvent.pos = tmp;
5233 return resultEvents;
5238 * @param {Number} pos
5239 * @param {Array.<SweepEvent>} resultEvents
5240 * @param {Object>} processed
5243 function nextPos(pos, resultEvents, processed, origIndex) {
5245 var newPos = pos + 1;
5246 var length = resultEvents.length;
5248 p = resultEvents[pos].point;
5250 if (newPos < length)
5251 { p1 = resultEvents[newPos].point; }
5254 // while in range and not the current one by value
5255 while (newPos < length && p1[0] === p[0] && p1[1] === p[1]) {
5256 if (!processed[newPos]) {
5261 p1 = resultEvents[newPos].point;
5266 while (processed[newPos] && newPos >= origIndex) {
5274 * @param {Array.<SweepEvent>} sortedEvents
5275 * @return {Array.<*>} polygons
5277 function connectEdges(sortedEvents, operation) {
5279 var resultEvents = orderEvents(sortedEvents);
5281 // "false"-filled array
5286 for (i = 0, len = resultEvents.length; i < len; i++) {
5287 if (processed[i]) { continue; }
5290 if (!resultEvents[i].isExteriorRing) {
5291 if (operation === DIFFERENCE && !resultEvents[i].isSubject && result.length === 0) {
5292 result.push(contour);
5293 } else if (result.length === 0) {
5294 result.push([[contour]]);
5296 result[result.length - 1].push(contour[0]);
5298 } else if (operation === DIFFERENCE && !resultEvents[i].isSubject && result.length > 1) {
5299 result[result.length - 1].push(contour[0]);
5301 result.push(contour);
5304 var ringId = result.length - 1;
5307 var initial = resultEvents[i].point;
5308 contour[0].push(initial);
5311 event = resultEvents[pos];
5312 processed[pos] = true;
5315 event.resultInOut = false;
5316 event.contourId = ringId;
5318 event.otherEvent.resultInOut = true;
5319 event.otherEvent.contourId = ringId;
5323 processed[pos] = true;
5324 contour[0].push(resultEvents[pos].point);
5325 pos = nextPos(pos, resultEvents, processed, i);
5328 pos = pos === -1 ? i : pos;
5330 event = resultEvents[pos];
5331 processed[pos] = processed[event.pos] = true;
5332 event.otherEvent.resultInOut = true;
5333 event.otherEvent.contourId = ringId;
5336 // Handle if the result is a polygon (eg not multipoly)
5337 // Commented it again, let's see what do we mean by that
5338 // if (result.length === 1) result = result[0];
5342 var tinyqueue = TinyQueue;
5343 var default_1 = TinyQueue;
5345 function TinyQueue(data, compare) {
5348 if (!(this instanceof TinyQueue)) { return new TinyQueue(data, compare); }
5350 this.data = data || [];
5351 this.length = this.data.length;
5352 this.compare = compare || defaultCompare;
5354 if (this.length > 0) {
5355 for (var i = (this.length >> 1) - 1; i >= 0; i--) { this$1._down(i); }
5359 function defaultCompare(a, b) {
5360 return a < b ? -1 : a > b ? 1 : 0;
5363 TinyQueue.prototype = {
5365 push: function (item) {
5366 this.data.push(item);
5368 this._up(this.length - 1);
5372 if (this.length === 0) { return undefined; }
5374 var top = this.data[0];
5377 if (this.length > 0) {
5378 this.data[0] = this.data[this.length];
5387 return this.data[0];
5390 _up: function (pos) {
5391 var data = this.data;
5392 var compare = this.compare;
5393 var item = data[pos];
5396 var parent = (pos - 1) >> 1;
5397 var current = data[parent];
5398 if (compare(item, current) >= 0) { break; }
5399 data[pos] = current;
5406 _down: function (pos) {
5409 var data = this.data;
5410 var compare = this.compare;
5411 var halfLength = this.length >> 1;
5412 var item = data[pos];
5414 while (pos < halfLength) {
5415 var left = (pos << 1) + 1;
5416 var right = left + 1;
5417 var best = data[left];
5419 if (right < this$1.length && compare(data[right], best) < 0) {
5423 if (compare(best, item) >= 0) { break; }
5432 tinyqueue.default = default_1;
5440 function processPolygon(contourOrHole, isSubject, depth, Q, bbox, isExteriorRing) {
5441 var i, len, s1, s2, e1, e2;
5442 for (i = 0, len = contourOrHole.length - 1; i < len; i++) {
5443 s1 = contourOrHole[i];
5444 s2 = contourOrHole[i + 1];
5445 e1 = new SweepEvent(s1, false, undefined, isSubject);
5446 e2 = new SweepEvent(s2, false, e1, isSubject);
5449 if (s1[0] === s2[0] && s1[1] === s2[1]) {
5450 continue; // skip collapsed edges, or it breaks
5453 e1.contourId = e2.contourId = depth;
5454 if (!isExteriorRing) {
5455 e1.isExteriorRing = false;
5456 e2.isExteriorRing = false;
5458 if (compareEvents(e1, e2) > 0) {
5464 var x = s1[0], y = s1[1];
5465 bbox[0] = min(bbox[0], x);
5466 bbox[1] = min(bbox[1], y);
5467 bbox[2] = max(bbox[2], x);
5468 bbox[3] = max(bbox[3], y);
5470 // Pushing it so the queue is sorted from left to right,
5471 // with object on the left having the highest priority.
5478 function fillQueue(subject, clipping, sbbox, cbbox, operation) {
5479 var eventQueue = new tinyqueue(null, compareEvents);
5480 var polygonSet, isExteriorRing, i, ii, j, jj; //, k, kk;
5482 for (i = 0, ii = subject.length; i < ii; i++) {
5483 polygonSet = subject[i];
5484 for (j = 0, jj = polygonSet.length; j < jj; j++) {
5485 isExteriorRing = j === 0;
5486 if (isExteriorRing) { contourId++; }
5487 processPolygon(polygonSet[j], true, contourId, eventQueue, sbbox, isExteriorRing);
5491 for (i = 0, ii = clipping.length; i < ii; i++) {
5492 polygonSet = clipping[i];
5493 for (j = 0, jj = polygonSet.length; j < jj; j++) {
5494 isExteriorRing = j === 0;
5495 if (operation === DIFFERENCE) { isExteriorRing = false; }
5496 if (isExteriorRing) { contourId++; }
5497 processPolygon(polygonSet[j], false, contourId, eventQueue, cbbox, isExteriorRing);
5507 function trivialOperation(subject, clipping, operation) {
5509 if (subject.length * clipping.length === 0) {
5510 if (operation === INTERSECTION) {
5512 } else if (operation === DIFFERENCE) {
5514 } else if (operation === UNION ||
5515 operation === XOR) {
5516 result = (subject.length === 0) ? clipping : subject;
5523 function compareBBoxes(subject, clipping, sbbox, cbbox, operation) {
5525 if (sbbox[0] > cbbox[2] ||
5526 cbbox[0] > sbbox[2] ||
5527 sbbox[1] > cbbox[3] ||
5528 cbbox[1] > sbbox[3]) {
5529 if (operation === INTERSECTION) {
5531 } else if (operation === DIFFERENCE) {
5533 } else if (operation === UNION ||
5534 operation === XOR) {
5535 result = subject.concat(clipping);
5542 function boolean(subject, clipping, operation) {
5543 if (typeof subject[0][0][0] === 'number') {
5544 subject = [subject];
5546 if (typeof clipping[0][0][0] === 'number') {
5547 clipping = [clipping];
5549 var trivial = trivialOperation(subject, clipping, operation);
5551 return trivial === EMPTY ? null : trivial;
5553 var sbbox = [Infinity, Infinity, -Infinity, -Infinity];
5554 var cbbox = [Infinity, Infinity, -Infinity, -Infinity];
5556 //console.time('fill queue');
5557 var eventQueue = fillQueue(subject, clipping, sbbox, cbbox, operation);
5558 //console.timeEnd('fill queue');
5560 trivial = compareBBoxes(subject, clipping, sbbox, cbbox, operation);
5562 return trivial === EMPTY ? null : trivial;
5564 //console.time('subdivide edges');
5565 var sortedEvents = subdivide(eventQueue, subject, clipping, sbbox, cbbox, operation);
5566 //console.timeEnd('subdivide edges');
5568 //console.time('connect vertices');
5569 var result = connectEdges(sortedEvents, operation);
5570 //console.timeEnd('connect vertices');
5574 function union (subject, clipping) {
5575 return boolean(subject, clipping, UNION);
5578 function diff (subject, clipping) {
5579 return boolean(subject, clipping, DIFFERENCE);
5582 function xor (subject, clipping){
5583 return boolean(subject, clipping, XOR);
5586 function intersection$1 (subject, clipping) {
5587 return boolean(subject, clipping, INTERSECTION);
5593 var operations = { UNION: UNION, DIFFERENCE: DIFFERENCE, INTERSECTION: INTERSECTION, XOR: XOR };
5595 exports.union = union;
5596 exports.diff = diff;
5598 exports.intersection = intersection$1;
5599 exports.operations = operations;
5601 Object.defineProperty(exports, '__esModule', { value: true });
5606 },{}],23:[function(require,module,exports){
5607 (function (process){
5608 // Copyright Joyent, Inc. and other Node contributors.
5610 // Permission is hereby granted, free of charge, to any person obtaining a
5611 // copy of this software and associated documentation files (the
5612 // "Software"), to deal in the Software without restriction, including
5613 // without limitation the rights to use, copy, modify, merge, publish,
5614 // distribute, sublicense, and/or sell copies of the Software, and to permit
5615 // persons to whom the Software is furnished to do so, subject to the
5616 // following conditions:
5618 // The above copyright notice and this permission notice shall be included
5619 // in all copies or substantial portions of the Software.
5621 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
5622 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5623 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
5624 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
5625 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
5626 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
5627 // USE OR OTHER DEALINGS IN THE SOFTWARE.
5629 // resolves . and .. elements in a path array with directory names there
5630 // must be no slashes, empty elements, or device names (c:\) in the array
5631 // (so also no leading and trailing slashes - it does not distinguish
5632 // relative and absolute paths)
5633 function normalizeArray(parts, allowAboveRoot) {
5634 // if the path tries to go above the root, `up` ends up > 0
5636 for (var i = parts.length - 1; i >= 0; i--) {
5637 var last = parts[i];
5640 } else if (last === '..') {
5649 // if the path is allowed to go above the root, restore leading ..s
5650 if (allowAboveRoot) {
5652 parts.unshift('..');
5659 // Split a filename into [root, dir, basename, ext], unix version
5660 // 'root' is just a slash, or nothing.
5662 /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
5663 var splitPath = function(filename) {
5664 return splitPathRe.exec(filename).slice(1);
5667 // path.resolve([from ...], to)
5669 exports.resolve = function() {
5670 var resolvedPath = '',
5671 resolvedAbsolute = false;
5673 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
5674 var path = (i >= 0) ? arguments[i] : process.cwd();
5676 // Skip empty and invalid entries
5677 if (typeof path !== 'string') {
5678 throw new TypeError('Arguments to path.resolve must be strings');
5683 resolvedPath = path + '/' + resolvedPath;
5684 resolvedAbsolute = path.charAt(0) === '/';
5687 // At this point the path should be resolved to a full absolute path, but
5688 // handle relative paths to be safe (might happen when process.cwd() fails)
5690 // Normalize the path
5691 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
5693 }), !resolvedAbsolute).join('/');
5695 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
5698 // path.normalize(path)
5700 exports.normalize = function(path) {
5701 var isAbsolute = exports.isAbsolute(path),
5702 trailingSlash = substr(path, -1) === '/';
5704 // Normalize the path
5705 path = normalizeArray(filter(path.split('/'), function(p) {
5707 }), !isAbsolute).join('/');
5709 if (!path && !isAbsolute) {
5712 if (path && trailingSlash) {
5716 return (isAbsolute ? '/' : '') + path;
5720 exports.isAbsolute = function(path) {
5721 return path.charAt(0) === '/';
5725 exports.join = function() {
5726 var paths = Array.prototype.slice.call(arguments, 0);
5727 return exports.normalize(filter(paths, function(p, index) {
5728 if (typeof p !== 'string') {
5729 throw new TypeError('Arguments to path.join must be strings');
5736 // path.relative(from, to)
5738 exports.relative = function(from, to) {
5739 from = exports.resolve(from).substr(1);
5740 to = exports.resolve(to).substr(1);
5742 function trim(arr) {
5744 for (; start < arr.length; start++) {
5745 if (arr[start] !== '') break;
5748 var end = arr.length - 1;
5749 for (; end >= 0; end--) {
5750 if (arr[end] !== '') break;
5753 if (start > end) return [];
5754 return arr.slice(start, end - start + 1);
5757 var fromParts = trim(from.split('/'));
5758 var toParts = trim(to.split('/'));
5760 var length = Math.min(fromParts.length, toParts.length);
5761 var samePartsLength = length;
5762 for (var i = 0; i < length; i++) {
5763 if (fromParts[i] !== toParts[i]) {
5764 samePartsLength = i;
5769 var outputParts = [];
5770 for (var i = samePartsLength; i < fromParts.length; i++) {
5771 outputParts.push('..');
5774 outputParts = outputParts.concat(toParts.slice(samePartsLength));
5776 return outputParts.join('/');
5780 exports.delimiter = ':';
5782 exports.dirname = function(path) {
5783 var result = splitPath(path),
5787 if (!root && !dir) {
5788 // No dirname whatsoever
5793 // It has a dirname, strip trailing slash
5794 dir = dir.substr(0, dir.length - 1);
5801 exports.basename = function(path, ext) {
5802 var f = splitPath(path)[2];
5803 // TODO: make this comparison case-insensitive on windows?
5804 if (ext && f.substr(-1 * ext.length) === ext) {
5805 f = f.substr(0, f.length - ext.length);
5811 exports.extname = function(path) {
5812 return splitPath(path)[3];
5815 function filter (xs, f) {
5816 if (xs.filter) return xs.filter(f);
5818 for (var i = 0; i < xs.length; i++) {
5819 if (f(xs[i], i, xs)) res.push(xs[i]);
5824 // String.prototype.substr - negative index don't work in IE8
5825 var substr = 'ab'.substr(-1) === 'b'
5826 ? function (str, start, len) { return str.substr(start, len) }
5827 : function (str, start, len) {
5828 if (start < 0) start = str.length + start;
5829 return str.substr(start, len);
5833 }).call(this,require('_process'))
5835 },{"_process":6}],24:[function(require,module,exports){
5838 module.exports = Pbf;
5840 var ieee754 = require('ieee754');
5843 this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
5846 this.length = this.buf.length;
5849 Pbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum
5850 Pbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64
5851 Pbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields
5852 Pbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32
5854 var SHIFT_LEFT_32 = (1 << 16) * (1 << 16),
5855 SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
5859 destroy: function() {
5863 // === READING =================================================================
5865 readFields: function(readField, result, end) {
5866 end = end || this.length;
5868 while (this.pos < end) {
5869 var val = this.readVarint(),
5871 startPos = this.pos;
5873 this.type = val & 0x7;
5874 readField(tag, result, this);
5876 if (this.pos === startPos) this.skip(val);
5881 readMessage: function(readField, result) {
5882 return this.readFields(readField, result, this.readVarint() + this.pos);
5885 readFixed32: function() {
5886 var val = readUInt32(this.buf, this.pos);
5891 readSFixed32: function() {
5892 var val = readInt32(this.buf, this.pos);
5897 // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
5899 readFixed64: function() {
5900 var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
5905 readSFixed64: function() {
5906 var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
5911 readFloat: function() {
5912 var val = ieee754.read(this.buf, this.pos, true, 23, 4);
5917 readDouble: function() {
5918 var val = ieee754.read(this.buf, this.pos, true, 52, 8);
5923 readVarint: function(isSigned) {
5927 b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;
5928 b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;
5929 b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;
5930 b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;
5931 b = buf[this.pos]; val |= (b & 0x0f) << 28;
5933 return readVarintRemainder(val, isSigned, this);
5936 readVarint64: function() { // for compatibility with v2.0.1
5937 return this.readVarint(true);
5940 readSVarint: function() {
5941 var num = this.readVarint();
5942 return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding
5945 readBoolean: function() {
5946 return Boolean(this.readVarint());
5949 readString: function() {
5950 var end = this.readVarint() + this.pos,
5951 str = readUtf8(this.buf, this.pos, end);
5956 readBytes: function() {
5957 var end = this.readVarint() + this.pos,
5958 buffer = this.buf.subarray(this.pos, end);
5963 // verbose for performance reasons; doesn't affect gzipped size
5965 readPackedVarint: function(arr, isSigned) {
5966 var end = readPackedEnd(this);
5968 while (this.pos < end) arr.push(this.readVarint(isSigned));
5971 readPackedSVarint: function(arr) {
5972 var end = readPackedEnd(this);
5974 while (this.pos < end) arr.push(this.readSVarint());
5977 readPackedBoolean: function(arr) {
5978 var end = readPackedEnd(this);
5980 while (this.pos < end) arr.push(this.readBoolean());
5983 readPackedFloat: function(arr) {
5984 var end = readPackedEnd(this);
5986 while (this.pos < end) arr.push(this.readFloat());
5989 readPackedDouble: function(arr) {
5990 var end = readPackedEnd(this);
5992 while (this.pos < end) arr.push(this.readDouble());
5995 readPackedFixed32: function(arr) {
5996 var end = readPackedEnd(this);
5998 while (this.pos < end) arr.push(this.readFixed32());
6001 readPackedSFixed32: function(arr) {
6002 var end = readPackedEnd(this);
6004 while (this.pos < end) arr.push(this.readSFixed32());
6007 readPackedFixed64: function(arr) {
6008 var end = readPackedEnd(this);
6010 while (this.pos < end) arr.push(this.readFixed64());
6013 readPackedSFixed64: function(arr) {
6014 var end = readPackedEnd(this);
6016 while (this.pos < end) arr.push(this.readSFixed64());
6020 skip: function(val) {
6021 var type = val & 0x7;
6022 if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}
6023 else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;
6024 else if (type === Pbf.Fixed32) this.pos += 4;
6025 else if (type === Pbf.Fixed64) this.pos += 8;
6026 else throw new Error('Unimplemented type: ' + type);
6029 // === WRITING =================================================================
6031 writeTag: function(tag, type) {
6032 this.writeVarint((tag << 3) | type);
6035 realloc: function(min) {
6036 var length = this.length || 16;
6038 while (length < this.pos + min) length *= 2;
6040 if (length !== this.length) {
6041 var buf = new Uint8Array(length);
6044 this.length = length;
6048 finish: function() {
6049 this.length = this.pos;
6051 return this.buf.subarray(0, this.length);
6054 writeFixed32: function(val) {
6056 writeInt32(this.buf, val, this.pos);
6060 writeSFixed32: function(val) {
6062 writeInt32(this.buf, val, this.pos);
6066 writeFixed64: function(val) {
6068 writeInt32(this.buf, val & -1, this.pos);
6069 writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
6073 writeSFixed64: function(val) {
6075 writeInt32(this.buf, val & -1, this.pos);
6076 writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
6080 writeVarint: function(val) {
6083 if (val > 0xfffffff || val < 0) {
6084 writeBigVarint(val, this);
6090 this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
6091 this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
6092 this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
6093 this.buf[this.pos++] = (val >>> 7) & 0x7f;
6096 writeSVarint: function(val) {
6097 this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
6100 writeBoolean: function(val) {
6101 this.writeVarint(Boolean(val));
6104 writeString: function(str) {
6106 this.realloc(str.length * 4);
6108 this.pos++; // reserve 1 byte for short string length
6110 var startPos = this.pos;
6111 // write the string directly to the buffer and see how much was written
6112 this.pos = writeUtf8(this.buf, str, this.pos);
6113 var len = this.pos - startPos;
6115 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
6117 // finally, write the message length in the reserved place and restore the position
6118 this.pos = startPos - 1;
6119 this.writeVarint(len);
6123 writeFloat: function(val) {
6125 ieee754.write(this.buf, val, this.pos, true, 23, 4);
6129 writeDouble: function(val) {
6131 ieee754.write(this.buf, val, this.pos, true, 52, 8);
6135 writeBytes: function(buffer) {
6136 var len = buffer.length;
6137 this.writeVarint(len);
6139 for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];
6142 writeRawMessage: function(fn, obj) {
6143 this.pos++; // reserve 1 byte for short message length
6145 // write the message directly to the buffer and see how much was written
6146 var startPos = this.pos;
6148 var len = this.pos - startPos;
6150 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
6152 // finally, write the message length in the reserved place and restore the position
6153 this.pos = startPos - 1;
6154 this.writeVarint(len);
6158 writeMessage: function(tag, fn, obj) {
6159 this.writeTag(tag, Pbf.Bytes);
6160 this.writeRawMessage(fn, obj);
6163 writePackedVarint: function(tag, arr) { this.writeMessage(tag, writePackedVarint, arr); },
6164 writePackedSVarint: function(tag, arr) { this.writeMessage(tag, writePackedSVarint, arr); },
6165 writePackedBoolean: function(tag, arr) { this.writeMessage(tag, writePackedBoolean, arr); },
6166 writePackedFloat: function(tag, arr) { this.writeMessage(tag, writePackedFloat, arr); },
6167 writePackedDouble: function(tag, arr) { this.writeMessage(tag, writePackedDouble, arr); },
6168 writePackedFixed32: function(tag, arr) { this.writeMessage(tag, writePackedFixed32, arr); },
6169 writePackedSFixed32: function(tag, arr) { this.writeMessage(tag, writePackedSFixed32, arr); },
6170 writePackedFixed64: function(tag, arr) { this.writeMessage(tag, writePackedFixed64, arr); },
6171 writePackedSFixed64: function(tag, arr) { this.writeMessage(tag, writePackedSFixed64, arr); },
6173 writeBytesField: function(tag, buffer) {
6174 this.writeTag(tag, Pbf.Bytes);
6175 this.writeBytes(buffer);
6177 writeFixed32Field: function(tag, val) {
6178 this.writeTag(tag, Pbf.Fixed32);
6179 this.writeFixed32(val);
6181 writeSFixed32Field: function(tag, val) {
6182 this.writeTag(tag, Pbf.Fixed32);
6183 this.writeSFixed32(val);
6185 writeFixed64Field: function(tag, val) {
6186 this.writeTag(tag, Pbf.Fixed64);
6187 this.writeFixed64(val);
6189 writeSFixed64Field: function(tag, val) {
6190 this.writeTag(tag, Pbf.Fixed64);
6191 this.writeSFixed64(val);
6193 writeVarintField: function(tag, val) {
6194 this.writeTag(tag, Pbf.Varint);
6195 this.writeVarint(val);
6197 writeSVarintField: function(tag, val) {
6198 this.writeTag(tag, Pbf.Varint);
6199 this.writeSVarint(val);
6201 writeStringField: function(tag, str) {
6202 this.writeTag(tag, Pbf.Bytes);
6203 this.writeString(str);
6205 writeFloatField: function(tag, val) {
6206 this.writeTag(tag, Pbf.Fixed32);
6207 this.writeFloat(val);
6209 writeDoubleField: function(tag, val) {
6210 this.writeTag(tag, Pbf.Fixed64);
6211 this.writeDouble(val);
6213 writeBooleanField: function(tag, val) {
6214 this.writeVarintField(tag, Boolean(val));
6218 function readVarintRemainder(l, s, p) {
6222 b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);
6223 b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);
6224 b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);
6225 b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);
6226 b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);
6227 b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);
6229 throw new Error('Expected varint not more than 10 bytes');
6232 function readPackedEnd(pbf) {
6233 return pbf.type === Pbf.Bytes ?
6234 pbf.readVarint() + pbf.pos : pbf.pos + 1;
6237 function toNum(low, high, isSigned) {
6239 return high * 0x100000000 + (low >>> 0);
6242 return ((high >>> 0) * 0x100000000) + (low >>> 0);
6245 function writeBigVarint(val, pbf) {
6249 low = (val % 0x100000000) | 0;
6250 high = (val / 0x100000000) | 0;
6252 low = ~(-val % 0x100000000);
6253 high = ~(-val / 0x100000000);
6255 if (low ^ 0xffffffff) {
6256 low = (low + 1) | 0;
6259 high = (high + 1) | 0;
6263 if (val >= 0x10000000000000000 || val < -0x10000000000000000) {
6264 throw new Error('Given varint doesn\'t fit into 10 bytes');
6269 writeBigVarintLow(low, high, pbf);
6270 writeBigVarintHigh(high, pbf);
6273 function writeBigVarintLow(low, high, pbf) {
6274 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
6275 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
6276 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
6277 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
6278 pbf.buf[pbf.pos] = low & 0x7f;
6281 function writeBigVarintHigh(high, pbf) {
6282 var lsb = (high & 0x07) << 4;
6284 pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;
6285 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
6286 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
6287 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
6288 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
6289 pbf.buf[pbf.pos++] = high & 0x7f;
6292 function makeRoomForExtraLength(startPos, len, pbf) {
6295 len <= 0x1fffff ? 2 :
6296 len <= 0xfffffff ? 3 : Math.ceil(Math.log(len) / (Math.LN2 * 7));
6298 // if 1 byte isn't enough for encoding message length, shift the data to the right
6299 pbf.realloc(extraLen);
6300 for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];
6303 function writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }
6304 function writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }
6305 function writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }
6306 function writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }
6307 function writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }
6308 function writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }
6309 function writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }
6310 function writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }
6311 function writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }
6313 // Buffer code below from https://github.com/feross/buffer, MIT-licensed
6315 function readUInt32(buf, pos) {
6316 return ((buf[pos]) |
6317 (buf[pos + 1] << 8) |
6318 (buf[pos + 2] << 16)) +
6319 (buf[pos + 3] * 0x1000000);
6322 function writeInt32(buf, val, pos) {
6324 buf[pos + 1] = (val >>> 8);
6325 buf[pos + 2] = (val >>> 16);
6326 buf[pos + 3] = (val >>> 24);
6329 function readInt32(buf, pos) {
6330 return ((buf[pos]) |
6331 (buf[pos + 1] << 8) |
6332 (buf[pos + 2] << 16)) +
6333 (buf[pos + 3] << 24);
6336 function readUtf8(buf, pos, end) {
6342 var c = null; // codepoint
6343 var bytesPerSequence =
6348 if (i + bytesPerSequence > end) break;
6352 if (bytesPerSequence === 1) {
6356 } else if (bytesPerSequence === 2) {
6358 if ((b1 & 0xC0) === 0x80) {
6359 c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);
6364 } else if (bytesPerSequence === 3) {
6367 if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {
6368 c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);
6369 if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {
6373 } else if (bytesPerSequence === 4) {
6377 if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
6378 c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);
6379 if (c <= 0xFFFF || c >= 0x110000) {
6387 bytesPerSequence = 1;
6389 } else if (c > 0xFFFF) {
6391 str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);
6392 c = 0xDC00 | c & 0x3FF;
6395 str += String.fromCharCode(c);
6396 i += bytesPerSequence;
6402 function writeUtf8(buf, str, pos) {
6403 for (var i = 0, c, lead; i < str.length; i++) {
6404 c = str.charCodeAt(i); // code point
6406 if (c > 0xD7FF && c < 0xE000) {
6415 c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;
6419 if (c > 0xDBFF || (i + 1 === str.length)) {
6439 buf[pos++] = c >> 0x6 | 0xC0;
6442 buf[pos++] = c >> 0xC | 0xE0;
6444 buf[pos++] = c >> 0x12 | 0xF0;
6445 buf[pos++] = c >> 0xC & 0x3F | 0x80;
6447 buf[pos++] = c >> 0x6 & 0x3F | 0x80;
6449 buf[pos++] = c & 0x3F | 0x80;
6455 },{"ieee754":17}],25:[function(require,module,exports){
6456 (function (global, factory) {
6457 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
6458 typeof define === 'function' && define.amd ? define(factory) :
6459 (global.quickselect = factory());
6460 }(this, (function () { 'use strict';
6462 function quickselect(arr, k, left, right, compare) {
6463 quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
6466 function quickselectStep(arr, k, left, right, compare) {
6468 while (right > left) {
6469 if (right - left > 600) {
6470 var n = right - left + 1;
6471 var m = k - left + 1;
6472 var z = Math.log(n);
6473 var s = 0.5 * Math.exp(2 * z / 3);
6474 var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
6475 var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
6476 var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
6477 quickselectStep(arr, k, newLeft, newRight, compare);
6485 if (compare(arr[right], t) > 0) swap(arr, left, right);
6491 while (compare(arr[i], t) < 0) i++;
6492 while (compare(arr[j], t) > 0) j--;
6495 if (compare(arr[left], t) === 0) swap(arr, left, j);
6498 swap(arr, j, right);
6501 if (j <= k) left = j + 1;
6502 if (k <= j) right = j - 1;
6506 function swap(arr, i, j) {
6512 function defaultCompare(a, b) {
6513 return a < b ? -1 : a > b ? 1 : 0;
6520 },{}],26:[function(require,module,exports){
6523 module.exports = rbush;
6524 module.exports.default = rbush;
6526 var quickselect = require('quickselect');
6528 function rbush(maxEntries, format) {
6529 if (!(this instanceof rbush)) return new rbush(maxEntries, format);
6531 // max entries in a node is 9 by default; min node fill is 40% for best performance
6532 this._maxEntries = Math.max(4, maxEntries || 9);
6533 this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
6536 this._initFormat(format);
6545 return this._all(this.data, []);
6548 search: function (bbox) {
6550 var node = this.data,
6552 toBBox = this.toBBox;
6554 if (!intersects(bbox, node)) return result;
6556 var nodesToSearch = [],
6557 i, len, child, childBBox;
6560 for (i = 0, len = node.children.length; i < len; i++) {
6562 child = node.children[i];
6563 childBBox = node.leaf ? toBBox(child) : child;
6565 if (intersects(bbox, childBBox)) {
6566 if (node.leaf) result.push(child);
6567 else if (contains(bbox, childBBox)) this._all(child, result);
6568 else nodesToSearch.push(child);
6571 node = nodesToSearch.pop();
6577 collides: function (bbox) {
6579 var node = this.data,
6580 toBBox = this.toBBox;
6582 if (!intersects(bbox, node)) return false;
6584 var nodesToSearch = [],
6585 i, len, child, childBBox;
6588 for (i = 0, len = node.children.length; i < len; i++) {
6590 child = node.children[i];
6591 childBBox = node.leaf ? toBBox(child) : child;
6593 if (intersects(bbox, childBBox)) {
6594 if (node.leaf || contains(bbox, childBBox)) return true;
6595 nodesToSearch.push(child);
6598 node = nodesToSearch.pop();
6604 load: function (data) {
6605 if (!(data && data.length)) return this;
6607 if (data.length < this._minEntries) {
6608 for (var i = 0, len = data.length; i < len; i++) {
6609 this.insert(data[i]);
6614 // recursively build the tree with the given data from scratch using OMT algorithm
6615 var node = this._build(data.slice(), 0, data.length - 1, 0);
6617 if (!this.data.children.length) {
6618 // save as is if tree is empty
6621 } else if (this.data.height === node.height) {
6622 // split root if trees have the same height
6623 this._splitRoot(this.data, node);
6626 if (this.data.height < node.height) {
6627 // swap trees if inserted one is bigger
6628 var tmpNode = this.data;
6633 // insert the small tree into the large tree at appropriate level
6634 this._insert(node, this.data.height - node.height - 1, true);
6640 insert: function (item) {
6641 if (item) this._insert(item, this.data.height - 1);
6645 clear: function () {
6646 this.data = createNode([]);
6650 remove: function (item, equalsFn) {
6651 if (!item) return this;
6653 var node = this.data,
6654 bbox = this.toBBox(item),
6657 i, parent, index, goingUp;
6659 // depth-first iterative tree traversal
6660 while (node || path.length) {
6662 if (!node) { // go up
6664 parent = path[path.length - 1];
6669 if (node.leaf) { // check current node
6670 index = findItem(item, node.children, equalsFn);
6673 // item found, remove the item and condense tree upwards
6674 node.children.splice(index, 1);
6676 this._condense(path);
6681 if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
6686 node = node.children[0];
6688 } else if (parent) { // go right
6690 node = parent.children[i];
6693 } else node = null; // nothing found
6699 toBBox: function (item) { return item; },
6701 compareMinX: compareNodeMinX,
6702 compareMinY: compareNodeMinY,
6704 toJSON: function () { return this.data; },
6706 fromJSON: function (data) {
6711 _all: function (node, result) {
6712 var nodesToSearch = [];
6714 if (node.leaf) result.push.apply(result, node.children);
6715 else nodesToSearch.push.apply(nodesToSearch, node.children);
6717 node = nodesToSearch.pop();
6722 _build: function (items, left, right, height) {
6724 var N = right - left + 1,
6725 M = this._maxEntries,
6729 // reached leaf level; return leaf
6730 node = createNode(items.slice(left, right + 1));
6731 calcBBox(node, this.toBBox);
6736 // target height of the bulk-loaded tree
6737 height = Math.ceil(Math.log(N) / Math.log(M));
6739 // target number of root entries to maximize storage utilization
6740 M = Math.ceil(N / Math.pow(M, height - 1));
6743 node = createNode([]);
6745 node.height = height;
6747 // split the items into M mostly square tiles
6749 var N2 = Math.ceil(N / M),
6750 N1 = N2 * Math.ceil(Math.sqrt(M)),
6751 i, j, right2, right3;
6753 multiSelect(items, left, right, N1, this.compareMinX);
6755 for (i = left; i <= right; i += N1) {
6757 right2 = Math.min(i + N1 - 1, right);
6759 multiSelect(items, i, right2, N2, this.compareMinY);
6761 for (j = i; j <= right2; j += N2) {
6763 right3 = Math.min(j + N2 - 1, right2);
6765 // pack each entry recursively
6766 node.children.push(this._build(items, j, right3, height - 1));
6770 calcBBox(node, this.toBBox);
6775 _chooseSubtree: function (bbox, node, level, path) {
6777 var i, len, child, targetNode, area, enlargement, minArea, minEnlargement;
6782 if (node.leaf || path.length - 1 === level) break;
6784 minArea = minEnlargement = Infinity;
6786 for (i = 0, len = node.children.length; i < len; i++) {
6787 child = node.children[i];
6788 area = bboxArea(child);
6789 enlargement = enlargedArea(bbox, child) - area;
6791 // choose entry with the least area enlargement
6792 if (enlargement < minEnlargement) {
6793 minEnlargement = enlargement;
6794 minArea = area < minArea ? area : minArea;
6797 } else if (enlargement === minEnlargement) {
6798 // otherwise choose one with the smallest area
6799 if (area < minArea) {
6806 node = targetNode || node.children[0];
6812 _insert: function (item, level, isNode) {
6814 var toBBox = this.toBBox,
6815 bbox = isNode ? item : toBBox(item),
6818 // find the best node for accommodating the item, saving all nodes along the path too
6819 var node = this._chooseSubtree(bbox, this.data, level, insertPath);
6821 // put the item into the node
6822 node.children.push(item);
6825 // split on node overflow; propagate upwards if necessary
6826 while (level >= 0) {
6827 if (insertPath[level].children.length > this._maxEntries) {
6828 this._split(insertPath, level);
6833 // adjust bboxes along the insertion path
6834 this._adjustParentBBoxes(bbox, insertPath, level);
6837 // split overflowed node into two
6838 _split: function (insertPath, level) {
6840 var node = insertPath[level],
6841 M = node.children.length,
6842 m = this._minEntries;
6844 this._chooseSplitAxis(node, m, M);
6846 var splitIndex = this._chooseSplitIndex(node, m, M);
6848 var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
6849 newNode.height = node.height;
6850 newNode.leaf = node.leaf;
6852 calcBBox(node, this.toBBox);
6853 calcBBox(newNode, this.toBBox);
6855 if (level) insertPath[level - 1].children.push(newNode);
6856 else this._splitRoot(node, newNode);
6859 _splitRoot: function (node, newNode) {
6861 this.data = createNode([node, newNode]);
6862 this.data.height = node.height + 1;
6863 this.data.leaf = false;
6864 calcBBox(this.data, this.toBBox);
6867 _chooseSplitIndex: function (node, m, M) {
6869 var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index;
6871 minOverlap = minArea = Infinity;
6873 for (i = m; i <= M - m; i++) {
6874 bbox1 = distBBox(node, 0, i, this.toBBox);
6875 bbox2 = distBBox(node, i, M, this.toBBox);
6877 overlap = intersectionArea(bbox1, bbox2);
6878 area = bboxArea(bbox1) + bboxArea(bbox2);
6880 // choose distribution with minimum overlap
6881 if (overlap < minOverlap) {
6882 minOverlap = overlap;
6885 minArea = area < minArea ? area : minArea;
6887 } else if (overlap === minOverlap) {
6888 // otherwise choose distribution with minimum area
6889 if (area < minArea) {
6899 // sorts node children by the best axis for split
6900 _chooseSplitAxis: function (node, m, M) {
6902 var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX,
6903 compareMinY = node.leaf ? this.compareMinY : compareNodeMinY,
6904 xMargin = this._allDistMargin(node, m, M, compareMinX),
6905 yMargin = this._allDistMargin(node, m, M, compareMinY);
6907 // if total distributions margin value is minimal for x, sort by minX,
6908 // otherwise it's already sorted by minY
6909 if (xMargin < yMargin) node.children.sort(compareMinX);
6912 // total margin of all possible split distributions where each node is at least m full
6913 _allDistMargin: function (node, m, M, compare) {
6915 node.children.sort(compare);
6917 var toBBox = this.toBBox,
6918 leftBBox = distBBox(node, 0, m, toBBox),
6919 rightBBox = distBBox(node, M - m, M, toBBox),
6920 margin = bboxMargin(leftBBox) + bboxMargin(rightBBox),
6923 for (i = m; i < M - m; i++) {
6924 child = node.children[i];
6925 extend(leftBBox, node.leaf ? toBBox(child) : child);
6926 margin += bboxMargin(leftBBox);
6929 for (i = M - m - 1; i >= m; i--) {
6930 child = node.children[i];
6931 extend(rightBBox, node.leaf ? toBBox(child) : child);
6932 margin += bboxMargin(rightBBox);
6938 _adjustParentBBoxes: function (bbox, path, level) {
6939 // adjust bboxes along the given tree path
6940 for (var i = level; i >= 0; i--) {
6941 extend(path[i], bbox);
6945 _condense: function (path) {
6946 // go through the path, removing empty nodes and updating bboxes
6947 for (var i = path.length - 1, siblings; i >= 0; i--) {
6948 if (path[i].children.length === 0) {
6950 siblings = path[i - 1].children;
6951 siblings.splice(siblings.indexOf(path[i]), 1);
6953 } else this.clear();
6955 } else calcBBox(path[i], this.toBBox);
6959 _initFormat: function (format) {
6960 // data format (minX, minY, maxX, maxY accessors)
6962 // uses eval-type function compilation instead of just accepting a toBBox function
6963 // because the algorithms are very sensitive to sorting functions performance,
6964 // so they should be dead simple and without inner calls
6966 var compareArr = ['return a', ' - b', ';'];
6968 this.compareMinX = new Function('a', 'b', compareArr.join(format[0]));
6969 this.compareMinY = new Function('a', 'b', compareArr.join(format[1]));
6971 this.toBBox = new Function('a',
6972 'return {minX: a' + format[0] +
6973 ', minY: a' + format[1] +
6974 ', maxX: a' + format[2] +
6975 ', maxY: a' + format[3] + '};');
6979 function findItem(item, items, equalsFn) {
6980 if (!equalsFn) return items.indexOf(item);
6982 for (var i = 0; i < items.length; i++) {
6983 if (equalsFn(item, items[i])) return i;
6988 // calculate node's bbox from bboxes of its children
6989 function calcBBox(node, toBBox) {
6990 distBBox(node, 0, node.children.length, toBBox, node);
6993 // min bounding rectangle of node children from k to p-1
6994 function distBBox(node, k, p, toBBox, destNode) {
6995 if (!destNode) destNode = createNode(null);
6996 destNode.minX = Infinity;
6997 destNode.minY = Infinity;
6998 destNode.maxX = -Infinity;
6999 destNode.maxY = -Infinity;
7001 for (var i = k, child; i < p; i++) {
7002 child = node.children[i];
7003 extend(destNode, node.leaf ? toBBox(child) : child);
7009 function extend(a, b) {
7010 a.minX = Math.min(a.minX, b.minX);
7011 a.minY = Math.min(a.minY, b.minY);
7012 a.maxX = Math.max(a.maxX, b.maxX);
7013 a.maxY = Math.max(a.maxY, b.maxY);
7017 function compareNodeMinX(a, b) { return a.minX - b.minX; }
7018 function compareNodeMinY(a, b) { return a.minY - b.minY; }
7020 function bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }
7021 function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }
7023 function enlargedArea(a, b) {
7024 return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *
7025 (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
7028 function intersectionArea(a, b) {
7029 var minX = Math.max(a.minX, b.minX),
7030 minY = Math.max(a.minY, b.minY),
7031 maxX = Math.min(a.maxX, b.maxX),
7032 maxY = Math.min(a.maxY, b.maxY);
7034 return Math.max(0, maxX - minX) *
7035 Math.max(0, maxY - minY);
7038 function contains(a, b) {
7039 return a.minX <= b.minX &&
7045 function intersects(a, b) {
7046 return b.minX <= a.maxX &&
7052 function createNode(children) {
7064 // sort an array so that items come in groups of n unsorted items, with groups sorted between each other;
7065 // combines selection algorithm with binary divide & conquer approach
7067 function multiSelect(arr, left, right, n, compare) {
7068 var stack = [left, right],
7071 while (stack.length) {
7072 right = stack.pop();
7075 if (right - left <= n) continue;
7077 mid = left + Math.ceil((right - left) / n / 2) * n;
7078 quickselect(arr, mid, left, right, compare);
7080 stack.push(left, mid, mid, right);
7084 },{"quickselect":25}],27:[function(require,module,exports){
7086 Object.defineProperty(exports, "__esModule", { value: true });
7087 var Observable_1 = require("./internal/Observable");
7088 exports.Observable = Observable_1.Observable;
7089 var ConnectableObservable_1 = require("./internal/observable/ConnectableObservable");
7090 exports.ConnectableObservable = ConnectableObservable_1.ConnectableObservable;
7091 var groupBy_1 = require("./internal/operators/groupBy");
7092 exports.GroupedObservable = groupBy_1.GroupedObservable;
7093 var observable_1 = require("./internal/symbol/observable");
7094 exports.observable = observable_1.observable;
7095 var Subject_1 = require("./internal/Subject");
7096 exports.Subject = Subject_1.Subject;
7097 var BehaviorSubject_1 = require("./internal/BehaviorSubject");
7098 exports.BehaviorSubject = BehaviorSubject_1.BehaviorSubject;
7099 var ReplaySubject_1 = require("./internal/ReplaySubject");
7100 exports.ReplaySubject = ReplaySubject_1.ReplaySubject;
7101 var AsyncSubject_1 = require("./internal/AsyncSubject");
7102 exports.AsyncSubject = AsyncSubject_1.AsyncSubject;
7103 var asap_1 = require("./internal/scheduler/asap");
7104 exports.asapScheduler = asap_1.asap;
7105 var async_1 = require("./internal/scheduler/async");
7106 exports.asyncScheduler = async_1.async;
7107 var queue_1 = require("./internal/scheduler/queue");
7108 exports.queueScheduler = queue_1.queue;
7109 var animationFrame_1 = require("./internal/scheduler/animationFrame");
7110 exports.animationFrameScheduler = animationFrame_1.animationFrame;
7111 var VirtualTimeScheduler_1 = require("./internal/scheduler/VirtualTimeScheduler");
7112 exports.VirtualTimeScheduler = VirtualTimeScheduler_1.VirtualTimeScheduler;
7113 exports.VirtualAction = VirtualTimeScheduler_1.VirtualAction;
7114 var Scheduler_1 = require("./internal/Scheduler");
7115 exports.Scheduler = Scheduler_1.Scheduler;
7116 var Subscription_1 = require("./internal/Subscription");
7117 exports.Subscription = Subscription_1.Subscription;
7118 var Subscriber_1 = require("./internal/Subscriber");
7119 exports.Subscriber = Subscriber_1.Subscriber;
7120 var Notification_1 = require("./internal/Notification");
7121 exports.Notification = Notification_1.Notification;
7122 var pipe_1 = require("./internal/util/pipe");
7123 exports.pipe = pipe_1.pipe;
7124 var noop_1 = require("./internal/util/noop");
7125 exports.noop = noop_1.noop;
7126 var identity_1 = require("./internal/util/identity");
7127 exports.identity = identity_1.identity;
7128 var isObservable_1 = require("./internal/util/isObservable");
7129 exports.isObservable = isObservable_1.isObservable;
7130 var ArgumentOutOfRangeError_1 = require("./internal/util/ArgumentOutOfRangeError");
7131 exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
7132 var EmptyError_1 = require("./internal/util/EmptyError");
7133 exports.EmptyError = EmptyError_1.EmptyError;
7134 var ObjectUnsubscribedError_1 = require("./internal/util/ObjectUnsubscribedError");
7135 exports.ObjectUnsubscribedError = ObjectUnsubscribedError_1.ObjectUnsubscribedError;
7136 var UnsubscriptionError_1 = require("./internal/util/UnsubscriptionError");
7137 exports.UnsubscriptionError = UnsubscriptionError_1.UnsubscriptionError;
7138 var TimeoutError_1 = require("./internal/util/TimeoutError");
7139 exports.TimeoutError = TimeoutError_1.TimeoutError;
7140 var bindCallback_1 = require("./internal/observable/bindCallback");
7141 exports.bindCallback = bindCallback_1.bindCallback;
7142 var bindNodeCallback_1 = require("./internal/observable/bindNodeCallback");
7143 exports.bindNodeCallback = bindNodeCallback_1.bindNodeCallback;
7144 var combineLatest_1 = require("./internal/observable/combineLatest");
7145 exports.combineLatest = combineLatest_1.combineLatest;
7146 var concat_1 = require("./internal/observable/concat");
7147 exports.concat = concat_1.concat;
7148 var defer_1 = require("./internal/observable/defer");
7149 exports.defer = defer_1.defer;
7150 var empty_1 = require("./internal/observable/empty");
7151 exports.empty = empty_1.empty;
7152 var forkJoin_1 = require("./internal/observable/forkJoin");
7153 exports.forkJoin = forkJoin_1.forkJoin;
7154 var from_1 = require("./internal/observable/from");
7155 exports.from = from_1.from;
7156 var fromEvent_1 = require("./internal/observable/fromEvent");
7157 exports.fromEvent = fromEvent_1.fromEvent;
7158 var fromEventPattern_1 = require("./internal/observable/fromEventPattern");
7159 exports.fromEventPattern = fromEventPattern_1.fromEventPattern;
7160 var generate_1 = require("./internal/observable/generate");
7161 exports.generate = generate_1.generate;
7162 var iif_1 = require("./internal/observable/iif");
7163 exports.iif = iif_1.iif;
7164 var interval_1 = require("./internal/observable/interval");
7165 exports.interval = interval_1.interval;
7166 var merge_1 = require("./internal/observable/merge");
7167 exports.merge = merge_1.merge;
7168 var never_1 = require("./internal/observable/never");
7169 exports.never = never_1.never;
7170 var of_1 = require("./internal/observable/of");
7171 exports.of = of_1.of;
7172 var onErrorResumeNext_1 = require("./internal/observable/onErrorResumeNext");
7173 exports.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext;
7174 var pairs_1 = require("./internal/observable/pairs");
7175 exports.pairs = pairs_1.pairs;
7176 var race_1 = require("./internal/observable/race");
7177 exports.race = race_1.race;
7178 var range_1 = require("./internal/observable/range");
7179 exports.range = range_1.range;
7180 var throwError_1 = require("./internal/observable/throwError");
7181 exports.throwError = throwError_1.throwError;
7182 var timer_1 = require("./internal/observable/timer");
7183 exports.timer = timer_1.timer;
7184 var using_1 = require("./internal/observable/using");
7185 exports.using = using_1.using;
7186 var zip_1 = require("./internal/observable/zip");
7187 exports.zip = zip_1.zip;
7188 var empty_2 = require("./internal/observable/empty");
7189 exports.EMPTY = empty_2.EMPTY;
7190 var never_2 = require("./internal/observable/never");
7191 exports.NEVER = never_2.NEVER;
7192 var config_1 = require("./internal/config");
7193 exports.config = config_1.config;
7195 },{"./internal/AsyncSubject":28,"./internal/BehaviorSubject":29,"./internal/Notification":31,"./internal/Observable":32,"./internal/ReplaySubject":35,"./internal/Scheduler":36,"./internal/Subject":37,"./internal/Subscriber":39,"./internal/Subscription":40,"./internal/config":41,"./internal/observable/ConnectableObservable":42,"./internal/observable/bindCallback":44,"./internal/observable/bindNodeCallback":45,"./internal/observable/combineLatest":46,"./internal/observable/concat":47,"./internal/observable/defer":48,"./internal/observable/empty":49,"./internal/observable/forkJoin":50,"./internal/observable/from":51,"./internal/observable/fromEvent":53,"./internal/observable/fromEventPattern":54,"./internal/observable/generate":58,"./internal/observable/iif":59,"./internal/observable/interval":60,"./internal/observable/merge":61,"./internal/observable/never":62,"./internal/observable/of":63,"./internal/observable/onErrorResumeNext":64,"./internal/observable/pairs":65,"./internal/observable/race":66,"./internal/observable/range":67,"./internal/observable/throwError":69,"./internal/observable/timer":70,"./internal/observable/using":71,"./internal/observable/zip":72,"./internal/operators/groupBy":108,"./internal/scheduler/VirtualTimeScheduler":185,"./internal/scheduler/animationFrame":186,"./internal/scheduler/asap":187,"./internal/scheduler/async":188,"./internal/scheduler/queue":189,"./internal/symbol/observable":191,"./internal/util/ArgumentOutOfRangeError":193,"./internal/util/EmptyError":194,"./internal/util/ObjectUnsubscribedError":196,"./internal/util/TimeoutError":197,"./internal/util/UnsubscriptionError":198,"./internal/util/identity":202,"./internal/util/isObservable":211,"./internal/util/noop":214,"./internal/util/pipe":216}],28:[function(require,module,exports){
7197 var __extends = (this && this.__extends) || (function () {
7198 var extendStatics = function (d, b) {
7199 extendStatics = Object.setPrototypeOf ||
7200 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7201 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7202 return extendStatics(d, b);
7204 return function (d, b) {
7205 extendStatics(d, b);
7206 function __() { this.constructor = d; }
7207 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7210 Object.defineProperty(exports, "__esModule", { value: true });
7211 var Subject_1 = require("./Subject");
7212 var Subscription_1 = require("./Subscription");
7213 var AsyncSubject = (function (_super) {
7214 __extends(AsyncSubject, _super);
7215 function AsyncSubject() {
7216 var _this = _super !== null && _super.apply(this, arguments) || this;
7218 _this.hasNext = false;
7219 _this.hasCompleted = false;
7222 AsyncSubject.prototype._subscribe = function (subscriber) {
7223 if (this.hasError) {
7224 subscriber.error(this.thrownError);
7225 return Subscription_1.Subscription.EMPTY;
7227 else if (this.hasCompleted && this.hasNext) {
7228 subscriber.next(this.value);
7229 subscriber.complete();
7230 return Subscription_1.Subscription.EMPTY;
7232 return _super.prototype._subscribe.call(this, subscriber);
7234 AsyncSubject.prototype.next = function (value) {
7235 if (!this.hasCompleted) {
7237 this.hasNext = true;
7240 AsyncSubject.prototype.error = function (error) {
7241 if (!this.hasCompleted) {
7242 _super.prototype.error.call(this, error);
7245 AsyncSubject.prototype.complete = function () {
7246 this.hasCompleted = true;
7248 _super.prototype.next.call(this, this.value);
7250 _super.prototype.complete.call(this);
7252 return AsyncSubject;
7253 }(Subject_1.Subject));
7254 exports.AsyncSubject = AsyncSubject;
7256 },{"./Subject":37,"./Subscription":40}],29:[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 Subject_1 = require("./Subject");
7273 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
7274 var BehaviorSubject = (function (_super) {
7275 __extends(BehaviorSubject, _super);
7276 function BehaviorSubject(_value) {
7277 var _this = _super.call(this) || this;
7278 _this._value = _value;
7281 Object.defineProperty(BehaviorSubject.prototype, "value", {
7283 return this.getValue();
7288 BehaviorSubject.prototype._subscribe = function (subscriber) {
7289 var subscription = _super.prototype._subscribe.call(this, subscriber);
7290 if (subscription && !subscription.closed) {
7291 subscriber.next(this._value);
7293 return subscription;
7295 BehaviorSubject.prototype.getValue = function () {
7296 if (this.hasError) {
7297 throw this.thrownError;
7299 else if (this.closed) {
7300 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7306 BehaviorSubject.prototype.next = function (value) {
7307 _super.prototype.next.call(this, this._value = value);
7309 return BehaviorSubject;
7310 }(Subject_1.Subject));
7311 exports.BehaviorSubject = BehaviorSubject;
7313 },{"./Subject":37,"./util/ObjectUnsubscribedError":196}],30:[function(require,module,exports){
7315 var __extends = (this && this.__extends) || (function () {
7316 var extendStatics = function (d, b) {
7317 extendStatics = Object.setPrototypeOf ||
7318 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7319 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7320 return extendStatics(d, b);
7322 return function (d, b) {
7323 extendStatics(d, b);
7324 function __() { this.constructor = d; }
7325 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7328 Object.defineProperty(exports, "__esModule", { value: true });
7329 var Subscriber_1 = require("./Subscriber");
7330 var InnerSubscriber = (function (_super) {
7331 __extends(InnerSubscriber, _super);
7332 function InnerSubscriber(parent, outerValue, outerIndex) {
7333 var _this = _super.call(this) || this;
7334 _this.parent = parent;
7335 _this.outerValue = outerValue;
7336 _this.outerIndex = outerIndex;
7340 InnerSubscriber.prototype._next = function (value) {
7341 this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
7343 InnerSubscriber.prototype._error = function (error) {
7344 this.parent.notifyError(error, this);
7347 InnerSubscriber.prototype._complete = function () {
7348 this.parent.notifyComplete(this);
7351 return InnerSubscriber;
7352 }(Subscriber_1.Subscriber));
7353 exports.InnerSubscriber = InnerSubscriber;
7355 },{"./Subscriber":39}],31:[function(require,module,exports){
7357 Object.defineProperty(exports, "__esModule", { value: true });
7358 var empty_1 = require("./observable/empty");
7359 var of_1 = require("./observable/of");
7360 var throwError_1 = require("./observable/throwError");
7361 var Notification = (function () {
7362 function Notification(kind, value, error) {
7366 this.hasValue = kind === 'N';
7368 Notification.prototype.observe = function (observer) {
7369 switch (this.kind) {
7371 return observer.next && observer.next(this.value);
7373 return observer.error && observer.error(this.error);
7375 return observer.complete && observer.complete();
7378 Notification.prototype.do = function (next, error, complete) {
7379 var kind = this.kind;
7382 return next && next(this.value);
7384 return error && error(this.error);
7386 return complete && complete();
7389 Notification.prototype.accept = function (nextOrObserver, error, complete) {
7390 if (nextOrObserver && typeof nextOrObserver.next === 'function') {
7391 return this.observe(nextOrObserver);
7394 return this.do(nextOrObserver, error, complete);
7397 Notification.prototype.toObservable = function () {
7398 var kind = this.kind;
7401 return of_1.of(this.value);
7403 return throwError_1.throwError(this.error);
7405 return empty_1.empty();
7407 throw new Error('unexpected notification kind value');
7409 Notification.createNext = function (value) {
7410 if (typeof value !== 'undefined') {
7411 return new Notification('N', value);
7413 return Notification.undefinedValueNotification;
7415 Notification.createError = function (err) {
7416 return new Notification('E', undefined, err);
7418 Notification.createComplete = function () {
7419 return Notification.completeNotification;
7421 Notification.completeNotification = new Notification('C');
7422 Notification.undefinedValueNotification = new Notification('N', undefined);
7423 return Notification;
7425 exports.Notification = Notification;
7427 },{"./observable/empty":49,"./observable/of":63,"./observable/throwError":69}],32:[function(require,module,exports){
7429 Object.defineProperty(exports, "__esModule", { value: true });
7430 var canReportError_1 = require("./util/canReportError");
7431 var toSubscriber_1 = require("./util/toSubscriber");
7432 var observable_1 = require("../internal/symbol/observable");
7433 var pipe_1 = require("./util/pipe");
7434 var config_1 = require("./config");
7435 var Observable = (function () {
7436 function Observable(subscribe) {
7437 this._isScalar = false;
7439 this._subscribe = subscribe;
7442 Observable.prototype.lift = function (operator) {
7443 var observable = new Observable();
7444 observable.source = this;
7445 observable.operator = operator;
7448 Observable.prototype.subscribe = function (observerOrNext, error, complete) {
7449 var operator = this.operator;
7450 var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
7452 operator.call(sink, this.source);
7455 sink.add(this.source || (config_1.config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
7456 this._subscribe(sink) :
7457 this._trySubscribe(sink));
7459 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
7460 if (sink.syncErrorThrowable) {
7461 sink.syncErrorThrowable = false;
7462 if (sink.syncErrorThrown) {
7463 throw sink.syncErrorValue;
7469 Observable.prototype._trySubscribe = function (sink) {
7471 return this._subscribe(sink);
7474 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
7475 sink.syncErrorThrown = true;
7476 sink.syncErrorValue = err;
7478 if (canReportError_1.canReportError(sink)) {
7486 Observable.prototype.forEach = function (next, promiseCtor) {
7488 promiseCtor = getPromiseCtor(promiseCtor);
7489 return new promiseCtor(function (resolve, reject) {
7491 subscription = _this.subscribe(function (value) {
7498 subscription.unsubscribe();
7501 }, reject, resolve);
7504 Observable.prototype._subscribe = function (subscriber) {
7505 var source = this.source;
7506 return source && source.subscribe(subscriber);
7508 Observable.prototype[observable_1.observable] = function () {
7511 Observable.prototype.pipe = function () {
7512 var operations = [];
7513 for (var _i = 0; _i < arguments.length; _i++) {
7514 operations[_i] = arguments[_i];
7516 if (operations.length === 0) {
7519 return pipe_1.pipeFromArray(operations)(this);
7521 Observable.prototype.toPromise = function (promiseCtor) {
7523 promiseCtor = getPromiseCtor(promiseCtor);
7524 return new promiseCtor(function (resolve, reject) {
7526 _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
7529 Observable.create = function (subscribe) {
7530 return new Observable(subscribe);
7534 exports.Observable = Observable;
7535 function getPromiseCtor(promiseCtor) {
7537 promiseCtor = config_1.config.Promise || Promise;
7540 throw new Error('no Promise impl found');
7545 },{"../internal/symbol/observable":191,"./config":41,"./util/canReportError":199,"./util/pipe":216,"./util/toSubscriber":223}],33:[function(require,module,exports){
7547 Object.defineProperty(exports, "__esModule", { value: true });
7548 var config_1 = require("./config");
7549 var hostReportError_1 = require("./util/hostReportError");
7552 next: function (value) { },
7553 error: function (err) {
7554 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
7558 hostReportError_1.hostReportError(err);
7561 complete: function () { }
7564 },{"./config":41,"./util/hostReportError":201}],34:[function(require,module,exports){
7566 var __extends = (this && this.__extends) || (function () {
7567 var extendStatics = function (d, b) {
7568 extendStatics = Object.setPrototypeOf ||
7569 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7570 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7571 return extendStatics(d, b);
7573 return function (d, b) {
7574 extendStatics(d, b);
7575 function __() { this.constructor = d; }
7576 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7579 Object.defineProperty(exports, "__esModule", { value: true });
7580 var Subscriber_1 = require("./Subscriber");
7581 var OuterSubscriber = (function (_super) {
7582 __extends(OuterSubscriber, _super);
7583 function OuterSubscriber() {
7584 return _super !== null && _super.apply(this, arguments) || this;
7586 OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7587 this.destination.next(innerValue);
7589 OuterSubscriber.prototype.notifyError = function (error, innerSub) {
7590 this.destination.error(error);
7592 OuterSubscriber.prototype.notifyComplete = function (innerSub) {
7593 this.destination.complete();
7595 return OuterSubscriber;
7596 }(Subscriber_1.Subscriber));
7597 exports.OuterSubscriber = OuterSubscriber;
7599 },{"./Subscriber":39}],35:[function(require,module,exports){
7601 var __extends = (this && this.__extends) || (function () {
7602 var extendStatics = function (d, b) {
7603 extendStatics = Object.setPrototypeOf ||
7604 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7605 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7606 return extendStatics(d, b);
7608 return function (d, b) {
7609 extendStatics(d, b);
7610 function __() { this.constructor = d; }
7611 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7614 Object.defineProperty(exports, "__esModule", { value: true });
7615 var Subject_1 = require("./Subject");
7616 var queue_1 = require("./scheduler/queue");
7617 var Subscription_1 = require("./Subscription");
7618 var observeOn_1 = require("./operators/observeOn");
7619 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
7620 var SubjectSubscription_1 = require("./SubjectSubscription");
7621 var ReplaySubject = (function (_super) {
7622 __extends(ReplaySubject, _super);
7623 function ReplaySubject(bufferSize, windowTime, scheduler) {
7624 if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
7625 if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
7626 var _this = _super.call(this) || this;
7627 _this.scheduler = scheduler;
7629 _this._infiniteTimeWindow = false;
7630 _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
7631 _this._windowTime = windowTime < 1 ? 1 : windowTime;
7632 if (windowTime === Number.POSITIVE_INFINITY) {
7633 _this._infiniteTimeWindow = true;
7634 _this.next = _this.nextInfiniteTimeWindow;
7637 _this.next = _this.nextTimeWindow;
7641 ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
7642 var _events = this._events;
7643 _events.push(value);
7644 if (_events.length > this._bufferSize) {
7647 _super.prototype.next.call(this, value);
7649 ReplaySubject.prototype.nextTimeWindow = function (value) {
7650 this._events.push(new ReplayEvent(this._getNow(), value));
7651 this._trimBufferThenGetEvents();
7652 _super.prototype.next.call(this, value);
7654 ReplaySubject.prototype._subscribe = function (subscriber) {
7655 var _infiniteTimeWindow = this._infiniteTimeWindow;
7656 var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
7657 var scheduler = this.scheduler;
7658 var len = _events.length;
7661 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7663 else if (this.isStopped || this.hasError) {
7664 subscription = Subscription_1.Subscription.EMPTY;
7667 this.observers.push(subscriber);
7668 subscription = new SubjectSubscription_1.SubjectSubscription(this, subscriber);
7671 subscriber.add(subscriber = new observeOn_1.ObserveOnSubscriber(subscriber, scheduler));
7673 if (_infiniteTimeWindow) {
7674 for (var i = 0; i < len && !subscriber.closed; i++) {
7675 subscriber.next(_events[i]);
7679 for (var i = 0; i < len && !subscriber.closed; i++) {
7680 subscriber.next(_events[i].value);
7683 if (this.hasError) {
7684 subscriber.error(this.thrownError);
7686 else if (this.isStopped) {
7687 subscriber.complete();
7689 return subscription;
7691 ReplaySubject.prototype._getNow = function () {
7692 return (this.scheduler || queue_1.queue).now();
7694 ReplaySubject.prototype._trimBufferThenGetEvents = function () {
7695 var now = this._getNow();
7696 var _bufferSize = this._bufferSize;
7697 var _windowTime = this._windowTime;
7698 var _events = this._events;
7699 var eventsCount = _events.length;
7700 var spliceCount = 0;
7701 while (spliceCount < eventsCount) {
7702 if ((now - _events[spliceCount].time) < _windowTime) {
7707 if (eventsCount > _bufferSize) {
7708 spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
7710 if (spliceCount > 0) {
7711 _events.splice(0, spliceCount);
7715 return ReplaySubject;
7716 }(Subject_1.Subject));
7717 exports.ReplaySubject = ReplaySubject;
7718 var ReplayEvent = (function () {
7719 function ReplayEvent(time, value) {
7726 },{"./Subject":37,"./SubjectSubscription":38,"./Subscription":40,"./operators/observeOn":123,"./scheduler/queue":189,"./util/ObjectUnsubscribedError":196}],36:[function(require,module,exports){
7728 Object.defineProperty(exports, "__esModule", { value: true });
7729 var Scheduler = (function () {
7730 function Scheduler(SchedulerAction, now) {
7731 if (now === void 0) { now = Scheduler.now; }
7732 this.SchedulerAction = SchedulerAction;
7735 Scheduler.prototype.schedule = function (work, delay, state) {
7736 if (delay === void 0) { delay = 0; }
7737 return new this.SchedulerAction(this, work).schedule(state, delay);
7739 Scheduler.now = function () { return Date.now(); };
7742 exports.Scheduler = Scheduler;
7744 },{}],37:[function(require,module,exports){
7746 var __extends = (this && this.__extends) || (function () {
7747 var extendStatics = function (d, b) {
7748 extendStatics = Object.setPrototypeOf ||
7749 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7750 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7751 return extendStatics(d, b);
7753 return function (d, b) {
7754 extendStatics(d, b);
7755 function __() { this.constructor = d; }
7756 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7759 Object.defineProperty(exports, "__esModule", { value: true });
7760 var Observable_1 = require("./Observable");
7761 var Subscriber_1 = require("./Subscriber");
7762 var Subscription_1 = require("./Subscription");
7763 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
7764 var SubjectSubscription_1 = require("./SubjectSubscription");
7765 var rxSubscriber_1 = require("../internal/symbol/rxSubscriber");
7766 var SubjectSubscriber = (function (_super) {
7767 __extends(SubjectSubscriber, _super);
7768 function SubjectSubscriber(destination) {
7769 var _this = _super.call(this, destination) || this;
7770 _this.destination = destination;
7773 return SubjectSubscriber;
7774 }(Subscriber_1.Subscriber));
7775 exports.SubjectSubscriber = SubjectSubscriber;
7776 var Subject = (function (_super) {
7777 __extends(Subject, _super);
7778 function Subject() {
7779 var _this = _super.call(this) || this;
7780 _this.observers = [];
7781 _this.closed = false;
7782 _this.isStopped = false;
7783 _this.hasError = false;
7784 _this.thrownError = null;
7787 Subject.prototype[rxSubscriber_1.rxSubscriber] = function () {
7788 return new SubjectSubscriber(this);
7790 Subject.prototype.lift = function (operator) {
7791 var subject = new AnonymousSubject(this, this);
7792 subject.operator = operator;
7795 Subject.prototype.next = function (value) {
7797 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7799 if (!this.isStopped) {
7800 var observers = this.observers;
7801 var len = observers.length;
7802 var copy = observers.slice();
7803 for (var i = 0; i < len; i++) {
7804 copy[i].next(value);
7808 Subject.prototype.error = function (err) {
7810 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7812 this.hasError = true;
7813 this.thrownError = err;
7814 this.isStopped = true;
7815 var observers = this.observers;
7816 var len = observers.length;
7817 var copy = observers.slice();
7818 for (var i = 0; i < len; i++) {
7821 this.observers.length = 0;
7823 Subject.prototype.complete = function () {
7825 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7827 this.isStopped = true;
7828 var observers = this.observers;
7829 var len = observers.length;
7830 var copy = observers.slice();
7831 for (var i = 0; i < len; i++) {
7834 this.observers.length = 0;
7836 Subject.prototype.unsubscribe = function () {
7837 this.isStopped = true;
7839 this.observers = null;
7841 Subject.prototype._trySubscribe = function (subscriber) {
7843 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7846 return _super.prototype._trySubscribe.call(this, subscriber);
7849 Subject.prototype._subscribe = function (subscriber) {
7851 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7853 else if (this.hasError) {
7854 subscriber.error(this.thrownError);
7855 return Subscription_1.Subscription.EMPTY;
7857 else if (this.isStopped) {
7858 subscriber.complete();
7859 return Subscription_1.Subscription.EMPTY;
7862 this.observers.push(subscriber);
7863 return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
7866 Subject.prototype.asObservable = function () {
7867 var observable = new Observable_1.Observable();
7868 observable.source = this;
7871 Subject.create = function (destination, source) {
7872 return new AnonymousSubject(destination, source);
7875 }(Observable_1.Observable));
7876 exports.Subject = Subject;
7877 var AnonymousSubject = (function (_super) {
7878 __extends(AnonymousSubject, _super);
7879 function AnonymousSubject(destination, source) {
7880 var _this = _super.call(this) || this;
7881 _this.destination = destination;
7882 _this.source = source;
7885 AnonymousSubject.prototype.next = function (value) {
7886 var destination = this.destination;
7887 if (destination && destination.next) {
7888 destination.next(value);
7891 AnonymousSubject.prototype.error = function (err) {
7892 var destination = this.destination;
7893 if (destination && destination.error) {
7894 this.destination.error(err);
7897 AnonymousSubject.prototype.complete = function () {
7898 var destination = this.destination;
7899 if (destination && destination.complete) {
7900 this.destination.complete();
7903 AnonymousSubject.prototype._subscribe = function (subscriber) {
7904 var source = this.source;
7906 return this.source.subscribe(subscriber);
7909 return Subscription_1.Subscription.EMPTY;
7912 return AnonymousSubject;
7914 exports.AnonymousSubject = AnonymousSubject;
7916 },{"../internal/symbol/rxSubscriber":192,"./Observable":32,"./SubjectSubscription":38,"./Subscriber":39,"./Subscription":40,"./util/ObjectUnsubscribedError":196}],38:[function(require,module,exports){
7918 var __extends = (this && this.__extends) || (function () {
7919 var extendStatics = function (d, b) {
7920 extendStatics = Object.setPrototypeOf ||
7921 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7922 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7923 return extendStatics(d, b);
7925 return function (d, b) {
7926 extendStatics(d, b);
7927 function __() { this.constructor = d; }
7928 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7931 Object.defineProperty(exports, "__esModule", { value: true });
7932 var Subscription_1 = require("./Subscription");
7933 var SubjectSubscription = (function (_super) {
7934 __extends(SubjectSubscription, _super);
7935 function SubjectSubscription(subject, subscriber) {
7936 var _this = _super.call(this) || this;
7937 _this.subject = subject;
7938 _this.subscriber = subscriber;
7939 _this.closed = false;
7942 SubjectSubscription.prototype.unsubscribe = function () {
7947 var subject = this.subject;
7948 var observers = subject.observers;
7949 this.subject = null;
7950 if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
7953 var subscriberIndex = observers.indexOf(this.subscriber);
7954 if (subscriberIndex !== -1) {
7955 observers.splice(subscriberIndex, 1);
7958 return SubjectSubscription;
7959 }(Subscription_1.Subscription));
7960 exports.SubjectSubscription = SubjectSubscription;
7962 },{"./Subscription":40}],39:[function(require,module,exports){
7964 var __extends = (this && this.__extends) || (function () {
7965 var extendStatics = function (d, b) {
7966 extendStatics = Object.setPrototypeOf ||
7967 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7968 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7969 return extendStatics(d, b);
7971 return function (d, b) {
7972 extendStatics(d, b);
7973 function __() { this.constructor = d; }
7974 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7977 Object.defineProperty(exports, "__esModule", { value: true });
7978 var isFunction_1 = require("./util/isFunction");
7979 var Observer_1 = require("./Observer");
7980 var Subscription_1 = require("./Subscription");
7981 var rxSubscriber_1 = require("../internal/symbol/rxSubscriber");
7982 var config_1 = require("./config");
7983 var hostReportError_1 = require("./util/hostReportError");
7984 var Subscriber = (function (_super) {
7985 __extends(Subscriber, _super);
7986 function Subscriber(destinationOrNext, error, complete) {
7987 var _this = _super.call(this) || this;
7988 _this.syncErrorValue = null;
7989 _this.syncErrorThrown = false;
7990 _this.syncErrorThrowable = false;
7991 _this.isStopped = false;
7992 _this._parentSubscription = null;
7993 switch (arguments.length) {
7995 _this.destination = Observer_1.empty;
7998 if (!destinationOrNext) {
7999 _this.destination = Observer_1.empty;
8002 if (typeof destinationOrNext === 'object') {
8003 if (destinationOrNext instanceof Subscriber) {
8004 _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
8005 _this.destination = destinationOrNext;
8006 destinationOrNext.add(_this);
8009 _this.syncErrorThrowable = true;
8010 _this.destination = new SafeSubscriber(_this, destinationOrNext);
8015 _this.syncErrorThrowable = true;
8016 _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
8021 Subscriber.prototype[rxSubscriber_1.rxSubscriber] = function () { return this; };
8022 Subscriber.create = function (next, error, complete) {
8023 var subscriber = new Subscriber(next, error, complete);
8024 subscriber.syncErrorThrowable = false;
8027 Subscriber.prototype.next = function (value) {
8028 if (!this.isStopped) {
8032 Subscriber.prototype.error = function (err) {
8033 if (!this.isStopped) {
8034 this.isStopped = true;
8038 Subscriber.prototype.complete = function () {
8039 if (!this.isStopped) {
8040 this.isStopped = true;
8044 Subscriber.prototype.unsubscribe = function () {
8048 this.isStopped = true;
8049 _super.prototype.unsubscribe.call(this);
8051 Subscriber.prototype._next = function (value) {
8052 this.destination.next(value);
8054 Subscriber.prototype._error = function (err) {
8055 this.destination.error(err);
8058 Subscriber.prototype._complete = function () {
8059 this.destination.complete();
8062 Subscriber.prototype._unsubscribeAndRecycle = function () {
8063 var _a = this, _parent = _a._parent, _parents = _a._parents;
8064 this._parent = null;
8065 this._parents = null;
8067 this.closed = false;
8068 this.isStopped = false;
8069 this._parent = _parent;
8070 this._parents = _parents;
8071 this._parentSubscription = null;
8075 }(Subscription_1.Subscription));
8076 exports.Subscriber = Subscriber;
8077 var SafeSubscriber = (function (_super) {
8078 __extends(SafeSubscriber, _super);
8079 function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
8080 var _this = _super.call(this) || this;
8081 _this._parentSubscriber = _parentSubscriber;
8083 var context = _this;
8084 if (isFunction_1.isFunction(observerOrNext)) {
8085 next = observerOrNext;
8087 else if (observerOrNext) {
8088 next = observerOrNext.next;
8089 error = observerOrNext.error;
8090 complete = observerOrNext.complete;
8091 if (observerOrNext !== Observer_1.empty) {
8092 context = Object.create(observerOrNext);
8093 if (isFunction_1.isFunction(context.unsubscribe)) {
8094 _this.add(context.unsubscribe.bind(context));
8096 context.unsubscribe = _this.unsubscribe.bind(_this);
8099 _this._context = context;
8101 _this._error = error;
8102 _this._complete = complete;
8105 SafeSubscriber.prototype.next = function (value) {
8106 if (!this.isStopped && this._next) {
8107 var _parentSubscriber = this._parentSubscriber;
8108 if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
8109 this.__tryOrUnsub(this._next, value);
8111 else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
8116 SafeSubscriber.prototype.error = function (err) {
8117 if (!this.isStopped) {
8118 var _parentSubscriber = this._parentSubscriber;
8119 var useDeprecatedSynchronousErrorHandling = config_1.config.useDeprecatedSynchronousErrorHandling;
8121 if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
8122 this.__tryOrUnsub(this._error, err);
8126 this.__tryOrSetError(_parentSubscriber, this._error, err);
8130 else if (!_parentSubscriber.syncErrorThrowable) {
8132 if (useDeprecatedSynchronousErrorHandling) {
8135 hostReportError_1.hostReportError(err);
8138 if (useDeprecatedSynchronousErrorHandling) {
8139 _parentSubscriber.syncErrorValue = err;
8140 _parentSubscriber.syncErrorThrown = true;
8143 hostReportError_1.hostReportError(err);
8149 SafeSubscriber.prototype.complete = function () {
8151 if (!this.isStopped) {
8152 var _parentSubscriber = this._parentSubscriber;
8153 if (this._complete) {
8154 var wrappedComplete = function () { return _this._complete.call(_this._context); };
8155 if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
8156 this.__tryOrUnsub(wrappedComplete);
8160 this.__tryOrSetError(_parentSubscriber, wrappedComplete);
8169 SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
8171 fn.call(this._context, value);
8175 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
8179 hostReportError_1.hostReportError(err);
8183 SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
8184 if (!config_1.config.useDeprecatedSynchronousErrorHandling) {
8185 throw new Error('bad call');
8188 fn.call(this._context, value);
8191 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
8192 parent.syncErrorValue = err;
8193 parent.syncErrorThrown = true;
8197 hostReportError_1.hostReportError(err);
8203 SafeSubscriber.prototype._unsubscribe = function () {
8204 var _parentSubscriber = this._parentSubscriber;
8205 this._context = null;
8206 this._parentSubscriber = null;
8207 _parentSubscriber.unsubscribe();
8209 return SafeSubscriber;
8211 exports.SafeSubscriber = SafeSubscriber;
8213 },{"../internal/symbol/rxSubscriber":192,"./Observer":33,"./Subscription":40,"./config":41,"./util/hostReportError":201,"./util/isFunction":206}],40:[function(require,module,exports){
8215 Object.defineProperty(exports, "__esModule", { value: true });
8216 var isArray_1 = require("./util/isArray");
8217 var isObject_1 = require("./util/isObject");
8218 var isFunction_1 = require("./util/isFunction");
8219 var tryCatch_1 = require("./util/tryCatch");
8220 var errorObject_1 = require("./util/errorObject");
8221 var UnsubscriptionError_1 = require("./util/UnsubscriptionError");
8222 var Subscription = (function () {
8223 function Subscription(unsubscribe) {
8224 this.closed = false;
8225 this._parent = null;
8226 this._parents = null;
8227 this._subscriptions = null;
8229 this._unsubscribe = unsubscribe;
8232 Subscription.prototype.unsubscribe = function () {
8233 var hasErrors = false;
8238 var _a = this, _parent = _a._parent, _parents = _a._parents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
8240 this._parent = null;
8241 this._parents = null;
8242 this._subscriptions = null;
8244 var len = _parents ? _parents.length : 0;
8246 _parent.remove(this);
8247 _parent = ++index < len && _parents[index] || null;
8249 if (isFunction_1.isFunction(_unsubscribe)) {
8250 var trial = tryCatch_1.tryCatch(_unsubscribe).call(this);
8251 if (trial === errorObject_1.errorObject) {
8253 errors = errors || (errorObject_1.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ?
8254 flattenUnsubscriptionErrors(errorObject_1.errorObject.e.errors) : [errorObject_1.errorObject.e]);
8257 if (isArray_1.isArray(_subscriptions)) {
8259 len = _subscriptions.length;
8260 while (++index < len) {
8261 var sub = _subscriptions[index];
8262 if (isObject_1.isObject(sub)) {
8263 var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub);
8264 if (trial === errorObject_1.errorObject) {
8266 errors = errors || [];
8267 var err = errorObject_1.errorObject.e;
8268 if (err instanceof UnsubscriptionError_1.UnsubscriptionError) {
8269 errors = errors.concat(flattenUnsubscriptionErrors(err.errors));
8279 throw new UnsubscriptionError_1.UnsubscriptionError(errors);
8282 Subscription.prototype.add = function (teardown) {
8283 if (!teardown || (teardown === Subscription.EMPTY)) {
8284 return Subscription.EMPTY;
8286 if (teardown === this) {
8289 var subscription = teardown;
8290 switch (typeof teardown) {
8292 subscription = new Subscription(teardown);
8294 if (subscription.closed || typeof subscription.unsubscribe !== 'function') {
8295 return subscription;
8297 else if (this.closed) {
8298 subscription.unsubscribe();
8299 return subscription;
8301 else if (typeof subscription._addParent !== 'function') {
8302 var tmp = subscription;
8303 subscription = new Subscription();
8304 subscription._subscriptions = [tmp];
8308 throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
8310 var subscriptions = this._subscriptions || (this._subscriptions = []);
8311 subscriptions.push(subscription);
8312 subscription._addParent(this);
8313 return subscription;
8315 Subscription.prototype.remove = function (subscription) {
8316 var subscriptions = this._subscriptions;
8317 if (subscriptions) {
8318 var subscriptionIndex = subscriptions.indexOf(subscription);
8319 if (subscriptionIndex !== -1) {
8320 subscriptions.splice(subscriptionIndex, 1);
8324 Subscription.prototype._addParent = function (parent) {
8325 var _a = this, _parent = _a._parent, _parents = _a._parents;
8326 if (!_parent || _parent === parent) {
8327 this._parent = parent;
8329 else if (!_parents) {
8330 this._parents = [parent];
8332 else if (_parents.indexOf(parent) === -1) {
8333 _parents.push(parent);
8336 Subscription.EMPTY = (function (empty) {
8337 empty.closed = true;
8339 }(new Subscription()));
8340 return Subscription;
8342 exports.Subscription = Subscription;
8343 function flattenUnsubscriptionErrors(errors) {
8344 return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []);
8347 },{"./util/UnsubscriptionError":198,"./util/errorObject":200,"./util/isArray":203,"./util/isFunction":206,"./util/isObject":210,"./util/tryCatch":224}],41:[function(require,module,exports){
8349 Object.defineProperty(exports, "__esModule", { value: true });
8350 var _enable_super_gross_mode_that_will_cause_bad_things = false;
8353 set useDeprecatedSynchronousErrorHandling(value) {
8355 var error = new Error();
8356 console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
8358 else if (_enable_super_gross_mode_that_will_cause_bad_things) {
8359 console.log('RxJS: Back to a better error behavior. Thank you. <3');
8361 _enable_super_gross_mode_that_will_cause_bad_things = value;
8363 get useDeprecatedSynchronousErrorHandling() {
8364 return _enable_super_gross_mode_that_will_cause_bad_things;
8368 },{}],42:[function(require,module,exports){
8370 var __extends = (this && this.__extends) || (function () {
8371 var extendStatics = function (d, b) {
8372 extendStatics = Object.setPrototypeOf ||
8373 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8374 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8375 return extendStatics(d, b);
8377 return function (d, b) {
8378 extendStatics(d, b);
8379 function __() { this.constructor = d; }
8380 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8383 Object.defineProperty(exports, "__esModule", { value: true });
8384 var Subject_1 = require("../Subject");
8385 var Observable_1 = require("../Observable");
8386 var Subscriber_1 = require("../Subscriber");
8387 var Subscription_1 = require("../Subscription");
8388 var refCount_1 = require("../operators/refCount");
8389 var ConnectableObservable = (function (_super) {
8390 __extends(ConnectableObservable, _super);
8391 function ConnectableObservable(source, subjectFactory) {
8392 var _this = _super.call(this) || this;
8393 _this.source = source;
8394 _this.subjectFactory = subjectFactory;
8395 _this._refCount = 0;
8396 _this._isComplete = false;
8399 ConnectableObservable.prototype._subscribe = function (subscriber) {
8400 return this.getSubject().subscribe(subscriber);
8402 ConnectableObservable.prototype.getSubject = function () {
8403 var subject = this._subject;
8404 if (!subject || subject.isStopped) {
8405 this._subject = this.subjectFactory();
8407 return this._subject;
8409 ConnectableObservable.prototype.connect = function () {
8410 var connection = this._connection;
8412 this._isComplete = false;
8413 connection = this._connection = new Subscription_1.Subscription();
8414 connection.add(this.source
8415 .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
8416 if (connection.closed) {
8417 this._connection = null;
8418 connection = Subscription_1.Subscription.EMPTY;
8421 this._connection = connection;
8426 ConnectableObservable.prototype.refCount = function () {
8427 return refCount_1.refCount()(this);
8429 return ConnectableObservable;
8430 }(Observable_1.Observable));
8431 exports.ConnectableObservable = ConnectableObservable;
8432 var connectableProto = ConnectableObservable.prototype;
8433 exports.connectableObservableDescriptor = {
8434 operator: { value: null },
8435 _refCount: { value: 0, writable: true },
8436 _subject: { value: null, writable: true },
8437 _connection: { value: null, writable: true },
8438 _subscribe: { value: connectableProto._subscribe },
8439 _isComplete: { value: connectableProto._isComplete, writable: true },
8440 getSubject: { value: connectableProto.getSubject },
8441 connect: { value: connectableProto.connect },
8442 refCount: { value: connectableProto.refCount }
8444 var ConnectableSubscriber = (function (_super) {
8445 __extends(ConnectableSubscriber, _super);
8446 function ConnectableSubscriber(destination, connectable) {
8447 var _this = _super.call(this, destination) || this;
8448 _this.connectable = connectable;
8451 ConnectableSubscriber.prototype._error = function (err) {
8452 this._unsubscribe();
8453 _super.prototype._error.call(this, err);
8455 ConnectableSubscriber.prototype._complete = function () {
8456 this.connectable._isComplete = true;
8457 this._unsubscribe();
8458 _super.prototype._complete.call(this);
8460 ConnectableSubscriber.prototype._unsubscribe = function () {
8461 var connectable = this.connectable;
8463 this.connectable = null;
8464 var connection = connectable._connection;
8465 connectable._refCount = 0;
8466 connectable._subject = null;
8467 connectable._connection = null;
8469 connection.unsubscribe();
8473 return ConnectableSubscriber;
8474 }(Subject_1.SubjectSubscriber));
8475 var RefCountOperator = (function () {
8476 function RefCountOperator(connectable) {
8477 this.connectable = connectable;
8479 RefCountOperator.prototype.call = function (subscriber, source) {
8480 var connectable = this.connectable;
8481 connectable._refCount++;
8482 var refCounter = new RefCountSubscriber(subscriber, connectable);
8483 var subscription = source.subscribe(refCounter);
8484 if (!refCounter.closed) {
8485 refCounter.connection = connectable.connect();
8487 return subscription;
8489 return RefCountOperator;
8491 var RefCountSubscriber = (function (_super) {
8492 __extends(RefCountSubscriber, _super);
8493 function RefCountSubscriber(destination, connectable) {
8494 var _this = _super.call(this, destination) || this;
8495 _this.connectable = connectable;
8498 RefCountSubscriber.prototype._unsubscribe = function () {
8499 var connectable = this.connectable;
8501 this.connection = null;
8504 this.connectable = null;
8505 var refCount = connectable._refCount;
8506 if (refCount <= 0) {
8507 this.connection = null;
8510 connectable._refCount = refCount - 1;
8512 this.connection = null;
8515 var connection = this.connection;
8516 var sharedConnection = connectable._connection;
8517 this.connection = null;
8518 if (sharedConnection && (!connection || sharedConnection === connection)) {
8519 sharedConnection.unsubscribe();
8522 return RefCountSubscriber;
8523 }(Subscriber_1.Subscriber));
8525 },{"../Observable":32,"../Subject":37,"../Subscriber":39,"../Subscription":40,"../operators/refCount":134}],43:[function(require,module,exports){
8527 var __extends = (this && this.__extends) || (function () {
8528 var extendStatics = function (d, b) {
8529 extendStatics = Object.setPrototypeOf ||
8530 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8531 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8532 return extendStatics(d, b);
8534 return function (d, b) {
8535 extendStatics(d, b);
8536 function __() { this.constructor = d; }
8537 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8540 Object.defineProperty(exports, "__esModule", { value: true });
8541 var Observable_1 = require("../Observable");
8542 var asap_1 = require("../scheduler/asap");
8543 var isNumeric_1 = require("../util/isNumeric");
8544 var SubscribeOnObservable = (function (_super) {
8545 __extends(SubscribeOnObservable, _super);
8546 function SubscribeOnObservable(source, delayTime, scheduler) {
8547 if (delayTime === void 0) { delayTime = 0; }
8548 if (scheduler === void 0) { scheduler = asap_1.asap; }
8549 var _this = _super.call(this) || this;
8550 _this.source = source;
8551 _this.delayTime = delayTime;
8552 _this.scheduler = scheduler;
8553 if (!isNumeric_1.isNumeric(delayTime) || delayTime < 0) {
8554 _this.delayTime = 0;
8556 if (!scheduler || typeof scheduler.schedule !== 'function') {
8557 _this.scheduler = asap_1.asap;
8561 SubscribeOnObservable.create = function (source, delay, scheduler) {
8562 if (delay === void 0) { delay = 0; }
8563 if (scheduler === void 0) { scheduler = asap_1.asap; }
8564 return new SubscribeOnObservable(source, delay, scheduler);
8566 SubscribeOnObservable.dispatch = function (arg) {
8567 var source = arg.source, subscriber = arg.subscriber;
8568 return this.add(source.subscribe(subscriber));
8570 SubscribeOnObservable.prototype._subscribe = function (subscriber) {
8571 var delay = this.delayTime;
8572 var source = this.source;
8573 var scheduler = this.scheduler;
8574 return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
8575 source: source, subscriber: subscriber
8578 return SubscribeOnObservable;
8579 }(Observable_1.Observable));
8580 exports.SubscribeOnObservable = SubscribeOnObservable;
8582 },{"../Observable":32,"../scheduler/asap":187,"../util/isNumeric":209}],44:[function(require,module,exports){
8584 Object.defineProperty(exports, "__esModule", { value: true });
8585 var Observable_1 = require("../Observable");
8586 var AsyncSubject_1 = require("../AsyncSubject");
8587 var map_1 = require("../operators/map");
8588 var canReportError_1 = require("../util/canReportError");
8589 var isArray_1 = require("../util/isArray");
8590 var isScheduler_1 = require("../util/isScheduler");
8591 function bindCallback(callbackFunc, resultSelector, scheduler) {
8592 if (resultSelector) {
8593 if (isScheduler_1.isScheduler(resultSelector)) {
8594 scheduler = resultSelector;
8597 return function () {
8599 for (var _i = 0; _i < arguments.length; _i++) {
8600 args[_i] = arguments[_i];
8602 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); }));
8606 return function () {
8608 for (var _i = 0; _i < arguments.length; _i++) {
8609 args[_i] = arguments[_i];
8616 callbackFunc: callbackFunc,
8617 scheduler: scheduler,
8619 return new Observable_1.Observable(function (subscriber) {
8622 subject = new AsyncSubject_1.AsyncSubject();
8623 var handler = function () {
8625 for (var _i = 0; _i < arguments.length; _i++) {
8626 innerArgs[_i] = arguments[_i];
8628 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
8632 callbackFunc.apply(context, args.concat([handler]));
8635 if (canReportError_1.canReportError(subject)) {
8643 return subject.subscribe(subscriber);
8647 args: args, subscriber: subscriber, params: params,
8649 return scheduler.schedule(dispatch, 0, state);
8654 exports.bindCallback = bindCallback;
8655 function dispatch(state) {
8658 var args = state.args, subscriber = state.subscriber, params = state.params;
8659 var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
8660 var subject = params.subject;
8662 subject = params.subject = new AsyncSubject_1.AsyncSubject();
8663 var handler = function () {
8665 for (var _i = 0; _i < arguments.length; _i++) {
8666 innerArgs[_i] = arguments[_i];
8668 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
8669 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
8672 callbackFunc.apply(context, args.concat([handler]));
8678 this.add(subject.subscribe(subscriber));
8680 function dispatchNext(state) {
8681 var value = state.value, subject = state.subject;
8682 subject.next(value);
8685 function dispatchError(state) {
8686 var err = state.err, subject = state.subject;
8690 },{"../AsyncSubject":28,"../Observable":32,"../operators/map":112,"../util/canReportError":199,"../util/isArray":203,"../util/isScheduler":213}],45:[function(require,module,exports){
8692 Object.defineProperty(exports, "__esModule", { value: true });
8693 var Observable_1 = require("../Observable");
8694 var AsyncSubject_1 = require("../AsyncSubject");
8695 var map_1 = require("../operators/map");
8696 var canReportError_1 = require("../util/canReportError");
8697 var isScheduler_1 = require("../util/isScheduler");
8698 var isArray_1 = require("../util/isArray");
8699 function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
8700 if (resultSelector) {
8701 if (isScheduler_1.isScheduler(resultSelector)) {
8702 scheduler = resultSelector;
8705 return function () {
8707 for (var _i = 0; _i < arguments.length; _i++) {
8708 args[_i] = arguments[_i];
8710 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); }));
8714 return function () {
8716 for (var _i = 0; _i < arguments.length; _i++) {
8717 args[_i] = arguments[_i];
8722 callbackFunc: callbackFunc,
8723 scheduler: scheduler,
8726 return new Observable_1.Observable(function (subscriber) {
8727 var context = params.context;
8728 var subject = params.subject;
8731 subject = params.subject = new AsyncSubject_1.AsyncSubject();
8732 var handler = function () {
8734 for (var _i = 0; _i < arguments.length; _i++) {
8735 innerArgs[_i] = arguments[_i];
8737 var err = innerArgs.shift();
8742 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
8746 callbackFunc.apply(context, args.concat([handler]));
8749 if (canReportError_1.canReportError(subject)) {
8757 return subject.subscribe(subscriber);
8760 return scheduler.schedule(dispatch, 0, { params: params, subscriber: subscriber, context: context });
8765 exports.bindNodeCallback = bindNodeCallback;
8766 function dispatch(state) {
8768 var params = state.params, subscriber = state.subscriber, context = state.context;
8769 var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
8770 var subject = params.subject;
8772 subject = params.subject = new AsyncSubject_1.AsyncSubject();
8773 var handler = function () {
8775 for (var _i = 0; _i < arguments.length; _i++) {
8776 innerArgs[_i] = arguments[_i];
8778 var err = innerArgs.shift();
8780 _this.add(scheduler.schedule(dispatchError, 0, { err: err, subject: subject }));
8783 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
8784 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
8788 callbackFunc.apply(context, args.concat([handler]));
8791 this.add(scheduler.schedule(dispatchError, 0, { err: err, subject: subject }));
8794 this.add(subject.subscribe(subscriber));
8796 function dispatchNext(arg) {
8797 var value = arg.value, subject = arg.subject;
8798 subject.next(value);
8801 function dispatchError(arg) {
8802 var err = arg.err, subject = arg.subject;
8806 },{"../AsyncSubject":28,"../Observable":32,"../operators/map":112,"../util/canReportError":199,"../util/isArray":203,"../util/isScheduler":213}],46:[function(require,module,exports){
8808 var __extends = (this && this.__extends) || (function () {
8809 var extendStatics = function (d, b) {
8810 extendStatics = Object.setPrototypeOf ||
8811 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8812 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8813 return extendStatics(d, b);
8815 return function (d, b) {
8816 extendStatics(d, b);
8817 function __() { this.constructor = d; }
8818 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8821 Object.defineProperty(exports, "__esModule", { value: true });
8822 var isScheduler_1 = require("../util/isScheduler");
8823 var isArray_1 = require("../util/isArray");
8824 var OuterSubscriber_1 = require("../OuterSubscriber");
8825 var subscribeToResult_1 = require("../util/subscribeToResult");
8826 var fromArray_1 = require("./fromArray");
8828 function combineLatest() {
8829 var observables = [];
8830 for (var _i = 0; _i < arguments.length; _i++) {
8831 observables[_i] = arguments[_i];
8833 var resultSelector = null;
8834 var scheduler = null;
8835 if (isScheduler_1.isScheduler(observables[observables.length - 1])) {
8836 scheduler = observables.pop();
8838 if (typeof observables[observables.length - 1] === 'function') {
8839 resultSelector = observables.pop();
8841 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
8842 observables = observables[0];
8844 return fromArray_1.fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
8846 exports.combineLatest = combineLatest;
8847 var CombineLatestOperator = (function () {
8848 function CombineLatestOperator(resultSelector) {
8849 this.resultSelector = resultSelector;
8851 CombineLatestOperator.prototype.call = function (subscriber, source) {
8852 return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
8854 return CombineLatestOperator;
8856 exports.CombineLatestOperator = CombineLatestOperator;
8857 var CombineLatestSubscriber = (function (_super) {
8858 __extends(CombineLatestSubscriber, _super);
8859 function CombineLatestSubscriber(destination, resultSelector) {
8860 var _this = _super.call(this, destination) || this;
8861 _this.resultSelector = resultSelector;
8864 _this.observables = [];
8867 CombineLatestSubscriber.prototype._next = function (observable) {
8868 this.values.push(NONE);
8869 this.observables.push(observable);
8871 CombineLatestSubscriber.prototype._complete = function () {
8872 var observables = this.observables;
8873 var len = observables.length;
8875 this.destination.complete();
8879 this.toRespond = len;
8880 for (var i = 0; i < len; i++) {
8881 var observable = observables[i];
8882 this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i));
8886 CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
8887 if ((this.active -= 1) === 0) {
8888 this.destination.complete();
8891 CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
8892 var values = this.values;
8893 var oldVal = values[outerIndex];
8894 var toRespond = !this.toRespond
8896 : oldVal === NONE ? --this.toRespond : this.toRespond;
8897 values[outerIndex] = innerValue;
8898 if (toRespond === 0) {
8899 if (this.resultSelector) {
8900 this._tryResultSelector(values);
8903 this.destination.next(values.slice());
8907 CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
8910 result = this.resultSelector.apply(this, values);
8913 this.destination.error(err);
8916 this.destination.next(result);
8918 return CombineLatestSubscriber;
8919 }(OuterSubscriber_1.OuterSubscriber));
8920 exports.CombineLatestSubscriber = CombineLatestSubscriber;
8922 },{"../OuterSubscriber":34,"../util/isArray":203,"../util/isScheduler":213,"../util/subscribeToResult":222,"./fromArray":52}],47:[function(require,module,exports){
8924 Object.defineProperty(exports, "__esModule", { value: true });
8925 var isScheduler_1 = require("../util/isScheduler");
8926 var of_1 = require("./of");
8927 var from_1 = require("./from");
8928 var concatAll_1 = require("../operators/concatAll");
8930 var observables = [];
8931 for (var _i = 0; _i < arguments.length; _i++) {
8932 observables[_i] = arguments[_i];
8934 if (observables.length === 1 || (observables.length === 2 && isScheduler_1.isScheduler(observables[1]))) {
8935 return from_1.from(observables[0]);
8937 return concatAll_1.concatAll()(of_1.of.apply(void 0, observables));
8939 exports.concat = concat;
8941 },{"../operators/concatAll":84,"../util/isScheduler":213,"./from":51,"./of":63}],48:[function(require,module,exports){
8943 Object.defineProperty(exports, "__esModule", { value: true });
8944 var Observable_1 = require("../Observable");
8945 var from_1 = require("./from");
8946 var empty_1 = require("./empty");
8947 function defer(observableFactory) {
8948 return new Observable_1.Observable(function (subscriber) {
8951 input = observableFactory();
8954 subscriber.error(err);
8957 var source = input ? from_1.from(input) : empty_1.empty();
8958 return source.subscribe(subscriber);
8961 exports.defer = defer;
8963 },{"../Observable":32,"./empty":49,"./from":51}],49:[function(require,module,exports){
8965 Object.defineProperty(exports, "__esModule", { value: true });
8966 var Observable_1 = require("../Observable");
8967 exports.EMPTY = new Observable_1.Observable(function (subscriber) { return subscriber.complete(); });
8968 function empty(scheduler) {
8969 return scheduler ? emptyScheduled(scheduler) : exports.EMPTY;
8971 exports.empty = empty;
8972 function emptyScheduled(scheduler) {
8973 return new Observable_1.Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
8975 exports.emptyScheduled = emptyScheduled;
8977 },{"../Observable":32}],50:[function(require,module,exports){
8979 var __extends = (this && this.__extends) || (function () {
8980 var extendStatics = function (d, b) {
8981 extendStatics = Object.setPrototypeOf ||
8982 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8983 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8984 return extendStatics(d, b);
8986 return function (d, b) {
8987 extendStatics(d, b);
8988 function __() { this.constructor = d; }
8989 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8992 Object.defineProperty(exports, "__esModule", { value: true });
8993 var Observable_1 = require("../Observable");
8994 var isArray_1 = require("../util/isArray");
8995 var empty_1 = require("./empty");
8996 var subscribeToResult_1 = require("../util/subscribeToResult");
8997 var OuterSubscriber_1 = require("../OuterSubscriber");
8998 var map_1 = require("../operators/map");
8999 function forkJoin() {
9001 for (var _i = 0; _i < arguments.length; _i++) {
9002 sources[_i] = arguments[_i];
9005 if (typeof sources[sources.length - 1] === 'function') {
9006 resultSelector = sources.pop();
9008 if (sources.length === 1 && isArray_1.isArray(sources[0])) {
9009 sources = sources[0];
9011 if (sources.length === 0) {
9012 return empty_1.EMPTY;
9014 if (resultSelector) {
9015 return forkJoin(sources).pipe(map_1.map(function (args) { return resultSelector.apply(void 0, args); }));
9017 return new Observable_1.Observable(function (subscriber) {
9018 return new ForkJoinSubscriber(subscriber, sources);
9021 exports.forkJoin = forkJoin;
9022 var ForkJoinSubscriber = (function (_super) {
9023 __extends(ForkJoinSubscriber, _super);
9024 function ForkJoinSubscriber(destination, sources) {
9025 var _this = _super.call(this, destination) || this;
9026 _this.sources = sources;
9027 _this.completed = 0;
9028 _this.haveValues = 0;
9029 var len = sources.length;
9030 _this.values = new Array(len);
9031 for (var i = 0; i < len; i++) {
9032 var source = sources[i];
9033 var innerSubscription = subscribeToResult_1.subscribeToResult(_this, source, null, i);
9034 if (innerSubscription) {
9035 _this.add(innerSubscription);
9040 ForkJoinSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
9041 this.values[outerIndex] = innerValue;
9042 if (!innerSub._hasValue) {
9043 innerSub._hasValue = true;
9047 ForkJoinSubscriber.prototype.notifyComplete = function (innerSub) {
9048 var _a = this, destination = _a.destination, haveValues = _a.haveValues, values = _a.values;
9049 var len = values.length;
9050 if (!innerSub._hasValue) {
9051 destination.complete();
9055 if (this.completed !== len) {
9058 if (haveValues === len) {
9059 destination.next(values);
9061 destination.complete();
9063 return ForkJoinSubscriber;
9064 }(OuterSubscriber_1.OuterSubscriber));
9066 },{"../Observable":32,"../OuterSubscriber":34,"../operators/map":112,"../util/isArray":203,"../util/subscribeToResult":222,"./empty":49}],51:[function(require,module,exports){
9068 Object.defineProperty(exports, "__esModule", { value: true });
9069 var Observable_1 = require("../Observable");
9070 var isPromise_1 = require("../util/isPromise");
9071 var isArrayLike_1 = require("../util/isArrayLike");
9072 var isInteropObservable_1 = require("../util/isInteropObservable");
9073 var isIterable_1 = require("../util/isIterable");
9074 var fromArray_1 = require("./fromArray");
9075 var fromPromise_1 = require("./fromPromise");
9076 var fromIterable_1 = require("./fromIterable");
9077 var fromObservable_1 = require("./fromObservable");
9078 var subscribeTo_1 = require("../util/subscribeTo");
9079 function from(input, scheduler) {
9081 if (input instanceof Observable_1.Observable) {
9084 return new Observable_1.Observable(subscribeTo_1.subscribeTo(input));
9086 if (input != null) {
9087 if (isInteropObservable_1.isInteropObservable(input)) {
9088 return fromObservable_1.fromObservable(input, scheduler);
9090 else if (isPromise_1.isPromise(input)) {
9091 return fromPromise_1.fromPromise(input, scheduler);
9093 else if (isArrayLike_1.isArrayLike(input)) {
9094 return fromArray_1.fromArray(input, scheduler);
9096 else if (isIterable_1.isIterable(input) || typeof input === 'string') {
9097 return fromIterable_1.fromIterable(input, scheduler);
9100 throw new TypeError((input !== null && typeof input || input) + ' is not observable');
9102 exports.from = from;
9104 },{"../Observable":32,"../util/isArrayLike":204,"../util/isInteropObservable":207,"../util/isIterable":208,"../util/isPromise":212,"../util/subscribeTo":217,"./fromArray":52,"./fromIterable":55,"./fromObservable":56,"./fromPromise":57}],52:[function(require,module,exports){
9106 Object.defineProperty(exports, "__esModule", { value: true });
9107 var Observable_1 = require("../Observable");
9108 var Subscription_1 = require("../Subscription");
9109 var subscribeToArray_1 = require("../util/subscribeToArray");
9110 function fromArray(input, scheduler) {
9112 return new Observable_1.Observable(subscribeToArray_1.subscribeToArray(input));
9115 return new Observable_1.Observable(function (subscriber) {
9116 var sub = new Subscription_1.Subscription();
9118 sub.add(scheduler.schedule(function () {
9119 if (i === input.length) {
9120 subscriber.complete();
9123 subscriber.next(input[i++]);
9124 if (!subscriber.closed) {
9125 sub.add(this.schedule());
9132 exports.fromArray = fromArray;
9134 },{"../Observable":32,"../Subscription":40,"../util/subscribeToArray":218}],53:[function(require,module,exports){
9136 Object.defineProperty(exports, "__esModule", { value: true });
9137 var Observable_1 = require("../Observable");
9138 var isArray_1 = require("../util/isArray");
9139 var isFunction_1 = require("../util/isFunction");
9140 var map_1 = require("../operators/map");
9141 var toString = Object.prototype.toString;
9142 function fromEvent(target, eventName, options, resultSelector) {
9143 if (isFunction_1.isFunction(options)) {
9144 resultSelector = options;
9145 options = undefined;
9147 if (resultSelector) {
9148 return fromEvent(target, eventName, options).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
9150 return new Observable_1.Observable(function (subscriber) {
9151 function handler(e) {
9152 if (arguments.length > 1) {
9153 subscriber.next(Array.prototype.slice.call(arguments));
9159 setupSubscription(target, eventName, handler, subscriber, options);
9162 exports.fromEvent = fromEvent;
9163 function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
9165 if (isEventTarget(sourceObj)) {
9166 var source_1 = sourceObj;
9167 sourceObj.addEventListener(eventName, handler, options);
9168 unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
9170 else if (isJQueryStyleEventEmitter(sourceObj)) {
9171 var source_2 = sourceObj;
9172 sourceObj.on(eventName, handler);
9173 unsubscribe = function () { return source_2.off(eventName, handler); };
9175 else if (isNodeStyleEventEmitter(sourceObj)) {
9176 var source_3 = sourceObj;
9177 sourceObj.addListener(eventName, handler);
9178 unsubscribe = function () { return source_3.removeListener(eventName, handler); };
9180 else if (sourceObj && sourceObj.length) {
9181 for (var i = 0, len = sourceObj.length; i < len; i++) {
9182 setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
9186 throw new TypeError('Invalid event target');
9188 subscriber.add(unsubscribe);
9190 function isNodeStyleEventEmitter(sourceObj) {
9191 return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
9193 function isJQueryStyleEventEmitter(sourceObj) {
9194 return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
9196 function isEventTarget(sourceObj) {
9197 return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
9200 },{"../Observable":32,"../operators/map":112,"../util/isArray":203,"../util/isFunction":206}],54:[function(require,module,exports){
9202 Object.defineProperty(exports, "__esModule", { value: true });
9203 var Observable_1 = require("../Observable");
9204 var isArray_1 = require("../util/isArray");
9205 var isFunction_1 = require("../util/isFunction");
9206 var map_1 = require("../operators/map");
9207 function fromEventPattern(addHandler, removeHandler, resultSelector) {
9208 if (resultSelector) {
9209 return fromEventPattern(addHandler, removeHandler).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
9211 return new Observable_1.Observable(function (subscriber) {
9212 var handler = function () {
9214 for (var _i = 0; _i < arguments.length; _i++) {
9215 e[_i] = arguments[_i];
9217 return subscriber.next(e.length === 1 ? e[0] : e);
9221 retValue = addHandler(handler);
9224 subscriber.error(err);
9227 if (!isFunction_1.isFunction(removeHandler)) {
9230 return function () { return removeHandler(handler, retValue); };
9233 exports.fromEventPattern = fromEventPattern;
9235 },{"../Observable":32,"../operators/map":112,"../util/isArray":203,"../util/isFunction":206}],55:[function(require,module,exports){
9237 Object.defineProperty(exports, "__esModule", { value: true });
9238 var Observable_1 = require("../Observable");
9239 var Subscription_1 = require("../Subscription");
9240 var iterator_1 = require("../symbol/iterator");
9241 var subscribeToIterable_1 = require("../util/subscribeToIterable");
9242 function fromIterable(input, scheduler) {
9244 throw new Error('Iterable cannot be null');
9247 return new Observable_1.Observable(subscribeToIterable_1.subscribeToIterable(input));
9250 return new Observable_1.Observable(function (subscriber) {
9251 var sub = new Subscription_1.Subscription();
9253 sub.add(function () {
9254 if (iterator && typeof iterator.return === 'function') {
9258 sub.add(scheduler.schedule(function () {
9259 iterator = input[iterator_1.iterator]();
9260 sub.add(scheduler.schedule(function () {
9261 if (subscriber.closed) {
9267 var result = iterator.next();
9268 value = result.value;
9272 subscriber.error(err);
9276 subscriber.complete();
9279 subscriber.next(value);
9288 exports.fromIterable = fromIterable;
9290 },{"../Observable":32,"../Subscription":40,"../symbol/iterator":190,"../util/subscribeToIterable":219}],56:[function(require,module,exports){
9292 Object.defineProperty(exports, "__esModule", { value: true });
9293 var Observable_1 = require("../Observable");
9294 var Subscription_1 = require("../Subscription");
9295 var observable_1 = require("../symbol/observable");
9296 var subscribeToObservable_1 = require("../util/subscribeToObservable");
9297 function fromObservable(input, scheduler) {
9299 return new Observable_1.Observable(subscribeToObservable_1.subscribeToObservable(input));
9302 return new Observable_1.Observable(function (subscriber) {
9303 var sub = new Subscription_1.Subscription();
9304 sub.add(scheduler.schedule(function () {
9305 var observable = input[observable_1.observable]();
9306 sub.add(observable.subscribe({
9307 next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
9308 error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
9309 complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
9316 exports.fromObservable = fromObservable;
9318 },{"../Observable":32,"../Subscription":40,"../symbol/observable":191,"../util/subscribeToObservable":220}],57:[function(require,module,exports){
9320 Object.defineProperty(exports, "__esModule", { value: true });
9321 var Observable_1 = require("../Observable");
9322 var Subscription_1 = require("../Subscription");
9323 var subscribeToPromise_1 = require("../util/subscribeToPromise");
9324 function fromPromise(input, scheduler) {
9326 return new Observable_1.Observable(subscribeToPromise_1.subscribeToPromise(input));
9329 return new Observable_1.Observable(function (subscriber) {
9330 var sub = new Subscription_1.Subscription();
9331 sub.add(scheduler.schedule(function () { return input.then(function (value) {
9332 sub.add(scheduler.schedule(function () {
9333 subscriber.next(value);
9334 sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
9337 sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
9343 exports.fromPromise = fromPromise;
9345 },{"../Observable":32,"../Subscription":40,"../util/subscribeToPromise":221}],58:[function(require,module,exports){
9347 Object.defineProperty(exports, "__esModule", { value: true });
9348 var Observable_1 = require("../Observable");
9349 var identity_1 = require("../util/identity");
9350 var isScheduler_1 = require("../util/isScheduler");
9351 function generate(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
9354 if (arguments.length == 1) {
9355 var options = initialStateOrOptions;
9356 initialState = options.initialState;
9357 condition = options.condition;
9358 iterate = options.iterate;
9359 resultSelector = options.resultSelector || identity_1.identity;
9360 scheduler = options.scheduler;
9362 else if (resultSelectorOrObservable === undefined || isScheduler_1.isScheduler(resultSelectorOrObservable)) {
9363 initialState = initialStateOrOptions;
9364 resultSelector = identity_1.identity;
9365 scheduler = resultSelectorOrObservable;
9368 initialState = initialStateOrOptions;
9369 resultSelector = resultSelectorOrObservable;
9371 return new Observable_1.Observable(function (subscriber) {
9372 var state = initialState;
9374 return scheduler.schedule(dispatch, 0, {
9375 subscriber: subscriber,
9377 condition: condition,
9378 resultSelector: resultSelector,
9384 var conditionResult = void 0;
9386 conditionResult = condition(state);
9389 subscriber.error(err);
9392 if (!conditionResult) {
9393 subscriber.complete();
9399 value = resultSelector(state);
9402 subscriber.error(err);
9405 subscriber.next(value);
9406 if (subscriber.closed) {
9410 state = iterate(state);
9413 subscriber.error(err);
9420 exports.generate = generate;
9421 function dispatch(state) {
9422 var subscriber = state.subscriber, condition = state.condition;
9423 if (subscriber.closed) {
9426 if (state.needIterate) {
9428 state.state = state.iterate(state.state);
9431 subscriber.error(err);
9436 state.needIterate = true;
9439 var conditionResult = void 0;
9441 conditionResult = condition(state.state);
9444 subscriber.error(err);
9447 if (!conditionResult) {
9448 subscriber.complete();
9451 if (subscriber.closed) {
9457 value = state.resultSelector(state.state);
9460 subscriber.error(err);
9463 if (subscriber.closed) {
9466 subscriber.next(value);
9467 if (subscriber.closed) {
9470 return this.schedule(state);
9473 },{"../Observable":32,"../util/identity":202,"../util/isScheduler":213}],59:[function(require,module,exports){
9475 Object.defineProperty(exports, "__esModule", { value: true });
9476 var defer_1 = require("./defer");
9477 var empty_1 = require("./empty");
9478 function iif(condition, trueResult, falseResult) {
9479 if (trueResult === void 0) { trueResult = empty_1.EMPTY; }
9480 if (falseResult === void 0) { falseResult = empty_1.EMPTY; }
9481 return defer_1.defer(function () { return condition() ? trueResult : falseResult; });
9485 },{"./defer":48,"./empty":49}],60:[function(require,module,exports){
9487 Object.defineProperty(exports, "__esModule", { value: true });
9488 var Observable_1 = require("../Observable");
9489 var async_1 = require("../scheduler/async");
9490 var isNumeric_1 = require("../util/isNumeric");
9491 function interval(period, scheduler) {
9492 if (period === void 0) { period = 0; }
9493 if (scheduler === void 0) { scheduler = async_1.async; }
9494 if (!isNumeric_1.isNumeric(period) || period < 0) {
9497 if (!scheduler || typeof scheduler.schedule !== 'function') {
9498 scheduler = async_1.async;
9500 return new Observable_1.Observable(function (subscriber) {
9501 subscriber.add(scheduler.schedule(dispatch, period, { subscriber: subscriber, counter: 0, period: period }));
9505 exports.interval = interval;
9506 function dispatch(state) {
9507 var subscriber = state.subscriber, counter = state.counter, period = state.period;
9508 subscriber.next(counter);
9509 this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
9512 },{"../Observable":32,"../scheduler/async":188,"../util/isNumeric":209}],61:[function(require,module,exports){
9514 Object.defineProperty(exports, "__esModule", { value: true });
9515 var Observable_1 = require("../Observable");
9516 var isScheduler_1 = require("../util/isScheduler");
9517 var mergeAll_1 = require("../operators/mergeAll");
9518 var fromArray_1 = require("./fromArray");
9520 var observables = [];
9521 for (var _i = 0; _i < arguments.length; _i++) {
9522 observables[_i] = arguments[_i];
9524 var concurrent = Number.POSITIVE_INFINITY;
9525 var scheduler = null;
9526 var last = observables[observables.length - 1];
9527 if (isScheduler_1.isScheduler(last)) {
9528 scheduler = observables.pop();
9529 if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
9530 concurrent = observables.pop();
9533 else if (typeof last === 'number') {
9534 concurrent = observables.pop();
9536 if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) {
9537 return observables[0];
9539 return mergeAll_1.mergeAll(concurrent)(fromArray_1.fromArray(observables, scheduler));
9541 exports.merge = merge;
9543 },{"../Observable":32,"../operators/mergeAll":117,"../util/isScheduler":213,"./fromArray":52}],62:[function(require,module,exports){
9545 Object.defineProperty(exports, "__esModule", { value: true });
9546 var Observable_1 = require("../Observable");
9547 var noop_1 = require("../util/noop");
9548 exports.NEVER = new Observable_1.Observable(noop_1.noop);
9550 return exports.NEVER;
9552 exports.never = never;
9554 },{"../Observable":32,"../util/noop":214}],63:[function(require,module,exports){
9556 Object.defineProperty(exports, "__esModule", { value: true });
9557 var isScheduler_1 = require("../util/isScheduler");
9558 var fromArray_1 = require("./fromArray");
9559 var empty_1 = require("./empty");
9560 var scalar_1 = require("./scalar");
9563 for (var _i = 0; _i < arguments.length; _i++) {
9564 args[_i] = arguments[_i];
9566 var scheduler = args[args.length - 1];
9567 if (isScheduler_1.isScheduler(scheduler)) {
9571 scheduler = undefined;
9573 switch (args.length) {
9575 return empty_1.empty(scheduler);
9577 return scheduler ? fromArray_1.fromArray(args, scheduler) : scalar_1.scalar(args[0]);
9579 return fromArray_1.fromArray(args, scheduler);
9584 },{"../util/isScheduler":213,"./empty":49,"./fromArray":52,"./scalar":68}],64:[function(require,module,exports){
9586 Object.defineProperty(exports, "__esModule", { value: true });
9587 var Observable_1 = require("../Observable");
9588 var from_1 = require("./from");
9589 var isArray_1 = require("../util/isArray");
9590 var empty_1 = require("./empty");
9591 function onErrorResumeNext() {
9593 for (var _i = 0; _i < arguments.length; _i++) {
9594 sources[_i] = arguments[_i];
9596 if (sources.length === 0) {
9597 return empty_1.EMPTY;
9599 var first = sources[0], remainder = sources.slice(1);
9600 if (sources.length === 1 && isArray_1.isArray(first)) {
9601 return onErrorResumeNext.apply(void 0, first);
9603 return new Observable_1.Observable(function (subscriber) {
9604 var subNext = function () { return subscriber.add(onErrorResumeNext.apply(void 0, remainder).subscribe(subscriber)); };
9605 return from_1.from(first).subscribe({
9606 next: function (value) { subscriber.next(value); },
9612 exports.onErrorResumeNext = onErrorResumeNext;
9614 },{"../Observable":32,"../util/isArray":203,"./empty":49,"./from":51}],65:[function(require,module,exports){
9616 Object.defineProperty(exports, "__esModule", { value: true });
9617 var Observable_1 = require("../Observable");
9618 var Subscription_1 = require("../Subscription");
9619 function pairs(obj, scheduler) {
9621 return new Observable_1.Observable(function (subscriber) {
9622 var keys = Object.keys(obj);
9623 for (var i = 0; i < keys.length && !subscriber.closed; i++) {
9625 if (obj.hasOwnProperty(key)) {
9626 subscriber.next([key, obj[key]]);
9629 subscriber.complete();
9633 return new Observable_1.Observable(function (subscriber) {
9634 var keys = Object.keys(obj);
9635 var subscription = new Subscription_1.Subscription();
9636 subscription.add(scheduler.schedule(dispatch, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
9637 return subscription;
9641 exports.pairs = pairs;
9642 function dispatch(state) {
9643 var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
9644 if (!subscriber.closed) {
9645 if (index < keys.length) {
9646 var key = keys[index];
9647 subscriber.next([key, obj[key]]);
9648 subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
9651 subscriber.complete();
9655 exports.dispatch = dispatch;
9657 },{"../Observable":32,"../Subscription":40}],66:[function(require,module,exports){
9659 var __extends = (this && this.__extends) || (function () {
9660 var extendStatics = function (d, b) {
9661 extendStatics = Object.setPrototypeOf ||
9662 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9663 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9664 return extendStatics(d, b);
9666 return function (d, b) {
9667 extendStatics(d, b);
9668 function __() { this.constructor = d; }
9669 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9672 Object.defineProperty(exports, "__esModule", { value: true });
9673 var isArray_1 = require("../util/isArray");
9674 var fromArray_1 = require("./fromArray");
9675 var OuterSubscriber_1 = require("../OuterSubscriber");
9676 var subscribeToResult_1 = require("../util/subscribeToResult");
9678 var observables = [];
9679 for (var _i = 0; _i < arguments.length; _i++) {
9680 observables[_i] = arguments[_i];
9682 if (observables.length === 1) {
9683 if (isArray_1.isArray(observables[0])) {
9684 observables = observables[0];
9687 return observables[0];
9690 return fromArray_1.fromArray(observables, undefined).lift(new RaceOperator());
9692 exports.race = race;
9693 var RaceOperator = (function () {
9694 function RaceOperator() {
9696 RaceOperator.prototype.call = function (subscriber, source) {
9697 return source.subscribe(new RaceSubscriber(subscriber));
9699 return RaceOperator;
9701 exports.RaceOperator = RaceOperator;
9702 var RaceSubscriber = (function (_super) {
9703 __extends(RaceSubscriber, _super);
9704 function RaceSubscriber(destination) {
9705 var _this = _super.call(this, destination) || this;
9706 _this.hasFirst = false;
9707 _this.observables = [];
9708 _this.subscriptions = [];
9711 RaceSubscriber.prototype._next = function (observable) {
9712 this.observables.push(observable);
9714 RaceSubscriber.prototype._complete = function () {
9715 var observables = this.observables;
9716 var len = observables.length;
9718 this.destination.complete();
9721 for (var i = 0; i < len && !this.hasFirst; i++) {
9722 var observable = observables[i];
9723 var subscription = subscribeToResult_1.subscribeToResult(this, observable, observable, i);
9724 if (this.subscriptions) {
9725 this.subscriptions.push(subscription);
9727 this.add(subscription);
9729 this.observables = null;
9732 RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
9733 if (!this.hasFirst) {
9734 this.hasFirst = true;
9735 for (var i = 0; i < this.subscriptions.length; i++) {
9736 if (i !== outerIndex) {
9737 var subscription = this.subscriptions[i];
9738 subscription.unsubscribe();
9739 this.remove(subscription);
9742 this.subscriptions = null;
9744 this.destination.next(innerValue);
9746 return RaceSubscriber;
9747 }(OuterSubscriber_1.OuterSubscriber));
9748 exports.RaceSubscriber = RaceSubscriber;
9750 },{"../OuterSubscriber":34,"../util/isArray":203,"../util/subscribeToResult":222,"./fromArray":52}],67:[function(require,module,exports){
9752 Object.defineProperty(exports, "__esModule", { value: true });
9753 var Observable_1 = require("../Observable");
9754 function range(start, count, scheduler) {
9755 if (start === void 0) { start = 0; }
9756 if (count === void 0) { count = 0; }
9757 return new Observable_1.Observable(function (subscriber) {
9759 var current = start;
9761 return scheduler.schedule(dispatch, 0, {
9762 index: index, count: count, start: start, subscriber: subscriber
9767 if (index++ >= count) {
9768 subscriber.complete();
9771 subscriber.next(current++);
9772 if (subscriber.closed) {
9780 exports.range = range;
9781 function dispatch(state) {
9782 var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
9783 if (index >= count) {
9784 subscriber.complete();
9787 subscriber.next(start);
9788 if (subscriber.closed) {
9791 state.index = index + 1;
9792 state.start = start + 1;
9793 this.schedule(state);
9795 exports.dispatch = dispatch;
9797 },{"../Observable":32}],68:[function(require,module,exports){
9799 Object.defineProperty(exports, "__esModule", { value: true });
9800 var Observable_1 = require("../Observable");
9801 function scalar(value) {
9802 var result = new Observable_1.Observable(function (subscriber) {
9803 subscriber.next(value);
9804 subscriber.complete();
9806 result._isScalar = true;
9807 result.value = value;
9810 exports.scalar = scalar;
9812 },{"../Observable":32}],69:[function(require,module,exports){
9814 Object.defineProperty(exports, "__esModule", { value: true });
9815 var Observable_1 = require("../Observable");
9816 function throwError(error, scheduler) {
9818 return new Observable_1.Observable(function (subscriber) { return subscriber.error(error); });
9821 return new Observable_1.Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });
9824 exports.throwError = throwError;
9825 function dispatch(_a) {
9826 var error = _a.error, subscriber = _a.subscriber;
9827 subscriber.error(error);
9830 },{"../Observable":32}],70:[function(require,module,exports){
9832 Object.defineProperty(exports, "__esModule", { value: true });
9833 var Observable_1 = require("../Observable");
9834 var async_1 = require("../scheduler/async");
9835 var isNumeric_1 = require("../util/isNumeric");
9836 var isScheduler_1 = require("../util/isScheduler");
9837 function timer(dueTime, periodOrScheduler, scheduler) {
9838 if (dueTime === void 0) { dueTime = 0; }
9840 if (isNumeric_1.isNumeric(periodOrScheduler)) {
9841 period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
9843 else if (isScheduler_1.isScheduler(periodOrScheduler)) {
9844 scheduler = periodOrScheduler;
9846 if (!isScheduler_1.isScheduler(scheduler)) {
9847 scheduler = async_1.async;
9849 return new Observable_1.Observable(function (subscriber) {
9850 var due = isNumeric_1.isNumeric(dueTime)
9852 : (+dueTime - scheduler.now());
9853 return scheduler.schedule(dispatch, due, {
9854 index: 0, period: period, subscriber: subscriber
9858 exports.timer = timer;
9859 function dispatch(state) {
9860 var index = state.index, period = state.period, subscriber = state.subscriber;
9861 subscriber.next(index);
9862 if (subscriber.closed) {
9865 else if (period === -1) {
9866 return subscriber.complete();
9868 state.index = index + 1;
9869 this.schedule(state, period);
9872 },{"../Observable":32,"../scheduler/async":188,"../util/isNumeric":209,"../util/isScheduler":213}],71:[function(require,module,exports){
9874 Object.defineProperty(exports, "__esModule", { value: true });
9875 var Observable_1 = require("../Observable");
9876 var from_1 = require("./from");
9877 var empty_1 = require("./empty");
9878 function using(resourceFactory, observableFactory) {
9879 return new Observable_1.Observable(function (subscriber) {
9882 resource = resourceFactory();
9885 subscriber.error(err);
9890 result = observableFactory(resource);
9893 subscriber.error(err);
9896 var source = result ? from_1.from(result) : empty_1.EMPTY;
9897 var subscription = source.subscribe(subscriber);
9898 return function () {
9899 subscription.unsubscribe();
9901 resource.unsubscribe();
9906 exports.using = using;
9908 },{"../Observable":32,"./empty":49,"./from":51}],72:[function(require,module,exports){
9910 var __extends = (this && this.__extends) || (function () {
9911 var extendStatics = function (d, b) {
9912 extendStatics = Object.setPrototypeOf ||
9913 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9914 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9915 return extendStatics(d, b);
9917 return function (d, b) {
9918 extendStatics(d, b);
9919 function __() { this.constructor = d; }
9920 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9923 Object.defineProperty(exports, "__esModule", { value: true });
9924 var fromArray_1 = require("./fromArray");
9925 var isArray_1 = require("../util/isArray");
9926 var Subscriber_1 = require("../Subscriber");
9927 var OuterSubscriber_1 = require("../OuterSubscriber");
9928 var subscribeToResult_1 = require("../util/subscribeToResult");
9929 var iterator_1 = require("../../internal/symbol/iterator");
9931 var observables = [];
9932 for (var _i = 0; _i < arguments.length; _i++) {
9933 observables[_i] = arguments[_i];
9935 var resultSelector = observables[observables.length - 1];
9936 if (typeof resultSelector === 'function') {
9939 return fromArray_1.fromArray(observables, undefined).lift(new ZipOperator(resultSelector));
9942 var ZipOperator = (function () {
9943 function ZipOperator(resultSelector) {
9944 this.resultSelector = resultSelector;
9946 ZipOperator.prototype.call = function (subscriber, source) {
9947 return source.subscribe(new ZipSubscriber(subscriber, this.resultSelector));
9951 exports.ZipOperator = ZipOperator;
9952 var ZipSubscriber = (function (_super) {
9953 __extends(ZipSubscriber, _super);
9954 function ZipSubscriber(destination, resultSelector, values) {
9955 if (values === void 0) { values = Object.create(null); }
9956 var _this = _super.call(this, destination) || this;
9957 _this.iterators = [];
9959 _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : null;
9960 _this.values = values;
9963 ZipSubscriber.prototype._next = function (value) {
9964 var iterators = this.iterators;
9965 if (isArray_1.isArray(value)) {
9966 iterators.push(new StaticArrayIterator(value));
9968 else if (typeof value[iterator_1.iterator] === 'function') {
9969 iterators.push(new StaticIterator(value[iterator_1.iterator]()));
9972 iterators.push(new ZipBufferIterator(this.destination, this, value));
9975 ZipSubscriber.prototype._complete = function () {
9976 var iterators = this.iterators;
9977 var len = iterators.length;
9980 this.destination.complete();
9984 for (var i = 0; i < len; i++) {
9985 var iterator = iterators[i];
9986 if (iterator.stillUnsubscribed) {
9987 var destination = this.destination;
9988 destination.add(iterator.subscribe(iterator, i));
9995 ZipSubscriber.prototype.notifyInactive = function () {
9997 if (this.active === 0) {
9998 this.destination.complete();
10001 ZipSubscriber.prototype.checkIterators = function () {
10002 var iterators = this.iterators;
10003 var len = iterators.length;
10004 var destination = this.destination;
10005 for (var i = 0; i < len; i++) {
10006 var iterator = iterators[i];
10007 if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) {
10011 var shouldComplete = false;
10013 for (var i = 0; i < len; i++) {
10014 var iterator = iterators[i];
10015 var result = iterator.next();
10016 if (iterator.hasCompleted()) {
10017 shouldComplete = true;
10020 destination.complete();
10023 args.push(result.value);
10025 if (this.resultSelector) {
10026 this._tryresultSelector(args);
10029 destination.next(args);
10031 if (shouldComplete) {
10032 destination.complete();
10035 ZipSubscriber.prototype._tryresultSelector = function (args) {
10038 result = this.resultSelector.apply(this, args);
10041 this.destination.error(err);
10044 this.destination.next(result);
10046 return ZipSubscriber;
10047 }(Subscriber_1.Subscriber));
10048 exports.ZipSubscriber = ZipSubscriber;
10049 var StaticIterator = (function () {
10050 function StaticIterator(iterator) {
10051 this.iterator = iterator;
10052 this.nextResult = iterator.next();
10054 StaticIterator.prototype.hasValue = function () {
10057 StaticIterator.prototype.next = function () {
10058 var result = this.nextResult;
10059 this.nextResult = this.iterator.next();
10062 StaticIterator.prototype.hasCompleted = function () {
10063 var nextResult = this.nextResult;
10064 return nextResult && nextResult.done;
10066 return StaticIterator;
10068 var StaticArrayIterator = (function () {
10069 function StaticArrayIterator(array) {
10070 this.array = array;
10073 this.length = array.length;
10075 StaticArrayIterator.prototype[iterator_1.iterator] = function () {
10078 StaticArrayIterator.prototype.next = function (value) {
10079 var i = this.index++;
10080 var array = this.array;
10081 return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
10083 StaticArrayIterator.prototype.hasValue = function () {
10084 return this.array.length > this.index;
10086 StaticArrayIterator.prototype.hasCompleted = function () {
10087 return this.array.length === this.index;
10089 return StaticArrayIterator;
10091 var ZipBufferIterator = (function (_super) {
10092 __extends(ZipBufferIterator, _super);
10093 function ZipBufferIterator(destination, parent, observable) {
10094 var _this = _super.call(this, destination) || this;
10095 _this.parent = parent;
10096 _this.observable = observable;
10097 _this.stillUnsubscribed = true;
10099 _this.isComplete = false;
10102 ZipBufferIterator.prototype[iterator_1.iterator] = function () {
10105 ZipBufferIterator.prototype.next = function () {
10106 var buffer = this.buffer;
10107 if (buffer.length === 0 && this.isComplete) {
10108 return { value: null, done: true };
10111 return { value: buffer.shift(), done: false };
10114 ZipBufferIterator.prototype.hasValue = function () {
10115 return this.buffer.length > 0;
10117 ZipBufferIterator.prototype.hasCompleted = function () {
10118 return this.buffer.length === 0 && this.isComplete;
10120 ZipBufferIterator.prototype.notifyComplete = function () {
10121 if (this.buffer.length > 0) {
10122 this.isComplete = true;
10123 this.parent.notifyInactive();
10126 this.destination.complete();
10129 ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10130 this.buffer.push(innerValue);
10131 this.parent.checkIterators();
10133 ZipBufferIterator.prototype.subscribe = function (value, index) {
10134 return subscribeToResult_1.subscribeToResult(this, this.observable, this, index);
10136 return ZipBufferIterator;
10137 }(OuterSubscriber_1.OuterSubscriber));
10139 },{"../../internal/symbol/iterator":190,"../OuterSubscriber":34,"../Subscriber":39,"../util/isArray":203,"../util/subscribeToResult":222,"./fromArray":52}],73:[function(require,module,exports){
10141 var __extends = (this && this.__extends) || (function () {
10142 var extendStatics = function (d, b) {
10143 extendStatics = Object.setPrototypeOf ||
10144 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10145 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10146 return extendStatics(d, b);
10148 return function (d, b) {
10149 extendStatics(d, b);
10150 function __() { this.constructor = d; }
10151 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10154 Object.defineProperty(exports, "__esModule", { value: true });
10155 var tryCatch_1 = require("../util/tryCatch");
10156 var errorObject_1 = require("../util/errorObject");
10157 var OuterSubscriber_1 = require("../OuterSubscriber");
10158 var subscribeToResult_1 = require("../util/subscribeToResult");
10159 function audit(durationSelector) {
10160 return function auditOperatorFunction(source) {
10161 return source.lift(new AuditOperator(durationSelector));
10164 exports.audit = audit;
10165 var AuditOperator = (function () {
10166 function AuditOperator(durationSelector) {
10167 this.durationSelector = durationSelector;
10169 AuditOperator.prototype.call = function (subscriber, source) {
10170 return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
10172 return AuditOperator;
10174 var AuditSubscriber = (function (_super) {
10175 __extends(AuditSubscriber, _super);
10176 function AuditSubscriber(destination, durationSelector) {
10177 var _this = _super.call(this, destination) || this;
10178 _this.durationSelector = durationSelector;
10179 _this.hasValue = false;
10182 AuditSubscriber.prototype._next = function (value) {
10183 this.value = value;
10184 this.hasValue = true;
10185 if (!this.throttled) {
10186 var duration = tryCatch_1.tryCatch(this.durationSelector)(value);
10187 if (duration === errorObject_1.errorObject) {
10188 this.destination.error(errorObject_1.errorObject.e);
10191 var innerSubscription = subscribeToResult_1.subscribeToResult(this, duration);
10192 if (!innerSubscription || innerSubscription.closed) {
10193 this.clearThrottle();
10196 this.add(this.throttled = innerSubscription);
10201 AuditSubscriber.prototype.clearThrottle = function () {
10202 var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
10204 this.remove(throttled);
10205 this.throttled = null;
10206 throttled.unsubscribe();
10210 this.hasValue = false;
10211 this.destination.next(value);
10214 AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
10215 this.clearThrottle();
10217 AuditSubscriber.prototype.notifyComplete = function () {
10218 this.clearThrottle();
10220 return AuditSubscriber;
10221 }(OuterSubscriber_1.OuterSubscriber));
10223 },{"../OuterSubscriber":34,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],74:[function(require,module,exports){
10225 Object.defineProperty(exports, "__esModule", { value: true });
10226 var async_1 = require("../scheduler/async");
10227 var audit_1 = require("./audit");
10228 var timer_1 = require("../observable/timer");
10229 function auditTime(duration, scheduler) {
10230 if (scheduler === void 0) { scheduler = async_1.async; }
10231 return audit_1.audit(function () { return timer_1.timer(duration, scheduler); });
10233 exports.auditTime = auditTime;
10235 },{"../observable/timer":70,"../scheduler/async":188,"./audit":73}],75:[function(require,module,exports){
10237 var __extends = (this && this.__extends) || (function () {
10238 var extendStatics = function (d, b) {
10239 extendStatics = Object.setPrototypeOf ||
10240 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10241 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10242 return extendStatics(d, b);
10244 return function (d, b) {
10245 extendStatics(d, b);
10246 function __() { this.constructor = d; }
10247 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10250 Object.defineProperty(exports, "__esModule", { value: true });
10251 var OuterSubscriber_1 = require("../OuterSubscriber");
10252 var subscribeToResult_1 = require("../util/subscribeToResult");
10253 function buffer(closingNotifier) {
10254 return function bufferOperatorFunction(source) {
10255 return source.lift(new BufferOperator(closingNotifier));
10258 exports.buffer = buffer;
10259 var BufferOperator = (function () {
10260 function BufferOperator(closingNotifier) {
10261 this.closingNotifier = closingNotifier;
10263 BufferOperator.prototype.call = function (subscriber, source) {
10264 return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
10266 return BufferOperator;
10268 var BufferSubscriber = (function (_super) {
10269 __extends(BufferSubscriber, _super);
10270 function BufferSubscriber(destination, closingNotifier) {
10271 var _this = _super.call(this, destination) || this;
10273 _this.add(subscribeToResult_1.subscribeToResult(_this, closingNotifier));
10276 BufferSubscriber.prototype._next = function (value) {
10277 this.buffer.push(value);
10279 BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10280 var buffer = this.buffer;
10282 this.destination.next(buffer);
10284 return BufferSubscriber;
10285 }(OuterSubscriber_1.OuterSubscriber));
10287 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],76:[function(require,module,exports){
10289 var __extends = (this && this.__extends) || (function () {
10290 var extendStatics = function (d, b) {
10291 extendStatics = Object.setPrototypeOf ||
10292 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10293 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10294 return extendStatics(d, b);
10296 return function (d, b) {
10297 extendStatics(d, b);
10298 function __() { this.constructor = d; }
10299 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10302 Object.defineProperty(exports, "__esModule", { value: true });
10303 var Subscriber_1 = require("../Subscriber");
10304 function bufferCount(bufferSize, startBufferEvery) {
10305 if (startBufferEvery === void 0) { startBufferEvery = null; }
10306 return function bufferCountOperatorFunction(source) {
10307 return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
10310 exports.bufferCount = bufferCount;
10311 var BufferCountOperator = (function () {
10312 function BufferCountOperator(bufferSize, startBufferEvery) {
10313 this.bufferSize = bufferSize;
10314 this.startBufferEvery = startBufferEvery;
10315 if (!startBufferEvery || bufferSize === startBufferEvery) {
10316 this.subscriberClass = BufferCountSubscriber;
10319 this.subscriberClass = BufferSkipCountSubscriber;
10322 BufferCountOperator.prototype.call = function (subscriber, source) {
10323 return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
10325 return BufferCountOperator;
10327 var BufferCountSubscriber = (function (_super) {
10328 __extends(BufferCountSubscriber, _super);
10329 function BufferCountSubscriber(destination, bufferSize) {
10330 var _this = _super.call(this, destination) || this;
10331 _this.bufferSize = bufferSize;
10335 BufferCountSubscriber.prototype._next = function (value) {
10336 var buffer = this.buffer;
10337 buffer.push(value);
10338 if (buffer.length == this.bufferSize) {
10339 this.destination.next(buffer);
10343 BufferCountSubscriber.prototype._complete = function () {
10344 var buffer = this.buffer;
10345 if (buffer.length > 0) {
10346 this.destination.next(buffer);
10348 _super.prototype._complete.call(this);
10350 return BufferCountSubscriber;
10351 }(Subscriber_1.Subscriber));
10352 var BufferSkipCountSubscriber = (function (_super) {
10353 __extends(BufferSkipCountSubscriber, _super);
10354 function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
10355 var _this = _super.call(this, destination) || this;
10356 _this.bufferSize = bufferSize;
10357 _this.startBufferEvery = startBufferEvery;
10358 _this.buffers = [];
10362 BufferSkipCountSubscriber.prototype._next = function (value) {
10363 var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
10365 if (count % startBufferEvery === 0) {
10368 for (var i = buffers.length; i--;) {
10369 var buffer = buffers[i];
10370 buffer.push(value);
10371 if (buffer.length === bufferSize) {
10372 buffers.splice(i, 1);
10373 this.destination.next(buffer);
10377 BufferSkipCountSubscriber.prototype._complete = function () {
10378 var _a = this, buffers = _a.buffers, destination = _a.destination;
10379 while (buffers.length > 0) {
10380 var buffer = buffers.shift();
10381 if (buffer.length > 0) {
10382 destination.next(buffer);
10385 _super.prototype._complete.call(this);
10387 return BufferSkipCountSubscriber;
10388 }(Subscriber_1.Subscriber));
10390 },{"../Subscriber":39}],77:[function(require,module,exports){
10392 var __extends = (this && this.__extends) || (function () {
10393 var extendStatics = function (d, b) {
10394 extendStatics = Object.setPrototypeOf ||
10395 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10396 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10397 return extendStatics(d, b);
10399 return function (d, b) {
10400 extendStatics(d, b);
10401 function __() { this.constructor = d; }
10402 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10405 Object.defineProperty(exports, "__esModule", { value: true });
10406 var async_1 = require("../scheduler/async");
10407 var Subscriber_1 = require("../Subscriber");
10408 var isScheduler_1 = require("../util/isScheduler");
10409 function bufferTime(bufferTimeSpan) {
10410 var length = arguments.length;
10411 var scheduler = async_1.async;
10412 if (isScheduler_1.isScheduler(arguments[arguments.length - 1])) {
10413 scheduler = arguments[arguments.length - 1];
10416 var bufferCreationInterval = null;
10418 bufferCreationInterval = arguments[1];
10420 var maxBufferSize = Number.POSITIVE_INFINITY;
10422 maxBufferSize = arguments[2];
10424 return function bufferTimeOperatorFunction(source) {
10425 return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
10428 exports.bufferTime = bufferTime;
10429 var BufferTimeOperator = (function () {
10430 function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
10431 this.bufferTimeSpan = bufferTimeSpan;
10432 this.bufferCreationInterval = bufferCreationInterval;
10433 this.maxBufferSize = maxBufferSize;
10434 this.scheduler = scheduler;
10436 BufferTimeOperator.prototype.call = function (subscriber, source) {
10437 return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
10439 return BufferTimeOperator;
10441 var Context = (function () {
10442 function Context() {
10447 var BufferTimeSubscriber = (function (_super) {
10448 __extends(BufferTimeSubscriber, _super);
10449 function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
10450 var _this = _super.call(this, destination) || this;
10451 _this.bufferTimeSpan = bufferTimeSpan;
10452 _this.bufferCreationInterval = bufferCreationInterval;
10453 _this.maxBufferSize = maxBufferSize;
10454 _this.scheduler = scheduler;
10455 _this.contexts = [];
10456 var context = _this.openContext();
10457 _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
10458 if (_this.timespanOnly) {
10459 var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
10460 _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
10463 var closeState = { subscriber: _this, context: context };
10464 var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
10465 _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
10466 _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
10470 BufferTimeSubscriber.prototype._next = function (value) {
10471 var contexts = this.contexts;
10472 var len = contexts.length;
10473 var filledBufferContext;
10474 for (var i = 0; i < len; i++) {
10475 var context_1 = contexts[i];
10476 var buffer = context_1.buffer;
10477 buffer.push(value);
10478 if (buffer.length == this.maxBufferSize) {
10479 filledBufferContext = context_1;
10482 if (filledBufferContext) {
10483 this.onBufferFull(filledBufferContext);
10486 BufferTimeSubscriber.prototype._error = function (err) {
10487 this.contexts.length = 0;
10488 _super.prototype._error.call(this, err);
10490 BufferTimeSubscriber.prototype._complete = function () {
10491 var _a = this, contexts = _a.contexts, destination = _a.destination;
10492 while (contexts.length > 0) {
10493 var context_2 = contexts.shift();
10494 destination.next(context_2.buffer);
10496 _super.prototype._complete.call(this);
10498 BufferTimeSubscriber.prototype._unsubscribe = function () {
10499 this.contexts = null;
10501 BufferTimeSubscriber.prototype.onBufferFull = function (context) {
10502 this.closeContext(context);
10503 var closeAction = context.closeAction;
10504 closeAction.unsubscribe();
10505 this.remove(closeAction);
10506 if (!this.closed && this.timespanOnly) {
10507 context = this.openContext();
10508 var bufferTimeSpan = this.bufferTimeSpan;
10509 var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
10510 this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
10513 BufferTimeSubscriber.prototype.openContext = function () {
10514 var context = new Context();
10515 this.contexts.push(context);
10518 BufferTimeSubscriber.prototype.closeContext = function (context) {
10519 this.destination.next(context.buffer);
10520 var contexts = this.contexts;
10521 var spliceIndex = contexts ? contexts.indexOf(context) : -1;
10522 if (spliceIndex >= 0) {
10523 contexts.splice(contexts.indexOf(context), 1);
10526 return BufferTimeSubscriber;
10527 }(Subscriber_1.Subscriber));
10528 function dispatchBufferTimeSpanOnly(state) {
10529 var subscriber = state.subscriber;
10530 var prevContext = state.context;
10532 subscriber.closeContext(prevContext);
10534 if (!subscriber.closed) {
10535 state.context = subscriber.openContext();
10536 state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
10539 function dispatchBufferCreation(state) {
10540 var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
10541 var context = subscriber.openContext();
10543 if (!subscriber.closed) {
10544 subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
10545 action.schedule(state, bufferCreationInterval);
10548 function dispatchBufferClose(arg) {
10549 var subscriber = arg.subscriber, context = arg.context;
10550 subscriber.closeContext(context);
10553 },{"../Subscriber":39,"../scheduler/async":188,"../util/isScheduler":213}],78:[function(require,module,exports){
10555 var __extends = (this && this.__extends) || (function () {
10556 var extendStatics = function (d, b) {
10557 extendStatics = Object.setPrototypeOf ||
10558 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10559 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10560 return extendStatics(d, b);
10562 return function (d, b) {
10563 extendStatics(d, b);
10564 function __() { this.constructor = d; }
10565 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10568 Object.defineProperty(exports, "__esModule", { value: true });
10569 var Subscription_1 = require("../Subscription");
10570 var subscribeToResult_1 = require("../util/subscribeToResult");
10571 var OuterSubscriber_1 = require("../OuterSubscriber");
10572 function bufferToggle(openings, closingSelector) {
10573 return function bufferToggleOperatorFunction(source) {
10574 return source.lift(new BufferToggleOperator(openings, closingSelector));
10577 exports.bufferToggle = bufferToggle;
10578 var BufferToggleOperator = (function () {
10579 function BufferToggleOperator(openings, closingSelector) {
10580 this.openings = openings;
10581 this.closingSelector = closingSelector;
10583 BufferToggleOperator.prototype.call = function (subscriber, source) {
10584 return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
10586 return BufferToggleOperator;
10588 var BufferToggleSubscriber = (function (_super) {
10589 __extends(BufferToggleSubscriber, _super);
10590 function BufferToggleSubscriber(destination, openings, closingSelector) {
10591 var _this = _super.call(this, destination) || this;
10592 _this.openings = openings;
10593 _this.closingSelector = closingSelector;
10594 _this.contexts = [];
10595 _this.add(subscribeToResult_1.subscribeToResult(_this, openings));
10598 BufferToggleSubscriber.prototype._next = function (value) {
10599 var contexts = this.contexts;
10600 var len = contexts.length;
10601 for (var i = 0; i < len; i++) {
10602 contexts[i].buffer.push(value);
10605 BufferToggleSubscriber.prototype._error = function (err) {
10606 var contexts = this.contexts;
10607 while (contexts.length > 0) {
10608 var context_1 = contexts.shift();
10609 context_1.subscription.unsubscribe();
10610 context_1.buffer = null;
10611 context_1.subscription = null;
10613 this.contexts = null;
10614 _super.prototype._error.call(this, err);
10616 BufferToggleSubscriber.prototype._complete = function () {
10617 var contexts = this.contexts;
10618 while (contexts.length > 0) {
10619 var context_2 = contexts.shift();
10620 this.destination.next(context_2.buffer);
10621 context_2.subscription.unsubscribe();
10622 context_2.buffer = null;
10623 context_2.subscription = null;
10625 this.contexts = null;
10626 _super.prototype._complete.call(this);
10628 BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10629 outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
10631 BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
10632 this.closeBuffer(innerSub.context);
10634 BufferToggleSubscriber.prototype.openBuffer = function (value) {
10636 var closingSelector = this.closingSelector;
10637 var closingNotifier = closingSelector.call(this, value);
10638 if (closingNotifier) {
10639 this.trySubscribe(closingNotifier);
10646 BufferToggleSubscriber.prototype.closeBuffer = function (context) {
10647 var contexts = this.contexts;
10648 if (contexts && context) {
10649 var buffer = context.buffer, subscription = context.subscription;
10650 this.destination.next(buffer);
10651 contexts.splice(contexts.indexOf(context), 1);
10652 this.remove(subscription);
10653 subscription.unsubscribe();
10656 BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
10657 var contexts = this.contexts;
10659 var subscription = new Subscription_1.Subscription();
10660 var context = { buffer: buffer, subscription: subscription };
10661 contexts.push(context);
10662 var innerSubscription = subscribeToResult_1.subscribeToResult(this, closingNotifier, context);
10663 if (!innerSubscription || innerSubscription.closed) {
10664 this.closeBuffer(context);
10667 innerSubscription.context = context;
10668 this.add(innerSubscription);
10669 subscription.add(innerSubscription);
10672 return BufferToggleSubscriber;
10673 }(OuterSubscriber_1.OuterSubscriber));
10675 },{"../OuterSubscriber":34,"../Subscription":40,"../util/subscribeToResult":222}],79:[function(require,module,exports){
10677 var __extends = (this && this.__extends) || (function () {
10678 var extendStatics = function (d, b) {
10679 extendStatics = Object.setPrototypeOf ||
10680 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10681 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10682 return extendStatics(d, b);
10684 return function (d, b) {
10685 extendStatics(d, b);
10686 function __() { this.constructor = d; }
10687 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10690 Object.defineProperty(exports, "__esModule", { value: true });
10691 var Subscription_1 = require("../Subscription");
10692 var tryCatch_1 = require("../util/tryCatch");
10693 var errorObject_1 = require("../util/errorObject");
10694 var OuterSubscriber_1 = require("../OuterSubscriber");
10695 var subscribeToResult_1 = require("../util/subscribeToResult");
10696 function bufferWhen(closingSelector) {
10697 return function (source) {
10698 return source.lift(new BufferWhenOperator(closingSelector));
10701 exports.bufferWhen = bufferWhen;
10702 var BufferWhenOperator = (function () {
10703 function BufferWhenOperator(closingSelector) {
10704 this.closingSelector = closingSelector;
10706 BufferWhenOperator.prototype.call = function (subscriber, source) {
10707 return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
10709 return BufferWhenOperator;
10711 var BufferWhenSubscriber = (function (_super) {
10712 __extends(BufferWhenSubscriber, _super);
10713 function BufferWhenSubscriber(destination, closingSelector) {
10714 var _this = _super.call(this, destination) || this;
10715 _this.closingSelector = closingSelector;
10716 _this.subscribing = false;
10717 _this.openBuffer();
10720 BufferWhenSubscriber.prototype._next = function (value) {
10721 this.buffer.push(value);
10723 BufferWhenSubscriber.prototype._complete = function () {
10724 var buffer = this.buffer;
10726 this.destination.next(buffer);
10728 _super.prototype._complete.call(this);
10730 BufferWhenSubscriber.prototype._unsubscribe = function () {
10731 this.buffer = null;
10732 this.subscribing = false;
10734 BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10737 BufferWhenSubscriber.prototype.notifyComplete = function () {
10738 if (this.subscribing) {
10745 BufferWhenSubscriber.prototype.openBuffer = function () {
10746 var closingSubscription = this.closingSubscription;
10747 if (closingSubscription) {
10748 this.remove(closingSubscription);
10749 closingSubscription.unsubscribe();
10751 var buffer = this.buffer;
10753 this.destination.next(buffer);
10756 var closingNotifier = tryCatch_1.tryCatch(this.closingSelector)();
10757 if (closingNotifier === errorObject_1.errorObject) {
10758 this.error(errorObject_1.errorObject.e);
10761 closingSubscription = new Subscription_1.Subscription();
10762 this.closingSubscription = closingSubscription;
10763 this.add(closingSubscription);
10764 this.subscribing = true;
10765 closingSubscription.add(subscribeToResult_1.subscribeToResult(this, closingNotifier));
10766 this.subscribing = false;
10769 return BufferWhenSubscriber;
10770 }(OuterSubscriber_1.OuterSubscriber));
10772 },{"../OuterSubscriber":34,"../Subscription":40,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],80:[function(require,module,exports){
10774 var __extends = (this && this.__extends) || (function () {
10775 var extendStatics = function (d, b) {
10776 extendStatics = Object.setPrototypeOf ||
10777 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10778 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10779 return extendStatics(d, b);
10781 return function (d, b) {
10782 extendStatics(d, b);
10783 function __() { this.constructor = d; }
10784 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10787 Object.defineProperty(exports, "__esModule", { value: true });
10788 var OuterSubscriber_1 = require("../OuterSubscriber");
10789 var InnerSubscriber_1 = require("../InnerSubscriber");
10790 var subscribeToResult_1 = require("../util/subscribeToResult");
10791 function catchError(selector) {
10792 return function catchErrorOperatorFunction(source) {
10793 var operator = new CatchOperator(selector);
10794 var caught = source.lift(operator);
10795 return (operator.caught = caught);
10798 exports.catchError = catchError;
10799 var CatchOperator = (function () {
10800 function CatchOperator(selector) {
10801 this.selector = selector;
10803 CatchOperator.prototype.call = function (subscriber, source) {
10804 return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
10806 return CatchOperator;
10808 var CatchSubscriber = (function (_super) {
10809 __extends(CatchSubscriber, _super);
10810 function CatchSubscriber(destination, selector, caught) {
10811 var _this = _super.call(this, destination) || this;
10812 _this.selector = selector;
10813 _this.caught = caught;
10816 CatchSubscriber.prototype.error = function (err) {
10817 if (!this.isStopped) {
10818 var result = void 0;
10820 result = this.selector(err, this.caught);
10823 _super.prototype.error.call(this, err2);
10826 this._unsubscribeAndRecycle();
10827 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
10828 this.add(innerSubscriber);
10829 subscribeToResult_1.subscribeToResult(this, result, undefined, undefined, innerSubscriber);
10832 return CatchSubscriber;
10833 }(OuterSubscriber_1.OuterSubscriber));
10835 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../util/subscribeToResult":222}],81:[function(require,module,exports){
10837 Object.defineProperty(exports, "__esModule", { value: true });
10838 var combineLatest_1 = require("../observable/combineLatest");
10839 function combineAll(project) {
10840 return function (source) { return source.lift(new combineLatest_1.CombineLatestOperator(project)); };
10842 exports.combineAll = combineAll;
10844 },{"../observable/combineLatest":46}],82:[function(require,module,exports){
10846 Object.defineProperty(exports, "__esModule", { value: true });
10847 var isArray_1 = require("../util/isArray");
10848 var combineLatest_1 = require("../observable/combineLatest");
10849 var from_1 = require("../observable/from");
10851 function combineLatest() {
10852 var observables = [];
10853 for (var _i = 0; _i < arguments.length; _i++) {
10854 observables[_i] = arguments[_i];
10856 var project = null;
10857 if (typeof observables[observables.length - 1] === 'function') {
10858 project = observables.pop();
10860 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
10861 observables = observables[0].slice();
10863 return function (source) { return source.lift.call(from_1.from([source].concat(observables)), new combineLatest_1.CombineLatestOperator(project)); };
10865 exports.combineLatest = combineLatest;
10867 },{"../observable/combineLatest":46,"../observable/from":51,"../util/isArray":203}],83:[function(require,module,exports){
10869 Object.defineProperty(exports, "__esModule", { value: true });
10870 var concat_1 = require("../observable/concat");
10871 function concat() {
10872 var observables = [];
10873 for (var _i = 0; _i < arguments.length; _i++) {
10874 observables[_i] = arguments[_i];
10876 return function (source) { return source.lift.call(concat_1.concat.apply(void 0, [source].concat(observables))); };
10878 exports.concat = concat;
10880 },{"../observable/concat":47}],84:[function(require,module,exports){
10882 Object.defineProperty(exports, "__esModule", { value: true });
10883 var mergeAll_1 = require("./mergeAll");
10884 function concatAll() {
10885 return mergeAll_1.mergeAll(1);
10887 exports.concatAll = concatAll;
10889 },{"./mergeAll":117}],85:[function(require,module,exports){
10891 Object.defineProperty(exports, "__esModule", { value: true });
10892 var mergeMap_1 = require("./mergeMap");
10893 function concatMap(project, resultSelector) {
10894 return mergeMap_1.mergeMap(project, resultSelector, 1);
10896 exports.concatMap = concatMap;
10898 },{"./mergeMap":118}],86:[function(require,module,exports){
10900 Object.defineProperty(exports, "__esModule", { value: true });
10901 var concatMap_1 = require("./concatMap");
10902 function concatMapTo(innerObservable, resultSelector) {
10903 return concatMap_1.concatMap(function () { return innerObservable; }, resultSelector);
10905 exports.concatMapTo = concatMapTo;
10907 },{"./concatMap":85}],87:[function(require,module,exports){
10909 var __extends = (this && this.__extends) || (function () {
10910 var extendStatics = function (d, b) {
10911 extendStatics = Object.setPrototypeOf ||
10912 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10913 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10914 return extendStatics(d, b);
10916 return function (d, b) {
10917 extendStatics(d, b);
10918 function __() { this.constructor = d; }
10919 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10922 Object.defineProperty(exports, "__esModule", { value: true });
10923 var Subscriber_1 = require("../Subscriber");
10924 function count(predicate) {
10925 return function (source) { return source.lift(new CountOperator(predicate, source)); };
10927 exports.count = count;
10928 var CountOperator = (function () {
10929 function CountOperator(predicate, source) {
10930 this.predicate = predicate;
10931 this.source = source;
10933 CountOperator.prototype.call = function (subscriber, source) {
10934 return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
10936 return CountOperator;
10938 var CountSubscriber = (function (_super) {
10939 __extends(CountSubscriber, _super);
10940 function CountSubscriber(destination, predicate, source) {
10941 var _this = _super.call(this, destination) || this;
10942 _this.predicate = predicate;
10943 _this.source = source;
10948 CountSubscriber.prototype._next = function (value) {
10949 if (this.predicate) {
10950 this._tryPredicate(value);
10956 CountSubscriber.prototype._tryPredicate = function (value) {
10959 result = this.predicate(value, this.index++, this.source);
10962 this.destination.error(err);
10969 CountSubscriber.prototype._complete = function () {
10970 this.destination.next(this.count);
10971 this.destination.complete();
10973 return CountSubscriber;
10974 }(Subscriber_1.Subscriber));
10976 },{"../Subscriber":39}],88:[function(require,module,exports){
10978 var __extends = (this && this.__extends) || (function () {
10979 var extendStatics = function (d, b) {
10980 extendStatics = Object.setPrototypeOf ||
10981 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10982 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10983 return extendStatics(d, b);
10985 return function (d, b) {
10986 extendStatics(d, b);
10987 function __() { this.constructor = d; }
10988 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10991 Object.defineProperty(exports, "__esModule", { value: true });
10992 var OuterSubscriber_1 = require("../OuterSubscriber");
10993 var subscribeToResult_1 = require("../util/subscribeToResult");
10994 function debounce(durationSelector) {
10995 return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
10997 exports.debounce = debounce;
10998 var DebounceOperator = (function () {
10999 function DebounceOperator(durationSelector) {
11000 this.durationSelector = durationSelector;
11002 DebounceOperator.prototype.call = function (subscriber, source) {
11003 return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
11005 return DebounceOperator;
11007 var DebounceSubscriber = (function (_super) {
11008 __extends(DebounceSubscriber, _super);
11009 function DebounceSubscriber(destination, durationSelector) {
11010 var _this = _super.call(this, destination) || this;
11011 _this.durationSelector = durationSelector;
11012 _this.hasValue = false;
11013 _this.durationSubscription = null;
11016 DebounceSubscriber.prototype._next = function (value) {
11018 var result = this.durationSelector.call(this, value);
11020 this._tryNext(value, result);
11024 this.destination.error(err);
11027 DebounceSubscriber.prototype._complete = function () {
11029 this.destination.complete();
11031 DebounceSubscriber.prototype._tryNext = function (value, duration) {
11032 var subscription = this.durationSubscription;
11033 this.value = value;
11034 this.hasValue = true;
11035 if (subscription) {
11036 subscription.unsubscribe();
11037 this.remove(subscription);
11039 subscription = subscribeToResult_1.subscribeToResult(this, duration);
11040 if (subscription && !subscription.closed) {
11041 this.add(this.durationSubscription = subscription);
11044 DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11047 DebounceSubscriber.prototype.notifyComplete = function () {
11050 DebounceSubscriber.prototype.emitValue = function () {
11051 if (this.hasValue) {
11052 var value = this.value;
11053 var subscription = this.durationSubscription;
11054 if (subscription) {
11055 this.durationSubscription = null;
11056 subscription.unsubscribe();
11057 this.remove(subscription);
11060 this.hasValue = false;
11061 _super.prototype._next.call(this, value);
11064 return DebounceSubscriber;
11065 }(OuterSubscriber_1.OuterSubscriber));
11067 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],89:[function(require,module,exports){
11069 var __extends = (this && this.__extends) || (function () {
11070 var extendStatics = function (d, b) {
11071 extendStatics = Object.setPrototypeOf ||
11072 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11073 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11074 return extendStatics(d, b);
11076 return function (d, b) {
11077 extendStatics(d, b);
11078 function __() { this.constructor = d; }
11079 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11082 Object.defineProperty(exports, "__esModule", { value: true });
11083 var Subscriber_1 = require("../Subscriber");
11084 var async_1 = require("../scheduler/async");
11085 function debounceTime(dueTime, scheduler) {
11086 if (scheduler === void 0) { scheduler = async_1.async; }
11087 return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
11089 exports.debounceTime = debounceTime;
11090 var DebounceTimeOperator = (function () {
11091 function DebounceTimeOperator(dueTime, scheduler) {
11092 this.dueTime = dueTime;
11093 this.scheduler = scheduler;
11095 DebounceTimeOperator.prototype.call = function (subscriber, source) {
11096 return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
11098 return DebounceTimeOperator;
11100 var DebounceTimeSubscriber = (function (_super) {
11101 __extends(DebounceTimeSubscriber, _super);
11102 function DebounceTimeSubscriber(destination, dueTime, scheduler) {
11103 var _this = _super.call(this, destination) || this;
11104 _this.dueTime = dueTime;
11105 _this.scheduler = scheduler;
11106 _this.debouncedSubscription = null;
11107 _this.lastValue = null;
11108 _this.hasValue = false;
11111 DebounceTimeSubscriber.prototype._next = function (value) {
11112 this.clearDebounce();
11113 this.lastValue = value;
11114 this.hasValue = true;
11115 this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this));
11117 DebounceTimeSubscriber.prototype._complete = function () {
11118 this.debouncedNext();
11119 this.destination.complete();
11121 DebounceTimeSubscriber.prototype.debouncedNext = function () {
11122 this.clearDebounce();
11123 if (this.hasValue) {
11124 var lastValue = this.lastValue;
11125 this.lastValue = null;
11126 this.hasValue = false;
11127 this.destination.next(lastValue);
11130 DebounceTimeSubscriber.prototype.clearDebounce = function () {
11131 var debouncedSubscription = this.debouncedSubscription;
11132 if (debouncedSubscription !== null) {
11133 this.remove(debouncedSubscription);
11134 debouncedSubscription.unsubscribe();
11135 this.debouncedSubscription = null;
11138 return DebounceTimeSubscriber;
11139 }(Subscriber_1.Subscriber));
11140 function dispatchNext(subscriber) {
11141 subscriber.debouncedNext();
11144 },{"../Subscriber":39,"../scheduler/async":188}],90:[function(require,module,exports){
11146 var __extends = (this && this.__extends) || (function () {
11147 var extendStatics = function (d, b) {
11148 extendStatics = Object.setPrototypeOf ||
11149 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11150 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11151 return extendStatics(d, b);
11153 return function (d, b) {
11154 extendStatics(d, b);
11155 function __() { this.constructor = d; }
11156 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11159 Object.defineProperty(exports, "__esModule", { value: true });
11160 var Subscriber_1 = require("../Subscriber");
11161 function defaultIfEmpty(defaultValue) {
11162 if (defaultValue === void 0) { defaultValue = null; }
11163 return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
11165 exports.defaultIfEmpty = defaultIfEmpty;
11166 var DefaultIfEmptyOperator = (function () {
11167 function DefaultIfEmptyOperator(defaultValue) {
11168 this.defaultValue = defaultValue;
11170 DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
11171 return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
11173 return DefaultIfEmptyOperator;
11175 var DefaultIfEmptySubscriber = (function (_super) {
11176 __extends(DefaultIfEmptySubscriber, _super);
11177 function DefaultIfEmptySubscriber(destination, defaultValue) {
11178 var _this = _super.call(this, destination) || this;
11179 _this.defaultValue = defaultValue;
11180 _this.isEmpty = true;
11183 DefaultIfEmptySubscriber.prototype._next = function (value) {
11184 this.isEmpty = false;
11185 this.destination.next(value);
11187 DefaultIfEmptySubscriber.prototype._complete = function () {
11188 if (this.isEmpty) {
11189 this.destination.next(this.defaultValue);
11191 this.destination.complete();
11193 return DefaultIfEmptySubscriber;
11194 }(Subscriber_1.Subscriber));
11196 },{"../Subscriber":39}],91:[function(require,module,exports){
11198 var __extends = (this && this.__extends) || (function () {
11199 var extendStatics = function (d, b) {
11200 extendStatics = Object.setPrototypeOf ||
11201 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11202 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11203 return extendStatics(d, b);
11205 return function (d, b) {
11206 extendStatics(d, b);
11207 function __() { this.constructor = d; }
11208 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11211 Object.defineProperty(exports, "__esModule", { value: true });
11212 var async_1 = require("../scheduler/async");
11213 var isDate_1 = require("../util/isDate");
11214 var Subscriber_1 = require("../Subscriber");
11215 var Notification_1 = require("../Notification");
11216 function delay(delay, scheduler) {
11217 if (scheduler === void 0) { scheduler = async_1.async; }
11218 var absoluteDelay = isDate_1.isDate(delay);
11219 var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
11220 return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
11222 exports.delay = delay;
11223 var DelayOperator = (function () {
11224 function DelayOperator(delay, scheduler) {
11225 this.delay = delay;
11226 this.scheduler = scheduler;
11228 DelayOperator.prototype.call = function (subscriber, source) {
11229 return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
11231 return DelayOperator;
11233 var DelaySubscriber = (function (_super) {
11234 __extends(DelaySubscriber, _super);
11235 function DelaySubscriber(destination, delay, scheduler) {
11236 var _this = _super.call(this, destination) || this;
11237 _this.delay = delay;
11238 _this.scheduler = scheduler;
11240 _this.active = false;
11241 _this.errored = false;
11244 DelaySubscriber.dispatch = function (state) {
11245 var source = state.source;
11246 var queue = source.queue;
11247 var scheduler = state.scheduler;
11248 var destination = state.destination;
11249 while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
11250 queue.shift().notification.observe(destination);
11252 if (queue.length > 0) {
11253 var delay_1 = Math.max(0, queue[0].time - scheduler.now());
11254 this.schedule(state, delay_1);
11257 this.unsubscribe();
11258 source.active = false;
11261 DelaySubscriber.prototype._schedule = function (scheduler) {
11262 this.active = true;
11263 var destination = this.destination;
11264 destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
11265 source: this, destination: this.destination, scheduler: scheduler
11268 DelaySubscriber.prototype.scheduleNotification = function (notification) {
11269 if (this.errored === true) {
11272 var scheduler = this.scheduler;
11273 var message = new DelayMessage(scheduler.now() + this.delay, notification);
11274 this.queue.push(message);
11275 if (this.active === false) {
11276 this._schedule(scheduler);
11279 DelaySubscriber.prototype._next = function (value) {
11280 this.scheduleNotification(Notification_1.Notification.createNext(value));
11282 DelaySubscriber.prototype._error = function (err) {
11283 this.errored = true;
11285 this.destination.error(err);
11286 this.unsubscribe();
11288 DelaySubscriber.prototype._complete = function () {
11289 this.scheduleNotification(Notification_1.Notification.createComplete());
11290 this.unsubscribe();
11292 return DelaySubscriber;
11293 }(Subscriber_1.Subscriber));
11294 var DelayMessage = (function () {
11295 function DelayMessage(time, notification) {
11297 this.notification = notification;
11299 return DelayMessage;
11302 },{"../Notification":31,"../Subscriber":39,"../scheduler/async":188,"../util/isDate":205}],92:[function(require,module,exports){
11304 var __extends = (this && this.__extends) || (function () {
11305 var extendStatics = function (d, b) {
11306 extendStatics = Object.setPrototypeOf ||
11307 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11308 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11309 return extendStatics(d, b);
11311 return function (d, b) {
11312 extendStatics(d, b);
11313 function __() { this.constructor = d; }
11314 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11317 Object.defineProperty(exports, "__esModule", { value: true });
11318 var Subscriber_1 = require("../Subscriber");
11319 var Observable_1 = require("../Observable");
11320 var OuterSubscriber_1 = require("../OuterSubscriber");
11321 var subscribeToResult_1 = require("../util/subscribeToResult");
11322 function delayWhen(delayDurationSelector, subscriptionDelay) {
11323 if (subscriptionDelay) {
11324 return function (source) {
11325 return new SubscriptionDelayObservable(source, subscriptionDelay)
11326 .lift(new DelayWhenOperator(delayDurationSelector));
11329 return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
11331 exports.delayWhen = delayWhen;
11332 var DelayWhenOperator = (function () {
11333 function DelayWhenOperator(delayDurationSelector) {
11334 this.delayDurationSelector = delayDurationSelector;
11336 DelayWhenOperator.prototype.call = function (subscriber, source) {
11337 return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
11339 return DelayWhenOperator;
11341 var DelayWhenSubscriber = (function (_super) {
11342 __extends(DelayWhenSubscriber, _super);
11343 function DelayWhenSubscriber(destination, delayDurationSelector) {
11344 var _this = _super.call(this, destination) || this;
11345 _this.delayDurationSelector = delayDurationSelector;
11346 _this.completed = false;
11347 _this.delayNotifierSubscriptions = [];
11351 DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11352 this.destination.next(outerValue);
11353 this.removeSubscription(innerSub);
11354 this.tryComplete();
11356 DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
11357 this._error(error);
11359 DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
11360 var value = this.removeSubscription(innerSub);
11362 this.destination.next(value);
11364 this.tryComplete();
11366 DelayWhenSubscriber.prototype._next = function (value) {
11367 var index = this.index++;
11369 var delayNotifier = this.delayDurationSelector(value, index);
11370 if (delayNotifier) {
11371 this.tryDelay(delayNotifier, value);
11375 this.destination.error(err);
11378 DelayWhenSubscriber.prototype._complete = function () {
11379 this.completed = true;
11380 this.tryComplete();
11381 this.unsubscribe();
11383 DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
11384 subscription.unsubscribe();
11385 var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
11386 if (subscriptionIdx !== -1) {
11387 this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
11389 return subscription.outerValue;
11391 DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
11392 var notifierSubscription = subscribeToResult_1.subscribeToResult(this, delayNotifier, value);
11393 if (notifierSubscription && !notifierSubscription.closed) {
11394 var destination = this.destination;
11395 destination.add(notifierSubscription);
11396 this.delayNotifierSubscriptions.push(notifierSubscription);
11399 DelayWhenSubscriber.prototype.tryComplete = function () {
11400 if (this.completed && this.delayNotifierSubscriptions.length === 0) {
11401 this.destination.complete();
11404 return DelayWhenSubscriber;
11405 }(OuterSubscriber_1.OuterSubscriber));
11406 var SubscriptionDelayObservable = (function (_super) {
11407 __extends(SubscriptionDelayObservable, _super);
11408 function SubscriptionDelayObservable(source, subscriptionDelay) {
11409 var _this = _super.call(this) || this;
11410 _this.source = source;
11411 _this.subscriptionDelay = subscriptionDelay;
11414 SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
11415 this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
11417 return SubscriptionDelayObservable;
11418 }(Observable_1.Observable));
11419 var SubscriptionDelaySubscriber = (function (_super) {
11420 __extends(SubscriptionDelaySubscriber, _super);
11421 function SubscriptionDelaySubscriber(parent, source) {
11422 var _this = _super.call(this) || this;
11423 _this.parent = parent;
11424 _this.source = source;
11425 _this.sourceSubscribed = false;
11428 SubscriptionDelaySubscriber.prototype._next = function (unused) {
11429 this.subscribeToSource();
11431 SubscriptionDelaySubscriber.prototype._error = function (err) {
11432 this.unsubscribe();
11433 this.parent.error(err);
11435 SubscriptionDelaySubscriber.prototype._complete = function () {
11436 this.unsubscribe();
11437 this.subscribeToSource();
11439 SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
11440 if (!this.sourceSubscribed) {
11441 this.sourceSubscribed = true;
11442 this.unsubscribe();
11443 this.source.subscribe(this.parent);
11446 return SubscriptionDelaySubscriber;
11447 }(Subscriber_1.Subscriber));
11449 },{"../Observable":32,"../OuterSubscriber":34,"../Subscriber":39,"../util/subscribeToResult":222}],93:[function(require,module,exports){
11451 var __extends = (this && this.__extends) || (function () {
11452 var extendStatics = function (d, b) {
11453 extendStatics = Object.setPrototypeOf ||
11454 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11455 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11456 return extendStatics(d, b);
11458 return function (d, b) {
11459 extendStatics(d, b);
11460 function __() { this.constructor = d; }
11461 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11464 Object.defineProperty(exports, "__esModule", { value: true });
11465 var Subscriber_1 = require("../Subscriber");
11466 function dematerialize() {
11467 return function dematerializeOperatorFunction(source) {
11468 return source.lift(new DeMaterializeOperator());
11471 exports.dematerialize = dematerialize;
11472 var DeMaterializeOperator = (function () {
11473 function DeMaterializeOperator() {
11475 DeMaterializeOperator.prototype.call = function (subscriber, source) {
11476 return source.subscribe(new DeMaterializeSubscriber(subscriber));
11478 return DeMaterializeOperator;
11480 var DeMaterializeSubscriber = (function (_super) {
11481 __extends(DeMaterializeSubscriber, _super);
11482 function DeMaterializeSubscriber(destination) {
11483 return _super.call(this, destination) || this;
11485 DeMaterializeSubscriber.prototype._next = function (value) {
11486 value.observe(this.destination);
11488 return DeMaterializeSubscriber;
11489 }(Subscriber_1.Subscriber));
11491 },{"../Subscriber":39}],94:[function(require,module,exports){
11493 var __extends = (this && this.__extends) || (function () {
11494 var extendStatics = function (d, b) {
11495 extendStatics = Object.setPrototypeOf ||
11496 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11497 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11498 return extendStatics(d, b);
11500 return function (d, b) {
11501 extendStatics(d, b);
11502 function __() { this.constructor = d; }
11503 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11506 Object.defineProperty(exports, "__esModule", { value: true });
11507 var OuterSubscriber_1 = require("../OuterSubscriber");
11508 var subscribeToResult_1 = require("../util/subscribeToResult");
11509 function distinct(keySelector, flushes) {
11510 return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
11512 exports.distinct = distinct;
11513 var DistinctOperator = (function () {
11514 function DistinctOperator(keySelector, flushes) {
11515 this.keySelector = keySelector;
11516 this.flushes = flushes;
11518 DistinctOperator.prototype.call = function (subscriber, source) {
11519 return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
11521 return DistinctOperator;
11523 var DistinctSubscriber = (function (_super) {
11524 __extends(DistinctSubscriber, _super);
11525 function DistinctSubscriber(destination, keySelector, flushes) {
11526 var _this = _super.call(this, destination) || this;
11527 _this.keySelector = keySelector;
11528 _this.values = new Set();
11530 _this.add(subscribeToResult_1.subscribeToResult(_this, flushes));
11534 DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11535 this.values.clear();
11537 DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
11538 this._error(error);
11540 DistinctSubscriber.prototype._next = function (value) {
11541 if (this.keySelector) {
11542 this._useKeySelector(value);
11545 this._finalizeNext(value, value);
11548 DistinctSubscriber.prototype._useKeySelector = function (value) {
11550 var destination = this.destination;
11552 key = this.keySelector(value);
11555 destination.error(err);
11558 this._finalizeNext(key, value);
11560 DistinctSubscriber.prototype._finalizeNext = function (key, value) {
11561 var values = this.values;
11562 if (!values.has(key)) {
11564 this.destination.next(value);
11567 return DistinctSubscriber;
11568 }(OuterSubscriber_1.OuterSubscriber));
11569 exports.DistinctSubscriber = DistinctSubscriber;
11571 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],95:[function(require,module,exports){
11573 var __extends = (this && this.__extends) || (function () {
11574 var extendStatics = function (d, b) {
11575 extendStatics = Object.setPrototypeOf ||
11576 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11577 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11578 return extendStatics(d, b);
11580 return function (d, b) {
11581 extendStatics(d, b);
11582 function __() { this.constructor = d; }
11583 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11586 Object.defineProperty(exports, "__esModule", { value: true });
11587 var Subscriber_1 = require("../Subscriber");
11588 var tryCatch_1 = require("../util/tryCatch");
11589 var errorObject_1 = require("../util/errorObject");
11590 function distinctUntilChanged(compare, keySelector) {
11591 return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
11593 exports.distinctUntilChanged = distinctUntilChanged;
11594 var DistinctUntilChangedOperator = (function () {
11595 function DistinctUntilChangedOperator(compare, keySelector) {
11596 this.compare = compare;
11597 this.keySelector = keySelector;
11599 DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
11600 return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
11602 return DistinctUntilChangedOperator;
11604 var DistinctUntilChangedSubscriber = (function (_super) {
11605 __extends(DistinctUntilChangedSubscriber, _super);
11606 function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
11607 var _this = _super.call(this, destination) || this;
11608 _this.keySelector = keySelector;
11609 _this.hasKey = false;
11610 if (typeof compare === 'function') {
11611 _this.compare = compare;
11615 DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
11618 DistinctUntilChangedSubscriber.prototype._next = function (value) {
11619 var keySelector = this.keySelector;
11622 key = tryCatch_1.tryCatch(this.keySelector)(value);
11623 if (key === errorObject_1.errorObject) {
11624 return this.destination.error(errorObject_1.errorObject.e);
11627 var result = false;
11629 result = tryCatch_1.tryCatch(this.compare)(this.key, key);
11630 if (result === errorObject_1.errorObject) {
11631 return this.destination.error(errorObject_1.errorObject.e);
11635 this.hasKey = true;
11637 if (Boolean(result) === false) {
11639 this.destination.next(value);
11642 return DistinctUntilChangedSubscriber;
11643 }(Subscriber_1.Subscriber));
11645 },{"../Subscriber":39,"../util/errorObject":200,"../util/tryCatch":224}],96:[function(require,module,exports){
11647 Object.defineProperty(exports, "__esModule", { value: true });
11648 var distinctUntilChanged_1 = require("./distinctUntilChanged");
11649 function distinctUntilKeyChanged(key, compare) {
11650 return distinctUntilChanged_1.distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
11652 exports.distinctUntilKeyChanged = distinctUntilKeyChanged;
11654 },{"./distinctUntilChanged":95}],97:[function(require,module,exports){
11656 Object.defineProperty(exports, "__esModule", { value: true });
11657 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
11658 var filter_1 = require("./filter");
11659 var throwIfEmpty_1 = require("./throwIfEmpty");
11660 var defaultIfEmpty_1 = require("./defaultIfEmpty");
11661 var take_1 = require("./take");
11662 function elementAt(index, defaultValue) {
11664 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError();
11666 var hasDefaultValue = arguments.length >= 2;
11667 return function (source) { return source.pipe(filter_1.filter(function (v, i) { return i === index; }), take_1.take(1), hasDefaultValue
11668 ? defaultIfEmpty_1.defaultIfEmpty(defaultValue)
11669 : throwIfEmpty_1.throwIfEmpty(function () { return new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError(); })); };
11671 exports.elementAt = elementAt;
11673 },{"../util/ArgumentOutOfRangeError":193,"./defaultIfEmpty":90,"./filter":103,"./take":155,"./throwIfEmpty":162}],98:[function(require,module,exports){
11675 Object.defineProperty(exports, "__esModule", { value: true });
11676 var fromArray_1 = require("../observable/fromArray");
11677 var scalar_1 = require("../observable/scalar");
11678 var empty_1 = require("../observable/empty");
11679 var concat_1 = require("../observable/concat");
11680 var isScheduler_1 = require("../util/isScheduler");
11681 function endWith() {
11683 for (var _i = 0; _i < arguments.length; _i++) {
11684 array[_i] = arguments[_i];
11686 return function (source) {
11687 var scheduler = array[array.length - 1];
11688 if (isScheduler_1.isScheduler(scheduler)) {
11694 var len = array.length;
11695 if (len === 1 && !scheduler) {
11696 return concat_1.concat(source, scalar_1.scalar(array[0]));
11698 else if (len > 0) {
11699 return concat_1.concat(source, fromArray_1.fromArray(array, scheduler));
11702 return concat_1.concat(source, empty_1.empty(scheduler));
11706 exports.endWith = endWith;
11708 },{"../observable/concat":47,"../observable/empty":49,"../observable/fromArray":52,"../observable/scalar":68,"../util/isScheduler":213}],99:[function(require,module,exports){
11710 var __extends = (this && this.__extends) || (function () {
11711 var extendStatics = function (d, b) {
11712 extendStatics = Object.setPrototypeOf ||
11713 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11714 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11715 return extendStatics(d, b);
11717 return function (d, b) {
11718 extendStatics(d, b);
11719 function __() { this.constructor = d; }
11720 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11723 Object.defineProperty(exports, "__esModule", { value: true });
11724 var Subscriber_1 = require("../Subscriber");
11725 function every(predicate, thisArg) {
11726 return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
11728 exports.every = every;
11729 var EveryOperator = (function () {
11730 function EveryOperator(predicate, thisArg, source) {
11731 this.predicate = predicate;
11732 this.thisArg = thisArg;
11733 this.source = source;
11735 EveryOperator.prototype.call = function (observer, source) {
11736 return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
11738 return EveryOperator;
11740 var EverySubscriber = (function (_super) {
11741 __extends(EverySubscriber, _super);
11742 function EverySubscriber(destination, predicate, thisArg, source) {
11743 var _this = _super.call(this, destination) || this;
11744 _this.predicate = predicate;
11745 _this.thisArg = thisArg;
11746 _this.source = source;
11748 _this.thisArg = thisArg || _this;
11751 EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
11752 this.destination.next(everyValueMatch);
11753 this.destination.complete();
11755 EverySubscriber.prototype._next = function (value) {
11756 var result = false;
11758 result = this.predicate.call(this.thisArg, value, this.index++, this.source);
11761 this.destination.error(err);
11765 this.notifyComplete(false);
11768 EverySubscriber.prototype._complete = function () {
11769 this.notifyComplete(true);
11771 return EverySubscriber;
11772 }(Subscriber_1.Subscriber));
11774 },{"../Subscriber":39}],100:[function(require,module,exports){
11776 var __extends = (this && this.__extends) || (function () {
11777 var extendStatics = function (d, b) {
11778 extendStatics = Object.setPrototypeOf ||
11779 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11780 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11781 return extendStatics(d, b);
11783 return function (d, b) {
11784 extendStatics(d, b);
11785 function __() { this.constructor = d; }
11786 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11789 Object.defineProperty(exports, "__esModule", { value: true });
11790 var OuterSubscriber_1 = require("../OuterSubscriber");
11791 var subscribeToResult_1 = require("../util/subscribeToResult");
11792 function exhaust() {
11793 return function (source) { return source.lift(new SwitchFirstOperator()); };
11795 exports.exhaust = exhaust;
11796 var SwitchFirstOperator = (function () {
11797 function SwitchFirstOperator() {
11799 SwitchFirstOperator.prototype.call = function (subscriber, source) {
11800 return source.subscribe(new SwitchFirstSubscriber(subscriber));
11802 return SwitchFirstOperator;
11804 var SwitchFirstSubscriber = (function (_super) {
11805 __extends(SwitchFirstSubscriber, _super);
11806 function SwitchFirstSubscriber(destination) {
11807 var _this = _super.call(this, destination) || this;
11808 _this.hasCompleted = false;
11809 _this.hasSubscription = false;
11812 SwitchFirstSubscriber.prototype._next = function (value) {
11813 if (!this.hasSubscription) {
11814 this.hasSubscription = true;
11815 this.add(subscribeToResult_1.subscribeToResult(this, value));
11818 SwitchFirstSubscriber.prototype._complete = function () {
11819 this.hasCompleted = true;
11820 if (!this.hasSubscription) {
11821 this.destination.complete();
11824 SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
11825 this.remove(innerSub);
11826 this.hasSubscription = false;
11827 if (this.hasCompleted) {
11828 this.destination.complete();
11831 return SwitchFirstSubscriber;
11832 }(OuterSubscriber_1.OuterSubscriber));
11834 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],101:[function(require,module,exports){
11836 var __extends = (this && this.__extends) || (function () {
11837 var extendStatics = function (d, b) {
11838 extendStatics = Object.setPrototypeOf ||
11839 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11840 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11841 return extendStatics(d, b);
11843 return function (d, b) {
11844 extendStatics(d, b);
11845 function __() { this.constructor = d; }
11846 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11849 Object.defineProperty(exports, "__esModule", { value: true });
11850 var OuterSubscriber_1 = require("../OuterSubscriber");
11851 var InnerSubscriber_1 = require("../InnerSubscriber");
11852 var subscribeToResult_1 = require("../util/subscribeToResult");
11853 var map_1 = require("./map");
11854 var from_1 = require("../observable/from");
11855 function exhaustMap(project, resultSelector) {
11856 if (resultSelector) {
11857 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); })); })); };
11859 return function (source) {
11860 return source.lift(new ExhauseMapOperator(project));
11863 exports.exhaustMap = exhaustMap;
11864 var ExhauseMapOperator = (function () {
11865 function ExhauseMapOperator(project) {
11866 this.project = project;
11868 ExhauseMapOperator.prototype.call = function (subscriber, source) {
11869 return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
11871 return ExhauseMapOperator;
11873 var ExhaustMapSubscriber = (function (_super) {
11874 __extends(ExhaustMapSubscriber, _super);
11875 function ExhaustMapSubscriber(destination, project) {
11876 var _this = _super.call(this, destination) || this;
11877 _this.project = project;
11878 _this.hasSubscription = false;
11879 _this.hasCompleted = false;
11883 ExhaustMapSubscriber.prototype._next = function (value) {
11884 if (!this.hasSubscription) {
11885 this.tryNext(value);
11888 ExhaustMapSubscriber.prototype.tryNext = function (value) {
11890 var index = this.index++;
11892 result = this.project(value, index);
11895 this.destination.error(err);
11898 this.hasSubscription = true;
11899 this._innerSub(result, value, index);
11901 ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
11902 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
11903 var destination = this.destination;
11904 destination.add(innerSubscriber);
11905 subscribeToResult_1.subscribeToResult(this, result, value, index, innerSubscriber);
11907 ExhaustMapSubscriber.prototype._complete = function () {
11908 this.hasCompleted = true;
11909 if (!this.hasSubscription) {
11910 this.destination.complete();
11912 this.unsubscribe();
11914 ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11915 this.destination.next(innerValue);
11917 ExhaustMapSubscriber.prototype.notifyError = function (err) {
11918 this.destination.error(err);
11920 ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
11921 var destination = this.destination;
11922 destination.remove(innerSub);
11923 this.hasSubscription = false;
11924 if (this.hasCompleted) {
11925 this.destination.complete();
11928 return ExhaustMapSubscriber;
11929 }(OuterSubscriber_1.OuterSubscriber));
11931 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../observable/from":51,"../util/subscribeToResult":222,"./map":112}],102:[function(require,module,exports){
11933 var __extends = (this && this.__extends) || (function () {
11934 var extendStatics = function (d, b) {
11935 extendStatics = Object.setPrototypeOf ||
11936 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11937 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11938 return extendStatics(d, b);
11940 return function (d, b) {
11941 extendStatics(d, b);
11942 function __() { this.constructor = d; }
11943 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11946 Object.defineProperty(exports, "__esModule", { value: true });
11947 var tryCatch_1 = require("../util/tryCatch");
11948 var errorObject_1 = require("../util/errorObject");
11949 var OuterSubscriber_1 = require("../OuterSubscriber");
11950 var subscribeToResult_1 = require("../util/subscribeToResult");
11951 function expand(project, concurrent, scheduler) {
11952 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
11953 if (scheduler === void 0) { scheduler = undefined; }
11954 concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
11955 return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
11957 exports.expand = expand;
11958 var ExpandOperator = (function () {
11959 function ExpandOperator(project, concurrent, scheduler) {
11960 this.project = project;
11961 this.concurrent = concurrent;
11962 this.scheduler = scheduler;
11964 ExpandOperator.prototype.call = function (subscriber, source) {
11965 return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
11967 return ExpandOperator;
11969 exports.ExpandOperator = ExpandOperator;
11970 var ExpandSubscriber = (function (_super) {
11971 __extends(ExpandSubscriber, _super);
11972 function ExpandSubscriber(destination, project, concurrent, scheduler) {
11973 var _this = _super.call(this, destination) || this;
11974 _this.project = project;
11975 _this.concurrent = concurrent;
11976 _this.scheduler = scheduler;
11979 _this.hasCompleted = false;
11980 if (concurrent < Number.POSITIVE_INFINITY) {
11985 ExpandSubscriber.dispatch = function (arg) {
11986 var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
11987 subscriber.subscribeToProjection(result, value, index);
11989 ExpandSubscriber.prototype._next = function (value) {
11990 var destination = this.destination;
11991 if (destination.closed) {
11995 var index = this.index++;
11996 if (this.active < this.concurrent) {
11997 destination.next(value);
11998 var result = tryCatch_1.tryCatch(this.project)(value, index);
11999 if (result === errorObject_1.errorObject) {
12000 destination.error(errorObject_1.errorObject.e);
12002 else if (!this.scheduler) {
12003 this.subscribeToProjection(result, value, index);
12006 var state = { subscriber: this, result: result, value: value, index: index };
12007 var destination_1 = this.destination;
12008 destination_1.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
12012 this.buffer.push(value);
12015 ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
12017 var destination = this.destination;
12018 destination.add(subscribeToResult_1.subscribeToResult(this, result, value, index));
12020 ExpandSubscriber.prototype._complete = function () {
12021 this.hasCompleted = true;
12022 if (this.hasCompleted && this.active === 0) {
12023 this.destination.complete();
12025 this.unsubscribe();
12027 ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
12028 this._next(innerValue);
12030 ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
12031 var buffer = this.buffer;
12032 var destination = this.destination;
12033 destination.remove(innerSub);
12035 if (buffer && buffer.length > 0) {
12036 this._next(buffer.shift());
12038 if (this.hasCompleted && this.active === 0) {
12039 this.destination.complete();
12042 return ExpandSubscriber;
12043 }(OuterSubscriber_1.OuterSubscriber));
12044 exports.ExpandSubscriber = ExpandSubscriber;
12046 },{"../OuterSubscriber":34,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],103:[function(require,module,exports){
12048 var __extends = (this && this.__extends) || (function () {
12049 var extendStatics = function (d, b) {
12050 extendStatics = Object.setPrototypeOf ||
12051 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12052 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12053 return extendStatics(d, b);
12055 return function (d, b) {
12056 extendStatics(d, b);
12057 function __() { this.constructor = d; }
12058 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12061 Object.defineProperty(exports, "__esModule", { value: true });
12062 var Subscriber_1 = require("../Subscriber");
12063 function filter(predicate, thisArg) {
12064 return function filterOperatorFunction(source) {
12065 return source.lift(new FilterOperator(predicate, thisArg));
12068 exports.filter = filter;
12069 var FilterOperator = (function () {
12070 function FilterOperator(predicate, thisArg) {
12071 this.predicate = predicate;
12072 this.thisArg = thisArg;
12074 FilterOperator.prototype.call = function (subscriber, source) {
12075 return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
12077 return FilterOperator;
12079 var FilterSubscriber = (function (_super) {
12080 __extends(FilterSubscriber, _super);
12081 function FilterSubscriber(destination, predicate, thisArg) {
12082 var _this = _super.call(this, destination) || this;
12083 _this.predicate = predicate;
12084 _this.thisArg = thisArg;
12088 FilterSubscriber.prototype._next = function (value) {
12091 result = this.predicate.call(this.thisArg, value, this.count++);
12094 this.destination.error(err);
12098 this.destination.next(value);
12101 return FilterSubscriber;
12102 }(Subscriber_1.Subscriber));
12104 },{"../Subscriber":39}],104:[function(require,module,exports){
12106 var __extends = (this && this.__extends) || (function () {
12107 var extendStatics = function (d, b) {
12108 extendStatics = Object.setPrototypeOf ||
12109 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12110 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12111 return extendStatics(d, b);
12113 return function (d, b) {
12114 extendStatics(d, b);
12115 function __() { this.constructor = d; }
12116 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12119 Object.defineProperty(exports, "__esModule", { value: true });
12120 var Subscriber_1 = require("../Subscriber");
12121 var Subscription_1 = require("../Subscription");
12122 function finalize(callback) {
12123 return function (source) { return source.lift(new FinallyOperator(callback)); };
12125 exports.finalize = finalize;
12126 var FinallyOperator = (function () {
12127 function FinallyOperator(callback) {
12128 this.callback = callback;
12130 FinallyOperator.prototype.call = function (subscriber, source) {
12131 return source.subscribe(new FinallySubscriber(subscriber, this.callback));
12133 return FinallyOperator;
12135 var FinallySubscriber = (function (_super) {
12136 __extends(FinallySubscriber, _super);
12137 function FinallySubscriber(destination, callback) {
12138 var _this = _super.call(this, destination) || this;
12139 _this.add(new Subscription_1.Subscription(callback));
12142 return FinallySubscriber;
12143 }(Subscriber_1.Subscriber));
12145 },{"../Subscriber":39,"../Subscription":40}],105:[function(require,module,exports){
12147 var __extends = (this && this.__extends) || (function () {
12148 var extendStatics = function (d, b) {
12149 extendStatics = Object.setPrototypeOf ||
12150 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12151 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12152 return extendStatics(d, b);
12154 return function (d, b) {
12155 extendStatics(d, b);
12156 function __() { this.constructor = d; }
12157 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12160 Object.defineProperty(exports, "__esModule", { value: true });
12161 var Subscriber_1 = require("../Subscriber");
12162 function find(predicate, thisArg) {
12163 if (typeof predicate !== 'function') {
12164 throw new TypeError('predicate is not a function');
12166 return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
12168 exports.find = find;
12169 var FindValueOperator = (function () {
12170 function FindValueOperator(predicate, source, yieldIndex, thisArg) {
12171 this.predicate = predicate;
12172 this.source = source;
12173 this.yieldIndex = yieldIndex;
12174 this.thisArg = thisArg;
12176 FindValueOperator.prototype.call = function (observer, source) {
12177 return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
12179 return FindValueOperator;
12181 exports.FindValueOperator = FindValueOperator;
12182 var FindValueSubscriber = (function (_super) {
12183 __extends(FindValueSubscriber, _super);
12184 function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
12185 var _this = _super.call(this, destination) || this;
12186 _this.predicate = predicate;
12187 _this.source = source;
12188 _this.yieldIndex = yieldIndex;
12189 _this.thisArg = thisArg;
12193 FindValueSubscriber.prototype.notifyComplete = function (value) {
12194 var destination = this.destination;
12195 destination.next(value);
12196 destination.complete();
12197 this.unsubscribe();
12199 FindValueSubscriber.prototype._next = function (value) {
12200 var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
12201 var index = this.index++;
12203 var result = predicate.call(thisArg || this, value, index, this.source);
12205 this.notifyComplete(this.yieldIndex ? index : value);
12209 this.destination.error(err);
12212 FindValueSubscriber.prototype._complete = function () {
12213 this.notifyComplete(this.yieldIndex ? -1 : undefined);
12215 return FindValueSubscriber;
12216 }(Subscriber_1.Subscriber));
12217 exports.FindValueSubscriber = FindValueSubscriber;
12219 },{"../Subscriber":39}],106:[function(require,module,exports){
12221 Object.defineProperty(exports, "__esModule", { value: true });
12222 var find_1 = require("../operators/find");
12223 function findIndex(predicate, thisArg) {
12224 return function (source) { return source.lift(new find_1.FindValueOperator(predicate, source, true, thisArg)); };
12226 exports.findIndex = findIndex;
12228 },{"../operators/find":105}],107:[function(require,module,exports){
12230 Object.defineProperty(exports, "__esModule", { value: true });
12231 var EmptyError_1 = require("../util/EmptyError");
12232 var filter_1 = require("./filter");
12233 var take_1 = require("./take");
12234 var defaultIfEmpty_1 = require("./defaultIfEmpty");
12235 var throwIfEmpty_1 = require("./throwIfEmpty");
12236 var identity_1 = require("../util/identity");
12237 function first(predicate, defaultValue) {
12238 var hasDefaultValue = arguments.length >= 2;
12239 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(); })); };
12241 exports.first = first;
12243 },{"../util/EmptyError":194,"../util/identity":202,"./defaultIfEmpty":90,"./filter":103,"./take":155,"./throwIfEmpty":162}],108:[function(require,module,exports){
12245 var __extends = (this && this.__extends) || (function () {
12246 var extendStatics = function (d, b) {
12247 extendStatics = Object.setPrototypeOf ||
12248 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12249 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12250 return extendStatics(d, b);
12252 return function (d, b) {
12253 extendStatics(d, b);
12254 function __() { this.constructor = d; }
12255 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12258 Object.defineProperty(exports, "__esModule", { value: true });
12259 var Subscriber_1 = require("../Subscriber");
12260 var Subscription_1 = require("../Subscription");
12261 var Observable_1 = require("../Observable");
12262 var Subject_1 = require("../Subject");
12263 function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
12264 return function (source) {
12265 return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
12268 exports.groupBy = groupBy;
12269 var GroupByOperator = (function () {
12270 function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
12271 this.keySelector = keySelector;
12272 this.elementSelector = elementSelector;
12273 this.durationSelector = durationSelector;
12274 this.subjectSelector = subjectSelector;
12276 GroupByOperator.prototype.call = function (subscriber, source) {
12277 return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
12279 return GroupByOperator;
12281 var GroupBySubscriber = (function (_super) {
12282 __extends(GroupBySubscriber, _super);
12283 function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
12284 var _this = _super.call(this, destination) || this;
12285 _this.keySelector = keySelector;
12286 _this.elementSelector = elementSelector;
12287 _this.durationSelector = durationSelector;
12288 _this.subjectSelector = subjectSelector;
12289 _this.groups = null;
12290 _this.attemptedToUnsubscribe = false;
12294 GroupBySubscriber.prototype._next = function (value) {
12297 key = this.keySelector(value);
12303 this._group(value, key);
12305 GroupBySubscriber.prototype._group = function (value, key) {
12306 var groups = this.groups;
12308 groups = this.groups = new Map();
12310 var group = groups.get(key);
12312 if (this.elementSelector) {
12314 element = this.elementSelector(value);
12324 group = (this.subjectSelector ? this.subjectSelector() : new Subject_1.Subject());
12325 groups.set(key, group);
12326 var groupedObservable = new GroupedObservable(key, group, this);
12327 this.destination.next(groupedObservable);
12328 if (this.durationSelector) {
12329 var duration = void 0;
12331 duration = this.durationSelector(new GroupedObservable(key, group));
12337 this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
12340 if (!group.closed) {
12341 group.next(element);
12344 GroupBySubscriber.prototype._error = function (err) {
12345 var groups = this.groups;
12347 groups.forEach(function (group, key) {
12352 this.destination.error(err);
12354 GroupBySubscriber.prototype._complete = function () {
12355 var groups = this.groups;
12357 groups.forEach(function (group, key) {
12362 this.destination.complete();
12364 GroupBySubscriber.prototype.removeGroup = function (key) {
12365 this.groups.delete(key);
12367 GroupBySubscriber.prototype.unsubscribe = function () {
12368 if (!this.closed) {
12369 this.attemptedToUnsubscribe = true;
12370 if (this.count === 0) {
12371 _super.prototype.unsubscribe.call(this);
12375 return GroupBySubscriber;
12376 }(Subscriber_1.Subscriber));
12377 var GroupDurationSubscriber = (function (_super) {
12378 __extends(GroupDurationSubscriber, _super);
12379 function GroupDurationSubscriber(key, group, parent) {
12380 var _this = _super.call(this, group) || this;
12382 _this.group = group;
12383 _this.parent = parent;
12386 GroupDurationSubscriber.prototype._next = function (value) {
12389 GroupDurationSubscriber.prototype._unsubscribe = function () {
12390 var _a = this, parent = _a.parent, key = _a.key;
12391 this.key = this.parent = null;
12393 parent.removeGroup(key);
12396 return GroupDurationSubscriber;
12397 }(Subscriber_1.Subscriber));
12398 var GroupedObservable = (function (_super) {
12399 __extends(GroupedObservable, _super);
12400 function GroupedObservable(key, groupSubject, refCountSubscription) {
12401 var _this = _super.call(this) || this;
12403 _this.groupSubject = groupSubject;
12404 _this.refCountSubscription = refCountSubscription;
12407 GroupedObservable.prototype._subscribe = function (subscriber) {
12408 var subscription = new Subscription_1.Subscription();
12409 var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
12410 if (refCountSubscription && !refCountSubscription.closed) {
12411 subscription.add(new InnerRefCountSubscription(refCountSubscription));
12413 subscription.add(groupSubject.subscribe(subscriber));
12414 return subscription;
12416 return GroupedObservable;
12417 }(Observable_1.Observable));
12418 exports.GroupedObservable = GroupedObservable;
12419 var InnerRefCountSubscription = (function (_super) {
12420 __extends(InnerRefCountSubscription, _super);
12421 function InnerRefCountSubscription(parent) {
12422 var _this = _super.call(this) || this;
12423 _this.parent = parent;
12427 InnerRefCountSubscription.prototype.unsubscribe = function () {
12428 var parent = this.parent;
12429 if (!parent.closed && !this.closed) {
12430 _super.prototype.unsubscribe.call(this);
12432 if (parent.count === 0 && parent.attemptedToUnsubscribe) {
12433 parent.unsubscribe();
12437 return InnerRefCountSubscription;
12438 }(Subscription_1.Subscription));
12440 },{"../Observable":32,"../Subject":37,"../Subscriber":39,"../Subscription":40}],109:[function(require,module,exports){
12442 var __extends = (this && this.__extends) || (function () {
12443 var extendStatics = function (d, b) {
12444 extendStatics = Object.setPrototypeOf ||
12445 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12446 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12447 return extendStatics(d, b);
12449 return function (d, b) {
12450 extendStatics(d, b);
12451 function __() { this.constructor = d; }
12452 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12455 Object.defineProperty(exports, "__esModule", { value: true });
12456 var Subscriber_1 = require("../Subscriber");
12457 function ignoreElements() {
12458 return function ignoreElementsOperatorFunction(source) {
12459 return source.lift(new IgnoreElementsOperator());
12462 exports.ignoreElements = ignoreElements;
12463 var IgnoreElementsOperator = (function () {
12464 function IgnoreElementsOperator() {
12466 IgnoreElementsOperator.prototype.call = function (subscriber, source) {
12467 return source.subscribe(new IgnoreElementsSubscriber(subscriber));
12469 return IgnoreElementsOperator;
12471 var IgnoreElementsSubscriber = (function (_super) {
12472 __extends(IgnoreElementsSubscriber, _super);
12473 function IgnoreElementsSubscriber() {
12474 return _super !== null && _super.apply(this, arguments) || this;
12476 IgnoreElementsSubscriber.prototype._next = function (unused) {
12478 return IgnoreElementsSubscriber;
12479 }(Subscriber_1.Subscriber));
12481 },{"../Subscriber":39}],110:[function(require,module,exports){
12483 var __extends = (this && this.__extends) || (function () {
12484 var extendStatics = function (d, b) {
12485 extendStatics = Object.setPrototypeOf ||
12486 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12487 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12488 return extendStatics(d, b);
12490 return function (d, b) {
12491 extendStatics(d, b);
12492 function __() { this.constructor = d; }
12493 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12496 Object.defineProperty(exports, "__esModule", { value: true });
12497 var Subscriber_1 = require("../Subscriber");
12498 function isEmpty() {
12499 return function (source) { return source.lift(new IsEmptyOperator()); };
12501 exports.isEmpty = isEmpty;
12502 var IsEmptyOperator = (function () {
12503 function IsEmptyOperator() {
12505 IsEmptyOperator.prototype.call = function (observer, source) {
12506 return source.subscribe(new IsEmptySubscriber(observer));
12508 return IsEmptyOperator;
12510 var IsEmptySubscriber = (function (_super) {
12511 __extends(IsEmptySubscriber, _super);
12512 function IsEmptySubscriber(destination) {
12513 return _super.call(this, destination) || this;
12515 IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
12516 var destination = this.destination;
12517 destination.next(isEmpty);
12518 destination.complete();
12520 IsEmptySubscriber.prototype._next = function (value) {
12521 this.notifyComplete(false);
12523 IsEmptySubscriber.prototype._complete = function () {
12524 this.notifyComplete(true);
12526 return IsEmptySubscriber;
12527 }(Subscriber_1.Subscriber));
12529 },{"../Subscriber":39}],111:[function(require,module,exports){
12531 Object.defineProperty(exports, "__esModule", { value: true });
12532 var EmptyError_1 = require("../util/EmptyError");
12533 var filter_1 = require("./filter");
12534 var takeLast_1 = require("./takeLast");
12535 var throwIfEmpty_1 = require("./throwIfEmpty");
12536 var defaultIfEmpty_1 = require("./defaultIfEmpty");
12537 var identity_1 = require("../util/identity");
12538 function last(predicate, defaultValue) {
12539 var hasDefaultValue = arguments.length >= 2;
12540 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(); })); };
12542 exports.last = last;
12544 },{"../util/EmptyError":194,"../util/identity":202,"./defaultIfEmpty":90,"./filter":103,"./takeLast":156,"./throwIfEmpty":162}],112:[function(require,module,exports){
12546 var __extends = (this && this.__extends) || (function () {
12547 var extendStatics = function (d, b) {
12548 extendStatics = Object.setPrototypeOf ||
12549 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12550 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12551 return extendStatics(d, b);
12553 return function (d, b) {
12554 extendStatics(d, b);
12555 function __() { this.constructor = d; }
12556 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12559 Object.defineProperty(exports, "__esModule", { value: true });
12560 var Subscriber_1 = require("../Subscriber");
12561 function map(project, thisArg) {
12562 return function mapOperation(source) {
12563 if (typeof project !== 'function') {
12564 throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
12566 return source.lift(new MapOperator(project, thisArg));
12570 var MapOperator = (function () {
12571 function MapOperator(project, thisArg) {
12572 this.project = project;
12573 this.thisArg = thisArg;
12575 MapOperator.prototype.call = function (subscriber, source) {
12576 return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
12578 return MapOperator;
12580 exports.MapOperator = MapOperator;
12581 var MapSubscriber = (function (_super) {
12582 __extends(MapSubscriber, _super);
12583 function MapSubscriber(destination, project, thisArg) {
12584 var _this = _super.call(this, destination) || this;
12585 _this.project = project;
12587 _this.thisArg = thisArg || _this;
12590 MapSubscriber.prototype._next = function (value) {
12593 result = this.project.call(this.thisArg, value, this.count++);
12596 this.destination.error(err);
12599 this.destination.next(result);
12601 return MapSubscriber;
12602 }(Subscriber_1.Subscriber));
12604 },{"../Subscriber":39}],113:[function(require,module,exports){
12606 var __extends = (this && this.__extends) || (function () {
12607 var extendStatics = function (d, b) {
12608 extendStatics = Object.setPrototypeOf ||
12609 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12610 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12611 return extendStatics(d, b);
12613 return function (d, b) {
12614 extendStatics(d, b);
12615 function __() { this.constructor = d; }
12616 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12619 Object.defineProperty(exports, "__esModule", { value: true });
12620 var Subscriber_1 = require("../Subscriber");
12621 function mapTo(value) {
12622 return function (source) { return source.lift(new MapToOperator(value)); };
12624 exports.mapTo = mapTo;
12625 var MapToOperator = (function () {
12626 function MapToOperator(value) {
12627 this.value = value;
12629 MapToOperator.prototype.call = function (subscriber, source) {
12630 return source.subscribe(new MapToSubscriber(subscriber, this.value));
12632 return MapToOperator;
12634 var MapToSubscriber = (function (_super) {
12635 __extends(MapToSubscriber, _super);
12636 function MapToSubscriber(destination, value) {
12637 var _this = _super.call(this, destination) || this;
12638 _this.value = value;
12641 MapToSubscriber.prototype._next = function (x) {
12642 this.destination.next(this.value);
12644 return MapToSubscriber;
12645 }(Subscriber_1.Subscriber));
12647 },{"../Subscriber":39}],114:[function(require,module,exports){
12649 var __extends = (this && this.__extends) || (function () {
12650 var extendStatics = function (d, b) {
12651 extendStatics = Object.setPrototypeOf ||
12652 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12653 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12654 return extendStatics(d, b);
12656 return function (d, b) {
12657 extendStatics(d, b);
12658 function __() { this.constructor = d; }
12659 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12662 Object.defineProperty(exports, "__esModule", { value: true });
12663 var Subscriber_1 = require("../Subscriber");
12664 var Notification_1 = require("../Notification");
12665 function materialize() {
12666 return function materializeOperatorFunction(source) {
12667 return source.lift(new MaterializeOperator());
12670 exports.materialize = materialize;
12671 var MaterializeOperator = (function () {
12672 function MaterializeOperator() {
12674 MaterializeOperator.prototype.call = function (subscriber, source) {
12675 return source.subscribe(new MaterializeSubscriber(subscriber));
12677 return MaterializeOperator;
12679 var MaterializeSubscriber = (function (_super) {
12680 __extends(MaterializeSubscriber, _super);
12681 function MaterializeSubscriber(destination) {
12682 return _super.call(this, destination) || this;
12684 MaterializeSubscriber.prototype._next = function (value) {
12685 this.destination.next(Notification_1.Notification.createNext(value));
12687 MaterializeSubscriber.prototype._error = function (err) {
12688 var destination = this.destination;
12689 destination.next(Notification_1.Notification.createError(err));
12690 destination.complete();
12692 MaterializeSubscriber.prototype._complete = function () {
12693 var destination = this.destination;
12694 destination.next(Notification_1.Notification.createComplete());
12695 destination.complete();
12697 return MaterializeSubscriber;
12698 }(Subscriber_1.Subscriber));
12700 },{"../Notification":31,"../Subscriber":39}],115:[function(require,module,exports){
12702 Object.defineProperty(exports, "__esModule", { value: true });
12703 var reduce_1 = require("./reduce");
12704 function max(comparer) {
12705 var max = (typeof comparer === 'function')
12706 ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
12707 : function (x, y) { return x > y ? x : y; };
12708 return reduce_1.reduce(max);
12712 },{"./reduce":133}],116:[function(require,module,exports){
12714 Object.defineProperty(exports, "__esModule", { value: true });
12715 var merge_1 = require("../observable/merge");
12717 var observables = [];
12718 for (var _i = 0; _i < arguments.length; _i++) {
12719 observables[_i] = arguments[_i];
12721 return function (source) { return source.lift.call(merge_1.merge.apply(void 0, [source].concat(observables))); };
12723 exports.merge = merge;
12725 },{"../observable/merge":61}],117:[function(require,module,exports){
12727 Object.defineProperty(exports, "__esModule", { value: true });
12728 var mergeMap_1 = require("./mergeMap");
12729 var identity_1 = require("../util/identity");
12730 function mergeAll(concurrent) {
12731 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12732 return mergeMap_1.mergeMap(identity_1.identity, concurrent);
12734 exports.mergeAll = mergeAll;
12736 },{"../util/identity":202,"./mergeMap":118}],118:[function(require,module,exports){
12738 var __extends = (this && this.__extends) || (function () {
12739 var extendStatics = function (d, b) {
12740 extendStatics = Object.setPrototypeOf ||
12741 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12742 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12743 return extendStatics(d, b);
12745 return function (d, b) {
12746 extendStatics(d, b);
12747 function __() { this.constructor = d; }
12748 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12751 Object.defineProperty(exports, "__esModule", { value: true });
12752 var subscribeToResult_1 = require("../util/subscribeToResult");
12753 var OuterSubscriber_1 = require("../OuterSubscriber");
12754 var InnerSubscriber_1 = require("../InnerSubscriber");
12755 var map_1 = require("./map");
12756 var from_1 = require("../observable/from");
12757 function mergeMap(project, resultSelector, concurrent) {
12758 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12759 if (typeof resultSelector === 'function') {
12760 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)); };
12762 else if (typeof resultSelector === 'number') {
12763 concurrent = resultSelector;
12765 return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
12767 exports.mergeMap = mergeMap;
12768 var MergeMapOperator = (function () {
12769 function MergeMapOperator(project, concurrent) {
12770 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12771 this.project = project;
12772 this.concurrent = concurrent;
12774 MergeMapOperator.prototype.call = function (observer, source) {
12775 return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
12777 return MergeMapOperator;
12779 exports.MergeMapOperator = MergeMapOperator;
12780 var MergeMapSubscriber = (function (_super) {
12781 __extends(MergeMapSubscriber, _super);
12782 function MergeMapSubscriber(destination, project, concurrent) {
12783 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12784 var _this = _super.call(this, destination) || this;
12785 _this.project = project;
12786 _this.concurrent = concurrent;
12787 _this.hasCompleted = false;
12793 MergeMapSubscriber.prototype._next = function (value) {
12794 if (this.active < this.concurrent) {
12795 this._tryNext(value);
12798 this.buffer.push(value);
12801 MergeMapSubscriber.prototype._tryNext = function (value) {
12803 var index = this.index++;
12805 result = this.project(value, index);
12808 this.destination.error(err);
12812 this._innerSub(result, value, index);
12814 MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
12815 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
12816 var destination = this.destination;
12817 destination.add(innerSubscriber);
12818 subscribeToResult_1.subscribeToResult(this, ish, value, index, innerSubscriber);
12820 MergeMapSubscriber.prototype._complete = function () {
12821 this.hasCompleted = true;
12822 if (this.active === 0 && this.buffer.length === 0) {
12823 this.destination.complete();
12825 this.unsubscribe();
12827 MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
12828 this.destination.next(innerValue);
12830 MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
12831 var buffer = this.buffer;
12832 this.remove(innerSub);
12834 if (buffer.length > 0) {
12835 this._next(buffer.shift());
12837 else if (this.active === 0 && this.hasCompleted) {
12838 this.destination.complete();
12841 return MergeMapSubscriber;
12842 }(OuterSubscriber_1.OuterSubscriber));
12843 exports.MergeMapSubscriber = MergeMapSubscriber;
12845 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../observable/from":51,"../util/subscribeToResult":222,"./map":112}],119:[function(require,module,exports){
12847 Object.defineProperty(exports, "__esModule", { value: true });
12848 var mergeMap_1 = require("./mergeMap");
12849 function mergeMapTo(innerObservable, resultSelector, concurrent) {
12850 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12851 if (typeof resultSelector === 'function') {
12852 return mergeMap_1.mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
12854 if (typeof resultSelector === 'number') {
12855 concurrent = resultSelector;
12857 return mergeMap_1.mergeMap(function () { return innerObservable; }, concurrent);
12859 exports.mergeMapTo = mergeMapTo;
12861 },{"./mergeMap":118}],120:[function(require,module,exports){
12863 var __extends = (this && this.__extends) || (function () {
12864 var extendStatics = function (d, b) {
12865 extendStatics = Object.setPrototypeOf ||
12866 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12867 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12868 return extendStatics(d, b);
12870 return function (d, b) {
12871 extendStatics(d, b);
12872 function __() { this.constructor = d; }
12873 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12876 Object.defineProperty(exports, "__esModule", { value: true });
12877 var tryCatch_1 = require("../util/tryCatch");
12878 var errorObject_1 = require("../util/errorObject");
12879 var subscribeToResult_1 = require("../util/subscribeToResult");
12880 var OuterSubscriber_1 = require("../OuterSubscriber");
12881 var InnerSubscriber_1 = require("../InnerSubscriber");
12882 function mergeScan(accumulator, seed, concurrent) {
12883 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12884 return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
12886 exports.mergeScan = mergeScan;
12887 var MergeScanOperator = (function () {
12888 function MergeScanOperator(accumulator, seed, concurrent) {
12889 this.accumulator = accumulator;
12891 this.concurrent = concurrent;
12893 MergeScanOperator.prototype.call = function (subscriber, source) {
12894 return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
12896 return MergeScanOperator;
12898 exports.MergeScanOperator = MergeScanOperator;
12899 var MergeScanSubscriber = (function (_super) {
12900 __extends(MergeScanSubscriber, _super);
12901 function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
12902 var _this = _super.call(this, destination) || this;
12903 _this.accumulator = accumulator;
12905 _this.concurrent = concurrent;
12906 _this.hasValue = false;
12907 _this.hasCompleted = false;
12913 MergeScanSubscriber.prototype._next = function (value) {
12914 if (this.active < this.concurrent) {
12915 var index = this.index++;
12916 var ish = tryCatch_1.tryCatch(this.accumulator)(this.acc, value);
12917 var destination = this.destination;
12918 if (ish === errorObject_1.errorObject) {
12919 destination.error(errorObject_1.errorObject.e);
12923 this._innerSub(ish, value, index);
12927 this.buffer.push(value);
12930 MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
12931 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
12932 var destination = this.destination;
12933 destination.add(innerSubscriber);
12934 subscribeToResult_1.subscribeToResult(this, ish, value, index, innerSubscriber);
12936 MergeScanSubscriber.prototype._complete = function () {
12937 this.hasCompleted = true;
12938 if (this.active === 0 && this.buffer.length === 0) {
12939 if (this.hasValue === false) {
12940 this.destination.next(this.acc);
12942 this.destination.complete();
12944 this.unsubscribe();
12946 MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
12947 var destination = this.destination;
12948 this.acc = innerValue;
12949 this.hasValue = true;
12950 destination.next(innerValue);
12952 MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
12953 var buffer = this.buffer;
12954 var destination = this.destination;
12955 destination.remove(innerSub);
12957 if (buffer.length > 0) {
12958 this._next(buffer.shift());
12960 else if (this.active === 0 && this.hasCompleted) {
12961 if (this.hasValue === false) {
12962 this.destination.next(this.acc);
12964 this.destination.complete();
12967 return MergeScanSubscriber;
12968 }(OuterSubscriber_1.OuterSubscriber));
12969 exports.MergeScanSubscriber = MergeScanSubscriber;
12971 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],121:[function(require,module,exports){
12973 Object.defineProperty(exports, "__esModule", { value: true });
12974 var reduce_1 = require("./reduce");
12975 function min(comparer) {
12976 var min = (typeof comparer === 'function')
12977 ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
12978 : function (x, y) { return x < y ? x : y; };
12979 return reduce_1.reduce(min);
12983 },{"./reduce":133}],122:[function(require,module,exports){
12985 Object.defineProperty(exports, "__esModule", { value: true });
12986 var ConnectableObservable_1 = require("../observable/ConnectableObservable");
12987 function multicast(subjectOrSubjectFactory, selector) {
12988 return function multicastOperatorFunction(source) {
12989 var subjectFactory;
12990 if (typeof subjectOrSubjectFactory === 'function') {
12991 subjectFactory = subjectOrSubjectFactory;
12994 subjectFactory = function subjectFactory() {
12995 return subjectOrSubjectFactory;
12998 if (typeof selector === 'function') {
12999 return source.lift(new MulticastOperator(subjectFactory, selector));
13001 var connectable = Object.create(source, ConnectableObservable_1.connectableObservableDescriptor);
13002 connectable.source = source;
13003 connectable.subjectFactory = subjectFactory;
13004 return connectable;
13007 exports.multicast = multicast;
13008 var MulticastOperator = (function () {
13009 function MulticastOperator(subjectFactory, selector) {
13010 this.subjectFactory = subjectFactory;
13011 this.selector = selector;
13013 MulticastOperator.prototype.call = function (subscriber, source) {
13014 var selector = this.selector;
13015 var subject = this.subjectFactory();
13016 var subscription = selector(subject).subscribe(subscriber);
13017 subscription.add(source.subscribe(subject));
13018 return subscription;
13020 return MulticastOperator;
13022 exports.MulticastOperator = MulticastOperator;
13024 },{"../observable/ConnectableObservable":42}],123:[function(require,module,exports){
13026 var __extends = (this && this.__extends) || (function () {
13027 var extendStatics = function (d, b) {
13028 extendStatics = Object.setPrototypeOf ||
13029 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13030 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13031 return extendStatics(d, b);
13033 return function (d, b) {
13034 extendStatics(d, b);
13035 function __() { this.constructor = d; }
13036 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13039 Object.defineProperty(exports, "__esModule", { value: true });
13040 var Subscriber_1 = require("../Subscriber");
13041 var Notification_1 = require("../Notification");
13042 function observeOn(scheduler, delay) {
13043 if (delay === void 0) { delay = 0; }
13044 return function observeOnOperatorFunction(source) {
13045 return source.lift(new ObserveOnOperator(scheduler, delay));
13048 exports.observeOn = observeOn;
13049 var ObserveOnOperator = (function () {
13050 function ObserveOnOperator(scheduler, delay) {
13051 if (delay === void 0) { delay = 0; }
13052 this.scheduler = scheduler;
13053 this.delay = delay;
13055 ObserveOnOperator.prototype.call = function (subscriber, source) {
13056 return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
13058 return ObserveOnOperator;
13060 exports.ObserveOnOperator = ObserveOnOperator;
13061 var ObserveOnSubscriber = (function (_super) {
13062 __extends(ObserveOnSubscriber, _super);
13063 function ObserveOnSubscriber(destination, scheduler, delay) {
13064 if (delay === void 0) { delay = 0; }
13065 var _this = _super.call(this, destination) || this;
13066 _this.scheduler = scheduler;
13067 _this.delay = delay;
13070 ObserveOnSubscriber.dispatch = function (arg) {
13071 var notification = arg.notification, destination = arg.destination;
13072 notification.observe(destination);
13073 this.unsubscribe();
13075 ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
13076 var destination = this.destination;
13077 destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
13079 ObserveOnSubscriber.prototype._next = function (value) {
13080 this.scheduleMessage(Notification_1.Notification.createNext(value));
13082 ObserveOnSubscriber.prototype._error = function (err) {
13083 this.scheduleMessage(Notification_1.Notification.createError(err));
13084 this.unsubscribe();
13086 ObserveOnSubscriber.prototype._complete = function () {
13087 this.scheduleMessage(Notification_1.Notification.createComplete());
13088 this.unsubscribe();
13090 return ObserveOnSubscriber;
13091 }(Subscriber_1.Subscriber));
13092 exports.ObserveOnSubscriber = ObserveOnSubscriber;
13093 var ObserveOnMessage = (function () {
13094 function ObserveOnMessage(notification, destination) {
13095 this.notification = notification;
13096 this.destination = destination;
13098 return ObserveOnMessage;
13100 exports.ObserveOnMessage = ObserveOnMessage;
13102 },{"../Notification":31,"../Subscriber":39}],124:[function(require,module,exports){
13104 var __extends = (this && this.__extends) || (function () {
13105 var extendStatics = function (d, b) {
13106 extendStatics = Object.setPrototypeOf ||
13107 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13108 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13109 return extendStatics(d, b);
13111 return function (d, b) {
13112 extendStatics(d, b);
13113 function __() { this.constructor = d; }
13114 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13117 Object.defineProperty(exports, "__esModule", { value: true });
13118 var from_1 = require("../observable/from");
13119 var isArray_1 = require("../util/isArray");
13120 var OuterSubscriber_1 = require("../OuterSubscriber");
13121 var InnerSubscriber_1 = require("../InnerSubscriber");
13122 var subscribeToResult_1 = require("../util/subscribeToResult");
13123 function onErrorResumeNext() {
13124 var nextSources = [];
13125 for (var _i = 0; _i < arguments.length; _i++) {
13126 nextSources[_i] = arguments[_i];
13128 if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) {
13129 nextSources = nextSources[0];
13131 return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
13133 exports.onErrorResumeNext = onErrorResumeNext;
13134 function onErrorResumeNextStatic() {
13135 var nextSources = [];
13136 for (var _i = 0; _i < arguments.length; _i++) {
13137 nextSources[_i] = arguments[_i];
13140 if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) {
13141 nextSources = nextSources[0];
13143 source = nextSources.shift();
13144 return from_1.from(source, null).lift(new OnErrorResumeNextOperator(nextSources));
13146 exports.onErrorResumeNextStatic = onErrorResumeNextStatic;
13147 var OnErrorResumeNextOperator = (function () {
13148 function OnErrorResumeNextOperator(nextSources) {
13149 this.nextSources = nextSources;
13151 OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
13152 return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
13154 return OnErrorResumeNextOperator;
13156 var OnErrorResumeNextSubscriber = (function (_super) {
13157 __extends(OnErrorResumeNextSubscriber, _super);
13158 function OnErrorResumeNextSubscriber(destination, nextSources) {
13159 var _this = _super.call(this, destination) || this;
13160 _this.destination = destination;
13161 _this.nextSources = nextSources;
13164 OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) {
13165 this.subscribeToNextSource();
13167 OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) {
13168 this.subscribeToNextSource();
13170 OnErrorResumeNextSubscriber.prototype._error = function (err) {
13171 this.subscribeToNextSource();
13172 this.unsubscribe();
13174 OnErrorResumeNextSubscriber.prototype._complete = function () {
13175 this.subscribeToNextSource();
13176 this.unsubscribe();
13178 OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
13179 var next = this.nextSources.shift();
13181 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
13182 var destination = this.destination;
13183 destination.add(innerSubscriber);
13184 subscribeToResult_1.subscribeToResult(this, next, undefined, undefined, innerSubscriber);
13187 this.destination.complete();
13190 return OnErrorResumeNextSubscriber;
13191 }(OuterSubscriber_1.OuterSubscriber));
13193 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../observable/from":51,"../util/isArray":203,"../util/subscribeToResult":222}],125:[function(require,module,exports){
13195 var __extends = (this && this.__extends) || (function () {
13196 var extendStatics = function (d, b) {
13197 extendStatics = Object.setPrototypeOf ||
13198 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13199 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13200 return extendStatics(d, b);
13202 return function (d, b) {
13203 extendStatics(d, b);
13204 function __() { this.constructor = d; }
13205 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13208 Object.defineProperty(exports, "__esModule", { value: true });
13209 var Subscriber_1 = require("../Subscriber");
13210 function pairwise() {
13211 return function (source) { return source.lift(new PairwiseOperator()); };
13213 exports.pairwise = pairwise;
13214 var PairwiseOperator = (function () {
13215 function PairwiseOperator() {
13217 PairwiseOperator.prototype.call = function (subscriber, source) {
13218 return source.subscribe(new PairwiseSubscriber(subscriber));
13220 return PairwiseOperator;
13222 var PairwiseSubscriber = (function (_super) {
13223 __extends(PairwiseSubscriber, _super);
13224 function PairwiseSubscriber(destination) {
13225 var _this = _super.call(this, destination) || this;
13226 _this.hasPrev = false;
13229 PairwiseSubscriber.prototype._next = function (value) {
13230 if (this.hasPrev) {
13231 this.destination.next([this.prev, value]);
13234 this.hasPrev = true;
13238 return PairwiseSubscriber;
13239 }(Subscriber_1.Subscriber));
13241 },{"../Subscriber":39}],126:[function(require,module,exports){
13243 Object.defineProperty(exports, "__esModule", { value: true });
13244 var not_1 = require("../util/not");
13245 var filter_1 = require("./filter");
13246 function partition(predicate, thisArg) {
13247 return function (source) { return [
13248 filter_1.filter(predicate, thisArg)(source),
13249 filter_1.filter(not_1.not(predicate, thisArg))(source)
13252 exports.partition = partition;
13254 },{"../util/not":215,"./filter":103}],127:[function(require,module,exports){
13256 Object.defineProperty(exports, "__esModule", { value: true });
13257 var map_1 = require("./map");
13259 var properties = [];
13260 for (var _i = 0; _i < arguments.length; _i++) {
13261 properties[_i] = arguments[_i];
13263 var length = properties.length;
13264 if (length === 0) {
13265 throw new Error('list of properties cannot be empty.');
13267 return function (source) { return map_1.map(plucker(properties, length))(source); };
13269 exports.pluck = pluck;
13270 function plucker(props, length) {
13271 var mapper = function (x) {
13272 var currentProp = x;
13273 for (var i = 0; i < length; i++) {
13274 var p = currentProp[props[i]];
13275 if (typeof p !== 'undefined') {
13282 return currentProp;
13287 },{"./map":112}],128:[function(require,module,exports){
13289 Object.defineProperty(exports, "__esModule", { value: true });
13290 var Subject_1 = require("../Subject");
13291 var multicast_1 = require("./multicast");
13292 function publish(selector) {
13294 multicast_1.multicast(function () { return new Subject_1.Subject(); }, selector) :
13295 multicast_1.multicast(new Subject_1.Subject());
13297 exports.publish = publish;
13299 },{"../Subject":37,"./multicast":122}],129:[function(require,module,exports){
13301 Object.defineProperty(exports, "__esModule", { value: true });
13302 var BehaviorSubject_1 = require("../BehaviorSubject");
13303 var multicast_1 = require("./multicast");
13304 function publishBehavior(value) {
13305 return function (source) { return multicast_1.multicast(new BehaviorSubject_1.BehaviorSubject(value))(source); };
13307 exports.publishBehavior = publishBehavior;
13309 },{"../BehaviorSubject":29,"./multicast":122}],130:[function(require,module,exports){
13311 Object.defineProperty(exports, "__esModule", { value: true });
13312 var AsyncSubject_1 = require("../AsyncSubject");
13313 var multicast_1 = require("./multicast");
13314 function publishLast() {
13315 return function (source) { return multicast_1.multicast(new AsyncSubject_1.AsyncSubject())(source); };
13317 exports.publishLast = publishLast;
13319 },{"../AsyncSubject":28,"./multicast":122}],131:[function(require,module,exports){
13321 Object.defineProperty(exports, "__esModule", { value: true });
13322 var ReplaySubject_1 = require("../ReplaySubject");
13323 var multicast_1 = require("./multicast");
13324 function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
13325 if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
13326 scheduler = selectorOrScheduler;
13328 var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
13329 var subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler);
13330 return function (source) { return multicast_1.multicast(function () { return subject; }, selector)(source); };
13332 exports.publishReplay = publishReplay;
13334 },{"../ReplaySubject":35,"./multicast":122}],132:[function(require,module,exports){
13336 Object.defineProperty(exports, "__esModule", { value: true });
13337 var isArray_1 = require("../util/isArray");
13338 var race_1 = require("../observable/race");
13340 var observables = [];
13341 for (var _i = 0; _i < arguments.length; _i++) {
13342 observables[_i] = arguments[_i];
13344 return function raceOperatorFunction(source) {
13345 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
13346 observables = observables[0];
13348 return source.lift.call(race_1.race.apply(void 0, [source].concat(observables)));
13351 exports.race = race;
13353 },{"../observable/race":66,"../util/isArray":203}],133:[function(require,module,exports){
13355 Object.defineProperty(exports, "__esModule", { value: true });
13356 var scan_1 = require("./scan");
13357 var takeLast_1 = require("./takeLast");
13358 var defaultIfEmpty_1 = require("./defaultIfEmpty");
13359 var pipe_1 = require("../util/pipe");
13360 function reduce(accumulator, seed) {
13361 if (arguments.length >= 2) {
13362 return function reduceOperatorFunctionWithSeed(source) {
13363 return pipe_1.pipe(scan_1.scan(accumulator, seed), takeLast_1.takeLast(1), defaultIfEmpty_1.defaultIfEmpty(seed))(source);
13366 return function reduceOperatorFunction(source) {
13367 return pipe_1.pipe(scan_1.scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast_1.takeLast(1))(source);
13370 exports.reduce = reduce;
13372 },{"../util/pipe":216,"./defaultIfEmpty":90,"./scan":141,"./takeLast":156}],134:[function(require,module,exports){
13374 var __extends = (this && this.__extends) || (function () {
13375 var extendStatics = function (d, b) {
13376 extendStatics = Object.setPrototypeOf ||
13377 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13378 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13379 return extendStatics(d, b);
13381 return function (d, b) {
13382 extendStatics(d, b);
13383 function __() { this.constructor = d; }
13384 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13387 Object.defineProperty(exports, "__esModule", { value: true });
13388 var Subscriber_1 = require("../Subscriber");
13389 function refCount() {
13390 return function refCountOperatorFunction(source) {
13391 return source.lift(new RefCountOperator(source));
13394 exports.refCount = refCount;
13395 var RefCountOperator = (function () {
13396 function RefCountOperator(connectable) {
13397 this.connectable = connectable;
13399 RefCountOperator.prototype.call = function (subscriber, source) {
13400 var connectable = this.connectable;
13401 connectable._refCount++;
13402 var refCounter = new RefCountSubscriber(subscriber, connectable);
13403 var subscription = source.subscribe(refCounter);
13404 if (!refCounter.closed) {
13405 refCounter.connection = connectable.connect();
13407 return subscription;
13409 return RefCountOperator;
13411 var RefCountSubscriber = (function (_super) {
13412 __extends(RefCountSubscriber, _super);
13413 function RefCountSubscriber(destination, connectable) {
13414 var _this = _super.call(this, destination) || this;
13415 _this.connectable = connectable;
13418 RefCountSubscriber.prototype._unsubscribe = function () {
13419 var connectable = this.connectable;
13420 if (!connectable) {
13421 this.connection = null;
13424 this.connectable = null;
13425 var refCount = connectable._refCount;
13426 if (refCount <= 0) {
13427 this.connection = null;
13430 connectable._refCount = refCount - 1;
13431 if (refCount > 1) {
13432 this.connection = null;
13435 var connection = this.connection;
13436 var sharedConnection = connectable._connection;
13437 this.connection = null;
13438 if (sharedConnection && (!connection || sharedConnection === connection)) {
13439 sharedConnection.unsubscribe();
13442 return RefCountSubscriber;
13443 }(Subscriber_1.Subscriber));
13445 },{"../Subscriber":39}],135:[function(require,module,exports){
13447 var __extends = (this && this.__extends) || (function () {
13448 var extendStatics = function (d, b) {
13449 extendStatics = Object.setPrototypeOf ||
13450 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13451 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13452 return extendStatics(d, b);
13454 return function (d, b) {
13455 extendStatics(d, b);
13456 function __() { this.constructor = d; }
13457 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13460 Object.defineProperty(exports, "__esModule", { value: true });
13461 var Subscriber_1 = require("../Subscriber");
13462 var empty_1 = require("../observable/empty");
13463 function repeat(count) {
13464 if (count === void 0) { count = -1; }
13465 return function (source) {
13467 return empty_1.empty();
13469 else if (count < 0) {
13470 return source.lift(new RepeatOperator(-1, source));
13473 return source.lift(new RepeatOperator(count - 1, source));
13477 exports.repeat = repeat;
13478 var RepeatOperator = (function () {
13479 function RepeatOperator(count, source) {
13480 this.count = count;
13481 this.source = source;
13483 RepeatOperator.prototype.call = function (subscriber, source) {
13484 return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
13486 return RepeatOperator;
13488 var RepeatSubscriber = (function (_super) {
13489 __extends(RepeatSubscriber, _super);
13490 function RepeatSubscriber(destination, count, source) {
13491 var _this = _super.call(this, destination) || this;
13492 _this.count = count;
13493 _this.source = source;
13496 RepeatSubscriber.prototype.complete = function () {
13497 if (!this.isStopped) {
13498 var _a = this, source = _a.source, count = _a.count;
13500 return _super.prototype.complete.call(this);
13502 else if (count > -1) {
13503 this.count = count - 1;
13505 source.subscribe(this._unsubscribeAndRecycle());
13508 return RepeatSubscriber;
13509 }(Subscriber_1.Subscriber));
13511 },{"../Subscriber":39,"../observable/empty":49}],136:[function(require,module,exports){
13513 var __extends = (this && this.__extends) || (function () {
13514 var extendStatics = function (d, b) {
13515 extendStatics = Object.setPrototypeOf ||
13516 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13517 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13518 return extendStatics(d, b);
13520 return function (d, b) {
13521 extendStatics(d, b);
13522 function __() { this.constructor = d; }
13523 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13526 Object.defineProperty(exports, "__esModule", { value: true });
13527 var Subject_1 = require("../Subject");
13528 var tryCatch_1 = require("../util/tryCatch");
13529 var errorObject_1 = require("../util/errorObject");
13530 var OuterSubscriber_1 = require("../OuterSubscriber");
13531 var subscribeToResult_1 = require("../util/subscribeToResult");
13532 function repeatWhen(notifier) {
13533 return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
13535 exports.repeatWhen = repeatWhen;
13536 var RepeatWhenOperator = (function () {
13537 function RepeatWhenOperator(notifier) {
13538 this.notifier = notifier;
13540 RepeatWhenOperator.prototype.call = function (subscriber, source) {
13541 return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
13543 return RepeatWhenOperator;
13545 var RepeatWhenSubscriber = (function (_super) {
13546 __extends(RepeatWhenSubscriber, _super);
13547 function RepeatWhenSubscriber(destination, notifier, source) {
13548 var _this = _super.call(this, destination) || this;
13549 _this.notifier = notifier;
13550 _this.source = source;
13551 _this.sourceIsBeingSubscribedTo = true;
13554 RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
13555 this.sourceIsBeingSubscribedTo = true;
13556 this.source.subscribe(this);
13558 RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) {
13559 if (this.sourceIsBeingSubscribedTo === false) {
13560 return _super.prototype.complete.call(this);
13563 RepeatWhenSubscriber.prototype.complete = function () {
13564 this.sourceIsBeingSubscribedTo = false;
13565 if (!this.isStopped) {
13566 if (!this.retries) {
13567 this.subscribeToRetries();
13569 if (!this.retriesSubscription || this.retriesSubscription.closed) {
13570 return _super.prototype.complete.call(this);
13572 this._unsubscribeAndRecycle();
13573 this.notifications.next();
13576 RepeatWhenSubscriber.prototype._unsubscribe = function () {
13577 var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
13578 if (notifications) {
13579 notifications.unsubscribe();
13580 this.notifications = null;
13582 if (retriesSubscription) {
13583 retriesSubscription.unsubscribe();
13584 this.retriesSubscription = null;
13586 this.retries = null;
13588 RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
13589 var _unsubscribe = this._unsubscribe;
13590 this._unsubscribe = null;
13591 _super.prototype._unsubscribeAndRecycle.call(this);
13592 this._unsubscribe = _unsubscribe;
13595 RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
13596 this.notifications = new Subject_1.Subject();
13597 var retries = tryCatch_1.tryCatch(this.notifier)(this.notifications);
13598 if (retries === errorObject_1.errorObject) {
13599 return _super.prototype.complete.call(this);
13601 this.retries = retries;
13602 this.retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries);
13604 return RepeatWhenSubscriber;
13605 }(OuterSubscriber_1.OuterSubscriber));
13607 },{"../OuterSubscriber":34,"../Subject":37,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],137:[function(require,module,exports){
13609 var __extends = (this && this.__extends) || (function () {
13610 var extendStatics = function (d, b) {
13611 extendStatics = Object.setPrototypeOf ||
13612 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13613 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13614 return extendStatics(d, b);
13616 return function (d, b) {
13617 extendStatics(d, b);
13618 function __() { this.constructor = d; }
13619 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13622 Object.defineProperty(exports, "__esModule", { value: true });
13623 var Subscriber_1 = require("../Subscriber");
13624 function retry(count) {
13625 if (count === void 0) { count = -1; }
13626 return function (source) { return source.lift(new RetryOperator(count, source)); };
13628 exports.retry = retry;
13629 var RetryOperator = (function () {
13630 function RetryOperator(count, source) {
13631 this.count = count;
13632 this.source = source;
13634 RetryOperator.prototype.call = function (subscriber, source) {
13635 return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
13637 return RetryOperator;
13639 var RetrySubscriber = (function (_super) {
13640 __extends(RetrySubscriber, _super);
13641 function RetrySubscriber(destination, count, source) {
13642 var _this = _super.call(this, destination) || this;
13643 _this.count = count;
13644 _this.source = source;
13647 RetrySubscriber.prototype.error = function (err) {
13648 if (!this.isStopped) {
13649 var _a = this, source = _a.source, count = _a.count;
13651 return _super.prototype.error.call(this, err);
13653 else if (count > -1) {
13654 this.count = count - 1;
13656 source.subscribe(this._unsubscribeAndRecycle());
13659 return RetrySubscriber;
13660 }(Subscriber_1.Subscriber));
13662 },{"../Subscriber":39}],138:[function(require,module,exports){
13664 var __extends = (this && this.__extends) || (function () {
13665 var extendStatics = function (d, b) {
13666 extendStatics = Object.setPrototypeOf ||
13667 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13668 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13669 return extendStatics(d, b);
13671 return function (d, b) {
13672 extendStatics(d, b);
13673 function __() { this.constructor = d; }
13674 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13677 Object.defineProperty(exports, "__esModule", { value: true });
13678 var Subject_1 = require("../Subject");
13679 var tryCatch_1 = require("../util/tryCatch");
13680 var errorObject_1 = require("../util/errorObject");
13681 var OuterSubscriber_1 = require("../OuterSubscriber");
13682 var subscribeToResult_1 = require("../util/subscribeToResult");
13683 function retryWhen(notifier) {
13684 return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
13686 exports.retryWhen = retryWhen;
13687 var RetryWhenOperator = (function () {
13688 function RetryWhenOperator(notifier, source) {
13689 this.notifier = notifier;
13690 this.source = source;
13692 RetryWhenOperator.prototype.call = function (subscriber, source) {
13693 return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
13695 return RetryWhenOperator;
13697 var RetryWhenSubscriber = (function (_super) {
13698 __extends(RetryWhenSubscriber, _super);
13699 function RetryWhenSubscriber(destination, notifier, source) {
13700 var _this = _super.call(this, destination) || this;
13701 _this.notifier = notifier;
13702 _this.source = source;
13705 RetryWhenSubscriber.prototype.error = function (err) {
13706 if (!this.isStopped) {
13707 var errors = this.errors;
13708 var retries = this.retries;
13709 var retriesSubscription = this.retriesSubscription;
13711 errors = new Subject_1.Subject();
13712 retries = tryCatch_1.tryCatch(this.notifier)(errors);
13713 if (retries === errorObject_1.errorObject) {
13714 return _super.prototype.error.call(this, errorObject_1.errorObject.e);
13716 retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries);
13719 this.errors = null;
13720 this.retriesSubscription = null;
13722 this._unsubscribeAndRecycle();
13723 this.errors = errors;
13724 this.retries = retries;
13725 this.retriesSubscription = retriesSubscription;
13729 RetryWhenSubscriber.prototype._unsubscribe = function () {
13730 var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
13732 errors.unsubscribe();
13733 this.errors = null;
13735 if (retriesSubscription) {
13736 retriesSubscription.unsubscribe();
13737 this.retriesSubscription = null;
13739 this.retries = null;
13741 RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
13742 var _unsubscribe = this._unsubscribe;
13743 this._unsubscribe = null;
13744 this._unsubscribeAndRecycle();
13745 this._unsubscribe = _unsubscribe;
13746 this.source.subscribe(this);
13748 return RetryWhenSubscriber;
13749 }(OuterSubscriber_1.OuterSubscriber));
13751 },{"../OuterSubscriber":34,"../Subject":37,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],139:[function(require,module,exports){
13753 var __extends = (this && this.__extends) || (function () {
13754 var extendStatics = function (d, b) {
13755 extendStatics = Object.setPrototypeOf ||
13756 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13757 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13758 return extendStatics(d, b);
13760 return function (d, b) {
13761 extendStatics(d, b);
13762 function __() { this.constructor = d; }
13763 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13766 Object.defineProperty(exports, "__esModule", { value: true });
13767 var OuterSubscriber_1 = require("../OuterSubscriber");
13768 var subscribeToResult_1 = require("../util/subscribeToResult");
13769 function sample(notifier) {
13770 return function (source) { return source.lift(new SampleOperator(notifier)); };
13772 exports.sample = sample;
13773 var SampleOperator = (function () {
13774 function SampleOperator(notifier) {
13775 this.notifier = notifier;
13777 SampleOperator.prototype.call = function (subscriber, source) {
13778 var sampleSubscriber = new SampleSubscriber(subscriber);
13779 var subscription = source.subscribe(sampleSubscriber);
13780 subscription.add(subscribeToResult_1.subscribeToResult(sampleSubscriber, this.notifier));
13781 return subscription;
13783 return SampleOperator;
13785 var SampleSubscriber = (function (_super) {
13786 __extends(SampleSubscriber, _super);
13787 function SampleSubscriber() {
13788 var _this = _super !== null && _super.apply(this, arguments) || this;
13789 _this.hasValue = false;
13792 SampleSubscriber.prototype._next = function (value) {
13793 this.value = value;
13794 this.hasValue = true;
13796 SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
13799 SampleSubscriber.prototype.notifyComplete = function () {
13802 SampleSubscriber.prototype.emitValue = function () {
13803 if (this.hasValue) {
13804 this.hasValue = false;
13805 this.destination.next(this.value);
13808 return SampleSubscriber;
13809 }(OuterSubscriber_1.OuterSubscriber));
13811 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],140:[function(require,module,exports){
13813 var __extends = (this && this.__extends) || (function () {
13814 var extendStatics = function (d, b) {
13815 extendStatics = Object.setPrototypeOf ||
13816 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13817 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13818 return extendStatics(d, b);
13820 return function (d, b) {
13821 extendStatics(d, b);
13822 function __() { this.constructor = d; }
13823 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13826 Object.defineProperty(exports, "__esModule", { value: true });
13827 var Subscriber_1 = require("../Subscriber");
13828 var async_1 = require("../scheduler/async");
13829 function sampleTime(period, scheduler) {
13830 if (scheduler === void 0) { scheduler = async_1.async; }
13831 return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
13833 exports.sampleTime = sampleTime;
13834 var SampleTimeOperator = (function () {
13835 function SampleTimeOperator(period, scheduler) {
13836 this.period = period;
13837 this.scheduler = scheduler;
13839 SampleTimeOperator.prototype.call = function (subscriber, source) {
13840 return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
13842 return SampleTimeOperator;
13844 var SampleTimeSubscriber = (function (_super) {
13845 __extends(SampleTimeSubscriber, _super);
13846 function SampleTimeSubscriber(destination, period, scheduler) {
13847 var _this = _super.call(this, destination) || this;
13848 _this.period = period;
13849 _this.scheduler = scheduler;
13850 _this.hasValue = false;
13851 _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
13854 SampleTimeSubscriber.prototype._next = function (value) {
13855 this.lastValue = value;
13856 this.hasValue = true;
13858 SampleTimeSubscriber.prototype.notifyNext = function () {
13859 if (this.hasValue) {
13860 this.hasValue = false;
13861 this.destination.next(this.lastValue);
13864 return SampleTimeSubscriber;
13865 }(Subscriber_1.Subscriber));
13866 function dispatchNotification(state) {
13867 var subscriber = state.subscriber, period = state.period;
13868 subscriber.notifyNext();
13869 this.schedule(state, period);
13872 },{"../Subscriber":39,"../scheduler/async":188}],141:[function(require,module,exports){
13874 var __extends = (this && this.__extends) || (function () {
13875 var extendStatics = function (d, b) {
13876 extendStatics = Object.setPrototypeOf ||
13877 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13878 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13879 return extendStatics(d, b);
13881 return function (d, b) {
13882 extendStatics(d, b);
13883 function __() { this.constructor = d; }
13884 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13887 Object.defineProperty(exports, "__esModule", { value: true });
13888 var Subscriber_1 = require("../Subscriber");
13889 function scan(accumulator, seed) {
13890 var hasSeed = false;
13891 if (arguments.length >= 2) {
13894 return function scanOperatorFunction(source) {
13895 return source.lift(new ScanOperator(accumulator, seed, hasSeed));
13898 exports.scan = scan;
13899 var ScanOperator = (function () {
13900 function ScanOperator(accumulator, seed, hasSeed) {
13901 if (hasSeed === void 0) { hasSeed = false; }
13902 this.accumulator = accumulator;
13904 this.hasSeed = hasSeed;
13906 ScanOperator.prototype.call = function (subscriber, source) {
13907 return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
13909 return ScanOperator;
13911 var ScanSubscriber = (function (_super) {
13912 __extends(ScanSubscriber, _super);
13913 function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
13914 var _this = _super.call(this, destination) || this;
13915 _this.accumulator = accumulator;
13916 _this._seed = _seed;
13917 _this.hasSeed = hasSeed;
13921 Object.defineProperty(ScanSubscriber.prototype, "seed", {
13925 set: function (value) {
13926 this.hasSeed = true;
13927 this._seed = value;
13932 ScanSubscriber.prototype._next = function (value) {
13933 if (!this.hasSeed) {
13935 this.destination.next(value);
13938 return this._tryNext(value);
13941 ScanSubscriber.prototype._tryNext = function (value) {
13942 var index = this.index++;
13945 result = this.accumulator(this.seed, value, index);
13948 this.destination.error(err);
13950 this.seed = result;
13951 this.destination.next(result);
13953 return ScanSubscriber;
13954 }(Subscriber_1.Subscriber));
13956 },{"../Subscriber":39}],142:[function(require,module,exports){
13958 var __extends = (this && this.__extends) || (function () {
13959 var extendStatics = function (d, b) {
13960 extendStatics = Object.setPrototypeOf ||
13961 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13962 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13963 return extendStatics(d, b);
13965 return function (d, b) {
13966 extendStatics(d, b);
13967 function __() { this.constructor = d; }
13968 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13971 Object.defineProperty(exports, "__esModule", { value: true });
13972 var Subscriber_1 = require("../Subscriber");
13973 var tryCatch_1 = require("../util/tryCatch");
13974 var errorObject_1 = require("../util/errorObject");
13975 function sequenceEqual(compareTo, comparor) {
13976 return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparor)); };
13978 exports.sequenceEqual = sequenceEqual;
13979 var SequenceEqualOperator = (function () {
13980 function SequenceEqualOperator(compareTo, comparor) {
13981 this.compareTo = compareTo;
13982 this.comparor = comparor;
13984 SequenceEqualOperator.prototype.call = function (subscriber, source) {
13985 return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparor));
13987 return SequenceEqualOperator;
13989 exports.SequenceEqualOperator = SequenceEqualOperator;
13990 var SequenceEqualSubscriber = (function (_super) {
13991 __extends(SequenceEqualSubscriber, _super);
13992 function SequenceEqualSubscriber(destination, compareTo, comparor) {
13993 var _this = _super.call(this, destination) || this;
13994 _this.compareTo = compareTo;
13995 _this.comparor = comparor;
13998 _this._oneComplete = false;
13999 _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
14002 SequenceEqualSubscriber.prototype._next = function (value) {
14003 if (this._oneComplete && this._b.length === 0) {
14007 this._a.push(value);
14008 this.checkValues();
14011 SequenceEqualSubscriber.prototype._complete = function () {
14012 if (this._oneComplete) {
14013 this.emit(this._a.length === 0 && this._b.length === 0);
14016 this._oneComplete = true;
14018 this.unsubscribe();
14020 SequenceEqualSubscriber.prototype.checkValues = function () {
14021 var _c = this, _a = _c._a, _b = _c._b, comparor = _c.comparor;
14022 while (_a.length > 0 && _b.length > 0) {
14023 var a = _a.shift();
14024 var b = _b.shift();
14025 var areEqual = false;
14027 areEqual = tryCatch_1.tryCatch(comparor)(a, b);
14028 if (areEqual === errorObject_1.errorObject) {
14029 this.destination.error(errorObject_1.errorObject.e);
14033 areEqual = a === b;
14040 SequenceEqualSubscriber.prototype.emit = function (value) {
14041 var destination = this.destination;
14042 destination.next(value);
14043 destination.complete();
14045 SequenceEqualSubscriber.prototype.nextB = function (value) {
14046 if (this._oneComplete && this._a.length === 0) {
14050 this._b.push(value);
14051 this.checkValues();
14054 SequenceEqualSubscriber.prototype.completeB = function () {
14055 if (this._oneComplete) {
14056 this.emit(this._a.length === 0 && this._b.length === 0);
14059 this._oneComplete = true;
14062 return SequenceEqualSubscriber;
14063 }(Subscriber_1.Subscriber));
14064 exports.SequenceEqualSubscriber = SequenceEqualSubscriber;
14065 var SequenceEqualCompareToSubscriber = (function (_super) {
14066 __extends(SequenceEqualCompareToSubscriber, _super);
14067 function SequenceEqualCompareToSubscriber(destination, parent) {
14068 var _this = _super.call(this, destination) || this;
14069 _this.parent = parent;
14072 SequenceEqualCompareToSubscriber.prototype._next = function (value) {
14073 this.parent.nextB(value);
14075 SequenceEqualCompareToSubscriber.prototype._error = function (err) {
14076 this.parent.error(err);
14077 this.unsubscribe();
14079 SequenceEqualCompareToSubscriber.prototype._complete = function () {
14080 this.parent.completeB();
14081 this.unsubscribe();
14083 return SequenceEqualCompareToSubscriber;
14084 }(Subscriber_1.Subscriber));
14086 },{"../Subscriber":39,"../util/errorObject":200,"../util/tryCatch":224}],143:[function(require,module,exports){
14088 Object.defineProperty(exports, "__esModule", { value: true });
14089 var multicast_1 = require("./multicast");
14090 var refCount_1 = require("./refCount");
14091 var Subject_1 = require("../Subject");
14092 function shareSubjectFactory() {
14093 return new Subject_1.Subject();
14096 return function (source) { return refCount_1.refCount()(multicast_1.multicast(shareSubjectFactory)(source)); };
14098 exports.share = share;
14100 },{"../Subject":37,"./multicast":122,"./refCount":134}],144:[function(require,module,exports){
14102 Object.defineProperty(exports, "__esModule", { value: true });
14103 var ReplaySubject_1 = require("../ReplaySubject");
14104 function shareReplay(bufferSize, windowTime, scheduler) {
14105 if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
14106 if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
14107 return function (source) { return source.lift(shareReplayOperator(bufferSize, windowTime, scheduler)); };
14109 exports.shareReplay = shareReplay;
14110 function shareReplayOperator(bufferSize, windowTime, scheduler) {
14114 var hasError = false;
14115 var isComplete = false;
14116 return function shareReplayOperation(source) {
14118 if (!subject || hasError) {
14120 subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler);
14121 subscription = source.subscribe({
14122 next: function (value) { subject.next(value); },
14123 error: function (err) {
14125 subject.error(err);
14127 complete: function () {
14129 subject.complete();
14133 var innerSub = subject.subscribe(this);
14134 return function () {
14136 innerSub.unsubscribe();
14137 if (subscription && refCount === 0 && isComplete) {
14138 subscription.unsubscribe();
14144 },{"../ReplaySubject":35}],145:[function(require,module,exports){
14146 var __extends = (this && this.__extends) || (function () {
14147 var extendStatics = function (d, b) {
14148 extendStatics = Object.setPrototypeOf ||
14149 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14150 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14151 return extendStatics(d, b);
14153 return function (d, b) {
14154 extendStatics(d, b);
14155 function __() { this.constructor = d; }
14156 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14159 Object.defineProperty(exports, "__esModule", { value: true });
14160 var Subscriber_1 = require("../Subscriber");
14161 var EmptyError_1 = require("../util/EmptyError");
14162 function single(predicate) {
14163 return function (source) { return source.lift(new SingleOperator(predicate, source)); };
14165 exports.single = single;
14166 var SingleOperator = (function () {
14167 function SingleOperator(predicate, source) {
14168 this.predicate = predicate;
14169 this.source = source;
14171 SingleOperator.prototype.call = function (subscriber, source) {
14172 return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source));
14174 return SingleOperator;
14176 var SingleSubscriber = (function (_super) {
14177 __extends(SingleSubscriber, _super);
14178 function SingleSubscriber(destination, predicate, source) {
14179 var _this = _super.call(this, destination) || this;
14180 _this.predicate = predicate;
14181 _this.source = source;
14182 _this.seenValue = false;
14186 SingleSubscriber.prototype.applySingleValue = function (value) {
14187 if (this.seenValue) {
14188 this.destination.error('Sequence contains more than one element');
14191 this.seenValue = true;
14192 this.singleValue = value;
14195 SingleSubscriber.prototype._next = function (value) {
14196 var index = this.index++;
14197 if (this.predicate) {
14198 this.tryNext(value, index);
14201 this.applySingleValue(value);
14204 SingleSubscriber.prototype.tryNext = function (value, index) {
14206 if (this.predicate(value, index, this.source)) {
14207 this.applySingleValue(value);
14211 this.destination.error(err);
14214 SingleSubscriber.prototype._complete = function () {
14215 var destination = this.destination;
14216 if (this.index > 0) {
14217 destination.next(this.seenValue ? this.singleValue : undefined);
14218 destination.complete();
14221 destination.error(new EmptyError_1.EmptyError);
14224 return SingleSubscriber;
14225 }(Subscriber_1.Subscriber));
14227 },{"../Subscriber":39,"../util/EmptyError":194}],146:[function(require,module,exports){
14229 var __extends = (this && this.__extends) || (function () {
14230 var extendStatics = function (d, b) {
14231 extendStatics = Object.setPrototypeOf ||
14232 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14233 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14234 return extendStatics(d, b);
14236 return function (d, b) {
14237 extendStatics(d, b);
14238 function __() { this.constructor = d; }
14239 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14242 Object.defineProperty(exports, "__esModule", { value: true });
14243 var Subscriber_1 = require("../Subscriber");
14244 function skip(count) {
14245 return function (source) { return source.lift(new SkipOperator(count)); };
14247 exports.skip = skip;
14248 var SkipOperator = (function () {
14249 function SkipOperator(total) {
14250 this.total = total;
14252 SkipOperator.prototype.call = function (subscriber, source) {
14253 return source.subscribe(new SkipSubscriber(subscriber, this.total));
14255 return SkipOperator;
14257 var SkipSubscriber = (function (_super) {
14258 __extends(SkipSubscriber, _super);
14259 function SkipSubscriber(destination, total) {
14260 var _this = _super.call(this, destination) || this;
14261 _this.total = total;
14265 SkipSubscriber.prototype._next = function (x) {
14266 if (++this.count > this.total) {
14267 this.destination.next(x);
14270 return SkipSubscriber;
14271 }(Subscriber_1.Subscriber));
14273 },{"../Subscriber":39}],147:[function(require,module,exports){
14275 var __extends = (this && this.__extends) || (function () {
14276 var extendStatics = function (d, b) {
14277 extendStatics = Object.setPrototypeOf ||
14278 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14279 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14280 return extendStatics(d, b);
14282 return function (d, b) {
14283 extendStatics(d, b);
14284 function __() { this.constructor = d; }
14285 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14288 Object.defineProperty(exports, "__esModule", { value: true });
14289 var Subscriber_1 = require("../Subscriber");
14290 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
14291 function skipLast(count) {
14292 return function (source) { return source.lift(new SkipLastOperator(count)); };
14294 exports.skipLast = skipLast;
14295 var SkipLastOperator = (function () {
14296 function SkipLastOperator(_skipCount) {
14297 this._skipCount = _skipCount;
14298 if (this._skipCount < 0) {
14299 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
14302 SkipLastOperator.prototype.call = function (subscriber, source) {
14303 if (this._skipCount === 0) {
14304 return source.subscribe(new Subscriber_1.Subscriber(subscriber));
14307 return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
14310 return SkipLastOperator;
14312 var SkipLastSubscriber = (function (_super) {
14313 __extends(SkipLastSubscriber, _super);
14314 function SkipLastSubscriber(destination, _skipCount) {
14315 var _this = _super.call(this, destination) || this;
14316 _this._skipCount = _skipCount;
14318 _this._ring = new Array(_skipCount);
14321 SkipLastSubscriber.prototype._next = function (value) {
14322 var skipCount = this._skipCount;
14323 var count = this._count++;
14324 if (count < skipCount) {
14325 this._ring[count] = value;
14328 var currentIndex = count % skipCount;
14329 var ring = this._ring;
14330 var oldValue = ring[currentIndex];
14331 ring[currentIndex] = value;
14332 this.destination.next(oldValue);
14335 return SkipLastSubscriber;
14336 }(Subscriber_1.Subscriber));
14338 },{"../Subscriber":39,"../util/ArgumentOutOfRangeError":193}],148:[function(require,module,exports){
14340 var __extends = (this && this.__extends) || (function () {
14341 var extendStatics = function (d, b) {
14342 extendStatics = Object.setPrototypeOf ||
14343 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14344 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14345 return extendStatics(d, b);
14347 return function (d, b) {
14348 extendStatics(d, b);
14349 function __() { this.constructor = d; }
14350 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14353 Object.defineProperty(exports, "__esModule", { value: true });
14354 var OuterSubscriber_1 = require("../OuterSubscriber");
14355 var InnerSubscriber_1 = require("../InnerSubscriber");
14356 var subscribeToResult_1 = require("../util/subscribeToResult");
14357 function skipUntil(notifier) {
14358 return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
14360 exports.skipUntil = skipUntil;
14361 var SkipUntilOperator = (function () {
14362 function SkipUntilOperator(notifier) {
14363 this.notifier = notifier;
14365 SkipUntilOperator.prototype.call = function (destination, source) {
14366 return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
14368 return SkipUntilOperator;
14370 var SkipUntilSubscriber = (function (_super) {
14371 __extends(SkipUntilSubscriber, _super);
14372 function SkipUntilSubscriber(destination, notifier) {
14373 var _this = _super.call(this, destination) || this;
14374 _this.hasValue = false;
14375 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(_this, undefined, undefined);
14376 _this.add(innerSubscriber);
14377 _this.innerSubscription = innerSubscriber;
14378 subscribeToResult_1.subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
14381 SkipUntilSubscriber.prototype._next = function (value) {
14382 if (this.hasValue) {
14383 _super.prototype._next.call(this, value);
14386 SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
14387 this.hasValue = true;
14388 if (this.innerSubscription) {
14389 this.innerSubscription.unsubscribe();
14392 SkipUntilSubscriber.prototype.notifyComplete = function () {
14394 return SkipUntilSubscriber;
14395 }(OuterSubscriber_1.OuterSubscriber));
14397 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../util/subscribeToResult":222}],149:[function(require,module,exports){
14399 var __extends = (this && this.__extends) || (function () {
14400 var extendStatics = function (d, b) {
14401 extendStatics = Object.setPrototypeOf ||
14402 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14403 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14404 return extendStatics(d, b);
14406 return function (d, b) {
14407 extendStatics(d, b);
14408 function __() { this.constructor = d; }
14409 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14412 Object.defineProperty(exports, "__esModule", { value: true });
14413 var Subscriber_1 = require("../Subscriber");
14414 function skipWhile(predicate) {
14415 return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
14417 exports.skipWhile = skipWhile;
14418 var SkipWhileOperator = (function () {
14419 function SkipWhileOperator(predicate) {
14420 this.predicate = predicate;
14422 SkipWhileOperator.prototype.call = function (subscriber, source) {
14423 return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
14425 return SkipWhileOperator;
14427 var SkipWhileSubscriber = (function (_super) {
14428 __extends(SkipWhileSubscriber, _super);
14429 function SkipWhileSubscriber(destination, predicate) {
14430 var _this = _super.call(this, destination) || this;
14431 _this.predicate = predicate;
14432 _this.skipping = true;
14436 SkipWhileSubscriber.prototype._next = function (value) {
14437 var destination = this.destination;
14438 if (this.skipping) {
14439 this.tryCallPredicate(value);
14441 if (!this.skipping) {
14442 destination.next(value);
14445 SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
14447 var result = this.predicate(value, this.index++);
14448 this.skipping = Boolean(result);
14451 this.destination.error(err);
14454 return SkipWhileSubscriber;
14455 }(Subscriber_1.Subscriber));
14457 },{"../Subscriber":39}],150:[function(require,module,exports){
14459 Object.defineProperty(exports, "__esModule", { value: true });
14460 var fromArray_1 = require("../observable/fromArray");
14461 var scalar_1 = require("../observable/scalar");
14462 var empty_1 = require("../observable/empty");
14463 var concat_1 = require("../observable/concat");
14464 var isScheduler_1 = require("../util/isScheduler");
14465 function startWith() {
14467 for (var _i = 0; _i < arguments.length; _i++) {
14468 array[_i] = arguments[_i];
14470 return function (source) {
14471 var scheduler = array[array.length - 1];
14472 if (isScheduler_1.isScheduler(scheduler)) {
14478 var len = array.length;
14479 if (len === 1 && !scheduler) {
14480 return concat_1.concat(scalar_1.scalar(array[0]), source);
14482 else if (len > 0) {
14483 return concat_1.concat(fromArray_1.fromArray(array, scheduler), source);
14486 return concat_1.concat(empty_1.empty(scheduler), source);
14490 exports.startWith = startWith;
14492 },{"../observable/concat":47,"../observable/empty":49,"../observable/fromArray":52,"../observable/scalar":68,"../util/isScheduler":213}],151:[function(require,module,exports){
14494 Object.defineProperty(exports, "__esModule", { value: true });
14495 var SubscribeOnObservable_1 = require("../observable/SubscribeOnObservable");
14496 function subscribeOn(scheduler, delay) {
14497 if (delay === void 0) { delay = 0; }
14498 return function subscribeOnOperatorFunction(source) {
14499 return source.lift(new SubscribeOnOperator(scheduler, delay));
14502 exports.subscribeOn = subscribeOn;
14503 var SubscribeOnOperator = (function () {
14504 function SubscribeOnOperator(scheduler, delay) {
14505 this.scheduler = scheduler;
14506 this.delay = delay;
14508 SubscribeOnOperator.prototype.call = function (subscriber, source) {
14509 return new SubscribeOnObservable_1.SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
14511 return SubscribeOnOperator;
14514 },{"../observable/SubscribeOnObservable":43}],152:[function(require,module,exports){
14516 Object.defineProperty(exports, "__esModule", { value: true });
14517 var switchMap_1 = require("./switchMap");
14518 var identity_1 = require("../util/identity");
14519 function switchAll() {
14520 return switchMap_1.switchMap(identity_1.identity);
14522 exports.switchAll = switchAll;
14524 },{"../util/identity":202,"./switchMap":153}],153:[function(require,module,exports){
14526 var __extends = (this && this.__extends) || (function () {
14527 var extendStatics = function (d, b) {
14528 extendStatics = Object.setPrototypeOf ||
14529 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14530 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14531 return extendStatics(d, b);
14533 return function (d, b) {
14534 extendStatics(d, b);
14535 function __() { this.constructor = d; }
14536 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14539 Object.defineProperty(exports, "__esModule", { value: true });
14540 var OuterSubscriber_1 = require("../OuterSubscriber");
14541 var InnerSubscriber_1 = require("../InnerSubscriber");
14542 var subscribeToResult_1 = require("../util/subscribeToResult");
14543 var map_1 = require("./map");
14544 var from_1 = require("../observable/from");
14545 function switchMap(project, resultSelector) {
14546 if (typeof resultSelector === 'function') {
14547 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); })); })); };
14549 return function (source) { return source.lift(new SwitchMapOperator(project)); };
14551 exports.switchMap = switchMap;
14552 var SwitchMapOperator = (function () {
14553 function SwitchMapOperator(project) {
14554 this.project = project;
14556 SwitchMapOperator.prototype.call = function (subscriber, source) {
14557 return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
14559 return SwitchMapOperator;
14561 var SwitchMapSubscriber = (function (_super) {
14562 __extends(SwitchMapSubscriber, _super);
14563 function SwitchMapSubscriber(destination, project) {
14564 var _this = _super.call(this, destination) || this;
14565 _this.project = project;
14569 SwitchMapSubscriber.prototype._next = function (value) {
14571 var index = this.index++;
14573 result = this.project(value, index);
14576 this.destination.error(error);
14579 this._innerSub(result, value, index);
14581 SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
14582 var innerSubscription = this.innerSubscription;
14583 if (innerSubscription) {
14584 innerSubscription.unsubscribe();
14586 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
14587 var destination = this.destination;
14588 destination.add(innerSubscriber);
14589 this.innerSubscription = subscribeToResult_1.subscribeToResult(this, result, value, index, innerSubscriber);
14591 SwitchMapSubscriber.prototype._complete = function () {
14592 var innerSubscription = this.innerSubscription;
14593 if (!innerSubscription || innerSubscription.closed) {
14594 _super.prototype._complete.call(this);
14596 this.unsubscribe();
14598 SwitchMapSubscriber.prototype._unsubscribe = function () {
14599 this.innerSubscription = null;
14601 SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
14602 var destination = this.destination;
14603 destination.remove(innerSub);
14604 this.innerSubscription = null;
14605 if (this.isStopped) {
14606 _super.prototype._complete.call(this);
14609 SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
14610 this.destination.next(innerValue);
14612 return SwitchMapSubscriber;
14613 }(OuterSubscriber_1.OuterSubscriber));
14615 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../observable/from":51,"../util/subscribeToResult":222,"./map":112}],154:[function(require,module,exports){
14617 Object.defineProperty(exports, "__esModule", { value: true });
14618 var switchMap_1 = require("./switchMap");
14619 function switchMapTo(innerObservable, resultSelector) {
14620 return resultSelector ? switchMap_1.switchMap(function () { return innerObservable; }, resultSelector) : switchMap_1.switchMap(function () { return innerObservable; });
14622 exports.switchMapTo = switchMapTo;
14624 },{"./switchMap":153}],155:[function(require,module,exports){
14626 var __extends = (this && this.__extends) || (function () {
14627 var extendStatics = function (d, b) {
14628 extendStatics = Object.setPrototypeOf ||
14629 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14630 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14631 return extendStatics(d, b);
14633 return function (d, b) {
14634 extendStatics(d, b);
14635 function __() { this.constructor = d; }
14636 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14639 Object.defineProperty(exports, "__esModule", { value: true });
14640 var Subscriber_1 = require("../Subscriber");
14641 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
14642 var empty_1 = require("../observable/empty");
14643 function take(count) {
14644 return function (source) {
14646 return empty_1.empty();
14649 return source.lift(new TakeOperator(count));
14653 exports.take = take;
14654 var TakeOperator = (function () {
14655 function TakeOperator(total) {
14656 this.total = total;
14657 if (this.total < 0) {
14658 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
14661 TakeOperator.prototype.call = function (subscriber, source) {
14662 return source.subscribe(new TakeSubscriber(subscriber, this.total));
14664 return TakeOperator;
14666 var TakeSubscriber = (function (_super) {
14667 __extends(TakeSubscriber, _super);
14668 function TakeSubscriber(destination, total) {
14669 var _this = _super.call(this, destination) || this;
14670 _this.total = total;
14674 TakeSubscriber.prototype._next = function (value) {
14675 var total = this.total;
14676 var count = ++this.count;
14677 if (count <= total) {
14678 this.destination.next(value);
14679 if (count === total) {
14680 this.destination.complete();
14681 this.unsubscribe();
14685 return TakeSubscriber;
14686 }(Subscriber_1.Subscriber));
14688 },{"../Subscriber":39,"../observable/empty":49,"../util/ArgumentOutOfRangeError":193}],156:[function(require,module,exports){
14690 var __extends = (this && this.__extends) || (function () {
14691 var extendStatics = function (d, b) {
14692 extendStatics = Object.setPrototypeOf ||
14693 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14694 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14695 return extendStatics(d, b);
14697 return function (d, b) {
14698 extendStatics(d, b);
14699 function __() { this.constructor = d; }
14700 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14703 Object.defineProperty(exports, "__esModule", { value: true });
14704 var Subscriber_1 = require("../Subscriber");
14705 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
14706 var empty_1 = require("../observable/empty");
14707 function takeLast(count) {
14708 return function takeLastOperatorFunction(source) {
14710 return empty_1.empty();
14713 return source.lift(new TakeLastOperator(count));
14717 exports.takeLast = takeLast;
14718 var TakeLastOperator = (function () {
14719 function TakeLastOperator(total) {
14720 this.total = total;
14721 if (this.total < 0) {
14722 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
14725 TakeLastOperator.prototype.call = function (subscriber, source) {
14726 return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
14728 return TakeLastOperator;
14730 var TakeLastSubscriber = (function (_super) {
14731 __extends(TakeLastSubscriber, _super);
14732 function TakeLastSubscriber(destination, total) {
14733 var _this = _super.call(this, destination) || this;
14734 _this.total = total;
14735 _this.ring = new Array();
14739 TakeLastSubscriber.prototype._next = function (value) {
14740 var ring = this.ring;
14741 var total = this.total;
14742 var count = this.count++;
14743 if (ring.length < total) {
14747 var index = count % total;
14748 ring[index] = value;
14751 TakeLastSubscriber.prototype._complete = function () {
14752 var destination = this.destination;
14753 var count = this.count;
14755 var total = this.count >= this.total ? this.total : this.count;
14756 var ring = this.ring;
14757 for (var i = 0; i < total; i++) {
14758 var idx = (count++) % total;
14759 destination.next(ring[idx]);
14762 destination.complete();
14764 return TakeLastSubscriber;
14765 }(Subscriber_1.Subscriber));
14767 },{"../Subscriber":39,"../observable/empty":49,"../util/ArgumentOutOfRangeError":193}],157:[function(require,module,exports){
14769 var __extends = (this && this.__extends) || (function () {
14770 var extendStatics = function (d, b) {
14771 extendStatics = Object.setPrototypeOf ||
14772 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14773 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14774 return extendStatics(d, b);
14776 return function (d, b) {
14777 extendStatics(d, b);
14778 function __() { this.constructor = d; }
14779 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14782 Object.defineProperty(exports, "__esModule", { value: true });
14783 var OuterSubscriber_1 = require("../OuterSubscriber");
14784 var subscribeToResult_1 = require("../util/subscribeToResult");
14785 function takeUntil(notifier) {
14786 return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
14788 exports.takeUntil = takeUntil;
14789 var TakeUntilOperator = (function () {
14790 function TakeUntilOperator(notifier) {
14791 this.notifier = notifier;
14793 TakeUntilOperator.prototype.call = function (subscriber, source) {
14794 var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
14795 var notifierSubscription = subscribeToResult_1.subscribeToResult(takeUntilSubscriber, this.notifier);
14796 if (notifierSubscription && !takeUntilSubscriber.seenValue) {
14797 takeUntilSubscriber.add(notifierSubscription);
14798 return source.subscribe(takeUntilSubscriber);
14800 return takeUntilSubscriber;
14802 return TakeUntilOperator;
14804 var TakeUntilSubscriber = (function (_super) {
14805 __extends(TakeUntilSubscriber, _super);
14806 function TakeUntilSubscriber(destination) {
14807 var _this = _super.call(this, destination) || this;
14808 _this.seenValue = false;
14811 TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
14812 this.seenValue = true;
14815 TakeUntilSubscriber.prototype.notifyComplete = function () {
14817 return TakeUntilSubscriber;
14818 }(OuterSubscriber_1.OuterSubscriber));
14820 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],158:[function(require,module,exports){
14822 var __extends = (this && this.__extends) || (function () {
14823 var extendStatics = function (d, b) {
14824 extendStatics = Object.setPrototypeOf ||
14825 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14826 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14827 return extendStatics(d, b);
14829 return function (d, b) {
14830 extendStatics(d, b);
14831 function __() { this.constructor = d; }
14832 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14835 Object.defineProperty(exports, "__esModule", { value: true });
14836 var Subscriber_1 = require("../Subscriber");
14837 function takeWhile(predicate) {
14838 return function (source) { return source.lift(new TakeWhileOperator(predicate)); };
14840 exports.takeWhile = takeWhile;
14841 var TakeWhileOperator = (function () {
14842 function TakeWhileOperator(predicate) {
14843 this.predicate = predicate;
14845 TakeWhileOperator.prototype.call = function (subscriber, source) {
14846 return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate));
14848 return TakeWhileOperator;
14850 var TakeWhileSubscriber = (function (_super) {
14851 __extends(TakeWhileSubscriber, _super);
14852 function TakeWhileSubscriber(destination, predicate) {
14853 var _this = _super.call(this, destination) || this;
14854 _this.predicate = predicate;
14858 TakeWhileSubscriber.prototype._next = function (value) {
14859 var destination = this.destination;
14862 result = this.predicate(value, this.index++);
14865 destination.error(err);
14868 this.nextOrComplete(value, result);
14870 TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
14871 var destination = this.destination;
14872 if (Boolean(predicateResult)) {
14873 destination.next(value);
14876 destination.complete();
14879 return TakeWhileSubscriber;
14880 }(Subscriber_1.Subscriber));
14882 },{"../Subscriber":39}],159:[function(require,module,exports){
14884 var __extends = (this && this.__extends) || (function () {
14885 var extendStatics = function (d, b) {
14886 extendStatics = Object.setPrototypeOf ||
14887 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14888 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14889 return extendStatics(d, b);
14891 return function (d, b) {
14892 extendStatics(d, b);
14893 function __() { this.constructor = d; }
14894 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14897 Object.defineProperty(exports, "__esModule", { value: true });
14898 var Subscriber_1 = require("../Subscriber");
14899 var noop_1 = require("../util/noop");
14900 var isFunction_1 = require("../util/isFunction");
14901 function tap(nextOrObserver, error, complete) {
14902 return function tapOperatorFunction(source) {
14903 return source.lift(new DoOperator(nextOrObserver, error, complete));
14907 var DoOperator = (function () {
14908 function DoOperator(nextOrObserver, error, complete) {
14909 this.nextOrObserver = nextOrObserver;
14910 this.error = error;
14911 this.complete = complete;
14913 DoOperator.prototype.call = function (subscriber, source) {
14914 return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
14918 var TapSubscriber = (function (_super) {
14919 __extends(TapSubscriber, _super);
14920 function TapSubscriber(destination, observerOrNext, error, complete) {
14921 var _this = _super.call(this, destination) || this;
14922 _this._tapNext = noop_1.noop;
14923 _this._tapError = noop_1.noop;
14924 _this._tapComplete = noop_1.noop;
14925 _this._tapError = error || noop_1.noop;
14926 _this._tapComplete = complete || noop_1.noop;
14927 if (isFunction_1.isFunction(observerOrNext)) {
14928 _this._context = _this;
14929 _this._tapNext = observerOrNext;
14931 else if (observerOrNext) {
14932 _this._context = observerOrNext;
14933 _this._tapNext = observerOrNext.next || noop_1.noop;
14934 _this._tapError = observerOrNext.error || noop_1.noop;
14935 _this._tapComplete = observerOrNext.complete || noop_1.noop;
14939 TapSubscriber.prototype._next = function (value) {
14941 this._tapNext.call(this._context, value);
14944 this.destination.error(err);
14947 this.destination.next(value);
14949 TapSubscriber.prototype._error = function (err) {
14951 this._tapError.call(this._context, err);
14954 this.destination.error(err);
14957 this.destination.error(err);
14959 TapSubscriber.prototype._complete = function () {
14961 this._tapComplete.call(this._context);
14964 this.destination.error(err);
14967 return this.destination.complete();
14969 return TapSubscriber;
14970 }(Subscriber_1.Subscriber));
14972 },{"../Subscriber":39,"../util/isFunction":206,"../util/noop":214}],160:[function(require,module,exports){
14974 var __extends = (this && this.__extends) || (function () {
14975 var extendStatics = function (d, b) {
14976 extendStatics = Object.setPrototypeOf ||
14977 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14978 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14979 return extendStatics(d, b);
14981 return function (d, b) {
14982 extendStatics(d, b);
14983 function __() { this.constructor = d; }
14984 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14987 Object.defineProperty(exports, "__esModule", { value: true });
14988 var OuterSubscriber_1 = require("../OuterSubscriber");
14989 var subscribeToResult_1 = require("../util/subscribeToResult");
14990 exports.defaultThrottleConfig = {
14994 function throttle(durationSelector, config) {
14995 if (config === void 0) { config = exports.defaultThrottleConfig; }
14996 return function (source) { return source.lift(new ThrottleOperator(durationSelector, config.leading, config.trailing)); };
14998 exports.throttle = throttle;
14999 var ThrottleOperator = (function () {
15000 function ThrottleOperator(durationSelector, leading, trailing) {
15001 this.durationSelector = durationSelector;
15002 this.leading = leading;
15003 this.trailing = trailing;
15005 ThrottleOperator.prototype.call = function (subscriber, source) {
15006 return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
15008 return ThrottleOperator;
15010 var ThrottleSubscriber = (function (_super) {
15011 __extends(ThrottleSubscriber, _super);
15012 function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
15013 var _this = _super.call(this, destination) || this;
15014 _this.destination = destination;
15015 _this.durationSelector = durationSelector;
15016 _this._leading = _leading;
15017 _this._trailing = _trailing;
15018 _this._hasValue = false;
15021 ThrottleSubscriber.prototype._next = function (value) {
15022 this._hasValue = true;
15023 this._sendValue = value;
15024 if (!this._throttled) {
15025 if (this._leading) {
15029 this.throttle(value);
15033 ThrottleSubscriber.prototype.send = function () {
15034 var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
15036 this.destination.next(_sendValue);
15037 this.throttle(_sendValue);
15039 this._hasValue = false;
15040 this._sendValue = null;
15042 ThrottleSubscriber.prototype.throttle = function (value) {
15043 var duration = this.tryDurationSelector(value);
15045 this.add(this._throttled = subscribeToResult_1.subscribeToResult(this, duration));
15048 ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
15050 return this.durationSelector(value);
15053 this.destination.error(err);
15057 ThrottleSubscriber.prototype.throttlingDone = function () {
15058 var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
15060 _throttled.unsubscribe();
15062 this._throttled = null;
15067 ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15068 this.throttlingDone();
15070 ThrottleSubscriber.prototype.notifyComplete = function () {
15071 this.throttlingDone();
15073 return ThrottleSubscriber;
15074 }(OuterSubscriber_1.OuterSubscriber));
15076 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],161:[function(require,module,exports){
15078 var __extends = (this && this.__extends) || (function () {
15079 var extendStatics = function (d, b) {
15080 extendStatics = Object.setPrototypeOf ||
15081 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15082 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15083 return extendStatics(d, b);
15085 return function (d, b) {
15086 extendStatics(d, b);
15087 function __() { this.constructor = d; }
15088 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15091 Object.defineProperty(exports, "__esModule", { value: true });
15092 var Subscriber_1 = require("../Subscriber");
15093 var async_1 = require("../scheduler/async");
15094 var throttle_1 = require("./throttle");
15095 function throttleTime(duration, scheduler, config) {
15096 if (scheduler === void 0) { scheduler = async_1.async; }
15097 if (config === void 0) { config = throttle_1.defaultThrottleConfig; }
15098 return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
15100 exports.throttleTime = throttleTime;
15101 var ThrottleTimeOperator = (function () {
15102 function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
15103 this.duration = duration;
15104 this.scheduler = scheduler;
15105 this.leading = leading;
15106 this.trailing = trailing;
15108 ThrottleTimeOperator.prototype.call = function (subscriber, source) {
15109 return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
15111 return ThrottleTimeOperator;
15113 var ThrottleTimeSubscriber = (function (_super) {
15114 __extends(ThrottleTimeSubscriber, _super);
15115 function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
15116 var _this = _super.call(this, destination) || this;
15117 _this.duration = duration;
15118 _this.scheduler = scheduler;
15119 _this.leading = leading;
15120 _this.trailing = trailing;
15121 _this._hasTrailingValue = false;
15122 _this._trailingValue = null;
15125 ThrottleTimeSubscriber.prototype._next = function (value) {
15126 if (this.throttled) {
15127 if (this.trailing) {
15128 this._trailingValue = value;
15129 this._hasTrailingValue = true;
15133 this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, { subscriber: this }));
15134 if (this.leading) {
15135 this.destination.next(value);
15139 ThrottleTimeSubscriber.prototype._complete = function () {
15140 if (this._hasTrailingValue) {
15141 this.destination.next(this._trailingValue);
15142 this.destination.complete();
15145 this.destination.complete();
15148 ThrottleTimeSubscriber.prototype.clearThrottle = function () {
15149 var throttled = this.throttled;
15151 if (this.trailing && this._hasTrailingValue) {
15152 this.destination.next(this._trailingValue);
15153 this._trailingValue = null;
15154 this._hasTrailingValue = false;
15156 throttled.unsubscribe();
15157 this.remove(throttled);
15158 this.throttled = null;
15161 return ThrottleTimeSubscriber;
15162 }(Subscriber_1.Subscriber));
15163 function dispatchNext(arg) {
15164 var subscriber = arg.subscriber;
15165 subscriber.clearThrottle();
15168 },{"../Subscriber":39,"../scheduler/async":188,"./throttle":160}],162:[function(require,module,exports){
15170 Object.defineProperty(exports, "__esModule", { value: true });
15171 var tap_1 = require("./tap");
15172 var EmptyError_1 = require("../util/EmptyError");
15173 exports.throwIfEmpty = function (errorFactory) {
15174 if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
15177 next: function () { this.hasValue = true; },
15178 complete: function () {
15179 if (!this.hasValue) {
15180 throw errorFactory();
15185 function defaultErrorFactory() {
15186 return new EmptyError_1.EmptyError();
15189 },{"../util/EmptyError":194,"./tap":159}],163:[function(require,module,exports){
15191 Object.defineProperty(exports, "__esModule", { value: true });
15192 var async_1 = require("../scheduler/async");
15193 var scan_1 = require("./scan");
15194 var defer_1 = require("../observable/defer");
15195 var map_1 = require("./map");
15196 function timeInterval(scheduler) {
15197 if (scheduler === void 0) { scheduler = async_1.async; }
15198 return function (source) { return defer_1.defer(function () {
15199 return source.pipe(scan_1.scan(function (_a, value) {
15200 var current = _a.current;
15201 return ({ value: value, current: scheduler.now(), last: current });
15202 }, { current: scheduler.now(), value: undefined, last: undefined }), map_1.map(function (_a) {
15203 var current = _a.current, last = _a.last, value = _a.value;
15204 return new TimeInterval(value, current - last);
15208 exports.timeInterval = timeInterval;
15209 var TimeInterval = (function () {
15210 function TimeInterval(value, interval) {
15211 this.value = value;
15212 this.interval = interval;
15214 return TimeInterval;
15216 exports.TimeInterval = TimeInterval;
15218 },{"../observable/defer":48,"../scheduler/async":188,"./map":112,"./scan":141}],164:[function(require,module,exports){
15220 Object.defineProperty(exports, "__esModule", { value: true });
15221 var async_1 = require("../scheduler/async");
15222 var TimeoutError_1 = require("../util/TimeoutError");
15223 var timeoutWith_1 = require("./timeoutWith");
15224 var throwError_1 = require("../observable/throwError");
15225 function timeout(due, scheduler) {
15226 if (scheduler === void 0) { scheduler = async_1.async; }
15227 return timeoutWith_1.timeoutWith(due, throwError_1.throwError(new TimeoutError_1.TimeoutError()), scheduler);
15229 exports.timeout = timeout;
15231 },{"../observable/throwError":69,"../scheduler/async":188,"../util/TimeoutError":197,"./timeoutWith":165}],165:[function(require,module,exports){
15233 var __extends = (this && this.__extends) || (function () {
15234 var extendStatics = function (d, b) {
15235 extendStatics = Object.setPrototypeOf ||
15236 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15237 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15238 return extendStatics(d, b);
15240 return function (d, b) {
15241 extendStatics(d, b);
15242 function __() { this.constructor = d; }
15243 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15246 Object.defineProperty(exports, "__esModule", { value: true });
15247 var async_1 = require("../scheduler/async");
15248 var isDate_1 = require("../util/isDate");
15249 var OuterSubscriber_1 = require("../OuterSubscriber");
15250 var subscribeToResult_1 = require("../util/subscribeToResult");
15251 function timeoutWith(due, withObservable, scheduler) {
15252 if (scheduler === void 0) { scheduler = async_1.async; }
15253 return function (source) {
15254 var absoluteTimeout = isDate_1.isDate(due);
15255 var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
15256 return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
15259 exports.timeoutWith = timeoutWith;
15260 var TimeoutWithOperator = (function () {
15261 function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
15262 this.waitFor = waitFor;
15263 this.absoluteTimeout = absoluteTimeout;
15264 this.withObservable = withObservable;
15265 this.scheduler = scheduler;
15267 TimeoutWithOperator.prototype.call = function (subscriber, source) {
15268 return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
15270 return TimeoutWithOperator;
15272 var TimeoutWithSubscriber = (function (_super) {
15273 __extends(TimeoutWithSubscriber, _super);
15274 function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
15275 var _this = _super.call(this, destination) || this;
15276 _this.absoluteTimeout = absoluteTimeout;
15277 _this.waitFor = waitFor;
15278 _this.withObservable = withObservable;
15279 _this.scheduler = scheduler;
15280 _this.action = null;
15281 _this.scheduleTimeout();
15284 TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
15285 var withObservable = subscriber.withObservable;
15286 subscriber._unsubscribeAndRecycle();
15287 subscriber.add(subscribeToResult_1.subscribeToResult(subscriber, withObservable));
15289 TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
15290 var action = this.action;
15292 this.action = action.schedule(this, this.waitFor);
15295 this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
15298 TimeoutWithSubscriber.prototype._next = function (value) {
15299 if (!this.absoluteTimeout) {
15300 this.scheduleTimeout();
15302 _super.prototype._next.call(this, value);
15304 TimeoutWithSubscriber.prototype._unsubscribe = function () {
15305 this.action = null;
15306 this.scheduler = null;
15307 this.withObservable = null;
15309 return TimeoutWithSubscriber;
15310 }(OuterSubscriber_1.OuterSubscriber));
15312 },{"../OuterSubscriber":34,"../scheduler/async":188,"../util/isDate":205,"../util/subscribeToResult":222}],166:[function(require,module,exports){
15314 Object.defineProperty(exports, "__esModule", { value: true });
15315 var async_1 = require("../scheduler/async");
15316 var map_1 = require("./map");
15317 function timestamp(scheduler) {
15318 if (scheduler === void 0) { scheduler = async_1.async; }
15319 return map_1.map(function (value) { return new Timestamp(value, scheduler.now()); });
15321 exports.timestamp = timestamp;
15322 var Timestamp = (function () {
15323 function Timestamp(value, timestamp) {
15324 this.value = value;
15325 this.timestamp = timestamp;
15329 exports.Timestamp = Timestamp;
15331 },{"../scheduler/async":188,"./map":112}],167:[function(require,module,exports){
15333 Object.defineProperty(exports, "__esModule", { value: true });
15334 var reduce_1 = require("./reduce");
15335 function toArrayReducer(arr, item, index) {
15342 function toArray() {
15343 return reduce_1.reduce(toArrayReducer, []);
15345 exports.toArray = toArray;
15347 },{"./reduce":133}],168:[function(require,module,exports){
15349 var __extends = (this && this.__extends) || (function () {
15350 var extendStatics = function (d, b) {
15351 extendStatics = Object.setPrototypeOf ||
15352 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15353 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15354 return extendStatics(d, b);
15356 return function (d, b) {
15357 extendStatics(d, b);
15358 function __() { this.constructor = d; }
15359 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15362 Object.defineProperty(exports, "__esModule", { value: true });
15363 var Subject_1 = require("../Subject");
15364 var OuterSubscriber_1 = require("../OuterSubscriber");
15365 var subscribeToResult_1 = require("../util/subscribeToResult");
15366 function window(windowBoundaries) {
15367 return function windowOperatorFunction(source) {
15368 return source.lift(new WindowOperator(windowBoundaries));
15371 exports.window = window;
15372 var WindowOperator = (function () {
15373 function WindowOperator(windowBoundaries) {
15374 this.windowBoundaries = windowBoundaries;
15376 WindowOperator.prototype.call = function (subscriber, source) {
15377 var windowSubscriber = new WindowSubscriber(subscriber);
15378 var sourceSubscription = source.subscribe(windowSubscriber);
15379 if (!sourceSubscription.closed) {
15380 windowSubscriber.add(subscribeToResult_1.subscribeToResult(windowSubscriber, this.windowBoundaries));
15382 return sourceSubscription;
15384 return WindowOperator;
15386 var WindowSubscriber = (function (_super) {
15387 __extends(WindowSubscriber, _super);
15388 function WindowSubscriber(destination) {
15389 var _this = _super.call(this, destination) || this;
15390 _this.window = new Subject_1.Subject();
15391 destination.next(_this.window);
15394 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15397 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
15398 this._error(error);
15400 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
15403 WindowSubscriber.prototype._next = function (value) {
15404 this.window.next(value);
15406 WindowSubscriber.prototype._error = function (err) {
15407 this.window.error(err);
15408 this.destination.error(err);
15410 WindowSubscriber.prototype._complete = function () {
15411 this.window.complete();
15412 this.destination.complete();
15414 WindowSubscriber.prototype._unsubscribe = function () {
15415 this.window = null;
15417 WindowSubscriber.prototype.openWindow = function () {
15418 var prevWindow = this.window;
15420 prevWindow.complete();
15422 var destination = this.destination;
15423 var newWindow = this.window = new Subject_1.Subject();
15424 destination.next(newWindow);
15426 return WindowSubscriber;
15427 }(OuterSubscriber_1.OuterSubscriber));
15429 },{"../OuterSubscriber":34,"../Subject":37,"../util/subscribeToResult":222}],169:[function(require,module,exports){
15431 var __extends = (this && this.__extends) || (function () {
15432 var extendStatics = function (d, b) {
15433 extendStatics = Object.setPrototypeOf ||
15434 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15435 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15436 return extendStatics(d, b);
15438 return function (d, b) {
15439 extendStatics(d, b);
15440 function __() { this.constructor = d; }
15441 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15444 Object.defineProperty(exports, "__esModule", { value: true });
15445 var Subscriber_1 = require("../Subscriber");
15446 var Subject_1 = require("../Subject");
15447 function windowCount(windowSize, startWindowEvery) {
15448 if (startWindowEvery === void 0) { startWindowEvery = 0; }
15449 return function windowCountOperatorFunction(source) {
15450 return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
15453 exports.windowCount = windowCount;
15454 var WindowCountOperator = (function () {
15455 function WindowCountOperator(windowSize, startWindowEvery) {
15456 this.windowSize = windowSize;
15457 this.startWindowEvery = startWindowEvery;
15459 WindowCountOperator.prototype.call = function (subscriber, source) {
15460 return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
15462 return WindowCountOperator;
15464 var WindowCountSubscriber = (function (_super) {
15465 __extends(WindowCountSubscriber, _super);
15466 function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
15467 var _this = _super.call(this, destination) || this;
15468 _this.destination = destination;
15469 _this.windowSize = windowSize;
15470 _this.startWindowEvery = startWindowEvery;
15471 _this.windows = [new Subject_1.Subject()];
15473 destination.next(_this.windows[0]);
15476 WindowCountSubscriber.prototype._next = function (value) {
15477 var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
15478 var destination = this.destination;
15479 var windowSize = this.windowSize;
15480 var windows = this.windows;
15481 var len = windows.length;
15482 for (var i = 0; i < len && !this.closed; i++) {
15483 windows[i].next(value);
15485 var c = this.count - windowSize + 1;
15486 if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
15487 windows.shift().complete();
15489 if (++this.count % startWindowEvery === 0 && !this.closed) {
15490 var window_1 = new Subject_1.Subject();
15491 windows.push(window_1);
15492 destination.next(window_1);
15495 WindowCountSubscriber.prototype._error = function (err) {
15496 var windows = this.windows;
15498 while (windows.length > 0 && !this.closed) {
15499 windows.shift().error(err);
15502 this.destination.error(err);
15504 WindowCountSubscriber.prototype._complete = function () {
15505 var windows = this.windows;
15507 while (windows.length > 0 && !this.closed) {
15508 windows.shift().complete();
15511 this.destination.complete();
15513 WindowCountSubscriber.prototype._unsubscribe = function () {
15515 this.windows = null;
15517 return WindowCountSubscriber;
15518 }(Subscriber_1.Subscriber));
15520 },{"../Subject":37,"../Subscriber":39}],170:[function(require,module,exports){
15522 var __extends = (this && this.__extends) || (function () {
15523 var extendStatics = function (d, b) {
15524 extendStatics = Object.setPrototypeOf ||
15525 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15526 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15527 return extendStatics(d, b);
15529 return function (d, b) {
15530 extendStatics(d, b);
15531 function __() { this.constructor = d; }
15532 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15535 Object.defineProperty(exports, "__esModule", { value: true });
15536 var Subject_1 = require("../Subject");
15537 var async_1 = require("../scheduler/async");
15538 var Subscriber_1 = require("../Subscriber");
15539 var isNumeric_1 = require("../util/isNumeric");
15540 var isScheduler_1 = require("../util/isScheduler");
15541 function windowTime(windowTimeSpan) {
15542 var scheduler = async_1.async;
15543 var windowCreationInterval = null;
15544 var maxWindowSize = Number.POSITIVE_INFINITY;
15545 if (isScheduler_1.isScheduler(arguments[3])) {
15546 scheduler = arguments[3];
15548 if (isScheduler_1.isScheduler(arguments[2])) {
15549 scheduler = arguments[2];
15551 else if (isNumeric_1.isNumeric(arguments[2])) {
15552 maxWindowSize = arguments[2];
15554 if (isScheduler_1.isScheduler(arguments[1])) {
15555 scheduler = arguments[1];
15557 else if (isNumeric_1.isNumeric(arguments[1])) {
15558 windowCreationInterval = arguments[1];
15560 return function windowTimeOperatorFunction(source) {
15561 return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
15564 exports.windowTime = windowTime;
15565 var WindowTimeOperator = (function () {
15566 function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
15567 this.windowTimeSpan = windowTimeSpan;
15568 this.windowCreationInterval = windowCreationInterval;
15569 this.maxWindowSize = maxWindowSize;
15570 this.scheduler = scheduler;
15572 WindowTimeOperator.prototype.call = function (subscriber, source) {
15573 return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
15575 return WindowTimeOperator;
15577 var CountedSubject = (function (_super) {
15578 __extends(CountedSubject, _super);
15579 function CountedSubject() {
15580 var _this = _super !== null && _super.apply(this, arguments) || this;
15581 _this._numberOfNextedValues = 0;
15584 CountedSubject.prototype.next = function (value) {
15585 this._numberOfNextedValues++;
15586 _super.prototype.next.call(this, value);
15588 Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
15590 return this._numberOfNextedValues;
15595 return CountedSubject;
15596 }(Subject_1.Subject));
15597 var WindowTimeSubscriber = (function (_super) {
15598 __extends(WindowTimeSubscriber, _super);
15599 function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
15600 var _this = _super.call(this, destination) || this;
15601 _this.destination = destination;
15602 _this.windowTimeSpan = windowTimeSpan;
15603 _this.windowCreationInterval = windowCreationInterval;
15604 _this.maxWindowSize = maxWindowSize;
15605 _this.scheduler = scheduler;
15606 _this.windows = [];
15607 var window = _this.openWindow();
15608 if (windowCreationInterval !== null && windowCreationInterval >= 0) {
15609 var closeState = { subscriber: _this, window: window, context: null };
15610 var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
15611 _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
15612 _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
15615 var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
15616 _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
15620 WindowTimeSubscriber.prototype._next = function (value) {
15621 var windows = this.windows;
15622 var len = windows.length;
15623 for (var i = 0; i < len; i++) {
15624 var window_1 = windows[i];
15625 if (!window_1.closed) {
15626 window_1.next(value);
15627 if (window_1.numberOfNextedValues >= this.maxWindowSize) {
15628 this.closeWindow(window_1);
15633 WindowTimeSubscriber.prototype._error = function (err) {
15634 var windows = this.windows;
15635 while (windows.length > 0) {
15636 windows.shift().error(err);
15638 this.destination.error(err);
15640 WindowTimeSubscriber.prototype._complete = function () {
15641 var windows = this.windows;
15642 while (windows.length > 0) {
15643 var window_2 = windows.shift();
15644 if (!window_2.closed) {
15645 window_2.complete();
15648 this.destination.complete();
15650 WindowTimeSubscriber.prototype.openWindow = function () {
15651 var window = new CountedSubject();
15652 this.windows.push(window);
15653 var destination = this.destination;
15654 destination.next(window);
15657 WindowTimeSubscriber.prototype.closeWindow = function (window) {
15659 var windows = this.windows;
15660 windows.splice(windows.indexOf(window), 1);
15662 return WindowTimeSubscriber;
15663 }(Subscriber_1.Subscriber));
15664 function dispatchWindowTimeSpanOnly(state) {
15665 var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
15667 subscriber.closeWindow(window);
15669 state.window = subscriber.openWindow();
15670 this.schedule(state, windowTimeSpan);
15672 function dispatchWindowCreation(state) {
15673 var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
15674 var window = subscriber.openWindow();
15676 var context = { action: action, subscription: null };
15677 var timeSpanState = { subscriber: subscriber, window: window, context: context };
15678 context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
15679 action.add(context.subscription);
15680 action.schedule(state, windowCreationInterval);
15682 function dispatchWindowClose(state) {
15683 var subscriber = state.subscriber, window = state.window, context = state.context;
15684 if (context && context.action && context.subscription) {
15685 context.action.remove(context.subscription);
15687 subscriber.closeWindow(window);
15690 },{"../Subject":37,"../Subscriber":39,"../scheduler/async":188,"../util/isNumeric":209,"../util/isScheduler":213}],171:[function(require,module,exports){
15692 var __extends = (this && this.__extends) || (function () {
15693 var extendStatics = function (d, b) {
15694 extendStatics = Object.setPrototypeOf ||
15695 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15696 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15697 return extendStatics(d, b);
15699 return function (d, b) {
15700 extendStatics(d, b);
15701 function __() { this.constructor = d; }
15702 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15705 Object.defineProperty(exports, "__esModule", { value: true });
15706 var Subject_1 = require("../Subject");
15707 var Subscription_1 = require("../Subscription");
15708 var tryCatch_1 = require("../util/tryCatch");
15709 var errorObject_1 = require("../util/errorObject");
15710 var OuterSubscriber_1 = require("../OuterSubscriber");
15711 var subscribeToResult_1 = require("../util/subscribeToResult");
15712 function windowToggle(openings, closingSelector) {
15713 return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
15715 exports.windowToggle = windowToggle;
15716 var WindowToggleOperator = (function () {
15717 function WindowToggleOperator(openings, closingSelector) {
15718 this.openings = openings;
15719 this.closingSelector = closingSelector;
15721 WindowToggleOperator.prototype.call = function (subscriber, source) {
15722 return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
15724 return WindowToggleOperator;
15726 var WindowToggleSubscriber = (function (_super) {
15727 __extends(WindowToggleSubscriber, _super);
15728 function WindowToggleSubscriber(destination, openings, closingSelector) {
15729 var _this = _super.call(this, destination) || this;
15730 _this.openings = openings;
15731 _this.closingSelector = closingSelector;
15732 _this.contexts = [];
15733 _this.add(_this.openSubscription = subscribeToResult_1.subscribeToResult(_this, openings, openings));
15736 WindowToggleSubscriber.prototype._next = function (value) {
15737 var contexts = this.contexts;
15739 var len = contexts.length;
15740 for (var i = 0; i < len; i++) {
15741 contexts[i].window.next(value);
15745 WindowToggleSubscriber.prototype._error = function (err) {
15746 var contexts = this.contexts;
15747 this.contexts = null;
15749 var len = contexts.length;
15751 while (++index < len) {
15752 var context_1 = contexts[index];
15753 context_1.window.error(err);
15754 context_1.subscription.unsubscribe();
15757 _super.prototype._error.call(this, err);
15759 WindowToggleSubscriber.prototype._complete = function () {
15760 var contexts = this.contexts;
15761 this.contexts = null;
15763 var len = contexts.length;
15765 while (++index < len) {
15766 var context_2 = contexts[index];
15767 context_2.window.complete();
15768 context_2.subscription.unsubscribe();
15771 _super.prototype._complete.call(this);
15773 WindowToggleSubscriber.prototype._unsubscribe = function () {
15774 var contexts = this.contexts;
15775 this.contexts = null;
15777 var len = contexts.length;
15779 while (++index < len) {
15780 var context_3 = contexts[index];
15781 context_3.window.unsubscribe();
15782 context_3.subscription.unsubscribe();
15786 WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15787 if (outerValue === this.openings) {
15788 var closingSelector = this.closingSelector;
15789 var closingNotifier = tryCatch_1.tryCatch(closingSelector)(innerValue);
15790 if (closingNotifier === errorObject_1.errorObject) {
15791 return this.error(errorObject_1.errorObject.e);
15794 var window_1 = new Subject_1.Subject();
15795 var subscription = new Subscription_1.Subscription();
15796 var context_4 = { window: window_1, subscription: subscription };
15797 this.contexts.push(context_4);
15798 var innerSubscription = subscribeToResult_1.subscribeToResult(this, closingNotifier, context_4);
15799 if (innerSubscription.closed) {
15800 this.closeWindow(this.contexts.length - 1);
15803 innerSubscription.context = context_4;
15804 subscription.add(innerSubscription);
15806 this.destination.next(window_1);
15810 this.closeWindow(this.contexts.indexOf(outerValue));
15813 WindowToggleSubscriber.prototype.notifyError = function (err) {
15816 WindowToggleSubscriber.prototype.notifyComplete = function (inner) {
15817 if (inner !== this.openSubscription) {
15818 this.closeWindow(this.contexts.indexOf(inner.context));
15821 WindowToggleSubscriber.prototype.closeWindow = function (index) {
15822 if (index === -1) {
15825 var contexts = this.contexts;
15826 var context = contexts[index];
15827 var window = context.window, subscription = context.subscription;
15828 contexts.splice(index, 1);
15830 subscription.unsubscribe();
15832 return WindowToggleSubscriber;
15833 }(OuterSubscriber_1.OuterSubscriber));
15835 },{"../OuterSubscriber":34,"../Subject":37,"../Subscription":40,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],172:[function(require,module,exports){
15837 var __extends = (this && this.__extends) || (function () {
15838 var extendStatics = function (d, b) {
15839 extendStatics = Object.setPrototypeOf ||
15840 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15841 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15842 return extendStatics(d, b);
15844 return function (d, b) {
15845 extendStatics(d, b);
15846 function __() { this.constructor = d; }
15847 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15850 Object.defineProperty(exports, "__esModule", { value: true });
15851 var Subject_1 = require("../Subject");
15852 var tryCatch_1 = require("../util/tryCatch");
15853 var errorObject_1 = require("../util/errorObject");
15854 var OuterSubscriber_1 = require("../OuterSubscriber");
15855 var subscribeToResult_1 = require("../util/subscribeToResult");
15856 function windowWhen(closingSelector) {
15857 return function windowWhenOperatorFunction(source) {
15858 return source.lift(new WindowOperator(closingSelector));
15861 exports.windowWhen = windowWhen;
15862 var WindowOperator = (function () {
15863 function WindowOperator(closingSelector) {
15864 this.closingSelector = closingSelector;
15866 WindowOperator.prototype.call = function (subscriber, source) {
15867 return source.subscribe(new WindowSubscriber(subscriber, this.closingSelector));
15869 return WindowOperator;
15871 var WindowSubscriber = (function (_super) {
15872 __extends(WindowSubscriber, _super);
15873 function WindowSubscriber(destination, closingSelector) {
15874 var _this = _super.call(this, destination) || this;
15875 _this.destination = destination;
15876 _this.closingSelector = closingSelector;
15877 _this.openWindow();
15880 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15881 this.openWindow(innerSub);
15883 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
15884 this._error(error);
15886 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
15887 this.openWindow(innerSub);
15889 WindowSubscriber.prototype._next = function (value) {
15890 this.window.next(value);
15892 WindowSubscriber.prototype._error = function (err) {
15893 this.window.error(err);
15894 this.destination.error(err);
15895 this.unsubscribeClosingNotification();
15897 WindowSubscriber.prototype._complete = function () {
15898 this.window.complete();
15899 this.destination.complete();
15900 this.unsubscribeClosingNotification();
15902 WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
15903 if (this.closingNotification) {
15904 this.closingNotification.unsubscribe();
15907 WindowSubscriber.prototype.openWindow = function (innerSub) {
15908 if (innerSub === void 0) { innerSub = null; }
15910 this.remove(innerSub);
15911 innerSub.unsubscribe();
15913 var prevWindow = this.window;
15915 prevWindow.complete();
15917 var window = this.window = new Subject_1.Subject();
15918 this.destination.next(window);
15919 var closingNotifier = tryCatch_1.tryCatch(this.closingSelector)();
15920 if (closingNotifier === errorObject_1.errorObject) {
15921 var err = errorObject_1.errorObject.e;
15922 this.destination.error(err);
15923 this.window.error(err);
15926 this.add(this.closingNotification = subscribeToResult_1.subscribeToResult(this, closingNotifier));
15929 return WindowSubscriber;
15930 }(OuterSubscriber_1.OuterSubscriber));
15932 },{"../OuterSubscriber":34,"../Subject":37,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],173:[function(require,module,exports){
15934 var __extends = (this && this.__extends) || (function () {
15935 var extendStatics = function (d, b) {
15936 extendStatics = Object.setPrototypeOf ||
15937 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15938 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15939 return extendStatics(d, b);
15941 return function (d, b) {
15942 extendStatics(d, b);
15943 function __() { this.constructor = d; }
15944 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15947 Object.defineProperty(exports, "__esModule", { value: true });
15948 var OuterSubscriber_1 = require("../OuterSubscriber");
15949 var subscribeToResult_1 = require("../util/subscribeToResult");
15950 function withLatestFrom() {
15952 for (var _i = 0; _i < arguments.length; _i++) {
15953 args[_i] = arguments[_i];
15955 return function (source) {
15957 if (typeof args[args.length - 1] === 'function') {
15958 project = args.pop();
15960 var observables = args;
15961 return source.lift(new WithLatestFromOperator(observables, project));
15964 exports.withLatestFrom = withLatestFrom;
15965 var WithLatestFromOperator = (function () {
15966 function WithLatestFromOperator(observables, project) {
15967 this.observables = observables;
15968 this.project = project;
15970 WithLatestFromOperator.prototype.call = function (subscriber, source) {
15971 return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
15973 return WithLatestFromOperator;
15975 var WithLatestFromSubscriber = (function (_super) {
15976 __extends(WithLatestFromSubscriber, _super);
15977 function WithLatestFromSubscriber(destination, observables, project) {
15978 var _this = _super.call(this, destination) || this;
15979 _this.observables = observables;
15980 _this.project = project;
15981 _this.toRespond = [];
15982 var len = observables.length;
15983 _this.values = new Array(len);
15984 for (var i = 0; i < len; i++) {
15985 _this.toRespond.push(i);
15987 for (var i = 0; i < len; i++) {
15988 var observable = observables[i];
15989 _this.add(subscribeToResult_1.subscribeToResult(_this, observable, observable, i));
15993 WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15994 this.values[outerIndex] = innerValue;
15995 var toRespond = this.toRespond;
15996 if (toRespond.length > 0) {
15997 var found = toRespond.indexOf(outerIndex);
15998 if (found !== -1) {
15999 toRespond.splice(found, 1);
16003 WithLatestFromSubscriber.prototype.notifyComplete = function () {
16005 WithLatestFromSubscriber.prototype._next = function (value) {
16006 if (this.toRespond.length === 0) {
16007 var args = [value].concat(this.values);
16008 if (this.project) {
16009 this._tryProject(args);
16012 this.destination.next(args);
16016 WithLatestFromSubscriber.prototype._tryProject = function (args) {
16019 result = this.project.apply(this, args);
16022 this.destination.error(err);
16025 this.destination.next(result);
16027 return WithLatestFromSubscriber;
16028 }(OuterSubscriber_1.OuterSubscriber));
16030 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],174:[function(require,module,exports){
16032 Object.defineProperty(exports, "__esModule", { value: true });
16033 var zip_1 = require("../observable/zip");
16035 var observables = [];
16036 for (var _i = 0; _i < arguments.length; _i++) {
16037 observables[_i] = arguments[_i];
16039 return function zipOperatorFunction(source) {
16040 return source.lift.call(zip_1.zip.apply(void 0, [source].concat(observables)));
16045 },{"../observable/zip":72}],175:[function(require,module,exports){
16047 Object.defineProperty(exports, "__esModule", { value: true });
16048 var zip_1 = require("../observable/zip");
16049 function zipAll(project) {
16050 return function (source) { return source.lift(new zip_1.ZipOperator(project)); };
16052 exports.zipAll = zipAll;
16054 },{"../observable/zip":72}],176:[function(require,module,exports){
16056 var __extends = (this && this.__extends) || (function () {
16057 var extendStatics = function (d, b) {
16058 extendStatics = Object.setPrototypeOf ||
16059 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16060 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16061 return extendStatics(d, b);
16063 return function (d, b) {
16064 extendStatics(d, b);
16065 function __() { this.constructor = d; }
16066 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16069 Object.defineProperty(exports, "__esModule", { value: true });
16070 var Subscription_1 = require("../Subscription");
16071 var Action = (function (_super) {
16072 __extends(Action, _super);
16073 function Action(scheduler, work) {
16074 return _super.call(this) || this;
16076 Action.prototype.schedule = function (state, delay) {
16077 if (delay === void 0) { delay = 0; }
16081 }(Subscription_1.Subscription));
16082 exports.Action = Action;
16084 },{"../Subscription":40}],177:[function(require,module,exports){
16086 var __extends = (this && this.__extends) || (function () {
16087 var extendStatics = function (d, b) {
16088 extendStatics = Object.setPrototypeOf ||
16089 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16090 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16091 return extendStatics(d, b);
16093 return function (d, b) {
16094 extendStatics(d, b);
16095 function __() { this.constructor = d; }
16096 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16099 Object.defineProperty(exports, "__esModule", { value: true });
16100 var AsyncAction_1 = require("./AsyncAction");
16101 var AnimationFrameAction = (function (_super) {
16102 __extends(AnimationFrameAction, _super);
16103 function AnimationFrameAction(scheduler, work) {
16104 var _this = _super.call(this, scheduler, work) || this;
16105 _this.scheduler = scheduler;
16109 AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
16110 if (delay === void 0) { delay = 0; }
16111 if (delay !== null && delay > 0) {
16112 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
16114 scheduler.actions.push(this);
16115 return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
16117 AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
16118 if (delay === void 0) { delay = 0; }
16119 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
16120 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
16122 if (scheduler.actions.length === 0) {
16123 cancelAnimationFrame(id);
16124 scheduler.scheduled = undefined;
16128 return AnimationFrameAction;
16129 }(AsyncAction_1.AsyncAction));
16130 exports.AnimationFrameAction = AnimationFrameAction;
16132 },{"./AsyncAction":181}],178:[function(require,module,exports){
16134 var __extends = (this && this.__extends) || (function () {
16135 var extendStatics = function (d, b) {
16136 extendStatics = Object.setPrototypeOf ||
16137 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16138 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16139 return extendStatics(d, b);
16141 return function (d, b) {
16142 extendStatics(d, b);
16143 function __() { this.constructor = d; }
16144 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16147 Object.defineProperty(exports, "__esModule", { value: true });
16148 var AsyncScheduler_1 = require("./AsyncScheduler");
16149 var AnimationFrameScheduler = (function (_super) {
16150 __extends(AnimationFrameScheduler, _super);
16151 function AnimationFrameScheduler() {
16152 return _super !== null && _super.apply(this, arguments) || this;
16154 AnimationFrameScheduler.prototype.flush = function (action) {
16155 this.active = true;
16156 this.scheduled = undefined;
16157 var actions = this.actions;
16160 var count = actions.length;
16161 action = action || actions.shift();
16163 if (error = action.execute(action.state, action.delay)) {
16166 } while (++index < count && (action = actions.shift()));
16167 this.active = false;
16169 while (++index < count && (action = actions.shift())) {
16170 action.unsubscribe();
16175 return AnimationFrameScheduler;
16176 }(AsyncScheduler_1.AsyncScheduler));
16177 exports.AnimationFrameScheduler = AnimationFrameScheduler;
16179 },{"./AsyncScheduler":182}],179:[function(require,module,exports){
16181 var __extends = (this && this.__extends) || (function () {
16182 var extendStatics = function (d, b) {
16183 extendStatics = Object.setPrototypeOf ||
16184 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16185 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16186 return extendStatics(d, b);
16188 return function (d, b) {
16189 extendStatics(d, b);
16190 function __() { this.constructor = d; }
16191 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16194 Object.defineProperty(exports, "__esModule", { value: true });
16195 var Immediate_1 = require("../util/Immediate");
16196 var AsyncAction_1 = require("./AsyncAction");
16197 var AsapAction = (function (_super) {
16198 __extends(AsapAction, _super);
16199 function AsapAction(scheduler, work) {
16200 var _this = _super.call(this, scheduler, work) || this;
16201 _this.scheduler = scheduler;
16205 AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
16206 if (delay === void 0) { delay = 0; }
16207 if (delay !== null && delay > 0) {
16208 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
16210 scheduler.actions.push(this);
16211 return scheduler.scheduled || (scheduler.scheduled = Immediate_1.Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
16213 AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
16214 if (delay === void 0) { delay = 0; }
16215 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
16216 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
16218 if (scheduler.actions.length === 0) {
16219 Immediate_1.Immediate.clearImmediate(id);
16220 scheduler.scheduled = undefined;
16225 }(AsyncAction_1.AsyncAction));
16226 exports.AsapAction = AsapAction;
16228 },{"../util/Immediate":195,"./AsyncAction":181}],180:[function(require,module,exports){
16230 var __extends = (this && this.__extends) || (function () {
16231 var extendStatics = function (d, b) {
16232 extendStatics = Object.setPrototypeOf ||
16233 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16234 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16235 return extendStatics(d, b);
16237 return function (d, b) {
16238 extendStatics(d, b);
16239 function __() { this.constructor = d; }
16240 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16243 Object.defineProperty(exports, "__esModule", { value: true });
16244 var AsyncScheduler_1 = require("./AsyncScheduler");
16245 var AsapScheduler = (function (_super) {
16246 __extends(AsapScheduler, _super);
16247 function AsapScheduler() {
16248 return _super !== null && _super.apply(this, arguments) || this;
16250 AsapScheduler.prototype.flush = function (action) {
16251 this.active = true;
16252 this.scheduled = undefined;
16253 var actions = this.actions;
16256 var count = actions.length;
16257 action = action || actions.shift();
16259 if (error = action.execute(action.state, action.delay)) {
16262 } while (++index < count && (action = actions.shift()));
16263 this.active = false;
16265 while (++index < count && (action = actions.shift())) {
16266 action.unsubscribe();
16271 return AsapScheduler;
16272 }(AsyncScheduler_1.AsyncScheduler));
16273 exports.AsapScheduler = AsapScheduler;
16275 },{"./AsyncScheduler":182}],181:[function(require,module,exports){
16277 var __extends = (this && this.__extends) || (function () {
16278 var extendStatics = function (d, b) {
16279 extendStatics = Object.setPrototypeOf ||
16280 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16281 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16282 return extendStatics(d, b);
16284 return function (d, b) {
16285 extendStatics(d, b);
16286 function __() { this.constructor = d; }
16287 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16290 Object.defineProperty(exports, "__esModule", { value: true });
16291 var Action_1 = require("./Action");
16292 var AsyncAction = (function (_super) {
16293 __extends(AsyncAction, _super);
16294 function AsyncAction(scheduler, work) {
16295 var _this = _super.call(this, scheduler, work) || this;
16296 _this.scheduler = scheduler;
16298 _this.pending = false;
16301 AsyncAction.prototype.schedule = function (state, delay) {
16302 if (delay === void 0) { delay = 0; }
16306 this.state = state;
16308 var scheduler = this.scheduler;
16310 this.id = this.recycleAsyncId(scheduler, id, delay);
16312 this.pending = true;
16313 this.delay = delay;
16314 this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
16317 AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
16318 if (delay === void 0) { delay = 0; }
16319 return setInterval(scheduler.flush.bind(scheduler, this), delay);
16321 AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
16322 if (delay === void 0) { delay = 0; }
16323 if (delay !== null && this.delay === delay && this.pending === false) {
16328 AsyncAction.prototype.execute = function (state, delay) {
16330 return new Error('executing a cancelled action');
16332 this.pending = false;
16333 var error = this._execute(state, delay);
16337 else if (this.pending === false && this.id != null) {
16338 this.id = this.recycleAsyncId(this.scheduler, this.id, null);
16341 AsyncAction.prototype._execute = function (state, delay) {
16342 var errored = false;
16343 var errorValue = undefined;
16349 errorValue = !!e && e || new Error(e);
16352 this.unsubscribe();
16356 AsyncAction.prototype._unsubscribe = function () {
16358 var scheduler = this.scheduler;
16359 var actions = scheduler.actions;
16360 var index = actions.indexOf(this);
16363 this.pending = false;
16364 this.scheduler = null;
16365 if (index !== -1) {
16366 actions.splice(index, 1);
16369 this.id = this.recycleAsyncId(scheduler, id, null);
16373 return AsyncAction;
16374 }(Action_1.Action));
16375 exports.AsyncAction = AsyncAction;
16377 },{"./Action":176}],182:[function(require,module,exports){
16379 var __extends = (this && this.__extends) || (function () {
16380 var extendStatics = function (d, b) {
16381 extendStatics = Object.setPrototypeOf ||
16382 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16383 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16384 return extendStatics(d, b);
16386 return function (d, b) {
16387 extendStatics(d, b);
16388 function __() { this.constructor = d; }
16389 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16392 Object.defineProperty(exports, "__esModule", { value: true });
16393 var Scheduler_1 = require("../Scheduler");
16394 var AsyncScheduler = (function (_super) {
16395 __extends(AsyncScheduler, _super);
16396 function AsyncScheduler(SchedulerAction, now) {
16397 if (now === void 0) { now = Scheduler_1.Scheduler.now; }
16398 var _this = _super.call(this, SchedulerAction, function () {
16399 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
16400 return AsyncScheduler.delegate.now();
16406 _this.actions = [];
16407 _this.active = false;
16408 _this.scheduled = undefined;
16411 AsyncScheduler.prototype.schedule = function (work, delay, state) {
16412 if (delay === void 0) { delay = 0; }
16413 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
16414 return AsyncScheduler.delegate.schedule(work, delay, state);
16417 return _super.prototype.schedule.call(this, work, delay, state);
16420 AsyncScheduler.prototype.flush = function (action) {
16421 var actions = this.actions;
16423 actions.push(action);
16427 this.active = true;
16429 if (error = action.execute(action.state, action.delay)) {
16432 } while (action = actions.shift());
16433 this.active = false;
16435 while (action = actions.shift()) {
16436 action.unsubscribe();
16441 return AsyncScheduler;
16442 }(Scheduler_1.Scheduler));
16443 exports.AsyncScheduler = AsyncScheduler;
16445 },{"../Scheduler":36}],183:[function(require,module,exports){
16447 var __extends = (this && this.__extends) || (function () {
16448 var extendStatics = function (d, b) {
16449 extendStatics = Object.setPrototypeOf ||
16450 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16451 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16452 return extendStatics(d, b);
16454 return function (d, b) {
16455 extendStatics(d, b);
16456 function __() { this.constructor = d; }
16457 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16460 Object.defineProperty(exports, "__esModule", { value: true });
16461 var AsyncAction_1 = require("./AsyncAction");
16462 var QueueAction = (function (_super) {
16463 __extends(QueueAction, _super);
16464 function QueueAction(scheduler, work) {
16465 var _this = _super.call(this, scheduler, work) || this;
16466 _this.scheduler = scheduler;
16470 QueueAction.prototype.schedule = function (state, delay) {
16471 if (delay === void 0) { delay = 0; }
16473 return _super.prototype.schedule.call(this, state, delay);
16475 this.delay = delay;
16476 this.state = state;
16477 this.scheduler.flush(this);
16480 QueueAction.prototype.execute = function (state, delay) {
16481 return (delay > 0 || this.closed) ?
16482 _super.prototype.execute.call(this, state, delay) :
16483 this._execute(state, delay);
16485 QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
16486 if (delay === void 0) { delay = 0; }
16487 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
16488 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
16490 return scheduler.flush(this);
16492 return QueueAction;
16493 }(AsyncAction_1.AsyncAction));
16494 exports.QueueAction = QueueAction;
16496 },{"./AsyncAction":181}],184:[function(require,module,exports){
16498 var __extends = (this && this.__extends) || (function () {
16499 var extendStatics = function (d, b) {
16500 extendStatics = Object.setPrototypeOf ||
16501 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16502 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16503 return extendStatics(d, b);
16505 return function (d, b) {
16506 extendStatics(d, b);
16507 function __() { this.constructor = d; }
16508 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16511 Object.defineProperty(exports, "__esModule", { value: true });
16512 var AsyncScheduler_1 = require("./AsyncScheduler");
16513 var QueueScheduler = (function (_super) {
16514 __extends(QueueScheduler, _super);
16515 function QueueScheduler() {
16516 return _super !== null && _super.apply(this, arguments) || this;
16518 return QueueScheduler;
16519 }(AsyncScheduler_1.AsyncScheduler));
16520 exports.QueueScheduler = QueueScheduler;
16522 },{"./AsyncScheduler":182}],185:[function(require,module,exports){
16524 var __extends = (this && this.__extends) || (function () {
16525 var extendStatics = function (d, b) {
16526 extendStatics = Object.setPrototypeOf ||
16527 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16528 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16529 return extendStatics(d, b);
16531 return function (d, b) {
16532 extendStatics(d, b);
16533 function __() { this.constructor = d; }
16534 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16537 Object.defineProperty(exports, "__esModule", { value: true });
16538 var AsyncAction_1 = require("./AsyncAction");
16539 var AsyncScheduler_1 = require("./AsyncScheduler");
16540 var VirtualTimeScheduler = (function (_super) {
16541 __extends(VirtualTimeScheduler, _super);
16542 function VirtualTimeScheduler(SchedulerAction, maxFrames) {
16543 if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
16544 if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
16545 var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
16546 _this.maxFrames = maxFrames;
16551 VirtualTimeScheduler.prototype.flush = function () {
16552 var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
16554 while ((action = actions.shift()) && (this.frame = action.delay) <= maxFrames) {
16555 if (error = action.execute(action.state, action.delay)) {
16560 while (action = actions.shift()) {
16561 action.unsubscribe();
16566 VirtualTimeScheduler.frameTimeFactor = 10;
16567 return VirtualTimeScheduler;
16568 }(AsyncScheduler_1.AsyncScheduler));
16569 exports.VirtualTimeScheduler = VirtualTimeScheduler;
16570 var VirtualAction = (function (_super) {
16571 __extends(VirtualAction, _super);
16572 function VirtualAction(scheduler, work, index) {
16573 if (index === void 0) { index = scheduler.index += 1; }
16574 var _this = _super.call(this, scheduler, work) || this;
16575 _this.scheduler = scheduler;
16577 _this.index = index;
16578 _this.active = true;
16579 _this.index = scheduler.index = index;
16582 VirtualAction.prototype.schedule = function (state, delay) {
16583 if (delay === void 0) { delay = 0; }
16585 return _super.prototype.schedule.call(this, state, delay);
16587 this.active = false;
16588 var action = new VirtualAction(this.scheduler, this.work);
16590 return action.schedule(state, delay);
16592 VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
16593 if (delay === void 0) { delay = 0; }
16594 this.delay = scheduler.frame + delay;
16595 var actions = scheduler.actions;
16596 actions.push(this);
16597 actions.sort(VirtualAction.sortActions);
16600 VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
16601 if (delay === void 0) { delay = 0; }
16604 VirtualAction.prototype._execute = function (state, delay) {
16605 if (this.active === true) {
16606 return _super.prototype._execute.call(this, state, delay);
16609 VirtualAction.sortActions = function (a, b) {
16610 if (a.delay === b.delay) {
16611 if (a.index === b.index) {
16614 else if (a.index > b.index) {
16621 else if (a.delay > b.delay) {
16628 return VirtualAction;
16629 }(AsyncAction_1.AsyncAction));
16630 exports.VirtualAction = VirtualAction;
16632 },{"./AsyncAction":181,"./AsyncScheduler":182}],186:[function(require,module,exports){
16634 Object.defineProperty(exports, "__esModule", { value: true });
16635 var AnimationFrameAction_1 = require("./AnimationFrameAction");
16636 var AnimationFrameScheduler_1 = require("./AnimationFrameScheduler");
16637 exports.animationFrame = new AnimationFrameScheduler_1.AnimationFrameScheduler(AnimationFrameAction_1.AnimationFrameAction);
16639 },{"./AnimationFrameAction":177,"./AnimationFrameScheduler":178}],187:[function(require,module,exports){
16641 Object.defineProperty(exports, "__esModule", { value: true });
16642 var AsapAction_1 = require("./AsapAction");
16643 var AsapScheduler_1 = require("./AsapScheduler");
16644 exports.asap = new AsapScheduler_1.AsapScheduler(AsapAction_1.AsapAction);
16646 },{"./AsapAction":179,"./AsapScheduler":180}],188:[function(require,module,exports){
16648 Object.defineProperty(exports, "__esModule", { value: true });
16649 var AsyncAction_1 = require("./AsyncAction");
16650 var AsyncScheduler_1 = require("./AsyncScheduler");
16651 exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction);
16653 },{"./AsyncAction":181,"./AsyncScheduler":182}],189:[function(require,module,exports){
16655 Object.defineProperty(exports, "__esModule", { value: true });
16656 var QueueAction_1 = require("./QueueAction");
16657 var QueueScheduler_1 = require("./QueueScheduler");
16658 exports.queue = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction);
16660 },{"./QueueAction":183,"./QueueScheduler":184}],190:[function(require,module,exports){
16662 Object.defineProperty(exports, "__esModule", { value: true });
16663 function getSymbolIterator() {
16664 if (typeof Symbol !== 'function' || !Symbol.iterator) {
16665 return '@@iterator';
16667 return Symbol.iterator;
16669 exports.getSymbolIterator = getSymbolIterator;
16670 exports.iterator = getSymbolIterator();
16671 exports.$$iterator = exports.iterator;
16673 },{}],191:[function(require,module,exports){
16675 Object.defineProperty(exports, "__esModule", { value: true });
16676 exports.observable = typeof Symbol === 'function' && Symbol.observable || '@@observable';
16678 },{}],192:[function(require,module,exports){
16680 Object.defineProperty(exports, "__esModule", { value: true });
16681 exports.rxSubscriber = typeof Symbol === 'function'
16682 ? Symbol('rxSubscriber')
16683 : '@@rxSubscriber_' + Math.random();
16684 exports.$$rxSubscriber = exports.rxSubscriber;
16686 },{}],193:[function(require,module,exports){
16688 Object.defineProperty(exports, "__esModule", { value: true });
16689 function ArgumentOutOfRangeErrorImpl() {
16691 this.message = 'argument out of range';
16692 this.name = 'ArgumentOutOfRangeError';
16695 ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
16696 exports.ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
16698 },{}],194:[function(require,module,exports){
16700 Object.defineProperty(exports, "__esModule", { value: true });
16701 function EmptyErrorImpl() {
16703 this.message = 'no elements in sequence';
16704 this.name = 'EmptyError';
16707 EmptyErrorImpl.prototype = Object.create(Error.prototype);
16708 exports.EmptyError = EmptyErrorImpl;
16710 },{}],195:[function(require,module,exports){
16712 Object.defineProperty(exports, "__esModule", { value: true });
16713 var nextHandle = 1;
16714 var tasksByHandle = {};
16715 function runIfPresent(handle) {
16716 var cb = tasksByHandle[handle];
16721 exports.Immediate = {
16722 setImmediate: function (cb) {
16723 var handle = nextHandle++;
16724 tasksByHandle[handle] = cb;
16725 Promise.resolve().then(function () { return runIfPresent(handle); });
16728 clearImmediate: function (handle) {
16729 delete tasksByHandle[handle];
16733 },{}],196:[function(require,module,exports){
16735 Object.defineProperty(exports, "__esModule", { value: true });
16736 function ObjectUnsubscribedErrorImpl() {
16738 this.message = 'object unsubscribed';
16739 this.name = 'ObjectUnsubscribedError';
16742 ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
16743 exports.ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
16745 },{}],197:[function(require,module,exports){
16747 Object.defineProperty(exports, "__esModule", { value: true });
16748 function TimeoutErrorImpl() {
16750 this.message = 'Timeout has occurred';
16751 this.name = 'TimeoutError';
16754 TimeoutErrorImpl.prototype = Object.create(Error.prototype);
16755 exports.TimeoutError = TimeoutErrorImpl;
16757 },{}],198:[function(require,module,exports){
16759 Object.defineProperty(exports, "__esModule", { value: true });
16760 function UnsubscriptionErrorImpl(errors) {
16762 this.message = errors ?
16763 errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
16764 this.name = 'UnsubscriptionError';
16765 this.errors = errors;
16768 UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
16769 exports.UnsubscriptionError = UnsubscriptionErrorImpl;
16771 },{}],199:[function(require,module,exports){
16773 Object.defineProperty(exports, "__esModule", { value: true });
16774 var Subscriber_1 = require("../Subscriber");
16775 function canReportError(observer) {
16777 var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
16778 if (closed_1 || isStopped) {
16781 else if (destination && destination instanceof Subscriber_1.Subscriber) {
16782 observer = destination;
16790 exports.canReportError = canReportError;
16792 },{"../Subscriber":39}],200:[function(require,module,exports){
16794 Object.defineProperty(exports, "__esModule", { value: true });
16795 exports.errorObject = { e: {} };
16797 },{}],201:[function(require,module,exports){
16799 Object.defineProperty(exports, "__esModule", { value: true });
16800 function hostReportError(err) {
16801 setTimeout(function () { throw err; });
16803 exports.hostReportError = hostReportError;
16805 },{}],202:[function(require,module,exports){
16807 Object.defineProperty(exports, "__esModule", { value: true });
16808 function identity(x) {
16811 exports.identity = identity;
16813 },{}],203:[function(require,module,exports){
16815 Object.defineProperty(exports, "__esModule", { value: true });
16816 exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
16818 },{}],204:[function(require,module,exports){
16820 Object.defineProperty(exports, "__esModule", { value: true });
16821 exports.isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
16823 },{}],205:[function(require,module,exports){
16825 Object.defineProperty(exports, "__esModule", { value: true });
16826 function isDate(value) {
16827 return value instanceof Date && !isNaN(+value);
16829 exports.isDate = isDate;
16831 },{}],206:[function(require,module,exports){
16833 Object.defineProperty(exports, "__esModule", { value: true });
16834 function isFunction(x) {
16835 return typeof x === 'function';
16837 exports.isFunction = isFunction;
16839 },{}],207:[function(require,module,exports){
16841 Object.defineProperty(exports, "__esModule", { value: true });
16842 var observable_1 = require("../symbol/observable");
16843 function isInteropObservable(input) {
16844 return input && typeof input[observable_1.observable] === 'function';
16846 exports.isInteropObservable = isInteropObservable;
16848 },{"../symbol/observable":191}],208:[function(require,module,exports){
16850 Object.defineProperty(exports, "__esModule", { value: true });
16851 var iterator_1 = require("../symbol/iterator");
16852 function isIterable(input) {
16853 return input && typeof input[iterator_1.iterator] === 'function';
16855 exports.isIterable = isIterable;
16857 },{"../symbol/iterator":190}],209:[function(require,module,exports){
16859 Object.defineProperty(exports, "__esModule", { value: true });
16860 var isArray_1 = require("./isArray");
16861 function isNumeric(val) {
16862 return !isArray_1.isArray(val) && (val - parseFloat(val) + 1) >= 0;
16864 exports.isNumeric = isNumeric;
16866 },{"./isArray":203}],210:[function(require,module,exports){
16868 Object.defineProperty(exports, "__esModule", { value: true });
16869 function isObject(x) {
16870 return x != null && typeof x === 'object';
16872 exports.isObject = isObject;
16874 },{}],211:[function(require,module,exports){
16876 Object.defineProperty(exports, "__esModule", { value: true });
16877 var Observable_1 = require("../Observable");
16878 function isObservable(obj) {
16879 return !!obj && (obj instanceof Observable_1.Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
16881 exports.isObservable = isObservable;
16883 },{"../Observable":32}],212:[function(require,module,exports){
16885 Object.defineProperty(exports, "__esModule", { value: true });
16886 function isPromise(value) {
16887 return value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
16889 exports.isPromise = isPromise;
16891 },{}],213:[function(require,module,exports){
16893 Object.defineProperty(exports, "__esModule", { value: true });
16894 function isScheduler(value) {
16895 return value && typeof value.schedule === 'function';
16897 exports.isScheduler = isScheduler;
16899 },{}],214:[function(require,module,exports){
16901 Object.defineProperty(exports, "__esModule", { value: true });
16902 function noop() { }
16903 exports.noop = noop;
16905 },{}],215:[function(require,module,exports){
16907 Object.defineProperty(exports, "__esModule", { value: true });
16908 function not(pred, thisArg) {
16909 function notPred() {
16910 return !(notPred.pred.apply(notPred.thisArg, arguments));
16912 notPred.pred = pred;
16913 notPred.thisArg = thisArg;
16918 },{}],216:[function(require,module,exports){
16920 Object.defineProperty(exports, "__esModule", { value: true });
16921 var noop_1 = require("./noop");
16924 for (var _i = 0; _i < arguments.length; _i++) {
16925 fns[_i] = arguments[_i];
16927 return pipeFromArray(fns);
16929 exports.pipe = pipe;
16930 function pipeFromArray(fns) {
16932 return noop_1.noop;
16934 if (fns.length === 1) {
16937 return function piped(input) {
16938 return fns.reduce(function (prev, fn) { return fn(prev); }, input);
16941 exports.pipeFromArray = pipeFromArray;
16943 },{"./noop":214}],217:[function(require,module,exports){
16945 Object.defineProperty(exports, "__esModule", { value: true });
16946 var Observable_1 = require("../Observable");
16947 var subscribeToArray_1 = require("./subscribeToArray");
16948 var subscribeToPromise_1 = require("./subscribeToPromise");
16949 var subscribeToIterable_1 = require("./subscribeToIterable");
16950 var subscribeToObservable_1 = require("./subscribeToObservable");
16951 var isArrayLike_1 = require("./isArrayLike");
16952 var isPromise_1 = require("./isPromise");
16953 var isObject_1 = require("./isObject");
16954 var iterator_1 = require("../symbol/iterator");
16955 var observable_1 = require("../symbol/observable");
16956 exports.subscribeTo = function (result) {
16957 if (result instanceof Observable_1.Observable) {
16958 return function (subscriber) {
16959 if (result._isScalar) {
16960 subscriber.next(result.value);
16961 subscriber.complete();
16965 return result.subscribe(subscriber);
16969 else if (result && typeof result[observable_1.observable] === 'function') {
16970 return subscribeToObservable_1.subscribeToObservable(result);
16972 else if (isArrayLike_1.isArrayLike(result)) {
16973 return subscribeToArray_1.subscribeToArray(result);
16975 else if (isPromise_1.isPromise(result)) {
16976 return subscribeToPromise_1.subscribeToPromise(result);
16978 else if (result && typeof result[iterator_1.iterator] === 'function') {
16979 return subscribeToIterable_1.subscribeToIterable(result);
16982 var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'";
16983 var msg = "You provided " + value + " where a stream was expected."
16984 + ' You can provide an Observable, Promise, Array, or Iterable.';
16985 throw new TypeError(msg);
16989 },{"../Observable":32,"../symbol/iterator":190,"../symbol/observable":191,"./isArrayLike":204,"./isObject":210,"./isPromise":212,"./subscribeToArray":218,"./subscribeToIterable":219,"./subscribeToObservable":220,"./subscribeToPromise":221}],218:[function(require,module,exports){
16991 Object.defineProperty(exports, "__esModule", { value: true });
16992 exports.subscribeToArray = function (array) { return function (subscriber) {
16993 for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
16994 subscriber.next(array[i]);
16996 if (!subscriber.closed) {
16997 subscriber.complete();
17001 },{}],219:[function(require,module,exports){
17003 Object.defineProperty(exports, "__esModule", { value: true });
17004 var iterator_1 = require("../symbol/iterator");
17005 exports.subscribeToIterable = function (iterable) { return function (subscriber) {
17006 var iterator = iterable[iterator_1.iterator]();
17008 var item = iterator.next();
17010 subscriber.complete();
17013 subscriber.next(item.value);
17014 if (subscriber.closed) {
17018 if (typeof iterator.return === 'function') {
17019 subscriber.add(function () {
17020 if (iterator.return) {
17028 },{"../symbol/iterator":190}],220:[function(require,module,exports){
17030 Object.defineProperty(exports, "__esModule", { value: true });
17031 var observable_1 = require("../symbol/observable");
17032 exports.subscribeToObservable = function (obj) { return function (subscriber) {
17033 var obs = obj[observable_1.observable]();
17034 if (typeof obs.subscribe !== 'function') {
17035 throw new TypeError('Provided object does not correctly implement Symbol.observable');
17038 return obs.subscribe(subscriber);
17042 },{"../symbol/observable":191}],221:[function(require,module,exports){
17044 Object.defineProperty(exports, "__esModule", { value: true });
17045 var hostReportError_1 = require("./hostReportError");
17046 exports.subscribeToPromise = function (promise) { return function (subscriber) {
17047 promise.then(function (value) {
17048 if (!subscriber.closed) {
17049 subscriber.next(value);
17050 subscriber.complete();
17052 }, function (err) { return subscriber.error(err); })
17053 .then(null, hostReportError_1.hostReportError);
17057 },{"./hostReportError":201}],222:[function(require,module,exports){
17059 Object.defineProperty(exports, "__esModule", { value: true });
17060 var InnerSubscriber_1 = require("../InnerSubscriber");
17061 var subscribeTo_1 = require("./subscribeTo");
17062 function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, destination) {
17063 if (destination === void 0) { destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
17064 if (destination.closed) {
17067 return subscribeTo_1.subscribeTo(result)(destination);
17069 exports.subscribeToResult = subscribeToResult;
17071 },{"../InnerSubscriber":30,"./subscribeTo":217}],223:[function(require,module,exports){
17073 Object.defineProperty(exports, "__esModule", { value: true });
17074 var Subscriber_1 = require("../Subscriber");
17075 var rxSubscriber_1 = require("../symbol/rxSubscriber");
17076 var Observer_1 = require("../Observer");
17077 function toSubscriber(nextOrObserver, error, complete) {
17078 if (nextOrObserver) {
17079 if (nextOrObserver instanceof Subscriber_1.Subscriber) {
17080 return nextOrObserver;
17082 if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
17083 return nextOrObserver[rxSubscriber_1.rxSubscriber]();
17086 if (!nextOrObserver && !error && !complete) {
17087 return new Subscriber_1.Subscriber(Observer_1.empty);
17089 return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
17091 exports.toSubscriber = toSubscriber;
17093 },{"../Observer":33,"../Subscriber":39,"../symbol/rxSubscriber":192}],224:[function(require,module,exports){
17095 Object.defineProperty(exports, "__esModule", { value: true });
17096 var errorObject_1 = require("./errorObject");
17097 var tryCatchTarget;
17098 function tryCatcher() {
17100 return tryCatchTarget.apply(this, arguments);
17103 errorObject_1.errorObject.e = e;
17104 return errorObject_1.errorObject;
17107 function tryCatch(fn) {
17108 tryCatchTarget = fn;
17111 exports.tryCatch = tryCatch;
17113 },{"./errorObject":200}],225:[function(require,module,exports){
17115 Object.defineProperty(exports, "__esModule", { value: true });
17116 var audit_1 = require("../internal/operators/audit");
17117 exports.audit = audit_1.audit;
17118 var auditTime_1 = require("../internal/operators/auditTime");
17119 exports.auditTime = auditTime_1.auditTime;
17120 var buffer_1 = require("../internal/operators/buffer");
17121 exports.buffer = buffer_1.buffer;
17122 var bufferCount_1 = require("../internal/operators/bufferCount");
17123 exports.bufferCount = bufferCount_1.bufferCount;
17124 var bufferTime_1 = require("../internal/operators/bufferTime");
17125 exports.bufferTime = bufferTime_1.bufferTime;
17126 var bufferToggle_1 = require("../internal/operators/bufferToggle");
17127 exports.bufferToggle = bufferToggle_1.bufferToggle;
17128 var bufferWhen_1 = require("../internal/operators/bufferWhen");
17129 exports.bufferWhen = bufferWhen_1.bufferWhen;
17130 var catchError_1 = require("../internal/operators/catchError");
17131 exports.catchError = catchError_1.catchError;
17132 var combineAll_1 = require("../internal/operators/combineAll");
17133 exports.combineAll = combineAll_1.combineAll;
17134 var combineLatest_1 = require("../internal/operators/combineLatest");
17135 exports.combineLatest = combineLatest_1.combineLatest;
17136 var concat_1 = require("../internal/operators/concat");
17137 exports.concat = concat_1.concat;
17138 var concatAll_1 = require("../internal/operators/concatAll");
17139 exports.concatAll = concatAll_1.concatAll;
17140 var concatMap_1 = require("../internal/operators/concatMap");
17141 exports.concatMap = concatMap_1.concatMap;
17142 var concatMapTo_1 = require("../internal/operators/concatMapTo");
17143 exports.concatMapTo = concatMapTo_1.concatMapTo;
17144 var count_1 = require("../internal/operators/count");
17145 exports.count = count_1.count;
17146 var debounce_1 = require("../internal/operators/debounce");
17147 exports.debounce = debounce_1.debounce;
17148 var debounceTime_1 = require("../internal/operators/debounceTime");
17149 exports.debounceTime = debounceTime_1.debounceTime;
17150 var defaultIfEmpty_1 = require("../internal/operators/defaultIfEmpty");
17151 exports.defaultIfEmpty = defaultIfEmpty_1.defaultIfEmpty;
17152 var delay_1 = require("../internal/operators/delay");
17153 exports.delay = delay_1.delay;
17154 var delayWhen_1 = require("../internal/operators/delayWhen");
17155 exports.delayWhen = delayWhen_1.delayWhen;
17156 var dematerialize_1 = require("../internal/operators/dematerialize");
17157 exports.dematerialize = dematerialize_1.dematerialize;
17158 var distinct_1 = require("../internal/operators/distinct");
17159 exports.distinct = distinct_1.distinct;
17160 var distinctUntilChanged_1 = require("../internal/operators/distinctUntilChanged");
17161 exports.distinctUntilChanged = distinctUntilChanged_1.distinctUntilChanged;
17162 var distinctUntilKeyChanged_1 = require("../internal/operators/distinctUntilKeyChanged");
17163 exports.distinctUntilKeyChanged = distinctUntilKeyChanged_1.distinctUntilKeyChanged;
17164 var elementAt_1 = require("../internal/operators/elementAt");
17165 exports.elementAt = elementAt_1.elementAt;
17166 var endWith_1 = require("../internal/operators/endWith");
17167 exports.endWith = endWith_1.endWith;
17168 var every_1 = require("../internal/operators/every");
17169 exports.every = every_1.every;
17170 var exhaust_1 = require("../internal/operators/exhaust");
17171 exports.exhaust = exhaust_1.exhaust;
17172 var exhaustMap_1 = require("../internal/operators/exhaustMap");
17173 exports.exhaustMap = exhaustMap_1.exhaustMap;
17174 var expand_1 = require("../internal/operators/expand");
17175 exports.expand = expand_1.expand;
17176 var filter_1 = require("../internal/operators/filter");
17177 exports.filter = filter_1.filter;
17178 var finalize_1 = require("../internal/operators/finalize");
17179 exports.finalize = finalize_1.finalize;
17180 var find_1 = require("../internal/operators/find");
17181 exports.find = find_1.find;
17182 var findIndex_1 = require("../internal/operators/findIndex");
17183 exports.findIndex = findIndex_1.findIndex;
17184 var first_1 = require("../internal/operators/first");
17185 exports.first = first_1.first;
17186 var groupBy_1 = require("../internal/operators/groupBy");
17187 exports.groupBy = groupBy_1.groupBy;
17188 var ignoreElements_1 = require("../internal/operators/ignoreElements");
17189 exports.ignoreElements = ignoreElements_1.ignoreElements;
17190 var isEmpty_1 = require("../internal/operators/isEmpty");
17191 exports.isEmpty = isEmpty_1.isEmpty;
17192 var last_1 = require("../internal/operators/last");
17193 exports.last = last_1.last;
17194 var map_1 = require("../internal/operators/map");
17195 exports.map = map_1.map;
17196 var mapTo_1 = require("../internal/operators/mapTo");
17197 exports.mapTo = mapTo_1.mapTo;
17198 var materialize_1 = require("../internal/operators/materialize");
17199 exports.materialize = materialize_1.materialize;
17200 var max_1 = require("../internal/operators/max");
17201 exports.max = max_1.max;
17202 var merge_1 = require("../internal/operators/merge");
17203 exports.merge = merge_1.merge;
17204 var mergeAll_1 = require("../internal/operators/mergeAll");
17205 exports.mergeAll = mergeAll_1.mergeAll;
17206 var mergeMap_1 = require("../internal/operators/mergeMap");
17207 exports.mergeMap = mergeMap_1.mergeMap;
17208 var mergeMap_2 = require("../internal/operators/mergeMap");
17209 exports.flatMap = mergeMap_2.mergeMap;
17210 var mergeMapTo_1 = require("../internal/operators/mergeMapTo");
17211 exports.mergeMapTo = mergeMapTo_1.mergeMapTo;
17212 var mergeScan_1 = require("../internal/operators/mergeScan");
17213 exports.mergeScan = mergeScan_1.mergeScan;
17214 var min_1 = require("../internal/operators/min");
17215 exports.min = min_1.min;
17216 var multicast_1 = require("../internal/operators/multicast");
17217 exports.multicast = multicast_1.multicast;
17218 var observeOn_1 = require("../internal/operators/observeOn");
17219 exports.observeOn = observeOn_1.observeOn;
17220 var onErrorResumeNext_1 = require("../internal/operators/onErrorResumeNext");
17221 exports.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext;
17222 var pairwise_1 = require("../internal/operators/pairwise");
17223 exports.pairwise = pairwise_1.pairwise;
17224 var partition_1 = require("../internal/operators/partition");
17225 exports.partition = partition_1.partition;
17226 var pluck_1 = require("../internal/operators/pluck");
17227 exports.pluck = pluck_1.pluck;
17228 var publish_1 = require("../internal/operators/publish");
17229 exports.publish = publish_1.publish;
17230 var publishBehavior_1 = require("../internal/operators/publishBehavior");
17231 exports.publishBehavior = publishBehavior_1.publishBehavior;
17232 var publishLast_1 = require("../internal/operators/publishLast");
17233 exports.publishLast = publishLast_1.publishLast;
17234 var publishReplay_1 = require("../internal/operators/publishReplay");
17235 exports.publishReplay = publishReplay_1.publishReplay;
17236 var race_1 = require("../internal/operators/race");
17237 exports.race = race_1.race;
17238 var reduce_1 = require("../internal/operators/reduce");
17239 exports.reduce = reduce_1.reduce;
17240 var repeat_1 = require("../internal/operators/repeat");
17241 exports.repeat = repeat_1.repeat;
17242 var repeatWhen_1 = require("../internal/operators/repeatWhen");
17243 exports.repeatWhen = repeatWhen_1.repeatWhen;
17244 var retry_1 = require("../internal/operators/retry");
17245 exports.retry = retry_1.retry;
17246 var retryWhen_1 = require("../internal/operators/retryWhen");
17247 exports.retryWhen = retryWhen_1.retryWhen;
17248 var refCount_1 = require("../internal/operators/refCount");
17249 exports.refCount = refCount_1.refCount;
17250 var sample_1 = require("../internal/operators/sample");
17251 exports.sample = sample_1.sample;
17252 var sampleTime_1 = require("../internal/operators/sampleTime");
17253 exports.sampleTime = sampleTime_1.sampleTime;
17254 var scan_1 = require("../internal/operators/scan");
17255 exports.scan = scan_1.scan;
17256 var sequenceEqual_1 = require("../internal/operators/sequenceEqual");
17257 exports.sequenceEqual = sequenceEqual_1.sequenceEqual;
17258 var share_1 = require("../internal/operators/share");
17259 exports.share = share_1.share;
17260 var shareReplay_1 = require("../internal/operators/shareReplay");
17261 exports.shareReplay = shareReplay_1.shareReplay;
17262 var single_1 = require("../internal/operators/single");
17263 exports.single = single_1.single;
17264 var skip_1 = require("../internal/operators/skip");
17265 exports.skip = skip_1.skip;
17266 var skipLast_1 = require("../internal/operators/skipLast");
17267 exports.skipLast = skipLast_1.skipLast;
17268 var skipUntil_1 = require("../internal/operators/skipUntil");
17269 exports.skipUntil = skipUntil_1.skipUntil;
17270 var skipWhile_1 = require("../internal/operators/skipWhile");
17271 exports.skipWhile = skipWhile_1.skipWhile;
17272 var startWith_1 = require("../internal/operators/startWith");
17273 exports.startWith = startWith_1.startWith;
17274 var subscribeOn_1 = require("../internal/operators/subscribeOn");
17275 exports.subscribeOn = subscribeOn_1.subscribeOn;
17276 var switchAll_1 = require("../internal/operators/switchAll");
17277 exports.switchAll = switchAll_1.switchAll;
17278 var switchMap_1 = require("../internal/operators/switchMap");
17279 exports.switchMap = switchMap_1.switchMap;
17280 var switchMapTo_1 = require("../internal/operators/switchMapTo");
17281 exports.switchMapTo = switchMapTo_1.switchMapTo;
17282 var take_1 = require("../internal/operators/take");
17283 exports.take = take_1.take;
17284 var takeLast_1 = require("../internal/operators/takeLast");
17285 exports.takeLast = takeLast_1.takeLast;
17286 var takeUntil_1 = require("../internal/operators/takeUntil");
17287 exports.takeUntil = takeUntil_1.takeUntil;
17288 var takeWhile_1 = require("../internal/operators/takeWhile");
17289 exports.takeWhile = takeWhile_1.takeWhile;
17290 var tap_1 = require("../internal/operators/tap");
17291 exports.tap = tap_1.tap;
17292 var throttle_1 = require("../internal/operators/throttle");
17293 exports.throttle = throttle_1.throttle;
17294 var throttleTime_1 = require("../internal/operators/throttleTime");
17295 exports.throttleTime = throttleTime_1.throttleTime;
17296 var throwIfEmpty_1 = require("../internal/operators/throwIfEmpty");
17297 exports.throwIfEmpty = throwIfEmpty_1.throwIfEmpty;
17298 var timeInterval_1 = require("../internal/operators/timeInterval");
17299 exports.timeInterval = timeInterval_1.timeInterval;
17300 var timeout_1 = require("../internal/operators/timeout");
17301 exports.timeout = timeout_1.timeout;
17302 var timeoutWith_1 = require("../internal/operators/timeoutWith");
17303 exports.timeoutWith = timeoutWith_1.timeoutWith;
17304 var timestamp_1 = require("../internal/operators/timestamp");
17305 exports.timestamp = timestamp_1.timestamp;
17306 var toArray_1 = require("../internal/operators/toArray");
17307 exports.toArray = toArray_1.toArray;
17308 var window_1 = require("../internal/operators/window");
17309 exports.window = window_1.window;
17310 var windowCount_1 = require("../internal/operators/windowCount");
17311 exports.windowCount = windowCount_1.windowCount;
17312 var windowTime_1 = require("../internal/operators/windowTime");
17313 exports.windowTime = windowTime_1.windowTime;
17314 var windowToggle_1 = require("../internal/operators/windowToggle");
17315 exports.windowToggle = windowToggle_1.windowToggle;
17316 var windowWhen_1 = require("../internal/operators/windowWhen");
17317 exports.windowWhen = windowWhen_1.windowWhen;
17318 var withLatestFrom_1 = require("../internal/operators/withLatestFrom");
17319 exports.withLatestFrom = withLatestFrom_1.withLatestFrom;
17320 var zip_1 = require("../internal/operators/zip");
17321 exports.zip = zip_1.zip;
17322 var zipAll_1 = require("../internal/operators/zipAll");
17323 exports.zipAll = zipAll_1.zipAll;
17325 },{"../internal/operators/audit":73,"../internal/operators/auditTime":74,"../internal/operators/buffer":75,"../internal/operators/bufferCount":76,"../internal/operators/bufferTime":77,"../internal/operators/bufferToggle":78,"../internal/operators/bufferWhen":79,"../internal/operators/catchError":80,"../internal/operators/combineAll":81,"../internal/operators/combineLatest":82,"../internal/operators/concat":83,"../internal/operators/concatAll":84,"../internal/operators/concatMap":85,"../internal/operators/concatMapTo":86,"../internal/operators/count":87,"../internal/operators/debounce":88,"../internal/operators/debounceTime":89,"../internal/operators/defaultIfEmpty":90,"../internal/operators/delay":91,"../internal/operators/delayWhen":92,"../internal/operators/dematerialize":93,"../internal/operators/distinct":94,"../internal/operators/distinctUntilChanged":95,"../internal/operators/distinctUntilKeyChanged":96,"../internal/operators/elementAt":97,"../internal/operators/endWith":98,"../internal/operators/every":99,"../internal/operators/exhaust":100,"../internal/operators/exhaustMap":101,"../internal/operators/expand":102,"../internal/operators/filter":103,"../internal/operators/finalize":104,"../internal/operators/find":105,"../internal/operators/findIndex":106,"../internal/operators/first":107,"../internal/operators/groupBy":108,"../internal/operators/ignoreElements":109,"../internal/operators/isEmpty":110,"../internal/operators/last":111,"../internal/operators/map":112,"../internal/operators/mapTo":113,"../internal/operators/materialize":114,"../internal/operators/max":115,"../internal/operators/merge":116,"../internal/operators/mergeAll":117,"../internal/operators/mergeMap":118,"../internal/operators/mergeMapTo":119,"../internal/operators/mergeScan":120,"../internal/operators/min":121,"../internal/operators/multicast":122,"../internal/operators/observeOn":123,"../internal/operators/onErrorResumeNext":124,"../internal/operators/pairwise":125,"../internal/operators/partition":126,"../internal/operators/pluck":127,"../internal/operators/publish":128,"../internal/operators/publishBehavior":129,"../internal/operators/publishLast":130,"../internal/operators/publishReplay":131,"../internal/operators/race":132,"../internal/operators/reduce":133,"../internal/operators/refCount":134,"../internal/operators/repeat":135,"../internal/operators/repeatWhen":136,"../internal/operators/retry":137,"../internal/operators/retryWhen":138,"../internal/operators/sample":139,"../internal/operators/sampleTime":140,"../internal/operators/scan":141,"../internal/operators/sequenceEqual":142,"../internal/operators/share":143,"../internal/operators/shareReplay":144,"../internal/operators/single":145,"../internal/operators/skip":146,"../internal/operators/skipLast":147,"../internal/operators/skipUntil":148,"../internal/operators/skipWhile":149,"../internal/operators/startWith":150,"../internal/operators/subscribeOn":151,"../internal/operators/switchAll":152,"../internal/operators/switchMap":153,"../internal/operators/switchMapTo":154,"../internal/operators/take":155,"../internal/operators/takeLast":156,"../internal/operators/takeUntil":157,"../internal/operators/takeWhile":158,"../internal/operators/tap":159,"../internal/operators/throttle":160,"../internal/operators/throttleTime":161,"../internal/operators/throwIfEmpty":162,"../internal/operators/timeInterval":163,"../internal/operators/timeout":164,"../internal/operators/timeoutWith":165,"../internal/operators/timestamp":166,"../internal/operators/toArray":167,"../internal/operators/window":168,"../internal/operators/windowCount":169,"../internal/operators/windowTime":170,"../internal/operators/windowToggle":171,"../internal/operators/windowWhen":172,"../internal/operators/withLatestFrom":173,"../internal/operators/zip":174,"../internal/operators/zipAll":175}],226:[function(require,module,exports){
17326 // threejs.org/license
17327 (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,
17328 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!==
17329 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,
17330 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?
17331 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!==
17332 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),
17333 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
17334 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);
17335 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=
17336 -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,
17337 {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=
17338 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,
17339 "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.");
17340 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,
17341 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;
17342 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,
17343 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+=
17344 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",
17345 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=
17346 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=
17347 !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;
17348 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=
17349 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=
17350 {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=
17351 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,
17352 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)},
17353 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"),
17354 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"===
17355 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),
17356 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,
17357 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===
17358 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=
17359 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;
17360 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");
17361 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?
17362 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!==
17363 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=
17364 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++;
17365 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);
17366 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"+
17367 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),
17368 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]!==
17369 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,
17370 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,
17371 !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||
17372 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;
17373 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,
17374 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,
17375 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;
17376 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=
17377 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.");
17378 ""!==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: "+
17379 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||
17380 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=
17381 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,
17382 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&&
17383 (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=
17384 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":
17385 "",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":
17386 "",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 "+
17387 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;",
17388 "#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",
17389 "#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 "+
17390 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?
17391 "#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&&
17392 (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",
17393 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"+
17394 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")+
17395 "\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",
17396 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),
17397 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=
17398 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",
17399 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(" ");
17400 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."));
17401 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,
17402 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,
17403 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,
17404 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<
17405 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!==
17406 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,
17407 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=
17408 {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};
17409 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,
17410 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=
17411 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);
17412 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,
17413 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;
17414 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=
17415 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]?
17416 (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=
17417 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)),
17418 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;
17419 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,
17420 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),
17421 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);
17422 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());
17423 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,
17424 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":
17425 "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,
17426 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,
17427 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);
17428 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;
17429 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);
17430 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!==
17431 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]),
17432 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,
17433 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!==
17434 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!==
17435 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:",
17436 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+").");
17437 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!==
17438 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=
17439 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=
17440 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");
17441 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);
17442 (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+
17443 "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=
17444 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,
17445 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=
17446 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)),
17447 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."));
17448 !(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);
17449 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,
17450 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);
17451 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+
17452 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+
17453 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=
17454 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),
17455 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&&
17456 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");
17457 }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;
17458 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;
17459 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===
17460 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===
17461 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;
17462 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===
17463 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;
17464 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=
17465 [],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]=
17466 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!==
17467 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);
17468 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),
17469 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;
17470 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"}),
17471 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);
17472 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};
17473 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(),
17474 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),
17475 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=
17476 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");
17477 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();
17478 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||
17479 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=
17480 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*
17481 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,
17482 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=
17483 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,
17484 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=
17485 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=
17486 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,
17487 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=
17488 !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));
17489 (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=
17490 !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=
17491 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,
17492 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,
17493 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=
17494 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&&
17495 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,
17496 "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=
17497 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),
17498 !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,
17499 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),
17500 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!==
17501 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=
17502 !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);
17503 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,
17504 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!==
17505 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)};
17506 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,
17507 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",
17508 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),
17509 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,
17510 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&&
17511 (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,
17512 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===
17513 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*
17514 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?
17515 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,
17516 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));
17517 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=
17518 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};
17519 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&&
17520 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=
17521 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=
17522 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")||
17523 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&&
17524 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,
17525 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=
17526 {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",
17527 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."),
17528 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;
17529 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=
17530 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,
17531 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=
17532 [],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,
17533 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,
17534 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.");
17535 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",
17536 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,
17537 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=
17538 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],
17539 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,
17540 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,
17541 -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,
17542 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,
17543 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,
17544 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=
17545 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=
17546 (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,
17547 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;
17548 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);
17549 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)||
17550 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",
17551 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}
17552 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;
17553 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=
17554 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,
17555 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,
17556 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,
17557 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-
17558 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=
17559 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),
17560 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;
17561 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);
17562 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?
17563 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;
17564 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],
17565 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=
17566 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=
17567 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=
17568 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()}
17569 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,
17570 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,
17571 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",
17572 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;
17573 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",
17574 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=
17575 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=
17576 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;
17577 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);
17578 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=
17579 ["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],
17580 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=
17581 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)||
17582 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),
17583 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=
17584 {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=
17585 [],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)}
17586 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=
17587 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);
17588 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;
17589 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=
17590 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=
17591 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,
17592 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}
17593 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,
17594 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)*
17595 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||
17596 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);
17597 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=
17598 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,
17599 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,
17600 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,
17601 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,
17602 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;
17603 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!==
17604 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.");
17605 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=
17606 !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);
17607 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,
17608 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=
17609 !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=
17610 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=
17611 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=
17612 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;
17613 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,
17614 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],
17615 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=
17616 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();
17617 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}
17618 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();
17619 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();
17620 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,
17621 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,
17622 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)&&
17623 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,
17624 -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);
17625 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&&
17626 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,
17627 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,
17628 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}));
17629 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.");
17630 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)===
17631 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,
17632 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!==
17633 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>>
17634 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;
17635 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)/
17636 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: "+
17637 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},
17638 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*=
17639 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,
17640 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=
17641 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)+
17642 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+=
17643 (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);
17644 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)},
17645 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,
17646 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.");
17647 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]=
17648 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=
17649 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!==
17650 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],
17651 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]*=
17652 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-
17653 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],
17654 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*
17655 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)*
17656 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=
17657 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,
17658 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;
17659 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);
17660 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]=
17661 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];
17662 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*
17663 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=
17664 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=
17665 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+
17666 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/
17667 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,
17668 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*
17669 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."),
17670 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;
17671 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===
17672 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},
17673 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,
17674 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+=
17675 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."),
17676 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,
17677 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,
17678 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=
17679 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,
17680 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=
17681 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*
17682 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,
17683 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=
17684 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-
17685 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(),
17686 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!==
17687 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;
17688 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,
17689 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]*=
17690 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");
17691 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=
17692 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]=
17693 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];
17694 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",
17695 .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=
17696 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=
17697 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!==
17698 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);
17699 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=
17700 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;
17701 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+=
17702 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-=
17703 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/
17704 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;
17705 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,
17706 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,
17707 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);
17708 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*
17709 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,
17710 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().");
17711 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();
17712 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=
17713 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);
17714 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},
17715 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"),
17716 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&&
17717 (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&&
17718 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,
17719 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;
17720 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=
17721 [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=
17722 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=
17723 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];
17724 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=
17725 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;
17726 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===
17727 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,
17728 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=
17729 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=
17730 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)},
17731 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);
17732 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],
17733 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();
17734 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];
17735 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",
17736 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",
17737 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",
17738 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",
17739 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",
17740 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",
17741 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",
17742 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",
17743 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",
17744 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",
17745 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",
17746 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",
17747 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",
17748 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",
17749 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",
17750 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",
17751 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",
17752 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",
17753 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",
17754 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",
17755 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",
17756 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",
17757 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",
17758 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",
17759 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",
17760 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",
17761 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",
17762 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",
17763 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",
17764 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",
17765 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",
17766 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",
17767 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",
17768 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",
17769 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",
17770 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",
17771 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",
17772 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",
17773 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",
17774 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",
17775 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",
17776 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",
17777 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",
17778 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",
17779 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",
17780 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",
17781 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",
17782 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",
17783 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",
17784 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",
17785 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",
17786 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",
17787 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",
17788 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",
17789 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",
17790 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",
17791 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",
17792 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",
17793 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",
17794 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",
17795 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",
17796 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",
17797 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",
17798 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"},
17799 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,
17800 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,
17801 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,
17802 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,
17803 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,
17804 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,
17805 {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,
17806 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=
17807 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])/
17808 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],
17809 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,
17810 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);
17811 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-
17812 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+=
17813 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=
17814 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},
17815 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},
17816 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:[]},
17817 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}},
17818 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},
17819 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},
17820 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,
17821 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,
17822 {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(" ");
17823 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=
17824 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=
17825 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"===
17826 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);
17827 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=[]);
17828 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&
17829 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,
17830 !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=
17831 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,
17832 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)}}(),
17833 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]);
17834 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"),
17835 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);
17836 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)}},
17837 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=
17838 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&&
17839 (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!==
17840 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);
17841 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;
17842 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,
17843 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)}});
17844 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=
17845 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);
17846 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;
17847 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}});
17848 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();
17849 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=
17850 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!==
17851 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],
17852 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&&
17853 (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=
17854 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,
17855 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=
17856 !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):
17857 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;
17858 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],
17859 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],
17860 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);
17861 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.",
17862 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=
17863 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&&
17864 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=
17865 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=
17866 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,
17867 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<
17868 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!==
17869 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!==
17870 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=
17871 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(){},
17872 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<
17873 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",
17874 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;
17875 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+
17876 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,
17877 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=
17878 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,
17879 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]);
17880 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 ",
17881 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}});
17882 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."),
17883 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;
17884 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);
17885 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}}(),
17886 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&&
17887 (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=
17888 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=
17889 !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},
17890 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)));
17891 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",
17892 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();
17893 (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,
17894 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",
17895 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]+=
17896 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."));
17897 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===
17898 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",
17899 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]=
17900 {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());
17901 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;
17902 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=
17903 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=
17904 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!==
17905 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&&
17906 (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,
17907 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&&
17908 (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);
17909 !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=
17910 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),
17911 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=
17912 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));
17913 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=
17914 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=
17915 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;
17916 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,
17917 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);
17918 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);
17919 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=
17920 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,
17921 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,
17922 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=
17923 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)}}(),
17924 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=
17925 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,
17926 {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===
17927 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,
17928 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);
17929 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)}});
17930 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=
17931 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,
17932 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,
17933 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),
17934 !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,
17935 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/
17936 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=
17937 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);
17938 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!==
17939 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=
17940 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};
17941 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;
17942 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()/
17943 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,
17944 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=
17945 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=
17946 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,
17947 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));
17948 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=
17949 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}},
17950 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+
17951 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,
17952 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,
17953 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,
17954 -.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}});
17955 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-
17956 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;
17957 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<
17958 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:
17959 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=
17960 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(),
17961 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),
17962 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,
17963 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===
17964 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=
17965 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]);
17966 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),
17967 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),
17968 {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=
17969 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=
17970 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&&
17971 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<
17972 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=
17973 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=
17974 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);
17975 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=
17976 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-
17977 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=
17978 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+
17979 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);
17980 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,
17981 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,
17982 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,
17983 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=
17984 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=
17985 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=
17986 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=
17987 !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=
17988 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;
17989 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,
17990 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;
17991 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);
17992 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};
17993 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,
17994 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),
17995 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=
17996 (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&&
17997 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);
17998 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=
17999 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");
18000 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=
18001 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?
18002 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);
18003 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);
18004 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=
18005 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.");
18006 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;
18007 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=
18008 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,
18009 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],
18010 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=
18011 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,
18012 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=
18013 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=
18014 !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;
18015 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),
18016 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};
18017 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,
18018 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};
18019 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();
18020 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=
18021 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=
18022 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();
18023 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};
18024 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,
18025 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);
18026 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=
18027 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,
18028 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();
18029 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=
18030 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},
18031 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,
18032 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);
18033 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&&
18034 (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),
18035 {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());
18036 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=
18037 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,
18038 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;
18039 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=
18040 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,
18041 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,
18042 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=
18043 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++];
18044 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=
18045 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]=
18046 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=
18047 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,
18048 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,
18049 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,
18050 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+
18051 " 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/
18052 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=
18053 !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=
18054 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]=
18055 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,
18056 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,
18057 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));
18058 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+
18059 "]",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,
18060 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=
18061 [],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=
18062 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===
18063 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=
18064 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=
18065 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=
18066 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&&
18067 (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);
18068 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!==
18069 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!==
18070 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||
18071 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,
18072 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,
18073 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!==
18074 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=
18075 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;
18076 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,
18077 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;
18078 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;
18079 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=
18080 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"!==
18081 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"===
18082 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},
18083 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=
18084 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++],
18085 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);
18086 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=
18087 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=
18088 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,
18089 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,
18090 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 "+
18091 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));
18092 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=
18093 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,
18094 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);
18095 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,
18096 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=
18097 (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<
18098 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={};
18099 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.",
18100 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);
18101 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",
18102 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):
18103 "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({},
18104 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.");
18105 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!==
18106 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&&
18107 (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);
18108 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,
18109 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),
18110 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,
18111 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)>
18112 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=
18113 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,
18114 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=
18115 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,
18116 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||
18117 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=
18118 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)}}()});
18119 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)):
18120 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,
18121 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,
18122 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},
18123 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;
18124 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(),
18125 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]);
18126 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.");
18127 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=
18128 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},
18129 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,
18130 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,
18131 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,
18132 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,
18133 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=
18134 /[\[\]\.:\/]/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: "+
18135 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;
18136 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,
18137 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=
18138 !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,
18139 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,
18140 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.",
18141 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.",
18142 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.",
18143 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.",
18144 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: "+
18145 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!==
18146 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_=
18147 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=
18148 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_,
18149 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()},
18150 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;
18151 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;
18152 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,
18153 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||
18154 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];
18155 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===
18156 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:
18157 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:
18158 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===
18159 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,
18160 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=
18161 [];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}}}},
18162 _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;
18163 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,
18164 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,
18165 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++,
18166 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=
18167 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,
18168 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,
18169 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=
18170 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)}});
18171 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,
18172 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||
18173 [];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=
18174 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-
18175 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*
18176 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);
18177 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()?
18178 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,
18179 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;
18180 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)},
18181 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)},
18182 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"),
18183 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",
18184 "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=
18185 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,
18186 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=
18187 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)}}();
18188 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,
18189 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=
18190 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);
18191 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);
18192 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,
18193 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"),
18194 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",
18195 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]=
18196 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,
18197 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,
18198 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);
18199 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.");
18200 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);
18201 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.")};
18202 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().");
18203 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().");
18204 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().");
18205 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,
18206 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.");
18207 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;
18208 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.");
18209 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.");
18210 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.");
18211 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)};
18212 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)},
18213 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().");
18214 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().");
18215 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,
18216 {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,
18217 {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().");
18218 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,
18219 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,
18220 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().");
18221 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,
18222 {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.")}}});
18223 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.");
18224 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.");
18225 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.");
18226 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.");
18227 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.");
18228 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)},
18229 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.");
18230 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.")}},
18231 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+
18232 ": .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")}}});
18233 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().");
18234 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' ).");
18235 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' ).");
18236 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.");
18237 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.")},
18238 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.");
18239 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,
18240 {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.")}},
18241 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.");
18242 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=
18243 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=
18244 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.");
18245 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},
18246 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().");
18247 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.");
18248 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=
18249 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=
18250 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;
18251 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=
18252 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=
18253 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=
18254 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=
18255 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=
18256 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=
18257 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=
18258 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=
18259 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=
18260 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;
18261 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=
18262 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;
18263 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,
18264 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,
18265 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.");
18266 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,
18267 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.");
18268 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=
18269 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.");
18270 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)};
18271 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.");
18272 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=
18273 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")},
18274 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})});
18276 },{}],227:[function(require,module,exports){
18279 module.exports = TinyQueue;
18281 function TinyQueue(data, compare) {
18282 if (!(this instanceof TinyQueue)) return new TinyQueue(data, compare);
18284 this.data = data || [];
18285 this.length = this.data.length;
18286 this.compare = compare || defaultCompare;
18288 if (this.length > 0) {
18289 for (var i = (this.length >> 1); i >= 0; i--) this._down(i);
18293 function defaultCompare(a, b) {
18294 return a < b ? -1 : a > b ? 1 : 0;
18297 TinyQueue.prototype = {
18299 push: function (item) {
18300 this.data.push(item);
18302 this._up(this.length - 1);
18306 if (this.length === 0) return undefined;
18307 var top = this.data[0];
18309 if (this.length > 0) {
18310 this.data[0] = this.data[this.length];
18317 peek: function () {
18318 return this.data[0];
18321 _up: function (pos) {
18322 var data = this.data;
18323 var compare = this.compare;
18324 var item = data[pos];
18327 var parent = (pos - 1) >> 1;
18328 var current = data[parent];
18329 if (compare(item, current) >= 0) break;
18330 data[pos] = current;
18337 _down: function (pos) {
18338 var data = this.data;
18339 var compare = this.compare;
18340 var len = this.length;
18341 var halfLen = len >> 1;
18342 var item = data[pos];
18344 while (pos < halfLen) {
18345 var left = (pos << 1) + 1;
18346 var right = left + 1;
18347 var best = data[left];
18349 if (right < len && compare(data[right], best) < 0) {
18351 best = data[right];
18353 if (compare(best, item) >= 0) break;
18363 },{}],228:[function(require,module,exports){
18364 var createElement = require("./vdom/create-element.js")
18366 module.exports = createElement
18368 },{"./vdom/create-element.js":234}],229:[function(require,module,exports){
18369 var diff = require("./vtree/diff.js")
18371 module.exports = diff
18373 },{"./vtree/diff.js":254}],230:[function(require,module,exports){
18374 var h = require("./virtual-hyperscript/index.js")
18378 },{"./virtual-hyperscript/index.js":241}],231:[function(require,module,exports){
18379 var diff = require("./diff.js")
18380 var patch = require("./patch.js")
18381 var h = require("./h.js")
18382 var create = require("./create-element.js")
18383 var VNode = require('./vnode/vnode.js')
18384 var VText = require('./vnode/vtext.js')
18395 },{"./create-element.js":228,"./diff.js":229,"./h.js":230,"./patch.js":232,"./vnode/vnode.js":250,"./vnode/vtext.js":252}],232:[function(require,module,exports){
18396 var patch = require("./vdom/patch.js")
18398 module.exports = patch
18400 },{"./vdom/patch.js":237}],233:[function(require,module,exports){
18401 var isObject = require("is-object")
18402 var isHook = require("../vnode/is-vhook.js")
18404 module.exports = applyProperties
18406 function applyProperties(node, props, previous) {
18407 for (var propName in props) {
18408 var propValue = props[propName]
18410 if (propValue === undefined) {
18411 removeProperty(node, propName, propValue, previous);
18412 } else if (isHook(propValue)) {
18413 removeProperty(node, propName, propValue, previous)
18414 if (propValue.hook) {
18415 propValue.hook(node,
18417 previous ? previous[propName] : undefined)
18420 if (isObject(propValue)) {
18421 patchObject(node, props, previous, propName, propValue);
18423 node[propName] = propValue
18429 function removeProperty(node, propName, propValue, previous) {
18431 var previousValue = previous[propName]
18433 if (!isHook(previousValue)) {
18434 if (propName === "attributes") {
18435 for (var attrName in previousValue) {
18436 node.removeAttribute(attrName)
18438 } else if (propName === "style") {
18439 for (var i in previousValue) {
18442 } else if (typeof previousValue === "string") {
18443 node[propName] = ""
18445 node[propName] = null
18447 } else if (previousValue.unhook) {
18448 previousValue.unhook(node, propName, propValue)
18453 function patchObject(node, props, previous, propName, propValue) {
18454 var previousValue = previous ? previous[propName] : undefined
18457 if (propName === "attributes") {
18458 for (var attrName in propValue) {
18459 var attrValue = propValue[attrName]
18461 if (attrValue === undefined) {
18462 node.removeAttribute(attrName)
18464 node.setAttribute(attrName, attrValue)
18471 if(previousValue && isObject(previousValue) &&
18472 getPrototype(previousValue) !== getPrototype(propValue)) {
18473 node[propName] = propValue
18477 if (!isObject(node[propName])) {
18478 node[propName] = {}
18481 var replacer = propName === "style" ? "" : undefined
18483 for (var k in propValue) {
18484 var value = propValue[k]
18485 node[propName][k] = (value === undefined) ? replacer : value
18489 function getPrototype(value) {
18490 if (Object.getPrototypeOf) {
18491 return Object.getPrototypeOf(value)
18492 } else if (value.__proto__) {
18493 return value.__proto__
18494 } else if (value.constructor) {
18495 return value.constructor.prototype
18499 },{"../vnode/is-vhook.js":245,"is-object":20}],234:[function(require,module,exports){
18500 var document = require("global/document")
18502 var applyProperties = require("./apply-properties")
18504 var isVNode = require("../vnode/is-vnode.js")
18505 var isVText = require("../vnode/is-vtext.js")
18506 var isWidget = require("../vnode/is-widget.js")
18507 var handleThunk = require("../vnode/handle-thunk.js")
18509 module.exports = createElement
18511 function createElement(vnode, opts) {
18512 var doc = opts ? opts.document || document : document
18513 var warn = opts ? opts.warn : null
18515 vnode = handleThunk(vnode).a
18517 if (isWidget(vnode)) {
18518 return vnode.init()
18519 } else if (isVText(vnode)) {
18520 return doc.createTextNode(vnode.text)
18521 } else if (!isVNode(vnode)) {
18523 warn("Item is not a valid virtual dom node", vnode)
18528 var node = (vnode.namespace === null) ?
18529 doc.createElement(vnode.tagName) :
18530 doc.createElementNS(vnode.namespace, vnode.tagName)
18532 var props = vnode.properties
18533 applyProperties(node, props)
18535 var children = vnode.children
18537 for (var i = 0; i < children.length; i++) {
18538 var childNode = createElement(children[i], opts)
18540 node.appendChild(childNode)
18547 },{"../vnode/handle-thunk.js":243,"../vnode/is-vnode.js":246,"../vnode/is-vtext.js":247,"../vnode/is-widget.js":248,"./apply-properties":233,"global/document":16}],235:[function(require,module,exports){
18548 // Maps a virtual DOM tree onto a real DOM tree in an efficient manner.
18549 // We don't want to read all of the DOM nodes in the tree so we use
18550 // the in-order tree indexing to eliminate recursion down certain branches.
18551 // We only recurse into a DOM node if we know that it contains a child of
18556 module.exports = domIndex
18558 function domIndex(rootNode, tree, indices, nodes) {
18559 if (!indices || indices.length === 0) {
18562 indices.sort(ascending)
18563 return recurse(rootNode, tree, indices, nodes, 0)
18567 function recurse(rootNode, tree, indices, nodes, rootIndex) {
18568 nodes = nodes || {}
18572 if (indexInRange(indices, rootIndex, rootIndex)) {
18573 nodes[rootIndex] = rootNode
18576 var vChildren = tree.children
18580 var childNodes = rootNode.childNodes
18582 for (var i = 0; i < tree.children.length; i++) {
18585 var vChild = vChildren[i] || noChild
18586 var nextIndex = rootIndex + (vChild.count || 0)
18588 // skip recursion down the tree if there are no nodes down here
18589 if (indexInRange(indices, rootIndex, nextIndex)) {
18590 recurse(childNodes[i], vChild, indices, nodes, rootIndex)
18593 rootIndex = nextIndex
18601 // Binary search for an index in the interval [left, right]
18602 function indexInRange(indices, left, right) {
18603 if (indices.length === 0) {
18608 var maxIndex = indices.length - 1
18612 while (minIndex <= maxIndex) {
18613 currentIndex = ((maxIndex + minIndex) / 2) >> 0
18614 currentItem = indices[currentIndex]
18616 if (minIndex === maxIndex) {
18617 return currentItem >= left && currentItem <= right
18618 } else if (currentItem < left) {
18619 minIndex = currentIndex + 1
18620 } else if (currentItem > right) {
18621 maxIndex = currentIndex - 1
18630 function ascending(a, b) {
18631 return a > b ? 1 : -1
18634 },{}],236:[function(require,module,exports){
18635 var applyProperties = require("./apply-properties")
18637 var isWidget = require("../vnode/is-widget.js")
18638 var VPatch = require("../vnode/vpatch.js")
18640 var updateWidget = require("./update-widget")
18642 module.exports = applyPatch
18644 function applyPatch(vpatch, domNode, renderOptions) {
18645 var type = vpatch.type
18646 var vNode = vpatch.vNode
18647 var patch = vpatch.patch
18650 case VPatch.REMOVE:
18651 return removeNode(domNode, vNode)
18652 case VPatch.INSERT:
18653 return insertNode(domNode, patch, renderOptions)
18655 return stringPatch(domNode, vNode, patch, renderOptions)
18656 case VPatch.WIDGET:
18657 return widgetPatch(domNode, vNode, patch, renderOptions)
18659 return vNodePatch(domNode, vNode, patch, renderOptions)
18661 reorderChildren(domNode, patch)
18664 applyProperties(domNode, patch, vNode.properties)
18667 return replaceRoot(domNode,
18668 renderOptions.patch(domNode, patch, renderOptions))
18674 function removeNode(domNode, vNode) {
18675 var parentNode = domNode.parentNode
18678 parentNode.removeChild(domNode)
18681 destroyWidget(domNode, vNode);
18686 function insertNode(parentNode, vNode, renderOptions) {
18687 var newNode = renderOptions.render(vNode, renderOptions)
18690 parentNode.appendChild(newNode)
18696 function stringPatch(domNode, leftVNode, vText, renderOptions) {
18699 if (domNode.nodeType === 3) {
18700 domNode.replaceData(0, domNode.length, vText.text)
18703 var parentNode = domNode.parentNode
18704 newNode = renderOptions.render(vText, renderOptions)
18706 if (parentNode && newNode !== domNode) {
18707 parentNode.replaceChild(newNode, domNode)
18714 function widgetPatch(domNode, leftVNode, widget, renderOptions) {
18715 var updating = updateWidget(leftVNode, widget)
18719 newNode = widget.update(leftVNode, domNode) || domNode
18721 newNode = renderOptions.render(widget, renderOptions)
18724 var parentNode = domNode.parentNode
18726 if (parentNode && newNode !== domNode) {
18727 parentNode.replaceChild(newNode, domNode)
18731 destroyWidget(domNode, leftVNode)
18737 function vNodePatch(domNode, leftVNode, vNode, renderOptions) {
18738 var parentNode = domNode.parentNode
18739 var newNode = renderOptions.render(vNode, renderOptions)
18741 if (parentNode && newNode !== domNode) {
18742 parentNode.replaceChild(newNode, domNode)
18748 function destroyWidget(domNode, w) {
18749 if (typeof w.destroy === "function" && isWidget(w)) {
18754 function reorderChildren(domNode, moves) {
18755 var childNodes = domNode.childNodes
18761 for (var i = 0; i < moves.removes.length; i++) {
18762 remove = moves.removes[i]
18763 node = childNodes[remove.from]
18765 keyMap[remove.key] = node
18767 domNode.removeChild(node)
18770 var length = childNodes.length
18771 for (var j = 0; j < moves.inserts.length; j++) {
18772 insert = moves.inserts[j]
18773 node = keyMap[insert.key]
18774 // this is the weirdest bug i've ever seen in webkit
18775 domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to])
18779 function replaceRoot(oldRoot, newRoot) {
18780 if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {
18781 oldRoot.parentNode.replaceChild(newRoot, oldRoot)
18787 },{"../vnode/is-widget.js":248,"../vnode/vpatch.js":251,"./apply-properties":233,"./update-widget":238}],237:[function(require,module,exports){
18788 var document = require("global/document")
18789 var isArray = require("x-is-array")
18791 var render = require("./create-element")
18792 var domIndex = require("./dom-index")
18793 var patchOp = require("./patch-op")
18794 module.exports = patch
18796 function patch(rootNode, patches, renderOptions) {
18797 renderOptions = renderOptions || {}
18798 renderOptions.patch = renderOptions.patch && renderOptions.patch !== patch
18799 ? renderOptions.patch
18801 renderOptions.render = renderOptions.render || render
18803 return renderOptions.patch(rootNode, patches, renderOptions)
18806 function patchRecursive(rootNode, patches, renderOptions) {
18807 var indices = patchIndices(patches)
18809 if (indices.length === 0) {
18813 var index = domIndex(rootNode, patches.a, indices)
18814 var ownerDocument = rootNode.ownerDocument
18816 if (!renderOptions.document && ownerDocument !== document) {
18817 renderOptions.document = ownerDocument
18820 for (var i = 0; i < indices.length; i++) {
18821 var nodeIndex = indices[i]
18822 rootNode = applyPatch(rootNode,
18824 patches[nodeIndex],
18831 function applyPatch(rootNode, domNode, patchList, renderOptions) {
18838 if (isArray(patchList)) {
18839 for (var i = 0; i < patchList.length; i++) {
18840 newNode = patchOp(patchList[i], domNode, renderOptions)
18842 if (domNode === rootNode) {
18847 newNode = patchOp(patchList, domNode, renderOptions)
18849 if (domNode === rootNode) {
18857 function patchIndices(patches) {
18860 for (var key in patches) {
18862 indices.push(Number(key))
18869 },{"./create-element":234,"./dom-index":235,"./patch-op":236,"global/document":16,"x-is-array":273}],238:[function(require,module,exports){
18870 var isWidget = require("../vnode/is-widget.js")
18872 module.exports = updateWidget
18874 function updateWidget(a, b) {
18875 if (isWidget(a) && isWidget(b)) {
18876 if ("name" in a && "name" in b) {
18877 return a.id === b.id
18879 return a.init === b.init
18886 },{"../vnode/is-widget.js":248}],239:[function(require,module,exports){
18889 var EvStore = require('ev-store');
18891 module.exports = EvHook;
18893 function EvHook(value) {
18894 if (!(this instanceof EvHook)) {
18895 return new EvHook(value);
18898 this.value = value;
18901 EvHook.prototype.hook = function (node, propertyName) {
18902 var es = EvStore(node);
18903 var propName = propertyName.substr(3);
18905 es[propName] = this.value;
18908 EvHook.prototype.unhook = function(node, propertyName) {
18909 var es = EvStore(node);
18910 var propName = propertyName.substr(3);
18912 es[propName] = undefined;
18915 },{"ev-store":9}],240:[function(require,module,exports){
18918 module.exports = SoftSetHook;
18920 function SoftSetHook(value) {
18921 if (!(this instanceof SoftSetHook)) {
18922 return new SoftSetHook(value);
18925 this.value = value;
18928 SoftSetHook.prototype.hook = function (node, propertyName) {
18929 if (node[propertyName] !== this.value) {
18930 node[propertyName] = this.value;
18934 },{}],241:[function(require,module,exports){
18937 var isArray = require('x-is-array');
18939 var VNode = require('../vnode/vnode.js');
18940 var VText = require('../vnode/vtext.js');
18941 var isVNode = require('../vnode/is-vnode');
18942 var isVText = require('../vnode/is-vtext');
18943 var isWidget = require('../vnode/is-widget');
18944 var isHook = require('../vnode/is-vhook');
18945 var isVThunk = require('../vnode/is-thunk');
18947 var parseTag = require('./parse-tag.js');
18948 var softSetHook = require('./hooks/soft-set-hook.js');
18949 var evHook = require('./hooks/ev-hook.js');
18951 module.exports = h;
18953 function h(tagName, properties, children) {
18954 var childNodes = [];
18955 var tag, props, key, namespace;
18957 if (!children && isChildren(properties)) {
18958 children = properties;
18962 props = props || properties || {};
18963 tag = parseTag(tagName, props);
18966 if (props.hasOwnProperty('key')) {
18968 props.key = undefined;
18971 // support namespace
18972 if (props.hasOwnProperty('namespace')) {
18973 namespace = props.namespace;
18974 props.namespace = undefined;
18978 if (tag === 'INPUT' &&
18980 props.hasOwnProperty('value') &&
18981 props.value !== undefined &&
18982 !isHook(props.value)
18984 props.value = softSetHook(props.value);
18987 transformProperties(props);
18989 if (children !== undefined && children !== null) {
18990 addChild(children, childNodes, tag, props);
18994 return new VNode(tag, props, childNodes, key, namespace);
18997 function addChild(c, childNodes, tag, props) {
18998 if (typeof c === 'string') {
18999 childNodes.push(new VText(c));
19000 } else if (typeof c === 'number') {
19001 childNodes.push(new VText(String(c)));
19002 } else if (isChild(c)) {
19003 childNodes.push(c);
19004 } else if (isArray(c)) {
19005 for (var i = 0; i < c.length; i++) {
19006 addChild(c[i], childNodes, tag, props);
19008 } else if (c === null || c === undefined) {
19011 throw UnexpectedVirtualElement({
19021 function transformProperties(props) {
19022 for (var propName in props) {
19023 if (props.hasOwnProperty(propName)) {
19024 var value = props[propName];
19026 if (isHook(value)) {
19030 if (propName.substr(0, 3) === 'ev-') {
19031 // add ev-foo support
19032 props[propName] = evHook(value);
19038 function isChild(x) {
19039 return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x);
19042 function isChildren(x) {
19043 return typeof x === 'string' || isArray(x) || isChild(x);
19046 function UnexpectedVirtualElement(data) {
19047 var err = new Error();
19049 err.type = 'virtual-hyperscript.unexpected.virtual-element';
19050 err.message = 'Unexpected virtual child passed to h().\n' +
19051 'Expected a VNode / Vthunk / VWidget / string but:\n' +
19053 errorString(data.foreignObject) +
19055 'The parent vnode is:\n' +
19056 errorString(data.parentVnode)
19058 'Suggested fix: change your `h(..., [ ... ])` callsite.';
19059 err.foreignObject = data.foreignObject;
19060 err.parentVnode = data.parentVnode;
19065 function errorString(obj) {
19067 return JSON.stringify(obj, null, ' ');
19069 return String(obj);
19073 },{"../vnode/is-thunk":244,"../vnode/is-vhook":245,"../vnode/is-vnode":246,"../vnode/is-vtext":247,"../vnode/is-widget":248,"../vnode/vnode.js":250,"../vnode/vtext.js":252,"./hooks/ev-hook.js":239,"./hooks/soft-set-hook.js":240,"./parse-tag.js":242,"x-is-array":273}],242:[function(require,module,exports){
19076 var split = require('browser-split');
19078 var classIdSplit = /([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/;
19079 var notClassId = /^\.|#/;
19081 module.exports = parseTag;
19083 function parseTag(tag, props) {
19088 var noId = !(props.hasOwnProperty('id'));
19090 var tagParts = split(tag, classIdSplit);
19091 var tagName = null;
19093 if (notClassId.test(tagParts[1])) {
19097 var classes, part, type, i;
19099 for (i = 0; i < tagParts.length; i++) {
19100 part = tagParts[i];
19106 type = part.charAt(0);
19110 } else if (type === '.') {
19111 classes = classes || [];
19112 classes.push(part.substring(1, part.length));
19113 } else if (type === '#' && noId) {
19114 props.id = part.substring(1, part.length);
19119 if (props.className) {
19120 classes.push(props.className);
19123 props.className = classes.join(' ');
19126 return props.namespace ? tagName : tagName.toUpperCase();
19129 },{"browser-split":5}],243:[function(require,module,exports){
19130 var isVNode = require("./is-vnode")
19131 var isVText = require("./is-vtext")
19132 var isWidget = require("./is-widget")
19133 var isThunk = require("./is-thunk")
19135 module.exports = handleThunk
19137 function handleThunk(a, b) {
19142 renderedB = renderThunk(b, a)
19146 renderedA = renderThunk(a, null)
19155 function renderThunk(thunk, previous) {
19156 var renderedThunk = thunk.vnode
19158 if (!renderedThunk) {
19159 renderedThunk = thunk.vnode = thunk.render(previous)
19162 if (!(isVNode(renderedThunk) ||
19163 isVText(renderedThunk) ||
19164 isWidget(renderedThunk))) {
19165 throw new Error("thunk did not return a valid node");
19168 return renderedThunk
19171 },{"./is-thunk":244,"./is-vnode":246,"./is-vtext":247,"./is-widget":248}],244:[function(require,module,exports){
19172 module.exports = isThunk
19174 function isThunk(t) {
19175 return t && t.type === "Thunk"
19178 },{}],245:[function(require,module,exports){
19179 module.exports = isHook
19181 function isHook(hook) {
19183 (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||
19184 typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))
19187 },{}],246:[function(require,module,exports){
19188 var version = require("./version")
19190 module.exports = isVirtualNode
19192 function isVirtualNode(x) {
19193 return x && x.type === "VirtualNode" && x.version === version
19196 },{"./version":249}],247:[function(require,module,exports){
19197 var version = require("./version")
19199 module.exports = isVirtualText
19201 function isVirtualText(x) {
19202 return x && x.type === "VirtualText" && x.version === version
19205 },{"./version":249}],248:[function(require,module,exports){
19206 module.exports = isWidget
19208 function isWidget(w) {
19209 return w && w.type === "Widget"
19212 },{}],249:[function(require,module,exports){
19213 module.exports = "2"
19215 },{}],250:[function(require,module,exports){
19216 var version = require("./version")
19217 var isVNode = require("./is-vnode")
19218 var isWidget = require("./is-widget")
19219 var isThunk = require("./is-thunk")
19220 var isVHook = require("./is-vhook")
19222 module.exports = VirtualNode
19224 var noProperties = {}
19225 var noChildren = []
19227 function VirtualNode(tagName, properties, children, key, namespace) {
19228 this.tagName = tagName
19229 this.properties = properties || noProperties
19230 this.children = children || noChildren
19231 this.key = key != null ? String(key) : undefined
19232 this.namespace = (typeof namespace === "string") ? namespace : null
19234 var count = (children && children.length) || 0
19235 var descendants = 0
19236 var hasWidgets = false
19237 var hasThunks = false
19238 var descendantHooks = false
19241 for (var propName in properties) {
19242 if (properties.hasOwnProperty(propName)) {
19243 var property = properties[propName]
19244 if (isVHook(property) && property.unhook) {
19249 hooks[propName] = property
19254 for (var i = 0; i < count; i++) {
19255 var child = children[i]
19256 if (isVNode(child)) {
19257 descendants += child.count || 0
19259 if (!hasWidgets && child.hasWidgets) {
19263 if (!hasThunks && child.hasThunks) {
19267 if (!descendantHooks && (child.hooks || child.descendantHooks)) {
19268 descendantHooks = true
19270 } else if (!hasWidgets && isWidget(child)) {
19271 if (typeof child.destroy === "function") {
19274 } else if (!hasThunks && isThunk(child)) {
19279 this.count = count + descendants
19280 this.hasWidgets = hasWidgets
19281 this.hasThunks = hasThunks
19283 this.descendantHooks = descendantHooks
19286 VirtualNode.prototype.version = version
19287 VirtualNode.prototype.type = "VirtualNode"
19289 },{"./is-thunk":244,"./is-vhook":245,"./is-vnode":246,"./is-widget":248,"./version":249}],251:[function(require,module,exports){
19290 var version = require("./version")
19292 VirtualPatch.NONE = 0
19293 VirtualPatch.VTEXT = 1
19294 VirtualPatch.VNODE = 2
19295 VirtualPatch.WIDGET = 3
19296 VirtualPatch.PROPS = 4
19297 VirtualPatch.ORDER = 5
19298 VirtualPatch.INSERT = 6
19299 VirtualPatch.REMOVE = 7
19300 VirtualPatch.THUNK = 8
19302 module.exports = VirtualPatch
19304 function VirtualPatch(type, vNode, patch) {
19305 this.type = Number(type)
19310 VirtualPatch.prototype.version = version
19311 VirtualPatch.prototype.type = "VirtualPatch"
19313 },{"./version":249}],252:[function(require,module,exports){
19314 var version = require("./version")
19316 module.exports = VirtualText
19318 function VirtualText(text) {
19319 this.text = String(text)
19322 VirtualText.prototype.version = version
19323 VirtualText.prototype.type = "VirtualText"
19325 },{"./version":249}],253:[function(require,module,exports){
19326 var isObject = require("is-object")
19327 var isHook = require("../vnode/is-vhook")
19329 module.exports = diffProps
19331 function diffProps(a, b) {
19334 for (var aKey in a) {
19335 if (!(aKey in b)) {
19337 diff[aKey] = undefined
19340 var aValue = a[aKey]
19341 var bValue = b[aKey]
19343 if (aValue === bValue) {
19345 } else if (isObject(aValue) && isObject(bValue)) {
19346 if (getPrototype(bValue) !== getPrototype(aValue)) {
19348 diff[aKey] = bValue
19349 } else if (isHook(bValue)) {
19351 diff[aKey] = bValue
19353 var objectDiff = diffProps(aValue, bValue)
19356 diff[aKey] = objectDiff
19361 diff[aKey] = bValue
19365 for (var bKey in b) {
19366 if (!(bKey in a)) {
19368 diff[bKey] = b[bKey]
19375 function getPrototype(value) {
19376 if (Object.getPrototypeOf) {
19377 return Object.getPrototypeOf(value)
19378 } else if (value.__proto__) {
19379 return value.__proto__
19380 } else if (value.constructor) {
19381 return value.constructor.prototype
19385 },{"../vnode/is-vhook":245,"is-object":20}],254:[function(require,module,exports){
19386 var isArray = require("x-is-array")
19388 var VPatch = require("../vnode/vpatch")
19389 var isVNode = require("../vnode/is-vnode")
19390 var isVText = require("../vnode/is-vtext")
19391 var isWidget = require("../vnode/is-widget")
19392 var isThunk = require("../vnode/is-thunk")
19393 var handleThunk = require("../vnode/handle-thunk")
19395 var diffProps = require("./diff-props")
19397 module.exports = diff
19399 function diff(a, b) {
19400 var patch = { a: a }
19401 walk(a, b, patch, 0)
19405 function walk(a, b, patch, index) {
19410 var apply = patch[index]
19411 var applyClear = false
19413 if (isThunk(a) || isThunk(b)) {
19414 thunks(a, b, patch, index)
19415 } else if (b == null) {
19417 // If a is a widget we will add a remove patch for it
19418 // Otherwise any child widgets/hooks must be destroyed.
19419 // This prevents adding two remove patches for a widget.
19420 if (!isWidget(a)) {
19421 clearState(a, patch, index)
19422 apply = patch[index]
19425 apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b))
19426 } else if (isVNode(b)) {
19428 if (a.tagName === b.tagName &&
19429 a.namespace === b.namespace &&
19431 var propsPatch = diffProps(a.properties, b.properties)
19433 apply = appendPatch(apply,
19434 new VPatch(VPatch.PROPS, a, propsPatch))
19436 apply = diffChildren(a, b, patch, apply, index)
19438 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
19442 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
19445 } else if (isVText(b)) {
19447 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
19449 } else if (a.text !== b.text) {
19450 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
19452 } else if (isWidget(b)) {
19453 if (!isWidget(a)) {
19457 apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b))
19461 patch[index] = apply
19465 clearState(a, patch, index)
19469 function diffChildren(a, b, patch, apply, index) {
19470 var aChildren = a.children
19471 var orderedSet = reorder(aChildren, b.children)
19472 var bChildren = orderedSet.children
19474 var aLen = aChildren.length
19475 var bLen = bChildren.length
19476 var len = aLen > bLen ? aLen : bLen
19478 for (var i = 0; i < len; i++) {
19479 var leftNode = aChildren[i]
19480 var rightNode = bChildren[i]
19485 // Excess nodes in b need to be added
19486 apply = appendPatch(apply,
19487 new VPatch(VPatch.INSERT, null, rightNode))
19490 walk(leftNode, rightNode, patch, index)
19493 if (isVNode(leftNode) && leftNode.count) {
19494 index += leftNode.count
19498 if (orderedSet.moves) {
19499 // Reorder nodes last
19500 apply = appendPatch(apply, new VPatch(
19510 function clearState(vNode, patch, index) {
19511 // TODO: Make this a single walk, not two
19512 unhook(vNode, patch, index)
19513 destroyWidgets(vNode, patch, index)
19516 // Patch records for all destroyed widgets must be added because we need
19517 // a DOM node reference for the destroy function
19518 function destroyWidgets(vNode, patch, index) {
19519 if (isWidget(vNode)) {
19520 if (typeof vNode.destroy === "function") {
19521 patch[index] = appendPatch(
19523 new VPatch(VPatch.REMOVE, vNode, null)
19526 } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
19527 var children = vNode.children
19528 var len = children.length
19529 for (var i = 0; i < len; i++) {
19530 var child = children[i]
19533 destroyWidgets(child, patch, index)
19535 if (isVNode(child) && child.count) {
19536 index += child.count
19539 } else if (isThunk(vNode)) {
19540 thunks(vNode, null, patch, index)
19544 // Create a sub-patch for thunks
19545 function thunks(a, b, patch, index) {
19546 var nodes = handleThunk(a, b)
19547 var thunkPatch = diff(nodes.a, nodes.b)
19548 if (hasPatches(thunkPatch)) {
19549 patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)
19553 function hasPatches(patch) {
19554 for (var index in patch) {
19555 if (index !== "a") {
19563 // Execute hooks when two nodes are identical
19564 function unhook(vNode, patch, index) {
19565 if (isVNode(vNode)) {
19567 patch[index] = appendPatch(
19572 undefinedKeys(vNode.hooks)
19577 if (vNode.descendantHooks || vNode.hasThunks) {
19578 var children = vNode.children
19579 var len = children.length
19580 for (var i = 0; i < len; i++) {
19581 var child = children[i]
19584 unhook(child, patch, index)
19586 if (isVNode(child) && child.count) {
19587 index += child.count
19591 } else if (isThunk(vNode)) {
19592 thunks(vNode, null, patch, index)
19596 function undefinedKeys(obj) {
19599 for (var key in obj) {
19600 result[key] = undefined
19606 // List diff, naive left to right reordering
19607 function reorder(aChildren, bChildren) {
19608 // O(M) time, O(M) memory
19609 var bChildIndex = keyIndex(bChildren)
19610 var bKeys = bChildIndex.keys
19611 var bFree = bChildIndex.free
19613 if (bFree.length === bChildren.length) {
19615 children: bChildren,
19620 // O(N) time, O(N) memory
19621 var aChildIndex = keyIndex(aChildren)
19622 var aKeys = aChildIndex.keys
19623 var aFree = aChildIndex.free
19625 if (aFree.length === aChildren.length) {
19627 children: bChildren,
19632 // O(MAX(N, M)) memory
19633 var newChildren = []
19636 var freeCount = bFree.length
19637 var deletedItems = 0
19639 // Iterate through a and match a node in b
19641 for (var i = 0 ; i < aChildren.length; i++) {
19642 var aItem = aChildren[i]
19646 if (bKeys.hasOwnProperty(aItem.key)) {
19647 // Match up the old keys
19648 itemIndex = bKeys[aItem.key]
19649 newChildren.push(bChildren[itemIndex])
19652 // Remove old keyed items
19653 itemIndex = i - deletedItems++
19654 newChildren.push(null)
19657 // Match the item in a with the next free item in b
19658 if (freeIndex < freeCount) {
19659 itemIndex = bFree[freeIndex++]
19660 newChildren.push(bChildren[itemIndex])
19662 // There are no free items in b to match with
19663 // the free items in a, so the extra free nodes
19665 itemIndex = i - deletedItems++
19666 newChildren.push(null)
19671 var lastFreeIndex = freeIndex >= bFree.length ?
19675 // Iterate through b and append any new keys
19677 for (var j = 0; j < bChildren.length; j++) {
19678 var newItem = bChildren[j]
19681 if (!aKeys.hasOwnProperty(newItem.key)) {
19682 // Add any new keyed items
19683 // We are adding new items to the end and then sorting them
19684 // in place. In future we should insert new items in place.
19685 newChildren.push(newItem)
19687 } else if (j >= lastFreeIndex) {
19688 // Add any leftover non-keyed items
19689 newChildren.push(newItem)
19693 var simulate = newChildren.slice()
19694 var simulateIndex = 0
19699 for (var k = 0; k < bChildren.length;) {
19700 var wantedItem = bChildren[k]
19701 simulateItem = simulate[simulateIndex]
19704 while (simulateItem === null && simulate.length) {
19705 removes.push(remove(simulate, simulateIndex, null))
19706 simulateItem = simulate[simulateIndex]
19709 if (!simulateItem || simulateItem.key !== wantedItem.key) {
19710 // if we need a key in this position...
19711 if (wantedItem.key) {
19712 if (simulateItem && simulateItem.key) {
19713 // if an insert doesn't put this key in place, it needs to move
19714 if (bKeys[simulateItem.key] !== k + 1) {
19715 removes.push(remove(simulate, simulateIndex, simulateItem.key))
19716 simulateItem = simulate[simulateIndex]
19717 // if the remove didn't put the wanted item in place, we need to insert it
19718 if (!simulateItem || simulateItem.key !== wantedItem.key) {
19719 inserts.push({key: wantedItem.key, to: k})
19721 // items are matching, so skip ahead
19727 inserts.push({key: wantedItem.key, to: k})
19731 inserts.push({key: wantedItem.key, to: k})
19735 // a key in simulate has no matching wanted key, remove it
19736 else if (simulateItem && simulateItem.key) {
19737 removes.push(remove(simulate, simulateIndex, simulateItem.key))
19746 // remove all the remaining nodes from simulate
19747 while(simulateIndex < simulate.length) {
19748 simulateItem = simulate[simulateIndex]
19749 removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key))
19752 // If the only moves we have are deletes then we can just
19753 // let the delete patch remove these items.
19754 if (removes.length === deletedItems && !inserts.length) {
19756 children: newChildren,
19762 children: newChildren,
19770 function remove(arr, index, key) {
19771 arr.splice(index, 1)
19779 function keyIndex(children) {
19782 var length = children.length
19784 for (var i = 0; i < length; i++) {
19785 var child = children[i]
19788 keys[child.key] = i
19795 keys: keys, // A hash of key name to index
19796 free: free // An array of unkeyed item indices
19800 function appendPatch(apply, patch) {
19802 if (isArray(apply)) {
19805 apply = [apply, patch]
19814 },{"../vnode/handle-thunk":243,"../vnode/is-thunk":244,"../vnode/is-vnode":246,"../vnode/is-vtext":247,"../vnode/is-widget":248,"../vnode/vpatch":251,"./diff-props":253,"x-is-array":273}],255:[function(require,module,exports){
19815 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19816 /** @author Brian Cavalier */
19817 /** @author John Hann */
19819 (function(define) { 'use strict';
19820 define(function (require) {
19822 var makePromise = require('./makePromise');
19823 var Scheduler = require('./Scheduler');
19824 var async = require('./env').asap;
19826 return makePromise({
19827 scheduler: new Scheduler(async)
19831 })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
19833 },{"./Scheduler":256,"./env":268,"./makePromise":270}],256:[function(require,module,exports){
19834 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19835 /** @author Brian Cavalier */
19836 /** @author John Hann */
19838 (function(define) { 'use strict';
19839 define(function() {
19841 // Credit to Twisol (https://github.com/Twisol) for suggesting
19842 // this type of extensible queue + trampoline approach for next-tick conflation.
19845 * Async task scheduler
19846 * @param {function} async function to schedule a single async function
19849 function Scheduler(async) {
19850 this._async = async;
19851 this._running = false;
19853 this._queue = this;
19854 this._queueLen = 0;
19855 this._afterQueue = {};
19856 this._afterQueueLen = 0;
19859 this.drain = function() {
19866 * @param {{ run:function }} task
19868 Scheduler.prototype.enqueue = function(task) {
19869 this._queue[this._queueLen++] = task;
19874 * Enqueue a task to run after the main task queue
19875 * @param {{ run:function }} task
19877 Scheduler.prototype.afterQueue = function(task) {
19878 this._afterQueue[this._afterQueueLen++] = task;
19882 Scheduler.prototype.run = function() {
19883 if (!this._running) {
19884 this._running = true;
19885 this._async(this.drain);
19890 * Drain the handler queue entirely, and then the after queue
19892 Scheduler.prototype._drain = function() {
19894 for (; i < this._queueLen; ++i) {
19895 this._queue[i].run();
19896 this._queue[i] = void 0;
19899 this._queueLen = 0;
19900 this._running = false;
19902 for (i = 0; i < this._afterQueueLen; ++i) {
19903 this._afterQueue[i].run();
19904 this._afterQueue[i] = void 0;
19907 this._afterQueueLen = 0;
19913 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
19915 },{}],257:[function(require,module,exports){
19916 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19917 /** @author Brian Cavalier */
19918 /** @author John Hann */
19920 (function(define) { 'use strict';
19921 define(function() {
19924 * Custom error type for promises rejected by promise.timeout
19925 * @param {string} message
19928 function TimeoutError (message) {
19930 this.message = message;
19931 this.name = TimeoutError.name;
19932 if (typeof Error.captureStackTrace === 'function') {
19933 Error.captureStackTrace(this, TimeoutError);
19937 TimeoutError.prototype = Object.create(Error.prototype);
19938 TimeoutError.prototype.constructor = TimeoutError;
19940 return TimeoutError;
19942 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
19943 },{}],258:[function(require,module,exports){
19944 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19945 /** @author Brian Cavalier */
19946 /** @author John Hann */
19948 (function(define) { 'use strict';
19949 define(function() {
19951 makeApply.tryCatchResolve = tryCatchResolve;
19955 function makeApply(Promise, call) {
19956 if(arguments.length < 2) {
19957 call = tryCatchResolve;
19962 function apply(f, thisArg, args) {
19963 var p = Promise._defer();
19964 var l = args.length;
19965 var params = new Array(l);
19966 callAndResolve({ f:f, thisArg:thisArg, args:args, params:params, i:l-1, call:call }, p._handler);
19971 function callAndResolve(c, h) {
19973 return call(c.f, c.thisArg, c.params, h);
19976 var handler = Promise._handler(c.args[c.i]);
19977 handler.fold(callAndResolveNext, c, void 0, h);
19980 function callAndResolveNext(c, x, h) {
19983 callAndResolve(c, h);
19987 function tryCatchResolve(f, thisArg, args, resolver) {
19989 resolver.resolve(f.apply(thisArg, args));
19991 resolver.reject(e);
19996 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20000 },{}],259:[function(require,module,exports){
20001 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20002 /** @author Brian Cavalier */
20003 /** @author John Hann */
20005 (function(define) { 'use strict';
20006 define(function(require) {
20008 var state = require('../state');
20009 var applier = require('../apply');
20011 return function array(Promise) {
20013 var applyFold = applier(Promise);
20014 var toPromise = Promise.resolve;
20015 var all = Promise.all;
20017 var ar = Array.prototype.reduce;
20018 var arr = Array.prototype.reduceRight;
20019 var slice = Array.prototype.slice;
20021 // Additional array combinators
20024 Promise.some = some;
20025 Promise.settle = settle;
20028 Promise.filter = filter;
20029 Promise.reduce = reduce;
20030 Promise.reduceRight = reduceRight;
20033 * When this promise fulfills with an array, do
20034 * onFulfilled.apply(void 0, array)
20035 * @param {function} onFulfilled function to apply
20036 * @returns {Promise} promise for the result of applying onFulfilled
20038 Promise.prototype.spread = function(onFulfilled) {
20039 return this.then(all).then(function(array) {
20040 return onFulfilled.apply(this, array);
20047 * One-winner competitive race.
20048 * Return a promise that will fulfill when one of the promises
20049 * in the input array fulfills, or will reject when all promises
20051 * @param {array} promises
20052 * @returns {Promise} promise for the first fulfilled value
20054 function any(promises) {
20055 var p = Promise._defer();
20056 var resolver = p._handler;
20057 var l = promises.length>>>0;
20062 for (var h, x, i = 0; i < l; ++i) {
20064 if(x === void 0 && !(i in promises)) {
20069 h = Promise._handler(x);
20070 if(h.state() > 0) {
20071 resolver.become(h);
20072 Promise._visitRemaining(promises, i, h);
20075 h.visit(resolver, handleFulfill, handleReject);
20079 if(pending === 0) {
20080 resolver.reject(new RangeError('any(): array must not be empty'));
20085 function handleFulfill(x) {
20086 /*jshint validthis:true*/
20088 this.resolve(x); // this === resolver
20091 function handleReject(e) {
20092 /*jshint validthis:true*/
20093 if(this.resolved) { // this === resolver
20098 if(--pending === 0) {
20099 this.reject(errors);
20105 * N-winner competitive race
20106 * Return a promise that will fulfill when n input promises have
20107 * fulfilled, or will reject when it becomes impossible for n
20108 * input promises to fulfill (ie when promises.length - n + 1
20110 * @param {array} promises
20111 * @param {number} n
20112 * @returns {Promise} promise for the earliest n fulfillment values
20116 function some(promises, n) {
20117 /*jshint maxcomplexity:7*/
20118 var p = Promise._defer();
20119 var resolver = p._handler;
20124 var l = promises.length>>>0;
20127 var x, i; // reused in both for() loops
20129 // First pass: count actual array items
20130 for(i=0; i<l; ++i) {
20132 if(x === void 0 && !(i in promises)) {
20138 // Compute actual goals
20139 n = Math.max(n, 0);
20140 nReject = (nFulfill - n + 1);
20141 nFulfill = Math.min(n, nFulfill);
20144 resolver.reject(new RangeError('some(): array must contain at least '
20145 + n + ' item(s), but had ' + nFulfill));
20146 } else if(nFulfill === 0) {
20147 resolver.resolve(results);
20150 // Second pass: observe each array item, make progress toward goals
20151 for(i=0; i<l; ++i) {
20153 if(x === void 0 && !(i in promises)) {
20157 Promise._handler(x).visit(resolver, fulfill, reject, resolver.notify);
20162 function fulfill(x) {
20163 /*jshint validthis:true*/
20164 if(this.resolved) { // this === resolver
20169 if(--nFulfill === 0) {
20171 this.resolve(results);
20175 function reject(e) {
20176 /*jshint validthis:true*/
20177 if(this.resolved) { // this === resolver
20182 if(--nReject === 0) {
20184 this.reject(errors);
20190 * Apply f to the value of each promise in a list of promises
20191 * and return a new list containing the results.
20192 * @param {array} promises
20193 * @param {function(x:*, index:Number):*} f mapping function
20194 * @returns {Promise}
20196 function map(promises, f) {
20197 return Promise._traverse(f, promises);
20201 * Filter the provided array of promises using the provided predicate. Input may
20202 * contain promises and values
20203 * @param {Array} promises array of promises and values
20204 * @param {function(x:*, index:Number):boolean} predicate filtering predicate.
20205 * Must return truthy (or promise for truthy) for items to retain.
20206 * @returns {Promise} promise that will fulfill with an array containing all items
20207 * for which predicate returned truthy.
20209 function filter(promises, predicate) {
20210 var a = slice.call(promises);
20211 return Promise._traverse(predicate, a).then(function(keep) {
20212 return filterSync(a, keep);
20216 function filterSync(promises, keep) {
20217 // Safe because we know all promises have fulfilled if we've made it this far
20218 var l = keep.length;
20219 var filtered = new Array(l);
20220 for(var i=0, j=0; i<l; ++i) {
20222 filtered[j++] = Promise._handler(promises[i]).value;
20225 filtered.length = j;
20231 * Return a promise that will always fulfill with an array containing
20232 * the outcome states of all input promises. The returned promise
20233 * will never reject.
20234 * @param {Array} promises
20235 * @returns {Promise} promise for array of settled state descriptors
20237 function settle(promises) {
20238 return all(promises.map(settleOne));
20241 function settleOne(p) {
20242 // Optimize the case where we get an already-resolved when.js promise
20243 // by extracting its state:
20245 if (p instanceof Promise) {
20246 // This is our own Promise type and we can reach its handler internals:
20247 handler = p._handler.join();
20249 if((handler && handler.state() === 0) || !handler) {
20250 // Either still pending, or not a Promise at all:
20251 return toPromise(p).then(state.fulfilled, state.rejected);
20254 // The promise is our own, but it is already resolved. Take a shortcut.
20255 // Since we're not actually handling the resolution, we need to disable
20256 // rejection reporting.
20257 handler._unreport();
20258 return state.inspect(handler);
20262 * Traditional reduce function, similar to `Array.prototype.reduce()`, but
20263 * input may contain promises and/or values, and reduceFunc
20264 * may return either a value or a promise, *and* initialValue may
20265 * be a promise for the starting value.
20266 * @param {Array|Promise} promises array or promise for an array of anything,
20267 * may contain a mix of promises and values.
20268 * @param {function(accumulated:*, x:*, index:Number):*} f reduce function
20269 * @returns {Promise} that will resolve to the final reduced value
20271 function reduce(promises, f /*, initialValue */) {
20272 return arguments.length > 2 ? ar.call(promises, liftCombine(f), arguments[2])
20273 : ar.call(promises, liftCombine(f));
20277 * Traditional reduce function, similar to `Array.prototype.reduceRight()`, but
20278 * input may contain promises and/or values, and reduceFunc
20279 * may return either a value or a promise, *and* initialValue may
20280 * be a promise for the starting value.
20281 * @param {Array|Promise} promises array or promise for an array of anything,
20282 * may contain a mix of promises and values.
20283 * @param {function(accumulated:*, x:*, index:Number):*} f reduce function
20284 * @returns {Promise} that will resolve to the final reduced value
20286 function reduceRight(promises, f /*, initialValue */) {
20287 return arguments.length > 2 ? arr.call(promises, liftCombine(f), arguments[2])
20288 : arr.call(promises, liftCombine(f));
20291 function liftCombine(f) {
20292 return function(z, x, i) {
20293 return applyFold(f, void 0, [z,x,i]);
20299 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
20301 },{"../apply":258,"../state":271}],260:[function(require,module,exports){
20302 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20303 /** @author Brian Cavalier */
20304 /** @author John Hann */
20306 (function(define) { 'use strict';
20307 define(function() {
20309 return function flow(Promise) {
20311 var resolve = Promise.resolve;
20312 var reject = Promise.reject;
20313 var origCatch = Promise.prototype['catch'];
20316 * Handle the ultimate fulfillment value or rejection reason, and assume
20317 * responsibility for all errors. If an error propagates out of result
20318 * or handleFatalError, it will be rethrown to the host, resulting in a
20319 * loud stack track on most platforms and a crash on some.
20320 * @param {function?} onResult
20321 * @param {function?} onError
20322 * @returns {undefined}
20324 Promise.prototype.done = function(onResult, onError) {
20325 this._handler.visit(this._handler.receiver, onResult, onError);
20329 * Add Error-type and predicate matching to catch. Examples:
20330 * promise.catch(TypeError, handleTypeError)
20331 * .catch(predicate, handleMatchedErrors)
20332 * .catch(handleRemainingErrors)
20333 * @param onRejected
20336 Promise.prototype['catch'] = Promise.prototype.otherwise = function(onRejected) {
20337 if (arguments.length < 2) {
20338 return origCatch.call(this, onRejected);
20341 if(typeof onRejected !== 'function') {
20342 return this.ensure(rejectInvalidPredicate);
20345 return origCatch.call(this, createCatchFilter(arguments[1], onRejected));
20349 * Wraps the provided catch handler, so that it will only be called
20350 * if the predicate evaluates truthy
20351 * @param {?function} handler
20352 * @param {function} predicate
20353 * @returns {function} conditional catch handler
20355 function createCatchFilter(handler, predicate) {
20356 return function(e) {
20357 return evaluatePredicate(e, predicate)
20358 ? handler.call(this, e)
20364 * Ensures that onFulfilledOrRejected will be called regardless of whether
20365 * this promise is fulfilled or rejected. onFulfilledOrRejected WILL NOT
20366 * receive the promises' value or reason. Any returned value will be disregarded.
20367 * onFulfilledOrRejected may throw or return a rejected promise to signal
20368 * an additional error.
20369 * @param {function} handler handler to be called regardless of
20370 * fulfillment or rejection
20371 * @returns {Promise}
20373 Promise.prototype['finally'] = Promise.prototype.ensure = function(handler) {
20374 if(typeof handler !== 'function') {
20378 return this.then(function(x) {
20379 return runSideEffect(handler, this, identity, x);
20381 return runSideEffect(handler, this, reject, e);
20385 function runSideEffect (handler, thisArg, propagate, value) {
20386 var result = handler.call(thisArg);
20387 return maybeThenable(result)
20388 ? propagateValue(result, propagate, value)
20389 : propagate(value);
20392 function propagateValue (result, propagate, x) {
20393 return resolve(result).then(function () {
20394 return propagate(x);
20399 * Recover from a failure by returning a defaultValue. If defaultValue
20400 * is a promise, it's fulfillment value will be used. If defaultValue is
20401 * a promise that rejects, the returned promise will reject with the
20403 * @param {*} defaultValue
20404 * @returns {Promise} new promise
20406 Promise.prototype['else'] = Promise.prototype.orElse = function(defaultValue) {
20407 return this.then(void 0, function() {
20408 return defaultValue;
20413 * Shortcut for .then(function() { return value; })
20415 * @return {Promise} a promise that:
20416 * - is fulfilled if value is not a promise, or
20417 * - if value is a promise, will fulfill with its value, or reject
20420 Promise.prototype['yield'] = function(value) {
20421 return this.then(function() {
20427 * Runs a side effect when this promise fulfills, without changing the
20428 * fulfillment value.
20429 * @param {function} onFulfilledSideEffect
20430 * @returns {Promise}
20432 Promise.prototype.tap = function(onFulfilledSideEffect) {
20433 return this.then(onFulfilledSideEffect)['yield'](this);
20439 function rejectInvalidPredicate() {
20440 throw new TypeError('catch predicate must be a function');
20443 function evaluatePredicate(e, predicate) {
20444 return isError(predicate) ? e instanceof predicate : predicate(e);
20447 function isError(predicate) {
20448 return predicate === Error
20449 || (predicate != null && predicate.prototype instanceof Error);
20452 function maybeThenable(x) {
20453 return (typeof x === 'object' || typeof x === 'function') && x !== null;
20456 function identity(x) {
20461 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20463 },{}],261:[function(require,module,exports){
20464 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20465 /** @author Brian Cavalier */
20466 /** @author John Hann */
20467 /** @author Jeff Escalante */
20469 (function(define) { 'use strict';
20470 define(function() {
20472 return function fold(Promise) {
20474 Promise.prototype.fold = function(f, z) {
20475 var promise = this._beget();
20477 this._handler.fold(function(z, x, to) {
20478 Promise._handler(z).fold(function(x, z, to) {
20479 to.resolve(f.call(this, z, x));
20481 }, z, promise._handler.receiver, promise._handler);
20490 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20492 },{}],262:[function(require,module,exports){
20493 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20494 /** @author Brian Cavalier */
20495 /** @author John Hann */
20497 (function(define) { 'use strict';
20498 define(function(require) {
20500 var inspect = require('../state').inspect;
20502 return function inspection(Promise) {
20504 Promise.prototype.inspect = function() {
20505 return inspect(Promise._handler(this));
20512 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
20514 },{"../state":271}],263:[function(require,module,exports){
20515 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20516 /** @author Brian Cavalier */
20517 /** @author John Hann */
20519 (function(define) { 'use strict';
20520 define(function() {
20522 return function generate(Promise) {
20524 var resolve = Promise.resolve;
20526 Promise.iterate = iterate;
20527 Promise.unfold = unfold;
20532 * @deprecated Use github.com/cujojs/most streams and most.iterate
20533 * Generate a (potentially infinite) stream of promised values:
20534 * x, f(x), f(f(x)), etc. until condition(x) returns true
20535 * @param {function} f function to generate a new x from the previous x
20536 * @param {function} condition function that, given the current x, returns
20537 * truthy when the iterate should stop
20538 * @param {function} handler function to handle the value produced by f
20539 * @param {*|Promise} x starting value, may be a promise
20540 * @return {Promise} the result of the last call to f before
20541 * condition returns true
20543 function iterate(f, condition, handler, x) {
20544 return unfold(function(x) {
20546 }, condition, handler, x);
20550 * @deprecated Use github.com/cujojs/most streams and most.unfold
20551 * Generate a (potentially infinite) stream of promised values
20552 * by applying handler(generator(seed)) iteratively until
20553 * condition(seed) returns true.
20554 * @param {function} unspool function that generates a [value, newSeed]
20556 * @param {function} condition function that, given the current seed, returns
20557 * truthy when the unfold should stop
20558 * @param {function} handler function to handle the value produced by unspool
20559 * @param x {*|Promise} starting value, may be a promise
20560 * @return {Promise} the result of the last value produced by unspool before
20561 * condition returns true
20563 function unfold(unspool, condition, handler, x) {
20564 return resolve(x).then(function(seed) {
20565 return resolve(condition(seed)).then(function(done) {
20566 return done ? seed : resolve(unspool(seed)).spread(next);
20570 function next(item, newSeed) {
20571 return resolve(handler(item)).then(function() {
20572 return unfold(unspool, condition, handler, newSeed);
20579 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20581 },{}],264:[function(require,module,exports){
20582 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20583 /** @author Brian Cavalier */
20584 /** @author John Hann */
20586 (function(define) { 'use strict';
20587 define(function() {
20589 return function progress(Promise) {
20593 * Register a progress handler for this promise
20594 * @param {function} onProgress
20595 * @returns {Promise}
20597 Promise.prototype.progress = function(onProgress) {
20598 return this.then(void 0, void 0, onProgress);
20605 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20607 },{}],265:[function(require,module,exports){
20608 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20609 /** @author Brian Cavalier */
20610 /** @author John Hann */
20612 (function(define) { 'use strict';
20613 define(function(require) {
20615 var env = require('../env');
20616 var TimeoutError = require('../TimeoutError');
20618 function setTimeout(f, ms, x, y) {
20619 return env.setTimer(function() {
20624 return function timed(Promise) {
20626 * Return a new promise whose fulfillment value is revealed only
20627 * after ms milliseconds
20628 * @param {number} ms milliseconds
20629 * @returns {Promise}
20631 Promise.prototype.delay = function(ms) {
20632 var p = this._beget();
20633 this._handler.fold(handleDelay, ms, void 0, p._handler);
20637 function handleDelay(ms, x, h) {
20638 setTimeout(resolveDelay, ms, x, h);
20641 function resolveDelay(x, h) {
20646 * Return a new promise that rejects after ms milliseconds unless
20647 * this promise fulfills earlier, in which case the returned promise
20648 * fulfills with the same value.
20649 * @param {number} ms milliseconds
20650 * @param {Error|*=} reason optional rejection reason to use, defaults
20651 * to a TimeoutError if not provided
20652 * @returns {Promise}
20654 Promise.prototype.timeout = function(ms, reason) {
20655 var p = this._beget();
20656 var h = p._handler;
20658 var t = setTimeout(onTimeout, ms, reason, p._handler);
20660 this._handler.visit(h,
20661 function onFulfill(x) {
20663 this.resolve(x); // this = h
20665 function onReject(x) {
20667 this.reject(x); // this = h
20674 function onTimeout(reason, h, ms) {
20675 var e = typeof reason === 'undefined'
20676 ? new TimeoutError('timed out after ' + ms + 'ms')
20685 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
20687 },{"../TimeoutError":257,"../env":268}],266:[function(require,module,exports){
20688 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20689 /** @author Brian Cavalier */
20690 /** @author John Hann */
20692 (function(define) { 'use strict';
20693 define(function(require) {
20695 var setTimer = require('../env').setTimer;
20696 var format = require('../format');
20698 return function unhandledRejection(Promise) {
20700 var logError = noop;
20701 var logInfo = noop;
20704 if(typeof console !== 'undefined') {
20705 // Alias console to prevent things like uglify's drop_console option from
20706 // removing console.log/error. Unhandled rejections fall into the same
20707 // category as uncaught exceptions, and build tools shouldn't silence them.
20708 localConsole = console;
20709 logError = typeof localConsole.error !== 'undefined'
20710 ? function (e) { localConsole.error(e); }
20711 : function (e) { localConsole.log(e); };
20713 logInfo = typeof localConsole.info !== 'undefined'
20714 ? function (e) { localConsole.info(e); }
20715 : function (e) { localConsole.log(e); };
20718 Promise.onPotentiallyUnhandledRejection = function(rejection) {
20719 enqueue(report, rejection);
20722 Promise.onPotentiallyUnhandledRejectionHandled = function(rejection) {
20723 enqueue(unreport, rejection);
20726 Promise.onFatalRejection = function(rejection) {
20727 enqueue(throwit, rejection.value);
20732 var running = null;
20734 function report(r) {
20737 logError('Potentially unhandled rejection [' + r.id + '] ' + format.formatError(r.value));
20741 function unreport(r) {
20742 var i = reported.indexOf(r);
20744 reported.splice(i, 1);
20745 logInfo('Handled previous rejection [' + r.id + '] ' + format.formatObject(r.value));
20749 function enqueue(f, x) {
20751 if(running === null) {
20752 running = setTimer(flush, 0);
20758 while(tasks.length > 0) {
20759 tasks.shift()(tasks.shift());
20766 function throwit(e) {
20773 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
20775 },{"../env":268,"../format":269}],267:[function(require,module,exports){
20776 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20777 /** @author Brian Cavalier */
20778 /** @author John Hann */
20780 (function(define) { 'use strict';
20781 define(function() {
20783 return function addWith(Promise) {
20785 * Returns a promise whose handlers will be called with `this` set to
20786 * the supplied receiver. Subsequent promises derived from the
20787 * returned promise will also have their handlers called with receiver
20788 * as `this`. Calling `with` with undefined or no arguments will return
20789 * a promise whose handlers will again be called in the usual Promises/A+
20790 * way (no `this`) thus safely undoing any previous `with` in the
20793 * WARNING: Promises returned from `with`/`withThis` are NOT Promises/A+
20794 * compliant, specifically violating 2.2.5 (http://promisesaplus.com/#point-41)
20796 * @param {object} receiver `this` value for all handlers attached to
20797 * the returned promise.
20798 * @returns {Promise}
20800 Promise.prototype['with'] = Promise.prototype.withThis = function(receiver) {
20801 var p = this._beget();
20802 var child = p._handler;
20803 child.receiver = receiver;
20804 this._handler.chain(child, receiver);
20812 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20815 },{}],268:[function(require,module,exports){
20816 (function (process){
20817 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20818 /** @author Brian Cavalier */
20819 /** @author John Hann */
20821 /*global process,document,setTimeout,clearTimeout,MutationObserver,WebKitMutationObserver*/
20822 (function(define) { 'use strict';
20823 define(function(require) {
20824 /*jshint maxcomplexity:6*/
20826 // Sniff "best" async scheduling option
20827 // Prefer process.nextTick or MutationObserver, then check for
20828 // setTimeout, and finally vertx, since its the only env that doesn't
20832 var capturedSetTimeout = typeof setTimeout !== 'undefined' && setTimeout;
20835 var setTimer = function(f, ms) { return setTimeout(f, ms); };
20836 var clearTimer = function(t) { return clearTimeout(t); };
20837 var asap = function (f) { return capturedSetTimeout(f, 0); };
20839 // Detect specific env
20840 if (isNode()) { // Node
20841 asap = function (f) { return process.nextTick(f); };
20843 } else if (MutationObs = hasMutationObserver()) { // Modern browser
20844 asap = initMutationObserver(MutationObs);
20846 } else if (!capturedSetTimeout) { // vert.x
20847 var vertxRequire = require;
20848 var vertx = vertxRequire('vertx');
20849 setTimer = function (f, ms) { return vertx.setTimer(ms, f); };
20850 clearTimer = vertx.cancelTimer;
20851 asap = vertx.runOnLoop || vertx.runOnContext;
20855 setTimer: setTimer,
20856 clearTimer: clearTimer,
20860 function isNode () {
20861 return typeof process !== 'undefined' &&
20862 Object.prototype.toString.call(process) === '[object process]';
20865 function hasMutationObserver () {
20866 return (typeof MutationObserver !== 'undefined' && MutationObserver) ||
20867 (typeof WebKitMutationObserver !== 'undefined' && WebKitMutationObserver);
20870 function initMutationObserver(MutationObserver) {
20872 var node = document.createTextNode('');
20873 var o = new MutationObserver(run);
20874 o.observe(node, { characterData: true });
20878 scheduled = void 0;
20883 return function (f) {
20885 node.data = (i ^= 1);
20889 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
20891 }).call(this,require('_process'))
20893 },{"_process":6}],269:[function(require,module,exports){
20894 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20895 /** @author Brian Cavalier */
20896 /** @author John Hann */
20898 (function(define) { 'use strict';
20899 define(function() {
20902 formatError: formatError,
20903 formatObject: formatObject,
20904 tryStringify: tryStringify
20908 * Format an error into a string. If e is an Error and has a stack property,
20909 * it's returned. Otherwise, e is formatted using formatObject, with a
20910 * warning added about e not being a proper Error.
20912 * @returns {String} formatted string, suitable for output to developers
20914 function formatError(e) {
20915 var s = typeof e === 'object' && e !== null && (e.stack || e.message) ? e.stack || e.message : formatObject(e);
20916 return e instanceof Error ? s : s + ' (WARNING: non-Error used)';
20920 * Format an object, detecting "plain" objects and running them through
20921 * JSON.stringify if possible.
20922 * @param {Object} o
20923 * @returns {string}
20925 function formatObject(o) {
20927 if(s === '[object Object]' && typeof JSON !== 'undefined') {
20928 s = tryStringify(o, s);
20934 * Try to return the result of JSON.stringify(x). If that fails, return
20937 * @param {*} defaultValue
20938 * @returns {String|*} JSON.stringify(x) or defaultValue
20940 function tryStringify(x, defaultValue) {
20942 return JSON.stringify(x);
20944 return defaultValue;
20949 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20951 },{}],270:[function(require,module,exports){
20952 (function (process){
20953 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20954 /** @author Brian Cavalier */
20955 /** @author John Hann */
20957 (function(define) { 'use strict';
20958 define(function() {
20960 return function makePromise(environment) {
20962 var tasks = environment.scheduler;
20963 var emitRejection = initEmitRejection();
20965 var objectCreate = Object.create ||
20967 function Child() {}
20968 Child.prototype = proto;
20969 return new Child();
20973 * Create a promise whose fate is determined by resolver
20975 * @returns {Promise} promise
20978 function Promise(resolver, handler) {
20979 this._handler = resolver === Handler ? handler : init(resolver);
20983 * Run the supplied resolver
20985 * @returns {Pending}
20987 function init(resolver) {
20988 var handler = new Pending();
20991 resolver(promiseResolve, promiseReject, promiseNotify);
20999 * Transition from pre-resolution state to post-resolution state, notifying
21000 * all listeners of the ultimate fulfillment or rejection
21001 * @param {*} x resolution value
21003 function promiseResolve (x) {
21004 handler.resolve(x);
21007 * Reject this promise with reason, which will be used verbatim
21008 * @param {Error|*} reason rejection reason, strongly suggested
21009 * to be an Error type
21011 function promiseReject (reason) {
21012 handler.reject(reason);
21017 * Issue a progress event, notifying all progress listeners
21018 * @param {*} x progress event payload to pass to all listeners
21020 function promiseNotify (x) {
21027 Promise.resolve = resolve;
21028 Promise.reject = reject;
21029 Promise.never = never;
21031 Promise._defer = defer;
21032 Promise._handler = getHandler;
21035 * Returns a trusted promise. If x is already a trusted promise, it is
21036 * returned, otherwise returns a new trusted Promise which follows x.
21038 * @return {Promise} promise
21040 function resolve(x) {
21041 return isPromise(x) ? x
21042 : new Promise(Handler, new Async(getHandler(x)));
21046 * Return a reject promise with x as its reason (x is used verbatim)
21048 * @returns {Promise} rejected promise
21050 function reject(x) {
21051 return new Promise(Handler, new Async(new Rejected(x)));
21055 * Return a promise that remains pending forever
21056 * @returns {Promise} forever-pending promise.
21059 return foreverPendingPromise; // Should be frozen
21063 * Creates an internal {promise, resolver} pair
21065 * @returns {Promise}
21068 return new Promise(Handler, new Pending());
21071 // Transformation and flow control
21074 * Transform this promise's fulfillment value, returning a new Promise
21075 * for the transformed result. If the promise cannot be fulfilled, onRejected
21076 * is called with the reason. onProgress *may* be called with updates toward
21077 * this promise's fulfillment.
21078 * @param {function=} onFulfilled fulfillment handler
21079 * @param {function=} onRejected rejection handler
21080 * @param {function=} onProgress @deprecated progress handler
21081 * @return {Promise} new promise
21083 Promise.prototype.then = function(onFulfilled, onRejected, onProgress) {
21084 var parent = this._handler;
21085 var state = parent.join().state();
21087 if ((typeof onFulfilled !== 'function' && state > 0) ||
21088 (typeof onRejected !== 'function' && state < 0)) {
21089 // Short circuit: value will not change, simply share handler
21090 return new this.constructor(Handler, parent);
21093 var p = this._beget();
21094 var child = p._handler;
21096 parent.chain(child, parent.receiver, onFulfilled, onRejected, onProgress);
21102 * If this promise cannot be fulfilled due to an error, call onRejected to
21103 * handle the error. Shortcut for .then(undefined, onRejected)
21104 * @param {function?} onRejected
21105 * @return {Promise}
21107 Promise.prototype['catch'] = function(onRejected) {
21108 return this.then(void 0, onRejected);
21112 * Creates a new, pending promise of the same type as this promise
21114 * @returns {Promise}
21116 Promise.prototype._beget = function() {
21117 return begetFrom(this._handler, this.constructor);
21120 function begetFrom(parent, Promise) {
21121 var child = new Pending(parent.receiver, parent.join().context);
21122 return new Promise(Handler, child);
21125 // Array combinators
21128 Promise.race = race;
21129 Promise._traverse = traverse;
21132 * Return a promise that will fulfill when all promises in the
21133 * input array have fulfilled, or will reject when one of the
21134 * promises rejects.
21135 * @param {array} promises array of promises
21136 * @returns {Promise} promise for array of fulfillment values
21138 function all(promises) {
21139 return traverseWith(snd, null, promises);
21143 * Array<Promise<X>> -> Promise<Array<f(X)>>
21145 * @param {function} f function to apply to each promise's value
21146 * @param {Array} promises array of promises
21147 * @returns {Promise} promise for transformed values
21149 function traverse(f, promises) {
21150 return traverseWith(tryCatch2, f, promises);
21153 function traverseWith(tryMap, f, promises) {
21154 var handler = typeof f === 'function' ? mapAt : settleAt;
21156 var resolver = new Pending();
21157 var pending = promises.length >>> 0;
21158 var results = new Array(pending);
21160 for (var i = 0, x; i < promises.length && !resolver.resolved; ++i) {
21163 if (x === void 0 && !(i in promises)) {
21168 traverseAt(promises, handler, i, x, resolver);
21171 if(pending === 0) {
21172 resolver.become(new Fulfilled(results));
21175 return new Promise(Handler, resolver);
21177 function mapAt(i, x, resolver) {
21178 if(!resolver.resolved) {
21179 traverseAt(promises, settleAt, i, tryMap(f, x, i), resolver);
21183 function settleAt(i, x, resolver) {
21185 if(--pending === 0) {
21186 resolver.become(new Fulfilled(results));
21191 function traverseAt(promises, handler, i, x, resolver) {
21192 if (maybeThenable(x)) {
21193 var h = getHandlerMaybeThenable(x);
21197 h.fold(handler, i, void 0, resolver);
21198 } else if (s > 0) {
21199 handler(i, h.value, resolver);
21201 resolver.become(h);
21202 visitRemaining(promises, i+1, h);
21205 handler(i, x, resolver);
21209 Promise._visitRemaining = visitRemaining;
21210 function visitRemaining(promises, start, handler) {
21211 for(var i=start; i<promises.length; ++i) {
21212 markAsHandled(getHandler(promises[i]), handler);
21216 function markAsHandled(h, handler) {
21217 if(h === handler) {
21223 h.visit(h, void 0, h._unreport);
21230 * Fulfill-reject competitive race. Return a promise that will settle
21231 * to the same state as the earliest input promise to settle.
21233 * WARNING: The ES6 Promise spec requires that race()ing an empty array
21234 * must return a promise that is pending forever. This implementation
21235 * returns a singleton forever-pending promise, the same singleton that is
21236 * returned by Promise.never(), thus can be checked with ===
21238 * @param {array} promises array of promises to race
21239 * @returns {Promise} if input is non-empty, a promise that will settle
21240 * to the same outcome as the earliest input promise to settle. if empty
21241 * is empty, returns a promise that will never settle.
21243 function race(promises) {
21244 if(typeof promises !== 'object' || promises === null) {
21245 return reject(new TypeError('non-iterable passed to race()'));
21248 // Sigh, race([]) is untestable unless we return *something*
21249 // that is recognizable without calling .then() on it.
21250 return promises.length === 0 ? never()
21251 : promises.length === 1 ? resolve(promises[0])
21252 : runRace(promises);
21255 function runRace(promises) {
21256 var resolver = new Pending();
21258 for(i=0; i<promises.length; ++i) {
21260 if (x === void 0 && !(i in promises)) {
21265 if(h.state() !== 0) {
21266 resolver.become(h);
21267 visitRemaining(promises, i+1, h);
21270 h.visit(resolver, resolver.resolve, resolver.reject);
21273 return new Promise(Handler, resolver);
21276 // Promise internals
21277 // Below this, everything is @private
21280 * Get an appropriate handler for x, without checking for cycles
21282 * @returns {object} handler
21284 function getHandler(x) {
21286 return x._handler.join();
21288 return maybeThenable(x) ? getHandlerUntrusted(x) : new Fulfilled(x);
21292 * Get a handler for thenable x.
21293 * NOTE: You must only call this if maybeThenable(x) == true
21294 * @param {object|function|Promise} x
21295 * @returns {object} handler
21297 function getHandlerMaybeThenable(x) {
21298 return isPromise(x) ? x._handler.join() : getHandlerUntrusted(x);
21302 * Get a handler for potentially untrusted thenable x
21304 * @returns {object} handler
21306 function getHandlerUntrusted(x) {
21308 var untrustedThen = x.then;
21309 return typeof untrustedThen === 'function'
21310 ? new Thenable(untrustedThen, x)
21311 : new Fulfilled(x);
21313 return new Rejected(e);
21318 * Handler for a promise that is pending forever
21321 function Handler() {}
21323 Handler.prototype.when
21324 = Handler.prototype.become
21325 = Handler.prototype.notify // deprecated
21326 = Handler.prototype.fail
21327 = Handler.prototype._unreport
21328 = Handler.prototype._report
21331 Handler.prototype._state = 0;
21333 Handler.prototype.state = function() {
21334 return this._state;
21338 * Recursively collapse handler chain to find the handler
21339 * nearest to the fully resolved value.
21340 * @returns {object} handler nearest the fully resolved value
21342 Handler.prototype.join = function() {
21344 while(h.handler !== void 0) {
21350 Handler.prototype.chain = function(to, receiver, fulfilled, rejected, progress) {
21353 receiver: receiver,
21354 fulfilled: fulfilled,
21355 rejected: rejected,
21360 Handler.prototype.visit = function(receiver, fulfilled, rejected, progress) {
21361 this.chain(failIfRejected, receiver, fulfilled, rejected, progress);
21364 Handler.prototype.fold = function(f, z, c, to) {
21365 this.when(new Fold(f, z, c, to));
21369 * Handler that invokes fail() on any handler it becomes
21372 function FailIfRejected() {}
21374 inherit(Handler, FailIfRejected);
21376 FailIfRejected.prototype.become = function(h) {
21380 var failIfRejected = new FailIfRejected();
21383 * Handler that manages a queue of consumers waiting on a pending promise
21386 function Pending(receiver, inheritedContext) {
21387 Promise.createContext(this, inheritedContext);
21389 this.consumers = void 0;
21390 this.receiver = receiver;
21391 this.handler = void 0;
21392 this.resolved = false;
21395 inherit(Handler, Pending);
21397 Pending.prototype._state = 0;
21399 Pending.prototype.resolve = function(x) {
21400 this.become(getHandler(x));
21403 Pending.prototype.reject = function(x) {
21404 if(this.resolved) {
21408 this.become(new Rejected(x));
21411 Pending.prototype.join = function() {
21412 if (!this.resolved) {
21418 while (h.handler !== void 0) {
21421 return this.handler = cycle();
21428 Pending.prototype.run = function() {
21429 var q = this.consumers;
21430 var handler = this.handler;
21431 this.handler = this.handler.join();
21432 this.consumers = void 0;
21434 for (var i = 0; i < q.length; ++i) {
21435 handler.when(q[i]);
21439 Pending.prototype.become = function(handler) {
21440 if(this.resolved) {
21444 this.resolved = true;
21445 this.handler = handler;
21446 if(this.consumers !== void 0) {
21447 tasks.enqueue(this);
21450 if(this.context !== void 0) {
21451 handler._report(this.context);
21455 Pending.prototype.when = function(continuation) {
21456 if(this.resolved) {
21457 tasks.enqueue(new ContinuationTask(continuation, this.handler));
21459 if(this.consumers === void 0) {
21460 this.consumers = [continuation];
21462 this.consumers.push(continuation);
21470 Pending.prototype.notify = function(x) {
21471 if(!this.resolved) {
21472 tasks.enqueue(new ProgressTask(x, this));
21476 Pending.prototype.fail = function(context) {
21477 var c = typeof context === 'undefined' ? this.context : context;
21478 this.resolved && this.handler.join().fail(c);
21481 Pending.prototype._report = function(context) {
21482 this.resolved && this.handler.join()._report(context);
21485 Pending.prototype._unreport = function() {
21486 this.resolved && this.handler.join()._unreport();
21490 * Wrap another handler and force it into a future stack
21491 * @param {object} handler
21494 function Async(handler) {
21495 this.handler = handler;
21498 inherit(Handler, Async);
21500 Async.prototype.when = function(continuation) {
21501 tasks.enqueue(new ContinuationTask(continuation, this));
21504 Async.prototype._report = function(context) {
21505 this.join()._report(context);
21508 Async.prototype._unreport = function() {
21509 this.join()._unreport();
21513 * Handler that wraps an untrusted thenable and assimilates it in a future stack
21514 * @param {function} then
21515 * @param {{then: function}} thenable
21518 function Thenable(then, thenable) {
21519 Pending.call(this);
21520 tasks.enqueue(new AssimilateTask(then, thenable, this));
21523 inherit(Pending, Thenable);
21526 * Handler for a fulfilled promise
21527 * @param {*} x fulfillment value
21530 function Fulfilled(x) {
21531 Promise.createContext(this);
21535 inherit(Handler, Fulfilled);
21537 Fulfilled.prototype._state = 1;
21539 Fulfilled.prototype.fold = function(f, z, c, to) {
21540 runContinuation3(f, z, this, c, to);
21543 Fulfilled.prototype.when = function(cont) {
21544 runContinuation1(cont.fulfilled, this, cont.receiver, cont.resolver);
21550 * Handler for a rejected promise
21551 * @param {*} x rejection reason
21554 function Rejected(x) {
21555 Promise.createContext(this);
21557 this.id = ++errorId;
21559 this.handled = false;
21560 this.reported = false;
21565 inherit(Handler, Rejected);
21567 Rejected.prototype._state = -1;
21569 Rejected.prototype.fold = function(f, z, c, to) {
21573 Rejected.prototype.when = function(cont) {
21574 if(typeof cont.rejected === 'function') {
21577 runContinuation1(cont.rejected, this, cont.receiver, cont.resolver);
21580 Rejected.prototype._report = function(context) {
21581 tasks.afterQueue(new ReportTask(this, context));
21584 Rejected.prototype._unreport = function() {
21588 this.handled = true;
21589 tasks.afterQueue(new UnreportTask(this));
21592 Rejected.prototype.fail = function(context) {
21593 this.reported = true;
21594 emitRejection('unhandledRejection', this);
21595 Promise.onFatalRejection(this, context === void 0 ? this.context : context);
21598 function ReportTask(rejection, context) {
21599 this.rejection = rejection;
21600 this.context = context;
21603 ReportTask.prototype.run = function() {
21604 if(!this.rejection.handled && !this.rejection.reported) {
21605 this.rejection.reported = true;
21606 emitRejection('unhandledRejection', this.rejection) ||
21607 Promise.onPotentiallyUnhandledRejection(this.rejection, this.context);
21611 function UnreportTask(rejection) {
21612 this.rejection = rejection;
21615 UnreportTask.prototype.run = function() {
21616 if(this.rejection.reported) {
21617 emitRejection('rejectionHandled', this.rejection) ||
21618 Promise.onPotentiallyUnhandledRejectionHandled(this.rejection);
21622 // Unhandled rejection hooks
21623 // By default, everything is a noop
21625 Promise.createContext
21626 = Promise.enterContext
21627 = Promise.exitContext
21628 = Promise.onPotentiallyUnhandledRejection
21629 = Promise.onPotentiallyUnhandledRejectionHandled
21630 = Promise.onFatalRejection
21633 // Errors and singletons
21635 var foreverPendingHandler = new Handler();
21636 var foreverPendingPromise = new Promise(Handler, foreverPendingHandler);
21639 return new Rejected(new TypeError('Promise cycle'));
21645 * Run a single consumer
21648 function ContinuationTask(continuation, handler) {
21649 this.continuation = continuation;
21650 this.handler = handler;
21653 ContinuationTask.prototype.run = function() {
21654 this.handler.join().when(this.continuation);
21658 * Run a queue of progress handlers
21661 function ProgressTask(value, handler) {
21662 this.handler = handler;
21663 this.value = value;
21666 ProgressTask.prototype.run = function() {
21667 var q = this.handler.consumers;
21672 for (var c, i = 0; i < q.length; ++i) {
21674 runNotify(c.progress, this.value, this.handler, c.receiver, c.resolver);
21679 * Assimilate a thenable, sending it's value to resolver
21680 * @param {function} then
21681 * @param {object|function} thenable
21682 * @param {object} resolver
21685 function AssimilateTask(then, thenable, resolver) {
21687 this.thenable = thenable;
21688 this.resolver = resolver;
21691 AssimilateTask.prototype.run = function() {
21692 var h = this.resolver;
21693 tryAssimilate(this._then, this.thenable, _resolve, _reject, _notify);
21695 function _resolve(x) { h.resolve(x); }
21696 function _reject(x) { h.reject(x); }
21697 function _notify(x) { h.notify(x); }
21700 function tryAssimilate(then, thenable, resolve, reject, notify) {
21702 then.call(thenable, resolve, reject, notify);
21709 * Fold a handler value with z
21712 function Fold(f, z, c, to) {
21713 this.f = f; this.z = z; this.c = c; this.to = to;
21714 this.resolver = failIfRejected;
21715 this.receiver = this;
21718 Fold.prototype.fulfilled = function(x) {
21719 this.f.call(this.c, this.z, x, this.to);
21722 Fold.prototype.rejected = function(x) {
21726 Fold.prototype.progress = function(x) {
21734 * @returns {boolean} true iff x is a trusted Promise
21736 function isPromise(x) {
21737 return x instanceof Promise;
21741 * Test just enough to rule out primitives, in order to take faster
21742 * paths in some code
21744 * @returns {boolean} false iff x is guaranteed *not* to be a thenable
21746 function maybeThenable(x) {
21747 return (typeof x === 'object' || typeof x === 'function') && x !== null;
21750 function runContinuation1(f, h, receiver, next) {
21751 if(typeof f !== 'function') {
21752 return next.become(h);
21755 Promise.enterContext(h);
21756 tryCatchReject(f, h.value, receiver, next);
21757 Promise.exitContext();
21760 function runContinuation3(f, x, h, receiver, next) {
21761 if(typeof f !== 'function') {
21762 return next.become(h);
21765 Promise.enterContext(h);
21766 tryCatchReject3(f, x, h.value, receiver, next);
21767 Promise.exitContext();
21773 function runNotify(f, x, h, receiver, next) {
21774 if(typeof f !== 'function') {
21775 return next.notify(x);
21778 Promise.enterContext(h);
21779 tryCatchReturn(f, x, receiver, next);
21780 Promise.exitContext();
21783 function tryCatch2(f, a, b) {
21792 * Return f.call(thisArg, x), or if it throws return a rejected promise for
21793 * the thrown exception
21795 function tryCatchReject(f, x, thisArg, next) {
21797 next.become(getHandler(f.call(thisArg, x)));
21799 next.become(new Rejected(e));
21804 * Same as above, but includes the extra argument parameter.
21806 function tryCatchReject3(f, x, y, thisArg, next) {
21808 f.call(thisArg, x, y, next);
21810 next.become(new Rejected(e));
21816 * Return f.call(thisArg, x), or if it throws, *return* the exception
21818 function tryCatchReturn(f, x, thisArg, next) {
21820 next.notify(f.call(thisArg, x));
21826 function inherit(Parent, Child) {
21827 Child.prototype = objectCreate(Parent.prototype);
21828 Child.prototype.constructor = Child;
21831 function snd(x, y) {
21837 function hasCustomEvent() {
21838 if(typeof CustomEvent === 'function') {
21840 var ev = new CustomEvent('unhandledRejection');
21841 return ev instanceof CustomEvent;
21842 } catch (ignoredException) {}
21847 function hasInternetExplorerCustomEvent() {
21848 if(typeof document !== 'undefined' && typeof document.createEvent === 'function') {
21850 // Try to create one event to make sure it's supported
21851 var ev = document.createEvent('CustomEvent');
21852 ev.initCustomEvent('eventType', false, true, {});
21854 } catch (ignoredException) {}
21859 function initEmitRejection() {
21860 /*global process, self, CustomEvent*/
21861 if(typeof process !== 'undefined' && process !== null
21862 && typeof process.emit === 'function') {
21863 // Returning falsy here means to call the default
21864 // onPotentiallyUnhandledRejection API. This is safe even in
21865 // browserify since process.emit always returns falsy in browserify:
21866 // https://github.com/defunctzombie/node-process/blob/master/browser.js#L40-L46
21867 return function(type, rejection) {
21868 return type === 'unhandledRejection'
21869 ? process.emit(type, rejection.value, rejection)
21870 : process.emit(type, rejection);
21872 } else if(typeof self !== 'undefined' && hasCustomEvent()) {
21873 return (function (self, CustomEvent) {
21874 return function (type, rejection) {
21875 var ev = new CustomEvent(type, {
21877 reason: rejection.value,
21884 return !self.dispatchEvent(ev);
21886 }(self, CustomEvent));
21887 } else if(typeof self !== 'undefined' && hasInternetExplorerCustomEvent()) {
21888 return (function(self, document) {
21889 return function(type, rejection) {
21890 var ev = document.createEvent('CustomEvent');
21891 ev.initCustomEvent(type, false, true, {
21892 reason: rejection.value,
21896 return !self.dispatchEvent(ev);
21898 }(self, document));
21907 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
21909 }).call(this,require('_process'))
21911 },{"_process":6}],271:[function(require,module,exports){
21912 /** @license MIT License (c) copyright 2010-2014 original author or authors */
21913 /** @author Brian Cavalier */
21914 /** @author John Hann */
21916 (function(define) { 'use strict';
21917 define(function() {
21920 pending: toPendingState,
21921 fulfilled: toFulfilledState,
21922 rejected: toRejectedState,
21926 function toPendingState() {
21927 return { state: 'pending' };
21930 function toRejectedState(e) {
21931 return { state: 'rejected', reason: e };
21934 function toFulfilledState(x) {
21935 return { state: 'fulfilled', value: x };
21938 function inspect(handler) {
21939 var state = handler.state();
21940 return state === 0 ? toPendingState()
21941 : state > 0 ? toFulfilledState(handler.value)
21942 : toRejectedState(handler.value);
21946 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
21948 },{}],272:[function(require,module,exports){
21949 /** @license MIT License (c) copyright 2010-2014 original author or authors */
21952 * Promises/A+ and when() implementation
21953 * when is part of the cujoJS family of libraries (http://cujojs.com/)
21954 * @author Brian Cavalier
21955 * @author John Hann
21957 (function(define) { 'use strict';
21958 define(function (require) {
21960 var timed = require('./lib/decorators/timed');
21961 var array = require('./lib/decorators/array');
21962 var flow = require('./lib/decorators/flow');
21963 var fold = require('./lib/decorators/fold');
21964 var inspect = require('./lib/decorators/inspect');
21965 var generate = require('./lib/decorators/iterate');
21966 var progress = require('./lib/decorators/progress');
21967 var withThis = require('./lib/decorators/with');
21968 var unhandledRejection = require('./lib/decorators/unhandledRejection');
21969 var TimeoutError = require('./lib/TimeoutError');
21971 var Promise = [array, flow, fold, generate, progress,
21972 inspect, withThis, timed, unhandledRejection]
21973 .reduce(function(Promise, feature) {
21974 return feature(Promise);
21975 }, require('./lib/Promise'));
21977 var apply = require('./lib/apply')(Promise);
21981 when.promise = promise; // Create a pending promise
21982 when.resolve = Promise.resolve; // Create a resolved promise
21983 when.reject = Promise.reject; // Create a rejected promise
21985 when.lift = lift; // lift a function to return promises
21986 when['try'] = attempt; // call a function and return a promise
21987 when.attempt = attempt; // alias for when.try
21989 when.iterate = Promise.iterate; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
21990 when.unfold = Promise.unfold; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
21992 when.join = join; // Join 2 or more promises
21994 when.all = all; // Resolve a list of promises
21995 when.settle = settle; // Settle a list of promises
21997 when.any = lift(Promise.any); // One-winner race
21998 when.some = lift(Promise.some); // Multi-winner race
21999 when.race = lift(Promise.race); // First-to-settle race
22001 when.map = map; // Array.map() for promises
22002 when.filter = filter; // Array.filter() for promises
22003 when.reduce = lift(Promise.reduce); // Array.reduce() for promises
22004 when.reduceRight = lift(Promise.reduceRight); // Array.reduceRight() for promises
22006 when.isPromiseLike = isPromiseLike; // Is something promise-like, aka thenable
22008 when.Promise = Promise; // Promise constructor
22009 when.defer = defer; // Create a {promise, resolve, reject} tuple
22013 when.TimeoutError = TimeoutError;
22016 * Get a trusted promise for x, or by transforming x with onFulfilled
22019 * @param {function?} onFulfilled callback to be called when x is
22020 * successfully fulfilled. If promiseOrValue is an immediate value, callback
22021 * will be invoked immediately.
22022 * @param {function?} onRejected callback to be called when x is
22024 * @param {function?} onProgress callback to be called when progress updates
22025 * are issued for x. @deprecated
22026 * @returns {Promise} a new promise that will fulfill with the return
22027 * value of callback or errback or the completion value of promiseOrValue if
22028 * callback and/or errback is not supplied.
22030 function when(x, onFulfilled, onRejected, onProgress) {
22031 var p = Promise.resolve(x);
22032 if (arguments.length < 2) {
22036 return p.then(onFulfilled, onRejected, onProgress);
22040 * Creates a new promise whose fate is determined by resolver.
22041 * @param {function} resolver function(resolve, reject, notify)
22042 * @returns {Promise} promise whose fate is determine by resolver
22044 function promise(resolver) {
22045 return new Promise(resolver);
22049 * Lift the supplied function, creating a version of f that returns
22050 * promises, and accepts promises as arguments.
22051 * @param {function} f
22052 * @returns {Function} version of f that returns promises
22055 return function() {
22056 for(var i=0, l=arguments.length, a=new Array(l); i<l; ++i) {
22057 a[i] = arguments[i];
22059 return apply(f, this, a);
22064 * Call f in a future turn, with the supplied args, and return a promise
22066 * @param {function} f
22067 * @returns {Promise}
22069 function attempt(f /*, args... */) {
22070 /*jshint validthis:true */
22071 for(var i=0, l=arguments.length-1, a=new Array(l); i<l; ++i) {
22072 a[i] = arguments[i+1];
22074 return apply(f, this, a);
22078 * Creates a {promise, resolver} pair, either or both of which
22079 * may be given out safely to consumers.
22080 * @return {{promise: Promise, resolve: function, reject: function, notify: function}}
22083 return new Deferred();
22086 function Deferred() {
22087 var p = Promise._defer();
22089 function resolve(x) { p._handler.resolve(x); }
22090 function reject(x) { p._handler.reject(x); }
22091 function notify(x) { p._handler.notify(x); }
22094 this.resolve = resolve;
22095 this.reject = reject;
22096 this.notify = notify;
22097 this.resolver = { resolve: resolve, reject: reject, notify: notify };
22101 * Determines if x is promise-like, i.e. a thenable object
22102 * NOTE: Will return true for *any thenable object*, and isn't truly
22103 * safe, since it may attempt to access the `then` property of x (i.e.
22104 * clever/malicious getters may do weird things)
22105 * @param {*} x anything
22106 * @returns {boolean} true if x is promise-like
22108 function isPromiseLike(x) {
22109 return x && typeof x.then === 'function';
22113 * Return a promise that will resolve only once all the supplied arguments
22114 * have resolved. The resolution value of the returned promise will be an array
22115 * containing the resolution values of each of the arguments.
22116 * @param {...*} arguments may be a mix of promises and values
22117 * @returns {Promise}
22119 function join(/* ...promises */) {
22120 return Promise.all(arguments);
22124 * Return a promise that will fulfill once all input promises have
22125 * fulfilled, or reject when any one input promise rejects.
22126 * @param {array|Promise} promises array (or promise for an array) of promises
22127 * @returns {Promise}
22129 function all(promises) {
22130 return when(promises, Promise.all);
22134 * Return a promise that will always fulfill with an array containing
22135 * the outcome states of all input promises. The returned promise
22136 * will only reject if `promises` itself is a rejected promise.
22137 * @param {array|Promise} promises array (or promise for an array) of promises
22138 * @returns {Promise} promise for array of settled state descriptors
22140 function settle(promises) {
22141 return when(promises, Promise.settle);
22145 * Promise-aware array map function, similar to `Array.prototype.map()`,
22146 * but input array may contain promises or values.
22147 * @param {Array|Promise} promises array of anything, may contain promises and values
22148 * @param {function(x:*, index:Number):*} mapFunc map function which may
22149 * return a promise or value
22150 * @returns {Promise} promise that will fulfill with an array of mapped values
22151 * or reject if any input promise rejects.
22153 function map(promises, mapFunc) {
22154 return when(promises, function(promises) {
22155 return Promise.map(promises, mapFunc);
22160 * Filter the provided array of promises using the provided predicate. Input may
22161 * contain promises and values
22162 * @param {Array|Promise} promises array of promises and values
22163 * @param {function(x:*, index:Number):boolean} predicate filtering predicate.
22164 * Must return truthy (or promise for truthy) for items to retain.
22165 * @returns {Promise} promise that will fulfill with an array containing all items
22166 * for which predicate returned truthy.
22168 function filter(promises, predicate) {
22169 return when(promises, function(promises) {
22170 return Promise.filter(promises, predicate);
22176 })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
22178 },{"./lib/Promise":255,"./lib/TimeoutError":257,"./lib/apply":258,"./lib/decorators/array":259,"./lib/decorators/flow":260,"./lib/decorators/fold":261,"./lib/decorators/inspect":262,"./lib/decorators/iterate":263,"./lib/decorators/progress":264,"./lib/decorators/timed":265,"./lib/decorators/unhandledRejection":266,"./lib/decorators/with":267}],273:[function(require,module,exports){
22179 var nativeIsArray = Array.isArray
22180 var toString = Object.prototype.toString
22182 module.exports = nativeIsArray || isArray
22184 function isArray(obj) {
22185 return toString.call(obj) === "[object Array]"
22188 },{}],274:[function(require,module,exports){
22190 Object.defineProperty(exports, "__esModule", { value: true });
22191 var APIv3_1 = require("./api/APIv3");
22192 exports.APIv3 = APIv3_1.APIv3;
22193 var ModelCreator_1 = require("./api/ModelCreator");
22194 exports.ModelCreator = ModelCreator_1.ModelCreator;
22196 },{"./api/APIv3":287,"./api/ModelCreator":288}],275:[function(require,module,exports){
22198 function __export(m) {
22199 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
22201 Object.defineProperty(exports, "__esModule", { value: true });
22202 var Component_1 = require("./component/Component");
22203 exports.Component = Component_1.Component;
22204 var ComponentService_1 = require("./component/ComponentService");
22205 exports.ComponentService = ComponentService_1.ComponentService;
22206 var HandlerBase_1 = require("./component/utils/HandlerBase");
22207 exports.HandlerBase = HandlerBase_1.HandlerBase;
22208 var MeshFactory_1 = require("./component/utils/MeshFactory");
22209 exports.MeshFactory = MeshFactory_1.MeshFactory;
22210 var MeshScene_1 = require("./component/utils/MeshScene");
22211 exports.MeshScene = MeshScene_1.MeshScene;
22212 var MouseOperator_1 = require("./component/utils/MouseOperator");
22213 exports.MouseOperator = MouseOperator_1.MouseOperator;
22214 var AttributionComponent_1 = require("./component/AttributionComponent");
22215 exports.AttributionComponent = AttributionComponent_1.AttributionComponent;
22216 var BackgroundComponent_1 = require("./component/BackgroundComponent");
22217 exports.BackgroundComponent = BackgroundComponent_1.BackgroundComponent;
22218 var BearingComponent_1 = require("./component/BearingComponent");
22219 exports.BearingComponent = BearingComponent_1.BearingComponent;
22220 var CacheComponent_1 = require("./component/CacheComponent");
22221 exports.CacheComponent = CacheComponent_1.CacheComponent;
22222 var CoverComponent_1 = require("./component/CoverComponent");
22223 exports.CoverComponent = CoverComponent_1.CoverComponent;
22224 var DebugComponent_1 = require("./component/DebugComponent");
22225 exports.DebugComponent = DebugComponent_1.DebugComponent;
22226 var DirectionComponent_1 = require("./component/direction/DirectionComponent");
22227 exports.DirectionComponent = DirectionComponent_1.DirectionComponent;
22228 var DirectionDOMCalculator_1 = require("./component/direction/DirectionDOMCalculator");
22229 exports.DirectionDOMCalculator = DirectionDOMCalculator_1.DirectionDOMCalculator;
22230 var DirectionDOMRenderer_1 = require("./component/direction/DirectionDOMRenderer");
22231 exports.DirectionDOMRenderer = DirectionDOMRenderer_1.DirectionDOMRenderer;
22232 var ImageComponent_1 = require("./component/ImageComponent");
22233 exports.ImageComponent = ImageComponent_1.ImageComponent;
22234 var KeyboardComponent_1 = require("./component/keyboard/KeyboardComponent");
22235 exports.KeyboardComponent = KeyboardComponent_1.KeyboardComponent;
22236 var KeyPlayHandler_1 = require("./component/keyboard/KeyPlayHandler");
22237 exports.KeyPlayHandler = KeyPlayHandler_1.KeyPlayHandler;
22238 var KeyZoomHandler_1 = require("./component/keyboard/KeyZoomHandler");
22239 exports.KeyZoomHandler = KeyZoomHandler_1.KeyZoomHandler;
22240 var KeySequenceNavigationHandler_1 = require("./component/keyboard/KeySequenceNavigationHandler");
22241 exports.KeySequenceNavigationHandler = KeySequenceNavigationHandler_1.KeySequenceNavigationHandler;
22242 var KeySpatialNavigationHandler_1 = require("./component/keyboard/KeySpatialNavigationHandler");
22243 exports.KeySpatialNavigationHandler = KeySpatialNavigationHandler_1.KeySpatialNavigationHandler;
22244 var LoadingComponent_1 = require("./component/LoadingComponent");
22245 exports.LoadingComponent = LoadingComponent_1.LoadingComponent;
22246 var Marker_1 = require("./component/marker/marker/Marker");
22247 exports.Marker = Marker_1.Marker;
22248 var MarkerComponent_1 = require("./component/marker/MarkerComponent");
22249 exports.MarkerComponent = MarkerComponent_1.MarkerComponent;
22250 var MarkerScene_1 = require("./component/marker/MarkerScene");
22251 exports.MarkerScene = MarkerScene_1.MarkerScene;
22252 var MarkerSet_1 = require("./component/marker/MarkerSet");
22253 exports.MarkerSet = MarkerSet_1.MarkerSet;
22254 var MouseComponent_1 = require("./component/mouse/MouseComponent");
22255 exports.MouseComponent = MouseComponent_1.MouseComponent;
22256 var BounceHandler_1 = require("./component/mouse/BounceHandler");
22257 exports.BounceHandler = BounceHandler_1.BounceHandler;
22258 var DragPanHandler_1 = require("./component/mouse/DragPanHandler");
22259 exports.DragPanHandler = DragPanHandler_1.DragPanHandler;
22260 var DoubleClickZoomHandler_1 = require("./component/mouse/DoubleClickZoomHandler");
22261 exports.DoubleClickZoomHandler = DoubleClickZoomHandler_1.DoubleClickZoomHandler;
22262 var EarthControlHandler_1 = require("./component/mouse/EarthControlHandler");
22263 exports.EarthControlHandler = EarthControlHandler_1.EarthControlHandler;
22264 var ScrollZoomHandler_1 = require("./component/mouse/ScrollZoomHandler");
22265 exports.ScrollZoomHandler = ScrollZoomHandler_1.ScrollZoomHandler;
22266 var TouchZoomHandler_1 = require("./component/mouse/TouchZoomHandler");
22267 exports.TouchZoomHandler = TouchZoomHandler_1.TouchZoomHandler;
22268 var ImageBoundary = require("./component/mouse/ImageBoundary");
22269 exports.ImageBoundary = ImageBoundary;
22270 var Popup_1 = require("./component/popup/popup/Popup");
22271 exports.Popup = Popup_1.Popup;
22272 var PopupComponent_1 = require("./component/popup/PopupComponent");
22273 exports.PopupComponent = PopupComponent_1.PopupComponent;
22274 var NavigationComponent_1 = require("./component/NavigationComponent");
22275 exports.NavigationComponent = NavigationComponent_1.NavigationComponent;
22276 var RouteComponent_1 = require("./component/RouteComponent");
22277 exports.RouteComponent = RouteComponent_1.RouteComponent;
22278 var SequenceComponent_1 = require("./component/sequence/SequenceComponent");
22279 exports.SequenceComponent = SequenceComponent_1.SequenceComponent;
22280 var SequenceDOMRenderer_1 = require("./component/sequence/SequenceDOMRenderer");
22281 exports.SequenceDOMRenderer = SequenceDOMRenderer_1.SequenceDOMRenderer;
22282 var SequenceMode_1 = require("./component/sequence/SequenceMode");
22283 exports.SequenceMode = SequenceMode_1.SequenceMode;
22284 var SpatialDataCache_1 = require("./component/spatialdata/SpatialDataCache");
22285 exports.SpatialDataCache = SpatialDataCache_1.SpatialDataCache;
22286 var SpatialDataComponent_1 = require("./component/spatialdata/SpatialDataComponent");
22287 exports.SpatialDataComponent = SpatialDataComponent_1.SpatialDataComponent;
22288 var SpatialDataScene_1 = require("./component/spatialdata/SpatialDataScene");
22289 exports.SpatialDataScene = SpatialDataScene_1.SpatialDataScene;
22290 var ImagePlaneComponent_1 = require("./component/imageplane/ImagePlaneComponent");
22291 exports.ImagePlaneComponent = ImagePlaneComponent_1.ImagePlaneComponent;
22292 var ImagePlaneGLRenderer_1 = require("./component/imageplane/ImagePlaneGLRenderer");
22293 exports.ImagePlaneGLRenderer = ImagePlaneGLRenderer_1.ImagePlaneGLRenderer;
22294 var Shaders_1 = require("./component/shaders/Shaders");
22295 exports.Shaders = Shaders_1.Shaders;
22296 var SimpleMarker_1 = require("./component/marker/marker/SimpleMarker");
22297 exports.SimpleMarker = SimpleMarker_1.SimpleMarker;
22298 var CircleMarker_1 = require("./component/marker/marker/CircleMarker");
22299 exports.CircleMarker = CircleMarker_1.CircleMarker;
22300 var SliderComponent_1 = require("./component/slider/SliderComponent");
22301 exports.SliderComponent = SliderComponent_1.SliderComponent;
22302 var SliderDOMRenderer_1 = require("./component/slider/SliderDOMRenderer");
22303 exports.SliderDOMRenderer = SliderDOMRenderer_1.SliderDOMRenderer;
22304 var SliderGLRenderer_1 = require("./component/slider/SliderGLRenderer");
22305 exports.SliderGLRenderer = SliderGLRenderer_1.SliderGLRenderer;
22306 var StatsComponent_1 = require("./component/StatsComponent");
22307 exports.StatsComponent = StatsComponent_1.StatsComponent;
22308 var TagHandlerBase_1 = require("./component/tag/handlers/TagHandlerBase");
22309 exports.TagHandlerBase = TagHandlerBase_1.TagHandlerBase;
22310 var CreateHandlerBase_1 = require("./component/tag/handlers/CreateHandlerBase");
22311 exports.CreateHandlerBase = CreateHandlerBase_1.CreateHandlerBase;
22312 var CreatePointHandler_1 = require("./component/tag/handlers/CreatePointHandler");
22313 exports.CreatePointHandler = CreatePointHandler_1.CreatePointHandler;
22314 var CreateVertexHandler_1 = require("./component/tag/handlers/CreateVertexHandler");
22315 exports.CreateVertexHandler = CreateVertexHandler_1.CreateVertexHandler;
22316 var CreatePolygonHandler_1 = require("./component/tag/handlers/CreatePolygonHandler");
22317 exports.CreatePolygonHandler = CreatePolygonHandler_1.CreatePolygonHandler;
22318 var CreateRectHandler_1 = require("./component/tag/handlers/CreateRectHandler");
22319 exports.CreateRectHandler = CreateRectHandler_1.CreateRectHandler;
22320 var CreateRectDragHandler_1 = require("./component/tag/handlers/CreateRectDragHandler");
22321 exports.CreateRectDragHandler = CreateRectDragHandler_1.CreateRectDragHandler;
22322 var EditVertexHandler_1 = require("./component/tag/handlers/EditVertexHandler");
22323 exports.EditVertexHandler = EditVertexHandler_1.EditVertexHandler;
22324 var Tag_1 = require("./component/tag/tag/Tag");
22325 exports.Tag = Tag_1.Tag;
22326 var OutlineTag_1 = require("./component/tag/tag/OutlineTag");
22327 exports.OutlineTag = OutlineTag_1.OutlineTag;
22328 var RenderTag_1 = require("./component/tag/tag/RenderTag");
22329 exports.RenderTag = RenderTag_1.RenderTag;
22330 var OutlineRenderTag_1 = require("./component/tag/tag/OutlineRenderTag");
22331 exports.OutlineRenderTag = OutlineRenderTag_1.OutlineRenderTag;
22332 var OutlineCreateTag_1 = require("./component/tag/tag/OutlineCreateTag");
22333 exports.OutlineCreateTag = OutlineCreateTag_1.OutlineCreateTag;
22334 var SpotTag_1 = require("./component/tag/tag/SpotTag");
22335 exports.SpotTag = SpotTag_1.SpotTag;
22336 var SpotRenderTag_1 = require("./component/tag/tag/SpotRenderTag");
22337 exports.SpotRenderTag = SpotRenderTag_1.SpotRenderTag;
22338 var TagDomain_1 = require("./component/tag/tag/TagDomain");
22339 exports.TagDomain = TagDomain_1.TagDomain;
22340 var TagComponent_1 = require("./component/tag/TagComponent");
22341 exports.TagComponent = TagComponent_1.TagComponent;
22342 var TagCreator_1 = require("./component/tag/TagCreator");
22343 exports.TagCreator = TagCreator_1.TagCreator;
22344 var TagDOMRenderer_1 = require("./component/tag/TagDOMRenderer");
22345 exports.TagDOMRenderer = TagDOMRenderer_1.TagDOMRenderer;
22346 var TagMode_1 = require("./component/tag/TagMode");
22347 exports.TagMode = TagMode_1.TagMode;
22348 var TagOperation_1 = require("./component/tag/TagOperation");
22349 exports.TagOperation = TagOperation_1.TagOperation;
22350 var TagScene_1 = require("./component/tag/TagScene");
22351 exports.TagScene = TagScene_1.TagScene;
22352 var TagSet_1 = require("./component/tag/TagSet");
22353 exports.TagSet = TagSet_1.TagSet;
22354 var Geometry_1 = require("./component/tag/geometry/Geometry");
22355 exports.Geometry = Geometry_1.Geometry;
22356 var VertexGeometry_1 = require("./component/tag/geometry/VertexGeometry");
22357 exports.VertexGeometry = VertexGeometry_1.VertexGeometry;
22358 var RectGeometry_1 = require("./component/tag/geometry/RectGeometry");
22359 exports.RectGeometry = RectGeometry_1.RectGeometry;
22360 var PointGeometry_1 = require("./component/tag/geometry/PointGeometry");
22361 exports.PointGeometry = PointGeometry_1.PointGeometry;
22362 var PolygonGeometry_1 = require("./component/tag/geometry/PolygonGeometry");
22363 exports.PolygonGeometry = PolygonGeometry_1.PolygonGeometry;
22364 var GeometryTagError_1 = require("./component/tag/error/GeometryTagError");
22365 exports.GeometryTagError = GeometryTagError_1.GeometryTagError;
22366 var ZoomComponent_1 = require("./component/zoom/ZoomComponent");
22367 exports.ZoomComponent = ZoomComponent_1.ZoomComponent;
22368 __export(require("./component/interfaces/interfaces"));
22370 },{"./component/AttributionComponent":289,"./component/BackgroundComponent":290,"./component/BearingComponent":291,"./component/CacheComponent":292,"./component/Component":293,"./component/ComponentService":294,"./component/CoverComponent":295,"./component/DebugComponent":296,"./component/ImageComponent":297,"./component/LoadingComponent":298,"./component/NavigationComponent":299,"./component/RouteComponent":300,"./component/StatsComponent":301,"./component/direction/DirectionComponent":302,"./component/direction/DirectionDOMCalculator":303,"./component/direction/DirectionDOMRenderer":304,"./component/imageplane/ImagePlaneComponent":305,"./component/imageplane/ImagePlaneGLRenderer":306,"./component/interfaces/interfaces":309,"./component/keyboard/KeyPlayHandler":310,"./component/keyboard/KeySequenceNavigationHandler":311,"./component/keyboard/KeySpatialNavigationHandler":312,"./component/keyboard/KeyZoomHandler":313,"./component/keyboard/KeyboardComponent":314,"./component/marker/MarkerComponent":316,"./component/marker/MarkerScene":317,"./component/marker/MarkerSet":318,"./component/marker/marker/CircleMarker":319,"./component/marker/marker/Marker":320,"./component/marker/marker/SimpleMarker":321,"./component/mouse/BounceHandler":322,"./component/mouse/DoubleClickZoomHandler":323,"./component/mouse/DragPanHandler":324,"./component/mouse/EarthControlHandler":325,"./component/mouse/ImageBoundary":326,"./component/mouse/MouseComponent":327,"./component/mouse/ScrollZoomHandler":328,"./component/mouse/TouchZoomHandler":329,"./component/popup/PopupComponent":331,"./component/popup/popup/Popup":332,"./component/sequence/SequenceComponent":333,"./component/sequence/SequenceDOMRenderer":334,"./component/sequence/SequenceMode":335,"./component/shaders/Shaders":336,"./component/slider/SliderComponent":337,"./component/slider/SliderDOMRenderer":338,"./component/slider/SliderGLRenderer":339,"./component/spatialdata/SpatialDataCache":340,"./component/spatialdata/SpatialDataComponent":341,"./component/spatialdata/SpatialDataScene":342,"./component/tag/TagComponent":344,"./component/tag/TagCreator":345,"./component/tag/TagDOMRenderer":346,"./component/tag/TagMode":347,"./component/tag/TagOperation":348,"./component/tag/TagScene":349,"./component/tag/TagSet":350,"./component/tag/error/GeometryTagError":351,"./component/tag/geometry/Geometry":352,"./component/tag/geometry/PointGeometry":353,"./component/tag/geometry/PolygonGeometry":354,"./component/tag/geometry/RectGeometry":355,"./component/tag/geometry/VertexGeometry":356,"./component/tag/handlers/CreateHandlerBase":357,"./component/tag/handlers/CreatePointHandler":358,"./component/tag/handlers/CreatePolygonHandler":359,"./component/tag/handlers/CreateRectDragHandler":360,"./component/tag/handlers/CreateRectHandler":361,"./component/tag/handlers/CreateVertexHandler":362,"./component/tag/handlers/EditVertexHandler":363,"./component/tag/handlers/TagHandlerBase":364,"./component/tag/tag/OutlineCreateTag":365,"./component/tag/tag/OutlineRenderTag":366,"./component/tag/tag/OutlineTag":367,"./component/tag/tag/RenderTag":368,"./component/tag/tag/SpotRenderTag":369,"./component/tag/tag/SpotTag":370,"./component/tag/tag/Tag":371,"./component/tag/tag/TagDomain":372,"./component/utils/HandlerBase":373,"./component/utils/MeshFactory":374,"./component/utils/MeshScene":375,"./component/utils/MouseOperator":376,"./component/zoom/ZoomComponent":377}],276:[function(require,module,exports){
22372 Object.defineProperty(exports, "__esModule", { value: true });
22373 var EdgeDirection_1 = require("./graph/edge/EdgeDirection");
22374 exports.EdgeDirection = EdgeDirection_1.EdgeDirection;
22375 var EdgeCalculatorSettings_1 = require("./graph/edge/EdgeCalculatorSettings");
22376 exports.EdgeCalculatorSettings = EdgeCalculatorSettings_1.EdgeCalculatorSettings;
22377 var EdgeCalculatorDirections_1 = require("./graph/edge/EdgeCalculatorDirections");
22378 exports.EdgeCalculatorDirections = EdgeCalculatorDirections_1.EdgeCalculatorDirections;
22379 var EdgeCalculatorCoefficients_1 = require("./graph/edge/EdgeCalculatorCoefficients");
22380 exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients_1.EdgeCalculatorCoefficients;
22381 var EdgeCalculator_1 = require("./graph/edge/EdgeCalculator");
22382 exports.EdgeCalculator = EdgeCalculator_1.EdgeCalculator;
22384 },{"./graph/edge/EdgeCalculator":399,"./graph/edge/EdgeCalculatorCoefficients":400,"./graph/edge/EdgeCalculatorDirections":401,"./graph/edge/EdgeCalculatorSettings":402,"./graph/edge/EdgeDirection":403}],277:[function(require,module,exports){
22386 Object.defineProperty(exports, "__esModule", { value: true });
22387 var AbortMapillaryError_1 = require("./error/AbortMapillaryError");
22388 exports.AbortMapillaryError = AbortMapillaryError_1.AbortMapillaryError;
22389 var ArgumentMapillaryError_1 = require("./error/ArgumentMapillaryError");
22390 exports.ArgumentMapillaryError = ArgumentMapillaryError_1.ArgumentMapillaryError;
22391 var GraphMapillaryError_1 = require("./error/GraphMapillaryError");
22392 exports.GraphMapillaryError = GraphMapillaryError_1.GraphMapillaryError;
22393 var MapillaryError_1 = require("./error/MapillaryError");
22394 exports.MapillaryError = MapillaryError_1.MapillaryError;
22396 },{"./error/AbortMapillaryError":378,"./error/ArgumentMapillaryError":379,"./error/GraphMapillaryError":380,"./error/MapillaryError":381}],278:[function(require,module,exports){
22398 Object.defineProperty(exports, "__esModule", { value: true });
22399 var Camera_1 = require("./geo/Camera");
22400 exports.Camera = Camera_1.Camera;
22401 var GeoCoords_1 = require("./geo/GeoCoords");
22402 exports.GeoCoords = GeoCoords_1.GeoCoords;
22403 var ViewportCoords_1 = require("./geo/ViewportCoords");
22404 exports.ViewportCoords = ViewportCoords_1.ViewportCoords;
22405 var Spatial_1 = require("./geo/Spatial");
22406 exports.Spatial = Spatial_1.Spatial;
22407 var Transform_1 = require("./geo/Transform");
22408 exports.Transform = Transform_1.Transform;
22409 var Geo = require("./geo/Geo");
22411 var Lines = require("./geo/Lines");
22412 exports.Lines = Lines;
22414 },{"./geo/Camera":382,"./geo/Geo":383,"./geo/GeoCoords":384,"./geo/Lines":385,"./geo/Spatial":386,"./geo/Transform":387,"./geo/ViewportCoords":388}],279:[function(require,module,exports){
22416 Object.defineProperty(exports, "__esModule", { value: true });
22417 var FilterCreator_1 = require("./graph/FilterCreator");
22418 exports.FilterCreator = FilterCreator_1.FilterCreator;
22419 var Graph_1 = require("./graph/Graph");
22420 exports.Graph = Graph_1.Graph;
22421 var GraphCalculator_1 = require("./graph/GraphCalculator");
22422 exports.GraphCalculator = GraphCalculator_1.GraphCalculator;
22423 var GraphMode_1 = require("./graph/GraphMode");
22424 exports.GraphMode = GraphMode_1.GraphMode;
22425 var GraphService_1 = require("./graph/GraphService");
22426 exports.GraphService = GraphService_1.GraphService;
22427 var ImageLoadingService_1 = require("./graph/ImageLoadingService");
22428 exports.ImageLoadingService = ImageLoadingService_1.ImageLoadingService;
22429 var MeshReader_1 = require("./graph/MeshReader");
22430 exports.MeshReader = MeshReader_1.MeshReader;
22431 var Node_1 = require("./graph/Node");
22432 exports.Node = Node_1.Node;
22433 var NodeCache_1 = require("./graph/NodeCache");
22434 exports.NodeCache = NodeCache_1.NodeCache;
22435 var Sequence_1 = require("./graph/Sequence");
22436 exports.Sequence = Sequence_1.Sequence;
22438 },{"./graph/FilterCreator":389,"./graph/Graph":390,"./graph/GraphCalculator":391,"./graph/GraphMode":392,"./graph/GraphService":393,"./graph/ImageLoadingService":394,"./graph/MeshReader":395,"./graph/Node":396,"./graph/NodeCache":397,"./graph/Sequence":398}],280:[function(require,module,exports){
22441 * MapillaryJS is a WebGL JavaScript library for exploring street level imagery
22444 function __export(m) {
22445 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
22447 Object.defineProperty(exports, "__esModule", { value: true });
22448 __export(require("./Support"));
22449 var Edge_1 = require("./Edge");
22450 exports.EdgeDirection = Edge_1.EdgeDirection;
22451 var Error_1 = require("./Error");
22452 exports.AbortMapillaryError = Error_1.AbortMapillaryError;
22453 var Render_1 = require("./Render");
22454 exports.RenderMode = Render_1.RenderMode;
22455 var State_1 = require("./State");
22456 exports.TransitionMode = State_1.TransitionMode;
22457 var Viewer_1 = require("./Viewer");
22458 exports.Alignment = Viewer_1.Alignment;
22459 exports.ImageSize = Viewer_1.ImageSize;
22460 exports.Viewer = Viewer_1.Viewer;
22461 var Component_1 = require("./Component");
22462 exports.SliderMode = Component_1.SliderMode;
22463 var TagComponent = require("./component/tag/Tag");
22464 exports.TagComponent = TagComponent;
22465 var MarkerComponent = require("./component/marker/Marker");
22466 exports.MarkerComponent = MarkerComponent;
22467 var PopupComponent = require("./component/popup/Popup");
22468 exports.PopupComponent = PopupComponent;
22470 },{"./Component":275,"./Edge":276,"./Error":277,"./Render":281,"./State":282,"./Support":283,"./Viewer":286,"./component/marker/Marker":315,"./component/popup/Popup":330,"./component/tag/Tag":343}],281:[function(require,module,exports){
22472 Object.defineProperty(exports, "__esModule", { value: true });
22473 var DOMRenderer_1 = require("./render/DOMRenderer");
22474 exports.DOMRenderer = DOMRenderer_1.DOMRenderer;
22475 var GLRenderer_1 = require("./render/GLRenderer");
22476 exports.GLRenderer = GLRenderer_1.GLRenderer;
22477 var GLRenderStage_1 = require("./render/GLRenderStage");
22478 exports.GLRenderStage = GLRenderStage_1.GLRenderStage;
22479 var RenderCamera_1 = require("./render/RenderCamera");
22480 exports.RenderCamera = RenderCamera_1.RenderCamera;
22481 var RenderMode_1 = require("./render/RenderMode");
22482 exports.RenderMode = RenderMode_1.RenderMode;
22483 var RenderService_1 = require("./render/RenderService");
22484 exports.RenderService = RenderService_1.RenderService;
22486 },{"./render/DOMRenderer":404,"./render/GLRenderStage":405,"./render/GLRenderer":406,"./render/RenderCamera":407,"./render/RenderMode":408,"./render/RenderService":409}],282:[function(require,module,exports){
22488 Object.defineProperty(exports, "__esModule", { value: true });
22489 var FrameGenerator_1 = require("./state/FrameGenerator");
22490 exports.FrameGenerator = FrameGenerator_1.FrameGenerator;
22491 var RotationDelta_1 = require("./state/RotationDelta");
22492 exports.RotationDelta = RotationDelta_1.RotationDelta;
22493 var State_1 = require("./state/State");
22494 exports.State = State_1.State;
22495 var StateBase_1 = require("./state/states/StateBase");
22496 exports.StateBase = StateBase_1.StateBase;
22497 var StateContext_1 = require("./state/StateContext");
22498 exports.StateContext = StateContext_1.StateContext;
22499 var StateService_1 = require("./state/StateService");
22500 exports.StateService = StateService_1.StateService;
22501 var TransitionMode_1 = require("./state/TransitionMode");
22502 exports.TransitionMode = TransitionMode_1.TransitionMode;
22503 var EarthState_1 = require("./state/states/EarthState");
22504 exports.EarthState = EarthState_1.EarthState;
22505 var InteractiveStateBase_1 = require("./state/states/InteractiveStateBase");
22506 exports.InteractiveStateBase = InteractiveStateBase_1.InteractiveStateBase;
22507 var InteractiveWaitingState_1 = require("./state/states/InteractiveWaitingState");
22508 exports.InteractiveWaitingState = InteractiveWaitingState_1.InteractiveWaitingState;
22509 var TraversingState_1 = require("./state/states/TraversingState");
22510 exports.TraversingState = TraversingState_1.TraversingState;
22511 var WaitingState_1 = require("./state/states/WaitingState");
22512 exports.WaitingState = WaitingState_1.WaitingState;
22514 },{"./state/FrameGenerator":410,"./state/RotationDelta":411,"./state/State":412,"./state/StateContext":413,"./state/StateService":414,"./state/TransitionMode":415,"./state/states/EarthState":416,"./state/states/InteractiveStateBase":417,"./state/states/InteractiveWaitingState":418,"./state/states/StateBase":419,"./state/states/TraversingState":420,"./state/states/WaitingState":421}],283:[function(require,module,exports){
22516 Object.defineProperty(exports, "__esModule", { value: true });
22517 var support = require("./utils/Support");
22519 * Test whether the current browser supports the full
22520 * functionality of MapillaryJS.
22522 * @description The full functionality includes WebGL rendering.
22524 * @return {boolean}
22526 * @example `var supported = Mapillary.isSupported();`
22528 function isSupported() {
22529 return isFallbackSupported() &&
22530 support.isWebGLSupportedCached();
22532 exports.isSupported = isSupported;
22534 * Test whether the current browser supports the fallback
22535 * functionality of MapillaryJS.
22537 * @description The fallback functionality does not include WebGL
22538 * rendering, only 2D canvas rendering.
22540 * @return {boolean}
22542 * @example `var fallbackSupported = Mapillary.isFallbackSupported();`
22544 function isFallbackSupported() {
22545 return support.isBrowser() &&
22546 support.isBlobSupported() &&
22547 support.isArraySupported() &&
22548 support.isFunctionSupported() &&
22549 support.isJSONSupported() &&
22550 support.isObjectSupported();
22552 exports.isFallbackSupported = isFallbackSupported;
22554 },{"./utils/Support":429}],284:[function(require,module,exports){
22556 Object.defineProperty(exports, "__esModule", { value: true });
22557 var ImageTileLoader_1 = require("./tiles/ImageTileLoader");
22558 exports.ImageTileLoader = ImageTileLoader_1.ImageTileLoader;
22559 var ImageTileStore_1 = require("./tiles/ImageTileStore");
22560 exports.ImageTileStore = ImageTileStore_1.ImageTileStore;
22561 var TextureProvider_1 = require("./tiles/TextureProvider");
22562 exports.TextureProvider = TextureProvider_1.TextureProvider;
22563 var RegionOfInterestCalculator_1 = require("./tiles/RegionOfInterestCalculator");
22564 exports.RegionOfInterestCalculator = RegionOfInterestCalculator_1.RegionOfInterestCalculator;
22566 },{"./tiles/ImageTileLoader":422,"./tiles/ImageTileStore":423,"./tiles/RegionOfInterestCalculator":424,"./tiles/TextureProvider":425}],285:[function(require,module,exports){
22568 function __export(m) {
22569 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
22571 Object.defineProperty(exports, "__esModule", { value: true });
22572 var DOM_1 = require("./utils/DOM");
22573 exports.DOM = DOM_1.DOM;
22574 var EventEmitter_1 = require("./utils/EventEmitter");
22575 exports.EventEmitter = EventEmitter_1.EventEmitter;
22576 var Settings_1 = require("./utils/Settings");
22577 exports.Settings = Settings_1.Settings;
22578 __export(require("./utils/Support"));
22579 var Urls_1 = require("./utils/Urls");
22580 exports.Urls = Urls_1.Urls;
22582 },{"./utils/DOM":426,"./utils/EventEmitter":427,"./utils/Settings":428,"./utils/Support":429,"./utils/Urls":430}],286:[function(require,module,exports){
22584 Object.defineProperty(exports, "__esModule", { value: true });
22585 var Alignment_1 = require("./viewer/Alignment");
22586 exports.Alignment = Alignment_1.Alignment;
22587 var CacheService_1 = require("./viewer/CacheService");
22588 exports.CacheService = CacheService_1.CacheService;
22589 var ComponentController_1 = require("./viewer/ComponentController");
22590 exports.ComponentController = ComponentController_1.ComponentController;
22591 var Container_1 = require("./viewer/Container");
22592 exports.Container = Container_1.Container;
22593 var Observer_1 = require("./viewer/Observer");
22594 exports.Observer = Observer_1.Observer;
22595 var ImageSize_1 = require("./viewer/ImageSize");
22596 exports.ImageSize = ImageSize_1.ImageSize;
22597 var KeyboardService_1 = require("./viewer/KeyboardService");
22598 exports.KeyboardService = KeyboardService_1.KeyboardService;
22599 var LoadingService_1 = require("./viewer/LoadingService");
22600 exports.LoadingService = LoadingService_1.LoadingService;
22601 var MouseService_1 = require("./viewer/MouseService");
22602 exports.MouseService = MouseService_1.MouseService;
22603 var Navigator_1 = require("./viewer/Navigator");
22604 exports.Navigator = Navigator_1.Navigator;
22605 var PlayService_1 = require("./viewer/PlayService");
22606 exports.PlayService = PlayService_1.PlayService;
22607 var Projection_1 = require("./viewer/Projection");
22608 exports.Projection = Projection_1.Projection;
22609 var SpriteService_1 = require("./viewer/SpriteService");
22610 exports.SpriteService = SpriteService_1.SpriteService;
22611 var TouchService_1 = require("./viewer/TouchService");
22612 exports.TouchService = TouchService_1.TouchService;
22613 var Viewer_1 = require("./viewer/Viewer");
22614 exports.Viewer = Viewer_1.Viewer;
22616 },{"./viewer/Alignment":431,"./viewer/CacheService":432,"./viewer/ComponentController":433,"./viewer/Container":434,"./viewer/ImageSize":435,"./viewer/KeyboardService":436,"./viewer/LoadingService":437,"./viewer/MouseService":438,"./viewer/Navigator":439,"./viewer/Observer":440,"./viewer/PlayService":441,"./viewer/Projection":442,"./viewer/SpriteService":443,"./viewer/TouchService":444,"./viewer/Viewer":445}],287:[function(require,module,exports){
22618 Object.defineProperty(exports, "__esModule", { value: true });
22619 var operators_1 = require("rxjs/operators");
22620 var rxjs_1 = require("rxjs");
22621 var API_1 = require("../API");
22625 * @classdesc Provides methods for access of API v3.
22627 var APIv3 = /** @class */ (function () {
22629 * Create a new api v3 instance.
22631 * @param {number} clientId - Client id for API requests.
22632 * @param {number} [token] - Optional bearer token for API requests of
22633 * protected resources.
22634 * @param {ModelCreator} [creator] - Optional model creator instance.
22636 function APIv3(clientId, token, creator) {
22637 this._clientId = clientId;
22638 this._modelCreator = creator != null ? creator : new API_1.ModelCreator();
22639 this._model = this._modelCreator.createModel(clientId, token);
22640 this._pageCount = 999;
22641 this._pathImageByKey = "imageByKey";
22642 this._pathImageCloseTo = "imageCloseTo";
22643 this._pathImagesByH = "imagesByH";
22644 this._pathImageViewAdd = "imageViewAdd";
22645 this._pathSequenceByKey = "sequenceByKey";
22646 this._pathSequenceViewAdd = "sequenceViewAdd";
22647 this._propertiesCore = [
22652 this._propertiesFill = [
22654 "captured_with_camera_uuid",
22656 "organization_key",
22660 this._propertiesKey = [
22663 this._propertiesSequence = [
22666 this._propertiesSpatial = [
22682 this._propertiesUser = [
22686 APIv3.prototype.imageByKeyFill$ = function (keys) {
22687 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
22688 this._pathImageByKey,
22690 this._propertiesKey
22691 .concat(this._propertiesFill)
22692 .concat(this._propertiesSpatial),
22693 this._propertiesKey
22694 .concat(this._propertiesUser)
22695 ])).pipe(operators_1.map(function (value) {
22697 throw new Error("Images (" + keys.join(", ") + ") could not be found.");
22699 return value.json.imageByKey;
22700 })), this._pathImageByKey, keys);
22702 APIv3.prototype.imageByKeyFull$ = function (keys) {
22703 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
22704 this._pathImageByKey,
22706 this._propertiesKey
22707 .concat(this._propertiesCore)
22708 .concat(this._propertiesFill)
22709 .concat(this._propertiesSpatial),
22710 this._propertiesKey
22711 .concat(this._propertiesUser)
22712 ])).pipe(operators_1.map(function (value) {
22714 throw new Error("Images (" + keys.join(", ") + ") could not be found.");
22716 return value.json.imageByKey;
22717 })), this._pathImageByKey, keys);
22719 APIv3.prototype.imageCloseTo$ = function (lat, lon) {
22720 var lonLat = lon + ":" + lat;
22721 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
22722 this._pathImageCloseTo,
22724 this._propertiesKey
22725 .concat(this._propertiesCore)
22726 .concat(this._propertiesFill)
22727 .concat(this._propertiesSpatial),
22728 this._propertiesKey
22729 .concat(this._propertiesUser)
22730 ])).pipe(operators_1.map(function (value) {
22731 return value != null ? value.json.imageCloseTo[lonLat] : null;
22732 })), this._pathImageCloseTo, [lonLat]);
22734 APIv3.prototype.imagesByH$ = function (hs) {
22736 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
22737 this._pathImagesByH,
22739 { from: 0, to: this._pageCount },
22740 this._propertiesKey
22741 .concat(this._propertiesCore)
22742 ])).pipe(operators_1.map(function (value) {
22744 value = { json: { imagesByH: {} } };
22745 for (var _i = 0, hs_1 = hs; _i < hs_1.length; _i++) {
22747 value.json.imagesByH[h] = {};
22748 for (var i = 0; i <= _this._pageCount; i++) {
22749 value.json.imagesByH[h][i] = null;
22753 return value.json.imagesByH;
22754 })), this._pathImagesByH, hs);
22756 APIv3.prototype.imageViewAdd$ = function (keys) {
22757 return this._catchInvalidateCall$(this._wrapCallModelResponse$(this._model.call([this._pathImageViewAdd], [keys])), this._pathImageViewAdd, keys);
22759 APIv3.prototype.invalidateImageByKey = function (keys) {
22760 this._invalidateGet(this._pathImageByKey, keys);
22762 APIv3.prototype.invalidateImagesByH = function (hs) {
22763 this._invalidateGet(this._pathImagesByH, hs);
22765 APIv3.prototype.invalidateSequenceByKey = function (sKeys) {
22766 this._invalidateGet(this._pathSequenceByKey, sKeys);
22768 APIv3.prototype.setToken = function (token) {
22769 this._model.invalidate([]);
22770 this._model = null;
22771 this._model = this._modelCreator.createModel(this._clientId, token);
22773 APIv3.prototype.sequenceByKey$ = function (sequenceKeys) {
22774 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
22775 this._pathSequenceByKey,
22777 this._propertiesKey
22778 .concat(this._propertiesSequence)
22779 ])).pipe(operators_1.map(function (value) {
22781 value = { json: { sequenceByKey: {} } };
22783 for (var _i = 0, sequenceKeys_1 = sequenceKeys; _i < sequenceKeys_1.length; _i++) {
22784 var sequenceKey = sequenceKeys_1[_i];
22785 if (!(sequenceKey in value.json.sequenceByKey)) {
22786 console.warn("Sequence data missing (" + sequenceKey + ")");
22787 value.json.sequenceByKey[sequenceKey] = { key: sequenceKey, keys: [] };
22790 return value.json.sequenceByKey;
22791 })), this._pathSequenceByKey, sequenceKeys);
22793 APIv3.prototype.sequenceViewAdd$ = function (sequenceKeys) {
22794 return this._catchInvalidateCall$(this._wrapCallModelResponse$(this._model.call([this._pathSequenceViewAdd], [sequenceKeys])), this._pathSequenceViewAdd, sequenceKeys);
22796 Object.defineProperty(APIv3.prototype, "clientId", {
22798 return this._clientId;
22803 APIv3.prototype._catchInvalidateGet$ = function (observable, path, paths) {
22805 return observable.pipe(operators_1.catchError(function (error) {
22806 _this._invalidateGet(path, paths);
22810 APIv3.prototype._catchInvalidateCall$ = function (observable, path, paths) {
22812 return observable.pipe(operators_1.catchError(function (error) {
22813 _this._invalidateCall(path, paths);
22817 APIv3.prototype._invalidateGet = function (path, paths) {
22818 this._model.invalidate([path, paths]);
22820 APIv3.prototype._invalidateCall = function (path, paths) {
22821 this._model.invalidate([path], [paths]);
22823 APIv3.prototype._wrapModelResponse$ = function (modelResponse) {
22824 return rxjs_1.Observable
22825 .create(function (subscriber) {
22827 .then(function (value) {
22828 subscriber.next(value);
22829 subscriber.complete();
22830 }, function (error) {
22831 subscriber.error(error);
22835 APIv3.prototype._wrapCallModelResponse$ = function (modelResponse) {
22836 return this._wrapModelResponse$(modelResponse).pipe(operators_1.map(function (value) {
22842 exports.APIv3 = APIv3;
22843 exports.default = APIv3;
22845 },{"../API":274,"rxjs":27,"rxjs/operators":225}],288:[function(require,module,exports){
22847 Object.defineProperty(exports, "__esModule", { value: true });
22848 var falcor = require("falcor");
22849 var falcor_http_datasource_1 = require("falcor-http-datasource");
22850 var Utils_1 = require("../Utils");
22852 * @class ModelCreator
22854 * @classdesc Creates API models.
22856 var ModelCreator = /** @class */ (function () {
22857 function ModelCreator() {
22860 * Creates a Falcor model.
22862 * @description Max cache size will be set to 16 MB. Authorization
22863 * header will be added if bearer token is supplied.
22865 * @param {number} clientId - Client id for API requests.
22866 * @param {number} [token] - Optional bearer token for API requests of
22867 * protected resources.
22868 * @returns {falcor.Model} Falcor model for HTTP requests.
22870 ModelCreator.prototype.createModel = function (clientId, token) {
22871 var configuration = {
22873 withCredentials: false,
22875 if (token != null) {
22876 configuration.headers = { "Authorization": "Bearer " + token };
22878 return new falcor.Model({
22879 maxSize: 16 * 1024 * 1024,
22880 source: new falcor_http_datasource_1.default(Utils_1.Urls.falcorModel(clientId), configuration),
22883 return ModelCreator;
22885 exports.ModelCreator = ModelCreator;
22886 exports.default = ModelCreator;
22888 },{"../Utils":285,"falcor":15,"falcor-http-datasource":10}],289:[function(require,module,exports){
22890 var __extends = (this && this.__extends) || (function () {
22891 var extendStatics = function (d, b) {
22892 extendStatics = Object.setPrototypeOf ||
22893 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22894 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22895 return extendStatics(d, b);
22897 return function (d, b) {
22898 extendStatics(d, b);
22899 function __() { this.constructor = d; }
22900 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22903 Object.defineProperty(exports, "__esModule", { value: true });
22904 var rxjs_1 = require("rxjs");
22905 var operators_1 = require("rxjs/operators");
22906 var vd = require("virtual-dom");
22907 var Component_1 = require("../Component");
22908 var Utils_1 = require("../Utils");
22909 var AttributionComponent = /** @class */ (function (_super) {
22910 __extends(AttributionComponent, _super);
22911 function AttributionComponent(name, container, navigator) {
22912 return _super.call(this, name, container, navigator) || this;
22914 AttributionComponent.prototype._activate = function () {
22916 this._disposable = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
22917 var node = _a[0], size = _a[1];
22920 vnode: _this._getAttributionNode(node.username, node.key, node.capturedAt, size.width),
22923 .subscribe(this._container.domRenderer.render$);
22925 AttributionComponent.prototype._deactivate = function () {
22926 this._disposable.unsubscribe();
22928 AttributionComponent.prototype._getDefaultConfiguration = function () {
22931 AttributionComponent.prototype._getAttributionNode = function (username, key, capturedAt, width) {
22932 var compact = width <= 640;
22933 var mapillaryIcon = vd.h("div.AttributionMapillaryLogo", []);
22934 var mapillaryLink = vd.h("a.AttributionIconContainer", { href: Utils_1.Urls.explore, target: "_blank" }, [mapillaryIcon]);
22935 var imageBy = compact ? "" + username : "image by " + username;
22936 var imageByContent = vd.h("div.AttributionUsername", { textContent: imageBy }, []);
22937 var date = new Date(capturedAt).toDateString().split(" ");
22938 var formatted = (date.length > 3 ?
22941 [date[1], date[2] + ",", date[3]] :
22943 var dateContent = vd.h("div.AttributionDate", { textContent: formatted }, []);
22944 var imageLink = vd.h("a.AttributionImageContainer", { href: Utils_1.Urls.exporeImage(key), target: "_blank" }, [imageByContent, dateContent]);
22945 var compactClass = compact ? ".AttributionCompact" : "";
22946 return vd.h("div.AttributionContainer" + compactClass, {}, [mapillaryLink, imageLink]);
22948 AttributionComponent.componentName = "attribution";
22949 return AttributionComponent;
22950 }(Component_1.Component));
22951 exports.AttributionComponent = AttributionComponent;
22952 Component_1.ComponentService.register(AttributionComponent);
22953 exports.default = AttributionComponent;
22955 },{"../Component":275,"../Utils":285,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],290:[function(require,module,exports){
22957 var __extends = (this && this.__extends) || (function () {
22958 var extendStatics = function (d, b) {
22959 extendStatics = Object.setPrototypeOf ||
22960 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22961 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22962 return extendStatics(d, b);
22964 return function (d, b) {
22965 extendStatics(d, b);
22966 function __() { this.constructor = d; }
22967 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22970 Object.defineProperty(exports, "__esModule", { value: true });
22971 var vd = require("virtual-dom");
22972 var Component_1 = require("../Component");
22973 var BackgroundComponent = /** @class */ (function (_super) {
22974 __extends(BackgroundComponent, _super);
22975 function BackgroundComponent(name, container, navigator) {
22976 return _super.call(this, name, container, navigator) || this;
22978 BackgroundComponent.prototype._activate = function () {
22979 this._container.domRenderer.render$
22980 .next({ name: this._name, vnode: this._getBackgroundNode("The viewer can't display the given image.") });
22982 BackgroundComponent.prototype._deactivate = function () {
22985 BackgroundComponent.prototype._getDefaultConfiguration = function () {
22988 BackgroundComponent.prototype._getBackgroundNode = function (notice) {
22989 // todo: add condition for when to display the DOM node
22990 return vd.h("div.BackgroundWrapper", {}, [
22991 vd.h("p", { textContent: notice }, []),
22994 BackgroundComponent.componentName = "background";
22995 return BackgroundComponent;
22996 }(Component_1.Component));
22997 exports.BackgroundComponent = BackgroundComponent;
22998 Component_1.ComponentService.register(BackgroundComponent);
22999 exports.default = BackgroundComponent;
23001 },{"../Component":275,"virtual-dom":231}],291:[function(require,module,exports){
23003 var __extends = (this && this.__extends) || (function () {
23004 var extendStatics = function (d, b) {
23005 extendStatics = Object.setPrototypeOf ||
23006 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23007 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23008 return extendStatics(d, b);
23010 return function (d, b) {
23011 extendStatics(d, b);
23012 function __() { this.constructor = d; }
23013 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23016 Object.defineProperty(exports, "__esModule", { value: true });
23017 var operators_1 = require("rxjs/operators");
23018 var vd = require("virtual-dom");
23019 var Component_1 = require("../Component");
23020 var Geo_1 = require("../Geo");
23021 var BearingComponent = /** @class */ (function (_super) {
23022 __extends(BearingComponent, _super);
23023 function BearingComponent(name, container, navigator) {
23024 var _this = _super.call(this, name, container, navigator) || this;
23025 _this._spatial = new Geo_1.Spatial();
23026 _this._svgNamespace = "http://www.w3.org/2000/svg";
23027 _this._distinctThreshold = Math.PI / 360;
23030 BearingComponent.prototype._activate = function () {
23032 var cameraBearingFov$ = this._container.renderService.renderCamera$.pipe(operators_1.map(function (rc) {
23033 var vFov = _this._spatial.degToRad(rc.perspective.fov);
23034 var hFov = rc.perspective.aspect === Number.POSITIVE_INFINITY ?
23036 Math.atan(rc.perspective.aspect * Math.tan(0.5 * vFov)) * 2;
23037 return [_this._spatial.azimuthalToBearing(rc.rotation.phi), hFov];
23038 }), operators_1.distinctUntilChanged(function (a1, a2) {
23039 return Math.abs(a2[0] - a1[0]) < _this._distinctThreshold &&
23040 Math.abs(a2[1] - a1[1]) < _this._distinctThreshold;
23042 this._renderSubscription = cameraBearingFov$.pipe(operators_1.map(function (_a) {
23043 var bearing = _a[0], fov = _a[1];
23044 var background = vd.h("div.BearingIndicatorBackground", {}, []);
23045 var backgroundCircle = vd.h("div.BearingIndicatorBackgroundCircle", {}, []);
23046 var north = _this._createNorth(bearing);
23047 var cameraSector = _this._createCircleSectorCompass(_this._createCircleSector(Math.max(Math.PI / 20, fov), "#FFF"));
23050 vnode: vd.h("div.BearingIndicatorContainer", { oncontextmenu: function (event) { event.preventDefault(); } }, [
23058 .subscribe(this._container.domRenderer.render$);
23060 BearingComponent.prototype._deactivate = function () {
23061 this._renderSubscription.unsubscribe();
23063 BearingComponent.prototype._getDefaultConfiguration = function () {
23066 BearingComponent.prototype._createCircleSectorCompass = function (cameraSector) {
23067 var group = vd.h("g", {
23068 attributes: { transform: "translate(1,1)" },
23069 namespace: this._svgNamespace,
23070 }, [cameraSector]);
23071 var svg = vd.h("svg", {
23072 attributes: { viewBox: "0 0 2 2" },
23073 namespace: this._svgNamespace,
23077 position: "absolute",
23084 BearingComponent.prototype._createCircleSector = function (fov, fill) {
23085 if (fov > 2 * Math.PI - Math.PI / 90) {
23086 return vd.h("circle", {
23087 attributes: { cx: "0", cy: "0", fill: fill, r: "1" },
23088 namespace: this._svgNamespace,
23091 var arcStart = -Math.PI / 2 - fov / 2;
23092 var arcEnd = arcStart + fov;
23093 var startX = Math.cos(arcStart);
23094 var startY = Math.sin(arcStart);
23095 var endX = Math.cos(arcEnd);
23096 var endY = Math.sin(arcEnd);
23097 var largeArc = fov >= Math.PI ? 1 : 0;
23098 var description = "M 0 0 " + startX + " " + startY + " A 1 1 0 " + largeArc + " 1 " + endX + " " + endY;
23099 return vd.h("path", {
23100 attributes: { d: description, fill: fill },
23101 namespace: this._svgNamespace,
23104 BearingComponent.prototype._createNorth = function (bearing) {
23105 var north = vd.h("div.BearingNorth", []);
23106 var container = vd.h("div.BearingNorthContainer", { style: { transform: "rotateZ(" + -bearing * 180 / Math.PI + "deg)" } }, [north]);
23109 BearingComponent.componentName = "bearing";
23110 return BearingComponent;
23111 }(Component_1.Component));
23112 exports.BearingComponent = BearingComponent;
23113 Component_1.ComponentService.register(BearingComponent);
23114 exports.default = BearingComponent;
23116 },{"../Component":275,"../Geo":278,"rxjs/operators":225,"virtual-dom":231}],292:[function(require,module,exports){
23118 var __extends = (this && this.__extends) || (function () {
23119 var extendStatics = function (d, b) {
23120 extendStatics = Object.setPrototypeOf ||
23121 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23122 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23123 return extendStatics(d, b);
23125 return function (d, b) {
23126 extendStatics(d, b);
23127 function __() { this.constructor = d; }
23128 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23131 Object.defineProperty(exports, "__esModule", { value: true });
23132 var rxjs_1 = require("rxjs");
23133 var operators_1 = require("rxjs/operators");
23134 var Edge_1 = require("../Edge");
23135 var Component_1 = require("../Component");
23136 var CacheComponent = /** @class */ (function (_super) {
23137 __extends(CacheComponent, _super);
23138 function CacheComponent(name, container, navigator) {
23139 return _super.call(this, name, container, navigator) || this;
23142 * Set the cache depth.
23144 * Configures the cache depth. The cache depth can be different for
23145 * different edge direction types.
23147 * @param {ICacheDepth} depth - Cache depth structure.
23149 CacheComponent.prototype.setDepth = function (depth) {
23150 this.configure({ depth: depth });
23152 CacheComponent.prototype._activate = function () {
23154 this._sequenceSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
23155 return node.sequenceEdges$;
23156 }), operators_1.filter(function (status) {
23157 return status.cached;
23158 })), this._configuration$).pipe(operators_1.switchMap(function (nc) {
23159 var status = nc[0];
23160 var configuration = nc[1];
23161 var sequenceDepth = Math.max(0, Math.min(4, configuration.depth.sequence));
23162 var next$ = _this._cache$(status.edges, Edge_1.EdgeDirection.Next, sequenceDepth);
23163 var prev$ = _this._cache$(status.edges, Edge_1.EdgeDirection.Prev, sequenceDepth);
23164 return rxjs_1.merge(next$, prev$).pipe(operators_1.catchError(function (error, caught) {
23165 console.error("Failed to cache sequence edges.", error);
23166 return rxjs_1.empty();
23169 .subscribe(function () { });
23170 this._spatialSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
23171 return rxjs_1.combineLatest(rxjs_1.of(node), node.spatialEdges$.pipe(operators_1.filter(function (status) {
23172 return status.cached;
23174 })), this._configuration$).pipe(operators_1.switchMap(function (_a) {
23175 var _b = _a[0], node = _b[0], edgeStatus = _b[1], configuration = _a[1];
23176 var edges = edgeStatus.edges;
23177 var depth = configuration.depth;
23178 var panoDepth = Math.max(0, Math.min(2, depth.pano));
23179 var stepDepth = node.pano ? 0 : Math.max(0, Math.min(3, depth.step));
23180 var turnDepth = node.pano ? 0 : Math.max(0, Math.min(1, depth.turn));
23181 var pano$ = _this._cache$(edges, Edge_1.EdgeDirection.Pano, panoDepth);
23182 var forward$ = _this._cache$(edges, Edge_1.EdgeDirection.StepForward, stepDepth);
23183 var backward$ = _this._cache$(edges, Edge_1.EdgeDirection.StepBackward, stepDepth);
23184 var left$ = _this._cache$(edges, Edge_1.EdgeDirection.StepLeft, stepDepth);
23185 var right$ = _this._cache$(edges, Edge_1.EdgeDirection.StepRight, stepDepth);
23186 var turnLeft$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnLeft, turnDepth);
23187 var turnRight$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnRight, turnDepth);
23188 var turnU$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnU, turnDepth);
23189 return rxjs_1.merge(forward$, backward$, left$, right$, pano$, turnLeft$, turnRight$, turnU$).pipe(operators_1.catchError(function (error, caught) {
23190 console.error("Failed to cache spatial edges.", error);
23191 return rxjs_1.empty();
23194 .subscribe(function () { });
23196 CacheComponent.prototype._deactivate = function () {
23197 this._sequenceSubscription.unsubscribe();
23198 this._spatialSubscription.unsubscribe();
23200 CacheComponent.prototype._getDefaultConfiguration = function () {
23201 return { depth: { pano: 1, sequence: 2, step: 1, turn: 0 } };
23203 CacheComponent.prototype._cache$ = function (edges, direction, depth) {
23205 return rxjs_1.zip(rxjs_1.of(edges), rxjs_1.of(depth)).pipe(operators_1.expand(function (ed) {
23208 var edgesDepths$ = [];
23210 for (var _i = 0, es_1 = es; _i < es_1.length; _i++) {
23211 var edge = es_1[_i];
23212 if (edge.data.direction === direction) {
23213 edgesDepths$.push(rxjs_1.zip(_this._navigator.graphService.cacheNode$(edge.to).pipe(operators_1.mergeMap(function (n) {
23214 return _this._nodeToEdges$(n, direction);
23215 })), rxjs_1.of(d - 1)));
23219 return rxjs_1.from(edgesDepths$).pipe(operators_1.mergeAll());
23220 }), operators_1.skip(1));
23222 CacheComponent.prototype._nodeToEdges$ = function (node, direction) {
23223 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
23224 node.sequenceEdges$ :
23225 node.spatialEdges$).pipe(operators_1.first(function (status) {
23226 return status.cached;
23227 }), operators_1.map(function (status) {
23228 return status.edges;
23231 CacheComponent.componentName = "cache";
23232 return CacheComponent;
23233 }(Component_1.Component));
23234 exports.CacheComponent = CacheComponent;
23235 Component_1.ComponentService.register(CacheComponent);
23236 exports.default = CacheComponent;
23238 },{"../Component":275,"../Edge":276,"rxjs":27,"rxjs/operators":225}],293:[function(require,module,exports){
23240 var __extends = (this && this.__extends) || (function () {
23241 var extendStatics = function (d, b) {
23242 extendStatics = Object.setPrototypeOf ||
23243 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23244 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23245 return extendStatics(d, b);
23247 return function (d, b) {
23248 extendStatics(d, b);
23249 function __() { this.constructor = d; }
23250 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23253 Object.defineProperty(exports, "__esModule", { value: true });
23254 var operators_1 = require("rxjs/operators");
23255 var rxjs_1 = require("rxjs");
23256 var Utils_1 = require("../Utils");
23257 var Component = /** @class */ (function (_super) {
23258 __extends(Component, _super);
23259 function Component(name, container, navigator) {
23260 var _this = _super.call(this) || this;
23261 _this._activated$ = new rxjs_1.BehaviorSubject(false);
23262 _this._configurationSubject$ = new rxjs_1.Subject();
23263 _this._activated = false;
23264 _this._container = container;
23265 _this._name = name;
23266 _this._navigator = navigator;
23267 _this._configuration$ =
23268 _this._configurationSubject$.pipe(operators_1.startWith(_this.defaultConfiguration), operators_1.scan(function (conf, newConf) {
23269 for (var key in newConf) {
23270 if (newConf.hasOwnProperty(key)) {
23271 conf[key] = newConf[key];
23275 }), operators_1.publishReplay(1), operators_1.refCount());
23276 _this._configuration$.subscribe(function () { });
23279 Object.defineProperty(Component.prototype, "activated", {
23281 return this._activated;
23286 Object.defineProperty(Component.prototype, "activated$", {
23289 return this._activated$;
23294 Object.defineProperty(Component.prototype, "defaultConfiguration", {
23296 * Get default configuration.
23298 * @returns {TConfiguration} Default configuration for component.
23301 return this._getDefaultConfiguration();
23306 Object.defineProperty(Component.prototype, "configuration$", {
23309 return this._configuration$;
23314 Object.defineProperty(Component.prototype, "name", {
23318 * @description The name of the component. Used when interacting with the
23319 * component through the Viewer's API.
23327 Component.prototype.activate = function (conf) {
23328 if (this._activated) {
23331 if (conf !== undefined) {
23332 this._configurationSubject$.next(conf);
23334 this._activated = true;
23336 this._activated$.next(true);
23338 Component.prototype.configure = function (conf) {
23339 this._configurationSubject$.next(conf);
23341 Component.prototype.deactivate = function () {
23342 if (!this._activated) {
23345 this._activated = false;
23346 this._deactivate();
23347 this._container.domRenderer.clear(this._name);
23348 this._container.glRenderer.clear(this._name);
23349 this._activated$.next(false);
23352 * Detect the viewer's new width and height and resize the component's
23353 * rendered elements accordingly if applicable.
23357 Component.prototype.resize = function () { return; };
23358 Component.componentName = "not_worthy";
23360 }(Utils_1.EventEmitter));
23361 exports.Component = Component;
23362 exports.default = Component;
23364 },{"../Utils":285,"rxjs":27,"rxjs/operators":225}],294:[function(require,module,exports){
23366 Object.defineProperty(exports, "__esModule", { value: true });
23367 var Error_1 = require("../Error");
23368 var ComponentService = /** @class */ (function () {
23369 function ComponentService(container, navigator) {
23370 this._components = {};
23371 for (var componentName in ComponentService.registeredComponents) {
23372 if (!ComponentService.registeredComponents.hasOwnProperty(componentName)) {
23375 var component = ComponentService.registeredComponents[componentName];
23376 this._components[componentName] = {
23378 component: new component(componentName, container, navigator),
23381 this._coverComponent = new ComponentService.registeredCoverComponent("cover", container, navigator);
23382 this._coverComponent.activate();
23383 this._coverActivated = true;
23385 ComponentService.register = function (component) {
23386 if (ComponentService.registeredComponents[component.componentName] === undefined) {
23387 ComponentService.registeredComponents[component.componentName] = component;
23390 ComponentService.registerCover = function (coverComponent) {
23391 ComponentService.registeredCoverComponent = coverComponent;
23393 Object.defineProperty(ComponentService.prototype, "coverActivated", {
23395 return this._coverActivated;
23400 ComponentService.prototype.activateCover = function () {
23401 if (this._coverActivated) {
23404 this._coverActivated = true;
23405 for (var componentName in this._components) {
23406 if (!this._components.hasOwnProperty(componentName)) {
23409 var component = this._components[componentName];
23410 if (component.active) {
23411 component.component.deactivate();
23415 ComponentService.prototype.deactivateCover = function () {
23416 if (!this._coverActivated) {
23419 this._coverActivated = false;
23420 for (var componentName in this._components) {
23421 if (!this._components.hasOwnProperty(componentName)) {
23424 var component = this._components[componentName];
23425 if (component.active) {
23426 component.component.activate();
23430 ComponentService.prototype.activate = function (name) {
23431 this._checkName(name);
23432 this._components[name].active = true;
23433 if (!this._coverActivated) {
23434 this.get(name).activate();
23437 ComponentService.prototype.configure = function (name, conf) {
23438 this._checkName(name);
23439 this.get(name).configure(conf);
23441 ComponentService.prototype.deactivate = function (name) {
23442 this._checkName(name);
23443 this._components[name].active = false;
23444 if (!this._coverActivated) {
23445 this.get(name).deactivate();
23448 ComponentService.prototype.get = function (name) {
23449 return this._components[name].component;
23451 ComponentService.prototype.getCover = function () {
23452 return this._coverComponent;
23454 ComponentService.prototype._checkName = function (name) {
23455 if (!(name in this._components)) {
23456 throw new Error_1.ArgumentMapillaryError("Component does not exist: " + name);
23459 ComponentService.registeredComponents = {};
23460 return ComponentService;
23462 exports.ComponentService = ComponentService;
23463 exports.default = ComponentService;
23465 },{"../Error":277}],295:[function(require,module,exports){
23467 var __extends = (this && this.__extends) || (function () {
23468 var extendStatics = function (d, b) {
23469 extendStatics = Object.setPrototypeOf ||
23470 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23471 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23472 return extendStatics(d, b);
23474 return function (d, b) {
23475 extendStatics(d, b);
23476 function __() { this.constructor = d; }
23477 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23480 Object.defineProperty(exports, "__esModule", { value: true });
23481 var rxjs_1 = require("rxjs");
23482 var operators_1 = require("rxjs/operators");
23483 var vd = require("virtual-dom");
23484 var Component_1 = require("../Component");
23485 var Utils_1 = require("../Utils");
23486 var Viewer_1 = require("../Viewer");
23487 var CoverComponent = /** @class */ (function (_super) {
23488 __extends(CoverComponent, _super);
23489 function CoverComponent(name, container, navigator) {
23490 return _super.call(this, name, container, navigator) || this;
23492 CoverComponent.prototype._activate = function () {
23494 this._configuration$.pipe(operators_1.distinctUntilChanged(undefined, function (configuration) {
23495 return configuration.state;
23496 }), operators_1.switchMap(function (configuration) {
23497 return rxjs_1.combineLatest(rxjs_1.of(configuration.state), _this._navigator.stateService.currentNode$);
23498 }), operators_1.switchMap(function (_a) {
23499 var state = _a[0], node = _a[1];
23500 var keySrc$ = rxjs_1.combineLatest(rxjs_1.of(node.key), node.image$.pipe(operators_1.filter(function (image) {
23502 }), operators_1.map(function (image) {
23505 return state === Component_1.CoverState.Visible ? keySrc$.pipe(operators_1.first()) : keySrc$;
23506 }), operators_1.distinctUntilChanged(function (_a, _b) {
23507 var k1 = _a[0], s1 = _a[1];
23508 var k2 = _b[0], s2 = _b[1];
23509 return k1 === k2 && s1 === s2;
23510 }), operators_1.map(function (_a) {
23511 var key = _a[0], src = _a[1];
23512 return { key: key, src: src };
23514 .subscribe(this._configurationSubject$);
23515 this._renderSubscription = rxjs_1.combineLatest(this._configuration$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
23516 var configuration = _a[0], size = _a[1];
23517 if (!configuration.key) {
23518 return { name: _this._name, vnode: vd.h("div", []) };
23520 var compactClass = size.width <= 640 || size.height <= 480 ? ".CoverCompact" : "";
23521 if (configuration.state === Component_1.CoverState.Hidden) {
23522 var doneContainer = vd.h("div.CoverContainer.CoverDone" + compactClass, [_this._getCoverBackgroundVNode(configuration)]);
23523 return { name: _this._name, vnode: doneContainer };
23525 var container = vd.h("div.CoverContainer" + compactClass, [_this._getCoverButtonVNode(configuration)]);
23526 return { name: _this._name, vnode: container };
23528 .subscribe(this._container.domRenderer.render$);
23530 CoverComponent.prototype._deactivate = function () {
23531 this._renderSubscription.unsubscribe();
23532 this._keySubscription.unsubscribe();
23534 CoverComponent.prototype._getDefaultConfiguration = function () {
23535 return { state: Component_1.CoverState.Visible };
23537 CoverComponent.prototype._getCoverButtonVNode = function (configuration) {
23539 var cover = configuration.state === Component_1.CoverState.Loading ? "div.Cover.CoverLoading" : "div.Cover";
23540 var coverButton = vd.h("div.CoverButton", { onclick: function () { _this.configure({ state: Component_1.CoverState.Loading }); } }, [vd.h("div.CoverButtonIcon", [])]);
23541 var coverLogo = vd.h("a.CoverLogo", { href: Utils_1.Urls.explore, target: "_blank" }, []);
23542 return vd.h(cover, [this._getCoverBackgroundVNode(configuration), coverButton, coverLogo]);
23544 CoverComponent.prototype._getCoverBackgroundVNode = function (conf) {
23545 var url = conf.src != null ?
23546 conf.src : Utils_1.Urls.thumbnail(conf.key, Viewer_1.ImageSize.Size640);
23547 var properties = { style: { backgroundImage: "url(" + url + ")" } };
23549 if (conf.state === Component_1.CoverState.Loading) {
23550 children.push(vd.h("div.Spinner", {}, []));
23552 return vd.h("div.CoverBackground", properties, children);
23554 CoverComponent.componentName = "cover";
23555 return CoverComponent;
23556 }(Component_1.Component));
23557 exports.CoverComponent = CoverComponent;
23558 Component_1.ComponentService.registerCover(CoverComponent);
23559 exports.default = CoverComponent;
23561 },{"../Component":275,"../Utils":285,"../Viewer":286,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],296:[function(require,module,exports){
23563 var __extends = (this && this.__extends) || (function () {
23564 var extendStatics = function (d, b) {
23565 extendStatics = Object.setPrototypeOf ||
23566 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23567 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23568 return extendStatics(d, b);
23570 return function (d, b) {
23571 extendStatics(d, b);
23572 function __() { this.constructor = d; }
23573 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23576 Object.defineProperty(exports, "__esModule", { value: true });
23577 var rxjs_1 = require("rxjs");
23578 var operators_1 = require("rxjs/operators");
23579 var vd = require("virtual-dom");
23580 var Component_1 = require("../Component");
23581 var DebugComponent = /** @class */ (function (_super) {
23582 __extends(DebugComponent, _super);
23583 function DebugComponent() {
23584 var _this = _super !== null && _super.apply(this, arguments) || this;
23585 _this._open$ = new rxjs_1.BehaviorSubject(false);
23588 DebugComponent.prototype._activate = function () {
23590 this._disposable = rxjs_1.combineLatest(this._navigator.stateService.currentState$, this._open$, this._navigator.imageLoadingService.loadstatus$).pipe(operators_1.map(function (_a) {
23591 var frame = _a[0], open = _a[1], loadStatus = _a[2];
23592 return { name: _this._name, vnode: _this._getDebugVNode(open, _this._getDebugInfo(frame, loadStatus)) };
23594 .subscribe(this._container.domRenderer.render$);
23596 DebugComponent.prototype._deactivate = function () {
23597 this._disposable.unsubscribe();
23599 DebugComponent.prototype._getDefaultConfiguration = function () {
23602 DebugComponent.prototype._getDebugInfo = function (frame, loadStatus) {
23604 ret.push(vd.h("h2", "Node"));
23605 if (frame.state.currentNode) {
23606 ret.push(vd.h("p", "currentNode: " + frame.state.currentNode.key));
23608 if (frame.state.previousNode) {
23609 ret.push(vd.h("p", "previousNode: " + frame.state.previousNode.key));
23611 ret.push(vd.h("h2", "Loading"));
23615 for (var key in loadStatus) {
23616 if (!loadStatus.hasOwnProperty(key)) {
23619 var status_1 = loadStatus[key];
23620 total += status_1.loaded;
23621 if (status_1.loaded !== status_1.total) {
23628 ret.push(vd.h("p", "Loaded Images: " + loaded));
23629 ret.push(vd.h("p", "Loading Images: " + loading));
23630 ret.push(vd.h("p", "Total bytes loaded: " + total));
23631 ret.push(vd.h("h2", "Camera"));
23632 ret.push(vd.h("p", "camera.position.x: " + frame.state.camera.position.x));
23633 ret.push(vd.h("p", "camera.position.y: " + frame.state.camera.position.y));
23634 ret.push(vd.h("p", "camera.position.z: " + frame.state.camera.position.z));
23635 ret.push(vd.h("p", "camera.lookat.x: " + frame.state.camera.lookat.x));
23636 ret.push(vd.h("p", "camera.lookat.y: " + frame.state.camera.lookat.y));
23637 ret.push(vd.h("p", "camera.lookat.z: " + frame.state.camera.lookat.z));
23638 ret.push(vd.h("p", "camera.up.x: " + frame.state.camera.up.x));
23639 ret.push(vd.h("p", "camera.up.y: " + frame.state.camera.up.y));
23640 ret.push(vd.h("p", "camera.up.z: " + frame.state.camera.up.z));
23643 DebugComponent.prototype._getDebugVNode = function (open, info) {
23645 return vd.h("div.Debug", {}, [
23646 vd.h("h2", {}, ["Debug"]),
23647 this._getDebugVNodeButton(open),
23648 vd.h("pre", {}, info),
23652 return this._getDebugVNodeButton(open);
23655 DebugComponent.prototype._getDebugVNodeButton = function (open) {
23656 var buttonText = open ? "Disable Debug" : "D";
23657 var buttonCssClass = open ? "" : ".DebugButtonFixed";
23659 return vd.h("button.DebugButton" + buttonCssClass, { onclick: this._closeDebugElement.bind(this) }, [buttonText]);
23662 return vd.h("button.DebugButton" + buttonCssClass, { onclick: this._openDebugElement.bind(this) }, [buttonText]);
23665 DebugComponent.prototype._closeDebugElement = function (open) {
23666 this._open$.next(false);
23668 DebugComponent.prototype._openDebugElement = function () {
23669 this._open$.next(true);
23671 DebugComponent.componentName = "debug";
23672 return DebugComponent;
23673 }(Component_1.Component));
23674 exports.DebugComponent = DebugComponent;
23675 Component_1.ComponentService.register(DebugComponent);
23676 exports.default = DebugComponent;
23678 },{"../Component":275,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],297:[function(require,module,exports){
23680 var __extends = (this && this.__extends) || (function () {
23681 var extendStatics = function (d, b) {
23682 extendStatics = Object.setPrototypeOf ||
23683 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23684 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23685 return extendStatics(d, b);
23687 return function (d, b) {
23688 extendStatics(d, b);
23689 function __() { this.constructor = d; }
23690 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23693 Object.defineProperty(exports, "__esModule", { value: true });
23694 var rxjs_1 = require("rxjs");
23695 var operators_1 = require("rxjs/operators");
23696 var vd = require("virtual-dom");
23697 var Component_1 = require("../Component");
23698 var Utils_1 = require("../Utils");
23699 var ImageComponent = /** @class */ (function (_super) {
23700 __extends(ImageComponent, _super);
23701 function ImageComponent(name, container, navigator, dom) {
23702 var _this = _super.call(this, name, container, navigator) || this;
23703 _this._canvasId = container.id + "-" + _this._name;
23704 _this._dom = !!dom ? dom : new Utils_1.DOM();
23707 ImageComponent.prototype._activate = function () {
23709 var canvasSize$ = this._container.domRenderer.element$.pipe(operators_1.map(function (element) {
23710 return _this._dom.document.getElementById(_this._canvasId);
23711 }), operators_1.filter(function (canvas) {
23713 }), operators_1.map(function (canvas) {
23714 var adaptableDomRenderer = canvas.parentElement;
23715 var width = adaptableDomRenderer.offsetWidth;
23716 var height = adaptableDomRenderer.offsetHeight;
23717 return [canvas, { height: height, width: width }];
23718 }), operators_1.distinctUntilChanged(function (s1, s2) {
23719 return s1.height === s2.height && s1.width === s2.width;
23721 var canvas = _a[0], size = _a[1];
23724 this.drawSubscription = rxjs_1.combineLatest(canvasSize$, this._navigator.stateService.currentNode$)
23725 .subscribe(function (_a) {
23726 var _b = _a[0], canvas = _b[0], size = _b[1], node = _a[1];
23727 canvas.width = size.width;
23728 canvas.height = size.height;
23731 .drawImage(node.image, 0, 0, size.width, size.height);
23733 this._container.domRenderer.renderAdaptive$.next({ name: this._name, vnode: vd.h("canvas#" + this._canvasId, []) });
23735 ImageComponent.prototype._deactivate = function () {
23736 this.drawSubscription.unsubscribe();
23738 ImageComponent.prototype._getDefaultConfiguration = function () {
23741 ImageComponent.componentName = "image";
23742 return ImageComponent;
23743 }(Component_1.Component));
23744 exports.ImageComponent = ImageComponent;
23745 Component_1.ComponentService.register(ImageComponent);
23746 exports.default = ImageComponent;
23749 },{"../Component":275,"../Utils":285,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],298:[function(require,module,exports){
23751 var __extends = (this && this.__extends) || (function () {
23752 var extendStatics = function (d, b) {
23753 extendStatics = Object.setPrototypeOf ||
23754 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23755 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23756 return extendStatics(d, b);
23758 return function (d, b) {
23759 extendStatics(d, b);
23760 function __() { this.constructor = d; }
23761 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23764 Object.defineProperty(exports, "__esModule", { value: true });
23765 var rxjs_1 = require("rxjs");
23766 var operators_1 = require("rxjs/operators");
23767 var vd = require("virtual-dom");
23768 var Component_1 = require("../Component");
23769 var LoadingComponent = /** @class */ (function (_super) {
23770 __extends(LoadingComponent, _super);
23771 function LoadingComponent(name, container, navigator) {
23772 return _super.call(this, name, container, navigator) || this;
23774 LoadingComponent.prototype._activate = function () {
23776 this._loadingSubscription = this._navigator.loadingService.loading$.pipe(operators_1.switchMap(function (loading) {
23778 _this._navigator.imageLoadingService.loadstatus$ :
23780 }), operators_1.map(function (loadStatus) {
23783 for (var key in loadStatus) {
23784 if (!loadStatus.hasOwnProperty(key)) {
23787 var status_1 = loadStatus[key];
23788 if (status_1.loaded !== status_1.total) {
23789 loaded += status_1.loaded;
23790 total += status_1.total;
23793 var percentage = 100;
23795 percentage = (loaded / total) * 100;
23797 return { name: _this._name, vnode: _this._getBarVNode(percentage) };
23799 .subscribe(this._container.domRenderer.render$);
23801 LoadingComponent.prototype._deactivate = function () {
23802 this._loadingSubscription.unsubscribe();
23804 LoadingComponent.prototype._getDefaultConfiguration = function () {
23807 LoadingComponent.prototype._getBarVNode = function (percentage) {
23808 var loadingBarStyle = {};
23809 var loadingContainerStyle = {};
23810 if (percentage !== 100) {
23811 loadingBarStyle.width = percentage.toFixed(0) + "%";
23812 loadingBarStyle.opacity = "1";
23815 loadingBarStyle.width = "100%";
23816 loadingBarStyle.opacity = "0";
23818 return vd.h("div.Loading", { style: loadingContainerStyle }, [vd.h("div.LoadingBar", { style: loadingBarStyle }, [])]);
23820 LoadingComponent.componentName = "loading";
23821 return LoadingComponent;
23822 }(Component_1.Component));
23823 exports.LoadingComponent = LoadingComponent;
23824 Component_1.ComponentService.register(LoadingComponent);
23825 exports.default = LoadingComponent;
23827 },{"../Component":275,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],299:[function(require,module,exports){
23829 var __extends = (this && this.__extends) || (function () {
23830 var extendStatics = function (d, b) {
23831 extendStatics = Object.setPrototypeOf ||
23832 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23833 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23834 return extendStatics(d, b);
23836 return function (d, b) {
23837 extendStatics(d, b);
23838 function __() { this.constructor = d; }
23839 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23842 Object.defineProperty(exports, "__esModule", { value: true });
23843 var rxjs_1 = require("rxjs");
23844 var operators_1 = require("rxjs/operators");
23845 var vd = require("virtual-dom");
23846 var Edge_1 = require("../Edge");
23847 var Error_1 = require("../Error");
23848 var Component_1 = require("../Component");
23850 * @class NavigationComponent
23852 * @classdesc Fallback navigation component for environments without WebGL support.
23854 * Replaces the functionality in the Direction and Sequence components.
23856 var NavigationComponent = /** @class */ (function (_super) {
23857 __extends(NavigationComponent, _super);
23859 function NavigationComponent(name, container, navigator) {
23860 var _this = _super.call(this, name, container, navigator) || this;
23861 _this._seqNames = {};
23862 _this._seqNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.Prev]] = "Prev";
23863 _this._seqNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.Next]] = "Next";
23864 _this._spaTopNames = {};
23865 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnLeft]] = "Turnleft";
23866 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepLeft]] = "Left";
23867 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepForward]] = "Forward";
23868 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepRight]] = "Right";
23869 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnRight]] = "Turnright";
23870 _this._spaBottomNames = {};
23871 _this._spaBottomNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnU]] = "Turnaround";
23872 _this._spaBottomNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepBackward]] = "Backward";
23875 NavigationComponent.prototype._activate = function () {
23877 this._renderSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, this._configuration$).pipe(operators_1.switchMap(function (_a) {
23878 var node = _a[0], configuration = _a[1];
23879 var sequenceEdges$ = configuration.sequence ?
23880 node.sequenceEdges$.pipe(operators_1.map(function (status) {
23881 return status.edges
23882 .map(function (edge) {
23883 return edge.data.direction;
23887 var spatialEdges$ = !node.pano && configuration.spatial ?
23888 node.spatialEdges$.pipe(operators_1.map(function (status) {
23889 return status.edges
23890 .map(function (edge) {
23891 return edge.data.direction;
23895 return rxjs_1.combineLatest(sequenceEdges$, spatialEdges$).pipe(operators_1.map(function (_a) {
23896 var seq = _a[0], spa = _a[1];
23897 return seq.concat(spa);
23899 }), operators_1.map(function (edgeDirections) {
23900 var seqs = _this._createArrowRow(_this._seqNames, edgeDirections);
23901 var spaTops = _this._createArrowRow(_this._spaTopNames, edgeDirections);
23902 var spaBottoms = _this._createArrowRow(_this._spaBottomNames, edgeDirections);
23903 var seqContainer = vd.h("div.NavigationSequence", seqs);
23904 var spaTopContainer = vd.h("div.NavigationSpatialTop", spaTops);
23905 var spaBottomContainer = vd.h("div.NavigationSpatialBottom", spaBottoms);
23906 var spaContainer = vd.h("div.NavigationSpatial", [spaTopContainer, spaBottomContainer]);
23907 return { name: _this._name, vnode: vd.h("div.NavigationContainer", [seqContainer, spaContainer]) };
23909 .subscribe(this._container.domRenderer.render$);
23911 NavigationComponent.prototype._deactivate = function () {
23912 this._renderSubscription.unsubscribe();
23914 NavigationComponent.prototype._getDefaultConfiguration = function () {
23915 return { sequence: true, spatial: true };
23917 NavigationComponent.prototype._createArrowRow = function (arrowNames, edgeDirections) {
23919 for (var arrowName in arrowNames) {
23920 if (!(arrowNames.hasOwnProperty(arrowName))) {
23923 var direction = Edge_1.EdgeDirection[arrowName];
23924 if (edgeDirections.indexOf(direction) !== -1) {
23925 arrows.push(this._createVNode(direction, arrowNames[arrowName], "visible"));
23928 arrows.push(this._createVNode(direction, arrowNames[arrowName], "hidden"));
23933 NavigationComponent.prototype._createVNode = function (direction, name, visibility) {
23935 return vd.h("span.Direction.Direction" + name, {
23936 onclick: function (ev) {
23937 _this._navigator.moveDir$(direction)
23938 .subscribe(undefined, function (error) {
23939 if (!(error instanceof Error_1.AbortMapillaryError)) {
23940 console.error(error);
23945 visibility: visibility,
23949 NavigationComponent.componentName = "navigation";
23950 return NavigationComponent;
23951 }(Component_1.Component));
23952 exports.NavigationComponent = NavigationComponent;
23953 Component_1.ComponentService.register(NavigationComponent);
23954 exports.default = NavigationComponent;
23956 },{"../Component":275,"../Edge":276,"../Error":277,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],300:[function(require,module,exports){
23958 var __extends = (this && this.__extends) || (function () {
23959 var extendStatics = function (d, b) {
23960 extendStatics = Object.setPrototypeOf ||
23961 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23962 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23963 return extendStatics(d, b);
23965 return function (d, b) {
23966 extendStatics(d, b);
23967 function __() { this.constructor = d; }
23968 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23971 Object.defineProperty(exports, "__esModule", { value: true });
23972 var rxjs_1 = require("rxjs");
23973 var operators_1 = require("rxjs/operators");
23974 var vd = require("virtual-dom");
23975 var Component_1 = require("../Component");
23976 var DescriptionState = /** @class */ (function () {
23977 function DescriptionState() {
23979 return DescriptionState;
23981 var RouteState = /** @class */ (function () {
23982 function RouteState() {
23986 var RouteTrack = /** @class */ (function () {
23987 function RouteTrack() {
23988 this.nodeInstructions = [];
23989 this.nodeInstructionsOrdered = [];
23993 var RouteComponent = /** @class */ (function (_super) {
23994 __extends(RouteComponent, _super);
23995 function RouteComponent(name, container, navigator) {
23996 return _super.call(this, name, container, navigator) || this;
23998 RouteComponent.prototype._activate = function () {
24000 var slowedStream$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
24001 return (frame.id % 2) === 0;
24002 }), operators_1.filter(function (frame) {
24003 return frame.state.nodesAhead < 15;
24004 }), operators_1.distinctUntilChanged(undefined, function (frame) {
24005 return frame.state.lastNode.key;
24007 var routeTrack$ = rxjs_1.combineLatest(this.configuration$.pipe(operators_1.mergeMap(function (conf) {
24008 return rxjs_1.from(conf.paths);
24009 }), operators_1.distinct(function (p) {
24010 return p.sequenceKey;
24011 }), operators_1.mergeMap(function (path) {
24012 return _this._navigator.apiV3.sequenceByKey$([path.sequenceKey]).pipe(operators_1.map(function (sequenceByKey) {
24013 return sequenceByKey[path.sequenceKey];
24015 })), this.configuration$).pipe(operators_1.map(function (_a) {
24016 var sequence = _a[0], conf = _a[1];
24018 var instructionPlaces = [];
24019 for (var _i = 0, _b = conf.paths; _i < _b.length; _i++) {
24021 if (path.sequenceKey === sequence.key) {
24022 var nodeInstructions = [];
24023 var saveKey = false;
24024 for (var _c = 0, _d = sequence.keys; _c < _d.length; _c++) {
24026 if (path.startKey === key) {
24030 var description = null;
24031 for (var _e = 0, _f = path.infoKeys; _e < _f.length; _e++) {
24032 var infoKey = _f[_e];
24033 if (infoKey.key === key) {
24034 description = infoKey.description;
24037 nodeInstructions.push({ description: description, key: key });
24039 if (path.stopKey === key) {
24043 instructionPlaces.push({ nodeInstructions: nodeInstructions, place: i });
24047 return instructionPlaces;
24048 }), operators_1.scan(function (routeTrack, instructionPlaces) {
24049 for (var _i = 0, instructionPlaces_1 = instructionPlaces; _i < instructionPlaces_1.length; _i++) {
24050 var instructionPlace = instructionPlaces_1[_i];
24051 routeTrack.nodeInstructionsOrdered[instructionPlace.place] = instructionPlace.nodeInstructions;
24053 for (var place in routeTrack.nodeInstructionsOrdered) {
24054 if (!routeTrack.nodeInstructionsOrdered.hasOwnProperty(place)) {
24057 var instructionGroup = routeTrack.nodeInstructionsOrdered[place];
24058 for (var _a = 0, instructionGroup_1 = instructionGroup; _a < instructionGroup_1.length; _a++) {
24059 var instruction = instructionGroup_1[_a];
24060 routeTrack.nodeInstructions.push(instruction);
24064 }, new RouteTrack()));
24065 var cacheNode$ = rxjs_1.combineLatest(slowedStream$, routeTrack$, this.configuration$).pipe(operators_1.map(function (_a) {
24066 var frame = _a[0], routeTrack = _a[1], conf = _a[2];
24067 return { conf: conf, frame: frame, routeTrack: routeTrack };
24068 }), operators_1.scan(function (routeState, rtAndFrame) {
24069 if (rtAndFrame.conf.playing === undefined || rtAndFrame.conf.playing) {
24070 routeState.routeTrack = rtAndFrame.routeTrack;
24071 routeState.currentNode = rtAndFrame.frame.state.currentNode;
24072 routeState.lastNode = rtAndFrame.frame.state.lastNode;
24073 routeState.playing = true;
24076 _this._navigator.stateService.cutNodes();
24077 routeState.playing = false;
24080 }, new RouteState()), operators_1.filter(function (routeState) {
24081 return routeState.playing;
24082 }), operators_1.filter(function (routeState) {
24083 for (var _i = 0, _a = routeState.routeTrack.nodeInstructions; _i < _a.length; _i++) {
24084 var nodeInstruction = _a[_i];
24085 if (!nodeInstruction) {
24088 if (nodeInstruction.key === routeState.lastNode.key) {
24093 }), operators_1.distinctUntilChanged(undefined, function (routeState) {
24094 return routeState.lastNode.key;
24095 }), operators_1.mergeMap(function (routeState) {
24097 for (var _i = 0, _a = routeState.routeTrack.nodeInstructions; _i < _a.length; _i++) {
24098 var nodeInstruction = _a[_i];
24099 if (nodeInstruction.key === routeState.lastNode.key) {
24104 var nextInstruction = routeState.routeTrack.nodeInstructions[i + 1];
24105 if (!nextInstruction) {
24106 return rxjs_1.of(null);
24108 return _this._navigator.graphService.cacheNode$(nextInstruction.key);
24110 this._disposable = rxjs_1.combineLatest(cacheNode$, this.configuration$).pipe(operators_1.map(function (_a) {
24111 var node = _a[0], conf = _a[1];
24112 return { conf: conf, node: node };
24113 }), operators_1.filter(function (cAN) {
24114 return cAN.node !== null && cAN.conf.playing;
24115 }), operators_1.pluck("node"))
24116 .subscribe(this._navigator.stateService.appendNode$);
24117 this._disposableDescription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, routeTrack$, this.configuration$).pipe(operators_1.map(function (_a) {
24118 var node = _a[0], routeTrack = _a[1], conf = _a[2];
24119 if (conf.playing !== undefined && !conf.playing) {
24122 var description = null;
24123 for (var _i = 0, _b = routeTrack.nodeInstructions; _i < _b.length; _i++) {
24124 var nodeInstruction = _b[_i];
24125 if (nodeInstruction.key === node.key) {
24126 description = nodeInstruction.description;
24130 return description;
24131 }), operators_1.scan(function (descriptionState, description) {
24132 if (description !== descriptionState.description && description !== null) {
24133 descriptionState.description = description;
24134 descriptionState.showsLeft = 6;
24137 descriptionState.showsLeft--;
24139 if (description === "quit") {
24140 descriptionState.description = null;
24142 return descriptionState;
24143 }, new DescriptionState()), operators_1.map(function (descriptionState) {
24144 if (descriptionState.showsLeft > 0 && descriptionState.description) {
24145 return { name: _this._name, vnode: _this._getRouteAnnotationNode(descriptionState.description) };
24148 return { name: _this._name, vnode: vd.h("div", []) };
24151 .subscribe(this._container.domRenderer.render$);
24153 RouteComponent.prototype._deactivate = function () {
24154 this._disposable.unsubscribe();
24155 this._disposableDescription.unsubscribe();
24157 RouteComponent.prototype._getDefaultConfiguration = function () {
24160 RouteComponent.prototype.play = function () {
24161 this.configure({ playing: true });
24163 RouteComponent.prototype.stop = function () {
24164 this.configure({ playing: false });
24166 RouteComponent.prototype._getRouteAnnotationNode = function (description) {
24167 return vd.h("div.RouteFrame", {}, [
24168 vd.h("p", { textContent: description }, []),
24171 RouteComponent.componentName = "route";
24172 return RouteComponent;
24173 }(Component_1.Component));
24174 exports.RouteComponent = RouteComponent;
24175 Component_1.ComponentService.register(RouteComponent);
24176 exports.default = RouteComponent;
24178 },{"../Component":275,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],301:[function(require,module,exports){
24180 var __extends = (this && this.__extends) || (function () {
24181 var extendStatics = function (d, b) {
24182 extendStatics = Object.setPrototypeOf ||
24183 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24184 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
24185 return extendStatics(d, b);
24187 return function (d, b) {
24188 extendStatics(d, b);
24189 function __() { this.constructor = d; }
24190 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24193 Object.defineProperty(exports, "__esModule", { value: true });
24194 var rxjs_1 = require("rxjs");
24195 var operators_1 = require("rxjs/operators");
24196 var Component_1 = require("../Component");
24197 var StatsComponent = /** @class */ (function (_super) {
24198 __extends(StatsComponent, _super);
24199 function StatsComponent(name, container, navigator, scheduler) {
24200 var _this = _super.call(this, name, container, navigator) || this;
24201 _this._scheduler = scheduler;
24204 StatsComponent.prototype._activate = function () {
24206 this._sequenceSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.scan(function (keys, node) {
24207 var sKey = node.sequenceKey;
24209 if (!(sKey in keys.reported)) {
24210 keys.report = [sKey];
24211 keys.reported[sKey] = true;
24214 }, { report: [], reported: {} }), operators_1.filter(function (keys) {
24215 return keys.report.length > 0;
24216 }), operators_1.mergeMap(function (keys) {
24217 return _this._navigator.apiV3.sequenceViewAdd$(keys.report).pipe(operators_1.catchError(function (error, caught) {
24218 console.error("Failed to report sequence stats (" + keys.report + ")", error);
24219 return rxjs_1.empty();
24222 .subscribe(function () { });
24223 this._imageSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
24225 })).pipe(operators_1.buffer(this._navigator.stateService.currentNode$.pipe(operators_1.debounceTime(5000, this._scheduler))), operators_1.scan(function (keys, newKeys) {
24227 for (var _i = 0, newKeys_1 = newKeys; _i < newKeys_1.length; _i++) {
24228 var key = newKeys_1[_i];
24229 if (!(key in keys.reported)) {
24230 keys.report.push(key);
24231 keys.reported[key] = true;
24235 }, { report: [], reported: {} }), operators_1.filter(function (keys) {
24236 return keys.report.length > 0;
24237 }), operators_1.mergeMap(function (keys) {
24238 return _this._navigator.apiV3.imageViewAdd$(keys.report).pipe(operators_1.catchError(function (error, caught) {
24239 console.error("Failed to report image stats (" + keys.report + ")", error);
24240 return rxjs_1.empty();
24243 .subscribe(function () { });
24245 StatsComponent.prototype._deactivate = function () {
24246 this._sequenceSubscription.unsubscribe();
24247 this._imageSubscription.unsubscribe();
24249 StatsComponent.prototype._getDefaultConfiguration = function () {
24252 StatsComponent.componentName = "stats";
24253 return StatsComponent;
24254 }(Component_1.Component));
24255 exports.StatsComponent = StatsComponent;
24256 Component_1.ComponentService.register(StatsComponent);
24257 exports.default = StatsComponent;
24259 },{"../Component":275,"rxjs":27,"rxjs/operators":225}],302:[function(require,module,exports){
24261 var __extends = (this && this.__extends) || (function () {
24262 var extendStatics = function (d, b) {
24263 extendStatics = Object.setPrototypeOf ||
24264 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24265 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
24266 return extendStatics(d, b);
24268 return function (d, b) {
24269 extendStatics(d, b);
24270 function __() { this.constructor = d; }
24271 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24274 Object.defineProperty(exports, "__esModule", { value: true });
24275 var vd = require("virtual-dom");
24276 var rxjs_1 = require("rxjs");
24277 var operators_1 = require("rxjs/operators");
24278 var Component_1 = require("../../Component");
24280 * @class DirectionComponent
24281 * @classdesc Component showing navigation arrows for steps and turns.
24283 var DirectionComponent = /** @class */ (function (_super) {
24284 __extends(DirectionComponent, _super);
24285 function DirectionComponent(name, container, navigator, directionDOMRenderer) {
24286 var _this = _super.call(this, name, container, navigator) || this;
24287 _this._renderer = !!directionDOMRenderer ?
24288 directionDOMRenderer :
24289 new Component_1.DirectionDOMRenderer(_this.defaultConfiguration, { height: container.element.offsetHeight, width: container.element.offsetWidth });
24290 _this._hoveredKeySubject$ = new rxjs_1.Subject();
24291 _this._hoveredKey$ = _this._hoveredKeySubject$.pipe(operators_1.share());
24294 Object.defineProperty(DirectionComponent.prototype, "hoveredKey$", {
24296 * Get hovered key observable.
24298 * @description An observable emitting the key of the node for the direction
24299 * arrow that is being hovered. When the mouse leaves a direction arrow null
24302 * @returns {Observable<string>}
24305 return this._hoveredKey$;
24311 * Set highlight key.
24313 * @description The arrow pointing towards the node corresponding to the
24314 * highlight key will be highlighted.
24316 * @param {string} highlightKey Key of node to be highlighted if existing
24319 DirectionComponent.prototype.setHighlightKey = function (highlightKey) {
24320 this.configure({ highlightKey: highlightKey });
24323 * Set min width of container element.
24325 * @description Set min width of the non transformed container element holding
24326 * the navigation arrows. If the min width is larger than the max width the
24327 * min width value will be used.
24329 * The container element is automatically resized when the resize
24330 * method on the Viewer class is called.
24332 * @param {number} minWidth
24334 DirectionComponent.prototype.setMinWidth = function (minWidth) {
24335 this.configure({ minWidth: minWidth });
24338 * Set max width of container element.
24340 * @description Set max width of the non transformed container element holding
24341 * the navigation arrows. If the min width is larger than the max width the
24342 * min width value will be used.
24344 * The container element is automatically resized when the resize
24345 * method on the Viewer class is called.
24347 * @param {number} minWidth
24349 DirectionComponent.prototype.setMaxWidth = function (maxWidth) {
24350 this.configure({ maxWidth: maxWidth });
24352 DirectionComponent.prototype._activate = function () {
24354 this._configurationSubscription = this._configuration$
24355 .subscribe(function (configuration) {
24356 _this._renderer.setConfiguration(configuration);
24358 this._resizeSubscription = this._container.renderService.size$
24359 .subscribe(function (size) {
24360 _this._renderer.resize(size);
24362 this._nodeSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.tap(function (node) {
24363 _this._container.domRenderer.render$.next({ name: _this._name, vnode: vd.h("div", {}, []) });
24364 _this._renderer.setNode(node);
24365 }), operators_1.withLatestFrom(this._configuration$), operators_1.switchMap(function (_a) {
24366 var node = _a[0], configuration = _a[1];
24367 return rxjs_1.combineLatest(node.spatialEdges$, configuration.distinguishSequence ?
24368 _this._navigator.graphService
24369 .cacheSequence$(node.sequenceKey).pipe(operators_1.catchError(function (error, caught) {
24370 console.error("Failed to cache sequence (" + node.sequenceKey + ")", error);
24371 return rxjs_1.of(null);
24375 .subscribe(function (_a) {
24376 var edgeStatus = _a[0], sequence = _a[1];
24377 _this._renderer.setEdges(edgeStatus, sequence);
24379 this._renderCameraSubscription = this._container.renderService.renderCameraFrame$.pipe(operators_1.tap(function (renderCamera) {
24380 _this._renderer.setRenderCamera(renderCamera);
24381 }), operators_1.map(function () {
24382 return _this._renderer;
24383 }), operators_1.filter(function (renderer) {
24384 return renderer.needsRender;
24385 }), operators_1.map(function (renderer) {
24386 return { name: _this._name, vnode: renderer.render(_this._navigator) };
24388 .subscribe(this._container.domRenderer.render$);
24389 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) {
24390 var element = _a[0];
24391 var elements = element.getElementsByClassName("DirectionsPerspective");
24392 for (var i = 0; i < elements.length; i++) {
24393 var hovered = elements.item(i).querySelector(":hover");
24394 if (hovered != null && hovered.hasAttribute("data-key")) {
24395 return hovered.getAttribute("data-key");
24399 }), operators_1.distinctUntilChanged())
24400 .subscribe(this._hoveredKeySubject$);
24401 this._emitHoveredKeySubscription = this._hoveredKey$
24402 .subscribe(function (key) {
24403 _this.fire(DirectionComponent.hoveredkeychanged, key);
24406 DirectionComponent.prototype._deactivate = function () {
24407 this._configurationSubscription.unsubscribe();
24408 this._emitHoveredKeySubscription.unsubscribe();
24409 this._hoveredKeySubscription.unsubscribe();
24410 this._nodeSubscription.unsubscribe();
24411 this._renderCameraSubscription.unsubscribe();
24413 DirectionComponent.prototype._getDefaultConfiguration = function () {
24415 distinguishSequence: false,
24421 DirectionComponent.componentName = "direction";
24423 * Event fired when the hovered key changes.
24425 * @description Emits the key of the node for the direction
24426 * arrow that is being hovered. When the mouse leaves a
24427 * direction arrow null is emitted.
24429 * @event DirectionComponent#hoveredkeychanged
24430 * @type {string} The hovered key, null if no key is hovered.
24432 DirectionComponent.hoveredkeychanged = "hoveredkeychanged";
24433 return DirectionComponent;
24434 }(Component_1.Component));
24435 exports.DirectionComponent = DirectionComponent;
24436 Component_1.ComponentService.register(DirectionComponent);
24437 exports.default = DirectionComponent;
24440 },{"../../Component":275,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],303:[function(require,module,exports){
24442 Object.defineProperty(exports, "__esModule", { value: true });
24443 var Geo_1 = require("../../Geo");
24445 * @class DirectionDOMCalculator
24446 * @classdesc Helper class for calculating DOM CSS properties.
24448 var DirectionDOMCalculator = /** @class */ (function () {
24449 function DirectionDOMCalculator(configuration, size) {
24450 this._spatial = new Geo_1.Spatial();
24451 this._minThresholdWidth = 320;
24452 this._maxThresholdWidth = 1480;
24453 this._minThresholdHeight = 240;
24454 this._maxThresholdHeight = 820;
24455 this._configure(configuration);
24456 this._resize(size);
24459 Object.defineProperty(DirectionDOMCalculator.prototype, "minWidth", {
24461 return this._minWidth;
24466 Object.defineProperty(DirectionDOMCalculator.prototype, "maxWidth", {
24468 return this._maxWidth;
24473 Object.defineProperty(DirectionDOMCalculator.prototype, "containerWidth", {
24475 return this._containerWidth;
24480 Object.defineProperty(DirectionDOMCalculator.prototype, "containerWidthCss", {
24482 return this._containerWidthCss;
24487 Object.defineProperty(DirectionDOMCalculator.prototype, "containerMarginCss", {
24489 return this._containerMarginCss;
24494 Object.defineProperty(DirectionDOMCalculator.prototype, "containerLeftCss", {
24496 return this._containerLeftCss;
24501 Object.defineProperty(DirectionDOMCalculator.prototype, "containerHeight", {
24503 return this._containerHeight;
24508 Object.defineProperty(DirectionDOMCalculator.prototype, "containerHeightCss", {
24510 return this._containerHeightCss;
24515 Object.defineProperty(DirectionDOMCalculator.prototype, "containerBottomCss", {
24517 return this._containerBottomCss;
24522 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleSize", {
24524 return this._stepCircleSize;
24529 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleSizeCss", {
24531 return this._stepCircleSizeCss;
24536 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleMarginCss", {
24538 return this._stepCircleMarginCss;
24543 Object.defineProperty(DirectionDOMCalculator.prototype, "turnCircleSize", {
24545 return this._turnCircleSize;
24550 Object.defineProperty(DirectionDOMCalculator.prototype, "turnCircleSizeCss", {
24552 return this._turnCircleSizeCss;
24557 Object.defineProperty(DirectionDOMCalculator.prototype, "outerRadius", {
24559 return this._outerRadius;
24564 Object.defineProperty(DirectionDOMCalculator.prototype, "innerRadius", {
24566 return this._innerRadius;
24571 Object.defineProperty(DirectionDOMCalculator.prototype, "shadowOffset", {
24573 return this._shadowOffset;
24579 * Configures the min and max width values.
24581 * @param {IDirectionConfiguration} configuration Configuration
24582 * with min and max width values.
24584 DirectionDOMCalculator.prototype.configure = function (configuration) {
24585 this._configure(configuration);
24589 * Resizes all properties according to the width and height
24590 * of the size object.
24592 * @param {ISize} size The size of the container element.
24594 DirectionDOMCalculator.prototype.resize = function (size) {
24595 this._resize(size);
24599 * Calculates the coordinates on the unit circle for an angle.
24601 * @param {number} angle Angle in radians.
24602 * @returns {Array<number>} The x and y coordinates on the unit circle.
24604 DirectionDOMCalculator.prototype.angleToCoordinates = function (angle) {
24605 return [Math.cos(angle), Math.sin(angle)];
24608 * Calculates the coordinates on the unit circle for the
24609 * relative angle between the first and second angle.
24611 * @param {number} first Angle in radians.
24612 * @param {number} second Angle in radians.
24613 * @returns {Array<number>} The x and y coordinates on the unit circle
24614 * for the relative angle between the first and second angle.
24616 DirectionDOMCalculator.prototype.relativeAngleToCoordiantes = function (first, second) {
24617 var relativeAngle = this._spatial.wrapAngle(first - second);
24618 return this.angleToCoordinates(relativeAngle);
24620 DirectionDOMCalculator.prototype._configure = function (configuration) {
24621 this._minWidth = configuration.minWidth;
24622 this._maxWidth = this._getMaxWidth(configuration.minWidth, configuration.maxWidth);
24624 DirectionDOMCalculator.prototype._resize = function (size) {
24625 this._elementWidth = size.width;
24626 this._elementHeight = size.height;
24628 DirectionDOMCalculator.prototype._reset = function () {
24629 this._containerWidth = this._getContainerWidth(this._elementWidth, this._elementHeight);
24630 this._containerHeight = this._getContainerHeight(this.containerWidth);
24631 this._stepCircleSize = this._getStepCircleDiameter(this._containerHeight);
24632 this._turnCircleSize = this._getTurnCircleDiameter(this.containerHeight);
24633 this._outerRadius = this._getOuterRadius(this._containerHeight);
24634 this._innerRadius = this._getInnerRadius(this._containerHeight);
24635 this._shadowOffset = 3;
24636 this._containerWidthCss = this._numberToCssPixels(this._containerWidth);
24637 this._containerMarginCss = this._numberToCssPixels(-0.5 * this._containerWidth);
24638 this._containerLeftCss = this._numberToCssPixels(Math.floor(0.5 * this._elementWidth));
24639 this._containerHeightCss = this._numberToCssPixels(this._containerHeight);
24640 this._containerBottomCss = this._numberToCssPixels(Math.floor(-0.08 * this._containerHeight));
24641 this._stepCircleSizeCss = this._numberToCssPixels(this._stepCircleSize);
24642 this._stepCircleMarginCss = this._numberToCssPixels(-0.5 * this._stepCircleSize);
24643 this._turnCircleSizeCss = this._numberToCssPixels(this._turnCircleSize);
24645 DirectionDOMCalculator.prototype._getContainerWidth = function (elementWidth, elementHeight) {
24646 var relativeWidth = (elementWidth - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth);
24647 var relativeHeight = (elementHeight - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight);
24648 var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight)));
24649 coeff = 0.04 * Math.round(25 * coeff);
24650 return this._minWidth + coeff * (this._maxWidth - this._minWidth);
24652 DirectionDOMCalculator.prototype._getContainerHeight = function (containerWidth) {
24653 return 0.77 * containerWidth;
24655 DirectionDOMCalculator.prototype._getStepCircleDiameter = function (containerHeight) {
24656 return 0.34 * containerHeight;
24658 DirectionDOMCalculator.prototype._getTurnCircleDiameter = function (containerHeight) {
24659 return 0.3 * containerHeight;
24661 DirectionDOMCalculator.prototype._getOuterRadius = function (containerHeight) {
24662 return 0.31 * containerHeight;
24664 DirectionDOMCalculator.prototype._getInnerRadius = function (containerHeight) {
24665 return 0.125 * containerHeight;
24667 DirectionDOMCalculator.prototype._numberToCssPixels = function (value) {
24668 return value + "px";
24670 DirectionDOMCalculator.prototype._getMaxWidth = function (value, minWidth) {
24671 return value > minWidth ? value : minWidth;
24673 return DirectionDOMCalculator;
24675 exports.DirectionDOMCalculator = DirectionDOMCalculator;
24676 exports.default = DirectionDOMCalculator;
24679 },{"../../Geo":278}],304:[function(require,module,exports){
24681 Object.defineProperty(exports, "__esModule", { value: true });
24682 var vd = require("virtual-dom");
24683 var Component_1 = require("../../Component");
24684 var Edge_1 = require("../../Edge");
24685 var Error_1 = require("../../Error");
24686 var Geo_1 = require("../../Geo");
24688 * @class DirectionDOMRenderer
24689 * @classdesc DOM renderer for direction arrows.
24691 var DirectionDOMRenderer = /** @class */ (function () {
24692 function DirectionDOMRenderer(configuration, size) {
24693 this._isEdge = false;
24694 this._spatial = new Geo_1.Spatial();
24695 this._calculator = new Component_1.DirectionDOMCalculator(configuration, size);
24697 this._rotation = { phi: 0, theta: 0 };
24698 this._epsilon = 0.5 * Math.PI / 180;
24699 this._highlightKey = null;
24700 this._distinguishSequence = false;
24701 this._needsRender = false;
24702 this._stepEdges = [];
24703 this._turnEdges = [];
24704 this._panoEdges = [];
24705 this._sequenceEdgeKeys = [];
24706 this._stepDirections = [
24707 Edge_1.EdgeDirection.StepForward,
24708 Edge_1.EdgeDirection.StepBackward,
24709 Edge_1.EdgeDirection.StepLeft,
24710 Edge_1.EdgeDirection.StepRight,
24712 this._turnDirections = [
24713 Edge_1.EdgeDirection.TurnLeft,
24714 Edge_1.EdgeDirection.TurnRight,
24715 Edge_1.EdgeDirection.TurnU,
24717 this._turnNames = {};
24718 this._turnNames[Edge_1.EdgeDirection.TurnLeft] = "TurnLeft";
24719 this._turnNames[Edge_1.EdgeDirection.TurnRight] = "TurnRight";
24720 this._turnNames[Edge_1.EdgeDirection.TurnU] = "TurnAround";
24721 // detects IE 8-11, then Edge 20+.
24722 var isIE = !!document.documentMode;
24723 this._isEdge = !isIE && !!window.StyleMedia;
24725 Object.defineProperty(DirectionDOMRenderer.prototype, "needsRender", {
24727 * Get needs render.
24729 * @returns {boolean} Value indicating whether render should be called.
24732 return this._needsRender;
24738 * Renders virtual DOM elements.
24740 * @description Calling render resets the needs render property.
24742 DirectionDOMRenderer.prototype.render = function (navigator) {
24743 this._needsRender = false;
24744 var rotation = this._rotation;
24747 if (this._node.pano) {
24748 steps = steps.concat(this._createPanoArrows(navigator, rotation));
24751 steps = steps.concat(this._createPerspectiveToPanoArrows(navigator, rotation));
24752 steps = steps.concat(this._createStepArrows(navigator, rotation));
24753 turns = turns.concat(this._createTurnArrows(navigator));
24755 return this._getContainer(steps, turns, rotation);
24757 DirectionDOMRenderer.prototype.setEdges = function (edgeStatus, sequence) {
24758 this._setEdges(edgeStatus, sequence);
24759 this._setNeedsRender();
24762 * Set node for which to show edges.
24764 * @param {Node} node
24766 DirectionDOMRenderer.prototype.setNode = function (node) {
24768 this._clearEdges();
24769 this._setNeedsRender();
24772 * Set the render camera to use for calculating rotations.
24774 * @param {RenderCamera} renderCamera
24776 DirectionDOMRenderer.prototype.setRenderCamera = function (renderCamera) {
24777 var rotation = renderCamera.rotation;
24778 if (Math.abs(rotation.phi - this._rotation.phi) < this._epsilon) {
24781 this._rotation = rotation;
24782 this._setNeedsRender();
24785 * Set configuration values.
24787 * @param {IDirectionConfiguration} configuration
24789 DirectionDOMRenderer.prototype.setConfiguration = function (configuration) {
24790 var needsRender = false;
24791 if (this._highlightKey !== configuration.highlightKey ||
24792 this._distinguishSequence !== configuration.distinguishSequence) {
24793 this._highlightKey = configuration.highlightKey;
24794 this._distinguishSequence = configuration.distinguishSequence;
24795 needsRender = true;
24797 if (this._calculator.minWidth !== configuration.minWidth ||
24798 this._calculator.maxWidth !== configuration.maxWidth) {
24799 this._calculator.configure(configuration);
24800 needsRender = true;
24803 this._setNeedsRender();
24807 * Detect the element's width and height and resize
24808 * elements accordingly.
24810 * @param {ISize} size Size of vßiewer container element.
24812 DirectionDOMRenderer.prototype.resize = function (size) {
24813 this._calculator.resize(size);
24814 this._setNeedsRender();
24816 DirectionDOMRenderer.prototype._setNeedsRender = function () {
24817 if (this._node != null) {
24818 this._needsRender = true;
24821 DirectionDOMRenderer.prototype._clearEdges = function () {
24822 this._stepEdges = [];
24823 this._turnEdges = [];
24824 this._panoEdges = [];
24825 this._sequenceEdgeKeys = [];
24827 DirectionDOMRenderer.prototype._setEdges = function (edgeStatus, sequence) {
24828 this._stepEdges = [];
24829 this._turnEdges = [];
24830 this._panoEdges = [];
24831 this._sequenceEdgeKeys = [];
24832 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
24834 var direction = edge.data.direction;
24835 if (this._stepDirections.indexOf(direction) > -1) {
24836 this._stepEdges.push(edge);
24839 if (this._turnDirections.indexOf(direction) > -1) {
24840 this._turnEdges.push(edge);
24843 if (edge.data.direction === Edge_1.EdgeDirection.Pano) {
24844 this._panoEdges.push(edge);
24847 if (this._distinguishSequence && sequence != null) {
24848 var edges = this._panoEdges
24849 .concat(this._stepEdges)
24850 .concat(this._turnEdges);
24851 for (var _b = 0, edges_1 = edges; _b < edges_1.length; _b++) {
24852 var edge = edges_1[_b];
24853 var edgeKey = edge.to;
24854 for (var _c = 0, _d = sequence.keys; _c < _d.length; _c++) {
24855 var sequenceKey = _d[_c];
24856 if (sequenceKey === edgeKey) {
24857 this._sequenceEdgeKeys.push(edgeKey);
24864 DirectionDOMRenderer.prototype._createPanoArrows = function (navigator, rotation) {
24866 for (var _i = 0, _a = this._panoEdges; _i < _a.length; _i++) {
24867 var panoEdge = _a[_i];
24868 arrows.push(this._createVNodeByKey(navigator, panoEdge.to, panoEdge.data.worldMotionAzimuth, rotation, this._calculator.outerRadius, "DirectionsArrowPano"));
24870 for (var _b = 0, _c = this._stepEdges; _b < _c.length; _b++) {
24871 var stepEdge = _c[_b];
24872 arrows.push(this._createPanoToPerspectiveArrow(navigator, stepEdge.to, stepEdge.data.worldMotionAzimuth, rotation, stepEdge.data.direction));
24876 DirectionDOMRenderer.prototype._createPanoToPerspectiveArrow = function (navigator, key, azimuth, rotation, direction) {
24877 var threshold = Math.PI / 8;
24878 var relativePhi = rotation.phi;
24879 switch (direction) {
24880 case Edge_1.EdgeDirection.StepBackward:
24881 relativePhi = rotation.phi - Math.PI;
24883 case Edge_1.EdgeDirection.StepLeft:
24884 relativePhi = rotation.phi + Math.PI / 2;
24886 case Edge_1.EdgeDirection.StepRight:
24887 relativePhi = rotation.phi - Math.PI / 2;
24892 if (Math.abs(this._spatial.wrapAngle(azimuth - relativePhi)) < threshold) {
24893 return this._createVNodeByKey(navigator, key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowStep");
24895 return this._createVNodeDisabled(key, azimuth, rotation);
24897 DirectionDOMRenderer.prototype._createPerspectiveToPanoArrows = function (navigator, rotation) {
24899 for (var _i = 0, _a = this._panoEdges; _i < _a.length; _i++) {
24900 var panoEdge = _a[_i];
24901 arrows.push(this._createVNodeByKey(navigator, panoEdge.to, panoEdge.data.worldMotionAzimuth, rotation, this._calculator.innerRadius, "DirectionsArrowPano", true));
24905 DirectionDOMRenderer.prototype._createStepArrows = function (navigator, rotation) {
24907 for (var _i = 0, _a = this._stepEdges; _i < _a.length; _i++) {
24908 var stepEdge = _a[_i];
24909 arrows.push(this._createVNodeByDirection(navigator, stepEdge.to, stepEdge.data.worldMotionAzimuth, rotation, stepEdge.data.direction));
24913 DirectionDOMRenderer.prototype._createTurnArrows = function (navigator) {
24915 for (var _i = 0, _a = this._turnEdges; _i < _a.length; _i++) {
24916 var turnEdge = _a[_i];
24917 var direction = turnEdge.data.direction;
24918 var name_1 = this._turnNames[direction];
24919 turns.push(this._createVNodeByTurn(navigator, turnEdge.to, name_1, direction));
24923 DirectionDOMRenderer.prototype._createVNodeByKey = function (navigator, key, azimuth, rotation, offset, className, shiftVertically) {
24924 var onClick = function (e) {
24925 navigator.moveToKey$(key)
24926 .subscribe(undefined, function (error) {
24927 if (!(error instanceof Error_1.AbortMapillaryError)) {
24928 console.error(error);
24932 return this._createVNode(key, azimuth, rotation, offset, className, "DirectionsCircle", onClick, shiftVertically);
24934 DirectionDOMRenderer.prototype._createVNodeByDirection = function (navigator, key, azimuth, rotation, direction) {
24935 var onClick = function (e) {
24936 navigator.moveDir$(direction)
24937 .subscribe(undefined, function (error) {
24938 if (!(error instanceof Error_1.AbortMapillaryError)) {
24939 console.error(error);
24943 return this._createVNode(key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowStep", "DirectionsCircle", onClick);
24945 DirectionDOMRenderer.prototype._createVNodeByTurn = function (navigator, key, className, direction) {
24946 var onClick = function (e) {
24947 navigator.moveDir$(direction)
24948 .subscribe(undefined, function (error) {
24949 if (!(error instanceof Error_1.AbortMapillaryError)) {
24950 console.error(error);
24955 height: this._calculator.turnCircleSizeCss,
24956 transform: "rotate(0)",
24957 width: this._calculator.turnCircleSizeCss,
24959 switch (direction) {
24960 case Edge_1.EdgeDirection.TurnLeft:
24961 style.left = "5px";
24964 case Edge_1.EdgeDirection.TurnRight:
24965 style.right = "5px";
24968 case Edge_1.EdgeDirection.TurnU:
24969 style.left = "5px";
24970 style.bottom = "5px";
24975 var circleProperties = {
24982 var circleClassName = "TurnCircle";
24983 if (this._sequenceEdgeKeys.indexOf(key) > -1) {
24984 circleClassName += "Sequence";
24986 if (this._highlightKey === key) {
24987 circleClassName += "Highlight";
24989 var turn = vd.h("div." + className, {}, []);
24990 return vd.h("div." + circleClassName, circleProperties, [turn]);
24992 DirectionDOMRenderer.prototype._createVNodeDisabled = function (key, azimuth, rotation) {
24993 return this._createVNode(key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowDisabled", "DirectionsCircleDisabled");
24995 DirectionDOMRenderer.prototype._createVNode = function (key, azimuth, rotation, radius, className, circleClassName, onClick, shiftVertically) {
24996 var translation = this._calculator.angleToCoordinates(azimuth - rotation.phi);
24997 // rotate 90 degrees clockwise and flip over X-axis
24998 var translationX = Math.round(-radius * translation[1] + 0.5 * this._calculator.containerWidth);
24999 var translationY = Math.round(-radius * translation[0] + 0.5 * this._calculator.containerHeight);
25000 var shadowTranslation = this._calculator.relativeAngleToCoordiantes(azimuth, rotation.phi);
25001 var shadowOffset = this._calculator.shadowOffset;
25002 var shadowTranslationX = -shadowOffset * shadowTranslation[1];
25003 var shadowTranslationY = shadowOffset * shadowTranslation[0];
25004 var filter = "drop-shadow(" + shadowTranslationX + "px " + shadowTranslationY + "px 1px rgba(0,0,0,0.8))";
25007 "-webkit-filter": filter,
25011 var chevron = vd.h("div." + className, properties, []);
25012 var azimuthDeg = -this._spatial.radToDeg(azimuth - rotation.phi);
25013 var circleTransform = shiftVertically ?
25014 "translate(" + translationX + "px, " + translationY + "px) rotate(" + azimuthDeg + "deg) translateZ(-0.01px)" :
25015 "translate(" + translationX + "px, " + translationY + "px) rotate(" + azimuthDeg + "deg)";
25016 var circleProperties = {
25017 attributes: { "data-key": key },
25020 height: this._calculator.stepCircleSizeCss,
25021 marginLeft: this._calculator.stepCircleMarginCss,
25022 marginTop: this._calculator.stepCircleMarginCss,
25023 transform: circleTransform,
25024 width: this._calculator.stepCircleSizeCss,
25027 if (this._sequenceEdgeKeys.indexOf(key) > -1) {
25028 circleClassName += "Sequence";
25030 if (this._highlightKey === key) {
25031 circleClassName += "Highlight";
25033 return vd.h("div." + circleClassName, circleProperties, [chevron]);
25035 DirectionDOMRenderer.prototype._getContainer = function (steps, turns, rotation) {
25036 // edge does not handle hover on perspective transforms.
25037 var transform = this._isEdge ?
25039 "perspective(" + this._calculator.containerWidthCss + ") rotateX(60deg)";
25041 oncontextmenu: function (event) { event.preventDefault(); },
25043 bottom: this._calculator.containerBottomCss,
25044 height: this._calculator.containerHeightCss,
25045 left: this._calculator.containerLeftCss,
25046 marginLeft: this._calculator.containerMarginCss,
25047 transform: transform,
25048 width: this._calculator.containerWidthCss,
25051 return vd.h("div.DirectionsPerspective", properties, turns.concat(steps));
25053 return DirectionDOMRenderer;
25055 exports.DirectionDOMRenderer = DirectionDOMRenderer;
25056 exports.default = DirectionDOMRenderer;
25059 },{"../../Component":275,"../../Edge":276,"../../Error":277,"../../Geo":278,"virtual-dom":231}],305:[function(require,module,exports){
25061 var __extends = (this && this.__extends) || (function () {
25062 var extendStatics = function (d, b) {
25063 extendStatics = Object.setPrototypeOf ||
25064 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25065 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25066 return extendStatics(d, b);
25068 return function (d, b) {
25069 extendStatics(d, b);
25070 function __() { this.constructor = d; }
25071 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25074 Object.defineProperty(exports, "__esModule", { value: true });
25075 var rxjs_1 = require("rxjs");
25076 var operators_1 = require("rxjs/operators");
25077 var Component_1 = require("../../Component");
25078 var Render_1 = require("../../Render");
25079 var Tiles_1 = require("../../Tiles");
25080 var Utils_1 = require("../../Utils");
25081 var ImagePlaneComponent = /** @class */ (function (_super) {
25082 __extends(ImagePlaneComponent, _super);
25083 function ImagePlaneComponent(name, container, navigator) {
25084 var _this = _super.call(this, name, container, navigator) || this;
25085 _this._imageTileLoader = new Tiles_1.ImageTileLoader(Utils_1.Urls.tileScheme, Utils_1.Urls.tileDomain, Utils_1.Urls.origin);
25086 _this._roiCalculator = new Tiles_1.RegionOfInterestCalculator();
25087 _this._rendererOperation$ = new rxjs_1.Subject();
25088 _this._rendererCreator$ = new rxjs_1.Subject();
25089 _this._rendererDisposer$ = new rxjs_1.Subject();
25090 _this._renderer$ = _this._rendererOperation$.pipe(operators_1.scan(function (renderer, operation) {
25091 return operation(renderer);
25092 }, null), operators_1.filter(function (renderer) {
25093 return renderer != null;
25094 }), operators_1.distinctUntilChanged(undefined, function (renderer) {
25095 return renderer.frameId;
25097 _this._rendererCreator$.pipe(operators_1.map(function () {
25098 return function (renderer) {
25099 if (renderer != null) {
25100 throw new Error("Multiple image plane states can not be created at the same time");
25102 return new Component_1.ImagePlaneGLRenderer();
25105 .subscribe(_this._rendererOperation$);
25106 _this._rendererDisposer$.pipe(operators_1.map(function () {
25107 return function (renderer) {
25108 renderer.dispose();
25112 .subscribe(_this._rendererOperation$);
25115 ImagePlaneComponent.prototype._activate = function () {
25117 this._rendererSubscription = this._renderer$.pipe(operators_1.map(function (renderer) {
25121 frameId: renderer.frameId,
25122 needsRender: renderer.needsRender,
25123 render: renderer.render.bind(renderer),
25124 stage: Render_1.GLRenderStage.Background,
25127 renderer.clearNeedsRender();
25130 .subscribe(this._container.glRenderer.render$);
25131 this._rendererCreator$.next(null);
25132 this._stateSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
25133 return function (renderer) {
25134 renderer.updateFrame(frame);
25138 .subscribe(this._rendererOperation$);
25139 var textureProvider$ = this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
25140 return frame.state.currentNode.key;
25141 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
25142 var frame = _a[0], renderer = _a[1], size = _a[2];
25143 var state = frame.state;
25144 var viewportSize = Math.max(size.width, size.height);
25145 var currentNode = state.currentNode;
25146 var currentTransform = state.currentTransform;
25147 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
25148 return new Tiles_1.TextureProvider(currentNode.key, currentTransform.basicWidth, currentTransform.basicHeight, tileSize, currentNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
25149 }), operators_1.publishReplay(1), operators_1.refCount());
25150 this._textureProviderSubscription = textureProvider$.subscribe(function () { });
25151 this._setTextureProviderSubscription = textureProvider$.pipe(operators_1.map(function (provider) {
25152 return function (renderer) {
25153 renderer.setTextureProvider(provider.key, provider);
25157 .subscribe(this._rendererOperation$);
25158 this._setTileSizeSubscription = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
25159 return rxjs_1.combineLatest(textureProvider$, rxjs_1.of(size)).pipe(operators_1.first());
25161 .subscribe(function (_a) {
25162 var provider = _a[0], size = _a[1];
25163 var viewportSize = Math.max(size.width, size.height);
25164 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
25165 provider.setTileSize(tileSize);
25167 this._abortTextureProviderSubscription = textureProvider$.pipe(operators_1.pairwise())
25168 .subscribe(function (pair) {
25169 var previous = pair[0];
25172 var roiTrigger$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
25173 var camera = _a[0], size = _a[1];
25175 camera.camera.position.clone(),
25176 camera.camera.lookat.clone(),
25177 camera.zoom.valueOf(),
25178 size.height.valueOf(),
25179 size.width.valueOf()
25181 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
25182 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
25183 }), operators_1.map(function (pls) {
25184 var samePosition = pls[0][0].equals(pls[1][0]);
25185 var sameLookat = pls[0][1].equals(pls[1][1]);
25186 var sameZoom = pls[0][2] === pls[1][2];
25187 var sameHeight = pls[0][3] === pls[1][3];
25188 var sameWidth = pls[0][4] === pls[1][4];
25189 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
25190 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
25192 }), operators_1.switchMap(function (stalled) {
25193 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
25194 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
25195 this._setRegionOfInterestSubscription = textureProvider$.pipe(operators_1.switchMap(function (provider) {
25196 return roiTrigger$.pipe(operators_1.map(function (_a) {
25197 var camera = _a[0], size = _a[1], transform = _a[2];
25199 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
25203 }), operators_1.filter(function (args) {
25204 return !args[1].disposed;
25206 .subscribe(function (args) {
25208 var provider = args[1];
25209 provider.setRegionOfInterest(roi);
25211 var hasTexture$ = textureProvider$.pipe(operators_1.switchMap(function (provider) {
25212 return provider.hasTexture$;
25213 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
25214 this._hasTextureSubscription = hasTexture$.subscribe(function () { });
25215 var nodeImage$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
25216 return frame.state.nodesAhead === 0;
25217 }), operators_1.map(function (frame) {
25218 return frame.state.currentNode;
25219 }), operators_1.distinctUntilChanged(undefined, function (node) {
25221 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexture$), operators_1.filter(function (args) {
25223 }), operators_1.map(function (args) {
25225 }), operators_1.filter(function (node) {
25227 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
25228 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
25229 }), operators_1.switchMap(function (node) {
25230 var baseImageSize = node.pano ?
25231 Utils_1.Settings.basePanoramaSize :
25232 Utils_1.Settings.baseImageSize;
25233 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
25234 return rxjs_1.empty();
25237 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
25238 return [n.image, n];
25240 return image$.pipe(operators_1.takeUntil(hasTexture$.pipe(operators_1.filter(function (hasTexture) {
25242 }))), operators_1.catchError(function (error, caught) {
25243 console.error("Failed to fetch high res image (" + node.key + ")", error);
25244 return rxjs_1.empty();
25246 })).pipe(operators_1.publish(), operators_1.refCount());
25247 this._updateBackgroundSubscription = nodeImage$.pipe(operators_1.withLatestFrom(textureProvider$))
25248 .subscribe(function (args) {
25249 if (args[0][1].key !== args[1].key ||
25250 args[1].disposed) {
25253 args[1].updateBackground(args[0][0]);
25255 this._updateTextureImageSubscription = nodeImage$.pipe(operators_1.map(function (imn) {
25256 return function (renderer) {
25257 renderer.updateTextureImage(imn[0], imn[1]);
25261 .subscribe(this._rendererOperation$);
25263 ImagePlaneComponent.prototype._deactivate = function () {
25264 this._rendererDisposer$.next(null);
25265 this._abortTextureProviderSubscription.unsubscribe();
25266 this._hasTextureSubscription.unsubscribe();
25267 this._rendererSubscription.unsubscribe();
25268 this._setRegionOfInterestSubscription.unsubscribe();
25269 this._setTextureProviderSubscription.unsubscribe();
25270 this._setTileSizeSubscription.unsubscribe();
25271 this._stateSubscription.unsubscribe();
25272 this._textureProviderSubscription.unsubscribe();
25273 this._updateBackgroundSubscription.unsubscribe();
25274 this._updateTextureImageSubscription.unsubscribe();
25276 ImagePlaneComponent.prototype._getDefaultConfiguration = function () {
25279 ImagePlaneComponent.componentName = "imagePlane";
25280 return ImagePlaneComponent;
25281 }(Component_1.Component));
25282 exports.ImagePlaneComponent = ImagePlaneComponent;
25283 Component_1.ComponentService.register(ImagePlaneComponent);
25284 exports.default = ImagePlaneComponent;
25286 },{"../../Component":275,"../../Render":281,"../../Tiles":284,"../../Utils":285,"rxjs":27,"rxjs/operators":225}],306:[function(require,module,exports){
25288 Object.defineProperty(exports, "__esModule", { value: true });
25289 var Component_1 = require("../../Component");
25290 var ImagePlaneGLRenderer = /** @class */ (function () {
25291 function ImagePlaneGLRenderer() {
25292 this._factory = new Component_1.MeshFactory();
25293 this._scene = new Component_1.MeshScene();
25295 this._alphaOld = 0;
25296 this._fadeOutSpeed = 0.05;
25297 this._currentKey = null;
25298 this._previousKey = null;
25299 this._providerDisposers = {};
25301 this._needsRender = false;
25303 Object.defineProperty(ImagePlaneGLRenderer.prototype, "frameId", {
25305 return this._frameId;
25310 Object.defineProperty(ImagePlaneGLRenderer.prototype, "needsRender", {
25312 return this._needsRender;
25317 ImagePlaneGLRenderer.prototype.indicateNeedsRender = function () {
25318 this._needsRender = true;
25320 ImagePlaneGLRenderer.prototype.updateFrame = function (frame) {
25321 this._updateFrameId(frame.id);
25322 this._needsRender = this._updateAlpha(frame.state.alpha) || this._needsRender;
25323 this._needsRender = this._updateAlphaOld(frame.state.alpha) || this._needsRender;
25324 this._needsRender = this._updateImagePlanes(frame.state) || this._needsRender;
25326 ImagePlaneGLRenderer.prototype.setTextureProvider = function (key, provider) {
25328 if (key !== this._currentKey) {
25331 var createdSubscription = provider.textureCreated$
25332 .subscribe(function (texture) {
25333 _this._updateTexture(texture);
25335 var updatedSubscription = provider.textureUpdated$
25336 .subscribe(function (updated) {
25337 _this._needsRender = true;
25339 var dispose = function () {
25340 createdSubscription.unsubscribe();
25341 updatedSubscription.unsubscribe();
25342 provider.dispose();
25344 if (key in this._providerDisposers) {
25345 var disposeProvider = this._providerDisposers[key];
25347 delete this._providerDisposers[key];
25349 this._providerDisposers[key] = dispose;
25351 ImagePlaneGLRenderer.prototype._updateTexture = function (texture) {
25352 this._needsRender = true;
25353 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
25354 var plane = _a[_i];
25355 var material = plane.material;
25356 var oldTexture = material.uniforms.projectorTex.value;
25357 material.uniforms.projectorTex.value = null;
25358 oldTexture.dispose();
25359 material.uniforms.projectorTex.value = texture;
25362 ImagePlaneGLRenderer.prototype.updateTextureImage = function (image, node) {
25363 if (this._currentKey !== node.key) {
25366 this._needsRender = true;
25367 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
25368 var plane = _a[_i];
25369 var material = plane.material;
25370 var texture = material.uniforms.projectorTex.value;
25371 texture.image = image;
25372 texture.needsUpdate = true;
25375 ImagePlaneGLRenderer.prototype.render = function (perspectiveCamera, renderer) {
25376 var planeAlpha = this._scene.imagePlanesOld.length ? 1 : this._alpha;
25377 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
25378 var plane = _a[_i];
25379 plane.material.uniforms.opacity.value = planeAlpha;
25381 for (var _b = 0, _c = this._scene.imagePlanesOld; _b < _c.length; _b++) {
25382 var plane = _c[_b];
25383 plane.material.uniforms.opacity.value = this._alphaOld;
25385 renderer.render(this._scene.scene, perspectiveCamera);
25386 renderer.render(this._scene.sceneOld, perspectiveCamera);
25387 for (var _d = 0, _e = this._scene.imagePlanes; _d < _e.length; _d++) {
25388 var plane = _e[_d];
25389 plane.material.uniforms.opacity.value = this._alpha;
25391 renderer.render(this._scene.scene, perspectiveCamera);
25393 ImagePlaneGLRenderer.prototype.clearNeedsRender = function () {
25394 this._needsRender = false;
25396 ImagePlaneGLRenderer.prototype.dispose = function () {
25397 this._scene.clear();
25399 ImagePlaneGLRenderer.prototype._updateFrameId = function (frameId) {
25400 this._frameId = frameId;
25402 ImagePlaneGLRenderer.prototype._updateAlpha = function (alpha) {
25403 if (alpha === this._alpha) {
25406 this._alpha = alpha;
25409 ImagePlaneGLRenderer.prototype._updateAlphaOld = function (alpha) {
25410 if (alpha < 1 || this._alphaOld === 0) {
25413 this._alphaOld = Math.max(0, this._alphaOld - this._fadeOutSpeed);
25416 ImagePlaneGLRenderer.prototype._updateImagePlanes = function (state) {
25417 if (state.currentNode == null || state.currentNode.key === this._currentKey) {
25420 var previousKey = state.previousNode != null ? state.previousNode.key : null;
25421 var currentKey = state.currentNode.key;
25422 if (this._previousKey !== previousKey &&
25423 this._previousKey !== currentKey &&
25424 this._previousKey in this._providerDisposers) {
25425 var disposeProvider = this._providerDisposers[this._previousKey];
25427 delete this._providerDisposers[this._previousKey];
25429 if (previousKey != null) {
25430 if (previousKey !== this._currentKey && previousKey !== this._previousKey) {
25431 var previousMesh = this._factory.createMesh(state.previousNode, state.previousTransform);
25432 this._scene.updateImagePlanes([previousMesh]);
25434 this._previousKey = previousKey;
25436 this._currentKey = currentKey;
25437 var currentMesh = this._factory.createMesh(state.currentNode, state.currentTransform);
25438 this._scene.updateImagePlanes([currentMesh]);
25439 this._alphaOld = 1;
25442 return ImagePlaneGLRenderer;
25444 exports.ImagePlaneGLRenderer = ImagePlaneGLRenderer;
25445 exports.default = ImagePlaneGLRenderer;
25447 },{"../../Component":275}],307:[function(require,module,exports){
25449 Object.defineProperty(exports, "__esModule", { value: true });
25451 (function (CoverState) {
25452 CoverState[CoverState["Hidden"] = 0] = "Hidden";
25453 CoverState[CoverState["Loading"] = 1] = "Loading";
25454 CoverState[CoverState["Visible"] = 2] = "Visible";
25455 })(CoverState = exports.CoverState || (exports.CoverState = {}));
25457 },{}],308:[function(require,module,exports){
25459 Object.defineProperty(exports, "__esModule", { value: true });
25461 * Enumeration for slider mode.
25466 * @description Modes for specifying how transitions
25467 * between nodes are performed in slider mode. Only
25468 * applicable when the slider component determines
25469 * that transitions with motion is possilble. When it
25470 * is not, the stationary mode will be applied.
25473 (function (SliderMode) {
25475 * Transitions with motion.
25477 * @description The slider component moves the
25478 * camera between the node origins.
25480 * In this mode it is not possible to zoom or pan.
25482 * The slider component falls back to stationary
25483 * mode when it determines that the pair of nodes
25484 * does not have a strong enough relation.
25486 SliderMode[SliderMode["Motion"] = 0] = "Motion";
25488 * Stationary transitions.
25490 * @description The camera is stationary.
25492 * In this mode it is possible to zoom and pan.
25494 SliderMode[SliderMode["Stationary"] = 1] = "Stationary";
25495 })(SliderMode = exports.SliderMode || (exports.SliderMode = {}));
25497 },{}],309:[function(require,module,exports){
25499 Object.defineProperty(exports, "__esModule", { value: true });
25500 var ICoverConfiguration_1 = require("./ICoverConfiguration");
25501 exports.CoverState = ICoverConfiguration_1.CoverState;
25502 var ISliderConfiguration_1 = require("./ISliderConfiguration");
25503 exports.SliderMode = ISliderConfiguration_1.SliderMode;
25505 },{"./ICoverConfiguration":307,"./ISliderConfiguration":308}],310:[function(require,module,exports){
25507 var __extends = (this && this.__extends) || (function () {
25508 var extendStatics = function (d, b) {
25509 extendStatics = Object.setPrototypeOf ||
25510 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25511 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25512 return extendStatics(d, b);
25514 return function (d, b) {
25515 extendStatics(d, b);
25516 function __() { this.constructor = d; }
25517 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25520 Object.defineProperty(exports, "__esModule", { value: true });
25521 var operators_1 = require("rxjs/operators");
25522 var Component_1 = require("../../Component");
25523 var Edge_1 = require("../../Edge");
25525 * The `KeyPlayHandler` allows the user to control the play behavior
25526 * using the following key commands:
25528 * `Spacebar`: Start or stop playing.
25529 * `SHIFT` + `D`: Switch direction.
25530 * `<`: Decrease speed.
25531 * `>`: Increase speed.
25535 * var keyboardComponent = viewer.getComponent("keyboard");
25537 * keyboardComponent.keyPlay.disable();
25538 * keyboardComponent.keyPlay.enable();
25540 * var isEnabled = keyboardComponent.keyPlay.isEnabled;
25543 var KeyPlayHandler = /** @class */ (function (_super) {
25544 __extends(KeyPlayHandler, _super);
25545 function KeyPlayHandler() {
25546 return _super !== null && _super.apply(this, arguments) || this;
25548 KeyPlayHandler.prototype._enable = function () {
25550 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) {
25551 return node.sequenceEdges$;
25553 .subscribe(function (_a) {
25554 var event = _a[0], playing = _a[1], direction = _a[2], speed = _a[3], status = _a[4];
25555 if (event.altKey || event.ctrlKey || event.metaKey) {
25558 switch (event.key) {
25560 if (!event.shiftKey) {
25563 var newDirection = playing ?
25564 null : direction === Edge_1.EdgeDirection.Next ?
25565 Edge_1.EdgeDirection.Prev : direction === Edge_1.EdgeDirection.Prev ?
25566 Edge_1.EdgeDirection.Next : null;
25567 if (newDirection != null) {
25568 _this._navigator.playService.setDirection(newDirection);
25572 if (event.shiftKey) {
25576 _this._navigator.playService.stop();
25579 for (var _i = 0, _b = status.edges; _i < _b.length; _i++) {
25581 if (edge.data.direction === direction) {
25582 _this._navigator.playService.play();
25588 _this._navigator.playService.setSpeed(speed - 0.05);
25591 _this._navigator.playService.setSpeed(speed + 0.05);
25596 event.preventDefault();
25599 KeyPlayHandler.prototype._disable = function () {
25600 this._keyDownSubscription.unsubscribe();
25602 KeyPlayHandler.prototype._getConfiguration = function (enable) {
25603 return { keyZoom: enable };
25605 return KeyPlayHandler;
25606 }(Component_1.HandlerBase));
25607 exports.KeyPlayHandler = KeyPlayHandler;
25608 exports.default = KeyPlayHandler;
25610 },{"../../Component":275,"../../Edge":276,"rxjs/operators":225}],311:[function(require,module,exports){
25612 var __extends = (this && this.__extends) || (function () {
25613 var extendStatics = function (d, b) {
25614 extendStatics = Object.setPrototypeOf ||
25615 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25616 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25617 return extendStatics(d, b);
25619 return function (d, b) {
25620 extendStatics(d, b);
25621 function __() { this.constructor = d; }
25622 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25625 Object.defineProperty(exports, "__esModule", { value: true });
25626 var operators_1 = require("rxjs/operators");
25627 var Component_1 = require("../../Component");
25628 var Edge_1 = require("../../Edge");
25629 var Error_1 = require("../../Error");
25631 * The `KeySequenceNavigationHandler` allows the user to navigate through a sequence using the
25632 * following key commands:
25634 * `ALT` + `Up Arrow`: Navigate to next image in the sequence.
25635 * `ALT` + `Down Arrow`: Navigate to previous image in sequence.
25639 * var keyboardComponent = viewer.getComponent("keyboard");
25641 * keyboardComponent.keySequenceNavigation.disable();
25642 * keyboardComponent.keySequenceNavigation.enable();
25644 * var isEnabled = keyboardComponent.keySequenceNavigation.isEnabled;
25647 var KeySequenceNavigationHandler = /** @class */ (function (_super) {
25648 __extends(KeySequenceNavigationHandler, _super);
25649 function KeySequenceNavigationHandler() {
25650 return _super !== null && _super.apply(this, arguments) || this;
25652 KeySequenceNavigationHandler.prototype._enable = function () {
25654 var sequenceEdges$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
25655 return node.sequenceEdges$;
25657 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(sequenceEdges$))
25658 .subscribe(function (_a) {
25659 var event = _a[0], edgeStatus = _a[1];
25660 var direction = null;
25661 switch (event.keyCode) {
25663 direction = Edge_1.EdgeDirection.Next;
25666 direction = Edge_1.EdgeDirection.Prev;
25671 event.preventDefault();
25672 if (!event.altKey || event.shiftKey || !edgeStatus.cached) {
25675 for (var _i = 0, _b = edgeStatus.edges; _i < _b.length; _i++) {
25677 if (edge.data.direction === direction) {
25678 _this._navigator.moveToKey$(edge.to)
25679 .subscribe(undefined, function (error) {
25680 if (!(error instanceof Error_1.AbortMapillaryError)) {
25681 console.error(error);
25689 KeySequenceNavigationHandler.prototype._disable = function () {
25690 this._keyDownSubscription.unsubscribe();
25692 KeySequenceNavigationHandler.prototype._getConfiguration = function (enable) {
25693 return { keySequenceNavigation: enable };
25695 return KeySequenceNavigationHandler;
25696 }(Component_1.HandlerBase));
25697 exports.KeySequenceNavigationHandler = KeySequenceNavigationHandler;
25698 exports.default = KeySequenceNavigationHandler;
25700 },{"../../Component":275,"../../Edge":276,"../../Error":277,"rxjs/operators":225}],312:[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 operators_1 = require("rxjs/operators");
25717 var Component_1 = require("../../Component");
25718 var Edge_1 = require("../../Edge");
25719 var Error_1 = require("../../Error");
25721 * The `KeySpatialNavigationHandler` allows the user to navigate through a sequence using the
25722 * following key commands:
25724 * `Up Arrow`: Step forward.
25725 * `Down Arrow`: Step backward.
25726 * `Left Arrow`: Step to the left.
25727 * `Rigth Arrow`: Step to the right.
25728 * `SHIFT` + `Down Arrow`: Turn around.
25729 * `SHIFT` + `Left Arrow`: Turn to the left.
25730 * `SHIFT` + `Rigth Arrow`: Turn to the right.
25734 * var keyboardComponent = viewer.getComponent("keyboard");
25736 * keyboardComponent.keySpatialNavigation.disable();
25737 * keyboardComponent.keySpatialNavigation.enable();
25739 * var isEnabled = keyboardComponent.keySpatialNavigation.isEnabled;
25742 var KeySpatialNavigationHandler = /** @class */ (function (_super) {
25743 __extends(KeySpatialNavigationHandler, _super);
25745 function KeySpatialNavigationHandler(component, container, navigator, spatial) {
25746 var _this = _super.call(this, component, container, navigator) || this;
25747 _this._spatial = spatial;
25750 KeySpatialNavigationHandler.prototype._enable = function () {
25752 var spatialEdges$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
25753 return node.spatialEdges$;
25755 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(spatialEdges$, this._navigator.stateService.currentState$))
25756 .subscribe(function (_a) {
25757 var event = _a[0], edgeStatus = _a[1], frame = _a[2];
25758 var pano = frame.state.currentNode.pano;
25759 var direction = null;
25760 switch (event.keyCode) {
25762 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnLeft : Edge_1.EdgeDirection.StepLeft;
25765 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.Pano : Edge_1.EdgeDirection.StepForward;
25768 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnRight : Edge_1.EdgeDirection.StepRight;
25771 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnU : Edge_1.EdgeDirection.StepBackward;
25776 event.preventDefault();
25777 if (event.altKey || !edgeStatus.cached ||
25778 (event.shiftKey && pano)) {
25782 _this._moveDir(direction, edgeStatus);
25786 shifts[Edge_1.EdgeDirection.StepBackward] = Math.PI;
25787 shifts[Edge_1.EdgeDirection.StepForward] = 0;
25788 shifts[Edge_1.EdgeDirection.StepLeft] = Math.PI / 2;
25789 shifts[Edge_1.EdgeDirection.StepRight] = -Math.PI / 2;
25790 var phi = _this._rotationFromCamera(frame.state.camera).phi;
25791 var navigationAngle = _this._spatial.wrapAngle(phi + shifts[direction]);
25792 var threshold = Math.PI / 4;
25793 var edges = edgeStatus.edges.filter(function (e) {
25794 return e.data.direction === Edge_1.EdgeDirection.Pano || e.data.direction === direction;
25796 var smallestAngle = Number.MAX_VALUE;
25798 for (var _i = 0, edges_1 = edges; _i < edges_1.length; _i++) {
25799 var edge = edges_1[_i];
25800 var angle = Math.abs(_this._spatial.wrapAngle(edge.data.worldMotionAzimuth - navigationAngle));
25801 if (angle < Math.min(smallestAngle, threshold)) {
25802 smallestAngle = angle;
25806 if (toKey == null) {
25809 _this._moveToKey(toKey);
25813 KeySpatialNavigationHandler.prototype._disable = function () {
25814 this._keyDownSubscription.unsubscribe();
25816 KeySpatialNavigationHandler.prototype._getConfiguration = function (enable) {
25817 return { keySpatialNavigation: enable };
25819 KeySpatialNavigationHandler.prototype._moveDir = function (direction, edgeStatus) {
25820 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
25822 if (edge.data.direction === direction) {
25823 this._moveToKey(edge.to);
25828 KeySpatialNavigationHandler.prototype._moveToKey = function (key) {
25829 this._navigator.moveToKey$(key)
25830 .subscribe(undefined, function (error) {
25831 if (!(error instanceof Error_1.AbortMapillaryError)) {
25832 console.error(error);
25836 KeySpatialNavigationHandler.prototype._rotationFromCamera = function (camera) {
25837 var direction = camera.lookat.clone().sub(camera.position);
25838 var upProjection = direction.clone().dot(camera.up);
25839 var planeProjection = direction.clone().sub(camera.up.clone().multiplyScalar(upProjection));
25840 var phi = Math.atan2(planeProjection.y, planeProjection.x);
25841 var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
25842 return { phi: phi, theta: theta };
25844 return KeySpatialNavigationHandler;
25845 }(Component_1.HandlerBase));
25846 exports.KeySpatialNavigationHandler = KeySpatialNavigationHandler;
25847 exports.default = KeySpatialNavigationHandler;
25849 },{"../../Component":275,"../../Edge":276,"../../Error":277,"rxjs/operators":225}],313:[function(require,module,exports){
25851 var __extends = (this && this.__extends) || (function () {
25852 var extendStatics = function (d, b) {
25853 extendStatics = Object.setPrototypeOf ||
25854 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25855 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25856 return extendStatics(d, b);
25858 return function (d, b) {
25859 extendStatics(d, b);
25860 function __() { this.constructor = d; }
25861 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25864 Object.defineProperty(exports, "__esModule", { value: true });
25865 var operators_1 = require("rxjs/operators");
25866 var Component_1 = require("../../Component");
25868 * The `KeyZoomHandler` allows the user to zoom in and out using the
25869 * following key commands:
25876 * var keyboardComponent = viewer.getComponent("keyboard");
25878 * keyboardComponent.keyZoom.disable();
25879 * keyboardComponent.keyZoom.enable();
25881 * var isEnabled = keyboardComponent.keyZoom.isEnabled;
25884 var KeyZoomHandler = /** @class */ (function (_super) {
25885 __extends(KeyZoomHandler, _super);
25887 function KeyZoomHandler(component, container, navigator, viewportCoords) {
25888 var _this = _super.call(this, component, container, navigator) || this;
25889 _this._viewportCoords = viewportCoords;
25892 KeyZoomHandler.prototype._enable = function () {
25894 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
25895 .subscribe(function (_a) {
25896 var event = _a[0], render = _a[1], transform = _a[2];
25897 if (event.altKey || event.shiftKey || event.ctrlKey || event.metaKey) {
25901 switch (event.key) {
25911 event.preventDefault();
25912 var unprojected = _this._viewportCoords.unprojectFromViewport(0, 0, render.perspective);
25913 var reference = transform.projectBasic(unprojected.toArray());
25914 _this._navigator.stateService.zoomIn(delta, reference);
25917 KeyZoomHandler.prototype._disable = function () {
25918 this._keyDownSubscription.unsubscribe();
25920 KeyZoomHandler.prototype._getConfiguration = function (enable) {
25921 return { keyZoom: enable };
25923 return KeyZoomHandler;
25924 }(Component_1.HandlerBase));
25925 exports.KeyZoomHandler = KeyZoomHandler;
25926 exports.default = KeyZoomHandler;
25928 },{"../../Component":275,"rxjs/operators":225}],314:[function(require,module,exports){
25930 var __extends = (this && this.__extends) || (function () {
25931 var extendStatics = function (d, b) {
25932 extendStatics = Object.setPrototypeOf ||
25933 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25934 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25935 return extendStatics(d, b);
25937 return function (d, b) {
25938 extendStatics(d, b);
25939 function __() { this.constructor = d; }
25940 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25943 Object.defineProperty(exports, "__esModule", { value: true });
25944 var Component_1 = require("../../Component");
25945 var Geo_1 = require("../../Geo");
25947 * @class KeyboardComponent
25949 * @classdesc Component for keyboard event handling.
25951 * To retrive and use the keyboard component
25955 * var viewer = new Mapillary.Viewer(
25960 * var keyboardComponent = viewer.getComponent("keyboard");
25963 var KeyboardComponent = /** @class */ (function (_super) {
25964 __extends(KeyboardComponent, _super);
25966 function KeyboardComponent(name, container, navigator) {
25967 var _this = _super.call(this, name, container, navigator) || this;
25968 _this._keyPlayHandler = new Component_1.KeyPlayHandler(_this, container, navigator);
25969 _this._keySequenceNavigationHandler = new Component_1.KeySequenceNavigationHandler(_this, container, navigator);
25970 _this._keySpatialNavigationHandler = new Component_1.KeySpatialNavigationHandler(_this, container, navigator, new Geo_1.Spatial());
25971 _this._keyZoomHandler = new Component_1.KeyZoomHandler(_this, container, navigator, new Geo_1.ViewportCoords());
25974 Object.defineProperty(KeyboardComponent.prototype, "keyPlay", {
25978 * @returns {KeyPlayHandler} The key play handler.
25981 return this._keyPlayHandler;
25986 Object.defineProperty(KeyboardComponent.prototype, "keySequenceNavigation", {
25988 * Get key sequence navigation.
25990 * @returns {KeySequenceNavigationHandler} The key sequence navigation handler.
25993 return this._keySequenceNavigationHandler;
25998 Object.defineProperty(KeyboardComponent.prototype, "keySpatialNavigation", {
26002 * @returns {KeySpatialNavigationHandler} The spatial handler.
26005 return this._keySpatialNavigationHandler;
26010 Object.defineProperty(KeyboardComponent.prototype, "keyZoom", {
26014 * @returns {KeyZoomHandler} The key zoom handler.
26017 return this._keyZoomHandler;
26022 KeyboardComponent.prototype._activate = function () {
26024 this._configurationSubscription = this._configuration$
26025 .subscribe(function (configuration) {
26026 if (configuration.keyPlay) {
26027 _this._keyPlayHandler.enable();
26030 _this._keyPlayHandler.disable();
26032 if (configuration.keySequenceNavigation) {
26033 _this._keySequenceNavigationHandler.enable();
26036 _this._keySequenceNavigationHandler.disable();
26038 if (configuration.keySpatialNavigation) {
26039 _this._keySpatialNavigationHandler.enable();
26042 _this._keySpatialNavigationHandler.disable();
26044 if (configuration.keyZoom) {
26045 _this._keyZoomHandler.enable();
26048 _this._keyZoomHandler.disable();
26052 KeyboardComponent.prototype._deactivate = function () {
26053 this._configurationSubscription.unsubscribe();
26054 this._keyPlayHandler.disable();
26055 this._keySequenceNavigationHandler.disable();
26056 this._keySpatialNavigationHandler.disable();
26057 this._keyZoomHandler.disable();
26059 KeyboardComponent.prototype._getDefaultConfiguration = function () {
26060 return { keyPlay: true, keySequenceNavigation: true, keySpatialNavigation: true, keyZoom: true };
26062 KeyboardComponent.componentName = "keyboard";
26063 return KeyboardComponent;
26064 }(Component_1.Component));
26065 exports.KeyboardComponent = KeyboardComponent;
26066 Component_1.ComponentService.register(KeyboardComponent);
26067 exports.default = KeyboardComponent;
26069 },{"../../Component":275,"../../Geo":278}],315:[function(require,module,exports){
26071 Object.defineProperty(exports, "__esModule", { value: true });
26072 var MarkerComponent_1 = require("./MarkerComponent");
26073 exports.MarkerComponent = MarkerComponent_1.MarkerComponent;
26074 var SimpleMarker_1 = require("./marker/SimpleMarker");
26075 exports.SimpleMarker = SimpleMarker_1.SimpleMarker;
26076 var CircleMarker_1 = require("./marker/CircleMarker");
26077 exports.CircleMarker = CircleMarker_1.CircleMarker;
26079 },{"./MarkerComponent":316,"./marker/CircleMarker":319,"./marker/SimpleMarker":321}],316:[function(require,module,exports){
26081 var __extends = (this && this.__extends) || (function () {
26082 var extendStatics = function (d, b) {
26083 extendStatics = Object.setPrototypeOf ||
26084 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26085 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26086 return extendStatics(d, b);
26088 return function (d, b) {
26089 extendStatics(d, b);
26090 function __() { this.constructor = d; }
26091 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26094 Object.defineProperty(exports, "__esModule", { value: true });
26095 var rxjs_1 = require("rxjs");
26096 var operators_1 = require("rxjs/operators");
26097 var THREE = require("three");
26098 var when = require("when");
26099 var Component_1 = require("../../Component");
26100 var Render_1 = require("../../Render");
26101 var Graph_1 = require("../../Graph");
26102 var Geo_1 = require("../../Geo");
26104 * @class MarkerComponent
26106 * @classdesc Component for showing and editing 3D marker objects.
26108 * The `add` method is used for adding new markers or replacing
26109 * markers already in the set.
26111 * If a marker already in the set has the same
26112 * id as one of the markers added, the old marker will be removed and
26113 * the added marker will take its place.
26115 * It is not possible to update markers in the set by updating any properties
26116 * directly on the marker object. Markers need to be replaced by
26117 * re-adding them for updates to geographic position or configuration
26120 * Markers added to the marker component can be either interactive
26121 * or non-interactive. Different marker types define their behavior.
26122 * Markers with interaction support can be configured with options
26123 * to respond to dragging inside the viewer and be detected when
26124 * retrieving markers from pixel points with the `getMarkerIdAt` method.
26126 * To retrive and use the marker component
26130 * var viewer = new Mapillary.Viewer(
26134 * { component: { marker: true } });
26136 * var markerComponent = viewer.getComponent("marker");
26139 var MarkerComponent = /** @class */ (function (_super) {
26140 __extends(MarkerComponent, _super);
26142 function MarkerComponent(name, container, navigator) {
26143 var _this = _super.call(this, name, container, navigator) || this;
26144 _this._relativeGroundAltitude = -2;
26145 _this._geoCoords = new Geo_1.GeoCoords();
26146 _this._graphCalculator = new Graph_1.GraphCalculator();
26147 _this._markerScene = new Component_1.MarkerScene();
26148 _this._markerSet = new Component_1.MarkerSet();
26149 _this._viewportCoords = new Geo_1.ViewportCoords();
26153 * Add markers to the marker set or replace markers in the marker set.
26155 * @description If a marker already in the set has the same
26156 * id as one of the markers added, the old marker will be removed
26157 * the added marker will take its place.
26159 * Any marker inside the visible bounding bbox
26160 * will be initialized and placed in the viewer.
26162 * @param {Array<Marker>} markers - Markers to add.
26164 * @example ```markerComponent.add([marker1, marker2]);```
26166 MarkerComponent.prototype.add = function (markers) {
26167 this._markerSet.add(markers);
26170 * Returns the marker in the marker set with the specified id, or
26171 * undefined if the id matches no marker.
26173 * @param {string} markerId - Id of the marker.
26175 * @example ```var marker = markerComponent.get("markerId");```
26178 MarkerComponent.prototype.get = function (markerId) {
26179 return this._markerSet.get(markerId);
26182 * Returns an array of all markers.
26184 * @example ```var markers = markerComponent.getAll();```
26186 MarkerComponent.prototype.getAll = function () {
26187 return this._markerSet.getAll();
26190 * Returns the id of the interactive marker closest to the current camera
26191 * position at the specified point.
26193 * @description Notice that the pixelPoint argument requires x, y
26194 * coordinates from pixel space.
26196 * With this function, you can use the coordinates provided by mouse
26197 * events to get information out of the marker component.
26199 * If no interactive geometry of an interactive marker exist at the pixel
26200 * point, `null` will be returned.
26202 * @param {Array<number>} pixelPoint - Pixel coordinates on the viewer element.
26203 * @returns {string} Id of the interactive marker closest to the camera. If no
26204 * interactive marker exist at the pixel point, `null` will be returned.
26208 * markerComponent.getMarkerIdAt([100, 100])
26209 * .then((markerId) => { console.log(markerId); });
26212 MarkerComponent.prototype.getMarkerIdAt = function (pixelPoint) {
26214 return when.promise(function (resolve, reject) {
26215 _this._container.renderService.renderCamera$.pipe(operators_1.first(), operators_1.map(function (render) {
26216 var viewport = _this._viewportCoords
26217 .canvasToViewport(pixelPoint[0], pixelPoint[1], _this._container.element);
26218 var id = _this._markerScene.intersectObjects(viewport, render.perspective);
26221 .subscribe(function (id) {
26223 }, function (error) {
26229 * Check if a marker exist in the marker set.
26231 * @param {string} markerId - Id of the marker.
26233 * @example ```var markerExists = markerComponent.has("markerId");```
26235 MarkerComponent.prototype.has = function (markerId) {
26236 return this._markerSet.has(markerId);
26239 * Remove markers with the specified ids from the marker set.
26241 * @param {Array<string>} markerIds - Ids for markers to remove.
26243 * @example ```markerComponent.remove(["id-1", "id-2"]);```
26245 MarkerComponent.prototype.remove = function (markerIds) {
26246 this._markerSet.remove(markerIds);
26249 * Remove all markers from the marker set.
26251 * @example ```markerComponent.removeAll();```
26253 MarkerComponent.prototype.removeAll = function () {
26254 this._markerSet.removeAll();
26256 MarkerComponent.prototype._activate = function () {
26258 var groundAltitude$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
26259 return frame.state.camera.position.z + _this._relativeGroundAltitude;
26260 }), operators_1.distinctUntilChanged(function (a1, a2) {
26261 return Math.abs(a1 - a2) < 0.01;
26262 }), operators_1.publishReplay(1), operators_1.refCount());
26263 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());
26264 var clampedConfiguration$ = this._configuration$.pipe(operators_1.map(function (configuration) {
26265 return { visibleBBoxSize: Math.max(1, Math.min(200, configuration.visibleBBoxSize)) };
26267 var currentlatLon$ = this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) { return node.latLon; }), operators_1.publishReplay(1), operators_1.refCount());
26268 var visibleBBox$ = rxjs_1.combineLatest(clampedConfiguration$, currentlatLon$).pipe(operators_1.map(function (_a) {
26269 var configuration = _a[0], latLon = _a[1];
26270 return _this._graphCalculator
26271 .boundingBoxCorners(latLon, configuration.visibleBBoxSize / 2);
26272 }), operators_1.publishReplay(1), operators_1.refCount());
26273 var visibleMarkers$ = rxjs_1.combineLatest(rxjs_1.concat(rxjs_1.of(this._markerSet), this._markerSet.changed$), visibleBBox$).pipe(operators_1.map(function (_a) {
26274 var set = _a[0], bbox = _a[1];
26275 return set.search(bbox);
26277 this._setChangedSubscription = geoInitiated$.pipe(operators_1.switchMap(function () {
26278 return visibleMarkers$.pipe(operators_1.withLatestFrom(_this._navigator.stateService.reference$, groundAltitude$));
26280 .subscribe(function (_a) {
26281 var markers = _a[0], reference = _a[1], alt = _a[2];
26282 var geoCoords = _this._geoCoords;
26283 var markerScene = _this._markerScene;
26284 var sceneMarkers = markerScene.markers;
26285 var markersToRemove = Object.assign({}, sceneMarkers);
26286 for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
26287 var marker = markers_1[_i];
26288 if (marker.id in sceneMarkers) {
26289 delete markersToRemove[marker.id];
26292 var point3d = geoCoords
26293 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
26294 markerScene.add(marker, point3d);
26297 for (var id in markersToRemove) {
26298 if (!markersToRemove.hasOwnProperty(id)) {
26301 markerScene.remove(id);
26304 this._markersUpdatedSubscription = geoInitiated$.pipe(operators_1.switchMap(function () {
26305 return _this._markerSet.updated$.pipe(operators_1.withLatestFrom(visibleBBox$, _this._navigator.stateService.reference$, groundAltitude$));
26307 .subscribe(function (_a) {
26308 var markers = _a[0], _b = _a[1], sw = _b[0], ne = _b[1], reference = _a[2], alt = _a[3];
26309 var geoCoords = _this._geoCoords;
26310 var markerScene = _this._markerScene;
26311 for (var _i = 0, markers_2 = markers; _i < markers_2.length; _i++) {
26312 var marker = markers_2[_i];
26313 var exists = markerScene.has(marker.id);
26314 var visible = marker.latLon.lat > sw.lat &&
26315 marker.latLon.lat < ne.lat &&
26316 marker.latLon.lon > sw.lon &&
26317 marker.latLon.lon < ne.lon;
26319 var point3d = geoCoords
26320 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
26321 markerScene.add(marker, point3d);
26323 else if (!visible && exists) {
26324 markerScene.remove(marker.id);
26328 this._referenceSubscription = this._navigator.stateService.reference$.pipe(operators_1.skip(1), operators_1.withLatestFrom(groundAltitude$))
26329 .subscribe(function (_a) {
26330 var reference = _a[0], alt = _a[1];
26331 var geoCoords = _this._geoCoords;
26332 var markerScene = _this._markerScene;
26333 for (var _i = 0, _b = markerScene.getAll(); _i < _b.length; _i++) {
26334 var marker = _b[_i];
26335 var point3d = geoCoords
26336 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
26337 markerScene.update(marker.id, point3d);
26340 this._adjustHeightSubscription = groundAltitude$.pipe(operators_1.skip(1), operators_1.withLatestFrom(this._navigator.stateService.reference$, currentlatLon$))
26341 .subscribe(function (_a) {
26342 var alt = _a[0], reference = _a[1], latLon = _a[2];
26343 var geoCoords = _this._geoCoords;
26344 var markerScene = _this._markerScene;
26345 var position = geoCoords
26346 .geodeticToEnu(latLon.lat, latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
26347 for (var _i = 0, _b = markerScene.getAll(); _i < _b.length; _i++) {
26348 var marker = _b[_i];
26349 var point3d = geoCoords
26350 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
26351 var distanceX = point3d[0] - position[0];
26352 var distanceY = point3d[1] - position[1];
26353 var groundDistance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
26354 if (groundDistance > 50) {
26357 markerScene.lerpAltitude(marker.id, alt, Math.min(1, Math.max(0, 1.2 - 1.2 * groundDistance / 50)));
26360 this._renderSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
26361 var scene = _this._markerScene;
26366 needsRender: scene.needsRender,
26367 render: scene.render.bind(scene),
26368 stage: Render_1.GLRenderStage.Foreground,
26372 .subscribe(this._container.glRenderer.render$);
26373 var hoveredMarkerId$ = rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._container.mouseService.mouseMove$).pipe(operators_1.map(function (_a) {
26374 var render = _a[0], event = _a[1];
26375 var element = _this._container.element;
26376 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
26377 var viewport = _this._viewportCoords.canvasToViewport(canvasX, canvasY, element);
26378 var markerId = _this._markerScene.intersectObjects(viewport, render.perspective);
26380 }), operators_1.publishReplay(1), operators_1.refCount());
26381 var draggingStarted$ = this._container.mouseService
26382 .filtered$(this._name, this._container.mouseService.mouseDragStart$).pipe(operators_1.map(function (event) {
26385 var draggingStopped$ = this._container.mouseService
26386 .filtered$(this._name, this._container.mouseService.mouseDragEnd$).pipe(operators_1.map(function (event) {
26389 var filteredDragging$ = rxjs_1.merge(draggingStarted$, draggingStopped$).pipe(operators_1.startWith(false));
26390 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())
26391 .subscribe(function (_a) {
26392 var previous = _a[0], current = _a[1];
26393 var dragging = current[0];
26394 var eventType = dragging ? MarkerComponent.dragstart : MarkerComponent.dragend;
26395 var id = dragging ? current[1] : previous[1];
26396 var marker = _this._markerScene.get(id);
26397 var markerEvent = { marker: marker, target: _this, type: eventType };
26398 _this.fire(eventType, markerEvent);
26400 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));
26401 this._mouseClaimSubscription = rxjs_1.combineLatest(this._container.mouseService.active$, hoveredMarkerId$.pipe(operators_1.distinctUntilChanged()), mouseDown$, filteredDragging$).pipe(operators_1.map(function (_a) {
26402 var active = _a[0], markerId = _a[1], mouseDown = _a[2], filteredDragging = _a[3];
26403 return (!active && markerId != null && mouseDown) || filteredDragging;
26404 }), operators_1.distinctUntilChanged())
26405 .subscribe(function (claim) {
26407 _this._container.mouseService.claimMouse(_this._name, 1);
26408 _this._container.mouseService.claimWheel(_this._name, 1);
26411 _this._container.mouseService.unclaimMouse(_this._name);
26412 _this._container.mouseService.unclaimWheel(_this._name);
26415 var offset$ = this._container.mouseService
26416 .filtered$(this._name, this._container.mouseService.mouseDragStart$).pipe(operators_1.withLatestFrom(hoveredMarkerId$, this._container.renderService.renderCamera$), operators_1.map(function (_a) {
26417 var e = _a[0], id = _a[1], r = _a[2];
26418 var marker = _this._markerScene.get(id);
26419 var element = _this._container.element;
26420 var _b = _this._viewportCoords.projectToCanvas(marker.geometry.position.toArray(), element, r.perspective), groundCanvasX = _b[0], groundCanvasY = _b[1];
26421 var _c = _this._viewportCoords.canvasPosition(e, element), canvasX = _c[0], canvasY = _c[1];
26422 var offset = [canvasX - groundCanvasX, canvasY - groundCanvasY];
26423 return [marker, offset, r];
26424 }), operators_1.publishReplay(1), operators_1.refCount());
26425 this._updateMarkerSubscription = this._container.mouseService
26426 .filtered$(this._name, this._container.mouseService.mouseDrag$).pipe(operators_1.withLatestFrom(offset$, this._navigator.stateService.reference$, clampedConfiguration$))
26427 .subscribe(function (_a) {
26428 var event = _a[0], _b = _a[1], marker = _b[0], offset = _b[1], render = _b[2], reference = _a[2], configuration = _a[3];
26429 if (!_this._markerScene.has(marker.id)) {
26432 var element = _this._container.element;
26433 var _c = _this._viewportCoords.canvasPosition(event, element), canvasX = _c[0], canvasY = _c[1];
26434 var groundX = canvasX - offset[0];
26435 var groundY = canvasY - offset[1];
26436 var _d = _this._viewportCoords
26437 .canvasToViewport(groundX, groundY, element), viewportX = _d[0], viewportY = _d[1];
26438 var direction = new THREE.Vector3(viewportX, viewportY, 1)
26439 .unproject(render.perspective)
26440 .sub(render.perspective.position)
26442 var distance = Math.min(_this._relativeGroundAltitude / direction.z, configuration.visibleBBoxSize / 2 - 0.1);
26443 if (distance < 0) {
26446 var intersection = direction
26448 .multiplyScalar(distance)
26449 .add(render.perspective.position);
26450 intersection.z = render.perspective.position.z + _this._relativeGroundAltitude;
26451 var _e = _this._geoCoords
26452 .enuToGeodetic(intersection.x, intersection.y, intersection.z, reference.lat, reference.lon, reference.alt), lat = _e[0], lon = _e[1];
26453 _this._markerScene.update(marker.id, intersection.toArray(), { lat: lat, lon: lon });
26454 _this._markerSet.update(marker);
26455 var markerEvent = { marker: marker, target: _this, type: MarkerComponent.changed };
26456 _this.fire(MarkerComponent.changed, markerEvent);
26459 MarkerComponent.prototype._deactivate = function () {
26460 this._adjustHeightSubscription.unsubscribe();
26461 this._dragEventSubscription.unsubscribe();
26462 this._markersUpdatedSubscription.unsubscribe();
26463 this._mouseClaimSubscription.unsubscribe();
26464 this._referenceSubscription.unsubscribe();
26465 this._renderSubscription.unsubscribe();
26466 this._setChangedSubscription.unsubscribe();
26467 this._updateMarkerSubscription.unsubscribe();
26468 this._markerScene.clear();
26470 MarkerComponent.prototype._getDefaultConfiguration = function () {
26471 return { visibleBBoxSize: 100 };
26473 MarkerComponent.componentName = "marker";
26475 * Fired when the position of a marker is changed.
26477 * @type {IMarkerEvent} markerEvent - Marker event data.
26480 * markerComponent.on("changed", function(e) {
26481 * console.log(e.marker.id, e.marker.latLon);
26485 MarkerComponent.changed = "changed";
26487 * Fired when a marker drag interaction starts.
26489 * @type {IMarkerEvent} markerEvent - Marker event data.
26492 * markerComponent.on("dragstart", function(e) {
26493 * console.log(e.marker.id, e.marker.latLon);
26497 MarkerComponent.dragstart = "dragstart";
26499 * Fired when a marker drag interaction ends.
26501 * @type {IMarkerEvent} markerEvent - Marker event data.
26504 * markerComponent.on("dragend", function(e) {
26505 * console.log(e.marker.id, e.marker.latLon);
26509 MarkerComponent.dragend = "dragend";
26510 return MarkerComponent;
26511 }(Component_1.Component));
26512 exports.MarkerComponent = MarkerComponent;
26513 Component_1.ComponentService.register(MarkerComponent);
26514 exports.default = MarkerComponent;
26517 },{"../../Component":275,"../../Geo":278,"../../Graph":279,"../../Render":281,"rxjs":27,"rxjs/operators":225,"three":226,"when":272}],317:[function(require,module,exports){
26519 Object.defineProperty(exports, "__esModule", { value: true });
26520 var THREE = require("three");
26521 var MarkerScene = /** @class */ (function () {
26522 function MarkerScene(scene, raycaster) {
26523 this._needsRender = false;
26524 this._interactiveObjects = [];
26525 this._markers = {};
26526 this._objectMarkers = {};
26527 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster();
26528 this._scene = !!scene ? scene : new THREE.Scene();
26530 Object.defineProperty(MarkerScene.prototype, "markers", {
26532 return this._markers;
26537 Object.defineProperty(MarkerScene.prototype, "needsRender", {
26539 return this._needsRender;
26544 MarkerScene.prototype.add = function (marker, position) {
26545 if (marker.id in this._markers) {
26546 this._dispose(marker.id);
26548 marker.createGeometry(position);
26549 this._scene.add(marker.geometry);
26550 this._markers[marker.id] = marker;
26551 for (var _i = 0, _a = marker.getInteractiveObjects(); _i < _a.length; _i++) {
26552 var interactiveObject = _a[_i];
26553 this._interactiveObjects.push(interactiveObject);
26554 this._objectMarkers[interactiveObject.uuid] = marker.id;
26556 this._needsRender = true;
26558 MarkerScene.prototype.clear = function () {
26559 for (var id in this._markers) {
26560 if (!this._markers.hasOwnProperty) {
26565 this._needsRender = true;
26567 MarkerScene.prototype.get = function (id) {
26568 return this._markers[id];
26570 MarkerScene.prototype.getAll = function () {
26573 .keys(this._markers)
26574 .map(function (id) { return _this._markers[id]; });
26576 MarkerScene.prototype.has = function (id) {
26577 return id in this._markers;
26579 MarkerScene.prototype.intersectObjects = function (_a, camera) {
26580 var viewportX = _a[0], viewportY = _a[1];
26581 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
26582 var intersects = this._raycaster.intersectObjects(this._interactiveObjects);
26583 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
26584 var intersect = intersects_1[_i];
26585 if (intersect.object.uuid in this._objectMarkers) {
26586 return this._objectMarkers[intersect.object.uuid];
26591 MarkerScene.prototype.lerpAltitude = function (id, alt, alpha) {
26592 if (!(id in this._markers)) {
26595 this._markers[id].lerpAltitude(alt, alpha);
26596 this._needsRender = true;
26598 MarkerScene.prototype.remove = function (id) {
26599 if (!(id in this._markers)) {
26603 this._needsRender = true;
26605 MarkerScene.prototype.render = function (perspectiveCamera, renderer) {
26606 renderer.render(this._scene, perspectiveCamera);
26607 this._needsRender = false;
26609 MarkerScene.prototype.update = function (id, position, latLon) {
26610 if (!(id in this._markers)) {
26613 var marker = this._markers[id];
26614 marker.updatePosition(position, latLon);
26615 this._needsRender = true;
26617 MarkerScene.prototype._dispose = function (id) {
26618 var marker = this._markers[id];
26619 this._scene.remove(marker.geometry);
26620 for (var _i = 0, _a = marker.getInteractiveObjects(); _i < _a.length; _i++) {
26621 var interactiveObject = _a[_i];
26622 var index = this._interactiveObjects.indexOf(interactiveObject);
26623 if (index !== -1) {
26624 this._interactiveObjects.splice(index, 1);
26627 console.warn("Object does not exist (" + interactiveObject.id + ") for " + id);
26629 delete this._objectMarkers[interactiveObject.uuid];
26631 marker.disposeGeometry();
26632 delete this._markers[id];
26634 return MarkerScene;
26636 exports.MarkerScene = MarkerScene;
26637 exports.default = MarkerScene;
26639 },{"three":226}],318:[function(require,module,exports){
26641 Object.defineProperty(exports, "__esModule", { value: true });
26642 var rbush = require("rbush");
26643 var rxjs_1 = require("rxjs");
26644 var MarkerSet = /** @class */ (function () {
26645 function MarkerSet() {
26647 this._index = rbush(16, [".lon", ".lat", ".lon", ".lat"]);
26648 this._indexChanged$ = new rxjs_1.Subject();
26649 this._updated$ = new rxjs_1.Subject();
26651 Object.defineProperty(MarkerSet.prototype, "changed$", {
26653 return this._indexChanged$;
26658 Object.defineProperty(MarkerSet.prototype, "updated$", {
26660 return this._updated$;
26665 MarkerSet.prototype.add = function (markers) {
26667 var hash = this._hash;
26668 var index = this._index;
26669 for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
26670 var marker = markers_1[_i];
26671 var id = marker.id;
26673 index.remove(hash[id]);
26674 updated.push(marker);
26677 lat: marker.latLon.lat,
26678 lon: marker.latLon.lon,
26682 index.insert(item);
26684 if (updated.length > 0) {
26685 this._updated$.next(updated);
26687 if (markers.length > updated.length) {
26688 this._indexChanged$.next(this);
26691 MarkerSet.prototype.has = function (id) {
26692 return id in this._hash;
26694 MarkerSet.prototype.get = function (id) {
26695 return this.has(id) ? this._hash[id].marker : undefined;
26697 MarkerSet.prototype.getAll = function () {
26700 .map(function (indexItem) {
26701 return indexItem.marker;
26704 MarkerSet.prototype.remove = function (ids) {
26705 var hash = this._hash;
26706 var index = this._index;
26707 var changed = false;
26708 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
26709 var id = ids_1[_i];
26710 if (!(id in hash)) {
26713 var item = hash[id];
26714 index.remove(item);
26719 this._indexChanged$.next(this);
26722 MarkerSet.prototype.removeAll = function () {
26724 this._index.clear();
26725 this._indexChanged$.next(this);
26727 MarkerSet.prototype.search = function (_a) {
26728 var sw = _a[0], ne = _a[1];
26730 .search({ maxX: ne.lon, maxY: ne.lat, minX: sw.lon, minY: sw.lat })
26731 .map(function (indexItem) {
26732 return indexItem.marker;
26735 MarkerSet.prototype.update = function (marker) {
26736 var hash = this._hash;
26737 var index = this._index;
26738 var id = marker.id;
26739 if (!(id in hash)) {
26742 index.remove(hash[id]);
26744 lat: marker.latLon.lat,
26745 lon: marker.latLon.lon,
26749 index.insert(item);
26753 exports.MarkerSet = MarkerSet;
26754 exports.default = MarkerSet;
26756 },{"rbush":26,"rxjs":27}],319:[function(require,module,exports){
26758 var __extends = (this && this.__extends) || (function () {
26759 var extendStatics = function (d, b) {
26760 extendStatics = Object.setPrototypeOf ||
26761 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26762 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26763 return extendStatics(d, b);
26765 return function (d, b) {
26766 extendStatics(d, b);
26767 function __() { this.constructor = d; }
26768 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26771 Object.defineProperty(exports, "__esModule", { value: true });
26772 var THREE = require("three");
26773 var Component_1 = require("../../../Component");
26775 * @class CircleMarker
26777 * @classdesc Non-interactive marker with a flat circle shape. The circle
26778 * marker can not be configured to be interactive.
26780 * Circle marker properties can not be updated after creation.
26782 * To create and add one `CircleMarker` with default configuration
26783 * and one with configuration use
26787 * var defaultMarker = new Mapillary.MarkerComponent.CircleMarker(
26789 * { lat: 0, lon: 0, });
26791 * var configuredMarker = new Mapillary.MarkerComponent.CircleMarker(
26793 * { lat: 0, lon: 0, },
26800 * markerComponent.add([defaultMarker, configuredMarker]);
26803 var CircleMarker = /** @class */ (function (_super) {
26804 __extends(CircleMarker, _super);
26805 function CircleMarker(id, latLon, options) {
26806 var _this = _super.call(this, id, latLon) || this;
26807 options = !!options ? options : {};
26808 _this._color = options.color != null ? options.color : 0xffffff;
26809 _this._opacity = options.opacity != null ? options.opacity : 0.4;
26810 _this._radius = options.radius != null ? options.radius : 1;
26813 CircleMarker.prototype._createGeometry = function (position) {
26814 var circle = new THREE.Mesh(new THREE.CircleGeometry(this._radius, 16), new THREE.MeshBasicMaterial({
26815 color: this._color,
26816 opacity: this._opacity,
26819 circle.up.fromArray([0, 0, 1]);
26820 circle.renderOrder = -1;
26821 var group = new THREE.Object3D();
26823 group.position.fromArray(position);
26824 this._geometry = group;
26826 CircleMarker.prototype._disposeGeometry = function () {
26827 for (var _i = 0, _a = this._geometry.children; _i < _a.length; _i++) {
26829 mesh.geometry.dispose();
26830 mesh.material.dispose();
26833 CircleMarker.prototype._getInteractiveObjects = function () {
26836 return CircleMarker;
26837 }(Component_1.Marker));
26838 exports.CircleMarker = CircleMarker;
26839 exports.default = CircleMarker;
26841 },{"../../../Component":275,"three":226}],320:[function(require,module,exports){
26843 Object.defineProperty(exports, "__esModule", { value: true });
26847 * @classdesc Represents an abstract marker class that should be extended
26848 * by marker implementations used in the marker component.
26850 var Marker = /** @class */ (function () {
26851 function Marker(id, latLon) {
26853 this._latLon = latLon;
26855 Object.defineProperty(Marker.prototype, "id", {
26858 * @returns {string} The id of the marker.
26866 Object.defineProperty(Marker.prototype, "geometry", {
26873 return this._geometry;
26878 Object.defineProperty(Marker.prototype, "latLon", {
26881 * @returns {ILatLon} The geographic coordinates of the marker.
26884 return this._latLon;
26890 Marker.prototype.createGeometry = function (position) {
26891 if (!!this._geometry) {
26894 this._createGeometry(position);
26895 // update matrix world if raycasting occurs before first render
26896 this._geometry.updateMatrixWorld(true);
26899 Marker.prototype.disposeGeometry = function () {
26900 if (!this._geometry) {
26903 this._disposeGeometry();
26904 this._geometry = undefined;
26907 Marker.prototype.getInteractiveObjects = function () {
26908 if (!this._geometry) {
26911 return this._getInteractiveObjects();
26914 Marker.prototype.lerpAltitude = function (alt, alpha) {
26915 if (!this._geometry) {
26918 this._geometry.position.z = (1 - alpha) * this._geometry.position.z + alpha * alt;
26921 Marker.prototype.updatePosition = function (position, latLon) {
26923 this._latLon.lat = latLon.lat;
26924 this._latLon.lon = latLon.lon;
26926 if (!this._geometry) {
26929 this._geometry.position.fromArray(position);
26930 this._geometry.updateMatrixWorld(true);
26934 exports.Marker = Marker;
26935 exports.default = Marker;
26937 },{}],321:[function(require,module,exports){
26939 var __extends = (this && this.__extends) || (function () {
26940 var extendStatics = function (d, b) {
26941 extendStatics = Object.setPrototypeOf ||
26942 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26943 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26944 return extendStatics(d, b);
26946 return function (d, b) {
26947 extendStatics(d, b);
26948 function __() { this.constructor = d; }
26949 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26952 Object.defineProperty(exports, "__esModule", { value: true });
26953 var THREE = require("three");
26954 var Component_1 = require("../../../Component");
26956 * @class SimpleMarker
26958 * @classdesc Interactive marker with ice cream shape. The sphere
26959 * inside the ice cream can be configured to be interactive.
26961 * Simple marker properties can not be updated after creation.
26963 * To create and add one `SimpleMarker` with default configuration
26964 * (non-interactive) and one interactive with configuration use
26968 * var defaultMarker = new Mapillary.MarkerComponent.SimpleMarker(
26970 * { lat: 0, lon: 0, });
26972 * var interactiveMarker = new Mapillary.MarkerComponent.SimpleMarker(
26974 * { lat: 0, lon: 0, },
26976 * ballColor: "#00f",
26977 * ballOpacity: 0.5,
26979 * interactive: true,
26984 * markerComponent.add([defaultMarker, interactiveMarker]);
26987 var SimpleMarker = /** @class */ (function (_super) {
26988 __extends(SimpleMarker, _super);
26989 function SimpleMarker(id, latLon, options) {
26990 var _this = _super.call(this, id, latLon) || this;
26991 options = !!options ? options : {};
26992 _this._ballColor = options.ballColor != null ? options.ballColor : 0xff0000;
26993 _this._ballOpacity = options.ballOpacity != null ? options.ballOpacity : 0.8;
26994 _this._circleToRayAngle = 2;
26995 _this._color = options.color != null ? options.color : 0xff0000;
26996 _this._interactive = !!options.interactive;
26997 _this._opacity = options.opacity != null ? options.opacity : 0.4;
26998 _this._radius = options.radius != null ? options.radius : 1;
27001 SimpleMarker.prototype._createGeometry = function (position) {
27002 var radius = this._radius;
27003 var cone = new THREE.Mesh(this._markerGeometry(radius, 8, 8), new THREE.MeshBasicMaterial({
27004 color: this._color,
27005 opacity: this._opacity,
27008 cone.renderOrder = 1;
27009 var ball = new THREE.Mesh(new THREE.SphereGeometry(radius / 2, 8, 8), new THREE.MeshBasicMaterial({
27010 color: this._ballColor,
27011 opacity: this._ballOpacity,
27014 ball.position.z = this._markerHeight(radius);
27015 var group = new THREE.Object3D();
27018 group.position.fromArray(position);
27019 this._geometry = group;
27021 SimpleMarker.prototype._disposeGeometry = function () {
27022 for (var _i = 0, _a = this._geometry.children; _i < _a.length; _i++) {
27024 mesh.geometry.dispose();
27025 mesh.material.dispose();
27028 SimpleMarker.prototype._getInteractiveObjects = function () {
27029 return this._interactive ? [this._geometry.children[0]] : [];
27031 SimpleMarker.prototype._markerHeight = function (radius) {
27032 var t = Math.tan(Math.PI - this._circleToRayAngle);
27033 return radius * Math.sqrt(1 + t * t);
27035 SimpleMarker.prototype._markerGeometry = function (radius, widthSegments, heightSegments) {
27036 var geometry = new THREE.Geometry();
27037 widthSegments = Math.max(3, Math.floor(widthSegments) || 8);
27038 heightSegments = Math.max(2, Math.floor(heightSegments) || 6);
27039 var height = this._markerHeight(radius);
27041 for (var y = 0; y <= heightSegments; ++y) {
27042 var verticesRow = [];
27043 for (var x = 0; x <= widthSegments; ++x) {
27044 var u = x / widthSegments * Math.PI * 2;
27045 var v = y / heightSegments * Math.PI;
27047 if (v < this._circleToRayAngle) {
27051 var t = Math.tan(v - this._circleToRayAngle);
27052 r = radius * Math.sqrt(1 + t * t);
27054 var vertex = new THREE.Vector3();
27055 vertex.x = r * Math.cos(u) * Math.sin(v);
27056 vertex.y = r * Math.sin(u) * Math.sin(v);
27057 vertex.z = r * Math.cos(v) + height;
27058 geometry.vertices.push(vertex);
27059 verticesRow.push(geometry.vertices.length - 1);
27061 vertices.push(verticesRow);
27063 for (var y = 0; y < heightSegments; ++y) {
27064 for (var x = 0; x < widthSegments; ++x) {
27065 var v1 = vertices[y][x + 1];
27066 var v2 = vertices[y][x];
27067 var v3 = vertices[y + 1][x];
27068 var v4 = vertices[y + 1][x + 1];
27069 var n1 = geometry.vertices[v1].clone().normalize();
27070 var n2 = geometry.vertices[v2].clone().normalize();
27071 var n3 = geometry.vertices[v3].clone().normalize();
27072 var n4 = geometry.vertices[v4].clone().normalize();
27073 geometry.faces.push(new THREE.Face3(v1, v2, v4, [n1, n2, n4]));
27074 geometry.faces.push(new THREE.Face3(v2, v3, v4, [n2.clone(), n3, n4.clone()]));
27077 geometry.computeFaceNormals();
27078 geometry.boundingSphere = new THREE.Sphere(new THREE.Vector3(), radius + height);
27081 return SimpleMarker;
27082 }(Component_1.Marker));
27083 exports.SimpleMarker = SimpleMarker;
27084 exports.default = SimpleMarker;
27086 },{"../../../Component":275,"three":226}],322:[function(require,module,exports){
27088 var __extends = (this && this.__extends) || (function () {
27089 var extendStatics = function (d, b) {
27090 extendStatics = Object.setPrototypeOf ||
27091 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27092 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27093 return extendStatics(d, b);
27095 return function (d, b) {
27096 extendStatics(d, b);
27097 function __() { this.constructor = d; }
27098 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27101 Object.defineProperty(exports, "__esModule", { value: true });
27102 var rxjs_1 = require("rxjs");
27103 var operators_1 = require("rxjs/operators");
27104 var Component_1 = require("../../Component");
27106 * The `BounceHandler` ensures that the viewer bounces back to the image
27107 * when drag panning outside of the image edge.
27109 var BounceHandler = /** @class */ (function (_super) {
27110 __extends(BounceHandler, _super);
27111 function BounceHandler(component, container, navigator, viewportCoords, spatial) {
27112 var _this = _super.call(this, component, container, navigator) || this;
27113 _this._spatial = spatial;
27114 _this._viewportCoords = viewportCoords;
27117 BounceHandler.prototype._enable = function () {
27119 var inTransition$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
27120 return frame.state.alpha < 1;
27122 this._bounceSubscription = rxjs_1.combineLatest(inTransition$, this._navigator.stateService.inTranslation$, this._container.mouseService.active$, this._container.touchService.active$).pipe(operators_1.map(function (noForce) {
27123 return noForce[0] || noForce[1] || noForce[2] || noForce[3];
27124 }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (noForce) {
27127 rxjs_1.combineLatest(_this._container.renderService.renderCamera$, _this._navigator.stateService.currentTransform$.pipe(operators_1.first()));
27129 .subscribe(function (_a) {
27130 var render = _a[0], transform = _a[1];
27131 if (!transform.hasValidScale && render.camera.focal < 0.1) {
27134 if (render.perspective.aspect === 0 || render.perspective.aspect === Number.POSITIVE_INFINITY) {
27137 var distances = Component_1.ImageBoundary.viewportDistances(transform, render.perspective, _this._viewportCoords);
27138 if (Math.max.apply(Math, distances) < 0.01) {
27141 var horizontalDistance = distances[1] - distances[3];
27142 var verticalDistance = distances[0] - distances[2];
27143 var currentDirection = _this._viewportCoords
27144 .unprojectFromViewport(0, 0, render.perspective)
27145 .sub(render.perspective.position);
27146 var directionPhi = _this._viewportCoords
27147 .unprojectFromViewport(horizontalDistance, 0, render.perspective)
27148 .sub(render.perspective.position);
27149 var directionTheta = _this._viewportCoords
27150 .unprojectFromViewport(0, verticalDistance, render.perspective)
27151 .sub(render.perspective.position);
27152 var phi = (horizontalDistance > 0 ? 1 : -1) * directionPhi.angleTo(currentDirection);
27153 var theta = (verticalDistance > 0 ? 1 : -1) * directionTheta.angleTo(currentDirection);
27154 var threshold = Math.PI / 60;
27156 phi = _this._spatial.clamp(coeff * phi, -threshold, threshold);
27157 theta = _this._spatial.clamp(coeff * theta, -threshold, threshold);
27158 _this._navigator.stateService.rotateUnbounded({ phi: phi, theta: theta });
27161 BounceHandler.prototype._disable = function () {
27162 this._bounceSubscription.unsubscribe();
27164 BounceHandler.prototype._getConfiguration = function () {
27167 return BounceHandler;
27168 }(Component_1.HandlerBase));
27169 exports.BounceHandler = BounceHandler;
27170 exports.default = BounceHandler;
27172 },{"../../Component":275,"rxjs":27,"rxjs/operators":225}],323:[function(require,module,exports){
27174 var __extends = (this && this.__extends) || (function () {
27175 var extendStatics = function (d, b) {
27176 extendStatics = Object.setPrototypeOf ||
27177 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27178 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27179 return extendStatics(d, b);
27181 return function (d, b) {
27182 extendStatics(d, b);
27183 function __() { this.constructor = d; }
27184 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27187 Object.defineProperty(exports, "__esModule", { value: true });
27188 var rxjs_1 = require("rxjs");
27189 var operators_1 = require("rxjs/operators");
27190 var Component_1 = require("../../Component");
27192 * The `DoubleClickZoomHandler` allows the user to zoom the viewer image at a point by double clicking.
27196 * var mouseComponent = viewer.getComponent("mouse");
27198 * mouseComponent.doubleClickZoom.disable();
27199 * mouseComponent.doubleClickZoom.enable();
27201 * var isEnabled = mouseComponent.doubleClickZoom.isEnabled;
27204 var DoubleClickZoomHandler = /** @class */ (function (_super) {
27205 __extends(DoubleClickZoomHandler, _super);
27207 function DoubleClickZoomHandler(component, container, navigator, viewportCoords) {
27208 var _this = _super.call(this, component, container, navigator) || this;
27209 _this._viewportCoords = viewportCoords;
27212 DoubleClickZoomHandler.prototype._enable = function () {
27214 this._zoomSubscription = rxjs_1.merge(this._container.mouseService
27215 .filtered$(this._component.name, this._container.mouseService.dblClick$), this._container.touchService.doubleTap$.pipe(operators_1.map(function (e) {
27216 var touch = e.touches[0];
27217 return { clientX: touch.clientX, clientY: touch.clientY, shiftKey: e.shiftKey };
27218 }))).pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
27219 .subscribe(function (_a) {
27220 var event = _a[0], render = _a[1], transform = _a[2];
27221 var element = _this._container.element;
27222 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
27223 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
27224 var reference = transform.projectBasic(unprojected.toArray());
27225 var delta = !!event.shiftKey ? -1 : 1;
27226 _this._navigator.stateService.zoomIn(delta, reference);
27229 DoubleClickZoomHandler.prototype._disable = function () {
27230 this._zoomSubscription.unsubscribe();
27232 DoubleClickZoomHandler.prototype._getConfiguration = function (enable) {
27233 return { doubleClickZoom: enable };
27235 return DoubleClickZoomHandler;
27236 }(Component_1.HandlerBase));
27237 exports.DoubleClickZoomHandler = DoubleClickZoomHandler;
27238 exports.default = DoubleClickZoomHandler;
27240 },{"../../Component":275,"rxjs":27,"rxjs/operators":225}],324:[function(require,module,exports){
27242 var __extends = (this && this.__extends) || (function () {
27243 var extendStatics = function (d, b) {
27244 extendStatics = Object.setPrototypeOf ||
27245 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27246 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27247 return extendStatics(d, b);
27249 return function (d, b) {
27250 extendStatics(d, b);
27251 function __() { this.constructor = d; }
27252 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27255 Object.defineProperty(exports, "__esModule", { value: true });
27256 var rxjs_1 = require("rxjs");
27257 var operators_1 = require("rxjs/operators");
27258 var Component_1 = require("../../Component");
27260 * The `DragPanHandler` allows the user to pan the viewer image by clicking and dragging the cursor.
27264 * var mouseComponent = viewer.getComponent("mouse");
27266 * mouseComponent.dragPan.disable();
27267 * mouseComponent.dragPan.enable();
27269 * var isEnabled = mouseComponent.dragPan.isEnabled;
27272 var DragPanHandler = /** @class */ (function (_super) {
27273 __extends(DragPanHandler, _super);
27275 function DragPanHandler(component, container, navigator, viewportCoords, spatial) {
27276 var _this = _super.call(this, component, container, navigator) || this;
27277 _this._spatial = spatial;
27278 _this._viewportCoords = viewportCoords;
27281 DragPanHandler.prototype._enable = function () {
27283 var draggingStarted$ = this._container.mouseService
27284 .filtered$(this._component.name, this._container.mouseService.mouseDragStart$).pipe(operators_1.map(function () {
27286 }), operators_1.share());
27287 var draggingStopped$ = this._container.mouseService
27288 .filtered$(this._component.name, this._container.mouseService.mouseDragEnd$).pipe(operators_1.map(function () {
27290 }), operators_1.share());
27291 this._activeMouseSubscription = rxjs_1.merge(draggingStarted$, draggingStopped$)
27292 .subscribe(this._container.mouseService.activate$);
27293 var documentMouseMove$ = rxjs_1.merge(draggingStarted$, draggingStopped$).pipe(operators_1.switchMap(function (dragging) {
27295 _this._container.mouseService.documentMouseMove$ :
27298 this._preventDefaultSubscription = rxjs_1.merge(documentMouseMove$, this._container.touchService.touchMove$)
27299 .subscribe(function (event) {
27300 event.preventDefault(); // prevent selection of content outside the viewer
27302 var touchMovingStarted$ = this._container.touchService.singleTouchDragStart$.pipe(operators_1.map(function () {
27305 var touchMovingStopped$ = this._container.touchService.singleTouchDragEnd$.pipe(operators_1.map(function () {
27308 this._activeTouchSubscription = rxjs_1.merge(touchMovingStarted$, touchMovingStopped$)
27309 .subscribe(this._container.touchService.activate$);
27310 var rotation$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
27311 return frame.state.currentNode.fullPano || frame.state.nodesAhead < 1;
27312 }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (enable) {
27314 return rxjs_1.empty();
27316 var mouseDrag$ = Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService);
27317 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) {
27318 return event != null && event.touches.length > 0 ?
27319 event.touches[0] : null;
27320 }), operators_1.pairwise(), operators_1.filter(function (pair) {
27321 return pair[0] != null && pair[1] != null;
27323 return rxjs_1.merge(mouseDrag$, singleTouchDrag$);
27324 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
27325 var events = _a[0], render = _a[1], transform = _a[2];
27326 var previousEvent = events[0];
27327 var event = events[1];
27328 var movementX = event.clientX - previousEvent.clientX;
27329 var movementY = event.clientY - previousEvent.clientY;
27330 var element = _this._container.element;
27331 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
27332 var currentDirection = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective)
27333 .sub(render.perspective.position);
27334 var directionX = _this._viewportCoords.unprojectFromCanvas(canvasX - movementX, canvasY, element, render.perspective)
27335 .sub(render.perspective.position);
27336 var directionY = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY - movementY, element, render.perspective)
27337 .sub(render.perspective.position);
27338 var phi = (movementX > 0 ? 1 : -1) * directionX.angleTo(currentDirection);
27339 var theta = (movementY > 0 ? -1 : 1) * directionY.angleTo(currentDirection);
27340 var distances = Component_1.ImageBoundary.viewportDistances(transform, render.perspective, _this._viewportCoords);
27341 if (distances[0] > 0 && theta < 0) {
27342 theta /= Math.max(1, 2e2 * distances[0]);
27344 if (distances[2] > 0 && theta > 0) {
27345 theta /= Math.max(1, 2e2 * distances[2]);
27347 if (distances[1] > 0 && phi < 0) {
27348 phi /= Math.max(1, 2e2 * distances[1]);
27350 if (distances[3] > 0 && phi > 0) {
27351 phi /= Math.max(1, 2e2 * distances[3]);
27353 return { phi: phi, theta: theta };
27354 }), operators_1.share());
27355 this._rotateWithoutInertiaSubscription = rotation$
27356 .subscribe(function (rotation) {
27357 _this._navigator.stateService.rotateWithoutInertia(rotation);
27359 this._rotateSubscription = rotation$.pipe(operators_1.scan(function (rotationBuffer, rotation) {
27360 _this._drainBuffer(rotationBuffer);
27361 rotationBuffer.push([Date.now(), rotation]);
27362 return rotationBuffer;
27363 }, []), 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) {
27364 var drainedBuffer = _this._drainBuffer(rotationBuffer.slice());
27365 var rotation = { phi: 0, theta: 0 };
27366 for (var _i = 0, drainedBuffer_1 = drainedBuffer; _i < drainedBuffer_1.length; _i++) {
27367 var bufferedRotation = drainedBuffer_1[_i];
27368 rotation.phi += bufferedRotation[1].phi;
27369 rotation.theta += bufferedRotation[1].theta;
27371 var count = drainedBuffer.length;
27373 rotation.phi /= count;
27374 rotation.theta /= count;
27376 var threshold = Math.PI / 18;
27377 rotation.phi = _this._spatial.clamp(rotation.phi, -threshold, threshold);
27378 rotation.theta = _this._spatial.clamp(rotation.theta, -threshold, threshold);
27381 .subscribe(function (rotation) {
27382 _this._navigator.stateService.rotate(rotation);
27385 DragPanHandler.prototype._disable = function () {
27386 this._activeMouseSubscription.unsubscribe();
27387 this._activeTouchSubscription.unsubscribe();
27388 this._preventDefaultSubscription.unsubscribe();
27389 this._rotateSubscription.unsubscribe();
27390 this._rotateWithoutInertiaSubscription.unsubscribe();
27391 this._activeMouseSubscription = null;
27392 this._activeTouchSubscription = null;
27393 this._preventDefaultSubscription = null;
27394 this._rotateSubscription = null;
27396 DragPanHandler.prototype._getConfiguration = function (enable) {
27397 return { dragPan: enable };
27399 DragPanHandler.prototype._drainBuffer = function (buffer) {
27401 var now = Date.now();
27402 while (buffer.length > 0 && now - buffer[0][0] > cutoff) {
27407 return DragPanHandler;
27408 }(Component_1.HandlerBase));
27409 exports.DragPanHandler = DragPanHandler;
27410 exports.default = DragPanHandler;
27412 },{"../../Component":275,"rxjs":27,"rxjs/operators":225}],325:[function(require,module,exports){
27414 var __extends = (this && this.__extends) || (function () {
27415 var extendStatics = function (d, b) {
27416 extendStatics = Object.setPrototypeOf ||
27417 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27418 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27419 return extendStatics(d, b);
27421 return function (d, b) {
27422 extendStatics(d, b);
27423 function __() { this.constructor = d; }
27424 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27427 Object.defineProperty(exports, "__esModule", { value: true });
27428 var THREE = require("three");
27429 var rxjs_1 = require("rxjs");
27430 var operators_1 = require("rxjs/operators");
27431 var Component_1 = require("../../Component");
27432 var State_1 = require("../../State");
27433 var EarthControlHandler = /** @class */ (function (_super) {
27434 __extends(EarthControlHandler, _super);
27435 function EarthControlHandler(component, container, navigator, viewportCoords, spatial) {
27436 var _this = _super.call(this, component, container, navigator) || this;
27437 _this._spatial = spatial;
27438 _this._viewportCoords = viewportCoords;
27441 EarthControlHandler.prototype._enable = function () {
27443 var earth$ = this._navigator.stateService.state$.pipe(operators_1.map(function (state) {
27444 return state === State_1.State.Earth;
27445 }), operators_1.share());
27446 this._preventDefaultSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
27448 _this._container.mouseService.mouseWheel$ :
27451 .subscribe(function (event) {
27452 event.preventDefault();
27454 this._truckSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
27456 return rxjs_1.empty();
27458 return Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService).pipe(operators_1.filter(function (_a) {
27459 var e1 = _a[0], e2 = _a[1];
27460 return !(e1.ctrlKey && e2.ctrlKey);
27462 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
27463 var _b = _a[0], previous = _b[0], current = _b[1], render = _a[1], transform = _a[2];
27464 var planeNormal = [0, 0, 1];
27465 var planePoint = transform.unprojectBasic([0.5, 0.5], 0);
27466 planePoint[2] -= 2;
27467 var currentIntersection = _this._planeIntersection(current, planeNormal, planePoint, render.perspective, _this._container.element);
27468 var previousIntersection = _this._planeIntersection(previous, planeNormal, planePoint, render.perspective, _this._container.element);
27469 if (!currentIntersection || !previousIntersection) {
27472 var direction = new THREE.Vector3()
27473 .subVectors(currentIntersection, previousIntersection)
27474 .multiplyScalar(-1)
27477 }), operators_1.filter(function (direction) {
27478 return !!direction;
27480 .subscribe(function (direction) {
27481 _this._navigator.stateService.truck(direction);
27483 this._orbitSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
27485 return rxjs_1.empty();
27487 return Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService).pipe(operators_1.filter(function (_a) {
27488 var e1 = _a[0], e2 = _a[1];
27489 return e1.ctrlKey && e2.ctrlKey;
27491 }), operators_1.map(function (_a) {
27492 var previous = _a[0], current = _a[1];
27493 var _b = _this._eventToViewport(current, _this._container.element), currentX = _b[0], currentY = _b[1];
27494 var _c = _this._eventToViewport(previous, _this._container.element), previousX = _c[0], previousY = _c[1];
27495 var phi = (previousX - currentX) * Math.PI;
27496 var theta = (currentY - previousY) * Math.PI / 2;
27497 return { phi: phi, theta: theta };
27499 .subscribe(function (rotation) {
27500 _this._navigator.stateService.orbit(rotation);
27502 this._dollySubscription = earth$.pipe(operators_1.switchMap(function (earth) {
27504 return rxjs_1.empty();
27506 return _this._container.mouseService
27507 .filteredWheel$(_this._component.name, _this._container.mouseService.mouseWheel$);
27508 }), operators_1.map(function (event) {
27509 var delta = event.deltaY;
27510 if (event.deltaMode === 1) {
27511 delta = 40 * delta;
27513 else if (event.deltaMode === 2) {
27514 delta = 800 * delta;
27516 var canvasSize = _this._viewportCoords.containerToCanvas(_this._container.element);
27517 return -delta / canvasSize[1];
27519 .subscribe(function (delta) {
27520 _this._navigator.stateService.dolly(delta);
27523 EarthControlHandler.prototype._disable = function () {
27524 this._dollySubscription.unsubscribe();
27525 this._orbitSubscription.unsubscribe();
27526 this._preventDefaultSubscription.unsubscribe();
27527 this._truckSubscription.unsubscribe();
27529 EarthControlHandler.prototype._getConfiguration = function () {
27532 EarthControlHandler.prototype._eventToViewport = function (event, element) {
27533 var previousCanvas = this._viewportCoords.canvasPosition(event, element);
27534 return this._viewportCoords.canvasToViewport(previousCanvas[0], previousCanvas[1], element);
27536 EarthControlHandler.prototype._planeIntersection = function (event, planeNormal, planePoint, camera, element) {
27537 var _a = this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
27538 var direction = this._viewportCoords
27539 .unprojectFromCanvas(canvasX, canvasY, element, camera)
27540 .sub(camera.position)
27542 if (Math.abs(this._spatial.angleToPlane(direction.toArray(), planeNormal)) < Math.PI / 90) {
27545 var l0 = camera.position.clone();
27546 var n = new THREE.Vector3().fromArray(planeNormal);
27547 var p0 = new THREE.Vector3().fromArray(planePoint);
27548 var d = new THREE.Vector3().subVectors(p0, l0).dot(n) / direction.clone().dot(n);
27549 var intersection = new THREE.Vector3().addVectors(l0, direction.multiplyScalar(d));
27550 if (this._viewportCoords.worldToCamera(intersection.toArray(), camera)[2] > 0) {
27553 return intersection;
27555 return EarthControlHandler;
27556 }(Component_1.HandlerBase));
27557 exports.EarthControlHandler = EarthControlHandler;
27558 exports.default = EarthControlHandler;
27560 },{"../../Component":275,"../../State":282,"rxjs":27,"rxjs/operators":225,"three":226}],326:[function(require,module,exports){
27562 Object.defineProperty(exports, "__esModule", { value: true });
27563 var Geo_1 = require("../../../src/Geo");
27564 function basicBoundaryPoints(pointsPerSide) {
27566 var os = [[0, 0], [1, 0], [1, 1], [0, 1]];
27567 var ds = [[1, 0], [0, 1], [-1, 0], [0, -1]];
27568 for (var side = 0; side < 4; ++side) {
27571 for (var i = 0; i < pointsPerSide; ++i) {
27572 points.push([o[0] + d[0] * i / pointsPerSide,
27573 o[1] + d[1] * i / pointsPerSide]);
27578 function insideViewport(x, y) {
27579 return x >= -1 && x <= 1 && y >= -1 && y <= 1;
27581 function insideBasic(x, y) {
27582 return x >= 0 && x <= 1 && y >= 0 && y <= 1;
27584 function viewportDistances(transform, perspective, viewportCoords) {
27585 var boundaryPointsBasic = basicBoundaryPoints(100);
27586 var boundaryPointsViewport = boundaryPointsBasic
27587 .map(function (basic) {
27588 return viewportCoords.basicToViewportSafe(basic[0], basic[1], transform, perspective);
27590 var visibleBoundaryPoints = [];
27591 var viewportSides = [
27597 var intersections = [false, false, false, false];
27598 for (var i = 0; i < boundaryPointsViewport.length; i++) {
27599 var p1 = boundaryPointsViewport[i];
27600 var p2 = boundaryPointsViewport[(i + 1) % boundaryPointsViewport.length];
27605 if (insideViewport(p1[0], p1[1])) {
27606 visibleBoundaryPoints.push(p1);
27610 var x1 = p1[0], y1 = p1[1];
27611 var x2 = p2[0], y2 = p2[1];
27612 if (insideViewport(x1, y1)) {
27613 if (insideViewport(x2, y2)) {
27614 visibleBoundaryPoints.push(p1);
27617 for (var side = 0; side < 4; side++) {
27618 var s1 = { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } };
27619 var s2 = { p1: viewportSides[side], p2: viewportSides[(side + 1) % 4] };
27620 var intersecting = Geo_1.Lines.segmentsIntersect(s1, s2);
27621 if (intersecting) {
27622 var intersection = Geo_1.Lines.segmentIntersection(s1, s2);
27623 visibleBoundaryPoints.push(p1, [intersection.x, intersection.y]);
27624 intersections[side] = true;
27630 var _a = viewportCoords.viewportToBasic(-1, 1, transform, perspective), topLeftBasicX = _a[0], topLeftBasicY = _a[1];
27631 var _b = viewportCoords.viewportToBasic(1, 1, transform, perspective), topRightBasicX = _b[0], topRightBasicY = _b[1];
27632 var _c = viewportCoords.viewportToBasic(1, -1, transform, perspective), bottomRightBasicX = _c[0], bottomRightBasicY = _c[1];
27633 var _d = viewportCoords.viewportToBasic(-1, -1, transform, perspective), bottomLeftBasicX = _d[0], bottomLeftBasicY = _d[1];
27634 if (insideBasic(topLeftBasicX, topLeftBasicY)) {
27635 intersections[3] = intersections[0] = true;
27637 if (insideBasic(topRightBasicX, topRightBasicY)) {
27638 intersections[0] = intersections[1] = true;
27640 if (insideBasic(bottomRightBasicX, bottomRightBasicY)) {
27641 intersections[1] = intersections[2] = true;
27643 if (insideBasic(bottomLeftBasicX, bottomLeftBasicY)) {
27644 intersections[2] = intersections[3] = true;
27646 var maximums = [-1, -1, 1, 1];
27647 for (var _i = 0, visibleBoundaryPoints_1 = visibleBoundaryPoints; _i < visibleBoundaryPoints_1.length; _i++) {
27648 var visibleBoundaryPoint = visibleBoundaryPoints_1[_i];
27649 var x = visibleBoundaryPoint[0];
27650 var y = visibleBoundaryPoint[1];
27651 if (x > maximums[1]) {
27654 if (x < maximums[3]) {
27657 if (y > maximums[0]) {
27660 if (y < maximums[2]) {
27664 var boundary = [1, 1, -1, -1];
27665 var distances = [];
27666 for (var side = 0; side < 4; side++) {
27667 if (intersections[side]) {
27671 distances.push(Math.abs(boundary[side] - maximums[side]));
27675 exports.viewportDistances = viewportDistances;
27677 },{"../../../src/Geo":278}],327:[function(require,module,exports){
27679 var __extends = (this && this.__extends) || (function () {
27680 var extendStatics = function (d, b) {
27681 extendStatics = Object.setPrototypeOf ||
27682 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27683 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27684 return extendStatics(d, b);
27686 return function (d, b) {
27687 extendStatics(d, b);
27688 function __() { this.constructor = d; }
27689 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27692 Object.defineProperty(exports, "__esModule", { value: true });
27693 var Component_1 = require("../../Component");
27694 var Geo_1 = require("../../Geo");
27696 * @class MouseComponent
27698 * @classdesc Component handling mouse and touch events for camera movement.
27700 * To retrive and use the mouse component
27704 * var viewer = new Mapillary.Viewer(
27709 * var mouseComponent = viewer.getComponent("mouse");
27712 var MouseComponent = /** @class */ (function (_super) {
27713 __extends(MouseComponent, _super);
27715 function MouseComponent(name, container, navigator) {
27716 var _this = _super.call(this, name, container, navigator) || this;
27717 var spatial = new Geo_1.Spatial();
27718 var viewportCoords = new Geo_1.ViewportCoords();
27719 _this._bounceHandler = new Component_1.BounceHandler(_this, container, navigator, viewportCoords, spatial);
27720 _this._doubleClickZoomHandler = new Component_1.DoubleClickZoomHandler(_this, container, navigator, viewportCoords);
27721 _this._dragPanHandler = new Component_1.DragPanHandler(_this, container, navigator, viewportCoords, spatial);
27722 _this._earthControlHandler = new Component_1.EarthControlHandler(_this, container, navigator, viewportCoords, spatial);
27723 _this._scrollZoomHandler = new Component_1.ScrollZoomHandler(_this, container, navigator, viewportCoords);
27724 _this._touchZoomHandler = new Component_1.TouchZoomHandler(_this, container, navigator, viewportCoords);
27727 Object.defineProperty(MouseComponent.prototype, "doubleClickZoom", {
27729 * Get double click zoom.
27731 * @returns {DoubleClickZoomHandler} The double click zoom handler.
27734 return this._doubleClickZoomHandler;
27739 Object.defineProperty(MouseComponent.prototype, "dragPan", {
27743 * @returns {DragPanHandler} The drag pan handler.
27746 return this._dragPanHandler;
27751 Object.defineProperty(MouseComponent.prototype, "scrollZoom", {
27755 * @returns {ScrollZoomHandler} The scroll zoom handler.
27758 return this._scrollZoomHandler;
27763 Object.defineProperty(MouseComponent.prototype, "touchZoom", {
27767 * @returns {TouchZoomHandler} The touch zoom handler.
27770 return this._touchZoomHandler;
27775 MouseComponent.prototype._activate = function () {
27777 this._bounceHandler.enable();
27778 this._earthControlHandler.enable();
27779 this._configurationSubscription = this._configuration$
27780 .subscribe(function (configuration) {
27781 if (configuration.doubleClickZoom) {
27782 _this._doubleClickZoomHandler.enable();
27785 _this._doubleClickZoomHandler.disable();
27787 if (configuration.dragPan) {
27788 _this._dragPanHandler.enable();
27791 _this._dragPanHandler.disable();
27793 if (configuration.scrollZoom) {
27794 _this._scrollZoomHandler.enable();
27797 _this._scrollZoomHandler.disable();
27799 if (configuration.touchZoom) {
27800 _this._touchZoomHandler.enable();
27803 _this._touchZoomHandler.disable();
27806 this._container.mouseService.claimMouse(this._name, 0);
27808 MouseComponent.prototype._deactivate = function () {
27809 this._container.mouseService.unclaimMouse(this._name);
27810 this._configurationSubscription.unsubscribe();
27811 this._bounceHandler.disable();
27812 this._doubleClickZoomHandler.disable();
27813 this._dragPanHandler.disable();
27814 this._earthControlHandler.disable();
27815 this._scrollZoomHandler.disable();
27816 this._touchZoomHandler.disable();
27818 MouseComponent.prototype._getDefaultConfiguration = function () {
27819 return { doubleClickZoom: false, dragPan: true, scrollZoom: true, touchZoom: true };
27822 MouseComponent.componentName = "mouse";
27823 return MouseComponent;
27824 }(Component_1.Component));
27825 exports.MouseComponent = MouseComponent;
27826 Component_1.ComponentService.register(MouseComponent);
27827 exports.default = MouseComponent;
27829 },{"../../Component":275,"../../Geo":278}],328:[function(require,module,exports){
27831 var __extends = (this && this.__extends) || (function () {
27832 var extendStatics = function (d, b) {
27833 extendStatics = Object.setPrototypeOf ||
27834 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27835 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27836 return extendStatics(d, b);
27838 return function (d, b) {
27839 extendStatics(d, b);
27840 function __() { this.constructor = d; }
27841 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27844 Object.defineProperty(exports, "__esModule", { value: true });
27845 var operators_1 = require("rxjs/operators");
27846 var Component_1 = require("../../Component");
27848 * The `ScrollZoomHandler` allows the user to zoom the viewer image by scrolling.
27852 * var mouseComponent = viewer.getComponent("mouse");
27854 * mouseComponent.scrollZoom.disable();
27855 * mouseComponent.scrollZoom.enable();
27857 * var isEnabled = mouseComponent.scrollZoom.isEnabled;
27860 var ScrollZoomHandler = /** @class */ (function (_super) {
27861 __extends(ScrollZoomHandler, _super);
27863 function ScrollZoomHandler(component, container, navigator, viewportCoords) {
27864 var _this = _super.call(this, component, container, navigator) || this;
27865 _this._viewportCoords = viewportCoords;
27868 ScrollZoomHandler.prototype._enable = function () {
27870 this._container.mouseService.claimWheel(this._component.name, 0);
27871 this._preventDefaultSubscription = this._container.mouseService.mouseWheel$
27872 .subscribe(function (event) {
27873 event.preventDefault();
27875 this._zoomSubscription = this._container.mouseService
27876 .filteredWheel$(this._component.name, this._container.mouseService.mouseWheel$).pipe(operators_1.withLatestFrom(this._navigator.stateService.currentState$, function (w, f) {
27878 }), operators_1.filter(function (args) {
27879 var state = args[1].state;
27880 return state.currentNode.fullPano || state.nodesAhead < 1;
27881 }), operators_1.map(function (args) {
27883 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, function (w, r, t) {
27886 .subscribe(function (args) {
27887 var event = args[0];
27888 var render = args[1];
27889 var transform = args[2];
27890 var element = _this._container.element;
27891 var _a = _this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
27892 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
27893 var reference = transform.projectBasic(unprojected.toArray());
27894 var deltaY = event.deltaY;
27895 if (event.deltaMode === 1) {
27896 deltaY = 40 * deltaY;
27898 else if (event.deltaMode === 2) {
27899 deltaY = 800 * deltaY;
27901 var canvasSize = _this._viewportCoords.containerToCanvas(element);
27902 var zoom = -3 * deltaY / canvasSize[1];
27903 _this._navigator.stateService.zoomIn(zoom, reference);
27906 ScrollZoomHandler.prototype._disable = function () {
27907 this._container.mouseService.unclaimWheel(this._component.name);
27908 this._preventDefaultSubscription.unsubscribe();
27909 this._zoomSubscription.unsubscribe();
27910 this._preventDefaultSubscription = null;
27911 this._zoomSubscription = null;
27913 ScrollZoomHandler.prototype._getConfiguration = function (enable) {
27914 return { scrollZoom: enable };
27916 return ScrollZoomHandler;
27917 }(Component_1.HandlerBase));
27918 exports.ScrollZoomHandler = ScrollZoomHandler;
27919 exports.default = ScrollZoomHandler;
27921 },{"../../Component":275,"rxjs/operators":225}],329:[function(require,module,exports){
27923 var __extends = (this && this.__extends) || (function () {
27924 var extendStatics = function (d, b) {
27925 extendStatics = Object.setPrototypeOf ||
27926 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27927 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27928 return extendStatics(d, b);
27930 return function (d, b) {
27931 extendStatics(d, b);
27932 function __() { this.constructor = d; }
27933 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27936 Object.defineProperty(exports, "__esModule", { value: true });
27937 var rxjs_1 = require("rxjs");
27938 var operators_1 = require("rxjs/operators");
27939 var Component_1 = require("../../Component");
27941 * The `TouchZoomHandler` allows the user to zoom the viewer image by pinching on a touchscreen.
27945 * var mouseComponent = viewer.getComponent("mouse");
27947 * mouseComponent.touchZoom.disable();
27948 * mouseComponent.touchZoom.enable();
27950 * var isEnabled = mouseComponent.touchZoom.isEnabled;
27953 var TouchZoomHandler = /** @class */ (function (_super) {
27954 __extends(TouchZoomHandler, _super);
27956 function TouchZoomHandler(component, container, navigator, viewportCoords) {
27957 var _this = _super.call(this, component, container, navigator) || this;
27958 _this._viewportCoords = viewportCoords;
27961 TouchZoomHandler.prototype._enable = function () {
27963 this._preventDefaultSubscription = this._container.touchService.pinch$
27964 .subscribe(function (pinch) {
27965 pinch.originalEvent.preventDefault();
27967 var pinchStarted$ = this._container.touchService.pinchStart$.pipe(operators_1.map(function (event) {
27970 var pinchStopped$ = this._container.touchService.pinchEnd$.pipe(operators_1.map(function (event) {
27973 this._activeSubscription = rxjs_1.merge(pinchStarted$, pinchStopped$)
27974 .subscribe(this._container.touchService.activate$);
27975 this._zoomSubscription = this._container.touchService.pinch$.pipe(operators_1.withLatestFrom(this._navigator.stateService.currentState$), operators_1.filter(function (args) {
27976 var state = args[1].state;
27977 return state.currentNode.fullPano || state.nodesAhead < 1;
27978 }), operators_1.map(function (args) {
27980 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
27981 .subscribe(function (_a) {
27982 var pinch = _a[0], render = _a[1], transform = _a[2];
27983 var element = _this._container.element;
27984 var _b = _this._viewportCoords.canvasPosition(pinch, element), canvasX = _b[0], canvasY = _b[1];
27985 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
27986 var reference = transform.projectBasic(unprojected.toArray());
27987 var _c = _this._viewportCoords.containerToCanvas(element), canvasWidth = _c[0], canvasHeight = _c[1];
27988 var zoom = 3 * pinch.distanceChange / Math.min(canvasWidth, canvasHeight);
27989 _this._navigator.stateService.zoomIn(zoom, reference);
27992 TouchZoomHandler.prototype._disable = function () {
27993 this._activeSubscription.unsubscribe();
27994 this._preventDefaultSubscription.unsubscribe();
27995 this._zoomSubscription.unsubscribe();
27996 this._preventDefaultSubscription = null;
27997 this._zoomSubscription = null;
27999 TouchZoomHandler.prototype._getConfiguration = function (enable) {
28000 return { touchZoom: enable };
28002 return TouchZoomHandler;
28003 }(Component_1.HandlerBase));
28004 exports.TouchZoomHandler = TouchZoomHandler;
28005 exports.default = TouchZoomHandler;
28007 },{"../../Component":275,"rxjs":27,"rxjs/operators":225}],330:[function(require,module,exports){
28009 Object.defineProperty(exports, "__esModule", { value: true });
28010 var Popup_1 = require("./popup/Popup");
28011 exports.Popup = Popup_1.Popup;
28012 var PopupComponent_1 = require("./PopupComponent");
28013 exports.PopupComponent = PopupComponent_1.PopupComponent;
28015 },{"./PopupComponent":331,"./popup/Popup":332}],331:[function(require,module,exports){
28017 var __extends = (this && this.__extends) || (function () {
28018 var extendStatics = function (d, b) {
28019 extendStatics = Object.setPrototypeOf ||
28020 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28021 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
28022 return extendStatics(d, b);
28024 return function (d, b) {
28025 extendStatics(d, b);
28026 function __() { this.constructor = d; }
28027 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28030 Object.defineProperty(exports, "__esModule", { value: true });
28031 var rxjs_1 = require("rxjs");
28032 var operators_1 = require("rxjs/operators");
28033 var Component_1 = require("../../Component");
28034 var Utils_1 = require("../../Utils");
28036 * @class PopupComponent
28038 * @classdesc Component for showing HTML popup objects.
28040 * The `add` method is used for adding new popups. Popups are removed by reference.
28042 * It is not possible to update popups in the set by updating any properties
28043 * directly on the popup object. Popups need to be replaced by
28044 * removing them and creating new ones with relevant changed properties and
28045 * adding those instead.
28047 * Popups are only relevant to a single image because they are based on
28048 * 2D basic image coordinates. Popups related to a certain image should
28049 * be removed when the viewer is moved to another node.
28051 * To retrive and use the popup component
28055 * var viewer = new Mapillary.Viewer(
28059 * { component: { popup: true } });
28061 * var popupComponent = viewer.getComponent("popup");
28064 var PopupComponent = /** @class */ (function (_super) {
28065 __extends(PopupComponent, _super);
28067 function PopupComponent(name, container, navigator, dom) {
28068 var _this = _super.call(this, name, container, navigator) || this;
28069 _this._dom = !!dom ? dom : new Utils_1.DOM();
28070 _this._popups = [];
28071 _this._added$ = new rxjs_1.Subject();
28072 _this._popups$ = new rxjs_1.Subject();
28076 * Add popups to the popups set.
28078 * @description Adding a new popup never replaces an old one
28079 * because they are stored by reference. Adding an already
28080 * existing popup has no effect.
28082 * @param {Array<Popup>} popups - Popups to add.
28084 * @example ```popupComponent.add([popup1, popup2]);```
28086 PopupComponent.prototype.add = function (popups) {
28087 for (var _i = 0, popups_1 = popups; _i < popups_1.length; _i++) {
28088 var popup = popups_1[_i];
28089 if (this._popups.indexOf(popup) !== -1) {
28092 this._popups.push(popup);
28093 if (this._activated) {
28094 popup.setParentContainer(this._popupContainer);
28097 this._added$.next(popups);
28098 this._popups$.next(this._popups);
28101 * Returns an array of all popups.
28103 * @example ```var popups = popupComponent.getAll();```
28105 PopupComponent.prototype.getAll = function () {
28106 return this._popups.slice();
28109 * Remove popups based on reference from the popup set.
28111 * @param {Array<Popup>} popups - Popups to remove.
28113 * @example ```popupComponent.remove([popup1, popup2]);```
28115 PopupComponent.prototype.remove = function (popups) {
28116 for (var _i = 0, popups_2 = popups; _i < popups_2.length; _i++) {
28117 var popup = popups_2[_i];
28118 this._remove(popup);
28120 this._popups$.next(this._popups);
28123 * Remove all popups from the popup set.
28125 * @example ```popupComponent.removeAll();```
28127 PopupComponent.prototype.removeAll = function () {
28128 for (var _i = 0, _a = this._popups.slice(); _i < _a.length; _i++) {
28129 var popup = _a[_i];
28130 this._remove(popup);
28132 this._popups$.next(this._popups);
28134 PopupComponent.prototype._activate = function () {
28136 this._popupContainer = this._dom.createElement("div", "mapillary-js-popup-container", this._container.element);
28137 for (var _i = 0, _a = this._popups; _i < _a.length; _i++) {
28138 var popup = _a[_i];
28139 popup.setParentContainer(this._popupContainer);
28141 this._updateAllSubscription = rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._container.renderService.size$, this._navigator.stateService.currentTransform$)
28142 .subscribe(function (_a) {
28143 var renderCamera = _a[0], size = _a[1], transform = _a[2];
28144 for (var _i = 0, _b = _this._popups; _i < _b.length; _i++) {
28145 var popup = _b[_i];
28146 popup.update(renderCamera, size, transform);
28149 var changed$ = this._popups$.pipe(operators_1.startWith(this._popups), operators_1.switchMap(function (popups) {
28150 return rxjs_1.from(popups).pipe(operators_1.mergeMap(function (popup) {
28151 return popup.changed$;
28153 }), operators_1.map(function (popup) {
28156 this._updateAddedChangedSubscription = rxjs_1.merge(this._added$, changed$).pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._container.renderService.size$, this._navigator.stateService.currentTransform$))
28157 .subscribe(function (_a) {
28158 var popups = _a[0], renderCamera = _a[1], size = _a[2], transform = _a[3];
28159 for (var _i = 0, popups_3 = popups; _i < popups_3.length; _i++) {
28160 var popup = popups_3[_i];
28161 popup.update(renderCamera, size, transform);
28165 PopupComponent.prototype._deactivate = function () {
28166 this._updateAllSubscription.unsubscribe();
28167 this._updateAddedChangedSubscription.unsubscribe();
28168 for (var _i = 0, _a = this._popups; _i < _a.length; _i++) {
28169 var popup = _a[_i];
28172 this._container.element.removeChild(this._popupContainer);
28173 delete this._popupContainer;
28175 PopupComponent.prototype._getDefaultConfiguration = function () {
28178 PopupComponent.prototype._remove = function (popup) {
28179 var index = this._popups.indexOf(popup);
28180 if (index === -1) {
28183 var removed = this._popups.splice(index, 1)[0];
28184 if (this._activated) {
28188 PopupComponent.componentName = "popup";
28189 return PopupComponent;
28190 }(Component_1.Component));
28191 exports.PopupComponent = PopupComponent;
28192 Component_1.ComponentService.register(PopupComponent);
28193 exports.default = PopupComponent;
28195 },{"../../Component":275,"../../Utils":285,"rxjs":27,"rxjs/operators":225}],332:[function(require,module,exports){
28197 Object.defineProperty(exports, "__esModule", { value: true });
28198 var rxjs_1 = require("rxjs");
28199 var Geo_1 = require("../../../Geo");
28200 var Utils_1 = require("../../../Utils");
28201 var Viewer_1 = require("../../../Viewer");
28205 * @classdesc Popup instance for rendering custom HTML content
28206 * on top of images. Popups are based on 2D basic image coordinates
28207 * (see the {@link Viewer} class documentation for more information about coordinate
28208 * systems) and a certain popup is therefore only relevant to a single image.
28209 * Popups related to a certain image should be removed when moving
28210 * to another image.
28212 * A popup must have both its content and its point or rect set to be
28213 * rendered. Popup options can not be updated after creation but the
28214 * basic point or rect as well as its content can be changed by calling
28215 * the appropriate methods.
28217 * To create and add one `Popup` with default configuration
28218 * (tooltip visuals and automatic float) and one with specific options
28223 * var defaultSpan = document.createElement('span');
28224 * defaultSpan.innerHTML = 'hello default';
28226 * var defaultPopup = new Mapillary.PopupComponent.Popup();
28227 * defaultPopup.setDOMContent(defaultSpan);
28228 * defaultPopup.setBasicPoint([0.3, 0.3]);
28230 * var cleanSpan = document.createElement('span');
28231 * cleanSpan.innerHTML = 'hello clean';
28233 * var cleanPopup = new Mapillary.PopupComponent.Popup({
28235 * float: Mapillary.Alignment.Top,
28240 * cleanPopup.setDOMContent(cleanSpan);
28241 * cleanPopup.setBasicPoint([0.6, 0.6]);
28243 * popupComponent.add([defaultPopup, cleanPopup]);
28246 * @description Implementation of API methods and API documentation inspired
28247 * by/used from https://github.com/mapbox/mapbox-gl-js/blob/v0.38.0/src/ui/popup.js
28249 var Popup = /** @class */ (function () {
28250 function Popup(options, viewportCoords, dom) {
28251 this._options = {};
28252 options = !!options ? options : {};
28253 this._options.capturePointer = options.capturePointer === false ?
28254 options.capturePointer : true;
28255 this._options.clean = options.clean;
28256 this._options.float = options.float;
28257 this._options.offset = options.offset;
28258 this._options.opacity = options.opacity;
28259 this._options.position = options.position;
28260 this._dom = !!dom ? dom : new Utils_1.DOM();
28261 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
28262 this._notifyChanged$ = new rxjs_1.Subject();
28264 Object.defineProperty(Popup.prototype, "changed$", {
28266 * @description Internal observable used by the component to
28267 * render the popup when its position or content has changed.
28271 return this._notifyChanged$;
28277 * @description Internal method used by the component to
28278 * remove all references to the popup.
28281 Popup.prototype.remove = function () {
28282 if (this._content && this._content.parentNode) {
28283 this._content.parentNode.removeChild(this._content);
28285 if (this._container) {
28286 this._container.parentNode.removeChild(this._container);
28287 delete this._container;
28289 if (this._parentContainer) {
28290 delete this._parentContainer;
28294 * Sets a 2D basic image coordinates point to the popup's anchor, and
28295 * moves the popup to it.
28297 * @description Overwrites any previously set point or rect.
28299 * @param {Array<number>} basicPoint - Point in 2D basic image coordinates.
28303 * var popup = new Mapillary.PopupComponent.Popup();
28304 * popup.setText('hello image');
28305 * popup.setBasicPoint([0.3, 0.3]);
28307 * popupComponent.add([popup]);
28310 Popup.prototype.setBasicPoint = function (basicPoint) {
28311 this._point = basicPoint.slice();
28313 this._notifyChanged$.next(this);
28316 * Sets a 2D basic image coordinates rect to the popup's anchor, and
28317 * moves the popup to it.
28319 * @description Overwrites any previously set point or rect.
28321 * @param {Array<number>} basicRect - Rect in 2D basic image
28322 * coordinates ([topLeftX, topLeftY, bottomRightX, bottomRightY]) .
28326 * var popup = new Mapillary.PopupComponent.Popup();
28327 * popup.setText('hello image');
28328 * popup.setBasicRect([0.3, 0.3, 0.5, 0.6]);
28330 * popupComponent.add([popup]);
28333 Popup.prototype.setBasicRect = function (basicRect) {
28334 this._rect = basicRect.slice();
28335 this._point = null;
28336 this._notifyChanged$.next(this);
28339 * Sets the popup's content to the element provided as a DOM node.
28341 * @param {Node} htmlNode - A DOM node to be used as content for the popup.
28345 * var div = document.createElement('div');
28346 * div.innerHTML = 'hello image';
28348 * var popup = new Mapillary.PopupComponent.Popup();
28349 * popup.setDOMContent(div);
28350 * popup.setBasicPoint([0.3, 0.3]);
28352 * popupComponent.add([popup]);
28355 Popup.prototype.setDOMContent = function (htmlNode) {
28356 if (this._content && this._content.parentNode) {
28357 this._content.parentNode.removeChild(this._content);
28359 var className = "mapillaryjs-popup-content" +
28360 (this._options.clean === true ? "-clean" : "") +
28361 (this._options.capturePointer === true ? " mapillaryjs-popup-capture-pointer" : "");
28362 this._content = this._dom.createElement("div", className, this._container);
28363 this._content.appendChild(htmlNode);
28364 this._notifyChanged$.next(this);
28367 * Sets the popup's content to the HTML provided as a string.
28369 * @description This method does not perform HTML filtering or sanitization,
28370 * and must be used only with trusted content. Consider Popup#setText if the
28371 * content is an untrusted text string.
28373 * @param {string} html - A string representing HTML content for the popup.
28377 * var popup = new Mapillary.PopupComponent.Popup();
28378 * popup.setHTML('<div>hello image</div>');
28379 * popup.setBasicPoint([0.3, 0.3]);
28381 * popupComponent.add([popup]);
28384 Popup.prototype.setHTML = function (html) {
28385 var frag = this._dom.document.createDocumentFragment();
28386 var temp = this._dom.createElement("body");
28388 temp.innerHTML = html;
28390 child = temp.firstChild;
28394 frag.appendChild(child);
28396 this.setDOMContent(frag);
28399 * Sets the popup's content to a string of text.
28401 * @description This function creates a Text node in the DOM, so it cannot insert raw HTML.
28402 * Use this method for security against XSS if the popup content is user-provided.
28404 * @param {string} text - Textual content for the popup.
28408 * var popup = new Mapillary.PopupComponent.Popup();
28409 * popup.setText('hello image');
28410 * popup.setBasicPoint([0.3, 0.3]);
28412 * popupComponent.add([popup]);
28415 Popup.prototype.setText = function (text) {
28416 this.setDOMContent(this._dom.document.createTextNode(text));
28419 * @description Internal method for attaching the popup to
28420 * its parent container so that it is rendered in the DOM tree.
28423 Popup.prototype.setParentContainer = function (parentContainer) {
28424 this._parentContainer = parentContainer;
28427 * @description Internal method for updating the rendered
28428 * position of the popup called by the popup component.
28431 Popup.prototype.update = function (renderCamera, size, transform) {
28433 if (!this._parentContainer || !this._content) {
28436 if (!this._point && !this._rect) {
28439 if (!this._container) {
28440 this._container = this._dom.createElement("div", "mapillaryjs-popup", this._parentContainer);
28441 var showTip = this._options.clean !== true &&
28442 this._options.float !== Viewer_1.Alignment.Center;
28444 var tipClassName = "mapillaryjs-popup-tip" +
28445 (this._options.capturePointer === true ? " mapillaryjs-popup-capture-pointer" : "");
28446 this._tip = this._dom.createElement("div", tipClassName, this._container);
28447 this._dom.createElement("div", "mapillaryjs-popup-tip-inner", this._tip);
28449 this._container.appendChild(this._content);
28450 this._parentContainer.appendChild(this._container);
28451 if (this._options.opacity != null) {
28452 this._container.style.opacity = this._options.opacity.toString();
28455 var pointPixel = null;
28456 var position = this._alignmentToPopupAligment(this._options.position);
28457 var float = this._alignmentToPopupAligment(this._options.float);
28458 var classList = this._container.classList;
28459 if (this._point != null) {
28461 this._viewportCoords.basicToCanvasSafe(this._point[0], this._point[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
28464 var alignments = ["center", "top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"];
28465 var appliedPosition = null;
28466 for (var _i = 0, alignments_1 = alignments; _i < alignments_1.length; _i++) {
28467 var alignment = alignments_1[_i];
28468 if (classList.contains("mapillaryjs-popup-float-" + alignment)) {
28469 appliedPosition = alignment;
28473 _a = this._rectToPixel(this._rect, position, appliedPosition, renderCamera, size, transform), pointPixel = _a[0], position = _a[1];
28478 if (pointPixel == null) {
28479 this._container.style.display = "none";
28482 this._container.style.display = "";
28484 var width = this._container.offsetWidth;
28485 var height = this._container.offsetHeight;
28486 var floats = this._pixelToFloats(pointPixel, size, width, height);
28487 float = floats.length === 0 ? "top" : floats.join("-");
28489 var offset = this._normalizeOffset(this._options.offset);
28490 pointPixel = [pointPixel[0] + offset[float][0], pointPixel[1] + offset[float][1]];
28491 pointPixel = [Math.round(pointPixel[0]), Math.round(pointPixel[1])];
28492 var floatTranslate = {
28493 "bottom": "translate(-50%,0)",
28494 "bottom-left": "translate(-100%,0)",
28495 "bottom-right": "translate(0,0)",
28496 "center": "translate(-50%,-50%)",
28497 "left": "translate(-100%,-50%)",
28498 "right": "translate(0,-50%)",
28499 "top": "translate(-50%,-100%)",
28500 "top-left": "translate(-100%,-100%)",
28501 "top-right": "translate(0,-100%)",
28503 for (var key in floatTranslate) {
28504 if (!floatTranslate.hasOwnProperty(key)) {
28507 classList.remove("mapillaryjs-popup-float-" + key);
28509 classList.add("mapillaryjs-popup-float-" + float);
28510 this._container.style.transform = floatTranslate[float] + " translate(" + pointPixel[0] + "px," + pointPixel[1] + "px)";
28512 Popup.prototype._rectToPixel = function (rect, position, appliedPosition, renderCamera, size, transform) {
28514 var width = this._container.offsetWidth;
28515 var height = this._container.offsetHeight;
28516 var floatOffsets = {
28517 "bottom": [0, height / 2],
28518 "bottom-left": [-width / 2, height / 2],
28519 "bottom-right": [width / 2, height / 2],
28520 "left": [-width / 2, 0],
28521 "right": [width / 2, 0],
28522 "top": [0, -height / 2],
28523 "top-left": [-width / 2, -height / 2],
28524 "top-right": [width / 2, -height / 2],
28526 var automaticPositions = ["top", "bottom", "left", "right"];
28527 var largestVisibleArea = [0, null, null];
28528 for (var _i = 0, automaticPositions_1 = automaticPositions; _i < automaticPositions_1.length; _i++) {
28529 var automaticPosition = automaticPositions_1[_i];
28530 var autoPointBasic = this._pointFromRectPosition(rect, automaticPosition);
28531 var autoPointPixel = this._viewportCoords.basicToCanvasSafe(autoPointBasic[0], autoPointBasic[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
28532 if (autoPointPixel == null) {
28535 var floatOffset = floatOffsets[automaticPosition];
28536 var offsetedPosition = [autoPointPixel[0] + floatOffset[0], autoPointPixel[1] + floatOffset[1]];
28537 var staticCoeff = appliedPosition != null && appliedPosition === automaticPosition ? 1 : 0.7;
28538 var floats = this._pixelToFloats(offsetedPosition, size, width / staticCoeff, height / (2 * staticCoeff));
28539 if (floats.length === 0 &&
28540 autoPointPixel[0] > 0 &&
28541 autoPointPixel[0] < size.width &&
28542 autoPointPixel[1] > 0 &&
28543 autoPointPixel[1] < size.height) {
28544 return [autoPointPixel, automaticPosition];
28546 var minX = Math.max(offsetedPosition[0] - width / 2, 0);
28547 var maxX = Math.min(offsetedPosition[0] + width / 2, size.width);
28548 var minY = Math.max(offsetedPosition[1] - height / 2, 0);
28549 var maxY = Math.min(offsetedPosition[1] + height / 2, size.height);
28550 var visibleX = Math.max(0, maxX - minX);
28551 var visibleY = Math.max(0, maxY - minY);
28552 var visibleArea = staticCoeff * visibleX * visibleY;
28553 if (visibleArea > largestVisibleArea[0]) {
28554 largestVisibleArea[0] = visibleArea;
28555 largestVisibleArea[1] = autoPointPixel;
28556 largestVisibleArea[2] = automaticPosition;
28559 if (largestVisibleArea[0] > 0) {
28560 return [largestVisibleArea[1], largestVisibleArea[2]];
28563 var pointBasic = this._pointFromRectPosition(rect, position);
28564 var pointPixel = this._viewportCoords.basicToCanvasSafe(pointBasic[0], pointBasic[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
28565 return [pointPixel, position != null ? position : "top"];
28567 Popup.prototype._alignmentToPopupAligment = function (float) {
28569 case Viewer_1.Alignment.Bottom:
28571 case Viewer_1.Alignment.BottomLeft:
28572 return "bottom-left";
28573 case Viewer_1.Alignment.BottomRight:
28574 return "bottom-right";
28575 case Viewer_1.Alignment.Center:
28577 case Viewer_1.Alignment.Left:
28579 case Viewer_1.Alignment.Right:
28581 case Viewer_1.Alignment.Top:
28583 case Viewer_1.Alignment.TopLeft:
28585 case Viewer_1.Alignment.TopRight:
28586 return "top-right";
28591 Popup.prototype._normalizeOffset = function (offset) {
28592 if (offset == null) {
28593 return this._normalizeOffset(0);
28595 if (typeof offset === "number") {
28596 // input specifies a radius
28597 var sideOffset = offset;
28598 var sign = sideOffset >= 0 ? 1 : -1;
28599 var cornerOffset = sign * Math.round(Math.sqrt(0.5 * Math.pow(sideOffset, 2)));
28601 "bottom": [0, sideOffset],
28602 "bottom-left": [-cornerOffset, cornerOffset],
28603 "bottom-right": [cornerOffset, cornerOffset],
28605 "left": [-sideOffset, 0],
28606 "right": [sideOffset, 0],
28607 "top": [0, -sideOffset],
28608 "top-left": [-cornerOffset, -cornerOffset],
28609 "top-right": [cornerOffset, -cornerOffset],
28613 // input specifes a value for each position
28615 "bottom": offset.bottom || [0, 0],
28616 "bottom-left": offset.bottomLeft || [0, 0],
28617 "bottom-right": offset.bottomRight || [0, 0],
28618 "center": offset.center || [0, 0],
28619 "left": offset.left || [0, 0],
28620 "right": offset.right || [0, 0],
28621 "top": offset.top || [0, 0],
28622 "top-left": offset.topLeft || [0, 0],
28623 "top-right": offset.topRight || [0, 0],
28627 Popup.prototype._pixelToFloats = function (pointPixel, size, width, height) {
28629 if (pointPixel[1] < height) {
28630 floats.push("bottom");
28632 else if (pointPixel[1] > size.height - height) {
28633 floats.push("top");
28635 if (pointPixel[0] < width / 2) {
28636 floats.push("right");
28638 else if (pointPixel[0] > size.width - width / 2) {
28639 floats.push("left");
28643 Popup.prototype._pointFromRectPosition = function (rect, position) {
28645 var x1 = rect[0] < rect[2] ? rect[2] : rect[2] + 1;
28648 switch (position) {
28650 return [(x0 + x1) / 2, y1];
28651 case "bottom-left":
28653 case "bottom-right":
28656 return [(x0 + x1) / 2, (y0 + y1) / 2];
28658 return [x0, (y0 + y1) / 2];
28660 return [x1, (y0 + y1) / 2];
28662 return [(x0 + x1) / 2, y0];
28668 return [(x0 + x1) / 2, y1];
28673 exports.Popup = Popup;
28674 exports.default = Popup;
28677 },{"../../../Geo":278,"../../../Utils":285,"../../../Viewer":286,"rxjs":27}],333:[function(require,module,exports){
28679 var __extends = (this && this.__extends) || (function () {
28680 var extendStatics = function (d, b) {
28681 extendStatics = Object.setPrototypeOf ||
28682 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28683 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
28684 return extendStatics(d, b);
28686 return function (d, b) {
28687 extendStatics(d, b);
28688 function __() { this.constructor = d; }
28689 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28692 Object.defineProperty(exports, "__esModule", { value: true });
28693 var rxjs_1 = require("rxjs");
28694 var operators_1 = require("rxjs/operators");
28695 var Component_1 = require("../../Component");
28696 var Edge_1 = require("../../Edge");
28697 var Graph_1 = require("../../Graph");
28699 * @class SequenceComponent
28700 * @classdesc Component showing navigation arrows for sequence directions
28701 * as well as playing button. Exposes an API to start and stop play.
28703 var SequenceComponent = /** @class */ (function (_super) {
28704 __extends(SequenceComponent, _super);
28705 function SequenceComponent(name, container, navigator, renderer, scheduler) {
28706 var _this = _super.call(this, name, container, navigator) || this;
28707 _this._sequenceDOMRenderer = !!renderer ? renderer : new Component_1.SequenceDOMRenderer(container);
28708 _this._scheduler = scheduler;
28709 _this._containerWidth$ = new rxjs_1.Subject();
28710 _this._hoveredKeySubject$ = new rxjs_1.Subject();
28711 _this._hoveredKey$ = _this._hoveredKeySubject$.pipe(operators_1.share());
28712 _this._navigator.playService.playing$.pipe(operators_1.skip(1), operators_1.withLatestFrom(_this._configuration$))
28713 .subscribe(function (_a) {
28714 var playing = _a[0], configuration = _a[1];
28715 _this.fire(SequenceComponent.playingchanged, playing);
28716 if (playing === configuration.playing) {
28726 _this._navigator.playService.direction$.pipe(operators_1.skip(1), operators_1.withLatestFrom(_this._configuration$))
28727 .subscribe(function (_a) {
28728 var direction = _a[0], configuration = _a[1];
28729 if (direction !== configuration.direction) {
28730 _this.setDirection(direction);
28735 Object.defineProperty(SequenceComponent.prototype, "hoveredKey$", {
28737 * Get hovered key observable.
28739 * @description An observable emitting the key of the node for the direction
28740 * arrow that is being hovered. When the mouse leaves a direction arrow null
28743 * @returns {Observable<string>}
28746 return this._hoveredKey$;
28754 * @fires PlayerComponent#playingchanged
28756 SequenceComponent.prototype.play = function () {
28757 this.configure({ playing: true });
28762 * @fires PlayerComponent#playingchanged
28764 SequenceComponent.prototype.stop = function () {
28765 this.configure({ playing: false });
28768 * Set the direction to follow when playing.
28770 * @param {EdgeDirection} direction - The direction that will be followed when playing.
28772 SequenceComponent.prototype.setDirection = function (direction) {
28773 this.configure({ direction: direction });
28776 * Set highlight key.
28778 * @description The arrow pointing towards the node corresponding to the
28779 * highlight key will be highlighted.
28781 * @param {string} highlightKey Key of node to be highlighted if existing.
28783 SequenceComponent.prototype.setHighlightKey = function (highlightKey) {
28784 this.configure({ highlightKey: highlightKey });
28787 * Set max width of container element.
28789 * @description Set max width of the container element holding
28790 * the sequence navigation elements. If the min width is larger than the
28791 * max width the min width value will be used.
28793 * The container element is automatically resized when the resize
28794 * method on the Viewer class is called.
28796 * @param {number} minWidth
28798 SequenceComponent.prototype.setMaxWidth = function (maxWidth) {
28799 this.configure({ maxWidth: maxWidth });
28802 * Set min width of container element.
28804 * @description Set min width of the container element holding
28805 * the sequence navigation elements. If the min width is larger than the
28806 * max width the min width value will be used.
28808 * The container element is automatically resized when the resize
28809 * method on the Viewer class is called.
28811 * @param {number} minWidth
28813 SequenceComponent.prototype.setMinWidth = function (minWidth) {
28814 this.configure({ minWidth: minWidth });
28817 * Set the value indicating whether the sequence UI elements should be visible.
28819 * @param {boolean} visible
28821 SequenceComponent.prototype.setVisible = function (visible) {
28822 this.configure({ visible: visible });
28824 SequenceComponent.prototype._activate = function () {
28826 this._sequenceDOMRenderer.activate();
28827 var edgeStatus$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
28828 return node.sequenceEdges$;
28829 }), operators_1.publishReplay(1), operators_1.refCount());
28830 var sequence$ = this._navigator.stateService.currentNode$.pipe(operators_1.distinctUntilChanged(undefined, function (node) {
28831 return node.sequenceKey;
28832 }), operators_1.switchMap(function (node) {
28833 return rxjs_1.concat(rxjs_1.of(null), _this._navigator.graphService.cacheSequence$(node.sequenceKey).pipe(operators_1.retry(3), operators_1.catchError(function (e) {
28834 console.error("Failed to cache sequence", e);
28835 return rxjs_1.of(null);
28837 }), operators_1.startWith(null), operators_1.publishReplay(1), operators_1.refCount());
28838 this._sequenceSubscription = sequence$.subscribe();
28839 var rendererKey$ = this._sequenceDOMRenderer.index$.pipe(operators_1.withLatestFrom(sequence$), operators_1.map(function (_a) {
28840 var index = _a[0], sequence = _a[1];
28841 return sequence != null ? sequence.keys[index] : null;
28842 }), operators_1.filter(function (key) {
28844 }), operators_1.distinctUntilChanged(), operators_1.publish(), operators_1.refCount());
28845 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) {
28846 return _this._navigator.moveToKey$(key).pipe(operators_1.catchError(function (e) {
28847 return rxjs_1.empty();
28851 this._setSequenceGraphModeSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
28854 .subscribe(function () {
28855 _this._navigator.graphService.setGraphMode(Graph_1.GraphMode.Sequence);
28857 this._setSpatialGraphModeSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
28860 .subscribe(function () {
28861 _this._navigator.graphService.setGraphMode(Graph_1.GraphMode.Spatial);
28863 this._navigator.graphService.graphMode$.pipe(operators_1.switchMap(function (mode) {
28864 return mode === Graph_1.GraphMode.Spatial ?
28865 _this._navigator.stateService.currentNode$.pipe(operators_1.take(2)) :
28867 }), operators_1.filter(function (node) {
28868 return !node.spatialEdges.cached;
28869 }), operators_1.switchMap(function (node) {
28870 return _this._navigator.graphService.cacheNode$(node.key).pipe(operators_1.catchError(function (e) {
28871 return rxjs_1.empty();
28875 this._stopSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
28878 .subscribe(function () {
28879 _this._navigator.playService.stop();
28881 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) {
28882 var _b = _a[0], mode = _b[0], changing = _b[1], node = _a[1];
28883 return changing && mode === Graph_1.GraphMode.Sequence ?
28884 _this._navigator.graphService.cacheSequenceNodes$(node.sequenceKey, node.key).pipe(operators_1.retry(3), operators_1.catchError(function (error) {
28885 console.error("Failed to cache sequence nodes.", error);
28886 return rxjs_1.empty();
28891 var position$ = sequence$.pipe(operators_1.switchMap(function (sequence) {
28893 return rxjs_1.of({ index: null, max: null });
28895 var firstCurrentKey = true;
28896 return _this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.startWith(false), operators_1.distinctUntilChanged(), operators_1.switchMap(function (changingPosition) {
28897 var skipCount = !changingPosition && firstCurrentKey ? 0 : 1;
28898 firstCurrentKey = false;
28899 return changingPosition ?
28901 _this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
28903 }), operators_1.distinctUntilChanged(), operators_1.skip(skipCount));
28904 }), operators_1.map(function (key) {
28905 var index = sequence.keys.indexOf(key);
28906 if (index === -1) {
28907 return { index: null, max: null };
28909 return { index: index, max: sequence.keys.length - 1 };
28912 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) {
28913 var edgeStatus = _a[0], configuration = _a[1], containerWidth = _a[2], renderer = _a[3], speed = _a[4], position = _a[5];
28914 var vNode = _this._sequenceDOMRenderer
28915 .render(edgeStatus, configuration, containerWidth, speed, position.index, position.max, _this, _this._navigator);
28916 return { name: _this._name, vnode: vNode };
28918 .subscribe(this._container.domRenderer.render$);
28919 this._setSpeedSubscription = this._sequenceDOMRenderer.speed$
28920 .subscribe(function (speed) {
28921 _this._navigator.playService.setSpeed(speed);
28923 this._setDirectionSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
28924 return configuration.direction;
28925 }), operators_1.distinctUntilChanged())
28926 .subscribe(function (direction) {
28927 _this._navigator.playService.setDirection(direction);
28929 this._containerWidthSubscription = rxjs_1.combineLatest(this._container.renderService.size$, this._configuration$.pipe(operators_1.distinctUntilChanged(function (value1, value2) {
28930 return value1[0] === value2[0] && value1[1] === value2[1];
28931 }, function (configuration) {
28932 return [configuration.minWidth, configuration.maxWidth];
28933 }))).pipe(operators_1.map(function (_a) {
28934 var size = _a[0], configuration = _a[1];
28935 return _this._sequenceDOMRenderer.getContainerWidth(size, configuration);
28937 .subscribe(this._containerWidth$);
28938 this._playingSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
28939 return configuration.playing;
28940 }), operators_1.distinctUntilChanged())
28941 .subscribe(function (playing) {
28943 _this._navigator.playService.play();
28946 _this._navigator.playService.stop();
28949 this._hoveredKeySubscription = this._sequenceDOMRenderer.mouseEnterDirection$.pipe(operators_1.switchMap(function (direction) {
28950 var edgeTo$ = edgeStatus$.pipe(operators_1.map(function (edgeStatus) {
28951 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
28953 if (edge.data.direction === direction) {
28958 }), operators_1.takeUntil(_this._sequenceDOMRenderer.mouseLeaveDirection$));
28959 return rxjs_1.concat(edgeTo$, rxjs_1.of(null));
28960 }), operators_1.distinctUntilChanged())
28961 .subscribe(this._hoveredKeySubject$);
28962 this._emitHoveredKeySubscription = this._hoveredKey$
28963 .subscribe(function (key) {
28964 _this.fire(SequenceComponent.hoveredkeychanged, key);
28967 SequenceComponent.prototype._deactivate = function () {
28968 this._emitHoveredKeySubscription.unsubscribe();
28969 this._renderSubscription.unsubscribe();
28970 this._playingSubscription.unsubscribe();
28971 this._containerWidthSubscription.unsubscribe();
28972 this._hoveredKeySubscription.unsubscribe();
28973 this._setSpeedSubscription.unsubscribe();
28974 this._setDirectionSubscription.unsubscribe();
28975 this._setSequenceGraphModeSubscription.unsubscribe();
28976 this._setSpatialGraphModeSubscription.unsubscribe();
28977 this._sequenceSubscription.unsubscribe();
28978 this._moveSubscription.unsubscribe();
28979 this._cacheSequenceNodesSubscription.unsubscribe();
28980 this._stopSubscription.unsubscribe();
28981 this._sequenceDOMRenderer.deactivate();
28983 SequenceComponent.prototype._getDefaultConfiguration = function () {
28985 direction: Edge_1.EdgeDirection.Next,
28993 SequenceComponent.componentName = "sequence";
28995 * Event fired when playing starts or stops.
28997 * @event SequenceComponent#playingchanged
28998 * @type {boolean} Indicates whether the player is playing.
29000 SequenceComponent.playingchanged = "playingchanged";
29002 * Event fired when the hovered key changes.
29004 * @description Emits the key of the node for the direction
29005 * arrow that is being hovered. When the mouse leaves a
29006 * direction arrow null is emitted.
29008 * @event SequenceComponent#hoveredkeychanged
29009 * @type {string} The hovered key, null if no key is hovered.
29011 SequenceComponent.hoveredkeychanged = "hoveredkeychanged";
29012 return SequenceComponent;
29013 }(Component_1.Component));
29014 exports.SequenceComponent = SequenceComponent;
29015 Component_1.ComponentService.register(SequenceComponent);
29016 exports.default = SequenceComponent;
29018 },{"../../Component":275,"../../Edge":276,"../../Graph":279,"rxjs":27,"rxjs/operators":225}],334:[function(require,module,exports){
29020 Object.defineProperty(exports, "__esModule", { value: true });
29021 var rxjs_1 = require("rxjs");
29022 var operators_1 = require("rxjs/operators");
29023 var vd = require("virtual-dom");
29024 var Component_1 = require("../../Component");
29025 var Edge_1 = require("../../Edge");
29026 var Error_1 = require("../../Error");
29027 var SequenceDOMRenderer = /** @class */ (function () {
29028 function SequenceDOMRenderer(container) {
29029 this._container = container;
29030 this._minThresholdWidth = 320;
29031 this._maxThresholdWidth = 1480;
29032 this._minThresholdHeight = 240;
29033 this._maxThresholdHeight = 820;
29034 this._stepperDefaultWidth = 108;
29035 this._controlsDefaultWidth = 88;
29036 this._defaultHeight = 30;
29037 this._expandControls = false;
29038 this._mode = Component_1.SequenceMode.Default;
29040 this._changingSpeed = false;
29041 this._index = null;
29042 this._changingPosition = false;
29043 this._mouseEnterDirection$ = new rxjs_1.Subject();
29044 this._mouseLeaveDirection$ = new rxjs_1.Subject();
29045 this._notifyChanged$ = new rxjs_1.Subject();
29046 this._notifyChangingPositionChanged$ = new rxjs_1.Subject();
29047 this._notifySpeedChanged$ = new rxjs_1.Subject();
29048 this._notifyIndexChanged$ = new rxjs_1.Subject();
29050 Object.defineProperty(SequenceDOMRenderer.prototype, "changed$", {
29052 return this._notifyChanged$;
29057 Object.defineProperty(SequenceDOMRenderer.prototype, "changingPositionChanged$", {
29059 return this._notifyChangingPositionChanged$;
29064 Object.defineProperty(SequenceDOMRenderer.prototype, "speed$", {
29066 return this._notifySpeedChanged$;
29071 Object.defineProperty(SequenceDOMRenderer.prototype, "index$", {
29073 return this._notifyIndexChanged$;
29078 Object.defineProperty(SequenceDOMRenderer.prototype, "mouseEnterDirection$", {
29080 return this._mouseEnterDirection$;
29085 Object.defineProperty(SequenceDOMRenderer.prototype, "mouseLeaveDirection$", {
29087 return this._mouseLeaveDirection$;
29092 SequenceDOMRenderer.prototype.activate = function () {
29094 if (!!this._changingSubscription) {
29097 this._changingSubscription = rxjs_1.merge(this._container.mouseService.documentMouseUp$, this._container.touchService.touchEnd$.pipe(operators_1.filter(function (touchEvent) {
29098 return touchEvent.touches.length === 0;
29100 .subscribe(function (event) {
29101 if (_this._changingSpeed) {
29102 _this._changingSpeed = false;
29104 if (_this._changingPosition) {
29105 _this._setChangingPosition(false);
29109 SequenceDOMRenderer.prototype.deactivate = function () {
29110 if (!this._changingSubscription) {
29113 this._changingSpeed = false;
29114 this._changingPosition = false;
29115 this._expandControls = false;
29116 this._mode = Component_1.SequenceMode.Default;
29117 this._changingSubscription.unsubscribe();
29118 this._changingSubscription = null;
29120 SequenceDOMRenderer.prototype.render = function (edgeStatus, configuration, containerWidth, speed, index, max, component, navigator) {
29121 if (configuration.visible === false) {
29122 return vd.h("div.SequenceContainer", {}, []);
29124 var stepper = this._createStepper(edgeStatus, configuration, containerWidth, component, navigator);
29125 var controls = this._createSequenceControls(containerWidth);
29126 var playback = this._createPlaybackControls(containerWidth, speed, component, configuration);
29127 var timeline = this._createTimelineControls(containerWidth, index, max);
29128 return vd.h("div.SequenceContainer", [stepper, controls, playback, timeline]);
29130 SequenceDOMRenderer.prototype.getContainerWidth = function (size, configuration) {
29131 var minWidth = configuration.minWidth;
29132 var maxWidth = configuration.maxWidth;
29133 if (maxWidth < minWidth) {
29134 maxWidth = minWidth;
29136 var relativeWidth = (size.width - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth);
29137 var relativeHeight = (size.height - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight);
29138 var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight)));
29139 return minWidth + coeff * (maxWidth - minWidth);
29141 SequenceDOMRenderer.prototype._createPositionInput = function (index, max) {
29143 this._index = index;
29144 var onPosition = function (e) {
29145 _this._index = Number(e.target.value);
29146 _this._notifyIndexChanged$.next(_this._index);
29148 var boundingRect = this._container.domContainer.getBoundingClientRect();
29149 var width = Math.max(276, Math.min(410, 5 + 0.8 * boundingRect.width)) - 65;
29150 var onStart = function (e) {
29151 e.stopPropagation();
29152 _this._setChangingPosition(true);
29154 var onMove = function (e) {
29155 if (_this._changingPosition === true) {
29156 e.stopPropagation();
29159 var onKeyDown = function (e) {
29160 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
29161 e.key === "ArrowRight" || e.key === "ArrowUp") {
29162 e.preventDefault();
29165 var positionInputProperties = {
29166 max: max != null ? max : 1,
29168 onchange: onPosition,
29169 oninput: onPosition,
29170 onkeydown: onKeyDown,
29171 onmousedown: onStart,
29172 onmousemove: onMove,
29173 ontouchmove: onMove,
29174 ontouchstart: onStart,
29176 width: width + "px",
29179 value: index != null ? index : 0,
29181 var disabled = index == null || max == null || max <= 1;
29183 positionInputProperties.disabled = "true";
29185 var positionInput = vd.h("input.SequencePosition", positionInputProperties, []);
29186 var positionContainerClass = disabled ? ".SequencePositionContainerDisabled" : ".SequencePositionContainer";
29187 return vd.h("div" + positionContainerClass, [positionInput]);
29189 SequenceDOMRenderer.prototype._createSpeedInput = function (speed) {
29191 this._speed = speed;
29192 var onSpeed = function (e) {
29193 _this._speed = Number(e.target.value) / 1000;
29194 _this._notifySpeedChanged$.next(_this._speed);
29196 var boundingRect = this._container.domContainer.getBoundingClientRect();
29197 var width = Math.max(276, Math.min(410, 5 + 0.8 * boundingRect.width)) - 160;
29198 var onStart = function (e) {
29199 _this._changingSpeed = true;
29200 e.stopPropagation();
29202 var onMove = function (e) {
29203 if (_this._changingSpeed === true) {
29204 e.stopPropagation();
29207 var onKeyDown = function (e) {
29208 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
29209 e.key === "ArrowRight" || e.key === "ArrowUp") {
29210 e.preventDefault();
29213 var speedInput = vd.h("input.SequenceSpeed", {
29218 onkeydown: onKeyDown,
29219 onmousedown: onStart,
29220 onmousemove: onMove,
29221 ontouchmove: onMove,
29222 ontouchstart: onStart,
29224 width: width + "px",
29227 value: 1000 * speed,
29229 return vd.h("div.SequenceSpeedContainer", [speedInput]);
29231 SequenceDOMRenderer.prototype._createPlaybackControls = function (containerWidth, speed, component, configuration) {
29233 if (this._mode !== Component_1.SequenceMode.Playback) {
29234 return vd.h("div.SequencePlayback", []);
29236 var switchIcon = vd.h("div.SequenceSwitchIcon.SequenceIconVisible", []);
29237 var direction = configuration.direction === Edge_1.EdgeDirection.Next ?
29238 Edge_1.EdgeDirection.Prev : Edge_1.EdgeDirection.Next;
29239 var playing = configuration.playing;
29240 var switchButtonProperties = {
29241 onclick: function () {
29243 component.setDirection(direction);
29247 var switchButtonClassName = configuration.playing ? ".SequenceSwitchButtonDisabled" : ".SequenceSwitchButton";
29248 var switchButton = vd.h("div" + switchButtonClassName, switchButtonProperties, [switchIcon]);
29249 var slowIcon = vd.h("div.SequenceSlowIcon.SequenceIconVisible", []);
29250 var slowContainer = vd.h("div.SequenceSlowContainer", [slowIcon]);
29251 var fastIcon = vd.h("div.SequenceFastIcon.SequenceIconVisible", []);
29252 var fastContainer = vd.h("div.SequenceFastContainer", [fastIcon]);
29253 var closeIcon = vd.h("div.SequenceCloseIcon.SequenceIconVisible", []);
29254 var closeButtonProperties = {
29255 onclick: function () {
29256 _this._mode = Component_1.SequenceMode.Default;
29257 _this._notifyChanged$.next(_this);
29260 var closeButton = vd.h("div.SequenceCloseButton", closeButtonProperties, [closeIcon]);
29261 var speedInput = this._createSpeedInput(speed);
29262 var playbackChildren = [switchButton, slowContainer, speedInput, fastContainer, closeButton];
29263 var top = Math.round(containerWidth / this._stepperDefaultWidth * this._defaultHeight + 10);
29264 var playbackProperties = { style: { top: top + "px" } };
29265 return vd.h("div.SequencePlayback", playbackProperties, playbackChildren);
29267 SequenceDOMRenderer.prototype._createPlayingButton = function (nextKey, prevKey, configuration, component) {
29268 var canPlay = configuration.direction === Edge_1.EdgeDirection.Next && nextKey != null ||
29269 configuration.direction === Edge_1.EdgeDirection.Prev && prevKey != null;
29270 var onclick = configuration.playing ?
29271 function (e) { component.stop(); } :
29272 canPlay ? function (e) { component.play(); } : null;
29273 var buttonProperties = { onclick: onclick };
29274 var iconClass = configuration.playing ?
29276 canPlay ? "Play" : "PlayDisabled";
29277 var iconProperties = { className: iconClass };
29278 if (configuration.direction === Edge_1.EdgeDirection.Prev) {
29279 iconProperties.style = {
29280 transform: "rotate(180deg) translate(50%, 50%)",
29283 var icon = vd.h("div.SequenceComponentIcon", iconProperties, []);
29284 var buttonClass = canPlay ? "SequencePlay" : "SequencePlayDisabled";
29285 return vd.h("div." + buttonClass, buttonProperties, [icon]);
29287 SequenceDOMRenderer.prototype._createSequenceControls = function (containerWidth) {
29289 var borderRadius = Math.round(8 / this._stepperDefaultWidth * containerWidth);
29290 var expanderProperties = {
29291 onclick: function () {
29292 _this._expandControls = !_this._expandControls;
29293 _this._mode = Component_1.SequenceMode.Default;
29294 _this._notifyChanged$.next(_this);
29297 "border-bottom-right-radius": borderRadius + "px",
29298 "border-top-right-radius": borderRadius + "px",
29301 var expanderBar = vd.h("div.SequenceExpanderBar", []);
29302 var expander = vd.h("div.SequenceExpanderButton", expanderProperties, [expanderBar]);
29303 var fastIconClassName = this._mode === Component_1.SequenceMode.Playback ?
29304 ".SequenceFastIconGrey.SequenceIconVisible" : ".SequenceFastIcon";
29305 var fastIcon = vd.h("div" + fastIconClassName, []);
29306 var playbackProperties = {
29307 onclick: function () {
29308 _this._mode = _this._mode === Component_1.SequenceMode.Playback ?
29309 Component_1.SequenceMode.Default :
29310 Component_1.SequenceMode.Playback;
29311 _this._notifyChanged$.next(_this);
29314 var playback = vd.h("div.SequencePlaybackButton", playbackProperties, [fastIcon]);
29315 var timelineIconClassName = this._mode === Component_1.SequenceMode.Timeline ?
29316 ".SequenceTimelineIconGrey.SequenceIconVisible" : ".SequenceTimelineIcon";
29317 var timelineIcon = vd.h("div" + timelineIconClassName, []);
29318 var timelineProperties = {
29319 onclick: function () {
29320 _this._mode = _this._mode === Component_1.SequenceMode.Timeline ?
29321 Component_1.SequenceMode.Default :
29322 Component_1.SequenceMode.Timeline;
29323 _this._notifyChanged$.next(_this);
29326 var timeline = vd.h("div.SequenceTimelineButton", timelineProperties, [timelineIcon]);
29329 height: (this._defaultHeight / this._stepperDefaultWidth * containerWidth) + "px",
29330 transform: "translate(" + (containerWidth / 2 + 2) + "px, 0)",
29331 width: (this._controlsDefaultWidth / this._stepperDefaultWidth * containerWidth) + "px",
29334 var className = ".SequenceControls" +
29335 (this._expandControls ? ".SequenceControlsExpanded" : "");
29336 return vd.h("div" + className, properties, [playback, timeline, expander]);
29338 SequenceDOMRenderer.prototype._createSequenceArrows = function (nextKey, prevKey, containerWidth, configuration, navigator) {
29340 var nextProperties = {
29341 onclick: nextKey != null ?
29343 navigator.moveDir$(Edge_1.EdgeDirection.Next)
29344 .subscribe(undefined, function (error) {
29345 if (!(error instanceof Error_1.AbortMapillaryError)) {
29346 console.error(error);
29351 onmouseenter: function (e) { _this._mouseEnterDirection$.next(Edge_1.EdgeDirection.Next); },
29352 onmouseleave: function (e) { _this._mouseLeaveDirection$.next(Edge_1.EdgeDirection.Next); },
29354 var borderRadius = Math.round(8 / this._stepperDefaultWidth * containerWidth);
29355 var prevProperties = {
29356 onclick: prevKey != null ?
29358 navigator.moveDir$(Edge_1.EdgeDirection.Prev)
29359 .subscribe(undefined, function (error) {
29360 if (!(error instanceof Error_1.AbortMapillaryError)) {
29361 console.error(error);
29366 onmouseenter: function (e) { _this._mouseEnterDirection$.next(Edge_1.EdgeDirection.Prev); },
29367 onmouseleave: function (e) { _this._mouseLeaveDirection$.next(Edge_1.EdgeDirection.Prev); },
29369 "border-bottom-left-radius": borderRadius + "px",
29370 "border-top-left-radius": borderRadius + "px",
29373 var nextClass = this._getStepClassName(Edge_1.EdgeDirection.Next, nextKey, configuration.highlightKey);
29374 var prevClass = this._getStepClassName(Edge_1.EdgeDirection.Prev, prevKey, configuration.highlightKey);
29375 var nextIcon = vd.h("div.SequenceComponentIcon", []);
29376 var prevIcon = vd.h("div.SequenceComponentIcon", []);
29378 vd.h("div." + prevClass, prevProperties, [prevIcon]),
29379 vd.h("div." + nextClass, nextProperties, [nextIcon]),
29382 SequenceDOMRenderer.prototype._createStepper = function (edgeStatus, configuration, containerWidth, component, navigator) {
29383 var nextKey = null;
29384 var prevKey = null;
29385 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
29387 if (edge.data.direction === Edge_1.EdgeDirection.Next) {
29390 if (edge.data.direction === Edge_1.EdgeDirection.Prev) {
29394 var playingButton = this._createPlayingButton(nextKey, prevKey, configuration, component);
29395 var buttons = this._createSequenceArrows(nextKey, prevKey, containerWidth, configuration, navigator);
29396 buttons.splice(1, 0, playingButton);
29397 var containerProperties = {
29398 oncontextmenu: function (event) { event.preventDefault(); },
29400 height: (this._defaultHeight / this._stepperDefaultWidth * containerWidth) + "px",
29401 width: containerWidth + "px",
29404 return vd.h("div.SequenceStepper", containerProperties, buttons);
29406 SequenceDOMRenderer.prototype._createTimelineControls = function (containerWidth, index, max) {
29408 if (this._mode !== Component_1.SequenceMode.Timeline) {
29409 return vd.h("div.SequenceTimeline", []);
29411 var positionInput = this._createPositionInput(index, max);
29412 var closeIcon = vd.h("div.SequenceCloseIcon.SequenceIconVisible", []);
29413 var closeButtonProperties = {
29414 onclick: function () {
29415 _this._mode = Component_1.SequenceMode.Default;
29416 _this._notifyChanged$.next(_this);
29419 var closeButton = vd.h("div.SequenceCloseButton", closeButtonProperties, [closeIcon]);
29420 var top = Math.round(containerWidth / this._stepperDefaultWidth * this._defaultHeight + 10);
29421 var playbackProperties = { style: { top: top + "px" } };
29422 return vd.h("div.SequenceTimeline", playbackProperties, [positionInput, closeButton]);
29424 SequenceDOMRenderer.prototype._getStepClassName = function (direction, key, highlightKey) {
29425 var className = direction === Edge_1.EdgeDirection.Next ?
29426 "SequenceStepNext" :
29427 "SequenceStepPrev";
29429 className += "Disabled";
29432 if (highlightKey === key) {
29433 className += "Highlight";
29438 SequenceDOMRenderer.prototype._setChangingPosition = function (value) {
29439 this._changingPosition = value;
29440 this._notifyChangingPositionChanged$.next(value);
29442 return SequenceDOMRenderer;
29444 exports.SequenceDOMRenderer = SequenceDOMRenderer;
29445 exports.default = SequenceDOMRenderer;
29447 },{"../../Component":275,"../../Edge":276,"../../Error":277,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],335:[function(require,module,exports){
29449 Object.defineProperty(exports, "__esModule", { value: true });
29451 (function (SequenceMode) {
29452 SequenceMode[SequenceMode["Default"] = 0] = "Default";
29453 SequenceMode[SequenceMode["Playback"] = 1] = "Playback";
29454 SequenceMode[SequenceMode["Timeline"] = 2] = "Timeline";
29455 })(SequenceMode = exports.SequenceMode || (exports.SequenceMode = {}));
29456 exports.default = SequenceMode;
29458 },{}],336:[function(require,module,exports){
29460 Object.defineProperty(exports, "__esModule", { value: true });
29462 var path = require("path");
29463 var Shaders = /** @class */ (function () {
29464 function Shaders() {
29466 Shaders.equirectangular = {
29467 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}",
29468 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}",
29470 Shaders.equirectangularCurtain = {
29471 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}",
29472 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}",
29474 Shaders.perspective = {
29475 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}",
29476 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}",
29478 Shaders.perspectiveCurtain = {
29479 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",
29480 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}",
29482 Shaders.perspectiveDistorted = {
29483 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",
29484 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",
29486 Shaders.perspectiveDistortedCurtain = {
29487 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",
29488 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",
29492 exports.Shaders = Shaders;
29495 },{"path":23}],337:[function(require,module,exports){
29497 var __extends = (this && this.__extends) || (function () {
29498 var extendStatics = function (d, b) {
29499 extendStatics = Object.setPrototypeOf ||
29500 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29501 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
29502 return extendStatics(d, b);
29504 return function (d, b) {
29505 extendStatics(d, b);
29506 function __() { this.constructor = d; }
29507 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29510 Object.defineProperty(exports, "__esModule", { value: true });
29511 var rxjs_1 = require("rxjs");
29512 var operators_1 = require("rxjs/operators");
29513 var Component_1 = require("../../Component");
29514 var Geo_1 = require("../../Geo");
29515 var State_1 = require("../../State");
29516 var Render_1 = require("../../Render");
29517 var Tiles_1 = require("../../Tiles");
29518 var Utils_1 = require("../../Utils");
29520 * @class SliderComponent
29522 * @classdesc Component for comparing pairs of images. Renders
29523 * a slider for adjusting the curtain of the first image.
29525 * Deactivate the sequence, direction and image plane
29526 * components when activating the slider component to avoid
29527 * interfering UI elements.
29529 * To retrive and use the marker component
29533 * var viewer = new Mapillary.Viewer(
29538 * viewer.deactivateComponent("imagePlane");
29539 * viewer.deactivateComponent("direction");
29540 * viewer.deactivateComponent("sequence");
29542 * viewer.activateComponent("slider");
29544 * var sliderComponent = viewer.getComponent("marker");
29547 var SliderComponent = /** @class */ (function (_super) {
29548 __extends(SliderComponent, _super);
29550 function SliderComponent(name, container, navigator, viewportCoords) {
29551 var _this = _super.call(this, name, container, navigator) || this;
29552 _this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
29553 _this._domRenderer = new Component_1.SliderDOMRenderer(container);
29554 _this._imageTileLoader = new Tiles_1.ImageTileLoader(Utils_1.Urls.tileScheme, Utils_1.Urls.tileDomain, Utils_1.Urls.origin);
29555 _this._roiCalculator = new Tiles_1.RegionOfInterestCalculator();
29556 _this._spatial = new Geo_1.Spatial();
29557 _this._glRendererOperation$ = new rxjs_1.Subject();
29558 _this._glRendererCreator$ = new rxjs_1.Subject();
29559 _this._glRendererDisposer$ = new rxjs_1.Subject();
29560 _this._glRenderer$ = _this._glRendererOperation$.pipe(operators_1.scan(function (glRenderer, operation) {
29561 return operation(glRenderer);
29562 }, null), operators_1.filter(function (glRenderer) {
29563 return glRenderer != null;
29564 }), operators_1.distinctUntilChanged(undefined, function (glRenderer) {
29565 return glRenderer.frameId;
29567 _this._glRendererCreator$.pipe(operators_1.map(function () {
29568 return function (glRenderer) {
29569 if (glRenderer != null) {
29570 throw new Error("Multiple slider states can not be created at the same time");
29572 return new Component_1.SliderGLRenderer();
29575 .subscribe(_this._glRendererOperation$);
29576 _this._glRendererDisposer$.pipe(operators_1.map(function () {
29577 return function (glRenderer) {
29578 glRenderer.dispose();
29582 .subscribe(_this._glRendererOperation$);
29586 * Set the initial position.
29588 * @description Configures the intial position of the slider.
29589 * The inital position value will be used when the component
29592 * @param {number} initialPosition - Initial slider position.
29594 SliderComponent.prototype.setInitialPosition = function (initialPosition) {
29595 this.configure({ initialPosition: initialPosition });
29598 * Set the image keys.
29600 * @description Configures the component to show the image
29601 * planes for the supplied image keys.
29603 * @param {ISliderKeys} keys - Slider keys object specifying
29604 * the images to be shown in the foreground and the background.
29606 SliderComponent.prototype.setKeys = function (keys) {
29607 this.configure({ keys: keys });
29610 * Set the slider mode.
29612 * @description Configures the mode for transitions between
29615 * @param {SliderMode} mode - Slider mode to be set.
29617 SliderComponent.prototype.setSliderMode = function (mode) {
29618 this.configure({ mode: mode });
29621 * Set the value controlling if the slider is visible.
29623 * @param {boolean} sliderVisible - Value indicating if
29624 * the slider should be visible or not.
29626 SliderComponent.prototype.setSliderVisible = function (sliderVisible) {
29627 this.configure({ sliderVisible: sliderVisible });
29629 SliderComponent.prototype._activate = function () {
29631 this._modeSubcription = this._domRenderer.mode$
29632 .subscribe(function (mode) {
29633 _this.setSliderMode(mode);
29635 this._glRenderSubscription = this._glRenderer$.pipe(operators_1.map(function (glRenderer) {
29639 frameId: glRenderer.frameId,
29640 needsRender: glRenderer.needsRender,
29641 render: glRenderer.render.bind(glRenderer),
29642 stage: Render_1.GLRenderStage.Background,
29647 .subscribe(this._container.glRenderer.render$);
29648 var position$ = rxjs_1.concat(this.configuration$.pipe(operators_1.map(function (configuration) {
29649 return configuration.initialPosition != null ?
29650 configuration.initialPosition : 1;
29651 }), operators_1.first()), this._domRenderer.position$);
29652 var mode$ = this.configuration$.pipe(operators_1.map(function (configuration) {
29653 return configuration.mode;
29654 }), operators_1.distinctUntilChanged());
29655 var motionless$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
29656 return frame.state.motionless;
29657 }), operators_1.distinctUntilChanged());
29658 var fullPano$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
29659 return frame.state.currentNode.fullPano;
29660 }), operators_1.distinctUntilChanged());
29661 var sliderVisible$ = rxjs_1.combineLatest(this._configuration$.pipe(operators_1.map(function (configuration) {
29662 return configuration.sliderVisible;
29663 })), this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
29664 return !(frame.state.currentNode == null ||
29665 frame.state.previousNode == null ||
29666 (frame.state.currentNode.pano && !frame.state.currentNode.fullPano) ||
29667 (frame.state.previousNode.pano && !frame.state.previousNode.fullPano) ||
29668 (frame.state.currentNode.fullPano && !frame.state.previousNode.fullPano));
29669 }), operators_1.distinctUntilChanged())).pipe(operators_1.map(function (_a) {
29670 var sliderVisible = _a[0], enabledState = _a[1];
29671 return sliderVisible && enabledState;
29672 }), operators_1.distinctUntilChanged());
29673 this._waitSubscription = rxjs_1.combineLatest(mode$, motionless$, fullPano$, sliderVisible$).pipe(operators_1.withLatestFrom(this._navigator.stateService.state$))
29674 .subscribe(function (_a) {
29675 var _b = _a[0], mode = _b[0], motionless = _b[1], fullPano = _b[2], sliderVisible = _b[3], state = _a[1];
29676 var interactive = sliderVisible &&
29677 (motionless || mode === Component_1.SliderMode.Stationary || fullPano);
29678 if (interactive && state !== State_1.State.WaitingInteractively) {
29679 _this._navigator.stateService.waitInteractively();
29681 else if (!interactive && state !== State_1.State.Waiting) {
29682 _this._navigator.stateService.wait();
29685 this._moveSubscription = rxjs_1.combineLatest(position$, mode$, motionless$, fullPano$, sliderVisible$)
29686 .subscribe(function (_a) {
29687 var position = _a[0], mode = _a[1], motionless = _a[2], fullPano = _a[3], sliderVisible = _a[4];
29688 if (motionless || mode === Component_1.SliderMode.Stationary || fullPano) {
29689 _this._navigator.stateService.moveTo(1);
29692 _this._navigator.stateService.moveTo(position);
29695 this._domRenderSubscription = rxjs_1.combineLatest(position$, mode$, motionless$, fullPano$, sliderVisible$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
29696 var position = _a[0], mode = _a[1], motionless = _a[2], fullPano = _a[3], sliderVisible = _a[4], size = _a[5];
29699 vnode: _this._domRenderer.render(position, mode, motionless, fullPano, sliderVisible),
29702 .subscribe(this._container.domRenderer.render$);
29703 this._glRendererCreator$.next(null);
29704 this._updateCurtainSubscription = rxjs_1.combineLatest(position$, fullPano$, sliderVisible$, this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.map(function (_a) {
29705 var position = _a[0], fullPano = _a[1], visible = _a[2], render = _a[3], transform = _a[4];
29707 return visible ? position : 1;
29709 var basicMin = _this._viewportCoords.viewportToBasic(-1.15, 0, transform, render.perspective);
29710 var basicMax = _this._viewportCoords.viewportToBasic(1.15, 0, transform, render.perspective);
29711 var shiftedMax = basicMax[0] < basicMin[0] ? basicMax[0] + 1 : basicMax[0];
29712 var basicPosition = basicMin[0] + position * (shiftedMax - basicMin[0]);
29713 return basicPosition > 1 ? basicPosition - 1 : basicPosition;
29714 }), operators_1.map(function (position) {
29715 return function (glRenderer) {
29716 glRenderer.updateCurtain(position);
29720 .subscribe(this._glRendererOperation$);
29721 this._stateSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentState$, mode$).pipe(operators_1.map(function (_a) {
29722 var frame = _a[0], mode = _a[1];
29723 return function (glRenderer) {
29724 glRenderer.update(frame, mode);
29728 .subscribe(this._glRendererOperation$);
29729 this._setKeysSubscription = this._configuration$.pipe(operators_1.filter(function (configuration) {
29730 return configuration.keys != null;
29731 }), operators_1.switchMap(function (configuration) {
29732 return rxjs_1.zip(rxjs_1.zip(_this._catchCacheNode$(configuration.keys.background), _this._catchCacheNode$(configuration.keys.foreground)).pipe(operators_1.map(function (nodes) {
29733 return { background: nodes[0], foreground: nodes[1] };
29734 })), _this._navigator.stateService.currentState$.pipe(operators_1.first())).pipe(operators_1.map(function (nf) {
29735 return { nodes: nf[0], state: nf[1].state };
29738 .subscribe(function (co) {
29739 if (co.state.currentNode != null &&
29740 co.state.previousNode != null &&
29741 co.state.currentNode.key === co.nodes.foreground.key &&
29742 co.state.previousNode.key === co.nodes.background.key) {
29745 if (co.state.currentNode.key === co.nodes.background.key) {
29746 _this._navigator.stateService.setNodes([co.nodes.foreground]);
29749 if (co.state.currentNode.key === co.nodes.foreground.key &&
29750 co.state.trajectory.length === 1) {
29751 _this._navigator.stateService.prependNodes([co.nodes.background]);
29754 _this._navigator.stateService.setNodes([co.nodes.background]);
29755 _this._navigator.stateService.setNodes([co.nodes.foreground]);
29759 var previousNode$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
29760 return frame.state.previousNode;
29761 }), operators_1.filter(function (node) {
29762 return node != null;
29763 }), operators_1.distinctUntilChanged(undefined, function (node) {
29766 var textureProvider$ = this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
29767 return frame.state.currentNode.key;
29768 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
29769 var frame = _a[0], renderer = _a[1], size = _a[2];
29770 var state = frame.state;
29771 var viewportSize = Math.max(size.width, size.height);
29772 var currentNode = state.currentNode;
29773 var currentTransform = state.currentTransform;
29774 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
29775 return new Tiles_1.TextureProvider(currentNode.key, currentTransform.basicWidth, currentTransform.basicHeight, tileSize, currentNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
29776 }), operators_1.publishReplay(1), operators_1.refCount());
29777 this._textureProviderSubscription = textureProvider$.subscribe(function () { });
29778 this._setTextureProviderSubscription = textureProvider$.pipe(operators_1.map(function (provider) {
29779 return function (renderer) {
29780 renderer.setTextureProvider(provider.key, provider);
29784 .subscribe(this._glRendererOperation$);
29785 this._setTileSizeSubscription = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
29786 return rxjs_1.combineLatest(textureProvider$, rxjs_1.of(size)).pipe(operators_1.first());
29788 .subscribe(function (_a) {
29789 var provider = _a[0], size = _a[1];
29790 var viewportSize = Math.max(size.width, size.height);
29791 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
29792 provider.setTileSize(tileSize);
29794 this._abortTextureProviderSubscription = textureProvider$.pipe(operators_1.pairwise())
29795 .subscribe(function (pair) {
29796 var previous = pair[0];
29799 var roiTrigger$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
29800 var camera = _a[0], size = _a[1];
29802 camera.camera.position.clone(),
29803 camera.camera.lookat.clone(),
29804 camera.zoom.valueOf(),
29805 size.height.valueOf(),
29806 size.width.valueOf()
29808 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
29809 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
29810 }), operators_1.map(function (pls) {
29811 var samePosition = pls[0][0].equals(pls[1][0]);
29812 var sameLookat = pls[0][1].equals(pls[1][1]);
29813 var sameZoom = pls[0][2] === pls[1][2];
29814 var sameHeight = pls[0][3] === pls[1][3];
29815 var sameWidth = pls[0][4] === pls[1][4];
29816 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
29817 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
29819 }), operators_1.switchMap(function (stalled) {
29820 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
29821 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
29822 this._setRegionOfInterestSubscription = textureProvider$.pipe(operators_1.switchMap(function (provider) {
29823 return roiTrigger$.pipe(operators_1.map(function (_a) {
29824 var camera = _a[0], size = _a[1], transform = _a[2];
29826 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
29830 }), operators_1.filter(function (args) {
29831 return !args[1].disposed;
29833 .subscribe(function (args) {
29835 var provider = args[1];
29836 provider.setRegionOfInterest(roi);
29838 var hasTexture$ = textureProvider$.pipe(operators_1.switchMap(function (provider) {
29839 return provider.hasTexture$;
29840 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
29841 this._hasTextureSubscription = hasTexture$.subscribe(function () { });
29842 var nodeImage$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
29843 return frame.state.nodesAhead === 0;
29844 }), operators_1.map(function (frame) {
29845 return frame.state.currentNode;
29846 }), operators_1.distinctUntilChanged(undefined, function (node) {
29848 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexture$), operators_1.filter(function (args) {
29850 }), operators_1.map(function (args) {
29852 }), operators_1.filter(function (node) {
29854 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
29855 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
29856 }), operators_1.switchMap(function (node) {
29857 var baseImageSize = node.pano ?
29858 Utils_1.Settings.basePanoramaSize :
29859 Utils_1.Settings.baseImageSize;
29860 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
29861 return rxjs_1.empty();
29864 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
29865 return [n.image, n];
29867 return image$.pipe(operators_1.takeUntil(hasTexture$.pipe(operators_1.filter(function (hasTexture) {
29869 }))), operators_1.catchError(function (error, caught) {
29870 console.error("Failed to fetch high res image (" + node.key + ")", error);
29871 return rxjs_1.empty();
29873 })).pipe(operators_1.publish(), operators_1.refCount());
29874 this._updateBackgroundSubscription = nodeImage$.pipe(operators_1.withLatestFrom(textureProvider$))
29875 .subscribe(function (args) {
29876 if (args[0][1].key !== args[1].key ||
29877 args[1].disposed) {
29880 args[1].updateBackground(args[0][0]);
29882 this._updateTextureImageSubscription = nodeImage$.pipe(operators_1.map(function (imn) {
29883 return function (renderer) {
29884 renderer.updateTextureImage(imn[0], imn[1]);
29888 .subscribe(this._glRendererOperation$);
29889 var textureProviderPrev$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
29890 return !!frame.state.previousNode;
29891 }), operators_1.distinctUntilChanged(undefined, function (frame) {
29892 return frame.state.previousNode.key;
29893 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
29894 var frame = _a[0], renderer = _a[1], size = _a[2];
29895 var state = frame.state;
29896 var viewportSize = Math.max(size.width, size.height);
29897 var previousNode = state.previousNode;
29898 var previousTransform = state.previousTransform;
29899 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
29900 return new Tiles_1.TextureProvider(previousNode.key, previousTransform.basicWidth, previousTransform.basicHeight, tileSize, previousNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
29901 }), operators_1.publishReplay(1), operators_1.refCount());
29902 this._textureProviderSubscriptionPrev = textureProviderPrev$.subscribe(function () { });
29903 this._setTextureProviderSubscriptionPrev = textureProviderPrev$.pipe(operators_1.map(function (provider) {
29904 return function (renderer) {
29905 renderer.setTextureProviderPrev(provider.key, provider);
29909 .subscribe(this._glRendererOperation$);
29910 this._setTileSizeSubscriptionPrev = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
29911 return rxjs_1.combineLatest(textureProviderPrev$, rxjs_1.of(size)).pipe(operators_1.first());
29913 .subscribe(function (_a) {
29914 var provider = _a[0], size = _a[1];
29915 var viewportSize = Math.max(size.width, size.height);
29916 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
29917 provider.setTileSize(tileSize);
29919 this._abortTextureProviderSubscriptionPrev = textureProviderPrev$.pipe(operators_1.pairwise())
29920 .subscribe(function (pair) {
29921 var previous = pair[0];
29924 var roiTriggerPrev$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
29925 var camera = _a[0], size = _a[1];
29927 camera.camera.position.clone(),
29928 camera.camera.lookat.clone(),
29929 camera.zoom.valueOf(),
29930 size.height.valueOf(),
29931 size.width.valueOf()
29933 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
29934 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
29935 }), operators_1.map(function (pls) {
29936 var samePosition = pls[0][0].equals(pls[1][0]);
29937 var sameLookat = pls[0][1].equals(pls[1][1]);
29938 var sameZoom = pls[0][2] === pls[1][2];
29939 var sameHeight = pls[0][3] === pls[1][3];
29940 var sameWidth = pls[0][4] === pls[1][4];
29941 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
29942 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
29944 }), operators_1.switchMap(function (stalled) {
29945 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
29946 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
29947 this._setRegionOfInterestSubscriptionPrev = textureProviderPrev$.pipe(operators_1.switchMap(function (provider) {
29948 return roiTriggerPrev$.pipe(operators_1.map(function (_a) {
29949 var camera = _a[0], size = _a[1], transform = _a[2];
29951 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
29955 }), operators_1.filter(function (args) {
29956 return !args[1].disposed;
29957 }), operators_1.withLatestFrom(this._navigator.stateService.currentState$))
29958 .subscribe(function (_a) {
29959 var _b = _a[0], roi = _b[0], provider = _b[1], frame = _a[1];
29960 var shiftedRoi = null;
29961 if (frame.state.previousNode.fullPano) {
29962 if (frame.state.currentNode.fullPano) {
29963 var currentViewingDirection = _this._spatial.viewingDirection(frame.state.currentNode.rotation);
29964 var previousViewingDirection = _this._spatial.viewingDirection(frame.state.previousNode.rotation);
29965 var directionDiff = _this._spatial.angleBetweenVector2(currentViewingDirection.x, currentViewingDirection.y, previousViewingDirection.x, previousViewingDirection.y);
29966 var shift = directionDiff / (2 * Math.PI);
29968 maxX: _this._spatial.wrap(roi.bbox.maxX + shift, 0, 1),
29969 maxY: roi.bbox.maxY,
29970 minX: _this._spatial.wrap(roi.bbox.minX + shift, 0, 1),
29971 minY: roi.bbox.minY,
29975 pixelHeight: roi.pixelHeight,
29976 pixelWidth: roi.pixelWidth,
29980 var currentViewingDirection = _this._spatial.viewingDirection(frame.state.currentNode.rotation);
29981 var previousViewingDirection = _this._spatial.viewingDirection(frame.state.previousNode.rotation);
29982 var directionDiff = _this._spatial.angleBetweenVector2(currentViewingDirection.x, currentViewingDirection.y, previousViewingDirection.x, previousViewingDirection.y);
29983 var shiftX = directionDiff / (2 * Math.PI);
29984 var a1 = _this._spatial.angleToPlane(currentViewingDirection.toArray(), [0, 0, 1]);
29985 var a2 = _this._spatial.angleToPlane(previousViewingDirection.toArray(), [0, 0, 1]);
29986 var shiftY = (a2 - a1) / (2 * Math.PI);
29987 var currentTransform = frame.state.currentTransform;
29988 var size = Math.max(currentTransform.basicWidth, currentTransform.basicHeight);
29989 var hFov = size > 0 ?
29990 2 * Math.atan(0.5 * currentTransform.basicWidth / (size * currentTransform.focal)) :
29992 var vFov = size > 0 ?
29993 2 * Math.atan(0.5 * currentTransform.basicHeight / (size * currentTransform.focal)) :
29995 var spanningWidth = hFov / (2 * Math.PI);
29996 var spanningHeight = vFov / Math.PI;
29997 var basicWidth = (roi.bbox.maxX - roi.bbox.minX) * spanningWidth;
29998 var basicHeight = (roi.bbox.maxY - roi.bbox.minY) * spanningHeight;
29999 var pixelWidth = roi.pixelWidth * spanningWidth;
30000 var pixelHeight = roi.pixelHeight * spanningHeight;
30001 var zoomShiftX = (roi.bbox.minX + roi.bbox.maxX) / 2 - 0.5;
30002 var zoomShiftY = (roi.bbox.minY + roi.bbox.maxY) / 2 - 0.5;
30003 var minX = 0.5 + shiftX + spanningWidth * zoomShiftX - basicWidth / 2;
30004 var maxX = 0.5 + shiftX + spanningWidth * zoomShiftX + basicWidth / 2;
30005 var minY = 0.5 + shiftY + spanningHeight * zoomShiftY - basicHeight / 2;
30006 var maxY = 0.5 + shiftY + spanningHeight * zoomShiftY + basicHeight / 2;
30008 maxX: _this._spatial.wrap(maxX, 0, 1),
30010 minX: _this._spatial.wrap(minX, 0, 1),
30015 pixelHeight: pixelHeight,
30016 pixelWidth: pixelWidth,
30021 var currentBasicAspect = frame.state.currentTransform.basicAspect;
30022 var previousBasicAspect = frame.state.previousTransform.basicAspect;
30023 var _c = _this._getBasicCorners(currentBasicAspect, previousBasicAspect), _d = _c[0], cornerMinX = _d[0], cornerMinY = _d[1], _e = _c[1], cornerMaxX = _e[0], cornerMaxY = _e[1];
30024 var basicWidth = cornerMaxX - cornerMinX;
30025 var basicHeight = cornerMaxY - cornerMinY;
30026 var pixelWidth = roi.pixelWidth / basicWidth;
30027 var pixelHeight = roi.pixelHeight / basicHeight;
30028 var minX = (basicWidth - 1) / (2 * basicWidth) + roi.bbox.minX / basicWidth;
30029 var maxX = (basicWidth - 1) / (2 * basicWidth) + roi.bbox.maxX / basicWidth;
30030 var minY = (basicHeight - 1) / (2 * basicHeight) + roi.bbox.minY / basicHeight;
30031 var maxY = (basicHeight - 1) / (2 * basicHeight) + roi.bbox.maxY / basicHeight;
30038 _this._clipBoundingBox(bbox);
30041 pixelHeight: pixelHeight,
30042 pixelWidth: pixelWidth,
30045 provider.setRegionOfInterest(shiftedRoi);
30047 var hasTexturePrev$ = textureProviderPrev$.pipe(operators_1.switchMap(function (provider) {
30048 return provider.hasTexture$;
30049 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
30050 this._hasTextureSubscriptionPrev = hasTexturePrev$.subscribe(function () { });
30051 var nodeImagePrev$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
30052 return frame.state.nodesAhead === 0 && !!frame.state.previousNode;
30053 }), operators_1.map(function (frame) {
30054 return frame.state.previousNode;
30055 }), operators_1.distinctUntilChanged(undefined, function (node) {
30057 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexturePrev$), operators_1.filter(function (args) {
30059 }), operators_1.map(function (args) {
30061 }), operators_1.filter(function (node) {
30063 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
30064 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
30065 }), operators_1.switchMap(function (node) {
30066 var baseImageSize = node.pano ?
30067 Utils_1.Settings.basePanoramaSize :
30068 Utils_1.Settings.baseImageSize;
30069 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
30070 return rxjs_1.empty();
30073 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
30074 return [n.image, n];
30076 return image$.pipe(operators_1.takeUntil(hasTexturePrev$.pipe(operators_1.filter(function (hasTexture) {
30078 }))), operators_1.catchError(function (error, caught) {
30079 console.error("Failed to fetch high res image (" + node.key + ")", error);
30080 return rxjs_1.empty();
30082 })).pipe(operators_1.publish(), operators_1.refCount());
30083 this._updateBackgroundSubscriptionPrev = nodeImagePrev$.pipe(operators_1.withLatestFrom(textureProviderPrev$))
30084 .subscribe(function (args) {
30085 if (args[0][1].key !== args[1].key ||
30086 args[1].disposed) {
30089 args[1].updateBackground(args[0][0]);
30091 this._updateTextureImageSubscriptionPrev = nodeImagePrev$.pipe(operators_1.map(function (imn) {
30092 return function (renderer) {
30093 renderer.updateTextureImage(imn[0], imn[1]);
30097 .subscribe(this._glRendererOperation$);
30099 SliderComponent.prototype._deactivate = function () {
30101 this._waitSubscription.unsubscribe();
30102 this._navigator.stateService.state$.pipe(operators_1.first())
30103 .subscribe(function (state) {
30104 if (state !== State_1.State.Traversing) {
30105 _this._navigator.stateService.traverse();
30108 this._glRendererDisposer$.next(null);
30109 this._domRenderer.deactivate();
30110 this._modeSubcription.unsubscribe();
30111 this._setKeysSubscription.unsubscribe();
30112 this._stateSubscription.unsubscribe();
30113 this._glRenderSubscription.unsubscribe();
30114 this._domRenderSubscription.unsubscribe();
30115 this._moveSubscription.unsubscribe();
30116 this._updateCurtainSubscription.unsubscribe();
30117 this._textureProviderSubscription.unsubscribe();
30118 this._setTextureProviderSubscription.unsubscribe();
30119 this._setTileSizeSubscription.unsubscribe();
30120 this._abortTextureProviderSubscription.unsubscribe();
30121 this._setRegionOfInterestSubscription.unsubscribe();
30122 this._hasTextureSubscription.unsubscribe();
30123 this._updateBackgroundSubscription.unsubscribe();
30124 this._updateTextureImageSubscription.unsubscribe();
30125 this._textureProviderSubscriptionPrev.unsubscribe();
30126 this._setTextureProviderSubscriptionPrev.unsubscribe();
30127 this._setTileSizeSubscriptionPrev.unsubscribe();
30128 this._abortTextureProviderSubscriptionPrev.unsubscribe();
30129 this._setRegionOfInterestSubscriptionPrev.unsubscribe();
30130 this._hasTextureSubscriptionPrev.unsubscribe();
30131 this._updateBackgroundSubscriptionPrev.unsubscribe();
30132 this._updateTextureImageSubscriptionPrev.unsubscribe();
30133 this.configure({ keys: null });
30135 SliderComponent.prototype._getDefaultConfiguration = function () {
30137 initialPosition: 1,
30138 mode: Component_1.SliderMode.Motion,
30139 sliderVisible: true,
30142 SliderComponent.prototype._catchCacheNode$ = function (key) {
30143 return this._navigator.graphService.cacheNode$(key).pipe(operators_1.catchError(function (error, caught) {
30144 console.error("Failed to cache slider node (" + key + ")", error);
30145 return rxjs_1.empty();
30148 SliderComponent.prototype._getBasicCorners = function (currentAspect, previousAspect) {
30151 if (currentAspect > previousAspect) {
30153 offsetY = 0.5 * currentAspect / previousAspect;
30156 offsetX = 0.5 * previousAspect / currentAspect;
30159 return [[0.5 - offsetX, 0.5 - offsetY], [0.5 + offsetX, 0.5 + offsetY]];
30161 SliderComponent.prototype._clipBoundingBox = function (bbox) {
30162 bbox.minX = Math.max(0, Math.min(1, bbox.minX));
30163 bbox.maxX = Math.max(0, Math.min(1, bbox.maxX));
30164 bbox.minY = Math.max(0, Math.min(1, bbox.minY));
30165 bbox.maxY = Math.max(0, Math.min(1, bbox.maxY));
30167 SliderComponent.componentName = "slider";
30168 return SliderComponent;
30169 }(Component_1.Component));
30170 exports.SliderComponent = SliderComponent;
30171 Component_1.ComponentService.register(SliderComponent);
30172 exports.default = SliderComponent;
30175 },{"../../Component":275,"../../Geo":278,"../../Render":281,"../../State":282,"../../Tiles":284,"../../Utils":285,"rxjs":27,"rxjs/operators":225}],338:[function(require,module,exports){
30177 Object.defineProperty(exports, "__esModule", { value: true });
30178 var rxjs_1 = require("rxjs");
30179 var operators_1 = require("rxjs/operators");
30180 var vd = require("virtual-dom");
30181 var Component_1 = require("../../Component");
30182 var SliderDOMRenderer = /** @class */ (function () {
30183 function SliderDOMRenderer(container) {
30184 this._container = container;
30185 this._interacting = false;
30186 this._notifyModeChanged$ = new rxjs_1.Subject();
30187 this._notifyPositionChanged$ = new rxjs_1.Subject();
30188 this._stopInteractionSubscription = null;
30190 Object.defineProperty(SliderDOMRenderer.prototype, "mode$", {
30192 return this._notifyModeChanged$;
30197 Object.defineProperty(SliderDOMRenderer.prototype, "position$", {
30199 return this._notifyPositionChanged$;
30204 SliderDOMRenderer.prototype.activate = function () {
30206 if (!!this._stopInteractionSubscription) {
30209 this._stopInteractionSubscription = rxjs_1.merge(this._container.mouseService.documentMouseUp$, this._container.touchService.touchEnd$.pipe(operators_1.filter(function (touchEvent) {
30210 return touchEvent.touches.length === 0;
30212 .subscribe(function (event) {
30213 if (_this._interacting) {
30214 _this._interacting = false;
30218 SliderDOMRenderer.prototype.deactivate = function () {
30219 if (!this._stopInteractionSubscription) {
30222 this._interacting = false;
30223 this._stopInteractionSubscription.unsubscribe();
30224 this._stopInteractionSubscription = null;
30226 SliderDOMRenderer.prototype.render = function (position, mode, motionless, pano, visible) {
30229 children.push(vd.h("div.SliderBorder", []));
30230 var modeVisible = !(motionless || pano);
30232 children.push(this._createModeButton(mode));
30234 children.push(this._createPositionInput(position, modeVisible));
30236 var boundingRect = this._container.domContainer.getBoundingClientRect();
30237 var width = Math.max(215, Math.min(400, boundingRect.width - 100));
30238 return vd.h("div.SliderContainer", { style: { width: width + "px" } }, children);
30240 SliderDOMRenderer.prototype._createModeButton = function (mode) {
30243 onclick: function () {
30244 _this._notifyModeChanged$.next(mode === Component_1.SliderMode.Motion ?
30245 Component_1.SliderMode.Stationary :
30246 Component_1.SliderMode.Motion);
30249 var className = mode === Component_1.SliderMode.Stationary ?
30250 "SliderModeButtonPressed" :
30251 "SliderModeButton";
30252 return vd.h("div." + className, properties, [vd.h("div.SliderModeIcon", [])]);
30254 SliderDOMRenderer.prototype._createPositionInput = function (position, modeVisible) {
30256 var onChange = function (e) {
30257 _this._notifyPositionChanged$.next(Number(e.target.value) / 1000);
30259 var onStart = function (e) {
30260 _this._interacting = true;
30261 e.stopPropagation();
30263 var onMove = function (e) {
30264 if (_this._interacting) {
30265 e.stopPropagation();
30268 var onKeyDown = function (e) {
30269 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
30270 e.key === "ArrowRight" || e.key === "ArrowUp") {
30271 e.preventDefault();
30274 var boundingRect = this._container.domContainer.getBoundingClientRect();
30275 var width = Math.max(215, Math.min(400, boundingRect.width - 105)) - 68 + (modeVisible ? 0 : 36);
30276 var positionInput = vd.h("input.SliderPosition", {
30279 onchange: onChange,
30281 onkeydown: onKeyDown,
30282 onmousedown: onStart,
30283 onmousemove: onMove,
30284 ontouchmove: onMove,
30285 ontouchstart: onStart,
30287 width: width + "px",
30290 value: 1000 * position,
30292 return vd.h("div.SliderPositionContainer", [positionInput]);
30294 return SliderDOMRenderer;
30296 exports.SliderDOMRenderer = SliderDOMRenderer;
30297 exports.default = SliderDOMRenderer;
30299 },{"../../Component":275,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],339:[function(require,module,exports){
30301 Object.defineProperty(exports, "__esModule", { value: true });
30302 var Component_1 = require("../../Component");
30303 var Geo_1 = require("../../Geo");
30304 var SliderGLRenderer = /** @class */ (function () {
30305 function SliderGLRenderer() {
30306 this._factory = new Component_1.MeshFactory();
30307 this._scene = new Component_1.MeshScene();
30308 this._spatial = new Geo_1.Spatial();
30309 this._currentKey = null;
30310 this._previousKey = null;
30311 this._disabled = false;
30314 this._needsRender = false;
30316 this._currentProviderDisposers = {};
30317 this._previousProviderDisposers = {};
30319 Object.defineProperty(SliderGLRenderer.prototype, "disabled", {
30321 return this._disabled;
30326 Object.defineProperty(SliderGLRenderer.prototype, "frameId", {
30328 return this._frameId;
30333 Object.defineProperty(SliderGLRenderer.prototype, "needsRender", {
30335 return this._needsRender;
30340 SliderGLRenderer.prototype.setTextureProvider = function (key, provider) {
30341 this._setTextureProvider(key, this._currentKey, provider, this._currentProviderDisposers, this._updateTexture.bind(this));
30343 SliderGLRenderer.prototype.setTextureProviderPrev = function (key, provider) {
30344 this._setTextureProvider(key, this._previousKey, provider, this._previousProviderDisposers, this._updateTexturePrev.bind(this));
30346 SliderGLRenderer.prototype.update = function (frame, mode) {
30347 this._updateFrameId(frame.id);
30348 this._updateImagePlanes(frame.state, mode);
30350 SliderGLRenderer.prototype.updateCurtain = function (curtain) {
30351 if (this._curtain === curtain) {
30354 this._curtain = curtain;
30355 this._updateCurtain();
30356 this._needsRender = true;
30358 SliderGLRenderer.prototype.updateTexture = function (image, node) {
30359 var imagePlanes = node.key === this._currentKey ?
30360 this._scene.imagePlanes :
30361 node.key === this._previousKey ?
30362 this._scene.imagePlanesOld :
30364 if (imagePlanes.length === 0) {
30367 this._needsRender = true;
30368 for (var _i = 0, imagePlanes_1 = imagePlanes; _i < imagePlanes_1.length; _i++) {
30369 var plane = imagePlanes_1[_i];
30370 var material = plane.material;
30371 var texture = material.uniforms.projectorTex.value;
30372 texture.image = image;
30373 texture.needsUpdate = true;
30376 SliderGLRenderer.prototype.updateTextureImage = function (image, node) {
30377 if (this._currentKey !== node.key) {
30380 this._needsRender = true;
30381 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
30382 var plane = _a[_i];
30383 var material = plane.material;
30384 var texture = material.uniforms.projectorTex.value;
30385 texture.image = image;
30386 texture.needsUpdate = true;
30389 SliderGLRenderer.prototype.render = function (perspectiveCamera, renderer) {
30390 if (!this.disabled) {
30391 renderer.render(this._scene.sceneOld, perspectiveCamera);
30393 renderer.render(this._scene.scene, perspectiveCamera);
30394 this._needsRender = false;
30396 SliderGLRenderer.prototype.dispose = function () {
30397 this._scene.clear();
30398 for (var key in this._currentProviderDisposers) {
30399 if (!this._currentProviderDisposers.hasOwnProperty(key)) {
30402 this._currentProviderDisposers[key]();
30404 for (var key in this._previousProviderDisposers) {
30405 if (!this._previousProviderDisposers.hasOwnProperty(key)) {
30408 this._previousProviderDisposers[key]();
30410 this._currentProviderDisposers = {};
30411 this._previousProviderDisposers = {};
30413 SliderGLRenderer.prototype._getBasicCorners = function (currentAspect, previousAspect) {
30416 if (currentAspect > previousAspect) {
30418 offsetY = 0.5 * currentAspect / previousAspect;
30421 offsetX = 0.5 * previousAspect / currentAspect;
30424 return [[0.5 - offsetX, 0.5 - offsetY], [0.5 + offsetX, 0.5 + offsetY]];
30426 SliderGLRenderer.prototype._setDisabled = function (state) {
30427 this._disabled = state.currentNode == null ||
30428 state.previousNode == null ||
30429 (state.currentNode.pano && !state.currentNode.fullPano) ||
30430 (state.previousNode.pano && !state.previousNode.fullPano) ||
30431 (state.currentNode.fullPano && !state.previousNode.fullPano);
30433 SliderGLRenderer.prototype._setTextureProvider = function (key, originalKey, provider, providerDisposers, updateTexture) {
30435 if (key !== originalKey) {
30438 var createdSubscription = provider.textureCreated$
30439 .subscribe(updateTexture);
30440 var updatedSubscription = provider.textureUpdated$
30441 .subscribe(function (updated) {
30442 _this._needsRender = true;
30444 var dispose = function () {
30445 createdSubscription.unsubscribe();
30446 updatedSubscription.unsubscribe();
30447 provider.dispose();
30449 if (key in providerDisposers) {
30450 var disposeProvider = providerDisposers[key];
30452 delete providerDisposers[key];
30454 providerDisposers[key] = dispose;
30456 SliderGLRenderer.prototype._updateCurtain = function () {
30457 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
30458 var plane = _a[_i];
30459 var shaderMaterial = plane.material;
30460 if (!!shaderMaterial.uniforms.curtain) {
30461 shaderMaterial.uniforms.curtain.value = this._curtain;
30465 SliderGLRenderer.prototype._updateFrameId = function (frameId) {
30466 this._frameId = frameId;
30468 SliderGLRenderer.prototype._updateImagePlanes = function (state, mode) {
30469 var currentChanged = state.currentNode != null && this._currentKey !== state.currentNode.key;
30470 var previousChanged = state.previousNode != null && this._previousKey !== state.previousNode.key;
30471 var modeChanged = this._mode !== mode;
30472 if (!(currentChanged || previousChanged || modeChanged)) {
30475 this._setDisabled(state);
30476 this._needsRender = true;
30478 var motionless = state.motionless || mode === Component_1.SliderMode.Stationary || state.currentNode.pano;
30479 if (this.disabled || previousChanged) {
30480 if (this._previousKey in this._previousProviderDisposers) {
30481 this._previousProviderDisposers[this._previousKey]();
30482 delete this._previousProviderDisposers[this._previousKey];
30485 if (this.disabled) {
30486 this._scene.setImagePlanesOld([]);
30489 if (previousChanged || modeChanged) {
30490 var previousNode = state.previousNode;
30491 this._previousKey = previousNode.key;
30492 var elements = state.currentTransform.rt.elements;
30493 var translation = [elements[12], elements[13], elements[14]];
30494 var currentAspect = state.currentTransform.basicAspect;
30495 var previousAspect = state.previousTransform.basicAspect;
30496 var textureScale = currentAspect > previousAspect ?
30497 [1, previousAspect / currentAspect] :
30498 [currentAspect / previousAspect, 1];
30499 var rotation = state.currentNode.rotation;
30500 var width = state.currentNode.width;
30501 var height = state.currentNode.height;
30502 if (previousNode.fullPano) {
30503 rotation = state.previousNode.rotation;
30504 translation = this._spatial
30505 .rotate(this._spatial
30506 .opticalCenter(state.currentNode.rotation, translation)
30507 .toArray(), rotation)
30508 .multiplyScalar(-1)
30510 width = state.previousNode.width;
30511 height = state.previousNode.height;
30513 var transform = new Geo_1.Transform(state.currentNode.orientation, width, height, state.currentNode.focal, state.currentNode.scale, previousNode.gpano, rotation, translation, previousNode.image, textureScale);
30514 var mesh = undefined;
30515 if (previousNode.fullPano) {
30516 mesh = this._factory.createMesh(previousNode, motionless || state.currentNode.fullPano ? transform : state.previousTransform);
30520 var _a = this._getBasicCorners(currentAspect, previousAspect), _b = _a[0], basicX0 = _b[0], basicY0 = _b[1], _c = _a[1], basicX1 = _c[0], basicY1 = _c[1];
30521 mesh = this._factory.createFlatMesh(state.previousNode, transform, basicX0, basicX1, basicY0, basicY1);
30524 mesh = this._factory.createMesh(state.previousNode, state.previousTransform);
30527 this._scene.setImagePlanesOld([mesh]);
30530 if (currentChanged || modeChanged) {
30531 if (this._currentKey in this._currentProviderDisposers) {
30532 this._currentProviderDisposers[this._currentKey]();
30533 delete this._currentProviderDisposers[this._currentKey];
30535 this._currentKey = state.currentNode.key;
30536 var imagePlanes = [];
30537 if (state.currentNode.fullPano) {
30538 imagePlanes.push(this._factory.createCurtainMesh(state.currentNode, state.currentTransform));
30540 else if (state.currentNode.pano && !state.currentNode.fullPano) {
30541 imagePlanes.push(this._factory.createMesh(state.currentNode, state.currentTransform));
30545 imagePlanes.push(this._factory.createDistortedCurtainMesh(state.currentNode, state.currentTransform));
30548 imagePlanes.push(this._factory.createCurtainMesh(state.currentNode, state.currentTransform));
30551 this._scene.setImagePlanes(imagePlanes);
30552 this._updateCurtain();
30555 SliderGLRenderer.prototype._updateTexture = function (texture) {
30556 this._needsRender = true;
30557 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
30558 var plane = _a[_i];
30559 var material = plane.material;
30560 var oldTexture = material.uniforms.projectorTex.value;
30561 material.uniforms.projectorTex.value = null;
30562 oldTexture.dispose();
30563 material.uniforms.projectorTex.value = texture;
30566 SliderGLRenderer.prototype._updateTexturePrev = function (texture) {
30567 this._needsRender = true;
30568 for (var _i = 0, _a = this._scene.imagePlanesOld; _i < _a.length; _i++) {
30569 var plane = _a[_i];
30570 var material = plane.material;
30571 var oldTexture = material.uniforms.projectorTex.value;
30572 material.uniforms.projectorTex.value = null;
30573 oldTexture.dispose();
30574 material.uniforms.projectorTex.value = texture;
30577 return SliderGLRenderer;
30579 exports.SliderGLRenderer = SliderGLRenderer;
30580 exports.default = SliderGLRenderer;
30583 },{"../../Component":275,"../../Geo":278}],340:[function(require,module,exports){
30585 Object.defineProperty(exports, "__esModule", { value: true });
30586 var geohash = require("latlon-geohash");
30587 var rxjs_1 = require("rxjs");
30588 var operators_1 = require("rxjs/operators");
30589 var Error_1 = require("../../Error");
30590 var Utils_1 = require("../../Utils");
30591 var SpatialDataCache = /** @class */ (function () {
30592 function SpatialDataCache(graphService) {
30593 this._graphService = graphService;
30595 this._cacheRequests = {};
30596 this._reconstructions = {};
30597 this._cachingReconstructions$ = {};
30598 this._cachingTiles$ = {};
30600 SpatialDataCache.prototype.cacheReconstructions$ = function (hash) {
30602 if (!this.hasTile(hash)) {
30603 throw new Error("Cannot cache reconstructions of a non-existing tile.");
30605 if (this.hasReconstructions(hash)) {
30606 throw new Error("Cannot cache reconstructions that already exists.");
30608 if (this.isCachingReconstructions(hash)) {
30609 return this._cachingReconstructions$[hash];
30612 if (hash in this._reconstructions) {
30613 var reconstructionKeys = this.getReconstructions(hash)
30614 .map(function (reconstruction) {
30615 return reconstruction.data.key;
30617 for (var _i = 0, _a = this.getTile(hash); _i < _a.length; _i++) {
30619 if (reconstructionKeys.indexOf(node.key) === -1) {
30625 tile.push.apply(tile, this.getTile(hash));
30626 this._reconstructions[hash] = [];
30628 this._cacheRequests[hash] = [];
30629 this._cachingReconstructions$[hash] = rxjs_1.from(tile).pipe(operators_1.mergeMap(function (nodeData) {
30630 return !_this._cacheRequests[hash] ?
30632 rxjs_1.zip(rxjs_1.of(nodeData), _this._getAtomicReconstruction(nodeData.key, _this._cacheRequests[hash]))
30633 .pipe(operators_1.catchError(function (error) {
30634 if (error instanceof Error_1.AbortMapillaryError) {
30635 return rxjs_1.empty();
30637 console.error(error);
30638 return rxjs_1.of([nodeData, null]);
30640 }, 6), operators_1.map(function (_a) {
30641 var nodeData = _a[0], reconstruction = _a[1];
30642 return { data: nodeData, reconstruction: reconstruction };
30643 }), operators_1.filter(function () {
30644 return hash in _this._reconstructions;
30645 }), operators_1.tap(function (data) {
30646 _this._reconstructions[hash].push(data);
30647 }), operators_1.filter(function (data) {
30648 return !!data.reconstruction;
30649 }), operators_1.finalize(function () {
30650 if (hash in _this._cachingReconstructions$) {
30651 delete _this._cachingReconstructions$[hash];
30653 if (hash in _this._cacheRequests) {
30654 delete _this._cacheRequests[hash];
30656 }), operators_1.publish(), operators_1.refCount());
30657 return this._cachingReconstructions$[hash];
30659 SpatialDataCache.prototype.cacheTile$ = function (hash) {
30661 if (hash.length !== 8) {
30662 throw new Error("Hash needs to be level 8.");
30664 if (this.hasTile(hash)) {
30665 throw new Error("Cannot cache tile that already exists.");
30667 if (this.hasTile(hash)) {
30668 return this._cachingTiles$[hash];
30670 var bounds = geohash.bounds(hash);
30671 var sw = { lat: bounds.sw.lat, lon: bounds.sw.lon };
30672 var ne = { lat: bounds.ne.lat, lon: bounds.ne.lon };
30673 this._tiles[hash] = [];
30674 this._cachingTiles$[hash] = this._graphService.cacheBoundingBox$(sw, ne).pipe(operators_1.catchError(function (error) {
30675 console.error(error);
30676 delete _this._tiles[hash];
30677 return rxjs_1.empty();
30678 }), operators_1.map(function (nodes) {
30680 .map(function (n) {
30681 return _this._createNodeData(n);
30683 }), operators_1.filter(function () {
30684 return hash in _this._tiles;
30685 }), operators_1.tap(function (nodeData) {
30687 (_a = _this._tiles[hash]).push.apply(_a, nodeData);
30688 delete _this._cachingTiles$[hash];
30689 }), operators_1.finalize(function () {
30690 if (hash in _this._cachingTiles$) {
30691 delete _this._cachingTiles$[hash];
30693 }), operators_1.publish(), operators_1.refCount());
30694 return this._cachingTiles$[hash];
30696 SpatialDataCache.prototype.isCachingReconstructions = function (hash) {
30697 return hash in this._cachingReconstructions$;
30699 SpatialDataCache.prototype.isCachingTile = function (hash) {
30700 return hash in this._cachingTiles$;
30702 SpatialDataCache.prototype.hasReconstructions = function (hash) {
30703 return !(hash in this._cachingReconstructions$) &&
30704 hash in this._reconstructions &&
30705 this._reconstructions[hash].length === this._tiles[hash].length;
30707 SpatialDataCache.prototype.hasTile = function (hash) {
30708 return !(hash in this._cachingTiles$) && hash in this._tiles;
30710 SpatialDataCache.prototype.getReconstructions = function (hash) {
30711 return hash in this._reconstructions ?
30712 this._reconstructions[hash]
30713 .filter(function (data) {
30714 return !!data.reconstruction;
30718 SpatialDataCache.prototype.getTile = function (hash) {
30719 return hash in this._tiles ? this._tiles[hash] : [];
30721 SpatialDataCache.prototype.uncache = function (keepHashes) {
30722 for (var _i = 0, _a = Object.keys(this._cacheRequests); _i < _a.length; _i++) {
30724 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
30727 for (var _b = 0, _c = this._cacheRequests[hash]; _b < _c.length; _b++) {
30728 var request = _c[_b];
30731 delete this._cacheRequests[hash];
30733 for (var _d = 0, _e = Object.keys(this._reconstructions); _d < _e.length; _d++) {
30735 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
30738 delete this._reconstructions[hash];
30740 for (var _f = 0, _g = Object.keys(this._tiles); _f < _g.length; _f++) {
30742 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
30745 delete this._tiles[hash];
30748 SpatialDataCache.prototype._createNodeData = function (node) {
30753 height: node.height,
30757 lat: node.latLon.lat,
30758 lon: node.latLon.lon,
30759 mergeCC: node.mergeCC,
30760 orientation: node.orientation,
30761 originalLat: node.originalLatLon.lat,
30762 originalLon: node.originalLatLon.lon,
30763 rotation: [node.rotation[0], node.rotation[1], node.rotation[2]],
30768 SpatialDataCache.prototype._getAtomicReconstruction = function (key, requests) {
30769 return rxjs_1.Observable.create(function (subscriber) {
30770 var xmlHTTP = new XMLHttpRequest();
30771 xmlHTTP.open("GET", Utils_1.Urls.atomicReconstruction(key), true);
30772 xmlHTTP.responseType = "json";
30773 xmlHTTP.timeout = 15000;
30774 xmlHTTP.onload = function () {
30775 if (!xmlHTTP.response) {
30776 subscriber.error(new Error("Atomic reconstruction does not exist (" + key + ")"));
30779 subscriber.next(xmlHTTP.response);
30780 subscriber.complete();
30783 xmlHTTP.onerror = function () {
30784 subscriber.error(new Error("Failed to get atomic reconstruction (" + key + ")"));
30786 xmlHTTP.ontimeout = function () {
30787 subscriber.error(new Error("Atomic reconstruction request timed out (" + key + ")"));
30789 xmlHTTP.onabort = function () {
30790 subscriber.error(new Error_1.AbortMapillaryError("Atomic reconstruction request was aborted (" + key + ")"));
30792 requests.push(xmlHTTP);
30793 xmlHTTP.send(null);
30796 return SpatialDataCache;
30798 exports.SpatialDataCache = SpatialDataCache;
30799 exports.default = SpatialDataCache;
30801 },{"../../Error":277,"../../Utils":285,"latlon-geohash":21,"rxjs":27,"rxjs/operators":225}],341:[function(require,module,exports){
30803 var __extends = (this && this.__extends) || (function () {
30804 var extendStatics = function (d, b) {
30805 extendStatics = Object.setPrototypeOf ||
30806 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30807 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30808 return extendStatics(d, b);
30810 return function (d, b) {
30811 extendStatics(d, b);
30812 function __() { this.constructor = d; }
30813 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30816 Object.defineProperty(exports, "__esModule", { value: true });
30817 var geohash = require("latlon-geohash");
30818 var rxjs_1 = require("rxjs");
30819 var operators_1 = require("rxjs/operators");
30820 var Component_1 = require("../../Component");
30821 var Geo_1 = require("../../Geo");
30822 var Render_1 = require("../../Render");
30823 var PlayService_1 = require("../../viewer/PlayService");
30824 var State_1 = require("../../state/State");
30825 var SpatialDataComponent = /** @class */ (function (_super) {
30826 __extends(SpatialDataComponent, _super);
30827 function SpatialDataComponent(name, container, navigator) {
30828 var _this = _super.call(this, name, container, navigator) || this;
30829 _this._cache = new Component_1.SpatialDataCache(navigator.graphService);
30830 _this._scene = new Component_1.SpatialDataScene(_this._getDefaultConfiguration());
30831 _this._viewportCoords = new Geo_1.ViewportCoords();
30832 _this._geoCoords = new Geo_1.GeoCoords();
30835 SpatialDataComponent.prototype._activate = function () {
30837 this._earthControlsSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30838 return configuration.earthControls;
30839 }), operators_1.distinctUntilChanged(), operators_1.withLatestFrom(this._navigator.stateService.state$))
30840 .subscribe(function (_a) {
30841 var earth = _a[0], state = _a[1];
30842 if (earth && state !== State_1.default.Earth) {
30843 _this._navigator.stateService.earth();
30845 else if (!earth && state === State_1.default.Earth) {
30846 _this._navigator.stateService.traverse();
30849 var direction$ = this._container.renderService.bearing$.pipe(operators_1.map(function (bearing) {
30850 var direction = "";
30851 if (bearing > 292.5 || bearing <= 67.5) {
30854 if (bearing > 112.5 && bearing <= 247.5) {
30857 if (bearing > 22.5 && bearing <= 157.5) {
30860 if (bearing > 202.5 && bearing <= 337.5) {
30864 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
30865 var hash$ = this._navigator.stateService.reference$.pipe(operators_1.tap(function () {
30866 _this._scene.uncache();
30867 }), operators_1.switchMap(function () {
30868 return _this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
30869 return geohash.encode(node.latLon.lat, node.latLon.lon, 8);
30870 }), operators_1.distinctUntilChanged());
30871 }), operators_1.publishReplay(1), operators_1.refCount());
30872 var sequencePlay$ = rxjs_1.combineLatest(this._navigator.playService.playing$, this._navigator.playService.speed$).pipe(operators_1.map(function (_a) {
30873 var playing = _a[0], speed = _a[1];
30874 return playing && speed > PlayService_1.default.sequenceSpeed;
30875 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
30876 this._addSubscription = rxjs_1.combineLatest(this._navigator.stateService.state$.pipe(operators_1.map(function (state) {
30877 return state === State_1.default.Earth;
30878 }), operators_1.distinctUntilChanged()), hash$, sequencePlay$, direction$).pipe(operators_1.distinctUntilChanged(function (_a, _b) {
30879 var e1 = _a[0], h1 = _a[1], s1 = _a[2], d1 = _a[3];
30880 var e2 = _b[0], h2 = _b[1], s2 = _b[2], d2 = _b[3];
30885 return h1 === h2 && s1 === s2;
30887 return h1 === h2 && s1 === s2 && d1 === d2;
30888 }), operators_1.concatMap(function (_a) {
30889 var earth = _a[0], hash = _a[1], sequencePlay = _a[2], direction = _a[3];
30891 return sequencePlay ?
30892 rxjs_1.of([hash]) :
30893 rxjs_1.of(_this._adjacentComponent(hash, 4));
30895 return sequencePlay ?
30896 rxjs_1.of([hash, geohash.neighbours(hash)[direction]]) :
30897 rxjs_1.of(_this._computeTiles(hash, direction));
30898 }), operators_1.switchMap(function (hashes) {
30899 return rxjs_1.from(hashes).pipe(operators_1.mergeMap(function (h) {
30901 if (_this._cache.hasTile(h)) {
30902 tile$ = rxjs_1.of(_this._cache.getTile(h));
30904 else if (_this._cache.isCachingTile(h)) {
30905 tile$ = _this._cache.cacheTile$(h).pipe(operators_1.last(null, {}), operators_1.switchMap(function () {
30906 return rxjs_1.of(_this._cache.getTile(h));
30910 tile$ = _this._cache.cacheTile$(h);
30912 return rxjs_1.combineLatest(rxjs_1.of(h), tile$);
30913 }, 1), operators_1.map(function (_a) {
30917 }), operators_1.concatMap(function (hash) {
30918 var reconstructions$;
30919 if (_this._cache.hasReconstructions(hash)) {
30920 reconstructions$ = rxjs_1.from(_this._cache.getReconstructions(hash));
30922 else if (_this._cache.isCachingReconstructions(hash)) {
30923 reconstructions$ = _this._cache.cacheReconstructions$(hash).pipe(operators_1.last(null, {}), operators_1.switchMap(function () {
30924 return rxjs_1.from(_this._cache.getReconstructions(hash));
30927 else if (_this._cache.hasTile(hash)) {
30928 reconstructions$ = _this._cache.cacheReconstructions$(hash);
30931 reconstructions$ = rxjs_1.empty();
30933 return rxjs_1.combineLatest(rxjs_1.of(hash), reconstructions$);
30934 }), operators_1.withLatestFrom(this._navigator.stateService.reference$), operators_1.tap(function (_a) {
30935 var hash = _a[0][0], reference = _a[1];
30936 if (_this._scene.hasTile(hash)) {
30939 _this._scene.addTile(_this._computeTileBBox(hash, reference), hash);
30940 }), operators_1.filter(function (_a) {
30941 var _b = _a[0], hash = _b[0], data = _b[1];
30942 return !_this._scene.hasReconstruction(data.reconstruction.main_shot, hash);
30943 }), operators_1.map(function (_a) {
30944 var _b = _a[0], hash = _b[0], data = _b[1], reference = _a[1];
30947 _this._createTransform(data.data, reference),
30948 _this._computeOriginalPosition(data.data, reference),
30952 .subscribe(function (_a) {
30953 var data = _a[0], transform = _a[1], position = _a[2], hash = _a[3];
30954 _this._scene.addReconstruction(data.reconstruction, transform, position, !!data.data.mergeCC ? data.data.mergeCC.toString() : "", hash);
30956 this._cameraVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30957 return configuration.camerasVisible;
30958 }), operators_1.distinctUntilChanged())
30959 .subscribe(function (visible) {
30960 _this._scene.setCameraVisibility(visible);
30962 this._pointVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30963 return configuration.pointsVisible;
30964 }), operators_1.distinctUntilChanged())
30965 .subscribe(function (visible) {
30966 _this._scene.setPointVisibility(visible);
30968 this._positionVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30969 return configuration.positionsVisible;
30970 }), operators_1.distinctUntilChanged())
30971 .subscribe(function (visible) {
30972 _this._scene.setPositionVisibility(visible);
30974 this._tileVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30975 return configuration.tilesVisible;
30976 }), operators_1.distinctUntilChanged())
30977 .subscribe(function (visible) {
30978 _this._scene.setTileVisibility(visible);
30980 this._visualizeConnectedComponentSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30981 return configuration.connectedComponents;
30982 }), operators_1.distinctUntilChanged())
30983 .subscribe(function (visualize) {
30984 _this._scene.setConnectedComponentVisualization(visualize);
30986 this._uncacheSubscription = hash$
30987 .subscribe(function (hash) {
30988 var keepHashes = _this._adjacentComponent(hash, 4);
30989 _this._scene.uncache(keepHashes);
30990 _this._cache.uncache(keepHashes);
30992 this._moveSubscription = this._navigator.playService.playing$.pipe(operators_1.switchMap(function (playing) {
30995 _this._container.mouseService.dblClick$;
30996 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$), operators_1.switchMap(function (_a) {
30997 var event = _a[0], render = _a[1];
30998 var element = _this._container.element;
30999 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
31000 var viewport = _this._viewportCoords.canvasToViewport(canvasX, canvasY, element);
31001 var key = _this._scene.intersectObjects(viewport, render.perspective);
31003 _this._navigator.moveToKey$(key).pipe(operators_1.catchError(function () {
31004 return rxjs_1.empty();
31009 this._renderSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
31010 var scene = _this._scene;
31015 needsRender: scene.needsRender,
31016 render: scene.render.bind(scene),
31017 stage: Render_1.GLRenderStage.Foreground,
31021 .subscribe(this._container.glRenderer.render$);
31023 SpatialDataComponent.prototype._deactivate = function () {
31025 this._cache.uncache();
31026 this._scene.uncache();
31027 this._addSubscription.unsubscribe();
31028 this._cameraVisibilitySubscription.unsubscribe();
31029 this._earthControlsSubscription.unsubscribe();
31030 this._moveSubscription.unsubscribe();
31031 this._pointVisibilitySubscription.unsubscribe();
31032 this._positionVisibilitySubscription.unsubscribe();
31033 this._renderSubscription.unsubscribe();
31034 this._tileVisibilitySubscription.unsubscribe();
31035 this._uncacheSubscription.unsubscribe();
31036 this._visualizeConnectedComponentSubscription.unsubscribe();
31037 this._navigator.stateService.state$.pipe(operators_1.first())
31038 .subscribe(function (state) {
31039 if (state === State_1.default.Earth) {
31040 _this._navigator.stateService.traverse();
31044 SpatialDataComponent.prototype._getDefaultConfiguration = function () {
31045 return { camerasVisible: false, pointsVisible: true, positionsVisible: false, tilesVisible: false };
31047 SpatialDataComponent.prototype._adjacentComponent = function (hash, depth) {
31048 var hashSet = new Set();
31050 this._adjacentComponentRecursive(hashSet, [hash], 0, depth);
31051 return this._setToArray(hashSet);
31053 SpatialDataComponent.prototype._adjacentComponentRecursive = function (hashSet, currentHashes, currentDepth, maxDepth) {
31054 if (currentDepth === maxDepth) {
31057 var neighbours = [];
31058 for (var _i = 0, currentHashes_1 = currentHashes; _i < currentHashes_1.length; _i++) {
31059 var hash = currentHashes_1[_i];
31060 var hashNeighbours = geohash.neighbours(hash);
31061 for (var direction in hashNeighbours) {
31062 if (!hashNeighbours.hasOwnProperty(direction)) {
31065 neighbours.push(hashNeighbours[direction]);
31068 var newHashes = [];
31069 for (var _a = 0, neighbours_1 = neighbours; _a < neighbours_1.length; _a++) {
31070 var neighbour = neighbours_1[_a];
31071 if (!hashSet.has(neighbour)) {
31072 hashSet.add(neighbour);
31073 newHashes.push(neighbour);
31076 this._adjacentComponentRecursive(hashSet, newHashes, currentDepth + 1, maxDepth);
31078 SpatialDataComponent.prototype._computeOriginalPosition = function (data, reference) {
31079 return this._geoCoords.geodeticToEnu(data.originalLat, data.originalLon, data.alt, reference.lat, reference.lon, reference.alt);
31081 SpatialDataComponent.prototype._computeTileBBox = function (hash, reference) {
31082 var bounds = geohash.bounds(hash);
31083 var sw = this._geoCoords.geodeticToEnu(bounds.sw.lat, bounds.sw.lon, 0, reference.lat, reference.lon, reference.alt);
31084 var ne = this._geoCoords.geodeticToEnu(bounds.ne.lat, bounds.ne.lon, 0, reference.lat, reference.lon, reference.alt);
31087 SpatialDataComponent.prototype._createTransform = function (data, reference) {
31088 var translation = Geo_1.Geo.computeTranslation({ alt: data.alt, lat: data.lat, lon: data.lon }, data.rotation, reference);
31089 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);
31092 SpatialDataComponent.prototype._computeTiles = function (hash, direction) {
31093 var hashSet = new Set();
31094 var directions = ["n", "ne", "e", "se", "s", "sw", "w", "nw"];
31095 this._computeTilesRecursive(hashSet, hash, direction, directions, 0, 2);
31096 return this._setToArray(hashSet);
31098 SpatialDataComponent.prototype._computeTilesRecursive = function (hashSet, currentHash, direction, directions, currentDepth, maxDepth) {
31099 hashSet.add(currentHash);
31100 if (currentDepth === maxDepth) {
31103 var neighbours = geohash.neighbours(currentHash);
31104 var directionIndex = directions.indexOf(direction);
31105 var length = directions.length;
31106 var directionNeighbours = [
31107 neighbours[directions[this._modulo((directionIndex - 1), length)]],
31108 neighbours[direction],
31109 neighbours[directions[this._modulo((directionIndex + 1), length)]],
31111 for (var _i = 0, directionNeighbours_1 = directionNeighbours; _i < directionNeighbours_1.length; _i++) {
31112 var directionNeighbour = directionNeighbours_1[_i];
31113 this._computeTilesRecursive(hashSet, directionNeighbour, direction, directions, currentDepth + 1, maxDepth);
31116 SpatialDataComponent.prototype._modulo = function (a, n) {
31117 return ((a % n) + n) % n;
31119 SpatialDataComponent.prototype._setToArray = function (s) {
31121 s.forEach(function (value) {
31126 SpatialDataComponent.componentName = "spatialData";
31127 return SpatialDataComponent;
31128 }(Component_1.Component));
31129 exports.SpatialDataComponent = SpatialDataComponent;
31130 Component_1.ComponentService.register(SpatialDataComponent);
31131 exports.default = SpatialDataComponent;
31133 },{"../../Component":275,"../../Geo":278,"../../Render":281,"../../state/State":412,"../../viewer/PlayService":441,"latlon-geohash":21,"rxjs":27,"rxjs/operators":225}],342:[function(require,module,exports){
31135 Object.defineProperty(exports, "__esModule", { value: true });
31136 var THREE = require("three");
31137 var SpatialDataScene = /** @class */ (function () {
31138 function SpatialDataScene(configuration, scene, raycaster) {
31139 this._scene = !!scene ? scene : new THREE.Scene();
31140 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster(undefined, undefined, 0.8);
31141 this._connectedComponentColors = {};
31142 this._needsRender = false;
31143 this._interactiveObjects = [];
31144 this._reconstructions = {};
31146 this._camerasVisible = configuration.camerasVisible;
31147 this._pointsVisible = configuration.pointsVisible;
31148 this._positionsVisible = configuration.positionsVisible;
31149 this._tilesVisible = configuration.tilesVisible;
31150 this._visualizeConnectedComponents = configuration.connectedComponents;
31152 Object.defineProperty(SpatialDataScene.prototype, "needsRender", {
31154 return this._needsRender;
31159 SpatialDataScene.prototype.addReconstruction = function (reconstruction, transform, originalPosition, connectedComponent, hash) {
31160 if (!(hash in this._reconstructions)) {
31161 this._reconstructions[hash] = {
31163 cameras: new THREE.Object3D(),
31164 connectedComponents: {},
31166 points: new THREE.Object3D(),
31167 positions: new THREE.Object3D(),
31169 this._reconstructions[hash].cameras.visible = this._camerasVisible;
31170 this._reconstructions[hash].points.visible = this._pointsVisible;
31171 this._reconstructions[hash].positions.visible = this._positionsVisible;
31172 this._scene.add(this._reconstructions[hash].cameras, this._reconstructions[hash].points, this._reconstructions[hash].positions);
31174 if (!(connectedComponent in this._reconstructions[hash].connectedComponents)) {
31175 this._reconstructions[hash].connectedComponents[connectedComponent] = [];
31177 if (transform.hasValidScale) {
31178 this._reconstructions[hash].points.add(this._createPoints(reconstruction, transform));
31180 var camera = this._createCamera(transform);
31181 this._reconstructions[hash].cameras.add(camera);
31182 for (var _i = 0, _a = camera.children; _i < _a.length; _i++) {
31183 var child = _a[_i];
31184 this._reconstructions[hash].cameraKeys[child.uuid] = reconstruction.main_shot;
31185 this._interactiveObjects.push(child);
31187 this._reconstructions[hash].connectedComponents[connectedComponent].push(camera);
31188 var color = this._getColor(connectedComponent, this._visualizeConnectedComponents);
31189 this._setCameraColor(color, camera);
31190 this._reconstructions[hash].positions.add(this._createPosition(transform, originalPosition));
31191 this._reconstructions[hash].keys.push(reconstruction.main_shot);
31192 this._needsRender = true;
31194 SpatialDataScene.prototype.addTile = function (tileBBox, hash) {
31195 if (this.hasTile(hash)) {
31198 var sw = tileBBox[0];
31199 var ne = tileBBox[1];
31200 var geometry = new THREE.Geometry();
31201 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));
31202 var tile = new THREE.Line(geometry, new THREE.LineBasicMaterial());
31203 this._tiles[hash] = new THREE.Object3D();
31204 this._tiles[hash].visible = this._tilesVisible;
31205 this._tiles[hash].add(tile);
31206 this._scene.add(this._tiles[hash]);
31207 this._needsRender = true;
31209 SpatialDataScene.prototype.uncache = function (keepHashes) {
31210 for (var _i = 0, _a = Object.keys(this._reconstructions); _i < _a.length; _i++) {
31212 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
31215 this._disposeReconstruction(hash);
31217 for (var _b = 0, _c = Object.keys(this._tiles); _b < _c.length; _b++) {
31219 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
31222 this._disposeTile(hash);
31224 this._needsRender = true;
31226 SpatialDataScene.prototype.hasReconstruction = function (key, hash) {
31227 return hash in this._reconstructions && this._reconstructions[hash].keys.indexOf(key) !== -1;
31229 SpatialDataScene.prototype.hasTile = function (hash) {
31230 return hash in this._tiles;
31232 SpatialDataScene.prototype.intersectObjects = function (_a, camera) {
31233 var viewportX = _a[0], viewportY = _a[1];
31234 if (!this._camerasVisible) {
31237 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
31238 var intersects = this._raycaster.intersectObjects(this._interactiveObjects);
31239 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
31240 var intersect = intersects_1[_i];
31241 for (var hash in this._reconstructions) {
31242 if (!this._reconstructions.hasOwnProperty(hash)) {
31245 if (intersect.object.uuid in this._reconstructions[hash].cameraKeys) {
31246 return this._reconstructions[hash].cameraKeys[intersect.object.uuid];
31252 SpatialDataScene.prototype.setCameraVisibility = function (visible) {
31253 if (visible === this._camerasVisible) {
31256 for (var hash in this._reconstructions) {
31257 if (!this._reconstructions.hasOwnProperty(hash)) {
31260 this._reconstructions[hash].cameras.visible = visible;
31262 this._camerasVisible = visible;
31263 this._needsRender = true;
31265 SpatialDataScene.prototype.setPointVisibility = function (visible) {
31266 if (visible === this._pointsVisible) {
31269 for (var hash in this._reconstructions) {
31270 if (!this._reconstructions.hasOwnProperty(hash)) {
31273 this._reconstructions[hash].points.visible = visible;
31275 this._pointsVisible = visible;
31276 this._needsRender = true;
31278 SpatialDataScene.prototype.setPositionVisibility = function (visible) {
31279 if (visible === this._positionsVisible) {
31282 for (var hash in this._reconstructions) {
31283 if (!this._reconstructions.hasOwnProperty(hash)) {
31286 this._reconstructions[hash].positions.visible = visible;
31288 this._positionsVisible = visible;
31289 this._needsRender = true;
31291 SpatialDataScene.prototype.setTileVisibility = function (visible) {
31292 if (visible === this._tilesVisible) {
31295 for (var hash in this._tiles) {
31296 if (!this._tiles.hasOwnProperty(hash)) {
31299 this._tiles[hash].visible = visible;
31301 this._tilesVisible = visible;
31302 this._needsRender = true;
31304 SpatialDataScene.prototype.setConnectedComponentVisualization = function (visualize) {
31305 if (visualize === this._visualizeConnectedComponents) {
31308 for (var hash in this._reconstructions) {
31309 if (!this._reconstructions.hasOwnProperty(hash)) {
31312 var connectedComponents = this._reconstructions[hash].connectedComponents;
31313 for (var connectedComponent in connectedComponents) {
31314 if (!connectedComponents.hasOwnProperty(connectedComponent)) {
31317 var color = this._getColor(connectedComponent, visualize);
31318 for (var _i = 0, _a = connectedComponents[connectedComponent]; _i < _a.length; _i++) {
31319 var camera = _a[_i];
31320 this._setCameraColor(color, camera);
31324 this._visualizeConnectedComponents = visualize;
31325 this._needsRender = true;
31327 SpatialDataScene.prototype.render = function (perspectiveCamera, renderer) {
31328 renderer.render(this._scene, perspectiveCamera);
31329 this._needsRender = false;
31331 SpatialDataScene.prototype._arrayToFloatArray = function (a, columns) {
31333 var f = new Float32Array(n * columns);
31334 for (var i = 0; i < n; i++) {
31337 f[index + 0] = item[0];
31338 f[index + 1] = item[1];
31339 f[index + 2] = item[2];
31343 SpatialDataScene.prototype._createAxis = function (transform) {
31344 var north = transform.unprojectBasic([0.5, 0], 0.22);
31345 var south = transform.unprojectBasic([0.5, 1], 0.16);
31346 var axis = new THREE.BufferGeometry();
31347 axis.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray([north, south], 3), 3));
31348 return new THREE.Line(axis, new THREE.LineBasicMaterial());
31350 SpatialDataScene.prototype._createCamera = function (transform) {
31351 return !!transform.gpano ?
31352 this._createPanoCamera(transform) :
31353 this._createPrespectiveCamera(transform);
31355 SpatialDataScene.prototype._createDiagonals = function (transform, depth) {
31356 var origin = transform.unprojectBasic([0, 0], 0, true);
31357 var topLeft = transform.unprojectBasic([0, 0], depth, true);
31358 var topRight = transform.unprojectBasic([1, 0], depth, true);
31359 var bottomRight = transform.unprojectBasic([1, 1], depth, true);
31360 var bottomLeft = transform.unprojectBasic([0, 1], depth, true);
31364 origin, bottomRight,
31365 origin, bottomLeft,
31367 var diagonals = new THREE.BufferGeometry();
31368 diagonals.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices, 3), 3));
31369 return new THREE.LineSegments(diagonals, new THREE.LineBasicMaterial());
31371 SpatialDataScene.prototype._createFrame = function (transform, depth) {
31372 var vertices2d = [];
31373 vertices2d.push.apply(vertices2d, this._subsample([0, 1], [0, 0], 20));
31374 vertices2d.push.apply(vertices2d, this._subsample([0, 0], [1, 0], 20));
31375 vertices2d.push.apply(vertices2d, this._subsample([1, 0], [1, 1], 20));
31376 var vertices3d = vertices2d
31377 .map(function (basic) {
31378 return transform.unprojectBasic(basic, depth, true);
31380 var frame = new THREE.BufferGeometry();
31381 frame.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices3d, 3), 3));
31382 return new THREE.Line(frame, new THREE.LineBasicMaterial());
31384 SpatialDataScene.prototype._createLatitude = function (basicY, numVertices, transform) {
31385 var positions = new Float32Array((numVertices + 1) * 3);
31386 for (var i = 0; i <= numVertices; i++) {
31387 var position = transform.unprojectBasic([i / numVertices, basicY], 0.16);
31389 positions[index + 0] = position[0];
31390 positions[index + 1] = position[1];
31391 positions[index + 2] = position[2];
31393 var latitude = new THREE.BufferGeometry();
31394 latitude.addAttribute("position", new THREE.BufferAttribute(positions, 3));
31395 return new THREE.Line(latitude, new THREE.LineBasicMaterial());
31397 SpatialDataScene.prototype._createLongitude = function (basicX, numVertices, transform) {
31398 var positions = new Float32Array((numVertices + 1) * 3);
31399 for (var i = 0; i <= numVertices; i++) {
31400 var position = transform.unprojectBasic([basicX, i / numVertices], 0.16);
31402 positions[index + 0] = position[0];
31403 positions[index + 1] = position[1];
31404 positions[index + 2] = position[2];
31406 var latitude = new THREE.BufferGeometry();
31407 latitude.addAttribute("position", new THREE.BufferAttribute(positions, 3));
31408 return new THREE.Line(latitude, new THREE.LineBasicMaterial());
31410 SpatialDataScene.prototype._createPanoCamera = function (transform) {
31411 var camera = new THREE.Object3D();
31412 camera.children.push(this._createAxis(transform));
31413 camera.children.push(this._createLatitude(0.5, 10, transform));
31414 camera.children.push(this._createLongitude(0, 6, transform));
31415 camera.children.push(this._createLongitude(0.25, 6, transform));
31416 camera.children.push(this._createLongitude(0.5, 6, transform));
31417 camera.children.push(this._createLongitude(0.75, 6, transform));
31420 SpatialDataScene.prototype._createPoints = function (reconstruction, transform) {
31421 var srtInverse = new THREE.Matrix4().getInverse(transform.srt);
31422 var points = Object
31423 .keys(reconstruction.points)
31424 .map(function (key) {
31425 return reconstruction.points[key];
31427 var numPoints = points.length;
31428 var positions = new Float32Array(numPoints * 3);
31429 var colors = new Float32Array(numPoints * 3);
31430 for (var i = 0; i < numPoints; i++) {
31432 var coords = points[i].coordinates;
31433 var point = new THREE.Vector3(coords[0], coords[1], coords[2])
31434 .applyMatrix4(srtInverse);
31435 positions[index + 0] = point.x;
31436 positions[index + 1] = point.y;
31437 positions[index + 2] = point.z;
31438 var color = points[i].color;
31439 colors[index + 0] = color[0] / 255.0;
31440 colors[index + 1] = color[1] / 255.0;
31441 colors[index + 2] = color[2] / 255.0;
31443 var geometry = new THREE.BufferGeometry();
31444 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
31445 geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3));
31446 var material = new THREE.PointsMaterial({
31448 vertexColors: THREE.VertexColors,
31450 return new THREE.Points(geometry, material);
31452 SpatialDataScene.prototype._createPosition = function (transform, originalPosition) {
31453 var computedPosition = transform.unprojectBasic([0, 0], 0);
31454 var vertices = [originalPosition, computedPosition];
31455 var geometry = new THREE.BufferGeometry();
31456 geometry.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices, 3), 3));
31457 return new THREE.Line(geometry, new THREE.LineBasicMaterial({ color: new THREE.Color(1, 0, 0) }));
31459 SpatialDataScene.prototype._createPrespectiveCamera = function (transform) {
31461 var camera = new THREE.Object3D();
31462 camera.children.push(this._createDiagonals(transform, depth));
31463 camera.children.push(this._createFrame(transform, depth));
31466 SpatialDataScene.prototype._disposeCameras = function (hash) {
31467 var tileCameras = this._reconstructions[hash].cameras;
31468 for (var _i = 0, _a = tileCameras.children.slice(); _i < _a.length; _i++) {
31469 var camera = _a[_i];
31470 for (var _b = 0, _c = camera.children; _b < _c.length; _b++) {
31471 var child = _c[_b];
31472 child.geometry.dispose();
31473 child.material.dispose();
31474 var index = this._interactiveObjects.indexOf(child);
31475 if (index !== -1) {
31476 this._interactiveObjects.splice(index, 1);
31479 console.warn("Object does not exist (" + child.id + ") for " + hash);
31482 tileCameras.remove(camera);
31484 this._scene.remove(tileCameras);
31486 SpatialDataScene.prototype._disposePoints = function (hash) {
31487 var tilePoints = this._reconstructions[hash].points;
31488 for (var _i = 0, _a = tilePoints.children.slice(); _i < _a.length; _i++) {
31489 var points = _a[_i];
31490 points.geometry.dispose();
31491 points.material.dispose();
31492 tilePoints.remove(points);
31494 this._scene.remove(tilePoints);
31496 SpatialDataScene.prototype._disposePositions = function (hash) {
31497 var tilePositions = this._reconstructions[hash].positions;
31498 for (var _i = 0, _a = tilePositions.children.slice(); _i < _a.length; _i++) {
31499 var position = _a[_i];
31500 position.geometry.dispose();
31501 position.material.dispose();
31502 tilePositions.remove(position);
31504 this._scene.remove(tilePositions);
31506 SpatialDataScene.prototype._disposeReconstruction = function (hash) {
31507 this._disposeCameras(hash);
31508 this._disposePoints(hash);
31509 this._disposePositions(hash);
31510 delete this._reconstructions[hash];
31512 SpatialDataScene.prototype._disposeTile = function (hash) {
31513 var tile = this._tiles[hash];
31514 for (var _i = 0, _a = tile.children.slice(); _i < _a.length; _i++) {
31516 line.geometry.dispose();
31517 line.material.dispose();
31520 this._scene.remove(tile);
31521 delete this._tiles[hash];
31523 SpatialDataScene.prototype._getColor = function (connectedComponent, visualizeConnectedComponents) {
31524 return visualizeConnectedComponents ?
31525 this._getConnectedComponentColor(connectedComponent) :
31528 SpatialDataScene.prototype._getConnectedComponentColor = function (connectedComponent) {
31529 if (!(connectedComponent in this._connectedComponentColors)) {
31530 this._connectedComponentColors[connectedComponent] = this._randomColor();
31532 return this._connectedComponentColors[connectedComponent];
31534 SpatialDataScene.prototype._interpolate = function (a, b, alpha) {
31535 return a + alpha * (b - a);
31537 SpatialDataScene.prototype._randomColor = function () {
31538 return "hsl(" + Math.floor(360 * Math.random()) + ", 100%, 65%)";
31540 SpatialDataScene.prototype._setCameraColor = function (color, camera) {
31541 for (var _i = 0, _a = camera.children; _i < _a.length; _i++) {
31542 var child = _a[_i];
31543 child.material.color = new THREE.Color(color);
31546 SpatialDataScene.prototype._subsample = function (p1, p2, subsamples) {
31547 if (subsamples < 1) {
31551 for (var i = 0; i <= subsamples + 1; i++) {
31553 for (var j = 0; j < 3; j++) {
31554 p.push(this._interpolate(p1[j], p2[j], i / (subsamples + 1)));
31560 return SpatialDataScene;
31562 exports.SpatialDataScene = SpatialDataScene;
31563 exports.default = SpatialDataScene;
31565 },{"three":226}],343:[function(require,module,exports){
31567 Object.defineProperty(exports, "__esModule", { value: true });
31568 var GeometryTagError_1 = require("./error/GeometryTagError");
31569 exports.GeometryTagError = GeometryTagError_1.GeometryTagError;
31570 var PointGeometry_1 = require("./geometry/PointGeometry");
31571 exports.PointGeometry = PointGeometry_1.PointGeometry;
31572 var RectGeometry_1 = require("./geometry/RectGeometry");
31573 exports.RectGeometry = RectGeometry_1.RectGeometry;
31574 var PolygonGeometry_1 = require("./geometry/PolygonGeometry");
31575 exports.PolygonGeometry = PolygonGeometry_1.PolygonGeometry;
31576 var OutlineTag_1 = require("./tag/OutlineTag");
31577 exports.OutlineTag = OutlineTag_1.OutlineTag;
31578 var SpotTag_1 = require("./tag/SpotTag");
31579 exports.SpotTag = SpotTag_1.SpotTag;
31580 var TagDomain_1 = require("./tag/TagDomain");
31581 exports.TagDomain = TagDomain_1.TagDomain;
31582 var TagComponent_1 = require("./TagComponent");
31583 exports.TagComponent = TagComponent_1.TagComponent;
31584 var TagMode_1 = require("./TagMode");
31585 exports.TagMode = TagMode_1.TagMode;
31587 },{"./TagComponent":344,"./TagMode":347,"./error/GeometryTagError":351,"./geometry/PointGeometry":353,"./geometry/PolygonGeometry":354,"./geometry/RectGeometry":355,"./tag/OutlineTag":367,"./tag/SpotTag":370,"./tag/TagDomain":372}],344:[function(require,module,exports){
31589 var __extends = (this && this.__extends) || (function () {
31590 var extendStatics = function (d, b) {
31591 extendStatics = Object.setPrototypeOf ||
31592 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31593 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
31594 return extendStatics(d, b);
31596 return function (d, b) {
31597 extendStatics(d, b);
31598 function __() { this.constructor = d; }
31599 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31602 Object.defineProperty(exports, "__esModule", { value: true });
31603 var rxjs_1 = require("rxjs");
31604 var operators_1 = require("rxjs/operators");
31605 var when = require("when");
31606 var Component_1 = require("../../Component");
31607 var Geo_1 = require("../../Geo");
31608 var Render_1 = require("../../Render");
31610 * @class TagComponent
31612 * @classdesc Component for showing and editing tags with different
31613 * geometries composed from 2D basic image coordinates (see the
31614 * {@link Viewer} class documentation for more information about coordinate
31617 * The `add` method is used for adding new tags or replacing
31618 * tags already in the set. Tags are removed by id.
31620 * If a tag already in the set has the same
31621 * id as one of the tags added, the old tag will be removed and
31622 * the added tag will take its place.
31624 * The tag component mode can be set to either be non interactive or
31625 * to be in creating mode of a certain geometry type.
31627 * The tag properties can be updated at any time and the change will
31628 * be visibile immediately.
31630 * Tags are only relevant to a single image because they are based on
31631 * 2D basic image coordinates. Tags related to a certain image should
31632 * be removed when the viewer is moved to another node.
31634 * To retrive and use the tag component
31638 * var viewer = new Mapillary.Viewer(
31642 * { component: { tag: true } });
31644 * var tagComponent = viewer.getComponent("tag");
31647 var TagComponent = /** @class */ (function (_super) {
31648 __extends(TagComponent, _super);
31650 function TagComponent(name, container, navigator) {
31651 var _this = _super.call(this, name, container, navigator) || this;
31652 _this._tagDomRenderer = new Component_1.TagDOMRenderer();
31653 _this._tagScene = new Component_1.TagScene();
31654 _this._tagSet = new Component_1.TagSet();
31655 _this._tagCreator = new Component_1.TagCreator(_this, navigator);
31656 _this._viewportCoords = new Geo_1.ViewportCoords();
31657 _this._createHandlers = {
31658 "CreatePoint": new Component_1.CreatePointHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
31659 "CreatePolygon": new Component_1.CreatePolygonHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
31660 "CreateRect": new Component_1.CreateRectHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
31661 "CreateRectDrag": new Component_1.CreateRectDragHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
31662 "Default": undefined,
31664 _this._editVertexHandler = new Component_1.EditVertexHandler(_this, container, navigator, _this._viewportCoords, _this._tagSet);
31665 _this._renderTags$ = _this._tagSet.changed$.pipe(operators_1.map(function (tagSet) {
31666 var tags = tagSet.getAll();
31667 // ensure that tags are always rendered in the same order
31668 // to avoid hover tracking problems on first resize.
31669 tags.sort(function (t1, t2) {
31670 var id1 = t1.tag.id;
31671 var id2 = t2.tag.id;
31681 }), operators_1.share());
31682 _this._tagChanged$ = _this._renderTags$.pipe(operators_1.switchMap(function (tags) {
31683 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
31684 return rxjs_1.merge(tag.tag.changed$, tag.tag.geometryChanged$);
31686 }), operators_1.share());
31687 _this._renderTagGLChanged$ = _this._renderTags$.pipe(operators_1.switchMap(function (tags) {
31688 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
31689 return tag.glObjectsChanged$;
31691 }), operators_1.share());
31692 _this._createGeometryChanged$ = _this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
31693 return tag != null ?
31694 tag.geometryChanged$ :
31696 }), operators_1.share());
31697 _this._createGLObjectsChanged$ = _this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
31698 return tag != null ?
31699 tag.glObjectsChanged$ :
31701 }), operators_1.share());
31702 _this._creatingConfiguration$ = _this._configuration$.pipe(operators_1.distinctUntilChanged(function (c1, c2) {
31703 return c1.mode === c2.mode;
31704 }, function (configuration) {
31706 createColor: configuration.createColor,
31707 mode: configuration.mode,
31709 }), operators_1.publishReplay(1), operators_1.refCount());
31710 _this._creatingConfiguration$
31711 .subscribe(function (configuration) {
31712 _this.fire(TagComponent.modechanged, configuration.mode);
31717 * Add tags to the tag set or replace tags in the tag set.
31719 * @description If a tag already in the set has the same
31720 * id as one of the tags added, the old tag will be removed
31721 * the added tag will take its place.
31723 * @param {Array<Tag>} tags - Tags to add.
31725 * @example ```tagComponent.add([tag1, tag2]);```
31727 TagComponent.prototype.add = function (tags) {
31729 if (this._activated) {
31730 this._navigator.stateService.currentTransform$.pipe(operators_1.first())
31731 .subscribe(function (transform) {
31732 _this._tagSet.add(tags, transform);
31733 var renderTags = tags
31734 .map(function (tag) {
31735 return _this._tagSet.get(tag.id);
31737 _this._tagScene.add(renderTags);
31741 this._tagSet.addDeactivated(tags);
31745 * Change the current tag mode.
31747 * @description Change the tag mode to one of the create modes for creating new geometries.
31749 * @param {TagMode} mode - New tag mode.
31751 * @fires TagComponent#modechanged
31753 * @example ```tagComponent.changeMode(Mapillary.TagComponent.TagMode.CreateRect);```
31755 TagComponent.prototype.changeMode = function (mode) {
31756 this.configure({ mode: mode });
31759 * Returns the tag in the tag set with the specified id, or
31760 * undefined if the id matches no tag.
31762 * @param {string} tagId - Id of the tag.
31764 * @example ```var tag = tagComponent.get("tagId");```
31766 TagComponent.prototype.get = function (tagId) {
31767 if (this._activated) {
31768 var renderTag = this._tagSet.get(tagId);
31769 return renderTag !== undefined ? renderTag.tag : undefined;
31772 return this._tagSet.getDeactivated(tagId);
31776 * Returns an array of all tags.
31778 * @example ```var tags = tagComponent.getAll();```
31780 TagComponent.prototype.getAll = function () {
31781 if (this.activated) {
31782 return this._tagSet
31784 .map(function (renderTag) {
31785 return renderTag.tag;
31789 return this._tagSet.getAllDeactivated();
31793 * Returns an array of tag ids for tags that contain the specified point.
31795 * @description The pixel point must lie inside the polygon or rectangle
31796 * of an added tag for the tag id to be returned. Tag ids for
31797 * tags that do not have a fill will also be returned if the point is inside
31798 * the geometry of the tag. Tags with point geometries can not be retrieved.
31800 * No tag ids will be returned for panoramas.
31802 * Notice that the pixelPoint argument requires x, y coordinates from pixel space.
31804 * With this function, you can use the coordinates provided by mouse
31805 * events to get information out of the tag component.
31807 * If no tag at exist the pixel point, an empty array will be returned.
31809 * @param {Array<number>} pixelPoint - Pixel coordinates on the viewer element.
31810 * @returns {Array<string>} Ids of the tags that contain the specified pixel point.
31814 * tagComponent.getTagIdsAt([100, 100])
31815 * .then((tagIds) => { console.log(tagIds); });
31818 TagComponent.prototype.getTagIdsAt = function (pixelPoint) {
31820 return when.promise(function (resolve, reject) {
31821 _this._container.renderService.renderCamera$.pipe(operators_1.first(), operators_1.map(function (render) {
31822 var viewport = _this._viewportCoords
31823 .canvasToViewport(pixelPoint[0], pixelPoint[1], _this._container.element);
31824 var ids = _this._tagScene.intersectObjects(viewport, render.perspective);
31827 .subscribe(function (ids) {
31829 }, function (error) {
31835 * Check if a tag exist in the tag set.
31837 * @param {string} tagId - Id of the tag.
31839 * @example ```var tagExists = tagComponent.has("tagId");```
31841 TagComponent.prototype.has = function (tagId) {
31842 return this._activated ? this._tagSet.has(tagId) : this._tagSet.hasDeactivated(tagId);
31845 * Remove tags with the specified ids from the tag set.
31847 * @param {Array<string>} tagIds - Ids for tags to remove.
31849 * @example ```tagComponent.remove(["id-1", "id-2"]);```
31851 TagComponent.prototype.remove = function (tagIds) {
31852 if (this._activated) {
31853 this._tagSet.remove(tagIds);
31854 this._tagScene.remove(tagIds);
31857 this._tagSet.removeDeactivated(tagIds);
31861 * Remove all tags from the tag set.
31863 * @example ```tagComponent.removeAll();```
31865 TagComponent.prototype.removeAll = function () {
31866 if (this._activated) {
31867 this._tagSet.removeAll();
31868 this._tagScene.removeAll();
31871 this._tagSet.removeAllDeactivated();
31874 TagComponent.prototype._activate = function () {
31876 this._editVertexHandler.enable();
31877 var handlerGeometryCreated$ = rxjs_1.from(Object.keys(this._createHandlers)).pipe(operators_1.map(function (key) {
31878 return _this._createHandlers[key];
31879 }), operators_1.filter(function (handler) {
31881 }), operators_1.mergeMap(function (handler) {
31882 return handler.geometryCreated$;
31883 }), operators_1.share());
31884 this._fireGeometryCreatedSubscription = handlerGeometryCreated$
31885 .subscribe(function (geometry) {
31886 _this.fire(TagComponent.geometrycreated, geometry);
31888 this._fireCreateGeometryEventSubscription = this._tagCreator.tag$.pipe(operators_1.skipWhile(function (tag) {
31889 return tag == null;
31890 }), operators_1.distinctUntilChanged())
31891 .subscribe(function (tag) {
31892 var eventType = tag != null ?
31893 TagComponent.creategeometrystart :
31894 TagComponent.creategeometryend;
31895 _this.fire(eventType, _this);
31897 this._handlerStopCreateSubscription = handlerGeometryCreated$
31898 .subscribe(function () {
31899 _this.changeMode(Component_1.TagMode.Default);
31901 this._handlerEnablerSubscription = this._creatingConfiguration$
31902 .subscribe(function (configuration) {
31903 _this._disableCreateHandlers();
31904 var mode = Component_1.TagMode[configuration.mode];
31905 var handler = _this._createHandlers[mode];
31910 this._fireTagsChangedSubscription = this._renderTags$
31911 .subscribe(function (tags) {
31912 _this.fire(TagComponent.tagschanged, _this);
31914 this._stopCreateSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
31915 return tag != null ?
31916 tag.aborted$.pipe(operators_1.map(function (t) { return null; })) :
31919 .subscribe(function () { _this.changeMode(Component_1.TagMode.Default); });
31920 this._setGLCreateTagSubscription = this._tagCreator.tag$
31921 .subscribe(function (tag) {
31922 if (_this._tagScene.hasCreateTag()) {
31923 _this._tagScene.removeCreateTag();
31926 _this._tagScene.addCreateTag(tag);
31929 this._createGLObjectsChangedSubscription = this._createGLObjectsChanged$
31930 .subscribe(function (tag) {
31931 _this._tagScene.updateCreateTagObjects(tag);
31933 this._updateGLObjectsSubscription = this._renderTagGLChanged$
31934 .subscribe(function (tag) {
31935 _this._tagScene.updateObjects(tag);
31937 this._updateTagSceneSubscription = this._tagChanged$
31938 .subscribe(function (tag) {
31939 _this._tagScene.update();
31941 this._domSubscription = rxjs_1.combineLatest(this._renderTags$.pipe(operators_1.startWith([]), operators_1.tap(function (tags) {
31942 _this._container.domRenderer.render$.next({
31944 vnode: _this._tagDomRenderer.clear(),
31946 })), 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) {
31947 var renderTags = _a[0], rc = _a[1], atlas = _a[2], size = _a[3], tag = _a[4], ct = _a[5];
31950 vnode: _this._tagDomRenderer.render(renderTags, ct, atlas, rc.perspective, size),
31953 .subscribe(this._container.domRenderer.render$);
31954 this._glSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
31955 var tagScene = _this._tagScene;
31960 needsRender: tagScene.needsRender,
31961 render: tagScene.render.bind(tagScene),
31962 stage: Render_1.GLRenderStage.Foreground,
31966 .subscribe(this._container.glRenderer.render$);
31967 this._navigator.stateService.currentTransform$.pipe(operators_1.first())
31968 .subscribe(function (transform) {
31969 _this._tagSet.activate(transform);
31970 _this._tagScene.add(_this._tagSet.getAll());
31973 TagComponent.prototype._deactivate = function () {
31974 this._editVertexHandler.disable();
31975 this._disableCreateHandlers();
31976 this._tagScene.clear();
31977 this._tagSet.deactivate();
31978 this._tagCreator.delete$.next(null);
31979 this._updateGLObjectsSubscription.unsubscribe();
31980 this._updateTagSceneSubscription.unsubscribe();
31981 this._stopCreateSubscription.unsubscribe();
31982 this._setGLCreateTagSubscription.unsubscribe();
31983 this._createGLObjectsChangedSubscription.unsubscribe();
31984 this._domSubscription.unsubscribe();
31985 this._glSubscription.unsubscribe();
31986 this._fireCreateGeometryEventSubscription.unsubscribe();
31987 this._fireGeometryCreatedSubscription.unsubscribe();
31988 this._fireTagsChangedSubscription.unsubscribe();
31989 this._handlerStopCreateSubscription.unsubscribe();
31990 this._handlerEnablerSubscription.unsubscribe();
31991 this._container.element.classList.remove("component-tag-create");
31993 TagComponent.prototype._getDefaultConfiguration = function () {
31995 createColor: 0xFFFFFF,
31996 mode: Component_1.TagMode.Default,
31999 TagComponent.prototype._disableCreateHandlers = function () {
32000 var createHandlers = this._createHandlers;
32001 for (var key in createHandlers) {
32002 if (!createHandlers.hasOwnProperty(key)) {
32005 var handler = createHandlers[key];
32012 TagComponent.componentName = "tag";
32014 * Event fired when an interaction to create a geometry ends.
32016 * @description A create interaction can by a geometry being created
32017 * or by the creation being aborted.
32019 * @event TagComponent#creategeometryend
32020 * @type {TagComponent} Tag component.
32023 * tagComponent.on("creategeometryend", function(component) {
32024 * console.log(component);
32028 TagComponent.creategeometryend = "creategeometryend";
32030 * Event fired when an interaction to create a geometry starts.
32032 * @description A create interaction starts when the first vertex
32033 * is created in the geometry.
32035 * @event TagComponent#creategeometrystart
32036 * @type {TagComponent} Tag component.
32039 * tagComponent.on("creategeometrystart", function(component) {
32040 * console.log(component);
32044 TagComponent.creategeometrystart = "creategeometrystart";
32046 * Event fired when the create mode is changed.
32048 * @event TagComponent#modechanged
32049 * @type {TagMode} Tag mode
32052 * tagComponent.on("modechanged", function(mode) {
32053 * console.log(mode);
32057 TagComponent.modechanged = "modechanged";
32059 * Event fired when a geometry has been created.
32061 * @event TagComponent#geometrycreated
32062 * @type {Geometry} Created geometry.
32065 * tagComponent.on("geometrycreated", function(geometry) {
32066 * console.log(geometry);
32070 TagComponent.geometrycreated = "geometrycreated";
32072 * Event fired when the tags collection has changed.
32074 * @event TagComponent#tagschanged
32075 * @type {TagComponent} Tag component.
32078 * tagComponent.on("tagschanged", function(component) {
32079 * console.log(component.getAll());
32083 TagComponent.tagschanged = "tagschanged";
32084 return TagComponent;
32085 }(Component_1.Component));
32086 exports.TagComponent = TagComponent;
32087 Component_1.ComponentService.register(TagComponent);
32088 exports.default = TagComponent;
32090 },{"../../Component":275,"../../Geo":278,"../../Render":281,"rxjs":27,"rxjs/operators":225,"when":272}],345:[function(require,module,exports){
32092 Object.defineProperty(exports, "__esModule", { value: true });
32093 var operators_1 = require("rxjs/operators");
32094 var rxjs_1 = require("rxjs");
32095 var Component_1 = require("../../Component");
32096 var TagCreator = /** @class */ (function () {
32097 function TagCreator(component, navigator) {
32098 this._component = component;
32099 this._navigator = navigator;
32100 this._tagOperation$ = new rxjs_1.Subject();
32101 this._createPolygon$ = new rxjs_1.Subject();
32102 this._createRect$ = new rxjs_1.Subject();
32103 this._delete$ = new rxjs_1.Subject();
32104 this._tag$ = this._tagOperation$.pipe(operators_1.scan(function (tag, operation) {
32105 return operation(tag);
32106 }, null), operators_1.share());
32107 this._createRect$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
32108 var coord = _a[0], conf = _a[1], transform = _a[2];
32109 return function (tag) {
32110 var geometry = new Component_1.RectGeometry([
32116 return new Component_1.OutlineCreateTag(geometry, { color: conf.createColor }, transform);
32119 .subscribe(this._tagOperation$);
32120 this._createPolygon$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
32121 var coord = _a[0], conf = _a[1], transform = _a[2];
32122 return function (tag) {
32123 var geometry = new Component_1.PolygonGeometry([
32124 [coord[0], coord[1]],
32125 [coord[0], coord[1]],
32126 [coord[0], coord[1]],
32128 return new Component_1.OutlineCreateTag(geometry, { color: conf.createColor }, transform);
32131 .subscribe(this._tagOperation$);
32132 this._delete$.pipe(operators_1.map(function () {
32133 return function (tag) {
32137 .subscribe(this._tagOperation$);
32139 Object.defineProperty(TagCreator.prototype, "createRect$", {
32141 return this._createRect$;
32146 Object.defineProperty(TagCreator.prototype, "createPolygon$", {
32148 return this._createPolygon$;
32153 Object.defineProperty(TagCreator.prototype, "delete$", {
32155 return this._delete$;
32160 Object.defineProperty(TagCreator.prototype, "tag$", {
32169 exports.TagCreator = TagCreator;
32170 exports.default = TagCreator;
32172 },{"../../Component":275,"rxjs":27,"rxjs/operators":225}],346:[function(require,module,exports){
32174 Object.defineProperty(exports, "__esModule", { value: true });
32175 var vd = require("virtual-dom");
32176 var TagDOMRenderer = /** @class */ (function () {
32177 function TagDOMRenderer() {
32179 TagDOMRenderer.prototype.render = function (tags, createTag, atlas, camera, size) {
32181 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
32182 var tag = tags_1[_i];
32183 vNodes = vNodes.concat(tag.getDOMObjects(atlas, camera, size));
32185 if (createTag != null) {
32186 vNodes = vNodes.concat(createTag.getDOMObjects(camera, size));
32188 return vd.h("div.TagContainer", {}, vNodes);
32190 TagDOMRenderer.prototype.clear = function () {
32191 return vd.h("div", {}, []);
32193 return TagDOMRenderer;
32195 exports.TagDOMRenderer = TagDOMRenderer;
32197 },{"virtual-dom":231}],347:[function(require,module,exports){
32199 Object.defineProperty(exports, "__esModule", { value: true });
32201 * Enumeration for tag modes
32204 * @description Modes for the interaction in the tag component.
32207 (function (TagMode) {
32209 * Disables creating tags.
32211 TagMode[TagMode["Default"] = 0] = "Default";
32213 * Create a point geometry through a click.
32215 TagMode[TagMode["CreatePoint"] = 1] = "CreatePoint";
32217 * Create a polygon geometry through clicks.
32219 TagMode[TagMode["CreatePolygon"] = 2] = "CreatePolygon";
32221 * Create a rect geometry through clicks.
32223 TagMode[TagMode["CreateRect"] = 3] = "CreateRect";
32225 * Create a rect geometry through drag.
32227 * @description Claims the mouse which results in mouse handlers like
32228 * drag pan and scroll zoom becoming inactive.
32230 TagMode[TagMode["CreateRectDrag"] = 4] = "CreateRectDrag";
32231 })(TagMode = exports.TagMode || (exports.TagMode = {}));
32232 exports.default = TagMode;
32234 },{}],348:[function(require,module,exports){
32236 Object.defineProperty(exports, "__esModule", { value: true });
32238 (function (TagOperation) {
32239 TagOperation[TagOperation["None"] = 0] = "None";
32240 TagOperation[TagOperation["Centroid"] = 1] = "Centroid";
32241 TagOperation[TagOperation["Vertex"] = 2] = "Vertex";
32242 })(TagOperation = exports.TagOperation || (exports.TagOperation = {}));
32243 exports.default = TagOperation;
32245 },{}],349:[function(require,module,exports){
32247 Object.defineProperty(exports, "__esModule", { value: true });
32248 var THREE = require("three");
32249 var TagScene = /** @class */ (function () {
32250 function TagScene(scene, raycaster) {
32251 this._createTag = null;
32252 this._needsRender = false;
32253 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster();
32254 this._scene = !!scene ? scene : new THREE.Scene();
32255 this._objectTags = {};
32256 this._retrievableObjects = [];
32259 Object.defineProperty(TagScene.prototype, "needsRender", {
32261 return this._needsRender;
32266 TagScene.prototype.add = function (tags) {
32267 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
32268 var tag = tags_1[_i];
32269 if (tag.tag.id in this._tags) {
32270 this._remove(tag.tag.id);
32274 this._needsRender = true;
32276 TagScene.prototype.addCreateTag = function (tag) {
32277 for (var _i = 0, _a = tag.glObjects; _i < _a.length; _i++) {
32278 var object = _a[_i];
32279 this._scene.add(object);
32281 this._createTag = { tag: tag, objects: tag.glObjects };
32282 this._needsRender = true;
32284 TagScene.prototype.clear = function () {
32285 for (var _i = 0, _a = Object.keys(this._tags); _i < _a.length; _i++) {
32289 this._needsRender = false;
32291 TagScene.prototype.get = function (id) {
32292 return this.has(id) ? this._tags[id].tag : undefined;
32294 TagScene.prototype.has = function (id) {
32295 return id in this._tags;
32297 TagScene.prototype.hasCreateTag = function () {
32298 return this._createTag != null;
32300 TagScene.prototype.intersectObjects = function (_a, camera) {
32301 var viewportX = _a[0], viewportY = _a[1];
32302 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
32303 var intersects = this._raycaster.intersectObjects(this._retrievableObjects);
32304 var intersectedIds = [];
32305 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
32306 var intersect = intersects_1[_i];
32307 if (intersect.object.uuid in this._objectTags) {
32308 intersectedIds.push(this._objectTags[intersect.object.uuid]);
32311 return intersectedIds;
32313 TagScene.prototype.remove = function (ids) {
32314 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
32315 var id = ids_1[_i];
32318 this._needsRender = true;
32320 TagScene.prototype.removeAll = function () {
32321 for (var _i = 0, _a = Object.keys(this._tags); _i < _a.length; _i++) {
32325 this._needsRender = true;
32327 TagScene.prototype.removeCreateTag = function () {
32328 if (this._createTag == null) {
32331 for (var _i = 0, _a = this._createTag.objects; _i < _a.length; _i++) {
32332 var object = _a[_i];
32333 this._scene.remove(object);
32335 this._createTag.tag.dispose();
32336 this._createTag = null;
32337 this._needsRender = true;
32339 TagScene.prototype.render = function (perspectiveCamera, renderer) {
32340 renderer.render(this._scene, perspectiveCamera);
32341 this._needsRender = false;
32343 TagScene.prototype.update = function () {
32344 this._needsRender = true;
32346 TagScene.prototype.updateCreateTagObjects = function (tag) {
32347 if (this._createTag.tag !== tag) {
32348 throw new Error("Create tags do not have the same reference.");
32350 for (var _i = 0, _a = this._createTag.objects; _i < _a.length; _i++) {
32351 var object = _a[_i];
32352 this._scene.remove(object);
32354 for (var _b = 0, _c = tag.glObjects; _b < _c.length; _b++) {
32355 var object = _c[_b];
32356 this._scene.add(object);
32358 this._createTag.objects = tag.glObjects;
32359 this._needsRender = true;
32361 TagScene.prototype.updateObjects = function (tag) {
32362 var id = tag.tag.id;
32363 if (this._tags[id].tag !== tag) {
32364 throw new Error("Tags do not have the same reference.");
32366 var tagObjects = this._tags[id];
32367 this._removeObjects(tagObjects);
32368 delete this._tags[id];
32370 this._needsRender = true;
32372 TagScene.prototype._add = function (tag) {
32373 var id = tag.tag.id;
32374 var tagObjects = { tag: tag, objects: [], retrievableObjects: [] };
32375 this._tags[id] = tagObjects;
32376 for (var _i = 0, _a = tag.getGLObjects(); _i < _a.length; _i++) {
32377 var object = _a[_i];
32378 tagObjects.objects.push(object);
32379 this._scene.add(object);
32381 for (var _b = 0, _c = tag.getRetrievableObjects(); _b < _c.length; _b++) {
32382 var retrievableObject = _c[_b];
32383 tagObjects.retrievableObjects.push(retrievableObject);
32384 this._retrievableObjects.push(retrievableObject);
32385 this._objectTags[retrievableObject.uuid] = tag.tag.id;
32388 TagScene.prototype._remove = function (id) {
32389 var tagObjects = this._tags[id];
32390 this._removeObjects(tagObjects);
32391 tagObjects.tag.dispose();
32392 delete this._tags[id];
32394 TagScene.prototype._removeObjects = function (tagObjects) {
32395 for (var _i = 0, _a = tagObjects.objects; _i < _a.length; _i++) {
32396 var object = _a[_i];
32397 this._scene.remove(object);
32399 for (var _b = 0, _c = tagObjects.retrievableObjects; _b < _c.length; _b++) {
32400 var retrievableObject = _c[_b];
32401 var index = this._retrievableObjects.indexOf(retrievableObject);
32402 if (index !== -1) {
32403 this._retrievableObjects.splice(index, 1);
32409 exports.TagScene = TagScene;
32410 exports.default = TagScene;
32412 },{"three":226}],350:[function(require,module,exports){
32414 Object.defineProperty(exports, "__esModule", { value: true });
32415 var rxjs_1 = require("rxjs");
32416 var Component_1 = require("../../Component");
32417 var TagSet = /** @class */ (function () {
32418 function TagSet() {
32419 this._active = false;
32421 this._hashDeactivated = {};
32422 this._notifyChanged$ = new rxjs_1.Subject();
32424 Object.defineProperty(TagSet.prototype, "active", {
32426 return this._active;
32431 Object.defineProperty(TagSet.prototype, "changed$", {
32433 return this._notifyChanged$;
32438 TagSet.prototype.activate = function (transform) {
32439 if (this._active) {
32442 for (var id in this._hashDeactivated) {
32443 if (!this._hashDeactivated.hasOwnProperty(id)) {
32446 var tag = this._hashDeactivated[id];
32447 this._add(tag, transform);
32449 this._hashDeactivated = {};
32450 this._active = true;
32451 this._notifyChanged$.next(this);
32453 TagSet.prototype.deactivate = function () {
32454 if (!this._active) {
32457 for (var id in this._hash) {
32458 if (!this._hash.hasOwnProperty(id)) {
32461 this._hashDeactivated[id] = this._hash[id].tag;
32464 this._active = false;
32466 TagSet.prototype.add = function (tags, transform) {
32467 this._assertActivationState(true);
32468 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
32469 var tag = tags_1[_i];
32470 this._add(tag, transform);
32472 this._notifyChanged$.next(this);
32474 TagSet.prototype.addDeactivated = function (tags) {
32475 this._assertActivationState(false);
32476 for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
32477 var tag = tags_2[_i];
32478 if (!(tag instanceof Component_1.OutlineTag || tag instanceof Component_1.SpotTag)) {
32479 throw new Error("Tag type not supported");
32481 this._hashDeactivated[tag.id] = tag;
32484 TagSet.prototype.get = function (id) {
32485 return this.has(id) ? this._hash[id] : undefined;
32487 TagSet.prototype.getAll = function () {
32488 var hash = this._hash;
32489 return Object.keys(hash)
32490 .map(function (id) {
32494 TagSet.prototype.getAllDeactivated = function () {
32495 var hashDeactivated = this._hashDeactivated;
32496 return Object.keys(hashDeactivated)
32497 .map(function (id) {
32498 return hashDeactivated[id];
32501 TagSet.prototype.getDeactivated = function (id) {
32502 return this.hasDeactivated(id) ? this._hashDeactivated[id] : undefined;
32504 TagSet.prototype.has = function (id) {
32505 return id in this._hash;
32507 TagSet.prototype.hasDeactivated = function (id) {
32508 return id in this._hashDeactivated;
32510 TagSet.prototype.remove = function (ids) {
32511 this._assertActivationState(true);
32512 var hash = this._hash;
32513 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
32514 var id = ids_1[_i];
32515 if (!(id in hash)) {
32520 this._notifyChanged$.next(this);
32522 TagSet.prototype.removeAll = function () {
32523 this._assertActivationState(true);
32525 this._notifyChanged$.next(this);
32527 TagSet.prototype.removeAllDeactivated = function () {
32528 this._assertActivationState(false);
32529 this._hashDeactivated = {};
32531 TagSet.prototype.removeDeactivated = function (ids) {
32532 this._assertActivationState(false);
32533 var hashDeactivated = this._hashDeactivated;
32534 for (var _i = 0, ids_2 = ids; _i < ids_2.length; _i++) {
32535 var id = ids_2[_i];
32536 if (!(id in hashDeactivated)) {
32539 delete hashDeactivated[id];
32542 TagSet.prototype._add = function (tag, transform) {
32543 if (tag instanceof Component_1.OutlineTag) {
32544 this._hash[tag.id] = new Component_1.OutlineRenderTag(tag, transform);
32546 else if (tag instanceof Component_1.SpotTag) {
32547 this._hash[tag.id] = new Component_1.SpotRenderTag(tag, transform);
32550 throw new Error("Tag type not supported");
32553 TagSet.prototype._assertActivationState = function (should) {
32554 if (should !== this._active) {
32555 throw new Error("Tag set not in correct state for operation.");
32560 exports.TagSet = TagSet;
32561 exports.default = TagSet;
32563 },{"../../Component":275,"rxjs":27}],351:[function(require,module,exports){
32565 var __extends = (this && this.__extends) || (function () {
32566 var extendStatics = function (d, b) {
32567 extendStatics = Object.setPrototypeOf ||
32568 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32569 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32570 return extendStatics(d, b);
32572 return function (d, b) {
32573 extendStatics(d, b);
32574 function __() { this.constructor = d; }
32575 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32578 Object.defineProperty(exports, "__esModule", { value: true });
32579 var Error_1 = require("../../../Error");
32580 var GeometryTagError = /** @class */ (function (_super) {
32581 __extends(GeometryTagError, _super);
32582 function GeometryTagError(message) {
32583 var _this = _super.call(this, message != null ? message : "The provided geometry value is incorrect") || this;
32584 _this.name = "GeometryTagError";
32587 return GeometryTagError;
32588 }(Error_1.MapillaryError));
32589 exports.GeometryTagError = GeometryTagError;
32590 exports.default = Error_1.MapillaryError;
32592 },{"../../../Error":277}],352:[function(require,module,exports){
32594 Object.defineProperty(exports, "__esModule", { value: true });
32595 var rxjs_1 = require("rxjs");
32599 * @classdesc Represents a geometry.
32601 var Geometry = /** @class */ (function () {
32603 * Create a geometry.
32608 function Geometry() {
32609 this._notifyChanged$ = new rxjs_1.Subject();
32611 Object.defineProperty(Geometry.prototype, "changed$", {
32613 * Get changed observable.
32615 * @description Emits the geometry itself every time the geometry
32618 * @returns {Observable<Geometry>} Observable emitting the geometry instance.
32622 return this._notifyChanged$;
32629 exports.Geometry = Geometry;
32630 exports.default = Geometry;
32632 },{"rxjs":27}],353:[function(require,module,exports){
32634 var __extends = (this && this.__extends) || (function () {
32635 var extendStatics = function (d, b) {
32636 extendStatics = Object.setPrototypeOf ||
32637 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32638 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32639 return extendStatics(d, b);
32641 return function (d, b) {
32642 extendStatics(d, b);
32643 function __() { this.constructor = d; }
32644 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32647 Object.defineProperty(exports, "__esModule", { value: true });
32648 var Component_1 = require("../../../Component");
32650 * @class PointGeometry
32652 * @classdesc Represents a point geometry in the 2D basic image coordinate system.
32656 * var basicPoint = [0.5, 0.7];
32657 * var pointGeometry = new Mapillary.TagComponent.PointGeometry(basicPoint);
32660 var PointGeometry = /** @class */ (function (_super) {
32661 __extends(PointGeometry, _super);
32663 * Create a point geometry.
32666 * @param {Array<number>} point - An array representing the basic coordinates of
32669 * @throws {GeometryTagError} Point coordinates must be valid basic coordinates.
32671 function PointGeometry(point) {
32672 var _this = _super.call(this) || this;
32675 if (x < 0 || x > 1 || y < 0 || y > 1) {
32676 throw new Component_1.GeometryTagError("Basic coordinates must be on the interval [0, 1].");
32678 _this._point = point.slice();
32681 Object.defineProperty(PointGeometry.prototype, "point", {
32683 * Get point property.
32684 * @returns {Array<number>} Array representing the basic coordinates of the point.
32687 return this._point;
32693 * Get the 2D basic coordinates for the centroid of the point, i.e. the 2D
32694 * basic coordinates of the point itself.
32696 * @returns {Array<number>} 2D basic coordinates representing the centroid.
32699 PointGeometry.prototype.getCentroid2d = function () {
32700 return this._point.slice();
32703 * Get the 3D world coordinates for the centroid of the point, i.e. the 3D
32704 * world coordinates of the point itself.
32706 * @param {Transform} transform - The transform of the node related to the point.
32707 * @returns {Array<number>} 3D world coordinates representing the centroid.
32710 PointGeometry.prototype.getCentroid3d = function (transform) {
32711 return transform.unprojectBasic(this._point, 200);
32714 * Set the centroid of the point, i.e. the point coordinates.
32716 * @param {Array<number>} value - The new value of the centroid.
32717 * @param {Transform} transform - The transform of the node related to the point.
32720 PointGeometry.prototype.setCentroid2d = function (value, transform) {
32722 Math.max(0, Math.min(1, value[0])),
32723 Math.max(0, Math.min(1, value[1])),
32725 this._point[0] = changed[0];
32726 this._point[1] = changed[1];
32727 this._notifyChanged$.next(this);
32729 return PointGeometry;
32730 }(Component_1.Geometry));
32731 exports.PointGeometry = PointGeometry;
32733 },{"../../../Component":275}],354:[function(require,module,exports){
32735 var __extends = (this && this.__extends) || (function () {
32736 var extendStatics = function (d, b) {
32737 extendStatics = Object.setPrototypeOf ||
32738 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32739 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32740 return extendStatics(d, b);
32742 return function (d, b) {
32743 extendStatics(d, b);
32744 function __() { this.constructor = d; }
32745 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32748 Object.defineProperty(exports, "__esModule", { value: true });
32749 var Component_1 = require("../../../Component");
32751 * @class PolygonGeometry
32753 * @classdesc Represents a polygon geometry in the 2D basic image coordinate system.
32754 * All polygons and holes provided to the constructor needs to be closed.
32758 * var basicPolygon = [[0.5, 0.3], [0.7, 0.3], [0.6, 0.5], [0.5, 0.3]];
32759 * var polygonGeometry = new Mapillary.TagComponent.PolygonGeometry(basicPolygon);
32762 var PolygonGeometry = /** @class */ (function (_super) {
32763 __extends(PolygonGeometry, _super);
32765 * Create a polygon geometry.
32768 * @param {Array<Array<number>>} polygon - Array of polygon vertices. Must be closed.
32769 * @param {Array<Array<Array<number>>>} [holes] - Array of arrays of hole vertices.
32770 * Each array of holes vertices must be closed.
32772 * @throws {GeometryTagError} Polygon coordinates must be valid basic coordinates.
32774 function PolygonGeometry(polygon, holes) {
32775 var _this = _super.call(this) || this;
32776 var polygonLength = polygon.length;
32777 if (polygonLength < 3) {
32778 throw new Component_1.GeometryTagError("A polygon must have three or more positions.");
32780 if (polygon[0][0] !== polygon[polygonLength - 1][0] ||
32781 polygon[0][1] !== polygon[polygonLength - 1][1]) {
32782 throw new Component_1.GeometryTagError("First and last positions must be equivalent.");
32784 _this._polygon = [];
32785 for (var _i = 0, polygon_1 = polygon; _i < polygon_1.length; _i++) {
32786 var vertex = polygon_1[_i];
32787 if (vertex[0] < 0 || vertex[0] > 1 ||
32788 vertex[1] < 0 || vertex[1] > 1) {
32789 throw new Component_1.GeometryTagError("Basic coordinates of polygon must be on the interval [0, 1].");
32791 _this._polygon.push(vertex.slice());
32794 if (holes == null) {
32797 for (var i = 0; i < holes.length; i++) {
32798 var hole = holes[i];
32799 var holeLength = hole.length;
32800 if (holeLength < 3) {
32801 throw new Component_1.GeometryTagError("A polygon hole must have three or more positions.");
32803 if (hole[0][0] !== hole[holeLength - 1][0] ||
32804 hole[0][1] !== hole[holeLength - 1][1]) {
32805 throw new Component_1.GeometryTagError("First and last positions of hole must be equivalent.");
32807 _this._holes.push([]);
32808 for (var _a = 0, hole_1 = hole; _a < hole_1.length; _a++) {
32809 var vertex = hole_1[_a];
32810 if (vertex[0] < 0 || vertex[0] > 1 ||
32811 vertex[1] < 0 || vertex[1] > 1) {
32812 throw new Component_1.GeometryTagError("Basic coordinates of hole must be on the interval [0, 1].");
32814 _this._holes[i].push(vertex.slice());
32819 Object.defineProperty(PolygonGeometry.prototype, "polygon", {
32821 * Get polygon property.
32822 * @returns {Array<Array<number>>} Closed 2d polygon.
32825 return this._polygon;
32830 Object.defineProperty(PolygonGeometry.prototype, "holes", {
32832 * Get holes property.
32833 * @returns {Array<Array<Array<number>>>} Holes of 2d polygon.
32836 return this._holes;
32842 * Add a vertex to the polygon by appending it after the last vertex.
32844 * @param {Array<number>} vertex - Vertex to add.
32847 PolygonGeometry.prototype.addVertex2d = function (vertex) {
32849 Math.max(0, Math.min(1, vertex[0])),
32850 Math.max(0, Math.min(1, vertex[1])),
32852 this._polygon.splice(this._polygon.length - 1, 0, clamped);
32853 this._notifyChanged$.next(this);
32856 * Get the coordinates of a vertex from the polygon representation of the geometry.
32858 * @description The first vertex represents the bottom-left corner with the rest of
32859 * the vertices following in clockwise order.
32861 * @param {number} index - Vertex index.
32862 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
32865 PolygonGeometry.prototype.getVertex2d = function (index) {
32866 return this._polygon[index].slice();
32869 * Remove a vertex from the polygon.
32871 * @param {number} index - The index of the vertex to remove.
32874 PolygonGeometry.prototype.removeVertex2d = function (index) {
32876 index >= this._polygon.length ||
32877 this._polygon.length < 4) {
32878 throw new Component_1.GeometryTagError("Index for removed vertex must be valid.");
32880 if (index > 0 && index < this._polygon.length - 1) {
32881 this._polygon.splice(index, 1);
32884 this._polygon.splice(0, 1);
32885 this._polygon.pop();
32886 var closing = this._polygon[0].slice();
32887 this._polygon.push(closing);
32889 this._notifyChanged$.next(this);
32892 PolygonGeometry.prototype.setVertex2d = function (index, value, transform) {
32894 Math.max(0, Math.min(1, value[0])),
32895 Math.max(0, Math.min(1, value[1])),
32897 if (index === 0 || index === this._polygon.length - 1) {
32898 this._polygon[0] = changed.slice();
32899 this._polygon[this._polygon.length - 1] = changed.slice();
32902 this._polygon[index] = changed.slice();
32904 this._notifyChanged$.next(this);
32907 PolygonGeometry.prototype.setCentroid2d = function (value, transform) {
32908 var xs = this._polygon.map(function (point) { return point[0]; });
32909 var ys = this._polygon.map(function (point) { return point[1]; });
32910 var minX = Math.min.apply(Math, xs);
32911 var maxX = Math.max.apply(Math, xs);
32912 var minY = Math.min.apply(Math, ys);
32913 var maxY = Math.max.apply(Math, ys);
32914 var centroid = this.getCentroid2d();
32915 var minTranslationX = -minX;
32916 var maxTranslationX = 1 - maxX;
32917 var minTranslationY = -minY;
32918 var maxTranslationY = 1 - maxY;
32919 var translationX = Math.max(minTranslationX, Math.min(maxTranslationX, value[0] - centroid[0]));
32920 var translationY = Math.max(minTranslationY, Math.min(maxTranslationY, value[1] - centroid[1]));
32921 for (var _i = 0, _a = this._polygon; _i < _a.length; _i++) {
32922 var point = _a[_i];
32923 point[0] += translationX;
32924 point[1] += translationY;
32926 this._notifyChanged$.next(this);
32929 PolygonGeometry.prototype.getPoints3d = function (transform) {
32930 return this._getPoints3d(this._subsample(this._polygon), transform);
32933 PolygonGeometry.prototype.getVertex3d = function (index, transform) {
32934 return transform.unprojectBasic(this._polygon[index], 200);
32937 PolygonGeometry.prototype.getVertices2d = function () {
32938 return this._polygon.slice();
32941 PolygonGeometry.prototype.getVertices3d = function (transform) {
32942 return this._getPoints3d(this._polygon, transform);
32945 * Get a polygon representation of the 3D coordinates for the vertices of each hole
32946 * of the geometry. Line segments between vertices will possibly be subsampled
32947 * resulting in a larger number of points than the total number of vertices.
32949 * @param {Transform} transform - The transform of the node related to the geometry.
32950 * @returns {Array<Array<Array<number>>>} Array of hole polygons in 3D world coordinates
32951 * representing the vertices of each hole of the geometry.
32954 PolygonGeometry.prototype.getHolePoints3d = function (transform) {
32957 .map(function (hole2d) {
32958 return _this._getPoints3d(_this._subsample(hole2d), transform);
32962 * Get a polygon representation of the 3D coordinates for the vertices of each hole
32965 * @param {Transform} transform - The transform of the node related to the geometry.
32966 * @returns {Array<Array<Array<number>>>} Array of hole polygons in 3D world coordinates
32967 * representing the vertices of each hole of the geometry.
32970 PolygonGeometry.prototype.getHoleVertices3d = function (transform) {
32973 .map(function (hole2d) {
32974 return _this._getPoints3d(hole2d, transform);
32978 PolygonGeometry.prototype.getCentroid2d = function () {
32979 var polygon = this._polygon;
32983 for (var i = 0; i < polygon.length - 1; i++) {
32984 var xi = polygon[i][0];
32985 var yi = polygon[i][1];
32986 var xi1 = polygon[i + 1][0];
32987 var yi1 = polygon[i + 1][1];
32988 var a = xi * yi1 - xi1 * yi;
32990 centroidX += (xi + xi1) * a;
32991 centroidY += (yi + yi1) * a;
32994 centroidX /= 6 * area;
32995 centroidY /= 6 * area;
32996 return [centroidX, centroidY];
32999 PolygonGeometry.prototype.getCentroid3d = function (transform) {
33000 var centroid2d = this.getCentroid2d();
33001 return transform.unprojectBasic(centroid2d, 200);
33004 PolygonGeometry.prototype.get3dDomainTriangles3d = function (transform) {
33006 return this._triangulate(this._project(this._polygon, transform), this.getVertices3d(transform), this._holes
33007 .map(function (hole2d) {
33008 return _this._project(hole2d, transform);
33009 }), this.getHoleVertices3d(transform));
33012 PolygonGeometry.prototype.getTriangles3d = function (transform) {
33014 if (transform.fullPano) {
33015 return this._triangulatePano(this._polygon.slice(), this.holes.slice(), transform);
33017 var points2d = this._project(this._subsample(this._polygon), transform);
33018 var points3d = this.getPoints3d(transform);
33019 var holes2d = this._holes
33020 .map(function (hole) {
33021 return _this._project(_this._subsample(hole), transform);
33023 var holes3d = this.getHolePoints3d(transform);
33024 return this._triangulate(points2d, points3d, holes2d, holes3d);
33027 PolygonGeometry.prototype.getPoleOfInaccessibility2d = function () {
33028 return this._getPoleOfInaccessibility2d(this._polygon.slice());
33031 PolygonGeometry.prototype.getPoleOfInaccessibility3d = function (transform) {
33032 var pole2d = this._getPoleOfInaccessibility2d(this._polygon.slice());
33033 return transform.unprojectBasic(pole2d, 200);
33035 PolygonGeometry.prototype._getPoints3d = function (points2d, transform) {
33037 .map(function (point) {
33038 return transform.unprojectBasic(point, 200);
33041 return PolygonGeometry;
33042 }(Component_1.VertexGeometry));
33043 exports.PolygonGeometry = PolygonGeometry;
33044 exports.default = PolygonGeometry;
33046 },{"../../../Component":275}],355:[function(require,module,exports){
33048 var __extends = (this && this.__extends) || (function () {
33049 var extendStatics = function (d, b) {
33050 extendStatics = Object.setPrototypeOf ||
33051 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33052 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33053 return extendStatics(d, b);
33055 return function (d, b) {
33056 extendStatics(d, b);
33057 function __() { this.constructor = d; }
33058 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33061 Object.defineProperty(exports, "__esModule", { value: true });
33062 var Component_1 = require("../../../Component");
33064 * @class RectGeometry
33066 * @classdesc Represents a rectangle geometry in the 2D basic image coordinate system.
33070 * var basicRect = [0.5, 0.3, 0.7, 0.4];
33071 * var rectGeometry = new Mapillary.TagComponent.RectGeometry(basicRect);
33074 var RectGeometry = /** @class */ (function (_super) {
33075 __extends(RectGeometry, _super);
33077 * Create a rectangle geometry.
33080 * @param {Array<number>} rect - An array representing the top-left and bottom-right
33081 * corners of the rectangle in basic coordinates. Ordered according to [x0, y0, x1, y1].
33083 * @throws {GeometryTagError} Rectangle coordinates must be valid basic coordinates.
33085 function RectGeometry(rect) {
33086 var _this = _super.call(this) || this;
33087 if (rect[1] > rect[3]) {
33088 throw new Component_1.GeometryTagError("Basic Y coordinates values can not be inverted.");
33090 for (var _i = 0, rect_1 = rect; _i < rect_1.length; _i++) {
33091 var coord = rect_1[_i];
33092 if (coord < 0 || coord > 1) {
33093 throw new Component_1.GeometryTagError("Basic coordinates must be on the interval [0, 1].");
33096 _this._anchorIndex = undefined;
33097 _this._rect = rect.slice(0, 4);
33098 _this._inverted = _this._rect[0] > _this._rect[2];
33101 Object.defineProperty(RectGeometry.prototype, "anchorIndex", {
33103 * Get anchor index property.
33105 * @returns {number} Index representing the current anchor property if
33106 * achoring indexing has been initialized. If anchor indexing has not been
33107 * initialized or has been terminated undefined will be returned.
33111 return this._anchorIndex;
33116 Object.defineProperty(RectGeometry.prototype, "inverted", {
33118 * Get inverted property.
33120 * @returns {boolean} Boolean determining whether the rect geometry is
33121 * inverted. For panoramas the rect geometrye may be inverted.
33125 return this._inverted;
33130 Object.defineProperty(RectGeometry.prototype, "rect", {
33132 * Get rect property.
33134 * @returns {Array<number>} Array representing the top-left and bottom-right
33135 * corners of the rectangle in basic coordinates.
33144 * Initialize anchor indexing to enable setting opposite vertex.
33146 * @param {number} [index] - The index of the vertex to use as anchor.
33148 * @throws {Error} If anchor indexing has already been initialized.
33149 * @throws {Error} If index is not valid (0 to 3).
33152 RectGeometry.prototype.initializeAnchorIndexing = function (index) {
33153 if (this._anchorIndex !== undefined) {
33154 throw new Error("Anchor indexing is already initialized.");
33156 if (index < 0 || index > 3) {
33157 throw new Error("Invalid anchor index: " + index + ".");
33159 this._anchorIndex = index === undefined ? 0 : index;
33162 * Terminate anchor indexing to disable setting pposite vertex.
33165 RectGeometry.prototype.terminateAnchorIndexing = function () {
33166 this._anchorIndex = undefined;
33169 * Set the value of the vertex opposite to the anchor in the polygon
33170 * representation of the rectangle.
33172 * @description Setting the opposite vertex may change the anchor index.
33174 * @param {Array<number>} opposite - The new value of the vertex opposite to the anchor.
33175 * @param {Transform} transform - The transform of the node related to the rectangle.
33177 * @throws {Error} When anchor indexing has not been initialized.
33180 RectGeometry.prototype.setOppositeVertex2d = function (opposite, transform) {
33181 if (this._anchorIndex === undefined) {
33182 throw new Error("Anchor indexing needs to be initialized.");
33185 Math.max(0, Math.min(1, opposite[0])),
33186 Math.max(0, Math.min(1, opposite[1])),
33188 var original = this._rect.slice();
33189 var anchor = this._anchorIndex === 0 ? [original[0], original[3]] :
33190 this._anchorIndex === 1 ? [original[0], original[1]] :
33191 this._anchorIndex === 2 ? [original[2], original[1]] :
33192 [original[2], original[3]];
33193 if (transform.fullPano) {
33194 var deltaX = this._anchorIndex < 2 ?
33195 changed[0] - original[2] :
33196 changed[0] - original[0];
33197 if (!this._inverted && this._anchorIndex < 2 && changed[0] < 0.25 && original[2] > 0.75 && deltaX < -0.5) {
33198 // right side passes boundary rightward
33199 this._inverted = true;
33200 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33202 else if (!this._inverted && this._anchorIndex >= 2 && changed[0] < 0.25 && original[2] > 0.75 && deltaX < -0.5) {
33203 // left side passes right side and boundary rightward
33204 this._inverted = true;
33205 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33207 else if (this._inverted && this._anchorIndex >= 2 && changed[0] < 0.25 && original[0] > 0.75 && deltaX < -0.5) {
33208 this._inverted = false;
33209 if (anchor[0] > changed[0]) {
33210 // left side passes boundary rightward
33211 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33214 // left side passes right side and boundary rightward
33215 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33218 else if (!this._inverted && this._anchorIndex >= 2 && changed[0] > 0.75 && original[0] < 0.25 && deltaX > 0.5) {
33219 // left side passes boundary leftward
33220 this._inverted = true;
33221 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33223 else if (!this._inverted && this._anchorIndex < 2 && changed[0] > 0.75 && original[0] < 0.25 && deltaX > 0.5) {
33224 // right side passes left side and boundary leftward
33225 this._inverted = true;
33226 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33228 else if (this._inverted && this._anchorIndex < 2 && changed[0] > 0.75 && original[2] < 0.25 && deltaX > 0.5) {
33229 this._inverted = false;
33230 if (anchor[0] > changed[0]) {
33231 // right side passes boundary leftward
33232 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33235 // right side passes left side and boundary leftward
33236 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33239 else if (this._inverted && this._anchorIndex < 2 && changed[0] > original[0]) {
33240 // inverted and right side passes left side completing a loop
33241 this._inverted = false;
33242 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33244 else if (this._inverted && this._anchorIndex >= 2 && changed[0] < original[2]) {
33245 // inverted and left side passes right side completing a loop
33246 this._inverted = false;
33247 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33249 else if (this._inverted) {
33250 // if still inverted only top and bottom can switch
33251 if (this._anchorIndex < 2) {
33252 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33255 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33259 // if still not inverted treat as non full pano
33260 if (anchor[0] <= changed[0] && anchor[1] > changed[1]) {
33261 this._anchorIndex = 0;
33263 else if (anchor[0] <= changed[0] && anchor[1] <= changed[1]) {
33264 this._anchorIndex = 1;
33266 else if (anchor[0] > changed[0] && anchor[1] <= changed[1]) {
33267 this._anchorIndex = 2;
33270 this._anchorIndex = 3;
33274 if (this._anchorIndex === 0) {
33275 rect[0] = anchor[0];
33276 rect[1] = changed[1];
33277 rect[2] = changed[0];
33278 rect[3] = anchor[1];
33280 else if (this._anchorIndex === 1) {
33281 rect[0] = anchor[0];
33282 rect[1] = anchor[1];
33283 rect[2] = changed[0];
33284 rect[3] = changed[1];
33286 else if (this._anchorIndex === 2) {
33287 rect[0] = changed[0];
33288 rect[1] = anchor[1];
33289 rect[2] = anchor[0];
33290 rect[3] = changed[1];
33293 rect[0] = changed[0];
33294 rect[1] = changed[1];
33295 rect[2] = anchor[0];
33296 rect[3] = anchor[1];
33298 if (!this._inverted && rect[0] > rect[2] ||
33299 this._inverted && rect[0] < rect[2]) {
33300 rect[0] = original[0];
33301 rect[2] = original[2];
33303 if (rect[1] > rect[3]) {
33304 rect[1] = original[1];
33305 rect[3] = original[3];
33307 this._rect[0] = rect[0];
33308 this._rect[1] = rect[1];
33309 this._rect[2] = rect[2];
33310 this._rect[3] = rect[3];
33313 if (anchor[0] <= changed[0] && anchor[1] > changed[1]) {
33314 this._anchorIndex = 0;
33316 else if (anchor[0] <= changed[0] && anchor[1] <= changed[1]) {
33317 this._anchorIndex = 1;
33319 else if (anchor[0] > changed[0] && anchor[1] <= changed[1]) {
33320 this._anchorIndex = 2;
33323 this._anchorIndex = 3;
33326 if (this._anchorIndex === 0) {
33327 rect[0] = anchor[0];
33328 rect[1] = changed[1];
33329 rect[2] = changed[0];
33330 rect[3] = anchor[1];
33332 else if (this._anchorIndex === 1) {
33333 rect[0] = anchor[0];
33334 rect[1] = anchor[1];
33335 rect[2] = changed[0];
33336 rect[3] = changed[1];
33338 else if (this._anchorIndex === 2) {
33339 rect[0] = changed[0];
33340 rect[1] = anchor[1];
33341 rect[2] = anchor[0];
33342 rect[3] = changed[1];
33345 rect[0] = changed[0];
33346 rect[1] = changed[1];
33347 rect[2] = anchor[0];
33348 rect[3] = anchor[1];
33350 if (rect[0] > rect[2]) {
33351 rect[0] = original[0];
33352 rect[2] = original[2];
33354 if (rect[1] > rect[3]) {
33355 rect[1] = original[1];
33356 rect[3] = original[3];
33358 this._rect[0] = rect[0];
33359 this._rect[1] = rect[1];
33360 this._rect[2] = rect[2];
33361 this._rect[3] = rect[3];
33363 this._notifyChanged$.next(this);
33366 * Set the value of a vertex in the polygon representation of the rectangle.
33368 * @description The polygon is defined to have the first vertex at the
33369 * bottom-left corner with the rest of the vertices following in clockwise order.
33371 * @param {number} index - The index of the vertex to be set.
33372 * @param {Array<number>} value - The new value of the vertex.
33373 * @param {Transform} transform - The transform of the node related to the rectangle.
33376 RectGeometry.prototype.setVertex2d = function (index, value, transform) {
33377 var original = this._rect.slice();
33379 Math.max(0, Math.min(1, value[0])),
33380 Math.max(0, Math.min(1, value[1])),
33384 rect[0] = changed[0];
33385 rect[1] = original[1];
33386 rect[2] = original[2];
33387 rect[3] = changed[1];
33389 else if (index === 1) {
33390 rect[0] = changed[0];
33391 rect[1] = changed[1];
33392 rect[2] = original[2];
33393 rect[3] = original[3];
33395 else if (index === 2) {
33396 rect[0] = original[0];
33397 rect[1] = changed[1];
33398 rect[2] = changed[0];
33399 rect[3] = original[3];
33401 else if (index === 3) {
33402 rect[0] = original[0];
33403 rect[1] = original[1];
33404 rect[2] = changed[0];
33405 rect[3] = changed[1];
33407 if (transform.fullPano) {
33408 var passingBoundaryLeftward = index < 2 && changed[0] > 0.75 && original[0] < 0.25 ||
33409 index >= 2 && this._inverted && changed[0] > 0.75 && original[2] < 0.25;
33410 var passingBoundaryRightward = index < 2 && this._inverted && changed[0] < 0.25 && original[0] > 0.75 ||
33411 index >= 2 && changed[0] < 0.25 && original[2] > 0.75;
33412 if (passingBoundaryLeftward || passingBoundaryRightward) {
33413 this._inverted = !this._inverted;
33416 if (rect[0] - original[0] < -0.25) {
33417 rect[0] = original[0];
33419 if (rect[2] - original[2] > 0.25) {
33420 rect[2] = original[2];
33423 if (!this._inverted && rect[0] > rect[2] ||
33424 this._inverted && rect[0] < rect[2]) {
33425 rect[0] = original[0];
33426 rect[2] = original[2];
33430 if (rect[0] > rect[2]) {
33431 rect[0] = original[0];
33432 rect[2] = original[2];
33435 if (rect[1] > rect[3]) {
33436 rect[1] = original[1];
33437 rect[3] = original[3];
33439 this._rect[0] = rect[0];
33440 this._rect[1] = rect[1];
33441 this._rect[2] = rect[2];
33442 this._rect[3] = rect[3];
33443 this._notifyChanged$.next(this);
33446 RectGeometry.prototype.setCentroid2d = function (value, transform) {
33447 var original = this._rect.slice();
33448 var x0 = original[0];
33449 var x1 = this._inverted ? original[2] + 1 : original[2];
33450 var y0 = original[1];
33451 var y1 = original[3];
33452 var centerX = x0 + (x1 - x0) / 2;
33453 var centerY = y0 + (y1 - y0) / 2;
33454 var translationX = 0;
33455 if (transform.gpano != null &&
33456 transform.gpano.CroppedAreaImageWidthPixels === transform.gpano.FullPanoWidthPixels) {
33457 translationX = this._inverted ? value[0] + 1 - centerX : value[0] - centerX;
33460 var minTranslationX = -x0;
33461 var maxTranslationX = 1 - x1;
33462 translationX = Math.max(minTranslationX, Math.min(maxTranslationX, value[0] - centerX));
33464 var minTranslationY = -y0;
33465 var maxTranslationY = 1 - y1;
33466 var translationY = Math.max(minTranslationY, Math.min(maxTranslationY, value[1] - centerY));
33467 this._rect[0] = original[0] + translationX;
33468 this._rect[1] = original[1] + translationY;
33469 this._rect[2] = original[2] + translationX;
33470 this._rect[3] = original[3] + translationY;
33471 if (this._rect[0] < 0) {
33472 this._rect[0] += 1;
33473 this._inverted = !this._inverted;
33475 else if (this._rect[0] > 1) {
33476 this._rect[0] -= 1;
33477 this._inverted = !this._inverted;
33479 if (this._rect[2] < 0) {
33480 this._rect[2] += 1;
33481 this._inverted = !this._inverted;
33483 else if (this._rect[2] > 1) {
33484 this._rect[2] -= 1;
33485 this._inverted = !this._inverted;
33487 this._notifyChanged$.next(this);
33490 * Get the 3D coordinates for the vertices of the rectangle with
33491 * interpolated points along the lines.
33493 * @param {Transform} transform - The transform of the node related to
33495 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates
33496 * representing the rectangle.
33499 RectGeometry.prototype.getPoints3d = function (transform) {
33500 return this._getPoints2d()
33501 .map(function (point) {
33502 return transform.unprojectBasic(point, 200);
33506 * Get the coordinates of a vertex from the polygon representation of the geometry.
33508 * @description The first vertex represents the bottom-left corner with the rest of
33509 * the vertices following in clockwise order. The method shifts the right side
33510 * coordinates of the rectangle by one unit to ensure that the vertices are ordered
33513 * @param {number} index - Vertex index.
33514 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
33517 RectGeometry.prototype.getVertex2d = function (index) {
33518 return this._rectToVertices2d(this._rect)[index];
33521 * Get the coordinates of a vertex from the polygon representation of the geometry.
33523 * @description The first vertex represents the bottom-left corner with the rest of
33524 * the vertices following in clockwise order. The coordinates will not be shifted
33525 * so they may not appear in clockwise order when layed out on the plane.
33527 * @param {number} index - Vertex index.
33528 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
33531 RectGeometry.prototype.getNonAdjustedVertex2d = function (index) {
33532 return this._rectToNonAdjustedVertices2d(this._rect)[index];
33535 * Get a vertex from the polygon representation of the 3D coordinates for the
33536 * vertices of the geometry.
33538 * @description The first vertex represents the bottom-left corner with the rest of
33539 * the vertices following in clockwise order.
33541 * @param {number} index - Vertex index.
33542 * @param {Transform} transform - The transform of the node related to the geometry.
33543 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates representing
33544 * the vertices of the geometry.
33547 RectGeometry.prototype.getVertex3d = function (index, transform) {
33548 return transform.unprojectBasic(this._rectToVertices2d(this._rect)[index], 200);
33551 * Get a polygon representation of the 2D basic coordinates for the vertices of the rectangle.
33553 * @description The first vertex represents the bottom-left corner with the rest of
33554 * the vertices following in clockwise order.
33556 * @returns {Array<Array<number>>} Polygon array of 2D basic coordinates representing
33557 * the rectangle vertices.
33560 RectGeometry.prototype.getVertices2d = function () {
33561 return this._rectToVertices2d(this._rect);
33564 * Get a polygon representation of the 3D coordinates for the vertices of the rectangle.
33566 * @description The first vertex represents the bottom-left corner with the rest of
33567 * the vertices following in clockwise order.
33569 * @param {Transform} transform - The transform of the node related to the rectangle.
33570 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates representing
33571 * the rectangle vertices.
33574 RectGeometry.prototype.getVertices3d = function (transform) {
33575 return this._rectToVertices2d(this._rect)
33576 .map(function (vertex) {
33577 return transform.unprojectBasic(vertex, 200);
33581 RectGeometry.prototype.getCentroid2d = function () {
33582 var rect = this._rect;
33584 var x1 = this._inverted ? rect[2] + 1 : rect[2];
33587 var centroidX = (x0 + x1) / 2;
33588 var centroidY = (y0 + y1) / 2;
33589 return [centroidX, centroidY];
33592 RectGeometry.prototype.getCentroid3d = function (transform) {
33593 var centroid2d = this.getCentroid2d();
33594 return transform.unprojectBasic(centroid2d, 200);
33599 RectGeometry.prototype.getPoleOfInaccessibility2d = function () {
33600 return this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));
33603 RectGeometry.prototype.getPoleOfInaccessibility3d = function (transform) {
33604 var pole2d = this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));
33605 return transform.unprojectBasic(pole2d, 200);
33608 RectGeometry.prototype.getTriangles3d = function (transform) {
33609 return transform.fullPano ?
33611 this._triangulate(this._project(this._getPoints2d(), transform), this.getPoints3d(transform));
33614 * Check if a particular bottom-right value is valid according to the current
33615 * rectangle coordinates.
33617 * @param {Array<number>} bottomRight - The bottom-right coordinates to validate
33618 * @returns {boolean} Value indicating whether the provided bottom-right coordinates
33622 RectGeometry.prototype.validate = function (bottomRight) {
33623 var rect = this._rect;
33624 if (!this._inverted && bottomRight[0] < rect[0] ||
33625 bottomRight[0] - rect[2] > 0.25 ||
33626 bottomRight[1] < rect[1]) {
33632 * Get the 2D coordinates for the vertices of the rectangle with
33633 * interpolated points along the lines.
33635 * @returns {Array<Array<number>>} Polygon array of 2D basic coordinates
33636 * representing the rectangle.
33638 RectGeometry.prototype._getPoints2d = function () {
33639 var vertices2d = this._rectToVertices2d(this._rect);
33640 var sides = vertices2d.length - 1;
33643 for (var i = 0; i < sides; ++i) {
33644 var startX = vertices2d[i][0];
33645 var startY = vertices2d[i][1];
33646 var endX = vertices2d[i + 1][0];
33647 var endY = vertices2d[i + 1][1];
33648 var intervalX = (endX - startX) / (sections - 1);
33649 var intervalY = (endY - startY) / (sections - 1);
33650 for (var j = 0; j < sections; ++j) {
33652 startX + j * intervalX,
33653 startY + j * intervalY,
33655 points2d.push(point);
33661 * Convert the top-left, bottom-right representation of a rectangle to a polygon
33662 * representation of the vertices starting at the bottom-left corner going
33665 * @description The method shifts the right side coordinates of the rectangle
33666 * by one unit to ensure that the vertices are ordered clockwise.
33668 * @param {Array<number>} rect - Top-left, bottom-right representation of a
33670 * @returns {Array<Array<number>>} Polygon representation of the vertices of the
33673 RectGeometry.prototype._rectToVertices2d = function (rect) {
33675 [rect[0], rect[3]],
33676 [rect[0], rect[1]],
33677 [this._inverted ? rect[2] + 1 : rect[2], rect[1]],
33678 [this._inverted ? rect[2] + 1 : rect[2], rect[3]],
33679 [rect[0], rect[3]],
33683 * Convert the top-left, bottom-right representation of a rectangle to a polygon
33684 * representation of the vertices starting at the bottom-left corner going
33687 * @description The first vertex represents the bottom-left corner with the rest of
33688 * the vertices following in clockwise order. The coordinates will not be shifted
33689 * to ensure that the vertices are ordered clockwise when layed out on the plane.
33691 * @param {Array<number>} rect - Top-left, bottom-right representation of a
33693 * @returns {Array<Array<number>>} Polygon representation of the vertices of the
33696 RectGeometry.prototype._rectToNonAdjustedVertices2d = function (rect) {
33698 [rect[0], rect[3]],
33699 [rect[0], rect[1]],
33700 [rect[2], rect[1]],
33701 [rect[2], rect[3]],
33702 [rect[0], rect[3]],
33705 return RectGeometry;
33706 }(Component_1.VertexGeometry));
33707 exports.RectGeometry = RectGeometry;
33708 exports.default = RectGeometry;
33710 },{"../../../Component":275}],356:[function(require,module,exports){
33712 var __extends = (this && this.__extends) || (function () {
33713 var extendStatics = function (d, b) {
33714 extendStatics = Object.setPrototypeOf ||
33715 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33716 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33717 return extendStatics(d, b);
33719 return function (d, b) {
33720 extendStatics(d, b);
33721 function __() { this.constructor = d; }
33722 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33725 Object.defineProperty(exports, "__esModule", { value: true });
33726 var earcut_1 = require("earcut");
33727 var martinez = require("martinez-polygon-clipping");
33728 var polylabel = require("@mapbox/polylabel");
33729 var THREE = require("three");
33730 var Component_1 = require("../../../Component");
33732 * @class VertexGeometry
33734 * @classdesc Represents a vertex geometry.
33736 var VertexGeometry = /** @class */ (function (_super) {
33737 __extends(VertexGeometry, _super);
33739 * Create a vertex geometry.
33744 function VertexGeometry() {
33745 var _this = _super.call(this) || this;
33746 _this._subsampleThreshold = 0.005;
33750 * Finds the polygon pole of inaccessibility, the most distant internal
33751 * point from the polygon outline.
33753 * @param {Array<Array<number>>} points2d - 2d points of outline to triangulate.
33754 * @returns {Array<number>} Point of inaccessibility.
33757 VertexGeometry.prototype._getPoleOfInaccessibility2d = function (points2d) {
33758 var pole2d = polylabel([points2d], 3e-2);
33761 VertexGeometry.prototype._project = function (points2d, transform) {
33762 var camera = this._createCamera(transform.upVector().toArray(), transform.unprojectSfM([0, 0], 0), transform.unprojectSfM([0, 0], 10));
33763 return this._deunproject(points2d, transform, camera);
33765 VertexGeometry.prototype._subsample = function (points2d, threshold) {
33766 if (threshold === void 0) { threshold = this._subsampleThreshold; }
33767 var subsampled = [];
33768 var length = points2d.length;
33769 for (var index = 0; index < length; index++) {
33770 var p1 = points2d[index];
33771 var p2 = points2d[(index + 1) % length];
33772 subsampled.push(p1);
33773 var dist = Math.sqrt(Math.pow((p2[0] - p1[0]), 2) + Math.pow((p2[1] - p1[1]), 2));
33774 var subsamples = Math.floor(dist / threshold);
33775 var coeff = 1 / (subsamples + 1);
33776 for (var i = 1; i <= subsamples; i++) {
33777 var alpha = i * coeff;
33779 (1 - alpha) * p1[0] + alpha * p2[0],
33780 (1 - alpha) * p1[1] + alpha * p2[1],
33782 subsampled.push(subsample);
33788 * Triangulates a 2d polygon and returns the triangle
33789 * representation as a flattened array of 3d points.
33791 * @param {Array<Array<number>>} points2d - 2d points of outline to triangulate.
33792 * @param {Array<Array<number>>} points3d - 3d points of outline corresponding to the 2d points.
33793 * @param {Array<Array<Array<number>>>} [holes2d] - 2d points of holes to triangulate.
33794 * @param {Array<Array<Array<number>>>} [holes3d] - 3d points of holes corresponding to the 2d points.
33795 * @returns {Array<number>} Flattened array of 3d points ordered based on the triangles.
33798 VertexGeometry.prototype._triangulate = function (points2d, points3d, holes2d, holes3d) {
33799 var data = [points2d.slice(0, -1)];
33800 for (var _i = 0, _a = holes2d != null ? holes2d : []; _i < _a.length; _i++) {
33801 var hole2d = _a[_i];
33802 data.push(hole2d.slice(0, -1));
33804 var points = points3d.slice(0, -1);
33805 for (var _b = 0, _c = holes3d != null ? holes3d : []; _b < _c.length; _b++) {
33806 var hole3d = _c[_b];
33807 points = points.concat(hole3d.slice(0, -1));
33809 var flattened = earcut_1.default.flatten(data);
33810 var indices = earcut_1.default(flattened.vertices, flattened.holes, flattened.dimensions);
33811 var triangles = [];
33812 for (var i = 0; i < indices.length; ++i) {
33813 var point = points[indices[i]];
33814 triangles.push(point[0]);
33815 triangles.push(point[1]);
33816 triangles.push(point[2]);
33820 VertexGeometry.prototype._triangulatePano = function (points2d, holes2d, transform) {
33821 var triangles = [];
33822 var epsilon = 1e-9;
33825 for (var x = 0; x < subareasX; x++) {
33826 for (var y = 0; y < subareasY; y++) {
33827 var epsilonX0 = x === 0 ? -epsilon : epsilon;
33828 var epsilonY0 = y === 0 ? -epsilon : epsilon;
33829 var x0 = x / subareasX + epsilonX0;
33830 var y0 = y / subareasY + epsilonY0;
33831 var x1 = (x + 1) / subareasX + epsilon;
33832 var y1 = (y + 1) / subareasY + epsilon;
33841 (2 * x + 1) / (2 * subareasX),
33842 (2 * y + 1) / (2 * subareasY),
33844 triangles.push.apply(triangles, this._triangulateSubarea(points2d, holes2d, bbox2d, lookat2d, transform));
33849 VertexGeometry.prototype._unproject = function (points2d, transform, distance) {
33850 if (distance === void 0) { distance = 200; }
33852 .map(function (point) {
33853 return transform.unprojectBasic(point, distance);
33856 VertexGeometry.prototype._createCamera = function (upVector, position, lookAt) {
33857 var camera = new THREE.Camera();
33858 camera.up.copy(new THREE.Vector3().fromArray(upVector));
33859 camera.position.copy(new THREE.Vector3().fromArray(position));
33860 camera.lookAt(new THREE.Vector3().fromArray(lookAt));
33861 camera.updateMatrix();
33862 camera.updateMatrixWorld(true);
33865 VertexGeometry.prototype._deunproject = function (points2d, transform, camera) {
33867 .map(function (point2d) {
33868 var pointWorld = transform.unprojectBasic(point2d, 10000);
33869 var pointCamera = new THREE.Vector3(pointWorld[0], pointWorld[1], pointWorld[2])
33870 .applyMatrix4(camera.matrixWorldInverse);
33871 return [pointCamera.x / pointCamera.z, pointCamera.y / pointCamera.z];
33874 VertexGeometry.prototype._triangulateSubarea = function (points2d, holes2d, bbox2d, lookat2d, transform) {
33875 var intersections = martinez.intersection([points2d].concat(holes2d), [bbox2d]);
33876 if (!intersections) {
33879 var triangles = [];
33880 var threshold = this._subsampleThreshold;
33881 var camera = this._createCamera(transform.upVector().toArray(), transform.unprojectSfM([0, 0], 0), transform.unprojectBasic(lookat2d, 10));
33882 for (var _i = 0, intersections_1 = intersections; _i < intersections_1.length; _i++) {
33883 var intersection = intersections_1[_i];
33884 var subsampledPolygon2d = this._subsample(intersection[0], threshold);
33885 var polygon2d = this._deunproject(subsampledPolygon2d, transform, camera);
33886 var polygon3d = this._unproject(subsampledPolygon2d, transform);
33887 var polygonHoles2d = [];
33888 var polygonHoles3d = [];
33889 for (var i = 1; i < intersection.length; i++) {
33890 var subsampledHole2d = this._subsample(intersection[i], threshold);
33891 var hole2d = this._deunproject(subsampledHole2d, transform, camera);
33892 var hole3d = this._unproject(subsampledHole2d, transform);
33893 polygonHoles2d.push(hole2d);
33894 polygonHoles3d.push(hole3d);
33896 triangles.push.apply(triangles, this._triangulate(polygon2d, polygon3d, polygonHoles2d, polygonHoles3d));
33900 return VertexGeometry;
33901 }(Component_1.Geometry));
33902 exports.VertexGeometry = VertexGeometry;
33903 exports.default = VertexGeometry;
33905 },{"../../../Component":275,"@mapbox/polylabel":1,"earcut":8,"martinez-polygon-clipping":22,"three":226}],357:[function(require,module,exports){
33907 var __extends = (this && this.__extends) || (function () {
33908 var extendStatics = function (d, b) {
33909 extendStatics = Object.setPrototypeOf ||
33910 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33911 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33912 return extendStatics(d, b);
33914 return function (d, b) {
33915 extendStatics(d, b);
33916 function __() { this.constructor = d; }
33917 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33920 Object.defineProperty(exports, "__esModule", { value: true });
33921 var operators_1 = require("rxjs/operators");
33922 var rxjs_1 = require("rxjs");
33923 var Component_1 = require("../../../Component");
33924 var CreateHandlerBase = /** @class */ (function (_super) {
33925 __extends(CreateHandlerBase, _super);
33926 function CreateHandlerBase(component, container, navigator, viewportCoords, tagCreator) {
33927 var _this = _super.call(this, component, container, navigator, viewportCoords) || this;
33928 _this._tagCreator = tagCreator;
33929 _this._geometryCreated$ = new rxjs_1.Subject();
33932 Object.defineProperty(CreateHandlerBase.prototype, "geometryCreated$", {
33934 return this._geometryCreated$;
33939 CreateHandlerBase.prototype._enable = function () {
33940 this._enableCreate();
33941 this._container.element.classList.add("component-tag-create");
33943 CreateHandlerBase.prototype._disable = function () {
33944 this._container.element.classList.remove("component-tag-create");
33945 this._disableCreate();
33947 CreateHandlerBase.prototype._validateBasic = function (basic) {
33950 return 0 <= x && x <= 1 && 0 <= y && y <= 1;
33952 CreateHandlerBase.prototype._mouseEventToBasic$ = function (mouseEvent$) {
33954 return mouseEvent$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
33955 var event = _a[0], camera = _a[1], transform = _a[2];
33956 return _this._mouseEventToBasic(event, _this._container.element, camera, transform);
33959 return CreateHandlerBase;
33960 }(Component_1.TagHandlerBase));
33961 exports.CreateHandlerBase = CreateHandlerBase;
33962 exports.default = CreateHandlerBase;
33964 },{"../../../Component":275,"rxjs":27,"rxjs/operators":225}],358:[function(require,module,exports){
33966 var __extends = (this && this.__extends) || (function () {
33967 var extendStatics = function (d, b) {
33968 extendStatics = Object.setPrototypeOf ||
33969 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33970 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33971 return extendStatics(d, b);
33973 return function (d, b) {
33974 extendStatics(d, b);
33975 function __() { this.constructor = d; }
33976 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33979 Object.defineProperty(exports, "__esModule", { value: true });
33980 var operators_1 = require("rxjs/operators");
33981 var Component_1 = require("../../../Component");
33982 var CreatePointHandler = /** @class */ (function (_super) {
33983 __extends(CreatePointHandler, _super);
33984 function CreatePointHandler() {
33985 return _super !== null && _super.apply(this, arguments) || this;
33987 CreatePointHandler.prototype._enableCreate = function () {
33988 this._container.mouseService.deferPixels(this._name, 4);
33989 this._geometryCreatedSubscription = this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(operators_1.filter(this._validateBasic), operators_1.map(function (basic) {
33990 return new Component_1.PointGeometry(basic);
33992 .subscribe(this._geometryCreated$);
33994 CreatePointHandler.prototype._disableCreate = function () {
33995 this._container.mouseService.undeferPixels(this._name);
33996 this._geometryCreatedSubscription.unsubscribe();
33998 CreatePointHandler.prototype._getNameExtension = function () {
33999 return "create-point";
34001 return CreatePointHandler;
34002 }(Component_1.CreateHandlerBase));
34003 exports.CreatePointHandler = CreatePointHandler;
34004 exports.default = CreatePointHandler;
34006 },{"../../../Component":275,"rxjs/operators":225}],359:[function(require,module,exports){
34008 var __extends = (this && this.__extends) || (function () {
34009 var extendStatics = function (d, b) {
34010 extendStatics = Object.setPrototypeOf ||
34011 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34012 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34013 return extendStatics(d, b);
34015 return function (d, b) {
34016 extendStatics(d, b);
34017 function __() { this.constructor = d; }
34018 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34021 Object.defineProperty(exports, "__esModule", { value: true });
34022 var Component_1 = require("../../../Component");
34023 var CreatePolygonHandler = /** @class */ (function (_super) {
34024 __extends(CreatePolygonHandler, _super);
34025 function CreatePolygonHandler() {
34026 return _super !== null && _super.apply(this, arguments) || this;
34028 CreatePolygonHandler.prototype._addPoint = function (tag, basicPoint) {
34029 tag.addPoint(basicPoint);
34031 Object.defineProperty(CreatePolygonHandler.prototype, "_create$", {
34033 return this._tagCreator.createPolygon$;
34038 CreatePolygonHandler.prototype._getNameExtension = function () {
34039 return "create-polygon";
34041 CreatePolygonHandler.prototype._setVertex2d = function (tag, basicPoint, transform) {
34042 tag.geometry.setVertex2d(tag.geometry.polygon.length - 2, basicPoint, transform);
34044 return CreatePolygonHandler;
34045 }(Component_1.CreateVertexHandler));
34046 exports.CreatePolygonHandler = CreatePolygonHandler;
34047 exports.default = CreatePolygonHandler;
34049 },{"../../../Component":275}],360:[function(require,module,exports){
34051 var __extends = (this && this.__extends) || (function () {
34052 var extendStatics = function (d, b) {
34053 extendStatics = Object.setPrototypeOf ||
34054 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34055 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34056 return extendStatics(d, b);
34058 return function (d, b) {
34059 extendStatics(d, b);
34060 function __() { this.constructor = d; }
34061 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34064 Object.defineProperty(exports, "__esModule", { value: true });
34065 var rxjs_1 = require("rxjs");
34066 var operators_1 = require("rxjs/operators");
34067 var Component_1 = require("../../../Component");
34068 var CreateRectDragHandler = /** @class */ (function (_super) {
34069 __extends(CreateRectDragHandler, _super);
34070 function CreateRectDragHandler() {
34071 return _super !== null && _super.apply(this, arguments) || this;
34073 CreateRectDragHandler.prototype._enableCreate = function () {
34075 this._container.mouseService.claimMouse(this._name, 2);
34076 this._deleteSubscription = this._navigator.stateService.currentTransform$.pipe(operators_1.map(function (transform) { return null; }), operators_1.skip(1))
34077 .subscribe(this._tagCreator.delete$);
34078 this._createSubscription = this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name, this._container.mouseService.mouseDragStart$)).pipe(operators_1.filter(this._validateBasic))
34079 .subscribe(this._tagCreator.createRect$);
34080 this._initializeAnchorIndexingSubscription = this._tagCreator.tag$.pipe(operators_1.filter(function (tag) {
34083 .subscribe(function (tag) {
34084 tag.geometry.initializeAnchorIndexing();
34086 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) {
34087 var _b = _a[0], event = _b[0], camera = _b[1], transform = _a[1];
34088 return _this._mouseEventToBasic(event, _this._container.element, camera, transform);
34090 this._setVertexSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34092 rxjs_1.combineLatest(rxjs_1.of(tag), basicMouse$, _this._navigator.stateService.currentTransform$) :
34095 .subscribe(function (_a) {
34096 var tag = _a[0], basicPoint = _a[1], transform = _a[2];
34097 tag.geometry.setOppositeVertex2d(basicPoint, transform);
34099 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) {
34101 }), operators_1.share());
34102 this._addPointSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34104 rxjs_1.combineLatest(rxjs_1.of(tag), basicMouseDragEnd$) :
34107 .subscribe(function (_a) {
34108 var tag = _a[0], basicPoint = _a[1];
34109 var rectGeometry = tag.geometry;
34110 if (!rectGeometry.validate(basicPoint)) {
34111 basicPoint = rectGeometry.getNonAdjustedVertex2d(3);
34113 tag.addPoint(basicPoint);
34115 this._geometryCreatedSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34117 tag.created$.pipe(operators_1.map(function (t) {
34122 .subscribe(this._geometryCreated$);
34124 CreateRectDragHandler.prototype._disableCreate = function () {
34125 this._container.mouseService.unclaimMouse(this._name);
34126 this._tagCreator.delete$.next(null);
34127 this._addPointSubscription.unsubscribe();
34128 this._createSubscription.unsubscribe();
34129 this._deleteSubscription.unsubscribe();
34130 this._geometryCreatedSubscription.unsubscribe();
34131 this._initializeAnchorIndexingSubscription.unsubscribe();
34132 this._setVertexSubscription.unsubscribe();
34134 CreateRectDragHandler.prototype._getNameExtension = function () {
34135 return "create-rect-drag";
34137 return CreateRectDragHandler;
34138 }(Component_1.CreateHandlerBase));
34139 exports.CreateRectDragHandler = CreateRectDragHandler;
34140 exports.default = CreateRectDragHandler;
34142 },{"../../../Component":275,"rxjs":27,"rxjs/operators":225}],361:[function(require,module,exports){
34144 var __extends = (this && this.__extends) || (function () {
34145 var extendStatics = function (d, b) {
34146 extendStatics = Object.setPrototypeOf ||
34147 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34148 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34149 return extendStatics(d, b);
34151 return function (d, b) {
34152 extendStatics(d, b);
34153 function __() { this.constructor = d; }
34154 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34157 Object.defineProperty(exports, "__esModule", { value: true });
34158 var operators_1 = require("rxjs/operators");
34159 var Component_1 = require("../../../Component");
34160 var CreateRectHandler = /** @class */ (function (_super) {
34161 __extends(CreateRectHandler, _super);
34162 function CreateRectHandler() {
34163 return _super !== null && _super.apply(this, arguments) || this;
34165 Object.defineProperty(CreateRectHandler.prototype, "_create$", {
34167 return this._tagCreator.createRect$;
34172 CreateRectHandler.prototype._addPoint = function (tag, basicPoint) {
34173 var rectGeometry = tag.geometry;
34174 if (!rectGeometry.validate(basicPoint)) {
34175 basicPoint = rectGeometry.getNonAdjustedVertex2d(3);
34177 tag.addPoint(basicPoint);
34179 CreateRectHandler.prototype._enable = function () {
34180 _super.prototype._enable.call(this);
34181 this._initializeAnchorIndexingSubscription = this._tagCreator.tag$.pipe(operators_1.filter(function (tag) {
34184 .subscribe(function (tag) {
34185 tag.geometry.initializeAnchorIndexing();
34188 CreateRectHandler.prototype._disable = function () {
34189 _super.prototype._disable.call(this);
34190 this._initializeAnchorIndexingSubscription.unsubscribe();
34192 CreateRectHandler.prototype._getNameExtension = function () {
34193 return "create-rect";
34195 CreateRectHandler.prototype._setVertex2d = function (tag, basicPoint, transform) {
34196 tag.geometry.setOppositeVertex2d(basicPoint, transform);
34198 return CreateRectHandler;
34199 }(Component_1.CreateVertexHandler));
34200 exports.CreateRectHandler = CreateRectHandler;
34201 exports.default = CreateRectHandler;
34203 },{"../../../Component":275,"rxjs/operators":225}],362:[function(require,module,exports){
34205 var __extends = (this && this.__extends) || (function () {
34206 var extendStatics = function (d, b) {
34207 extendStatics = Object.setPrototypeOf ||
34208 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34209 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34210 return extendStatics(d, b);
34212 return function (d, b) {
34213 extendStatics(d, b);
34214 function __() { this.constructor = d; }
34215 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34218 Object.defineProperty(exports, "__esModule", { value: true });
34219 var rxjs_1 = require("rxjs");
34220 var operators_1 = require("rxjs/operators");
34221 var Component_1 = require("../../../Component");
34222 var CreateVertexHandler = /** @class */ (function (_super) {
34223 __extends(CreateVertexHandler, _super);
34224 function CreateVertexHandler() {
34225 return _super !== null && _super.apply(this, arguments) || this;
34227 CreateVertexHandler.prototype._enableCreate = function () {
34229 this._container.mouseService.deferPixels(this._name, 4);
34230 var transformChanged$ = this._navigator.stateService.currentTransform$.pipe(operators_1.map(function (transform) { }), operators_1.publishReplay(1), operators_1.refCount());
34231 this._deleteSubscription = transformChanged$.pipe(operators_1.skip(1))
34232 .subscribe(this._tagCreator.delete$);
34233 var basicClick$ = this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(operators_1.share());
34234 this._createSubscription = transformChanged$.pipe(operators_1.switchMap(function () {
34235 return basicClick$.pipe(operators_1.filter(_this._validateBasic), operators_1.take(1));
34237 .subscribe(this._create$);
34238 this._setVertexSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34240 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$) :
34243 .subscribe(function (_a) {
34244 var tag = _a[0], event = _a[1], camera = _a[2], transform = _a[3];
34245 var basicPoint = _this._mouseEventToBasic(event, _this._container.element, camera, transform);
34246 _this._setVertex2d(tag, basicPoint, transform);
34248 this._addPointSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34250 rxjs_1.combineLatest(rxjs_1.of(tag), basicClick$) :
34253 .subscribe(function (_a) {
34254 var tag = _a[0], basicPoint = _a[1];
34255 _this._addPoint(tag, basicPoint);
34257 this._geometryCreateSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34259 tag.created$.pipe(operators_1.map(function (t) {
34264 .subscribe(this._geometryCreated$);
34266 CreateVertexHandler.prototype._disableCreate = function () {
34267 this._container.mouseService.undeferPixels(this._name);
34268 this._tagCreator.delete$.next(null);
34269 this._addPointSubscription.unsubscribe();
34270 this._createSubscription.unsubscribe();
34271 this._deleteSubscription.unsubscribe();
34272 this._geometryCreateSubscription.unsubscribe();
34273 this._setVertexSubscription.unsubscribe();
34275 return CreateVertexHandler;
34276 }(Component_1.CreateHandlerBase));
34277 exports.CreateVertexHandler = CreateVertexHandler;
34278 exports.default = CreateVertexHandler;
34280 },{"../../../Component":275,"rxjs":27,"rxjs/operators":225}],363:[function(require,module,exports){
34282 var __extends = (this && this.__extends) || (function () {
34283 var extendStatics = function (d, b) {
34284 extendStatics = Object.setPrototypeOf ||
34285 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34286 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34287 return extendStatics(d, b);
34289 return function (d, b) {
34290 extendStatics(d, b);
34291 function __() { this.constructor = d; }
34292 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34295 Object.defineProperty(exports, "__esModule", { value: true });
34296 var rxjs_1 = require("rxjs");
34297 var operators_1 = require("rxjs/operators");
34298 var Component_1 = require("../../../Component");
34299 var EditVertexHandler = /** @class */ (function (_super) {
34300 __extends(EditVertexHandler, _super);
34301 function EditVertexHandler(component, container, navigator, viewportCoords, tagSet) {
34302 var _this = _super.call(this, component, container, navigator, viewportCoords) || this;
34303 _this._tagSet = tagSet;
34306 EditVertexHandler.prototype._enable = function () {
34308 var interaction$ = this._tagSet.changed$.pipe(operators_1.map(function (tagSet) {
34309 return tagSet.getAll();
34310 }), operators_1.switchMap(function (tags) {
34311 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
34312 return tag.interact$;
34314 }), operators_1.switchMap(function (interaction) {
34315 return rxjs_1.concat(rxjs_1.of(interaction), _this._container.mouseService.documentMouseUp$.pipe(operators_1.map(function () {
34316 return { offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: null };
34317 }), operators_1.first()));
34318 }), operators_1.share());
34319 var mouseMove$ = rxjs_1.merge(this._container.mouseService.mouseMove$, this._container.mouseService.domMouseMove$).pipe(operators_1.share());
34320 this._claimMouseSubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
34321 return !!interaction.tag ? _this._container.mouseService.domMouseDragStart$ : rxjs_1.empty();
34323 .subscribe(function () {
34324 _this._container.mouseService.claimMouse(_this._name, 3);
34326 this._cursorSubscription = interaction$.pipe(operators_1.map(function (interaction) {
34327 return interaction.cursor;
34328 }), operators_1.distinctUntilChanged())
34329 .subscribe(function (cursor) {
34330 var interactionCursors = ["crosshair", "move", "nesw-resize", "nwse-resize"];
34331 for (var _i = 0, interactionCursors_1 = interactionCursors; _i < interactionCursors_1.length; _i++) {
34332 var interactionCursor = interactionCursors_1[_i];
34333 _this._container.element.classList.remove("component-tag-edit-" + interactionCursor);
34336 _this._container.element.classList.add("component-tag-edit-" + cursor);
34339 this._unclaimMouseSubscription = this._container.mouseService
34340 .filtered$(this._name, this._container.mouseService.domMouseDragEnd$)
34341 .subscribe(function (e) {
34342 _this._container.mouseService.unclaimMouse(_this._name);
34344 this._preventDefaultSubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
34345 return !!interaction.tag ?
34346 _this._container.mouseService.documentMouseMove$ :
34349 .subscribe(function (event) {
34350 event.preventDefault(); // prevent selection of content outside the viewer
34352 this._updateGeometrySubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
34353 if (interaction.operation === Component_1.TagOperation.None || !interaction.tag) {
34354 return rxjs_1.empty();
34356 var mouseDrag$ = _this._container.mouseService
34357 .filtered$(_this._name, _this._container.mouseService.domMouseDrag$).pipe(operators_1.filter(function (event) {
34358 return _this._viewportCoords.insideElement(event, _this._container.element);
34360 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) {
34361 var event = _a[0], render = _a[1];
34362 return [event, render, i, transform];
34365 .subscribe(function (_a) {
34366 var mouseEvent = _a[0], renderCamera = _a[1], interaction = _a[2], transform = _a[3];
34367 var basic = _this._mouseEventToBasic(mouseEvent, _this._container.element, renderCamera, transform, interaction.offsetX, interaction.offsetY);
34368 var geometry = interaction.tag.geometry;
34369 if (interaction.operation === Component_1.TagOperation.Centroid) {
34370 geometry.setCentroid2d(basic, transform);
34372 else if (interaction.operation === Component_1.TagOperation.Vertex) {
34373 geometry.setVertex2d(interaction.vertexIndex, basic, transform);
34377 EditVertexHandler.prototype._disable = function () {
34378 this._claimMouseSubscription.unsubscribe();
34379 this._cursorSubscription.unsubscribe();
34380 this._preventDefaultSubscription.unsubscribe();
34381 this._unclaimMouseSubscription.unsubscribe();
34382 this._updateGeometrySubscription.unsubscribe();
34384 EditVertexHandler.prototype._getNameExtension = function () {
34385 return "edit-vertex";
34387 return EditVertexHandler;
34388 }(Component_1.TagHandlerBase));
34389 exports.EditVertexHandler = EditVertexHandler;
34390 exports.default = EditVertexHandler;
34393 },{"../../../Component":275,"rxjs":27,"rxjs/operators":225}],364:[function(require,module,exports){
34395 var __extends = (this && this.__extends) || (function () {
34396 var extendStatics = function (d, b) {
34397 extendStatics = Object.setPrototypeOf ||
34398 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34399 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34400 return extendStatics(d, b);
34402 return function (d, b) {
34403 extendStatics(d, b);
34404 function __() { this.constructor = d; }
34405 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34408 Object.defineProperty(exports, "__esModule", { value: true });
34409 var Component_1 = require("../../../Component");
34410 var TagHandlerBase = /** @class */ (function (_super) {
34411 __extends(TagHandlerBase, _super);
34412 function TagHandlerBase(component, container, navigator, viewportCoords) {
34413 var _this = _super.call(this, component, container, navigator) || this;
34414 _this._name = _this._component.name + "-" + _this._getNameExtension();
34415 _this._viewportCoords = viewportCoords;
34418 TagHandlerBase.prototype._getConfiguration = function (enable) {
34421 TagHandlerBase.prototype._mouseEventToBasic = function (event, element, camera, transform, offsetX, offsetY) {
34422 offsetX = offsetX != null ? offsetX : 0;
34423 offsetY = offsetY != null ? offsetY : 0;
34424 var _a = this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
34425 var basic = this._viewportCoords.canvasToBasic(canvasX - offsetX, canvasY - offsetY, element, transform, camera.perspective);
34428 return TagHandlerBase;
34429 }(Component_1.HandlerBase));
34430 exports.TagHandlerBase = TagHandlerBase;
34431 exports.default = TagHandlerBase;
34434 },{"../../../Component":275}],365:[function(require,module,exports){
34436 Object.defineProperty(exports, "__esModule", { value: true });
34437 var operators_1 = require("rxjs/operators");
34438 var THREE = require("three");
34439 var vd = require("virtual-dom");
34440 var rxjs_1 = require("rxjs");
34441 var Component_1 = require("../../../Component");
34442 var Geo_1 = require("../../../Geo");
34443 var OutlineCreateTag = /** @class */ (function () {
34444 function OutlineCreateTag(geometry, options, transform, viewportCoords) {
34446 this._geometry = geometry;
34447 this._options = { color: options.color == null ? 0xFFFFFF : options.color };
34448 this._transform = transform;
34449 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
34450 this._outline = this._createOutine();
34451 this._glObjects = [this._outline];
34452 this._aborted$ = new rxjs_1.Subject();
34453 this._created$ = new rxjs_1.Subject();
34454 this._glObjectsChanged$ = new rxjs_1.Subject();
34455 this._geometryChangedSubscription = this._geometry.changed$
34456 .subscribe(function (vertexGeometry) {
34457 _this._disposeOutline();
34458 _this._outline = _this._createOutine();
34459 _this._glObjects = [_this._outline];
34460 _this._glObjectsChanged$.next(_this);
34463 Object.defineProperty(OutlineCreateTag.prototype, "geometry", {
34465 return this._geometry;
34470 Object.defineProperty(OutlineCreateTag.prototype, "glObjects", {
34472 return this._glObjects;
34477 Object.defineProperty(OutlineCreateTag.prototype, "aborted$", {
34479 return this._aborted$;
34484 Object.defineProperty(OutlineCreateTag.prototype, "created$", {
34486 return this._created$;
34491 Object.defineProperty(OutlineCreateTag.prototype, "glObjectsChanged$", {
34493 return this._glObjectsChanged$;
34498 Object.defineProperty(OutlineCreateTag.prototype, "geometryChanged$", {
34501 return this._geometry.changed$.pipe(operators_1.map(function (geometry) {
34508 OutlineCreateTag.prototype.dispose = function () {
34509 this._disposeOutline();
34510 this._geometryChangedSubscription.unsubscribe();
34512 OutlineCreateTag.prototype.getDOMObjects = function (camera, size) {
34516 offsetHeight: size.height, offsetWidth: size.width,
34518 var abort = function (e) {
34519 e.stopPropagation();
34520 _this._aborted$.next(_this);
34522 if (this._geometry instanceof Component_1.RectGeometry) {
34523 var anchorIndex = this._geometry.anchorIndex;
34524 var vertexIndex = anchorIndex === undefined ? 1 : anchorIndex;
34525 var _a = this._geometry.getVertex2d(vertexIndex), basicX = _a[0], basicY = _a[1];
34526 var canvasPoint = this._viewportCoords.basicToCanvasSafe(basicX, basicY, container, this._transform, camera);
34527 if (canvasPoint != null) {
34528 var background = this._colorToBackground(this._options.color);
34529 var transform = this._canvasToTransform(canvasPoint);
34530 var pointProperties = {
34531 style: { background: background, transform: transform },
34533 var completerProperties = {
34535 style: { transform: transform },
34537 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
34538 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
34541 else if (this._geometry instanceof Component_1.PolygonGeometry) {
34542 var polygonGeometry_1 = this._geometry;
34543 var _b = polygonGeometry_1.getVertex2d(0), firstVertexBasicX = _b[0], firstVertexBasicY = _b[1];
34544 var firstVertexCanvas = this._viewportCoords.basicToCanvasSafe(firstVertexBasicX, firstVertexBasicY, container, this._transform, camera);
34545 if (firstVertexCanvas != null) {
34546 var firstOnclick = polygonGeometry_1.polygon.length > 4 ?
34548 e.stopPropagation();
34549 polygonGeometry_1.removeVertex2d(polygonGeometry_1.polygon.length - 2);
34550 _this._created$.next(_this);
34553 var transform = this._canvasToTransform(firstVertexCanvas);
34554 var completerProperties = {
34555 onclick: firstOnclick,
34556 style: { transform: transform },
34558 var firstClass = polygonGeometry_1.polygon.length > 4 ?
34561 vNodes.push(vd.h("div." + firstClass, completerProperties, []));
34563 if (polygonGeometry_1.polygon.length > 3) {
34564 var _c = polygonGeometry_1.getVertex2d(polygonGeometry_1.polygon.length - 3), lastVertexBasicX = _c[0], lastVertexBasicY = _c[1];
34565 var lastVertexCanvas = this._viewportCoords.basicToCanvasSafe(lastVertexBasicX, lastVertexBasicY, container, this._transform, camera);
34566 if (lastVertexCanvas != null) {
34567 var remove = function (e) {
34568 e.stopPropagation();
34569 polygonGeometry_1.removeVertex2d(polygonGeometry_1.polygon.length - 3);
34571 var transform = this._canvasToTransform(lastVertexCanvas);
34572 var completerProperties = {
34574 style: { transform: transform },
34576 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
34579 var verticesBasic = polygonGeometry_1.polygon.slice();
34580 verticesBasic.splice(-2, 2);
34581 for (var _i = 0, verticesBasic_1 = verticesBasic; _i < verticesBasic_1.length; _i++) {
34582 var vertexBasic = verticesBasic_1[_i];
34583 var vertexCanvas = this._viewportCoords.basicToCanvasSafe(vertexBasic[0], vertexBasic[1], container, this._transform, camera);
34584 if (vertexCanvas != null) {
34585 var background = this._colorToBackground(this._options.color);
34586 var transform = this._canvasToTransform(vertexCanvas);
34587 var pointProperties = {
34589 background: background,
34590 transform: transform,
34593 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
34599 OutlineCreateTag.prototype.addPoint = function (point) {
34600 if (this._geometry instanceof Component_1.RectGeometry) {
34601 var rectGeometry = this._geometry;
34602 if (!rectGeometry.validate(point)) {
34605 this._created$.next(this);
34607 else if (this._geometry instanceof Component_1.PolygonGeometry) {
34608 var polygonGeometry = this._geometry;
34609 polygonGeometry.addVertex2d(point);
34612 OutlineCreateTag.prototype._canvasToTransform = function (canvas) {
34613 var canvasX = Math.round(canvas[0]);
34614 var canvasY = Math.round(canvas[1]);
34615 var transform = "translate(-50%,-50%) translate(" + canvasX + "px," + canvasY + "px)";
34618 OutlineCreateTag.prototype._colorToBackground = function (color) {
34619 return "#" + ("000000" + color.toString(16)).substr(-6);
34621 OutlineCreateTag.prototype._createOutine = function () {
34622 var polygon3d = this._geometry instanceof Component_1.RectGeometry ?
34623 this._geometry.getPoints3d(this._transform) :
34624 this._geometry.getVertices3d(this._transform);
34625 var positions = this._getLinePositions(polygon3d);
34626 var geometry = new THREE.BufferGeometry();
34627 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
34628 var material = new THREE.LineBasicMaterial({
34629 color: this._options.color,
34632 return new THREE.Line(geometry, material);
34634 OutlineCreateTag.prototype._disposeOutline = function () {
34635 if (this._outline == null) {
34638 var line = this._outline;
34639 line.geometry.dispose();
34640 line.material.dispose();
34641 this._outline = null;
34642 this._glObjects = [];
34644 OutlineCreateTag.prototype._getLinePositions = function (polygon3d) {
34645 var length = polygon3d.length;
34646 var positions = new Float32Array(length * 3);
34647 for (var i = 0; i < length; ++i) {
34649 var position = polygon3d[i];
34650 positions[index] = position[0];
34651 positions[index + 1] = position[1];
34652 positions[index + 2] = position[2];
34656 return OutlineCreateTag;
34658 exports.OutlineCreateTag = OutlineCreateTag;
34659 exports.default = OutlineCreateTag;
34662 },{"../../../Component":275,"../../../Geo":278,"rxjs":27,"rxjs/operators":225,"three":226,"virtual-dom":231}],366:[function(require,module,exports){
34664 var __extends = (this && this.__extends) || (function () {
34665 var extendStatics = function (d, b) {
34666 extendStatics = Object.setPrototypeOf ||
34667 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34668 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34669 return extendStatics(d, b);
34671 return function (d, b) {
34672 extendStatics(d, b);
34673 function __() { this.constructor = d; }
34674 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34677 Object.defineProperty(exports, "__esModule", { value: true });
34678 var THREE = require("three");
34679 var vd = require("virtual-dom");
34680 var Component_1 = require("../../../Component");
34682 * @class OutlineRenderTag
34683 * @classdesc Tag visualizing the properties of an OutlineTag.
34685 var OutlineRenderTag = /** @class */ (function (_super) {
34686 __extends(OutlineRenderTag, _super);
34687 function OutlineRenderTag(tag, transform) {
34688 var _this = _super.call(this, tag, transform) || this;
34689 _this._fill = !transform.gpano ?
34690 _this._createFill() :
34691 transform.fullPano &&
34692 tag.domain === Component_1.TagDomain.TwoDimensional &&
34693 tag.geometry instanceof Component_1.PolygonGeometry ?
34694 _this._createFill() :
34696 _this._holes = _this._tag.lineWidth >= 1 ?
34697 _this._createHoles() :
34699 _this._outline = _this._tag.lineWidth >= 1 ?
34700 _this._createOutline() :
34702 _this._geometryChangedSubscription = _this._tag.geometry.changed$
34703 .subscribe(function () {
34704 if (_this._fill != null) {
34705 _this._updateFillGeometry();
34707 if (_this._holes.length > 0) {
34708 _this._updateHoleGeometries();
34710 if (_this._outline != null) {
34711 _this._updateOulineGeometry();
34714 _this._changedSubscription = _this._tag.changed$
34715 .subscribe(function () {
34716 var glObjectsChanged = false;
34717 if (_this._fill != null) {
34718 _this._updateFillMaterial(_this._fill.material);
34720 if (_this._outline == null) {
34721 if (_this._tag.lineWidth >= 1) {
34722 _this._holes = _this._createHoles();
34723 _this._outline = _this._createOutline();
34724 glObjectsChanged = true;
34728 _this._updateHoleMaterials();
34729 _this._updateOutlineMaterial();
34731 if (glObjectsChanged) {
34732 _this._glObjectsChanged$.next(_this);
34737 OutlineRenderTag.prototype.dispose = function () {
34738 this._disposeFill();
34739 this._disposeHoles();
34740 this._disposeOutline();
34741 this._changedSubscription.unsubscribe();
34742 this._geometryChangedSubscription.unsubscribe();
34744 OutlineRenderTag.prototype.getDOMObjects = function (atlas, camera, size) {
34747 var isRect = this._tag.geometry instanceof Component_1.RectGeometry;
34748 var isPerspective = !this._transform.gpano;
34750 offsetHeight: size.height, offsetWidth: size.width,
34752 if (this._tag.icon != null && (isRect || isPerspective)) {
34753 var _a = this._tag.geometry instanceof Component_1.RectGeometry ?
34754 this._tag.geometry.getVertex2d(this._tag.iconIndex) :
34755 this._tag.geometry.getPoleOfInaccessibility2d(), iconBasicX = _a[0], iconBasicY = _a[1];
34756 var iconCanvas = this._viewportCoords.basicToCanvasSafe(iconBasicX, iconBasicY, container, this._transform, camera);
34757 if (iconCanvas != null) {
34758 var interact = function (e) {
34759 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
34761 if (atlas.loaded) {
34762 var sprite = atlas.getDOMSprite(this._tag.icon, this._tag.iconFloat);
34763 var iconCanvasX = Math.round(iconCanvas[0]);
34764 var iconCanvasY = Math.round(iconCanvas[1]);
34765 var transform = "translate(" + iconCanvasX + "px," + iconCanvasY + "px)";
34766 var click = function (e) {
34767 e.stopPropagation();
34768 _this._tag.click$.next(_this._tag);
34772 onmousedown: interact,
34773 style: { transform: transform },
34775 vNodes.push(vd.h("div.TagSymbol", properties, [sprite]));
34779 else if (this._tag.text != null && (isRect || isPerspective)) {
34780 var _b = this._tag.geometry instanceof Component_1.RectGeometry ?
34781 this._tag.geometry.getVertex2d(3) :
34782 this._tag.geometry.getPoleOfInaccessibility2d(), textBasicX = _b[0], textBasicY = _b[1];
34783 var textCanvas = this._viewportCoords.basicToCanvasSafe(textBasicX, textBasicY, container, this._transform, camera);
34784 if (textCanvas != null) {
34785 var textCanvasX = Math.round(textCanvas[0]);
34786 var textCanvasY = Math.round(textCanvas[1]);
34787 var transform = this._tag.geometry instanceof Component_1.RectGeometry ?
34788 "translate(" + textCanvasX + "px," + textCanvasY + "px)" :
34789 "translate(-50%, -50%) translate(" + textCanvasX + "px," + textCanvasY + "px)";
34790 var interact = function (e) {
34791 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
34794 onmousedown: interact,
34796 color: this._colorToCss(this._tag.textColor),
34797 transform: transform,
34799 textContent: this._tag.text,
34801 vNodes.push(vd.h("span.TagSymbol", properties, []));
34804 if (!this._tag.editable) {
34807 var lineColor = this._colorToCss(this._tag.lineColor);
34808 if (this._tag.geometry instanceof Component_1.RectGeometry) {
34809 var _c = this._tag.geometry.getCentroid2d(), centroidBasicX = _c[0], centroidBasicY = _c[1];
34810 var centroidCanvas = this._viewportCoords.basicToCanvasSafe(centroidBasicX, centroidBasicY, container, this._transform, camera);
34811 if (centroidCanvas != null) {
34812 var interact = this._interact(Component_1.TagOperation.Centroid, "move");
34813 var centroidCanvasX = Math.round(centroidCanvas[0]);
34814 var centroidCanvasY = Math.round(centroidCanvas[1]);
34815 var transform = "translate(-50%, -50%) translate(" + centroidCanvasX + "px," + centroidCanvasY + "px)";
34817 onmousedown: interact,
34818 style: { background: lineColor, transform: transform },
34820 vNodes.push(vd.h("div.TagMover", properties, []));
34823 var vertices2d = this._tag.geometry.getVertices2d();
34824 for (var i = 0; i < vertices2d.length - 1; i++) {
34826 ((this._tag.icon != null && i === this._tag.iconIndex) ||
34827 (this._tag.icon == null && this._tag.text != null && i === 3))) {
34830 var _d = vertices2d[i], vertexBasicX = _d[0], vertexBasicY = _d[1];
34831 var vertexCanvas = this._viewportCoords.basicToCanvasSafe(vertexBasicX, vertexBasicY, container, this._transform, camera);
34832 if (vertexCanvas == null) {
34835 var cursor = isRect ?
34836 i % 2 === 0 ? "nesw-resize" : "nwse-resize" :
34838 var interact = this._interact(Component_1.TagOperation.Vertex, cursor, i);
34839 var vertexCanvasX = Math.round(vertexCanvas[0]);
34840 var vertexCanvasY = Math.round(vertexCanvas[1]);
34841 var transform = "translate(-50%, -50%) translate(" + vertexCanvasX + "px," + vertexCanvasY + "px)";
34843 onmousedown: interact,
34844 style: { background: lineColor, transform: transform, cursor: cursor },
34846 vNodes.push(vd.h("div.TagResizer", properties, []));
34847 if (!this._tag.indicateVertices) {
34850 var pointProperties = {
34851 style: { background: lineColor, transform: transform },
34853 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
34857 OutlineRenderTag.prototype.getGLObjects = function () {
34858 var glObjects = [];
34859 if (this._fill != null) {
34860 glObjects.push(this._fill);
34862 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
34864 glObjects.push(hole);
34866 if (this._outline != null) {
34867 glObjects.push(this._outline);
34871 OutlineRenderTag.prototype.getRetrievableObjects = function () {
34872 return this._fill != null ? [this._fill] : [];
34874 OutlineRenderTag.prototype._colorToCss = function (color) {
34875 return "#" + ("000000" + color.toString(16)).substr(-6);
34877 OutlineRenderTag.prototype._createFill = function () {
34878 var triangles = this._getTriangles();
34879 var positions = new Float32Array(triangles);
34880 var geometry = new THREE.BufferGeometry();
34881 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
34882 geometry.computeBoundingSphere();
34883 var material = new THREE.MeshBasicMaterial({ side: THREE.DoubleSide, transparent: true });
34884 this._updateFillMaterial(material);
34885 return new THREE.Mesh(geometry, material);
34887 OutlineRenderTag.prototype._createHoles = function () {
34889 if (this._tag.geometry instanceof Component_1.PolygonGeometry) {
34890 var holes3d = this._getHoles3d();
34891 for (var _i = 0, holes3d_1 = holes3d; _i < holes3d_1.length; _i++) {
34892 var holePoints3d = holes3d_1[_i];
34893 var hole = this._createLine(holePoints3d);
34899 OutlineRenderTag.prototype._createLine = function (points3d) {
34900 var positions = this._getLinePositions(points3d);
34901 var geometry = new THREE.BufferGeometry();
34902 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
34903 geometry.computeBoundingSphere();
34904 var material = new THREE.LineBasicMaterial();
34905 this._updateLineBasicMaterial(material);
34906 var line = new THREE.Line(geometry, material);
34907 line.renderOrder = 1;
34910 OutlineRenderTag.prototype._createOutline = function () {
34911 return this._createLine(this._getPoints3d());
34913 OutlineRenderTag.prototype._disposeFill = function () {
34914 if (this._fill == null) {
34917 this._fill.geometry.dispose();
34918 this._fill.material.dispose();
34921 OutlineRenderTag.prototype._disposeHoles = function () {
34922 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
34924 hole.geometry.dispose();
34925 hole.material.dispose();
34929 OutlineRenderTag.prototype._disposeOutline = function () {
34930 if (this._outline == null) {
34933 this._outline.geometry.dispose();
34934 this._outline.material.dispose();
34935 this._outline = null;
34937 OutlineRenderTag.prototype._getLinePositions = function (points3d) {
34938 var length = points3d.length;
34939 var positions = new Float32Array(length * 3);
34940 for (var i = 0; i < length; ++i) {
34942 var position = points3d[i];
34943 positions[index + 0] = position[0];
34944 positions[index + 1] = position[1];
34945 positions[index + 2] = position[2];
34949 OutlineRenderTag.prototype._getHoles3d = function () {
34950 var polygonGeometry = this._tag.geometry;
34951 return this._in3dDomain() ?
34952 polygonGeometry.getHoleVertices3d(this._transform) :
34953 polygonGeometry.getHolePoints3d(this._transform);
34955 OutlineRenderTag.prototype._getPoints3d = function () {
34956 return this._in3dDomain() ?
34957 this._tag.geometry.getVertices3d(this._transform) :
34958 this._tag.geometry.getPoints3d(this._transform);
34960 OutlineRenderTag.prototype._getTriangles = function () {
34961 return this._in3dDomain() ?
34962 this._tag.geometry.get3dDomainTriangles3d(this._transform) :
34963 this._tag.geometry.getTriangles3d(this._transform);
34965 OutlineRenderTag.prototype._in3dDomain = function () {
34966 return this._tag.geometry instanceof Component_1.PolygonGeometry && this._tag.domain === Component_1.TagDomain.ThreeDimensional;
34968 OutlineRenderTag.prototype._interact = function (operation, cursor, vertexIndex) {
34970 return function (e) {
34971 var offsetX = e.offsetX - e.target.offsetWidth / 2;
34972 var offsetY = e.offsetY - e.target.offsetHeight / 2;
34973 _this._interact$.next({
34977 operation: operation,
34979 vertexIndex: vertexIndex,
34983 OutlineRenderTag.prototype._updateFillGeometry = function () {
34984 var triangles = this._getTriangles();
34985 var positions = new Float32Array(triangles);
34986 var geometry = this._fill.geometry;
34987 var attribute = geometry.getAttribute("position");
34988 if (attribute.array.length === positions.length) {
34989 attribute.set(positions);
34990 attribute.needsUpdate = true;
34993 geometry.removeAttribute("position");
34994 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
34996 geometry.computeBoundingSphere();
34998 OutlineRenderTag.prototype._updateFillMaterial = function (material) {
34999 material.color = new THREE.Color(this._tag.fillColor);
35000 material.opacity = this._tag.fillOpacity;
35001 material.needsUpdate = true;
35003 OutlineRenderTag.prototype._updateHoleGeometries = function () {
35004 var holes3d = this._getHoles3d();
35005 if (holes3d.length !== this._holes.length) {
35006 throw new Error("Changing the number of holes is not supported.");
35008 for (var i = 0; i < this._holes.length; i++) {
35009 var holePoints3d = holes3d[i];
35010 var hole = this._holes[i];
35011 this._updateLine(hole, holePoints3d);
35014 OutlineRenderTag.prototype._updateHoleMaterials = function () {
35015 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
35017 var material = hole.material;
35018 this._updateLineBasicMaterial(material);
35021 OutlineRenderTag.prototype._updateLine = function (line, points3d) {
35022 var positions = this._getLinePositions(points3d);
35023 var geometry = line.geometry;
35024 var attribute = geometry.getAttribute("position");
35025 attribute.set(positions);
35026 attribute.needsUpdate = true;
35027 geometry.computeBoundingSphere();
35029 OutlineRenderTag.prototype._updateOulineGeometry = function () {
35030 this._updateLine(this._outline, this._getPoints3d());
35032 OutlineRenderTag.prototype._updateOutlineMaterial = function () {
35033 var material = this._outline.material;
35034 this._updateLineBasicMaterial(material);
35036 OutlineRenderTag.prototype._updateLineBasicMaterial = function (material) {
35037 material.color = new THREE.Color(this._tag.lineColor);
35038 material.linewidth = Math.max(this._tag.lineWidth, 1);
35039 material.visible = this._tag.lineWidth >= 1 && this._tag.lineOpacity > 0;
35040 material.opacity = this._tag.lineOpacity;
35041 material.transparent = this._tag.lineOpacity < 1;
35042 material.needsUpdate = true;
35044 return OutlineRenderTag;
35045 }(Component_1.RenderTag));
35046 exports.OutlineRenderTag = OutlineRenderTag;
35049 },{"../../../Component":275,"three":226,"virtual-dom":231}],367:[function(require,module,exports){
35051 var __extends = (this && this.__extends) || (function () {
35052 var extendStatics = function (d, b) {
35053 extendStatics = Object.setPrototypeOf ||
35054 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35055 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35056 return extendStatics(d, b);
35058 return function (d, b) {
35059 extendStatics(d, b);
35060 function __() { this.constructor = d; }
35061 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35064 Object.defineProperty(exports, "__esModule", { value: true });
35065 var rxjs_1 = require("rxjs");
35066 var Component_1 = require("../../../Component");
35067 var Viewer_1 = require("../../../Viewer");
35069 * @class OutlineTag
35071 * @classdesc Tag holding properties for visualizing a geometry outline.
35075 * var geometry = new Mapillary.TagComponent.RectGeometry([0.3, 0.3, 0.5, 0.4]);
35076 * var tag = new Mapillary.TagComponent.OutlineTag(
35079 * { editable: true, lineColor: 0xff0000 });
35081 * tagComponent.add([tag]);
35084 var OutlineTag = /** @class */ (function (_super) {
35085 __extends(OutlineTag, _super);
35087 * Create an outline tag.
35091 * @param {string} id - Unique identifier of the tag.
35092 * @param {VertexGeometry} geometry - Geometry defining vertices of tag.
35093 * @param {IOutlineTagOptions} options - Options defining the visual appearance and
35094 * behavior of the outline tag.
35096 function OutlineTag(id, geometry, options) {
35097 var _this = _super.call(this, id, geometry) || this;
35098 options = !!options ? options : {};
35099 var domain = options.domain != null && geometry instanceof Component_1.PolygonGeometry ?
35100 options.domain : Component_1.TagDomain.TwoDimensional;
35101 var twoDimensionalPolygon = _this._twoDimensionalPolygon(domain, geometry);
35102 _this._domain = domain;
35103 _this._editable = options.editable == null || twoDimensionalPolygon ? false : options.editable;
35104 _this._fillColor = options.fillColor == null ? 0xFFFFFF : options.fillColor;
35105 _this._fillOpacity = options.fillOpacity == null ? 0.0 : options.fillOpacity;
35106 _this._icon = options.icon === undefined ? null : options.icon;
35107 _this._iconFloat = options.iconFloat == null ? Viewer_1.Alignment.Center : options.iconFloat;
35108 _this._iconIndex = options.iconIndex == null ? 3 : options.iconIndex;
35109 _this._indicateVertices = options.indicateVertices == null ? true : options.indicateVertices;
35110 _this._lineColor = options.lineColor == null ? 0xFFFFFF : options.lineColor;
35111 _this._lineOpacity = options.lineOpacity == null ? 1 : options.lineOpacity;
35112 _this._lineWidth = options.lineWidth == null ? 1 : options.lineWidth;
35113 _this._text = options.text === undefined ? null : options.text;
35114 _this._textColor = options.textColor == null ? 0xFFFFFF : options.textColor;
35115 _this._click$ = new rxjs_1.Subject();
35117 .subscribe(function (t) {
35118 _this.fire(OutlineTag.click, _this);
35122 Object.defineProperty(OutlineTag.prototype, "click$", {
35124 * Click observable.
35126 * @description An observable emitting the tag when the icon of the
35127 * tag has been clicked.
35129 * @returns {Observable<Tag>}
35132 return this._click$;
35137 Object.defineProperty(OutlineTag.prototype, "domain", {
35139 * Get domain property.
35141 * @description Readonly property that can only be set in constructor.
35143 * @returns Value indicating the domain of the tag.
35146 return this._domain;
35151 Object.defineProperty(OutlineTag.prototype, "editable", {
35153 * Get editable property.
35154 * @returns {boolean} Value indicating if tag is editable.
35157 return this._editable;
35160 * Set editable property.
35163 * @fires Tag#changed
35165 set: function (value) {
35166 if (this._twoDimensionalPolygon(this._domain, this._geometry)) {
35169 this._editable = value;
35170 this._notifyChanged$.next(this);
35175 Object.defineProperty(OutlineTag.prototype, "fillColor", {
35177 * Get fill color property.
35178 * @returns {number}
35181 return this._fillColor;
35184 * Set fill color property.
35187 * @fires Tag#changed
35189 set: function (value) {
35190 this._fillColor = value;
35191 this._notifyChanged$.next(this);
35196 Object.defineProperty(OutlineTag.prototype, "fillOpacity", {
35198 * Get fill opacity property.
35199 * @returns {number}
35202 return this._fillOpacity;
35205 * Set fill opacity property.
35208 * @fires Tag#changed
35210 set: function (value) {
35211 this._fillOpacity = value;
35212 this._notifyChanged$.next(this);
35217 Object.defineProperty(OutlineTag.prototype, "geometry", {
35220 return this._geometry;
35225 Object.defineProperty(OutlineTag.prototype, "icon", {
35227 * Get icon property.
35228 * @returns {string}
35234 * Set icon property.
35237 * @fires Tag#changed
35239 set: function (value) {
35240 this._icon = value;
35241 this._notifyChanged$.next(this);
35246 Object.defineProperty(OutlineTag.prototype, "iconFloat", {
35248 * Get icon float property.
35249 * @returns {Alignment}
35252 return this._iconFloat;
35255 * Set icon float property.
35256 * @param {Alignment}
35258 * @fires Tag#changed
35260 set: function (value) {
35261 this._iconFloat = value;
35262 this._notifyChanged$.next(this);
35267 Object.defineProperty(OutlineTag.prototype, "iconIndex", {
35269 * Get icon index property.
35270 * @returns {number}
35273 return this._iconIndex;
35276 * Set icon index property.
35279 * @fires Tag#changed
35281 set: function (value) {
35282 this._iconIndex = value;
35283 this._notifyChanged$.next(this);
35288 Object.defineProperty(OutlineTag.prototype, "indicateVertices", {
35290 * Get indicate vertices property.
35291 * @returns {boolean} Value indicating if vertices should be indicated
35292 * when tag is editable.
35295 return this._indicateVertices;
35298 * Set indicate vertices property.
35301 * @fires Tag#changed
35303 set: function (value) {
35304 this._indicateVertices = value;
35305 this._notifyChanged$.next(this);
35310 Object.defineProperty(OutlineTag.prototype, "lineColor", {
35312 * Get line color property.
35313 * @returns {number}
35316 return this._lineColor;
35319 * Set line color property.
35322 * @fires Tag#changed
35324 set: function (value) {
35325 this._lineColor = value;
35326 this._notifyChanged$.next(this);
35331 Object.defineProperty(OutlineTag.prototype, "lineOpacity", {
35333 * Get line opacity property.
35334 * @returns {number}
35337 return this._lineOpacity;
35340 * Set line opacity property.
35343 * @fires Tag#changed
35345 set: function (value) {
35346 this._lineOpacity = value;
35347 this._notifyChanged$.next(this);
35352 Object.defineProperty(OutlineTag.prototype, "lineWidth", {
35354 * Get line width property.
35355 * @returns {number}
35358 return this._lineWidth;
35361 * Set line width property.
35364 * @fires Tag#changed
35366 set: function (value) {
35367 this._lineWidth = value;
35368 this._notifyChanged$.next(this);
35373 Object.defineProperty(OutlineTag.prototype, "text", {
35375 * Get text property.
35376 * @returns {string}
35382 * Set text property.
35385 * @fires Tag#changed
35387 set: function (value) {
35388 this._text = value;
35389 this._notifyChanged$.next(this);
35394 Object.defineProperty(OutlineTag.prototype, "textColor", {
35396 * Get text color property.
35397 * @returns {number}
35400 return this._textColor;
35403 * Set text color property.
35406 * @fires Tag#changed
35408 set: function (value) {
35409 this._textColor = value;
35410 this._notifyChanged$.next(this);
35416 * Set options for tag.
35418 * @description Sets all the option properties provided and keeps
35419 * the rest of the values as is.
35421 * @param {IOutlineTagOptions} options - Outline tag options
35423 * @fires {Tag#changed}
35425 OutlineTag.prototype.setOptions = function (options) {
35426 var twoDimensionalPolygon = this._twoDimensionalPolygon(this._domain, this._geometry);
35427 this._editable = twoDimensionalPolygon || options.editable == null ? this._editable : options.editable;
35428 this._icon = options.icon === undefined ? this._icon : options.icon;
35429 this._iconFloat = options.iconFloat == null ? this._iconFloat : options.iconFloat;
35430 this._iconIndex = options.iconIndex == null ? this._iconIndex : options.iconIndex;
35431 this._indicateVertices = options.indicateVertices == null ? this._indicateVertices : options.indicateVertices;
35432 this._lineColor = options.lineColor == null ? this._lineColor : options.lineColor;
35433 this._lineWidth = options.lineWidth == null ? this._lineWidth : options.lineWidth;
35434 this._fillColor = options.fillColor == null ? this._fillColor : options.fillColor;
35435 this._fillOpacity = options.fillOpacity == null ? this._fillOpacity : options.fillOpacity;
35436 this._text = options.text === undefined ? this._text : options.text;
35437 this._textColor = options.textColor == null ? this._textColor : options.textColor;
35438 this._notifyChanged$.next(this);
35440 OutlineTag.prototype._twoDimensionalPolygon = function (domain, geometry) {
35441 return domain !== Component_1.TagDomain.ThreeDimensional && geometry instanceof Component_1.PolygonGeometry;
35444 * Event fired when the icon of the outline tag is clicked.
35446 * @event OutlineTag#click
35447 * @type {OutlineTag} The tag instance that was clicked.
35449 OutlineTag.click = "click";
35451 }(Component_1.Tag));
35452 exports.OutlineTag = OutlineTag;
35453 exports.default = OutlineTag;
35455 },{"../../../Component":275,"../../../Viewer":286,"rxjs":27}],368:[function(require,module,exports){
35457 Object.defineProperty(exports, "__esModule", { value: true });
35458 var rxjs_1 = require("rxjs");
35459 var Geo_1 = require("../../../Geo");
35460 var RenderTag = /** @class */ (function () {
35461 function RenderTag(tag, transform, viewportCoords) {
35463 this._transform = transform;
35464 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
35465 this._glObjectsChanged$ = new rxjs_1.Subject();
35466 this._interact$ = new rxjs_1.Subject();
35468 Object.defineProperty(RenderTag.prototype, "glObjectsChanged$", {
35470 return this._glObjectsChanged$;
35475 Object.defineProperty(RenderTag.prototype, "interact$", {
35477 return this._interact$;
35482 Object.defineProperty(RenderTag.prototype, "tag", {
35491 exports.RenderTag = RenderTag;
35492 exports.default = RenderTag;
35494 },{"../../../Geo":278,"rxjs":27}],369:[function(require,module,exports){
35496 var __extends = (this && this.__extends) || (function () {
35497 var extendStatics = function (d, b) {
35498 extendStatics = Object.setPrototypeOf ||
35499 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35500 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35501 return extendStatics(d, b);
35503 return function (d, b) {
35504 extendStatics(d, b);
35505 function __() { this.constructor = d; }
35506 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35509 Object.defineProperty(exports, "__esModule", { value: true });
35510 var vd = require("virtual-dom");
35511 var Component_1 = require("../../../Component");
35512 var Viewer_1 = require("../../../Viewer");
35514 * @class SpotRenderTag
35515 * @classdesc Tag visualizing the properties of a SpotTag.
35517 var SpotRenderTag = /** @class */ (function (_super) {
35518 __extends(SpotRenderTag, _super);
35519 function SpotRenderTag() {
35520 return _super !== null && _super.apply(this, arguments) || this;
35522 SpotRenderTag.prototype.dispose = function () { };
35523 SpotRenderTag.prototype.getDOMObjects = function (atlas, camera, size) {
35525 var tag = this._tag;
35527 offsetHeight: size.height, offsetWidth: size.width,
35530 var _a = tag.geometry.getCentroid2d(), centroidBasicX = _a[0], centroidBasicY = _a[1];
35531 var centroidCanvas = this._viewportCoords.basicToCanvasSafe(centroidBasicX, centroidBasicY, container, this._transform, camera);
35532 if (centroidCanvas != null) {
35533 var interactNone = function (e) {
35534 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: tag });
35536 var canvasX = Math.round(centroidCanvas[0]);
35537 var canvasY = Math.round(centroidCanvas[1]);
35538 if (tag.icon != null) {
35539 if (atlas.loaded) {
35540 var sprite = atlas.getDOMSprite(tag.icon, Viewer_1.Alignment.Bottom);
35541 var iconTransform = "translate(" + canvasX + "px," + (canvasY + 8) + "px)";
35543 onmousedown: interactNone,
35545 pointerEvents: "all",
35546 transform: iconTransform,
35549 vNodes.push(vd.h("div", properties, [sprite]));
35552 else if (tag.text != null) {
35553 var textTransform = "translate(-50%,0%) translate(" + canvasX + "px," + (canvasY + 8) + "px)";
35555 onmousedown: interactNone,
35557 color: this._colorToCss(tag.textColor),
35558 transform: textTransform,
35560 textContent: tag.text,
35562 vNodes.push(vd.h("span.TagSymbol", properties, []));
35564 var interact = this._interact(Component_1.TagOperation.Centroid, tag, "move");
35565 var background = this._colorToCss(tag.color);
35566 var transform = "translate(-50%,-50%) translate(" + canvasX + "px," + canvasY + "px)";
35567 if (tag.editable) {
35568 var interactorProperties = {
35569 onmousedown: interact,
35571 background: background,
35572 transform: transform,
35575 vNodes.push(vd.h("div.TagSpotInteractor", interactorProperties, []));
35577 var pointProperties = {
35579 background: background,
35580 transform: transform,
35583 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
35587 SpotRenderTag.prototype.getGLObjects = function () { return []; };
35588 SpotRenderTag.prototype.getRetrievableObjects = function () { return []; };
35589 SpotRenderTag.prototype._colorToCss = function (color) {
35590 return "#" + ("000000" + color.toString(16)).substr(-6);
35592 SpotRenderTag.prototype._interact = function (operation, tag, cursor, vertexIndex) {
35594 return function (e) {
35595 var offsetX = e.offsetX - e.target.offsetWidth / 2;
35596 var offsetY = e.offsetY - e.target.offsetHeight / 2;
35597 _this._interact$.next({
35601 operation: operation,
35603 vertexIndex: vertexIndex,
35607 return SpotRenderTag;
35608 }(Component_1.RenderTag));
35609 exports.SpotRenderTag = SpotRenderTag;
35612 },{"../../../Component":275,"../../../Viewer":286,"virtual-dom":231}],370:[function(require,module,exports){
35614 var __extends = (this && this.__extends) || (function () {
35615 var extendStatics = function (d, b) {
35616 extendStatics = Object.setPrototypeOf ||
35617 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35618 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35619 return extendStatics(d, b);
35621 return function (d, b) {
35622 extendStatics(d, b);
35623 function __() { this.constructor = d; }
35624 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35627 Object.defineProperty(exports, "__esModule", { value: true });
35628 var Component_1 = require("../../../Component");
35632 * @classdesc Tag holding properties for visualizing the centroid of a geometry.
35636 * var geometry = new Mapillary.TagComponent.PointGeometry([0.3, 0.3]);
35637 * var tag = new Mapillary.TagComponent.SpotTag(
35640 * { editable: true, color: 0xff0000 });
35642 * tagComponent.add([tag]);
35645 var SpotTag = /** @class */ (function (_super) {
35646 __extends(SpotTag, _super);
35648 * Create a spot tag.
35652 * @param {string} id
35653 * @param {Geometry} geometry
35654 * @param {IOutlineTagOptions} options - Options defining the visual appearance and
35655 * behavior of the spot tag.
35657 function SpotTag(id, geometry, options) {
35658 var _this = _super.call(this, id, geometry) || this;
35659 options = !!options ? options : {};
35660 _this._color = options.color == null ? 0xFFFFFF : options.color;
35661 _this._editable = options.editable == null ? false : options.editable;
35662 _this._icon = options.icon === undefined ? null : options.icon;
35663 _this._text = options.text === undefined ? null : options.text;
35664 _this._textColor = options.textColor == null ? 0xFFFFFF : options.textColor;
35667 Object.defineProperty(SpotTag.prototype, "color", {
35669 * Get color property.
35670 * @returns {number} The color of the spot as a hexagonal number;
35673 return this._color;
35676 * Set color property.
35679 * @fires Tag#changed
35681 set: function (value) {
35682 this._color = value;
35683 this._notifyChanged$.next(this);
35688 Object.defineProperty(SpotTag.prototype, "editable", {
35690 * Get editable property.
35691 * @returns {boolean} Value indicating if tag is editable.
35694 return this._editable;
35697 * Set editable property.
35700 * @fires Tag#changed
35702 set: function (value) {
35703 this._editable = value;
35704 this._notifyChanged$.next(this);
35709 Object.defineProperty(SpotTag.prototype, "icon", {
35711 * Get icon property.
35712 * @returns {string}
35718 * Set icon property.
35721 * @fires Tag#changed
35723 set: function (value) {
35724 this._icon = value;
35725 this._notifyChanged$.next(this);
35730 Object.defineProperty(SpotTag.prototype, "text", {
35732 * Get text property.
35733 * @returns {string}
35739 * Set text property.
35742 * @fires Tag#changed
35744 set: function (value) {
35745 this._text = value;
35746 this._notifyChanged$.next(this);
35751 Object.defineProperty(SpotTag.prototype, "textColor", {
35753 * Get text color property.
35754 * @returns {number}
35757 return this._textColor;
35760 * Set text color property.
35763 * @fires Tag#changed
35765 set: function (value) {
35766 this._textColor = value;
35767 this._notifyChanged$.next(this);
35773 * Set options for tag.
35775 * @description Sets all the option properties provided and keps
35776 * the rest of the values as is.
35778 * @param {ISpotTagOptions} options - Spot tag options
35780 * @fires {Tag#changed}
35782 SpotTag.prototype.setOptions = function (options) {
35783 this._color = options.color == null ? this._color : options.color;
35784 this._editable = options.editable == null ? this._editable : options.editable;
35785 this._icon = options.icon === undefined ? this._icon : options.icon;
35786 this._text = options.text === undefined ? this._text : options.text;
35787 this._textColor = options.textColor == null ? this._textColor : options.textColor;
35788 this._notifyChanged$.next(this);
35791 }(Component_1.Tag));
35792 exports.SpotTag = SpotTag;
35793 exports.default = SpotTag;
35795 },{"../../../Component":275}],371:[function(require,module,exports){
35797 var __extends = (this && this.__extends) || (function () {
35798 var extendStatics = function (d, b) {
35799 extendStatics = Object.setPrototypeOf ||
35800 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35801 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35802 return extendStatics(d, b);
35804 return function (d, b) {
35805 extendStatics(d, b);
35806 function __() { this.constructor = d; }
35807 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35810 Object.defineProperty(exports, "__esModule", { value: true });
35811 var operators_1 = require("rxjs/operators");
35812 var rxjs_1 = require("rxjs");
35813 var Utils_1 = require("../../../Utils");
35817 * @classdesc Abstract class representing the basic functionality of for a tag.
35819 var Tag = /** @class */ (function (_super) {
35820 __extends(Tag, _super);
35825 * @param {string} id
35826 * @param {Geometry} geometry
35828 function Tag(id, geometry) {
35829 var _this = _super.call(this) || this;
35831 _this._geometry = geometry;
35832 _this._notifyChanged$ = new rxjs_1.Subject();
35833 _this._notifyChanged$
35834 .subscribe(function (t) {
35835 _this.fire(Tag.changed, _this);
35837 _this._geometry.changed$
35838 .subscribe(function (g) {
35839 _this.fire(Tag.geometrychanged, _this);
35843 Object.defineProperty(Tag.prototype, "id", {
35846 * @returns {string}
35854 Object.defineProperty(Tag.prototype, "geometry", {
35856 * Get geometry property.
35857 * @returns {Geometry} The geometry of the tag.
35860 return this._geometry;
35865 Object.defineProperty(Tag.prototype, "changed$", {
35867 * Get changed observable.
35868 * @returns {Observable<Tag>}
35872 return this._notifyChanged$;
35877 Object.defineProperty(Tag.prototype, "geometryChanged$", {
35879 * Get geometry changed observable.
35880 * @returns {Observable<Tag>}
35885 return this._geometry.changed$.pipe(operators_1.map(function (geometry) {
35887 }), operators_1.share());
35893 * Event fired when a property related to the visual appearance of the
35896 * @event Tag#changed
35897 * @type {Tag} The tag instance that has changed.
35899 Tag.changed = "changed";
35901 * Event fired when the geometry of the tag has changed.
35903 * @event Tag#geometrychanged
35904 * @type {Tag} The tag instance whose geometry has changed.
35906 Tag.geometrychanged = "geometrychanged";
35908 }(Utils_1.EventEmitter));
35910 exports.default = Tag;
35912 },{"../../../Utils":285,"rxjs":27,"rxjs/operators":225}],372:[function(require,module,exports){
35914 Object.defineProperty(exports, "__esModule", { value: true });
35916 * Enumeration for tag domains.
35919 * @description Defines where lines between two vertices are treated
35922 * Only applicable for polygons. For rectangles lines between
35923 * vertices are always treated as straight in the distorted 2D
35924 * projection and bended in the undistorted 3D space.
35927 (function (TagDomain) {
35929 * Treats lines between two vertices as straight in the
35930 * distorted 2D projection, i.e. on the image. If the image
35931 * is distorted this will result in bended lines when rendered
35932 * in the undistorted 3D space.
35934 TagDomain[TagDomain["TwoDimensional"] = 0] = "TwoDimensional";
35936 * Treats lines as straight in the undistorted 3D space. If the
35937 * image is distorted this will result in bended lines when rendered
35938 * on the distorted 2D projection of the image.
35940 TagDomain[TagDomain["ThreeDimensional"] = 1] = "ThreeDimensional";
35941 })(TagDomain = exports.TagDomain || (exports.TagDomain = {}));
35942 exports.default = TagDomain;
35944 },{}],373:[function(require,module,exports){
35946 Object.defineProperty(exports, "__esModule", { value: true });
35947 var HandlerBase = /** @class */ (function () {
35949 function HandlerBase(component, container, navigator) {
35950 this._component = component;
35951 this._container = container;
35952 this._navigator = navigator;
35953 this._enabled = false;
35955 Object.defineProperty(HandlerBase.prototype, "isEnabled", {
35957 * Returns a Boolean indicating whether the interaction is enabled.
35959 * @returns {boolean} `true` if the interaction is enabled.
35962 return this._enabled;
35968 * Enables the interaction.
35970 * @example ```<component-name>.<handler-name>.enable();```
35972 HandlerBase.prototype.enable = function () {
35973 if (this._enabled || !this._component.activated) {
35977 this._enabled = true;
35978 this._component.configure(this._getConfiguration(true));
35981 * Disables the interaction.
35983 * @example ```<component-name>.<handler-name>.disable();```
35985 HandlerBase.prototype.disable = function () {
35986 if (!this._enabled) {
35990 this._enabled = false;
35991 if (this._component.activated) {
35992 this._component.configure(this._getConfiguration(false));
35995 return HandlerBase;
35997 exports.HandlerBase = HandlerBase;
35998 exports.default = HandlerBase;
36000 },{}],374:[function(require,module,exports){
36002 Object.defineProperty(exports, "__esModule", { value: true });
36003 var THREE = require("three");
36004 var Component_1 = require("../../Component");
36005 var MeshFactory = /** @class */ (function () {
36006 function MeshFactory(imagePlaneDepth, imageSphereRadius) {
36007 this._imagePlaneDepth = imagePlaneDepth != null ? imagePlaneDepth : 200;
36008 this._imageSphereRadius = imageSphereRadius != null ? imageSphereRadius : 200;
36010 MeshFactory.prototype.createMesh = function (node, transform) {
36011 var mesh = node.pano ?
36012 this._createImageSphere(node, transform) :
36013 this._createImagePlane(node, transform);
36016 MeshFactory.prototype.createFlatMesh = function (node, transform, basicX0, basicX1, basicY0, basicY1) {
36017 var texture = this._createTexture(node.image);
36018 var materialParameters = this._createDistortedPlaneMaterialParameters(transform, texture);
36019 var material = new THREE.ShaderMaterial(materialParameters);
36020 var geometry = this._getFlatImagePlaneGeoFromBasic(transform, basicX0, basicX1, basicY0, basicY1);
36021 return new THREE.Mesh(geometry, material);
36023 MeshFactory.prototype.createCurtainMesh = function (node, transform) {
36024 if (node.pano && !node.fullPano) {
36025 throw new Error("Cropped panoramas cannot have curtain.");
36028 this._createSphereCurtainMesh(node, transform) :
36029 this._createCurtainMesh(node, transform);
36031 MeshFactory.prototype.createDistortedCurtainMesh = function (node, transform) {
36033 throw new Error("Cropped panoramas cannot have curtain.");
36035 return this._createDistortedCurtainMesh(node, transform);
36037 MeshFactory.prototype._createCurtainMesh = function (node, transform) {
36038 var texture = this._createTexture(node.image);
36039 var materialParameters = this._createCurtainPlaneMaterialParameters(transform, texture);
36040 var material = new THREE.ShaderMaterial(materialParameters);
36041 var geometry = this._useMesh(transform, node) ?
36042 this._getImagePlaneGeo(transform, node) :
36043 this._getRegularFlatImagePlaneGeo(transform);
36044 return new THREE.Mesh(geometry, material);
36046 MeshFactory.prototype._createDistortedCurtainMesh = function (node, transform) {
36047 var texture = this._createTexture(node.image);
36048 var materialParameters = this._createDistortedCurtainPlaneMaterialParameters(transform, texture);
36049 var material = new THREE.ShaderMaterial(materialParameters);
36050 var geometry = this._getRegularFlatImagePlaneGeo(transform);
36051 return new THREE.Mesh(geometry, material);
36053 MeshFactory.prototype._createSphereCurtainMesh = function (node, transform) {
36054 var texture = this._createTexture(node.image);
36055 var materialParameters = this._createCurtainSphereMaterialParameters(transform, texture);
36056 var material = new THREE.ShaderMaterial(materialParameters);
36057 return this._useMesh(transform, node) ?
36058 new THREE.Mesh(this._getImageSphereGeo(transform, node), material) :
36059 new THREE.Mesh(this._getFlatImageSphereGeo(transform), material);
36061 MeshFactory.prototype._createImageSphere = function (node, transform) {
36062 var texture = this._createTexture(node.image);
36063 var materialParameters = this._createSphereMaterialParameters(transform, texture);
36064 var material = new THREE.ShaderMaterial(materialParameters);
36065 var mesh = this._useMesh(transform, node) ?
36066 new THREE.Mesh(this._getImageSphereGeo(transform, node), material) :
36067 new THREE.Mesh(this._getFlatImageSphereGeo(transform), material);
36070 MeshFactory.prototype._createImagePlane = function (node, transform) {
36071 var texture = this._createTexture(node.image);
36072 var materialParameters = this._createPlaneMaterialParameters(transform, texture);
36073 var material = new THREE.ShaderMaterial(materialParameters);
36074 var geometry = this._useMesh(transform, node) ?
36075 this._getImagePlaneGeo(transform, node) :
36076 this._getRegularFlatImagePlaneGeo(transform);
36077 return new THREE.Mesh(geometry, material);
36079 MeshFactory.prototype._createSphereMaterialParameters = function (transform, texture) {
36080 var gpano = transform.gpano;
36081 var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2;
36082 var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels;
36083 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
36084 var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2;
36085 var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels;
36086 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
36087 var materialParameters = {
36089 fragmentShader: Component_1.Shaders.equirectangular.fragment,
36090 side: THREE.DoubleSide,
36107 value: transform.rt,
36115 value: thetaLength,
36122 vertexShader: Component_1.Shaders.equirectangular.vertex,
36124 return materialParameters;
36126 MeshFactory.prototype._createCurtainSphereMaterialParameters = function (transform, texture) {
36127 var gpano = transform.gpano;
36128 var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2;
36129 var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels;
36130 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
36131 var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2;
36132 var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels;
36133 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
36134 var materialParameters = {
36136 fragmentShader: Component_1.Shaders.equirectangularCurtain.fragment,
36137 side: THREE.DoubleSide,
36158 value: transform.rt,
36166 value: thetaLength,
36173 vertexShader: Component_1.Shaders.equirectangularCurtain.vertex,
36175 return materialParameters;
36177 MeshFactory.prototype._createPlaneMaterialParameters = function (transform, texture) {
36178 var materialParameters = {
36180 fragmentShader: Component_1.Shaders.perspective.fragment,
36181 side: THREE.DoubleSide,
36186 value: transform.focal,
36190 value: transform.ck1,
36194 value: transform.ck2,
36202 value: transform.basicRt,
36210 value: !!transform.radialPeak ? transform.radialPeak : 0,
36214 value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth,
36218 value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight,
36221 vertexShader: Component_1.Shaders.perspective.vertex,
36223 return materialParameters;
36225 MeshFactory.prototype._createCurtainPlaneMaterialParameters = function (transform, texture) {
36226 var materialParameters = {
36228 fragmentShader: Component_1.Shaders.perspectiveCurtain.fragment,
36229 side: THREE.DoubleSide,
36238 value: transform.focal,
36242 value: transform.ck1,
36246 value: transform.ck2,
36254 value: transform.basicRt,
36262 value: !!transform.radialPeak ? transform.radialPeak : 0,
36266 value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth,
36270 value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight,
36273 vertexShader: Component_1.Shaders.perspectiveCurtain.vertex,
36275 return materialParameters;
36277 MeshFactory.prototype._createDistortedCurtainPlaneMaterialParameters = function (transform, texture) {
36278 var materialParameters = {
36280 fragmentShader: Component_1.Shaders.perspectiveDistortedCurtain.fragment,
36281 side: THREE.DoubleSide,
36294 value: transform.projectorMatrix(),
36301 vertexShader: Component_1.Shaders.perspectiveDistortedCurtain.vertex,
36303 return materialParameters;
36305 MeshFactory.prototype._createDistortedPlaneMaterialParameters = function (transform, texture) {
36306 var materialParameters = {
36308 fragmentShader: Component_1.Shaders.perspectiveDistorted.fragment,
36309 side: THREE.DoubleSide,
36318 value: transform.projectorMatrix(),
36325 vertexShader: Component_1.Shaders.perspectiveDistorted.vertex,
36327 return materialParameters;
36329 MeshFactory.prototype._createTexture = function (image) {
36330 var texture = new THREE.Texture(image);
36331 texture.minFilter = THREE.LinearFilter;
36332 texture.needsUpdate = true;
36335 MeshFactory.prototype._useMesh = function (transform, node) {
36336 return node.mesh.vertices.length && transform.hasValidScale;
36338 MeshFactory.prototype._getImageSphereGeo = function (transform, node) {
36339 var t = new THREE.Matrix4().getInverse(transform.srt);
36340 // push everything at least 5 meters in front of the camera
36341 var minZ = 5.0 * transform.scale;
36342 var maxZ = this._imageSphereRadius * transform.scale;
36343 var vertices = node.mesh.vertices;
36344 var numVertices = vertices.length / 3;
36345 var positions = new Float32Array(vertices.length);
36346 for (var i = 0; i < numVertices; ++i) {
36348 var x = vertices[index + 0];
36349 var y = vertices[index + 1];
36350 var z = vertices[index + 2];
36351 var l = Math.sqrt(x * x + y * y + z * z);
36352 var boundedL = Math.max(minZ, Math.min(l, maxZ));
36353 var factor = boundedL / l;
36354 var p = new THREE.Vector3(x * factor, y * factor, z * factor);
36356 positions[index + 0] = p.x;
36357 positions[index + 1] = p.y;
36358 positions[index + 2] = p.z;
36360 var faces = node.mesh.faces;
36361 var indices = new Uint16Array(faces.length);
36362 for (var i = 0; i < faces.length; ++i) {
36363 indices[i] = faces[i];
36365 var geometry = new THREE.BufferGeometry();
36366 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
36367 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
36370 MeshFactory.prototype._getImagePlaneGeo = function (transform, node) {
36371 var undistortionMarginFactor = 3;
36372 var t = new THREE.Matrix4().getInverse(transform.srt);
36373 // push everything at least 5 meters in front of the camera
36374 var minZ = 5.0 * transform.scale;
36375 var maxZ = this._imagePlaneDepth * transform.scale;
36376 var vertices = node.mesh.vertices;
36377 var numVertices = vertices.length / 3;
36378 var positions = new Float32Array(vertices.length);
36379 for (var i = 0; i < numVertices; ++i) {
36381 var x = vertices[index + 0];
36382 var y = vertices[index + 1];
36383 var z = vertices[index + 2];
36385 x *= undistortionMarginFactor;
36386 y *= undistortionMarginFactor;
36388 var boundedZ = Math.max(minZ, Math.min(z, maxZ));
36389 var factor = boundedZ / z;
36390 var p = new THREE.Vector3(x * factor, y * factor, boundedZ);
36392 positions[index + 0] = p.x;
36393 positions[index + 1] = p.y;
36394 positions[index + 2] = p.z;
36396 var faces = node.mesh.faces;
36397 var indices = new Uint16Array(faces.length);
36398 for (var i = 0; i < faces.length; ++i) {
36399 indices[i] = faces[i];
36401 var geometry = new THREE.BufferGeometry();
36402 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
36403 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
36406 MeshFactory.prototype._getFlatImageSphereGeo = function (transform) {
36407 var gpano = transform.gpano;
36408 var phiStart = 2 * Math.PI * gpano.CroppedAreaLeftPixels / gpano.FullPanoWidthPixels;
36409 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
36410 var thetaStart = Math.PI *
36411 (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels - gpano.CroppedAreaTopPixels) /
36412 gpano.FullPanoHeightPixels;
36413 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
36414 var geometry = new THREE.SphereGeometry(this._imageSphereRadius, 20, 40, phiStart - Math.PI / 2, phiLength, thetaStart, thetaLength);
36415 geometry.applyMatrix(new THREE.Matrix4().getInverse(transform.rt));
36418 MeshFactory.prototype._getRegularFlatImagePlaneGeo = function (transform) {
36419 var width = transform.width;
36420 var height = transform.height;
36421 var size = Math.max(width, height);
36422 var dx = width / 2.0 / size;
36423 var dy = height / 2.0 / size;
36424 return this._getFlatImagePlaneGeo(transform, dx, dy);
36426 MeshFactory.prototype._getFlatImagePlaneGeo = function (transform, dx, dy) {
36428 vertices.push(transform.unprojectSfM([-dx, -dy], this._imagePlaneDepth));
36429 vertices.push(transform.unprojectSfM([dx, -dy], this._imagePlaneDepth));
36430 vertices.push(transform.unprojectSfM([dx, dy], this._imagePlaneDepth));
36431 vertices.push(transform.unprojectSfM([-dx, dy], this._imagePlaneDepth));
36432 return this._createFlatGeometry(vertices);
36434 MeshFactory.prototype._getFlatImagePlaneGeoFromBasic = function (transform, basicX0, basicX1, basicY0, basicY1) {
36436 vertices.push(transform.unprojectBasic([basicX0, basicY0], this._imagePlaneDepth));
36437 vertices.push(transform.unprojectBasic([basicX1, basicY0], this._imagePlaneDepth));
36438 vertices.push(transform.unprojectBasic([basicX1, basicY1], this._imagePlaneDepth));
36439 vertices.push(transform.unprojectBasic([basicX0, basicY1], this._imagePlaneDepth));
36440 return this._createFlatGeometry(vertices);
36442 MeshFactory.prototype._createFlatGeometry = function (vertices) {
36443 var positions = new Float32Array(12);
36444 for (var i = 0; i < vertices.length; i++) {
36446 positions[index + 0] = vertices[i][0];
36447 positions[index + 1] = vertices[i][1];
36448 positions[index + 2] = vertices[i][2];
36450 var indices = new Uint16Array(6);
36457 var geometry = new THREE.BufferGeometry();
36458 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
36459 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
36462 return MeshFactory;
36464 exports.MeshFactory = MeshFactory;
36465 exports.default = MeshFactory;
36467 },{"../../Component":275,"three":226}],375:[function(require,module,exports){
36469 Object.defineProperty(exports, "__esModule", { value: true });
36470 var THREE = require("three");
36471 var MeshScene = /** @class */ (function () {
36472 function MeshScene() {
36473 this.scene = new THREE.Scene();
36474 this.sceneOld = new THREE.Scene();
36475 this.imagePlanes = [];
36476 this.imagePlanesOld = [];
36478 MeshScene.prototype.updateImagePlanes = function (planes) {
36479 this._dispose(this.imagePlanesOld, this.sceneOld);
36480 for (var _i = 0, _a = this.imagePlanes; _i < _a.length; _i++) {
36481 var plane = _a[_i];
36482 this.scene.remove(plane);
36483 this.sceneOld.add(plane);
36485 for (var _b = 0, planes_1 = planes; _b < planes_1.length; _b++) {
36486 var plane = planes_1[_b];
36487 this.scene.add(plane);
36489 this.imagePlanesOld = this.imagePlanes;
36490 this.imagePlanes = planes;
36492 MeshScene.prototype.addImagePlanes = function (planes) {
36493 for (var _i = 0, planes_2 = planes; _i < planes_2.length; _i++) {
36494 var plane = planes_2[_i];
36495 this.scene.add(plane);
36496 this.imagePlanes.push(plane);
36499 MeshScene.prototype.addImagePlanesOld = function (planes) {
36500 for (var _i = 0, planes_3 = planes; _i < planes_3.length; _i++) {
36501 var plane = planes_3[_i];
36502 this.sceneOld.add(plane);
36503 this.imagePlanesOld.push(plane);
36506 MeshScene.prototype.setImagePlanes = function (planes) {
36508 this.addImagePlanes(planes);
36510 MeshScene.prototype.setImagePlanesOld = function (planes) {
36512 this.addImagePlanesOld(planes);
36514 MeshScene.prototype.clear = function () {
36518 MeshScene.prototype._clear = function () {
36519 this._dispose(this.imagePlanes, this.scene);
36520 this.imagePlanes.length = 0;
36522 MeshScene.prototype._clearOld = function () {
36523 this._dispose(this.imagePlanesOld, this.sceneOld);
36524 this.imagePlanesOld.length = 0;
36526 MeshScene.prototype._dispose = function (planes, scene) {
36527 for (var _i = 0, planes_4 = planes; _i < planes_4.length; _i++) {
36528 var plane = planes_4[_i];
36529 scene.remove(plane);
36530 plane.geometry.dispose();
36531 plane.material.dispose();
36532 var texture = plane.material.uniforms.projectorTex.value;
36533 if (texture != null) {
36540 exports.MeshScene = MeshScene;
36541 exports.default = MeshScene;
36543 },{"three":226}],376:[function(require,module,exports){
36545 Object.defineProperty(exports, "__esModule", { value: true });
36546 var rxjs_1 = require("rxjs");
36547 var operators_1 = require("rxjs/operators");
36548 var MouseOperator = /** @class */ (function () {
36549 function MouseOperator() {
36551 MouseOperator.filteredPairwiseMouseDrag$ = function (name, mouseService) {
36552 return mouseService
36553 .filtered$(name, mouseService.mouseDragStart$).pipe(operators_1.switchMap(function (mouseDragStart) {
36554 var mouseDragging$ = rxjs_1.concat(rxjs_1.of(mouseDragStart), mouseService
36555 .filtered$(name, mouseService.mouseDrag$));
36556 var mouseDragEnd$ = mouseService
36557 .filtered$(name, mouseService.mouseDragEnd$).pipe(operators_1.map(function () {
36560 return rxjs_1.merge(mouseDragging$, mouseDragEnd$).pipe(operators_1.takeWhile(function (e) {
36562 }), operators_1.startWith(null));
36563 }), operators_1.pairwise(), operators_1.filter(function (pair) {
36564 return pair[0] != null && pair[1] != null;
36567 return MouseOperator;
36569 exports.MouseOperator = MouseOperator;
36570 exports.default = MouseOperator;
36572 },{"rxjs":27,"rxjs/operators":225}],377:[function(require,module,exports){
36574 var __extends = (this && this.__extends) || (function () {
36575 var extendStatics = function (d, b) {
36576 extendStatics = Object.setPrototypeOf ||
36577 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36578 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36579 return extendStatics(d, b);
36581 return function (d, b) {
36582 extendStatics(d, b);
36583 function __() { this.constructor = d; }
36584 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36587 Object.defineProperty(exports, "__esModule", { value: true });
36588 var rxjs_1 = require("rxjs");
36589 var operators_1 = require("rxjs/operators");
36590 var vd = require("virtual-dom");
36591 var Component_1 = require("../../Component");
36592 var Geo_1 = require("../../Geo");
36593 var State_1 = require("../../State");
36594 var ZoomComponent = /** @class */ (function (_super) {
36595 __extends(ZoomComponent, _super);
36596 function ZoomComponent(name, container, navigator) {
36597 var _this = _super.call(this, name, container, navigator) || this;
36598 _this._viewportCoords = new Geo_1.ViewportCoords();
36599 _this._zoomDelta$ = new rxjs_1.Subject();
36602 ZoomComponent.prototype._activate = function () {
36604 this._renderSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentState$, this._navigator.stateService.state$).pipe(operators_1.map(function (_a) {
36605 var frame = _a[0], state = _a[1];
36606 return [frame.state.zoom, state];
36607 }), operators_1.map(function (_a) {
36608 var zoom = _a[0], state = _a[1];
36609 var zoomInIcon = vd.h("div.ZoomInIcon", []);
36610 var zoomInButton = zoom >= 3 || state === State_1.State.Waiting ?
36611 vd.h("div.ZoomInButtonDisabled", [zoomInIcon]) :
36612 vd.h("div.ZoomInButton", { onclick: function () { _this._zoomDelta$.next(1); } }, [zoomInIcon]);
36613 var zoomOutIcon = vd.h("div.ZoomOutIcon", []);
36614 var zoomOutButton = zoom <= 0 || state === State_1.State.Waiting ?
36615 vd.h("div.ZoomOutButtonDisabled", [zoomOutIcon]) :
36616 vd.h("div.ZoomOutButton", { onclick: function () { _this._zoomDelta$.next(-1); } }, [zoomOutIcon]);
36619 vnode: vd.h("div.ZoomContainer", { oncontextmenu: function (event) { event.preventDefault(); } }, [zoomInButton, zoomOutButton]),
36622 .subscribe(this._container.domRenderer.render$);
36623 this._zoomSubscription = this._zoomDelta$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
36624 .subscribe(function (_a) {
36625 var zoomDelta = _a[0], render = _a[1], transform = _a[2];
36626 var unprojected = _this._viewportCoords.unprojectFromViewport(0, 0, render.perspective);
36627 var reference = transform.projectBasic(unprojected.toArray());
36628 _this._navigator.stateService.zoomIn(zoomDelta, reference);
36631 ZoomComponent.prototype._deactivate = function () {
36632 this._renderSubscription.unsubscribe();
36633 this._zoomSubscription.unsubscribe();
36635 ZoomComponent.prototype._getDefaultConfiguration = function () {
36638 ZoomComponent.componentName = "zoom";
36639 return ZoomComponent;
36640 }(Component_1.Component));
36641 exports.ZoomComponent = ZoomComponent;
36642 Component_1.ComponentService.register(ZoomComponent);
36643 exports.default = ZoomComponent;
36645 },{"../../Component":275,"../../Geo":278,"../../State":282,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],378:[function(require,module,exports){
36647 var __extends = (this && this.__extends) || (function () {
36648 var extendStatics = function (d, b) {
36649 extendStatics = Object.setPrototypeOf ||
36650 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36651 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36652 return extendStatics(d, b);
36654 return function (d, b) {
36655 extendStatics(d, b);
36656 function __() { this.constructor = d; }
36657 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36660 Object.defineProperty(exports, "__esModule", { value: true });
36661 var MapillaryError_1 = require("./MapillaryError");
36663 * @class AbortMapillaryError
36665 * @classdesc Error thrown when a move to request has been
36666 * aborted before completing because of a subsequent request.
36668 var AbortMapillaryError = /** @class */ (function (_super) {
36669 __extends(AbortMapillaryError, _super);
36670 function AbortMapillaryError(message) {
36671 var _this = _super.call(this, message != null ? message : "The request was aborted.") || this;
36672 Object.setPrototypeOf(_this, AbortMapillaryError.prototype);
36673 _this.name = "AbortMapillaryError";
36676 return AbortMapillaryError;
36677 }(MapillaryError_1.MapillaryError));
36678 exports.AbortMapillaryError = AbortMapillaryError;
36679 exports.default = AbortMapillaryError;
36681 },{"./MapillaryError":381}],379:[function(require,module,exports){
36683 var __extends = (this && this.__extends) || (function () {
36684 var extendStatics = function (d, b) {
36685 extendStatics = Object.setPrototypeOf ||
36686 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36687 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36688 return extendStatics(d, b);
36690 return function (d, b) {
36691 extendStatics(d, b);
36692 function __() { this.constructor = d; }
36693 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36696 Object.defineProperty(exports, "__esModule", { value: true });
36697 var MapillaryError_1 = require("./MapillaryError");
36698 var ArgumentMapillaryError = /** @class */ (function (_super) {
36699 __extends(ArgumentMapillaryError, _super);
36700 function ArgumentMapillaryError(message) {
36701 var _this = _super.call(this, message != null ? message : "The argument is not valid.") || this;
36702 Object.setPrototypeOf(_this, ArgumentMapillaryError.prototype);
36703 _this.name = "ArgumentMapillaryError";
36706 return ArgumentMapillaryError;
36707 }(MapillaryError_1.MapillaryError));
36708 exports.ArgumentMapillaryError = ArgumentMapillaryError;
36709 exports.default = ArgumentMapillaryError;
36711 },{"./MapillaryError":381}],380:[function(require,module,exports){
36713 var __extends = (this && this.__extends) || (function () {
36714 var extendStatics = function (d, b) {
36715 extendStatics = Object.setPrototypeOf ||
36716 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36717 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36718 return extendStatics(d, b);
36720 return function (d, b) {
36721 extendStatics(d, b);
36722 function __() { this.constructor = d; }
36723 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36726 Object.defineProperty(exports, "__esModule", { value: true });
36727 var MapillaryError_1 = require("./MapillaryError");
36728 var GraphMapillaryError = /** @class */ (function (_super) {
36729 __extends(GraphMapillaryError, _super);
36730 function GraphMapillaryError(message) {
36731 var _this = _super.call(this, message) || this;
36732 Object.setPrototypeOf(_this, GraphMapillaryError.prototype);
36733 _this.name = "GraphMapillaryError";
36736 return GraphMapillaryError;
36737 }(MapillaryError_1.MapillaryError));
36738 exports.GraphMapillaryError = GraphMapillaryError;
36739 exports.default = GraphMapillaryError;
36741 },{"./MapillaryError":381}],381:[function(require,module,exports){
36743 var __extends = (this && this.__extends) || (function () {
36744 var extendStatics = function (d, b) {
36745 extendStatics = Object.setPrototypeOf ||
36746 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36747 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36748 return extendStatics(d, b);
36750 return function (d, b) {
36751 extendStatics(d, b);
36752 function __() { this.constructor = d; }
36753 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36756 Object.defineProperty(exports, "__esModule", { value: true });
36757 var MapillaryError = /** @class */ (function (_super) {
36758 __extends(MapillaryError, _super);
36759 function MapillaryError(message) {
36760 var _this = _super.call(this, message) || this;
36761 Object.setPrototypeOf(_this, MapillaryError.prototype);
36762 _this.name = "MapillaryError";
36765 return MapillaryError;
36767 exports.MapillaryError = MapillaryError;
36768 exports.default = MapillaryError;
36770 },{}],382:[function(require,module,exports){
36772 Object.defineProperty(exports, "__esModule", { value: true });
36773 var THREE = require("three");
36777 * @classdesc Holds information about a camera.
36779 var Camera = /** @class */ (function () {
36781 * Create a new camera instance.
36782 * @param {Transform} [transform] - Optional transform instance.
36784 function Camera(transform) {
36785 if (transform != null) {
36786 this._position = new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0));
36787 this._lookat = new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10));
36788 this._up = transform.upVector();
36789 this._focal = this._getFocal(transform);
36792 this._position = new THREE.Vector3(0, 0, 0);
36793 this._lookat = new THREE.Vector3(0, 0, 1);
36794 this._up = new THREE.Vector3(0, -1, 0);
36798 Object.defineProperty(Camera.prototype, "position", {
36801 * @returns {THREE.Vector3} The position vector.
36804 return this._position;
36809 Object.defineProperty(Camera.prototype, "lookat", {
36812 * @returns {THREE.Vector3} The lookat vector.
36815 return this._lookat;
36820 Object.defineProperty(Camera.prototype, "up", {
36823 * @returns {THREE.Vector3} The up vector.
36831 Object.defineProperty(Camera.prototype, "focal", {
36834 * @returns {number} The focal length.
36837 return this._focal;
36842 set: function (value) {
36843 this._focal = value;
36849 * Update this camera to the linearly interpolated value of two other cameras.
36851 * @param {Camera} a - First camera.
36852 * @param {Camera} b - Second camera.
36853 * @param {number} alpha - Interpolation value on the interval [0, 1].
36855 Camera.prototype.lerpCameras = function (a, b, alpha) {
36856 this._position.subVectors(b.position, a.position).multiplyScalar(alpha).add(a.position);
36857 this._lookat.subVectors(b.lookat, a.lookat).multiplyScalar(alpha).add(a.lookat);
36858 this._up.subVectors(b.up, a.up).multiplyScalar(alpha).add(a.up);
36859 this._focal = (1 - alpha) * a.focal + alpha * b.focal;
36862 * Copy the properties of another camera to this camera.
36864 * @param {Camera} other - Another camera.
36866 Camera.prototype.copy = function (other) {
36867 this._position.copy(other.position);
36868 this._lookat.copy(other.lookat);
36869 this._up.copy(other.up);
36870 this._focal = other.focal;
36873 * Clone this camera.
36875 * @returns {Camera} A camera with cloned properties equal to this camera.
36877 Camera.prototype.clone = function () {
36878 var camera = new Camera();
36879 camera.position.copy(this._position);
36880 camera.lookat.copy(this._lookat);
36881 camera.up.copy(this._up);
36882 camera.focal = this._focal;
36886 * Determine the distance between this camera and another camera.
36888 * @param {Camera} other - Another camera.
36889 * @returns {number} The distance between the cameras.
36891 Camera.prototype.diff = function (other) {
36892 var pd = this._position.distanceToSquared(other.position);
36893 var ld = this._lookat.distanceToSquared(other.lookat);
36894 var ud = this._up.distanceToSquared(other.up);
36895 var fd = 100 * Math.abs(this._focal - other.focal);
36896 return Math.max(pd, ld, ud, fd);
36899 * Get the focal length based on the transform.
36901 * @description Returns the focal length of the transform if gpano info is not available.
36902 * Returns a focal length corresponding to a vertical fov clamped to [45, 90] degrees based on
36903 * the gpano information if available.
36905 * @returns {number} Focal length.
36907 Camera.prototype._getFocal = function (transform) {
36908 if (transform.gpano == null) {
36909 return transform.focal;
36911 var vFov = Math.PI * transform.gpano.CroppedAreaImageHeightPixels / transform.gpano.FullPanoHeightPixels;
36912 var focal = 0.5 / Math.tan(vFov / 2);
36913 return Math.min(1 / (2 * (Math.sqrt(2) - 1)), Math.max(0.5, focal));
36917 exports.Camera = Camera;
36919 },{"three":226}],383:[function(require,module,exports){
36921 Object.defineProperty(exports, "__esModule", { value: true });
36922 var Geo_1 = require("../Geo");
36923 var geoCoords = new Geo_1.GeoCoords();
36924 var spatial = new Geo_1.Spatial();
36925 function computeTranslation(position, rotation, reference) {
36926 var C = geoCoords.geodeticToEnu(position.lat, position.lon, position.alt, reference.lat, reference.lon, reference.alt);
36927 var RC = spatial.rotate(C, rotation);
36928 var translation = [-RC.x, -RC.y, -RC.z];
36929 return translation;
36931 exports.computeTranslation = computeTranslation;
36933 },{"../Geo":278}],384:[function(require,module,exports){
36935 Object.defineProperty(exports, "__esModule", { value: true });
36939 * @classdesc Converts coordinates between the geodetic (WGS84),
36940 * Earth-Centered, Earth-Fixed (ECEF) and local topocentric
36941 * East, North, Up (ENU) reference frames.
36943 * The WGS84 has latitude (degrees), longitude (degrees) and
36944 * altitude (meters) values.
36946 * The ECEF Z-axis pierces the north pole and the
36947 * XY-axis defines the equatorial plane. The X-axis extends
36948 * from the geocenter to the intersection of the Equator and
36949 * the Greenwich Meridian. All values in meters.
36951 * The WGS84 parameters are:
36955 * f = 1 / 298.257223563
36956 * e = Math.sqrt((a^2 - b^2) / a^2)
36957 * e' = Math.sqrt((a^2 - b^2) / b^2)
36959 * The WGS84 to ECEF conversion is performed using the following:
36961 * X = (N - h) * cos(phi) * cos(lambda)
36962 * Y = (N + h) * cos(phi) * sin(lambda)
36963 * Z = (b^2 * N / a^2 + h) * sin(phi)
36968 * lambda = longitude
36969 * h = height above ellipsoid (altitude)
36970 * N = Radius of curvature (meters)
36971 * = a / Math.sqrt(1 - e^2 * sin(phi)^2)
36973 * The ECEF to WGS84 conversion is performed using the following:
36975 * phi = arctan((Z + e'^2 * b * sin(theta)^3) / (p - e^2 * a * cos(theta)^3))
36976 * lambda = arctan(Y / X)
36977 * h = p / cos(phi) - N
36981 * p = Math.sqrt(X^2 + Y^2)
36982 * theta = arctan(Z * a / p * b)
36984 * In the ENU reference frame the x-axis points to the
36985 * East, the y-axis to the North and the z-axis Up. All values
36988 * The ECEF to ENU conversion is performed using the following:
36990 * | x | | -sin(lambda_r) cos(lambda_r) 0 | | X - X_r |
36991 * | y | = | -sin(phi_r) * cos(lambda_r) -sin(phi_r) * sin(lambda_r) cos(phi_r) | | Y - Y_r |
36992 * | z | | cos(phi_r) * cos(lambda_r) cos(phi_r) * sin(lambda_r) sin(phi_r) | | Z - Z_r |
36996 * phi_r = latitude of reference
36997 * lambda_r = longitude of reference
36998 * X_r, Y_r, Z_r = ECEF coordinates of reference
37000 * The ENU to ECEF conversion is performed by solving the above equation for X, Y, Z.
37002 * WGS84 to ENU and ENU to WGS84 are two step conversions with ECEF calculated in
37003 * the first step for both conversions.
37005 var GeoCoords = /** @class */ (function () {
37006 function GeoCoords() {
37007 this._wgs84a = 6378137.0;
37008 this._wgs84b = 6356752.31424518;
37011 * Convert coordinates from geodetic (WGS84) reference to local topocentric
37014 * @param {number} lat Latitude in degrees.
37015 * @param {number} lon Longitude in degrees.
37016 * @param {number} alt Altitude in meters.
37017 * @param {number} refLat Reference latitude in degrees.
37018 * @param {number} refLon Reference longitude in degrees.
37019 * @param {number} refAlt Reference altitude in meters.
37020 * @returns {Array<number>} The x, y, z local topocentric ENU coordinates.
37022 GeoCoords.prototype.geodeticToEnu = function (lat, lon, alt, refLat, refLon, refAlt) {
37023 var ecef = this.geodeticToEcef(lat, lon, alt);
37024 return this.ecefToEnu(ecef[0], ecef[1], ecef[2], refLat, refLon, refAlt);
37027 * Convert coordinates from local topocentric (ENU) reference to
37028 * geodetic (WGS84) reference.
37030 * @param {number} x Topocentric ENU coordinate in East direction.
37031 * @param {number} y Topocentric ENU coordinate in North direction.
37032 * @param {number} z Topocentric ENU coordinate in Up direction.
37033 * @param {number} refLat Reference latitude in degrees.
37034 * @param {number} refLon Reference longitude in degrees.
37035 * @param {number} refAlt Reference altitude in meters.
37036 * @returns {Array<number>} The latitude and longitude in degrees
37037 * as well as altitude in meters.
37039 GeoCoords.prototype.enuToGeodetic = function (x, y, z, refLat, refLon, refAlt) {
37040 var ecef = this.enuToEcef(x, y, z, refLat, refLon, refAlt);
37041 return this.ecefToGeodetic(ecef[0], ecef[1], ecef[2]);
37044 * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference
37045 * to local topocentric (ENU) reference.
37047 * @param {number} X ECEF X-value.
37048 * @param {number} Y ECEF Y-value.
37049 * @param {number} Z ECEF Z-value.
37050 * @param {number} refLat Reference latitude in degrees.
37051 * @param {number} refLon Reference longitude in degrees.
37052 * @param {number} refAlt Reference altitude in meters.
37053 * @returns {Array<number>} The x, y, z topocentric ENU coordinates in East, North
37054 * and Up directions respectively.
37056 GeoCoords.prototype.ecefToEnu = function (X, Y, Z, refLat, refLon, refAlt) {
37057 var refEcef = this.geodeticToEcef(refLat, refLon, refAlt);
37058 var V = [X - refEcef[0], Y - refEcef[1], Z - refEcef[2]];
37059 refLat = refLat * Math.PI / 180.0;
37060 refLon = refLon * Math.PI / 180.0;
37061 var cosLat = Math.cos(refLat);
37062 var sinLat = Math.sin(refLat);
37063 var cosLon = Math.cos(refLon);
37064 var sinLon = Math.sin(refLon);
37065 var x = -sinLon * V[0] + cosLon * V[1];
37066 var y = -sinLat * cosLon * V[0] - sinLat * sinLon * V[1] + cosLat * V[2];
37067 var z = cosLat * cosLon * V[0] + cosLat * sinLon * V[1] + sinLat * V[2];
37071 * Convert coordinates from local topocentric (ENU) reference
37072 * to Earth-Centered, Earth-Fixed (ECEF) reference.
37074 * @param {number} x Topocentric ENU coordinate in East direction.
37075 * @param {number} y Topocentric ENU coordinate in North direction.
37076 * @param {number} z Topocentric ENU coordinate in Up direction.
37077 * @param {number} refLat Reference latitude in degrees.
37078 * @param {number} refLon Reference longitude in degrees.
37079 * @param {number} refAlt Reference altitude in meters.
37080 * @returns {Array<number>} The X, Y, Z ECEF coordinates.
37082 GeoCoords.prototype.enuToEcef = function (x, y, z, refLat, refLon, refAlt) {
37083 var refEcef = this.geodeticToEcef(refLat, refLon, refAlt);
37084 refLat = refLat * Math.PI / 180.0;
37085 refLon = refLon * Math.PI / 180.0;
37086 var cosLat = Math.cos(refLat);
37087 var sinLat = Math.sin(refLat);
37088 var cosLon = Math.cos(refLon);
37089 var sinLon = Math.sin(refLon);
37090 var X = -sinLon * x - sinLat * cosLon * y + cosLat * cosLon * z + refEcef[0];
37091 var Y = cosLon * x - sinLat * sinLon * y + cosLat * sinLon * z + refEcef[1];
37092 var Z = cosLat * y + sinLat * z + refEcef[2];
37096 * Convert coordinates from geodetic reference (WGS84) to Earth-Centered,
37097 * Earth-Fixed (ECEF) reference.
37099 * @param {number} lat Latitude in degrees.
37100 * @param {number} lon Longitude in degrees.
37101 * @param {number} alt Altitude in meters.
37102 * @returns {Array<number>} The X, Y, Z ECEF coordinates.
37104 GeoCoords.prototype.geodeticToEcef = function (lat, lon, alt) {
37105 var a = this._wgs84a;
37106 var b = this._wgs84b;
37107 lat = lat * Math.PI / 180.0;
37108 lon = lon * Math.PI / 180.0;
37109 var cosLat = Math.cos(lat);
37110 var sinLat = Math.sin(lat);
37111 var cosLon = Math.cos(lon);
37112 var sinLon = Math.sin(lon);
37115 var L = 1.0 / Math.sqrt(a2 * cosLat * cosLat + b2 * sinLat * sinLat);
37116 var nhcl = (a2 * L + alt) * cosLat;
37117 var X = nhcl * cosLon;
37118 var Y = nhcl * sinLon;
37119 var Z = (b2 * L + alt) * sinLat;
37123 * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference
37124 * to geodetic reference (WGS84).
37126 * @param {number} X ECEF X-value.
37127 * @param {number} Y ECEF Y-value.
37128 * @param {number} Z ECEF Z-value.
37129 * @returns {Array<number>} The latitude and longitude in degrees
37130 * as well as altitude in meters.
37132 GeoCoords.prototype.ecefToGeodetic = function (X, Y, Z) {
37133 var a = this._wgs84a;
37134 var b = this._wgs84b;
37137 var a2mb2 = a2 - b2;
37138 var ea = Math.sqrt(a2mb2 / a2);
37139 var eb = Math.sqrt(a2mb2 / b2);
37140 var p = Math.sqrt(X * X + Y * Y);
37141 var theta = Math.atan2(Z * a, p * b);
37142 var sinTheta = Math.sin(theta);
37143 var cosTheta = Math.cos(theta);
37144 var lon = Math.atan2(Y, X);
37145 var lat = Math.atan2(Z + eb * eb * b * sinTheta * sinTheta * sinTheta, p - ea * ea * a * cosTheta * cosTheta * cosTheta);
37146 var sinLat = Math.sin(lat);
37147 var cosLat = Math.cos(lat);
37148 var N = a / Math.sqrt(1 - ea * ea * sinLat * sinLat);
37149 var alt = p / cosLat - N;
37150 return [lat * 180.0 / Math.PI, lon * 180.0 / Math.PI, alt];
37154 exports.GeoCoords = GeoCoords;
37155 exports.default = GeoCoords;
37157 },{}],385:[function(require,module,exports){
37159 Object.defineProperty(exports, "__esModule", { value: true });
37161 return n > 0 ? 1 : n < 0 ? -1 : 0;
37163 function colinearPointOnSegment(p, s) {
37164 return p.x <= Math.max(s.p1.x, s.p2.x) &&
37165 p.x >= Math.min(s.p1.x, s.p2.x) &&
37166 p.y >= Math.max(s.p1.y, s.p2.y) &&
37167 p.y >= Math.min(s.p1.y, s.p2.y);
37169 function parallel(s1, s2) {
37170 var ux = s1.p2.x - s1.p1.x;
37171 var uy = s1.p2.y - s1.p1.y;
37172 var vx = s2.p2.x - s2.p1.x;
37173 var vy = s2.p2.y - s2.p1.y;
37174 var cross = ux * vy - uy * vx;
37175 var u2 = ux * ux + uy * uy;
37176 var v2 = vx * vx + vy * vy;
37177 var epsilon2 = 1e-10;
37178 return cross * cross < epsilon2 * u2 * v2;
37180 function tripletOrientation(p1, p2, p3) {
37181 var orientation = (p2.y - p1.y) * (p3.x - p2.x) -
37182 (p3.y - p2.y) * (p2.x - p1.x);
37183 return sign(orientation);
37185 function segmentsIntersect(s1, s2) {
37186 if (parallel(s1, s2)) {
37189 var o1 = tripletOrientation(s1.p1, s1.p2, s2.p1);
37190 var o2 = tripletOrientation(s1.p1, s1.p2, s2.p2);
37191 var o3 = tripletOrientation(s2.p1, s2.p2, s1.p1);
37192 var o4 = tripletOrientation(s2.p1, s2.p2, s1.p2);
37193 if (o1 !== o2 && o3 !== o4) {
37196 if (o1 === 0 && colinearPointOnSegment(s2.p1, s1)) {
37199 if (o2 === 0 && colinearPointOnSegment(s2.p2, s1)) {
37202 if (o3 === 0 && colinearPointOnSegment(s1.p1, s2)) {
37205 if (o4 === 0 && colinearPointOnSegment(s1.p2, s2)) {
37210 exports.segmentsIntersect = segmentsIntersect;
37211 function segmentIntersection(s1, s2) {
37212 if (parallel(s1, s2)) {
37223 var den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
37224 var xNum = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
37225 var yNum = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
37226 return { x: xNum / den, y: yNum / den };
37228 exports.segmentIntersection = segmentIntersection;
37230 },{}],386:[function(require,module,exports){
37232 Object.defineProperty(exports, "__esModule", { value: true });
37233 var THREE = require("three");
37237 * @classdesc Provides methods for scalar, vector and matrix calculations.
37239 var Spatial = /** @class */ (function () {
37240 function Spatial() {
37241 this._epsilon = 1e-9;
37244 * Converts azimuthal phi rotation (counter-clockwise with origin on X-axis) to
37245 * bearing (clockwise with origin at north or Y-axis).
37247 * @param {number} phi - Azimuthal phi angle in radians.
37248 * @returns {number} Bearing in radians.
37250 Spatial.prototype.azimuthalToBearing = function (phi) {
37251 return -phi + Math.PI / 2;
37254 * Converts degrees to radians.
37256 * @param {number} deg - Degrees.
37257 * @returns {number} Radians.
37259 Spatial.prototype.degToRad = function (deg) {
37260 return Math.PI * deg / 180;
37263 * Converts radians to degrees.
37265 * @param {number} rad - Radians.
37266 * @returns {number} Degrees.
37268 Spatial.prototype.radToDeg = function (rad) {
37269 return 180 * rad / Math.PI;
37272 * Creates a rotation matrix from an angle-axis vector.
37274 * @param {Array<number>} angleAxis - Angle-axis representation of a rotation.
37275 * @returns {THREE.Matrix4} Rotation matrix.
37277 Spatial.prototype.rotationMatrix = function (angleAxis) {
37278 var axis = new THREE.Vector3(angleAxis[0], angleAxis[1], angleAxis[2]);
37279 var angle = axis.length();
37283 return new THREE.Matrix4().makeRotationAxis(axis, angle);
37286 * Rotates a vector according to a angle-axis rotation vector.
37288 * @param {Array<number>} vector - Vector to rotate.
37289 * @param {Array<number>} angleAxis - Angle-axis representation of a rotation.
37290 * @returns {THREE.Vector3} Rotated vector.
37292 Spatial.prototype.rotate = function (vector, angleAxis) {
37293 var v = new THREE.Vector3(vector[0], vector[1], vector[2]);
37294 var rotationMatrix = this.rotationMatrix(angleAxis);
37295 v.applyMatrix4(rotationMatrix);
37299 * Calculates the optical center from a rotation vector
37300 * on the angle-axis representation and a translation vector
37301 * according to C = -R^T t.
37303 * @param {Array<number>} rotation - Angle-axis representation of a rotation.
37304 * @param {Array<number>} translation - Translation vector.
37305 * @returns {THREE.Vector3} Optical center.
37307 Spatial.prototype.opticalCenter = function (rotation, translation) {
37308 var angleAxis = [-rotation[0], -rotation[1], -rotation[2]];
37309 var vector = [-translation[0], -translation[1], -translation[2]];
37310 return this.rotate(vector, angleAxis);
37313 * Calculates the viewing direction from a rotation vector
37314 * on the angle-axis representation.
37316 * @param {number[]} rotation - Angle-axis representation of a rotation.
37317 * @returns {THREE.Vector3} Viewing direction.
37319 Spatial.prototype.viewingDirection = function (rotation) {
37320 var angleAxis = [-rotation[0], -rotation[1], -rotation[2]];
37321 return this.rotate([0, 0, 1], angleAxis);
37324 * Wrap a number on the interval [min, max].
37326 * @param {number} value - Value to wrap.
37327 * @param {number} min - Lower endpoint of interval.
37328 * @param {number} max - Upper endpoint of interval.
37329 * @returns {number} The wrapped number.
37331 Spatial.prototype.wrap = function (value, min, max) {
37333 throw new Error("Invalid arguments: max must be larger than min.");
37335 var interval = (max - min);
37336 while (value > max || value < min) {
37338 value = value - interval;
37340 else if (value < min) {
37341 value = value + interval;
37347 * Wrap an angle on the interval [-Pi, Pi].
37349 * @param {number} angle - Value to wrap.
37350 * @returns {number} Wrapped angle.
37352 Spatial.prototype.wrapAngle = function (angle) {
37353 return this.wrap(angle, -Math.PI, Math.PI);
37356 * Limit the value to the interval [min, max] by changing the value to
37357 * the nearest available one when it is outside the interval.
37359 * @param {number} value - Value to clamp.
37360 * @param {number} min - Minimum of the interval.
37361 * @param {number} max - Maximum of the interval.
37362 * @returns {number} Clamped value.
37364 Spatial.prototype.clamp = function (value, min, max) {
37374 * Calculates the counter-clockwise angle from the first
37375 * vector (x1, y1)^T to the second (x2, y2)^T.
37377 * @param {number} x1 - X coordinate of first vector.
37378 * @param {number} y1 - Y coordinate of first vector.
37379 * @param {number} x2 - X coordinate of second vector.
37380 * @param {number} y2 - Y coordinate of second vector.
37381 * @returns {number} Counter clockwise angle between the vectors.
37383 Spatial.prototype.angleBetweenVector2 = function (x1, y1, x2, y2) {
37384 var angle = Math.atan2(y2, x2) - Math.atan2(y1, x1);
37385 return this.wrapAngle(angle);
37388 * Calculates the minimum (absolute) angle change for rotation
37389 * from one angle to another on the [-Pi, Pi] interval.
37391 * @param {number} angle1 - Start angle.
37392 * @param {number} angle2 - Destination angle.
37393 * @returns {number} Absolute angle change between angles.
37395 Spatial.prototype.angleDifference = function (angle1, angle2) {
37396 var angle = angle2 - angle1;
37397 return this.wrapAngle(angle);
37400 * Calculates the relative rotation angle between two
37401 * angle-axis vectors.
37403 * @param {number} rotation1 - First angle-axis vector.
37404 * @param {number} rotation2 - Second angle-axis vector.
37405 * @returns {number} Relative rotation angle.
37407 Spatial.prototype.relativeRotationAngle = function (rotation1, rotation2) {
37408 var R1T = this.rotationMatrix([-rotation1[0], -rotation1[1], -rotation1[2]]);
37409 var R2 = this.rotationMatrix(rotation2);
37410 var R = R1T.multiply(R2);
37411 var elements = R.elements;
37412 // from Tr(R) = 1 + 2 * cos(theta)
37413 var tr = elements[0] + elements[5] + elements[10];
37414 var theta = Math.acos(Math.max(Math.min((tr - 1) / 2, 1), -1));
37418 * Calculates the angle from a vector to a plane.
37420 * @param {Array<number>} vector - The vector.
37421 * @param {Array<number>} planeNormal - Normal of the plane.
37422 * @returns {number} Angle from between plane and vector.
37424 Spatial.prototype.angleToPlane = function (vector, planeNormal) {
37425 var v = new THREE.Vector3().fromArray(vector);
37426 var norm = v.length();
37427 if (norm < this._epsilon) {
37430 var projection = v.dot(new THREE.Vector3().fromArray(planeNormal));
37431 return Math.asin(projection / norm);
37434 * Calculates the distance between two coordinates
37435 * (latitude longitude pairs) in meters according to
37436 * the haversine formula.
37438 * @param {number} lat1 - Latitude of the first coordinate in degrees.
37439 * @param {number} lon1 - Longitude of the first coordinate in degrees.
37440 * @param {number} lat2 - Latitude of the second coordinate in degrees.
37441 * @param {number} lon2 - Longitude of the second coordinate in degrees.
37442 * @returns {number} Distance between lat lon positions in meters.
37444 Spatial.prototype.distanceFromLatLon = function (lat1, lon1, lat2, lon2) {
37446 var dLat = this.degToRad(lat2 - lat1);
37447 var dLon = this.degToRad(lon2 - lon1);
37448 var hav = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
37449 Math.cos(this.degToRad(lat1)) * Math.cos(this.degToRad(lat2)) *
37450 Math.sin(dLon / 2) * Math.sin(dLon / 2);
37451 var d = 2 * r * Math.atan2(Math.sqrt(hav), Math.sqrt(1 - hav));
37456 exports.Spatial = Spatial;
37457 exports.default = Spatial;
37459 },{"three":226}],387:[function(require,module,exports){
37461 Object.defineProperty(exports, "__esModule", { value: true });
37462 var THREE = require("three");
37466 * @classdesc Class used for calculating coordinate transformations
37469 var Transform = /** @class */ (function () {
37471 * Create a new transform instance.
37472 * @param {number} orientation - Image orientation.
37473 * @param {number} width - Image height.
37474 * @param {number} height - Image width.
37475 * @param {number} focal - Focal length.
37476 * @param {number} scale - Atomic scale.
37477 * @param {IGPano} gpano - Panorama properties.
37478 * @param {Array<number>} rotation - Rotation vector in three dimensions.
37479 * @param {Array<number>} translation - Translation vector in three dimensions.
37480 * @param {HTMLImageElement} image - Image for fallback size calculations.
37482 function Transform(orientation, width, height, focal, scale, gpano, rotation, translation, image, textureScale, ck1, ck2) {
37483 this._orientation = this._getValue(orientation, 1);
37484 var imageWidth = image != null ? image.width : 4;
37485 var imageHeight = image != null ? image.height : 3;
37486 var keepOrientation = this._orientation < 5;
37487 this._width = this._getValue(width, keepOrientation ? imageWidth : imageHeight);
37488 this._height = this._getValue(height, keepOrientation ? imageHeight : imageWidth);
37489 this._basicAspect = keepOrientation ?
37490 this._width / this._height :
37491 this._height / this._width;
37492 this._basicWidth = keepOrientation ? width : height;
37493 this._basicHeight = keepOrientation ? height : width;
37494 this._focal = this._getValue(focal, 1);
37495 this._scale = this._getValue(scale, 0);
37496 this._gpano = gpano != null ? gpano : null;
37497 this._rt = this._getRt(rotation, translation);
37498 this._srt = this._getSrt(this._rt, this._scale);
37499 this._basicRt = this._getBasicRt(this._rt, orientation);
37500 this._textureScale = !!textureScale ? textureScale : [1, 1];
37501 this._ck1 = !!ck1 ? ck1 : 0;
37502 this._ck2 = !!ck2 ? ck2 : 0;
37503 this._radialPeak = this._getRadialPeak(this._ck1, this._ck2);
37505 Object.defineProperty(Transform.prototype, "ck1", {
37512 Object.defineProperty(Transform.prototype, "ck2", {
37519 Object.defineProperty(Transform.prototype, "basicAspect", {
37521 * Get basic aspect.
37522 * @returns {number} The orientation adjusted aspect ratio.
37525 return this._basicAspect;
37530 Object.defineProperty(Transform.prototype, "basicHeight", {
37532 * Get basic height.
37534 * @description Does not fall back to node image height but
37535 * uses original value from API so can be faulty.
37537 * @returns {number} The height of the basic version image
37538 * (adjusted for orientation).
37541 return this._basicHeight;
37546 Object.defineProperty(Transform.prototype, "basicRt", {
37548 return this._basicRt;
37553 Object.defineProperty(Transform.prototype, "basicWidth", {
37557 * @description Does not fall back to node image width but
37558 * uses original value from API so can be faulty.
37560 * @returns {number} The width of the basic version image
37561 * (adjusted for orientation).
37564 return this._basicWidth;
37569 Object.defineProperty(Transform.prototype, "focal", {
37572 * @returns {number} The node focal length.
37575 return this._focal;
37580 Object.defineProperty(Transform.prototype, "fullPano", {
37584 * @returns {boolean} Value indicating whether the node is a complete
37588 return this._gpano != null &&
37589 this._gpano.CroppedAreaLeftPixels === 0 &&
37590 this._gpano.CroppedAreaTopPixels === 0 &&
37591 this._gpano.CroppedAreaImageWidthPixels === this._gpano.FullPanoWidthPixels &&
37592 this._gpano.CroppedAreaImageHeightPixels === this._gpano.FullPanoHeightPixels;
37597 Object.defineProperty(Transform.prototype, "gpano", {
37600 * @returns {number} The node gpano information.
37603 return this._gpano;
37608 Object.defineProperty(Transform.prototype, "height", {
37612 * @description Falls back to the node image height if
37613 * the API data is faulty.
37615 * @returns {number} The orientation adjusted image height.
37618 return this._height;
37623 Object.defineProperty(Transform.prototype, "orientation", {
37626 * @returns {number} The image orientation.
37629 return this._orientation;
37634 Object.defineProperty(Transform.prototype, "rt", {
37637 * @returns {THREE.Matrix4} The extrinsic camera matrix.
37645 Object.defineProperty(Transform.prototype, "srt", {
37648 * @returns {THREE.Matrix4} The scaled extrinsic camera matrix.
37656 Object.defineProperty(Transform.prototype, "scale", {
37659 * @returns {number} The node atomic reconstruction scale.
37662 return this._scale;
37667 Object.defineProperty(Transform.prototype, "hasValidScale", {
37669 * Get has valid scale.
37670 * @returns {boolean} Value indicating if the scale of the transform is valid.
37673 return this._scale > 1e-2 && this._scale < 50;
37678 Object.defineProperty(Transform.prototype, "radialPeak", {
37681 * @returns {number} Value indicating the radius where the radial
37682 * undistortion function peaks.
37685 return this._radialPeak;
37690 Object.defineProperty(Transform.prototype, "width", {
37694 * @description Falls back to the node image width if
37695 * the API data is faulty.
37697 * @returns {number} The orientation adjusted image width.
37700 return this._width;
37706 * Calculate the up vector for the node transform.
37708 * @returns {THREE.Vector3} Normalized and orientation adjusted up vector.
37710 Transform.prototype.upVector = function () {
37711 var rte = this._rt.elements;
37712 switch (this._orientation) {
37714 return new THREE.Vector3(-rte[1], -rte[5], -rte[9]);
37716 return new THREE.Vector3(rte[1], rte[5], rte[9]);
37718 return new THREE.Vector3(-rte[0], -rte[4], -rte[8]);
37720 return new THREE.Vector3(rte[0], rte[4], rte[8]);
37722 return new THREE.Vector3(-rte[1], -rte[5], -rte[9]);
37726 * Calculate projector matrix for projecting 3D points to texture map
37727 * coordinates (u and v).
37729 * @returns {THREE.Matrix4} Projection matrix for 3D point to texture
37730 * map coordinate calculations.
37732 Transform.prototype.projectorMatrix = function () {
37733 var projector = this._normalizedToTextureMatrix();
37734 var f = this._focal;
37735 var projection = new THREE.Matrix4().set(f, 0, 0, 0, 0, f, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0);
37736 projector.multiply(projection);
37737 projector.multiply(this._rt);
37741 * Project 3D world coordinates to basic coordinates.
37743 * @param {Array<number>} point3d - 3D world coordinates.
37744 * @return {Array<number>} 2D basic coordinates.
37746 Transform.prototype.projectBasic = function (point3d) {
37747 var sfm = this.projectSfM(point3d);
37748 return this._sfmToBasic(sfm);
37751 * Unproject basic coordinates to 3D world coordinates.
37753 * @param {Array<number>} basic - 2D basic coordinates.
37754 * @param {Array<number>} distance - Distance to unproject from camera center.
37755 * @param {boolean} [depth] - Treat the distance value as depth from camera center.
37756 * Only applicable for perspective images. Will be
37757 * ignored for panoramas.
37758 * @returns {Array<number>} Unprojected 3D world coordinates.
37760 Transform.prototype.unprojectBasic = function (basic, distance, depth) {
37761 var sfm = this._basicToSfm(basic);
37762 return this.unprojectSfM(sfm, distance, depth);
37765 * Project 3D world coordinates to SfM coordinates.
37767 * @param {Array<number>} point3d - 3D world coordinates.
37768 * @return {Array<number>} 2D SfM coordinates.
37770 Transform.prototype.projectSfM = function (point3d) {
37771 var v = new THREE.Vector4(point3d[0], point3d[1], point3d[2], 1);
37772 v.applyMatrix4(this._rt);
37773 return this._bearingToSfm([v.x, v.y, v.z]);
37776 * Unproject SfM coordinates to a 3D world coordinates.
37778 * @param {Array<number>} sfm - 2D SfM coordinates.
37779 * @param {Array<number>} distance - Distance to unproject from camera center.
37780 * @param {boolean} [depth] - Treat the distance value as depth from camera center.
37781 * Only applicable for perspective images. Will be
37782 * ignored for panoramas.
37783 * @returns {Array<number>} Unprojected 3D world coordinates.
37785 Transform.prototype.unprojectSfM = function (sfm, distance, depth) {
37786 var bearing = this._sfmToBearing(sfm);
37787 var v = depth && !this.gpano ?
37788 new THREE.Vector4(distance * bearing[0] / bearing[2], distance * bearing[1] / bearing[2], distance, 1) :
37789 new THREE.Vector4(distance * bearing[0], distance * bearing[1], distance * bearing[2], 1);
37790 v.applyMatrix4(new THREE.Matrix4().getInverse(this._rt));
37791 return [v.x / v.w, v.y / v.w, v.z / v.w];
37794 * Transform SfM coordinates to bearing vector (3D cartesian
37795 * coordinates on the unit sphere).
37797 * @param {Array<number>} sfm - 2D SfM coordinates.
37798 * @returns {Array<number>} Bearing vector (3D cartesian coordinates
37799 * on the unit sphere).
37801 Transform.prototype._sfmToBearing = function (sfm) {
37802 if (this._fullPano()) {
37803 var lon = sfm[0] * 2 * Math.PI;
37804 var lat = -sfm[1] * 2 * Math.PI;
37805 var x = Math.cos(lat) * Math.sin(lon);
37806 var y = -Math.sin(lat);
37807 var z = Math.cos(lat) * Math.cos(lon);
37810 else if (this._gpano) {
37811 var size = Math.max(this.gpano.CroppedAreaImageWidthPixels, this.gpano.CroppedAreaImageHeightPixels);
37812 var fullPanoPixel = [
37813 sfm[0] * size + this.gpano.CroppedAreaImageWidthPixels / 2 + this.gpano.CroppedAreaLeftPixels,
37814 sfm[1] * size + this.gpano.CroppedAreaImageHeightPixels / 2 + this.gpano.CroppedAreaTopPixels,
37816 var lon = 2 * Math.PI * (fullPanoPixel[0] / this.gpano.FullPanoWidthPixels - 0.5);
37817 var lat = -Math.PI * (fullPanoPixel[1] / this.gpano.FullPanoHeightPixels - 0.5);
37818 var x = Math.cos(lat) * Math.sin(lon);
37819 var y = -Math.sin(lat);
37820 var z = Math.cos(lat) * Math.cos(lon);
37824 var _a = [sfm[0] / this._focal, sfm[1] / this._focal], dxn = _a[0], dyn = _a[1];
37825 var rp = this._radialPeak;
37826 var dr = Math.sqrt(dxn * dxn + dyn * dyn);
37828 for (var i = 0; i < 10; i++) {
37833 d = 1 + this._ck1 * Math.pow(r, 2) + this._ck2 * Math.pow(r, 4);
37837 var v = new THREE.Vector3(xn, yn, 1);
37839 return [v.x, v.y, v.z];
37843 * Transform bearing vector (3D cartesian coordiantes on the unit sphere) to
37846 * @param {Array<number>} bearing - Bearing vector (3D cartesian coordinates on the
37848 * @returns {Array<number>} 2D SfM coordinates.
37850 Transform.prototype._bearingToSfm = function (bearing) {
37851 if (this._fullPano()) {
37852 var x = bearing[0];
37853 var y = bearing[1];
37854 var z = bearing[2];
37855 var lon = Math.atan2(x, z);
37856 var lat = Math.atan2(-y, Math.sqrt(x * x + z * z));
37857 return [lon / (2 * Math.PI), -lat / (2 * Math.PI)];
37859 else if (this._gpano) {
37860 var x = bearing[0];
37861 var y = bearing[1];
37862 var z = bearing[2];
37863 var lon = Math.atan2(x, z);
37864 var lat = Math.atan2(-y, Math.sqrt(x * x + z * z));
37865 var fullPanoPixel = [
37866 (lon / (2 * Math.PI) + 0.5) * this.gpano.FullPanoWidthPixels,
37867 (-lat / Math.PI + 0.5) * this.gpano.FullPanoHeightPixels,
37869 var size = Math.max(this.gpano.CroppedAreaImageWidthPixels, this.gpano.CroppedAreaImageHeightPixels);
37871 (fullPanoPixel[0] - this.gpano.CroppedAreaLeftPixels - this.gpano.CroppedAreaImageWidthPixels / 2) / size,
37872 (fullPanoPixel[1] - this.gpano.CroppedAreaTopPixels - this.gpano.CroppedAreaImageHeightPixels / 2) / size,
37876 if (bearing[2] > 0) {
37877 var _a = [bearing[0] / bearing[2], bearing[1] / bearing[2]], xn = _a[0], yn = _a[1];
37878 var r2 = xn * xn + yn * yn;
37879 var rp2 = Math.pow(this._radialPeak, 2);
37883 var d = 1 + this._ck1 * r2 + this._ck2 * Math.pow(r2, 2);
37885 this._focal * d * xn,
37886 this._focal * d * yn,
37891 bearing[0] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
37892 bearing[1] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
37898 * Convert basic coordinates to SfM coordinates.
37900 * @param {Array<number>} basic - 2D basic coordinates.
37901 * @returns {Array<number>} 2D SfM coordinates.
37903 Transform.prototype._basicToSfm = function (basic) {
37906 switch (this._orientation) {
37908 rotatedX = basic[0];
37909 rotatedY = basic[1];
37912 rotatedX = 1 - basic[0];
37913 rotatedY = 1 - basic[1];
37916 rotatedX = basic[1];
37917 rotatedY = 1 - basic[0];
37920 rotatedX = 1 - basic[1];
37921 rotatedY = basic[0];
37924 rotatedX = basic[0];
37925 rotatedY = basic[1];
37928 var w = this._width;
37929 var h = this._height;
37930 var s = Math.max(w, h);
37931 var sfmX = rotatedX * w / s - w / s / 2;
37932 var sfmY = rotatedY * h / s - h / s / 2;
37933 return [sfmX, sfmY];
37936 * Convert SfM coordinates to basic coordinates.
37938 * @param {Array<number>} sfm - 2D SfM coordinates.
37939 * @returns {Array<number>} 2D basic coordinates.
37941 Transform.prototype._sfmToBasic = function (sfm) {
37942 var w = this._width;
37943 var h = this._height;
37944 var s = Math.max(w, h);
37945 var rotatedX = (sfm[0] + w / s / 2) / w * s;
37946 var rotatedY = (sfm[1] + h / s / 2) / h * s;
37949 switch (this._orientation) {
37955 basicX = 1 - rotatedX;
37956 basicY = 1 - rotatedY;
37959 basicX = 1 - rotatedY;
37964 basicY = 1 - rotatedX;
37971 return [basicX, basicY];
37974 * Determines if the gpano information indicates a full panorama.
37976 * @returns {boolean} Value determining if the gpano information indicates
37979 Transform.prototype._fullPano = function () {
37980 return this.gpano != null &&
37981 this.gpano.CroppedAreaLeftPixels === 0 &&
37982 this.gpano.CroppedAreaTopPixels === 0 &&
37983 this.gpano.CroppedAreaImageWidthPixels === this.gpano.FullPanoWidthPixels &&
37984 this.gpano.CroppedAreaImageHeightPixels === this.gpano.FullPanoHeightPixels;
37987 * Checks a value and returns it if it exists and is larger than 0.
37988 * Fallbacks if it is null.
37990 * @param {number} value - Value to check.
37991 * @param {number} fallback - Value to fall back to.
37992 * @returns {number} The value or its fallback value if it is not defined or negative.
37994 Transform.prototype._getValue = function (value, fallback) {
37995 return value != null && value > 0 ? value : fallback;
37998 * Creates the extrinsic camera matrix [ R | t ].
38000 * @param {Array<number>} rotation - Rotation vector in angle axis representation.
38001 * @param {Array<number>} translation - Translation vector.
38002 * @returns {THREE.Matrix4} Extrisic camera matrix.
38004 Transform.prototype._getRt = function (rotation, translation) {
38005 var axis = new THREE.Vector3(rotation[0], rotation[1], rotation[2]);
38006 var angle = axis.length();
38010 var rt = new THREE.Matrix4();
38011 rt.makeRotationAxis(axis, angle);
38012 rt.setPosition(new THREE.Vector3(translation[0], translation[1], translation[2]));
38016 * Calculates the scaled extrinsic camera matrix scale * [ R | t ].
38018 * @param {THREE.Matrix4} rt - Extrisic camera matrix.
38019 * @param {number} scale - Scale factor.
38020 * @returns {THREE.Matrix4} Scaled extrisic camera matrix.
38022 Transform.prototype._getSrt = function (rt, scale) {
38023 var srt = rt.clone();
38024 var elements = srt.elements;
38025 elements[12] = scale * elements[12];
38026 elements[13] = scale * elements[13];
38027 elements[14] = scale * elements[14];
38028 srt.scale(new THREE.Vector3(scale, scale, scale));
38031 Transform.prototype._getBasicRt = function (rt, orientation) {
38032 var axis = new THREE.Vector3(0, 0, 1);
38034 switch (orientation) {
38039 angle = Math.PI / 2;
38042 angle = 3 * Math.PI / 2;
38047 return new THREE.Matrix4()
38048 .makeRotationAxis(axis, angle)
38051 Transform.prototype._getRadialPeak = function (k1, k2) {
38055 var d = Math.pow(b, 2) - 4 * a * c;
38059 var root1 = (-b - Math.sqrt(d)) / 2 / a;
38060 var root2 = (-b + Math.sqrt(d)) / 2 / a;
38061 var minRoot = Math.min(root1, root2);
38062 var maxRoot = Math.max(root1, root2);
38063 return minRoot > 0 ?
38064 Math.sqrt(minRoot) :
38066 Math.sqrt(maxRoot) :
38070 * Calculate a transformation matrix from normalized coordinates for
38071 * texture map coordinates.
38073 * @returns {THREE.Matrix4} Normalized coordinates to texture map
38074 * coordinates transformation matrix.
38076 Transform.prototype._normalizedToTextureMatrix = function () {
38077 var size = Math.max(this._width, this._height);
38078 var scaleX = this._orientation < 5 ? this._textureScale[0] : this._textureScale[1];
38079 var scaleY = this._orientation < 5 ? this._textureScale[1] : this._textureScale[0];
38080 var w = size / this._width * scaleX;
38081 var h = size / this._height * scaleY;
38082 switch (this._orientation) {
38084 return new THREE.Matrix4().set(w, 0, 0, 0.5, 0, -h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
38086 return new THREE.Matrix4().set(-w, 0, 0, 0.5, 0, h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
38088 return new THREE.Matrix4().set(0, -h, 0, 0.5, -w, 0, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
38090 return new THREE.Matrix4().set(0, h, 0, 0.5, w, 0, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
38092 return new THREE.Matrix4().set(w, 0, 0, 0.5, 0, -h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
38097 exports.Transform = Transform;
38099 },{"three":226}],388:[function(require,module,exports){
38101 Object.defineProperty(exports, "__esModule", { value: true });
38102 var THREE = require("three");
38104 * @class ViewportCoords
38106 * @classdesc Provides methods for calculating 2D coordinate conversions
38107 * as well as 3D projection and unprojection.
38109 * Basic coordinates are 2D coordinates on the [0, 1] interval and
38110 * have the origin point, (0, 0), at the top left corner and the
38111 * maximum value, (1, 1), at the bottom right corner of the original
38114 * Viewport coordinates are 2D coordinates on the [-1, 1] interval and
38115 * have the origin point in the center. The bottom left corner point is
38116 * (-1, -1) and the top right corner point is (1, 1).
38118 * Canvas coordiantes are 2D pixel coordinates on the [0, canvasWidth] and
38119 * [0, canvasHeight] intervals. The origin point (0, 0) is in the top left
38120 * corner and the maximum value is (canvasWidth, canvasHeight) is in the
38121 * bottom right corner.
38123 * 3D coordinates are in the topocentric world reference frame.
38125 var ViewportCoords = /** @class */ (function () {
38126 function ViewportCoords() {
38127 this._unprojectDepth = 200;
38130 * Convert basic coordinates to canvas coordinates.
38132 * @description Transform origin and camera position needs to be the
38133 * equal for reliable return value.
38135 * @param {number} basicX - Basic X coordinate.
38136 * @param {number} basicY - Basic Y coordinate.
38137 * @param {HTMLElement} container - The viewer container.
38138 * @param {Transform} transform - Transform of the node to unproject from.
38139 * @param {THREE.Camera} camera - Camera used in rendering.
38140 * @returns {Array<number>} 2D canvas coordinates.
38142 ViewportCoords.prototype.basicToCanvas = function (basicX, basicY, container, transform, camera) {
38143 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
38144 var canvas = this.projectToCanvas(point3d, container, camera);
38148 * Convert basic coordinates to canvas coordinates safely. If 3D point is
38149 * behind camera null will be returned.
38151 * @description Transform origin and camera position needs to be the
38152 * equal for reliable return value.
38154 * @param {number} basicX - Basic X coordinate.
38155 * @param {number} basicY - Basic Y coordinate.
38156 * @param {HTMLElement} container - The viewer container.
38157 * @param {Transform} transform - Transform of the node to unproject from.
38158 * @param {THREE.Camera} camera - Camera used in rendering.
38159 * @returns {Array<number>} 2D canvas coordinates if the basic point represents a 3D point
38160 * in front of the camera, otherwise null.
38162 ViewportCoords.prototype.basicToCanvasSafe = function (basicX, basicY, container, transform, camera) {
38163 var viewport = this.basicToViewportSafe(basicX, basicY, transform, camera);
38164 if (viewport === null) {
38167 var canvas = this.viewportToCanvas(viewport[0], viewport[1], container);
38171 * Convert basic coordinates to viewport coordinates.
38173 * @description Transform origin and camera position needs to be the
38174 * equal for reliable return value.
38176 * @param {number} basicX - Basic X coordinate.
38177 * @param {number} basicY - Basic Y coordinate.
38178 * @param {Transform} transform - Transform of the node to unproject from.
38179 * @param {THREE.Camera} camera - Camera used in rendering.
38180 * @returns {Array<number>} 2D viewport coordinates.
38182 ViewportCoords.prototype.basicToViewport = function (basicX, basicY, transform, camera) {
38183 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
38184 var viewport = this.projectToViewport(point3d, camera);
38188 * Convert basic coordinates to viewport coordinates safely. If 3D point is
38189 * behind camera null will be returned.
38191 * @description Transform origin and camera position needs to be the
38192 * equal for reliable return value.
38194 * @param {number} basicX - Basic X coordinate.
38195 * @param {number} basicY - Basic Y coordinate.
38196 * @param {Transform} transform - Transform of the node to unproject from.
38197 * @param {THREE.Camera} camera - Camera used in rendering.
38198 * @returns {Array<number>} 2D viewport coordinates.
38200 ViewportCoords.prototype.basicToViewportSafe = function (basicX, basicY, transform, camera) {
38201 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
38202 var pointCamera = this.worldToCamera(point3d, camera);
38203 if (pointCamera[2] > 0) {
38206 var viewport = this.projectToViewport(point3d, camera);
38210 * Convert camera 3D coordinates to viewport coordinates.
38212 * @param {number} pointCamera - 3D point in camera coordinate system.
38213 * @param {THREE.Camera} camera - Camera used in rendering.
38214 * @returns {Array<number>} 2D viewport coordinates.
38216 ViewportCoords.prototype.cameraToViewport = function (pointCamera, camera) {
38217 var viewport = new THREE.Vector3().fromArray(pointCamera)
38218 .applyMatrix4(camera.projectionMatrix);
38219 return [viewport.x, viewport.y];
38222 * Get canvas pixel position from event.
38224 * @param {Event} event - Event containing clientX and clientY properties.
38225 * @param {HTMLElement} element - HTML element.
38226 * @returns {Array<number>} 2D canvas coordinates.
38228 ViewportCoords.prototype.canvasPosition = function (event, element) {
38229 var clientRect = element.getBoundingClientRect();
38230 var canvasX = event.clientX - clientRect.left - element.clientLeft;
38231 var canvasY = event.clientY - clientRect.top - element.clientTop;
38232 return [canvasX, canvasY];
38235 * Convert canvas coordinates to basic coordinates.
38237 * @description Transform origin and camera position needs to be the
38238 * equal for reliable return value.
38240 * @param {number} canvasX - Canvas X coordinate.
38241 * @param {number} canvasY - Canvas Y coordinate.
38242 * @param {HTMLElement} container - The viewer container.
38243 * @param {Transform} transform - Transform of the node to unproject from.
38244 * @param {THREE.Camera} camera - Camera used in rendering.
38245 * @returns {Array<number>} 2D basic coordinates.
38247 ViewportCoords.prototype.canvasToBasic = function (canvasX, canvasY, container, transform, camera) {
38248 var point3d = this.unprojectFromCanvas(canvasX, canvasY, container, camera)
38250 var basic = transform.projectBasic(point3d);
38254 * Convert canvas coordinates to viewport coordinates.
38256 * @param {number} canvasX - Canvas X coordinate.
38257 * @param {number} canvasY - Canvas Y coordinate.
38258 * @param {HTMLElement} container - The viewer container.
38259 * @returns {Array<number>} 2D viewport coordinates.
38261 ViewportCoords.prototype.canvasToViewport = function (canvasX, canvasY, container) {
38262 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
38263 var viewportX = 2 * canvasX / canvasWidth - 1;
38264 var viewportY = 1 - 2 * canvasY / canvasHeight;
38265 return [viewportX, viewportY];
38268 * Determines the width and height of the container in canvas coordinates.
38270 * @param {HTMLElement} container - The viewer container.
38271 * @returns {Array<number>} 2D canvas coordinates.
38273 ViewportCoords.prototype.containerToCanvas = function (container) {
38274 return [container.offsetWidth, container.offsetHeight];
38277 * Determine basic distances from image to canvas corners.
38279 * @description Transform origin and camera position needs to be the
38280 * equal for reliable return value.
38282 * Determines the smallest basic distance for every side of the canvas.
38284 * @param {Transform} transform - Transform of the node to unproject from.
38285 * @param {THREE.Camera} camera - Camera used in rendering.
38286 * @returns {Array<number>} Array of basic distances as [top, right, bottom, left].
38288 ViewportCoords.prototype.getBasicDistances = function (transform, camera) {
38289 var topLeftBasic = this.viewportToBasic(-1, 1, transform, camera);
38290 var topRightBasic = this.viewportToBasic(1, 1, transform, camera);
38291 var bottomRightBasic = this.viewportToBasic(1, -1, transform, camera);
38292 var bottomLeftBasic = this.viewportToBasic(-1, -1, transform, camera);
38293 var topBasicDistance = 0;
38294 var rightBasicDistance = 0;
38295 var bottomBasicDistance = 0;
38296 var leftBasicDistance = 0;
38297 if (topLeftBasic[1] < 0 && topRightBasic[1] < 0) {
38298 topBasicDistance = topLeftBasic[1] > topRightBasic[1] ?
38302 if (topRightBasic[0] > 1 && bottomRightBasic[0] > 1) {
38303 rightBasicDistance = topRightBasic[0] < bottomRightBasic[0] ?
38304 topRightBasic[0] - 1 :
38305 bottomRightBasic[0] - 1;
38307 if (bottomRightBasic[1] > 1 && bottomLeftBasic[1] > 1) {
38308 bottomBasicDistance = bottomRightBasic[1] < bottomLeftBasic[1] ?
38309 bottomRightBasic[1] - 1 :
38310 bottomLeftBasic[1] - 1;
38312 if (bottomLeftBasic[0] < 0 && topLeftBasic[0] < 0) {
38313 leftBasicDistance = bottomLeftBasic[0] > topLeftBasic[0] ?
38314 -bottomLeftBasic[0] :
38317 return [topBasicDistance, rightBasicDistance, bottomBasicDistance, leftBasicDistance];
38320 * Determine pixel distances from image to canvas corners.
38322 * @description Transform origin and camera position needs to be the
38323 * equal for reliable return value.
38325 * Determines the smallest pixel distance for every side of the canvas.
38327 * @param {HTMLElement} container - The viewer container.
38328 * @param {Transform} transform - Transform of the node to unproject from.
38329 * @param {THREE.Camera} camera - Camera used in rendering.
38330 * @returns {Array<number>} Array of pixel distances as [top, right, bottom, left].
38332 ViewportCoords.prototype.getPixelDistances = function (container, transform, camera) {
38333 var topLeftBasic = this.viewportToBasic(-1, 1, transform, camera);
38334 var topRightBasic = this.viewportToBasic(1, 1, transform, camera);
38335 var bottomRightBasic = this.viewportToBasic(1, -1, transform, camera);
38336 var bottomLeftBasic = this.viewportToBasic(-1, -1, transform, camera);
38337 var topPixelDistance = 0;
38338 var rightPixelDistance = 0;
38339 var bottomPixelDistance = 0;
38340 var leftPixelDistance = 0;
38341 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
38342 if (topLeftBasic[1] < 0 && topRightBasic[1] < 0) {
38343 var basicX = topLeftBasic[1] > topRightBasic[1] ?
38346 var canvas = this.basicToCanvas(basicX, 0, container, transform, camera);
38347 topPixelDistance = canvas[1] > 0 ? canvas[1] : 0;
38349 if (topRightBasic[0] > 1 && bottomRightBasic[0] > 1) {
38350 var basicY = topRightBasic[0] < bottomRightBasic[0] ?
38352 bottomRightBasic[1];
38353 var canvas = this.basicToCanvas(1, basicY, container, transform, camera);
38354 rightPixelDistance = canvas[0] < canvasWidth ? canvasWidth - canvas[0] : 0;
38356 if (bottomRightBasic[1] > 1 && bottomLeftBasic[1] > 1) {
38357 var basicX = bottomRightBasic[1] < bottomLeftBasic[1] ?
38358 bottomRightBasic[0] :
38359 bottomLeftBasic[0];
38360 var canvas = this.basicToCanvas(basicX, 1, container, transform, camera);
38361 bottomPixelDistance = canvas[1] < canvasHeight ? canvasHeight - canvas[1] : 0;
38363 if (bottomLeftBasic[0] < 0 && topLeftBasic[0] < 0) {
38364 var basicY = bottomLeftBasic[0] > topLeftBasic[0] ?
38365 bottomLeftBasic[1] :
38367 var canvas = this.basicToCanvas(0, basicY, container, transform, camera);
38368 leftPixelDistance = canvas[0] > 0 ? canvas[0] : 0;
38370 return [topPixelDistance, rightPixelDistance, bottomPixelDistance, leftPixelDistance];
38373 * Determine if an event occured inside an element.
38375 * @param {Event} event - Event containing clientX and clientY properties.
38376 * @param {HTMLElement} element - HTML element.
38377 * @returns {boolean} Value indicating if the event occured inside the element or not.
38379 ViewportCoords.prototype.insideElement = function (event, element) {
38380 var clientRect = element.getBoundingClientRect();
38381 var minX = clientRect.left + element.clientLeft;
38382 var maxX = minX + element.clientWidth;
38383 var minY = clientRect.top + element.clientTop;
38384 var maxY = minY + element.clientHeight;
38385 return event.clientX > minX &&
38386 event.clientX < maxX &&
38387 event.clientY > minY &&
38388 event.clientY < maxY;
38391 * Project 3D world coordinates to canvas coordinates.
38393 * @param {Array<number>} point3D - 3D world coordinates.
38394 * @param {HTMLElement} container - The viewer container.
38395 * @param {THREE.Camera} camera - Camera used in rendering.
38396 * @returns {Array<number>} 2D canvas coordinates.
38398 ViewportCoords.prototype.projectToCanvas = function (point3d, container, camera) {
38399 var viewport = this.projectToViewport(point3d, camera);
38400 var canvas = this.viewportToCanvas(viewport[0], viewport[1], container);
38404 * Project 3D world coordinates to viewport coordinates.
38406 * @param {Array<number>} point3D - 3D world coordinates.
38407 * @param {THREE.Camera} camera - Camera used in rendering.
38408 * @returns {Array<number>} 2D viewport coordinates.
38410 ViewportCoords.prototype.projectToViewport = function (point3d, camera) {
38411 var viewport = new THREE.Vector3(point3d[0], point3d[1], point3d[2])
38413 return [viewport.x, viewport.y];
38416 * Uproject canvas coordinates to 3D world coordinates.
38418 * @param {number} canvasX - Canvas X coordinate.
38419 * @param {number} canvasY - Canvas Y coordinate.
38420 * @param {HTMLElement} container - The viewer container.
38421 * @param {THREE.Camera} camera - Camera used in rendering.
38422 * @returns {Array<number>} 3D world coordinates.
38424 ViewportCoords.prototype.unprojectFromCanvas = function (canvasX, canvasY, container, camera) {
38425 var viewport = this.canvasToViewport(canvasX, canvasY, container);
38426 var point3d = this.unprojectFromViewport(viewport[0], viewport[1], camera);
38430 * Unproject viewport coordinates to 3D world coordinates.
38432 * @param {number} viewportX - Viewport X coordinate.
38433 * @param {number} viewportY - Viewport Y coordinate.
38434 * @param {THREE.Camera} camera - Camera used in rendering.
38435 * @returns {Array<number>} 3D world coordinates.
38437 ViewportCoords.prototype.unprojectFromViewport = function (viewportX, viewportY, camera) {
38438 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
38439 .unproject(camera);
38443 * Convert viewport coordinates to basic coordinates.
38445 * @description Transform origin and camera position needs to be the
38446 * equal for reliable return value.
38448 * @param {number} viewportX - Viewport X coordinate.
38449 * @param {number} viewportY - Viewport Y coordinate.
38450 * @param {Transform} transform - Transform of the node to unproject from.
38451 * @param {THREE.Camera} camera - Camera used in rendering.
38452 * @returns {Array<number>} 2D basic coordinates.
38454 ViewportCoords.prototype.viewportToBasic = function (viewportX, viewportY, transform, camera) {
38455 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
38458 var basic = transform.projectBasic(point3d);
38462 * Convert viewport coordinates to canvas coordinates.
38464 * @param {number} viewportX - Viewport X coordinate.
38465 * @param {number} viewportY - Viewport Y coordinate.
38466 * @param {HTMLElement} container - The viewer container.
38467 * @returns {Array<number>} 2D canvas coordinates.
38469 ViewportCoords.prototype.viewportToCanvas = function (viewportX, viewportY, container) {
38470 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
38471 var canvasX = canvasWidth * (viewportX + 1) / 2;
38472 var canvasY = -canvasHeight * (viewportY - 1) / 2;
38473 return [canvasX, canvasY];
38476 * Convert 3D world coordinates to 3D camera coordinates.
38478 * @param {number} point3D - 3D point in world coordinate system.
38479 * @param {THREE.Camera} camera - Camera used in rendering.
38480 * @returns {Array<number>} 3D camera coordinates.
38482 ViewportCoords.prototype.worldToCamera = function (point3d, camera) {
38483 var pointCamera = new THREE.Vector3(point3d[0], point3d[1], point3d[2])
38484 .applyMatrix4(camera.matrixWorldInverse);
38485 return pointCamera.toArray();
38487 return ViewportCoords;
38489 exports.ViewportCoords = ViewportCoords;
38490 exports.default = ViewportCoords;
38493 },{"three":226}],389:[function(require,module,exports){
38495 Object.defineProperty(exports, "__esModule", { value: true });
38499 * @classdesc Represents a class for creating node filters. Implementation and
38500 * definitions based on https://github.com/mapbox/feature-filter.
38502 var FilterCreator = /** @class */ (function () {
38503 function FilterCreator() {
38506 * Create a filter from a filter expression.
38508 * @description The following filters are supported:
38525 * @param {FilterExpression} filter - Comparison, set membership or combinding filter
38527 * @returns {FilterFunction} Function taking a node and returning a boolean that
38528 * indicates whether the node passed the test or not.
38530 FilterCreator.prototype.createFilter = function (filter) {
38531 return new Function("node", "return " + this._compile(filter) + ";");
38533 FilterCreator.prototype._compile = function (filter) {
38534 if (filter == null || filter.length <= 1) {
38537 var operator = filter[0];
38538 var operation = operator === "==" ? this._compileComparisonOp("===", filter[1], filter[2], false) :
38539 operator === "!=" ? this._compileComparisonOp("!==", filter[1], filter[2], false) :
38540 operator === ">" ||
38541 operator === ">=" ||
38542 operator === "<" ||
38543 operator === "<=" ? this._compileComparisonOp(operator, filter[1], filter[2], true) :
38544 operator === "in" ?
38545 this._compileInOp(filter[1], filter.slice(2)) :
38546 operator === "!in" ?
38547 this._compileNegation(this._compileInOp(filter[1], filter.slice(2))) :
38548 operator === "all" ? this._compileLogicalOp(filter.slice(1), "&&") :
38550 return "(" + operation + ")";
38552 FilterCreator.prototype._compare = function (a, b) {
38553 return a < b ? -1 : a > b ? 1 : 0;
38555 FilterCreator.prototype._compileComparisonOp = function (operator, property, value, checkType) {
38556 var left = this._compilePropertyReference(property);
38557 var right = JSON.stringify(value);
38558 return (checkType ? "typeof " + left + "===typeof " + right + "&&" : "") + left + operator + right;
38560 FilterCreator.prototype._compileInOp = function (property, values) {
38561 var compare = this._compare;
38562 var left = JSON.stringify(values.sort(compare));
38563 var right = this._compilePropertyReference(property);
38564 return left + ".indexOf(" + right + ")!==-1";
38566 FilterCreator.prototype._compileLogicalOp = function (filters, operator) {
38567 var compile = this._compile.bind(this);
38568 return filters.map(compile).join(operator);
38570 FilterCreator.prototype._compileNegation = function (expression) {
38571 return "!(" + expression + ")";
38573 FilterCreator.prototype._compilePropertyReference = function (property) {
38574 return "node[" + JSON.stringify(property) + "]";
38576 return FilterCreator;
38578 exports.FilterCreator = FilterCreator;
38579 exports.default = FilterCreator;
38581 },{}],390:[function(require,module,exports){
38583 Object.defineProperty(exports, "__esModule", { value: true });
38584 var rxjs_1 = require("rxjs");
38585 var operators_1 = require("rxjs/operators");
38586 var rbush = require("rbush");
38587 var Edge_1 = require("../Edge");
38588 var Error_1 = require("../Error");
38589 var Graph_1 = require("../Graph");
38593 * @classdesc Represents a graph of nodes with edges.
38595 var Graph = /** @class */ (function () {
38597 * Create a new graph instance.
38599 * @param {APIv3} [apiV3] - API instance for retrieving data.
38600 * @param {rbush.RBush<NodeIndexItem>} [nodeIndex] - Node index for fast spatial retreival.
38601 * @param {GraphCalculator} [graphCalculator] - Instance for graph calculations.
38602 * @param {EdgeCalculator} [edgeCalculator] - Instance for edge calculations.
38603 * @param {FilterCreator} [filterCreator] - Instance for filter creation.
38604 * @param {IGraphConfiguration} [configuration] - Configuration struct.
38606 function Graph(apiV3, nodeIndex, graphCalculator, edgeCalculator, filterCreator, configuration) {
38607 this._apiV3 = apiV3;
38608 this._cachedNodes = {};
38609 this._cachedNodeTiles = {};
38610 this._cachedSequenceNodes = {};
38611 this._cachedSpatialEdges = {};
38612 this._cachedTiles = {};
38613 this._cachingFill$ = {};
38614 this._cachingFull$ = {};
38615 this._cachingSequenceNodes$ = {};
38616 this._cachingSequences$ = {};
38617 this._cachingSpatialArea$ = {};
38618 this._cachingTiles$ = {};
38619 this._changed$ = new rxjs_1.Subject();
38620 this._defaultAlt = 2;
38621 this._edgeCalculator = edgeCalculator != null ? edgeCalculator : new Edge_1.EdgeCalculator();
38622 this._filterCreator = filterCreator != null ? filterCreator : new Graph_1.FilterCreator();
38623 this._filter = this._filterCreator.createFilter(undefined);
38624 this._graphCalculator = graphCalculator != null ? graphCalculator : new Graph_1.GraphCalculator();
38625 this._configuration = configuration != null ?
38629 maxUnusedNodes: 100,
38630 maxUnusedPreStoredNodes: 30,
38631 maxUnusedTiles: 20,
38634 this._nodeIndex = nodeIndex != null ? nodeIndex : rbush(16, [".lat", ".lon", ".lat", ".lon"]);
38635 this._nodeIndexTiles = {};
38636 this._nodeToTile = {};
38637 this._preStored = {};
38638 this._requiredNodeTiles = {};
38639 this._requiredSpatialArea = {};
38640 this._sequences = {};
38641 this._tilePrecision = 7;
38642 this._tileThreshold = 20;
38644 Object.defineProperty(Graph.prototype, "changed$", {
38648 * @returns {Observable<Graph>} Observable emitting
38649 * the graph every time it has changed.
38652 return this._changed$;
38658 * Caches the full node data for all images within a bounding
38661 * @description The node assets are not cached.
38663 * @param {ILatLon} sw - South west corner of bounding box.
38664 * @param {ILatLon} ne - North east corner of bounding box.
38665 * @returns {Observable<Graph>} Observable emitting the full
38666 * nodes in the bounding box.
38668 Graph.prototype.cacheBoundingBox$ = function (sw, ne) {
38670 var cacheTiles$ = this._graphCalculator.encodeHsFromBoundingBox(sw, ne)
38671 .filter(function (h) {
38672 return !(h in _this._cachedTiles);
38674 .map(function (h) {
38675 return h in _this._cachingTiles$ ?
38676 _this._cachingTiles$[h] :
38677 _this._cacheTile$(h);
38679 if (cacheTiles$.length === 0) {
38680 cacheTiles$.push(rxjs_1.of(this));
38682 return rxjs_1.from(cacheTiles$).pipe(operators_1.mergeAll(), operators_1.last(), operators_1.mergeMap(function (graph) {
38683 var nodes = _this._nodeIndex
38690 .map(function (item) {
38693 var fullNodes = [];
38694 var coreNodes = [];
38695 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
38696 var node = nodes_1[_i];
38698 fullNodes.push(node);
38701 coreNodes.push(node.key);
38704 var coreNodeBatches = [];
38705 var batchSize = 200;
38706 while (coreNodes.length > 0) {
38707 coreNodeBatches.push(coreNodes.splice(0, batchSize));
38709 var fullNodes$ = rxjs_1.of(fullNodes);
38710 var fillNodes$ = coreNodeBatches
38711 .map(function (batch) {
38712 return _this._apiV3.imageByKeyFill$(batch).pipe(operators_1.map(function (imageByKeyFill) {
38713 var filledNodes = [];
38714 for (var fillKey in imageByKeyFill) {
38715 if (!imageByKeyFill.hasOwnProperty(fillKey)) {
38718 if (_this.hasNode(fillKey)) {
38719 var node = _this.getNode(fillKey);
38721 _this._makeFull(node, imageByKeyFill[fillKey]);
38723 filledNodes.push(node);
38726 return filledNodes;
38729 return rxjs_1.merge(fullNodes$, rxjs_1.from(fillNodes$).pipe(operators_1.mergeAll()));
38730 }), operators_1.reduce(function (acc, value) {
38731 return acc.concat(value);
38735 * Retrieve and cache node fill properties.
38737 * @param {string} key - Key of node to fill.
38738 * @returns {Observable<Graph>} Observable emitting the graph
38739 * when the node has been updated.
38740 * @throws {GraphMapillaryError} When the operation is not valid on the
38743 Graph.prototype.cacheFill$ = function (key) {
38745 if (key in this._cachingFull$) {
38746 throw new Error_1.GraphMapillaryError("Cannot fill node while caching full (" + key + ").");
38748 if (!this.hasNode(key)) {
38749 throw new Error_1.GraphMapillaryError("Cannot fill node that does not exist in graph (" + key + ").");
38751 if (key in this._cachingFill$) {
38752 return this._cachingFill$[key];
38754 var node = this.getNode(key);
38756 throw new Error_1.GraphMapillaryError("Cannot fill node that is already full (" + key + ").");
38758 this._cachingFill$[key] = this._apiV3.imageByKeyFill$([key]).pipe(operators_1.tap(function (imageByKeyFill) {
38760 _this._makeFull(node, imageByKeyFill[key]);
38762 delete _this._cachingFill$[key];
38763 }), operators_1.map(function (imageByKeyFill) {
38765 }), operators_1.finalize(function () {
38766 if (key in _this._cachingFill$) {
38767 delete _this._cachingFill$[key];
38769 _this._changed$.next(_this);
38770 }), operators_1.publish(), operators_1.refCount());
38771 return this._cachingFill$[key];
38774 * Retrieve and cache full node properties.
38776 * @param {string} key - Key of node to fill.
38777 * @returns {Observable<Graph>} Observable emitting the graph
38778 * when the node has been updated.
38779 * @throws {GraphMapillaryError} When the operation is not valid on the
38782 Graph.prototype.cacheFull$ = function (key) {
38784 if (key in this._cachingFull$) {
38785 return this._cachingFull$[key];
38787 if (this.hasNode(key)) {
38788 throw new Error_1.GraphMapillaryError("Cannot cache full node that already exist in graph (" + key + ").");
38790 this._cachingFull$[key] = this._apiV3.imageByKeyFull$([key]).pipe(operators_1.tap(function (imageByKeyFull) {
38791 var fn = imageByKeyFull[key];
38792 if (_this.hasNode(key)) {
38793 var node = _this.getNode(key);
38795 _this._makeFull(node, fn);
38799 if (fn.sequence_key == null) {
38800 throw new Error_1.GraphMapillaryError("Node has no sequence key (" + key + ").");
38802 var node = new Graph_1.Node(fn);
38803 _this._makeFull(node, fn);
38804 var h = _this._graphCalculator.encodeH(node.originalLatLon, _this._tilePrecision);
38805 _this._preStore(h, node);
38806 _this._setNode(node);
38807 delete _this._cachingFull$[key];
38809 }), operators_1.map(function (imageByKeyFull) {
38811 }), operators_1.finalize(function () {
38812 if (key in _this._cachingFull$) {
38813 delete _this._cachingFull$[key];
38815 _this._changed$.next(_this);
38816 }), operators_1.publish(), operators_1.refCount());
38817 return this._cachingFull$[key];
38820 * Retrieve and cache a node sequence.
38822 * @param {string} key - Key of node for which to retrieve sequence.
38823 * @returns {Observable<Graph>} Observable emitting the graph
38824 * when the sequence has been retrieved.
38825 * @throws {GraphMapillaryError} When the operation is not valid on the
38828 Graph.prototype.cacheNodeSequence$ = function (key) {
38829 if (!this.hasNode(key)) {
38830 throw new Error_1.GraphMapillaryError("Cannot cache sequence edges of node that does not exist in graph (" + key + ").");
38832 var node = this.getNode(key);
38833 if (node.sequenceKey in this._sequences) {
38834 throw new Error_1.GraphMapillaryError("Sequence already cached (" + key + "), (" + node.sequenceKey + ").");
38836 return this._cacheSequence$(node.sequenceKey);
38839 * Retrieve and cache a sequence.
38841 * @param {string} sequenceKey - Key of sequence to cache.
38842 * @returns {Observable<Graph>} Observable emitting the graph
38843 * when the sequence has been retrieved.
38844 * @throws {GraphMapillaryError} When the operation is not valid on the
38847 Graph.prototype.cacheSequence$ = function (sequenceKey) {
38848 if (sequenceKey in this._sequences) {
38849 throw new Error_1.GraphMapillaryError("Sequence already cached (" + sequenceKey + ")");
38851 return this._cacheSequence$(sequenceKey);
38854 * Cache sequence edges for a node.
38856 * @param {string} key - Key of node.
38857 * @throws {GraphMapillaryError} When the operation is not valid on the
38860 Graph.prototype.cacheSequenceEdges = function (key) {
38861 var node = this.getNode(key);
38862 if (!(node.sequenceKey in this._sequences)) {
38863 throw new Error_1.GraphMapillaryError("Sequence is not cached (" + key + "), (" + node.sequenceKey + ")");
38865 var sequence = this._sequences[node.sequenceKey].sequence;
38866 var edges = this._edgeCalculator.computeSequenceEdges(node, sequence);
38867 node.cacheSequenceEdges(edges);
38870 * Retrieve and cache full nodes for all keys in a sequence.
38872 * @param {string} sequenceKey - Key of sequence.
38873 * @param {string} referenceNodeKey - Key of node to use as reference
38874 * for optimized caching.
38875 * @returns {Observable<Graph>} Observable emitting the graph
38876 * when the nodes of the sequence has been cached.
38878 Graph.prototype.cacheSequenceNodes$ = function (sequenceKey, referenceNodeKey) {
38880 if (!this.hasSequence(sequenceKey)) {
38881 throw new Error_1.GraphMapillaryError("Cannot cache sequence nodes of sequence that does not exist in graph (" + sequenceKey + ").");
38883 if (this.hasSequenceNodes(sequenceKey)) {
38884 throw new Error_1.GraphMapillaryError("Sequence nodes already cached (" + sequenceKey + ").");
38886 var sequence = this.getSequence(sequenceKey);
38887 if (sequence.key in this._cachingSequenceNodes$) {
38888 return this._cachingSequenceNodes$[sequence.key];
38891 var keys = sequence.keys.slice();
38892 var referenceBatchSize = 50;
38893 if (!!referenceNodeKey && keys.length > referenceBatchSize) {
38894 var referenceIndex = keys.indexOf(referenceNodeKey);
38895 var startIndex = Math.max(0, Math.min(referenceIndex - referenceBatchSize / 2, keys.length - referenceBatchSize));
38896 batches.push(keys.splice(startIndex, referenceBatchSize));
38898 var batchSize = 200;
38899 while (keys.length > 0) {
38900 batches.push(keys.splice(0, batchSize));
38902 var batchesToCache = batches.length;
38903 var sequenceNodes$ = rxjs_1.from(batches).pipe(operators_1.mergeMap(function (batch) {
38904 return _this._apiV3.imageByKeyFull$(batch).pipe(operators_1.tap(function (imageByKeyFull) {
38905 for (var fullKey in imageByKeyFull) {
38906 if (!imageByKeyFull.hasOwnProperty(fullKey)) {
38909 var fn = imageByKeyFull[fullKey];
38910 if (_this.hasNode(fullKey)) {
38911 var node = _this.getNode(fn.key);
38913 _this._makeFull(node, fn);
38917 if (fn.sequence_key == null) {
38918 console.warn("Sequence missing, discarding node (" + fn.key + ")");
38920 var node = new Graph_1.Node(fn);
38921 _this._makeFull(node, fn);
38922 var h = _this._graphCalculator.encodeH(node.originalLatLon, _this._tilePrecision);
38923 _this._preStore(h, node);
38924 _this._setNode(node);
38928 }), operators_1.map(function (imageByKeyFull) {
38931 }, 6), operators_1.last(), operators_1.finalize(function () {
38932 delete _this._cachingSequenceNodes$[sequence.key];
38933 if (batchesToCache === 0) {
38934 _this._cachedSequenceNodes[sequence.key] = true;
38936 }), operators_1.publish(), operators_1.refCount());
38937 this._cachingSequenceNodes$[sequence.key] = sequenceNodes$;
38938 return sequenceNodes$;
38941 * Retrieve and cache full nodes for a node spatial area.
38943 * @param {string} key - Key of node for which to retrieve sequence.
38944 * @returns {Observable<Graph>} Observable emitting the graph
38945 * when the nodes in the spatial area has been made full.
38946 * @throws {GraphMapillaryError} When the operation is not valid on the
38949 Graph.prototype.cacheSpatialArea$ = function (key) {
38951 if (!this.hasNode(key)) {
38952 throw new Error_1.GraphMapillaryError("Cannot cache spatial area of node that does not exist in graph (" + key + ").");
38954 if (key in this._cachedSpatialEdges) {
38955 throw new Error_1.GraphMapillaryError("Node already spatially cached (" + key + ").");
38957 if (!(key in this._requiredSpatialArea)) {
38958 throw new Error_1.GraphMapillaryError("Spatial area not determined (" + key + ").");
38960 var spatialArea = this._requiredSpatialArea[key];
38961 if (Object.keys(spatialArea.cacheNodes).length === 0) {
38962 throw new Error_1.GraphMapillaryError("Spatial nodes already cached (" + key + ").");
38964 if (key in this._cachingSpatialArea$) {
38965 return this._cachingSpatialArea$[key];
38968 while (spatialArea.cacheKeys.length > 0) {
38969 batches.push(spatialArea.cacheKeys.splice(0, 200));
38971 var batchesToCache = batches.length;
38972 var spatialNodes$ = [];
38973 var _loop_1 = function (batch) {
38974 var spatialNodeBatch$ = this_1._apiV3.imageByKeyFill$(batch).pipe(operators_1.tap(function (imageByKeyFill) {
38975 for (var fillKey in imageByKeyFill) {
38976 if (!imageByKeyFill.hasOwnProperty(fillKey)) {
38979 var spatialNode = spatialArea.cacheNodes[fillKey];
38980 if (spatialNode.full) {
38981 delete spatialArea.cacheNodes[fillKey];
38984 var fillNode = imageByKeyFill[fillKey];
38985 _this._makeFull(spatialNode, fillNode);
38986 delete spatialArea.cacheNodes[fillKey];
38988 if (--batchesToCache === 0) {
38989 delete _this._cachingSpatialArea$[key];
38991 }), operators_1.map(function (imageByKeyFill) {
38993 }), operators_1.catchError(function (error) {
38994 for (var _i = 0, batch_1 = batch; _i < batch_1.length; _i++) {
38995 var batchKey = batch_1[_i];
38996 if (batchKey in spatialArea.all) {
38997 delete spatialArea.all[batchKey];
38999 if (batchKey in spatialArea.cacheNodes) {
39000 delete spatialArea.cacheNodes[batchKey];
39003 if (--batchesToCache === 0) {
39004 delete _this._cachingSpatialArea$[key];
39007 }), operators_1.finalize(function () {
39008 if (Object.keys(spatialArea.cacheNodes).length === 0) {
39009 _this._changed$.next(_this);
39011 }), operators_1.publish(), operators_1.refCount());
39012 spatialNodes$.push(spatialNodeBatch$);
39015 for (var _i = 0, batches_1 = batches; _i < batches_1.length; _i++) {
39016 var batch = batches_1[_i];
39019 this._cachingSpatialArea$[key] = spatialNodes$;
39020 return spatialNodes$;
39023 * Cache spatial edges for a node.
39025 * @param {string} key - Key of node.
39026 * @throws {GraphMapillaryError} When the operation is not valid on the
39029 Graph.prototype.cacheSpatialEdges = function (key) {
39030 if (key in this._cachedSpatialEdges) {
39031 throw new Error_1.GraphMapillaryError("Spatial edges already cached (" + key + ").");
39033 var node = this.getNode(key);
39034 var sequence = this._sequences[node.sequenceKey].sequence;
39035 var fallbackKeys = [];
39036 var prevKey = sequence.findPrevKey(node.key);
39037 if (prevKey != null) {
39038 fallbackKeys.push(prevKey);
39040 var nextKey = sequence.findNextKey(node.key);
39041 if (nextKey != null) {
39042 fallbackKeys.push(nextKey);
39044 var allSpatialNodes = this._requiredSpatialArea[key].all;
39045 var potentialNodes = [];
39046 var filter = this._filter;
39047 for (var spatialNodeKey in allSpatialNodes) {
39048 if (!allSpatialNodes.hasOwnProperty(spatialNodeKey)) {
39051 var spatialNode = allSpatialNodes[spatialNodeKey];
39052 if (filter(spatialNode)) {
39053 potentialNodes.push(spatialNode);
39056 var potentialEdges = this._edgeCalculator.getPotentialEdges(node, potentialNodes, fallbackKeys);
39057 var edges = this._edgeCalculator.computeStepEdges(node, potentialEdges, prevKey, nextKey);
39058 edges = edges.concat(this._edgeCalculator.computeTurnEdges(node, potentialEdges));
39059 edges = edges.concat(this._edgeCalculator.computePanoEdges(node, potentialEdges));
39060 edges = edges.concat(this._edgeCalculator.computePerspectiveToPanoEdges(node, potentialEdges));
39061 edges = edges.concat(this._edgeCalculator.computeSimilarEdges(node, potentialEdges));
39062 node.cacheSpatialEdges(edges);
39063 this._cachedSpatialEdges[key] = node;
39064 delete this._requiredSpatialArea[key];
39065 delete this._cachedNodeTiles[key];
39068 * Retrieve and cache geohash tiles for a node.
39070 * @param {string} key - Key of node for which to retrieve tiles.
39071 * @returns {Array<Observable<Graph>>} Array of observables emitting
39072 * the graph for each tile required for the node has been cached.
39073 * @throws {GraphMapillaryError} When the operation is not valid on the
39076 Graph.prototype.cacheTiles$ = function (key) {
39078 if (key in this._cachedNodeTiles) {
39079 throw new Error_1.GraphMapillaryError("Tiles already cached (" + key + ").");
39081 if (key in this._cachedSpatialEdges) {
39082 throw new Error_1.GraphMapillaryError("Spatial edges already cached so tiles considered cached (" + key + ").");
39084 if (!(key in this._requiredNodeTiles)) {
39085 throw new Error_1.GraphMapillaryError("Tiles have not been determined (" + key + ").");
39087 var nodeTiles = this._requiredNodeTiles[key];
39088 if (nodeTiles.cache.length === 0 &&
39089 nodeTiles.caching.length === 0) {
39090 throw new Error_1.GraphMapillaryError("Tiles already cached (" + key + ").");
39092 if (!this.hasNode(key)) {
39093 throw new Error_1.GraphMapillaryError("Cannot cache tiles of node that does not exist in graph (" + key + ").");
39095 var hs = nodeTiles.cache.slice();
39096 nodeTiles.caching = this._requiredNodeTiles[key].caching.concat(hs);
39097 nodeTiles.cache = [];
39098 var cacheTiles$ = [];
39099 var _loop_2 = function (h) {
39100 var cacheTile$ = h in this_2._cachingTiles$ ?
39101 this_2._cachingTiles$[h] :
39102 this_2._cacheTile$(h);
39103 cacheTiles$.push(cacheTile$.pipe(operators_1.tap(function (graph) {
39104 var index = nodeTiles.caching.indexOf(h);
39106 nodeTiles.caching.splice(index, 1);
39108 if (nodeTiles.caching.length === 0 &&
39109 nodeTiles.cache.length === 0) {
39110 delete _this._requiredNodeTiles[key];
39111 _this._cachedNodeTiles[key] = true;
39113 }), operators_1.catchError(function (error) {
39114 var index = nodeTiles.caching.indexOf(h);
39116 nodeTiles.caching.splice(index, 1);
39118 if (nodeTiles.caching.length === 0 &&
39119 nodeTiles.cache.length === 0) {
39120 delete _this._requiredNodeTiles[key];
39121 _this._cachedNodeTiles[key] = true;
39124 }), operators_1.finalize(function () {
39125 _this._changed$.next(_this);
39126 }), operators_1.publish(), operators_1.refCount()));
39129 for (var _i = 0, _a = nodeTiles.caching; _i < _a.length; _i++) {
39133 return cacheTiles$;
39136 * Initialize the cache for a node.
39138 * @param {string} key - Key of node.
39139 * @throws {GraphMapillaryError} When the operation is not valid on the
39142 Graph.prototype.initializeCache = function (key) {
39143 if (key in this._cachedNodes) {
39144 throw new Error_1.GraphMapillaryError("Node already in cache (" + key + ").");
39146 var node = this.getNode(key);
39147 node.initializeCache(new Graph_1.NodeCache());
39148 var accessed = new Date().getTime();
39149 this._cachedNodes[key] = { accessed: accessed, node: node };
39150 this._updateCachedTileAccess(key, accessed);
39153 * Get a value indicating if the graph is fill caching a node.
39155 * @param {string} key - Key of node.
39156 * @returns {boolean} Value indicating if the node is being fill cached.
39158 Graph.prototype.isCachingFill = function (key) {
39159 return key in this._cachingFill$;
39162 * Get a value indicating if the graph is fully caching a node.
39164 * @param {string} key - Key of node.
39165 * @returns {boolean} Value indicating if the node is being fully cached.
39167 Graph.prototype.isCachingFull = function (key) {
39168 return key in this._cachingFull$;
39171 * Get a value indicating if the graph is caching a sequence of a node.
39173 * @param {string} key - Key of node.
39174 * @returns {boolean} Value indicating if the sequence of a node is
39177 Graph.prototype.isCachingNodeSequence = function (key) {
39178 var node = this.getNode(key);
39179 return node.sequenceKey in this._cachingSequences$;
39182 * Get a value indicating if the graph is caching a sequence.
39184 * @param {string} sequenceKey - Key of sequence.
39185 * @returns {boolean} Value indicating if the sequence is
39188 Graph.prototype.isCachingSequence = function (sequenceKey) {
39189 return sequenceKey in this._cachingSequences$;
39192 * Get a value indicating if the graph is caching sequence nodes.
39194 * @param {string} sequenceKey - Key of sequence.
39195 * @returns {boolean} Value indicating if the sequence nodes are
39198 Graph.prototype.isCachingSequenceNodes = function (sequenceKey) {
39199 return sequenceKey in this._cachingSequenceNodes$;
39202 * Get a value indicating if the graph is caching the tiles
39203 * required for calculating spatial edges of a node.
39205 * @param {string} key - Key of node.
39206 * @returns {boolean} Value indicating if the tiles of
39207 * a node are being cached.
39209 Graph.prototype.isCachingTiles = function (key) {
39210 return key in this._requiredNodeTiles &&
39211 this._requiredNodeTiles[key].cache.length === 0 &&
39212 this._requiredNodeTiles[key].caching.length > 0;
39215 * Get a value indicating if the cache has been initialized
39218 * @param {string} key - Key of node.
39219 * @returns {boolean} Value indicating if the cache has been
39220 * initialized for a node.
39222 Graph.prototype.hasInitializedCache = function (key) {
39223 return key in this._cachedNodes;
39226 * Get a value indicating if a node exist in the graph.
39228 * @param {string} key - Key of node.
39229 * @returns {boolean} Value indicating if a node exist in the graph.
39231 Graph.prototype.hasNode = function (key) {
39232 var accessed = new Date().getTime();
39233 this._updateCachedNodeAccess(key, accessed);
39234 this._updateCachedTileAccess(key, accessed);
39235 return key in this._nodes;
39238 * Get a value indicating if a node sequence exist in the graph.
39240 * @param {string} key - Key of node.
39241 * @returns {boolean} Value indicating if a node sequence exist
39244 Graph.prototype.hasNodeSequence = function (key) {
39245 var node = this.getNode(key);
39246 var sequenceKey = node.sequenceKey;
39247 var hasNodeSequence = sequenceKey in this._sequences;
39248 if (hasNodeSequence) {
39249 this._sequences[sequenceKey].accessed = new Date().getTime();
39251 return hasNodeSequence;
39254 * Get a value indicating if a sequence exist in the graph.
39256 * @param {string} sequenceKey - Key of sequence.
39257 * @returns {boolean} Value indicating if a sequence exist
39260 Graph.prototype.hasSequence = function (sequenceKey) {
39261 var hasSequence = sequenceKey in this._sequences;
39263 this._sequences[sequenceKey].accessed = new Date().getTime();
39265 return hasSequence;
39268 * Get a value indicating if sequence nodes has been cached in the graph.
39270 * @param {string} sequenceKey - Key of sequence.
39271 * @returns {boolean} Value indicating if a sequence nodes has been
39272 * cached in the graph.
39274 Graph.prototype.hasSequenceNodes = function (sequenceKey) {
39275 return sequenceKey in this._cachedSequenceNodes;
39278 * Get a value indicating if the graph has fully cached
39279 * all nodes in the spatial area of a node.
39281 * @param {string} key - Key of node.
39282 * @returns {boolean} Value indicating if the spatial area
39283 * of a node has been cached.
39285 Graph.prototype.hasSpatialArea = function (key) {
39286 if (!this.hasNode(key)) {
39287 throw new Error_1.GraphMapillaryError("Spatial area nodes cannot be determined if node not in graph (" + key + ").");
39289 if (key in this._cachedSpatialEdges) {
39292 if (key in this._requiredSpatialArea) {
39293 return Object.keys(this._requiredSpatialArea[key].cacheNodes).length === 0;
39295 var node = this.getNode(key);
39296 var bbox = this._graphCalculator.boundingBoxCorners(node.latLon, this._tileThreshold);
39297 var spatialItems = this._nodeIndex.search({
39303 var spatialNodes = {
39308 for (var _i = 0, spatialItems_1 = spatialItems; _i < spatialItems_1.length; _i++) {
39309 var spatialItem = spatialItems_1[_i];
39310 spatialNodes.all[spatialItem.node.key] = spatialItem.node;
39311 if (!spatialItem.node.full) {
39312 spatialNodes.cacheKeys.push(spatialItem.node.key);
39313 spatialNodes.cacheNodes[spatialItem.node.key] = spatialItem.node;
39316 this._requiredSpatialArea[key] = spatialNodes;
39317 return spatialNodes.cacheKeys.length === 0;
39320 * Get a value indicating if the graph has a tiles required
39323 * @param {string} key - Key of node.
39324 * @returns {boolean} Value indicating if the the tiles required
39325 * by a node has been cached.
39327 Graph.prototype.hasTiles = function (key) {
39329 if (key in this._cachedNodeTiles) {
39332 if (key in this._cachedSpatialEdges) {
39335 if (!this.hasNode(key)) {
39336 throw new Error_1.GraphMapillaryError("Node does not exist in graph (" + key + ").");
39338 var nodeTiles = { cache: [], caching: [] };
39339 if (!(key in this._requiredNodeTiles)) {
39340 var node = this.getNode(key);
39341 nodeTiles.cache = this._graphCalculator
39342 .encodeHs(node.latLon, this._tilePrecision, this._tileThreshold)
39343 .filter(function (h) {
39344 return !(h in _this._cachedTiles);
39346 if (nodeTiles.cache.length > 0) {
39347 this._requiredNodeTiles[key] = nodeTiles;
39351 nodeTiles = this._requiredNodeTiles[key];
39353 return nodeTiles.cache.length === 0 && nodeTiles.caching.length === 0;
39358 * @param {string} key - Key of node.
39359 * @returns {Node} Retrieved node.
39361 Graph.prototype.getNode = function (key) {
39362 var accessed = new Date().getTime();
39363 this._updateCachedNodeAccess(key, accessed);
39364 this._updateCachedTileAccess(key, accessed);
39365 return this._nodes[key];
39370 * @param {string} sequenceKey - Key of sequence.
39371 * @returns {Node} Retrieved sequence.
39373 Graph.prototype.getSequence = function (sequenceKey) {
39374 var sequenceAccess = this._sequences[sequenceKey];
39375 sequenceAccess.accessed = new Date().getTime();
39376 return sequenceAccess.sequence;
39379 * Reset all spatial edges of the graph nodes.
39381 Graph.prototype.resetSpatialEdges = function () {
39382 var cachedKeys = Object.keys(this._cachedSpatialEdges);
39383 for (var _i = 0, cachedKeys_1 = cachedKeys; _i < cachedKeys_1.length; _i++) {
39384 var cachedKey = cachedKeys_1[_i];
39385 var node = this._cachedSpatialEdges[cachedKey];
39386 node.resetSpatialEdges();
39387 delete this._cachedSpatialEdges[cachedKey];
39391 * Reset the complete graph but keep the nodes corresponding
39392 * to the supplied keys. All other nodes will be disposed.
39394 * @param {Array<string>} keepKeys - Keys for nodes to keep
39395 * in graph after reset.
39397 Graph.prototype.reset = function (keepKeys) {
39399 for (var _i = 0, keepKeys_1 = keepKeys; _i < keepKeys_1.length; _i++) {
39400 var key = keepKeys_1[_i];
39401 if (!this.hasNode(key)) {
39402 throw new Error("Node does not exist " + key);
39404 var node = this.getNode(key);
39405 node.resetSequenceEdges();
39406 node.resetSpatialEdges();
39409 for (var _a = 0, _b = Object.keys(this._cachedNodes); _a < _b.length; _a++) {
39410 var cachedKey = _b[_a];
39411 if (keepKeys.indexOf(cachedKey) !== -1) {
39414 this._cachedNodes[cachedKey].node.dispose();
39415 delete this._cachedNodes[cachedKey];
39417 this._cachedNodeTiles = {};
39418 this._cachedSpatialEdges = {};
39419 this._cachedTiles = {};
39420 this._cachingFill$ = {};
39421 this._cachingFull$ = {};
39422 this._cachingSequences$ = {};
39423 this._cachingSpatialArea$ = {};
39424 this._cachingTiles$ = {};
39426 this._nodeToTile = {};
39427 this._preStored = {};
39428 for (var _c = 0, nodes_2 = nodes; _c < nodes_2.length; _c++) {
39429 var node = nodes_2[_c];
39430 this._nodes[node.key] = node;
39431 var h = this._graphCalculator.encodeH(node.originalLatLon, this._tilePrecision);
39432 this._preStore(h, node);
39434 this._requiredNodeTiles = {};
39435 this._requiredSpatialArea = {};
39436 this._sequences = {};
39437 this._nodeIndexTiles = {};
39438 this._nodeIndex.clear();
39441 * Set the spatial node filter.
39443 * @param {FilterExpression} filter - Filter expression to be applied
39444 * when calculating spatial edges.
39446 Graph.prototype.setFilter = function (filter) {
39447 this._filter = this._filterCreator.createFilter(filter);
39450 * Uncache the graph according to the graph configuration.
39452 * @description Uncaches unused tiles, unused nodes and
39453 * sequences according to the numbers specified in the
39454 * graph configuration. Sequences does not have a direct
39455 * reference to either tiles or nodes and may be uncached
39456 * even if they are related to the nodes that should be kept.
39458 * @param {Array<string>} keepKeys - Keys of nodes to keep in
39459 * graph unrelated to last access. Tiles related to those keys
39460 * will also be kept in graph.
39461 * @param {string} keepSequenceKey - Optional key of sequence
39462 * for which the belonging nodes should not be disposed or
39463 * removed from the graph. These nodes may still be uncached if
39464 * not specified in keep keys param.
39466 Graph.prototype.uncache = function (keepKeys, keepSequenceKey) {
39467 var keysInUse = {};
39468 this._addNewKeys(keysInUse, this._cachingFull$);
39469 this._addNewKeys(keysInUse, this._cachingFill$);
39470 this._addNewKeys(keysInUse, this._cachingSpatialArea$);
39471 this._addNewKeys(keysInUse, this._requiredNodeTiles);
39472 this._addNewKeys(keysInUse, this._requiredSpatialArea);
39473 for (var _i = 0, keepKeys_2 = keepKeys; _i < keepKeys_2.length; _i++) {
39474 var key = keepKeys_2[_i];
39475 if (key in keysInUse) {
39478 keysInUse[key] = true;
39481 for (var key in keysInUse) {
39482 if (!keysInUse.hasOwnProperty(key)) {
39485 var node = this._nodes[key];
39486 var nodeHs = this._graphCalculator.encodeHs(node.latLon);
39487 for (var _a = 0, nodeHs_1 = nodeHs; _a < nodeHs_1.length; _a++) {
39488 var nodeH = nodeHs_1[_a];
39489 if (!(nodeH in keepHs)) {
39490 keepHs[nodeH] = true;
39494 var potentialHs = [];
39495 for (var h in this._cachedTiles) {
39496 if (!this._cachedTiles.hasOwnProperty(h) || h in keepHs) {
39499 potentialHs.push([h, this._cachedTiles[h]]);
39501 var uncacheHs = potentialHs
39502 .sort(function (h1, h2) {
39503 return h2[1].accessed - h1[1].accessed;
39505 .slice(this._configuration.maxUnusedTiles)
39506 .map(function (h) {
39509 for (var _b = 0, uncacheHs_1 = uncacheHs; _b < uncacheHs_1.length; _b++) {
39510 var uncacheH = uncacheHs_1[_b];
39511 this._uncacheTile(uncacheH, keepSequenceKey);
39513 var potentialPreStored = [];
39514 var nonCachedPreStored = [];
39515 for (var h in this._preStored) {
39516 if (!this._preStored.hasOwnProperty(h) || h in this._cachingTiles$) {
39519 var prestoredNodes = this._preStored[h];
39520 for (var key in prestoredNodes) {
39521 if (!prestoredNodes.hasOwnProperty(key) || key in keysInUse) {
39524 if (prestoredNodes[key].sequenceKey === keepSequenceKey) {
39527 if (key in this._cachedNodes) {
39528 potentialPreStored.push([this._cachedNodes[key], h]);
39531 nonCachedPreStored.push([key, h]);
39535 var uncachePreStored = potentialPreStored
39536 .sort(function (_a, _b) {
39537 var na1 = _a[0], h1 = _a[1];
39538 var na2 = _b[0], h2 = _b[1];
39539 return na2.accessed - na1.accessed;
39541 .slice(this._configuration.maxUnusedPreStoredNodes)
39542 .map(function (_a) {
39543 var na = _a[0], h = _a[1];
39544 return [na.node.key, h];
39546 this._uncachePreStored(nonCachedPreStored);
39547 this._uncachePreStored(uncachePreStored);
39548 var potentialNodes = [];
39549 for (var key in this._cachedNodes) {
39550 if (!this._cachedNodes.hasOwnProperty(key) || key in keysInUse) {
39553 potentialNodes.push(this._cachedNodes[key]);
39555 var uncacheNodes = potentialNodes
39556 .sort(function (n1, n2) {
39557 return n2.accessed - n1.accessed;
39559 .slice(this._configuration.maxUnusedNodes);
39560 for (var _c = 0, uncacheNodes_1 = uncacheNodes; _c < uncacheNodes_1.length; _c++) {
39561 var nodeAccess = uncacheNodes_1[_c];
39562 nodeAccess.node.uncache();
39563 var key = nodeAccess.node.key;
39564 delete this._cachedNodes[key];
39565 if (key in this._cachedNodeTiles) {
39566 delete this._cachedNodeTiles[key];
39568 if (key in this._cachedSpatialEdges) {
39569 delete this._cachedSpatialEdges[key];
39572 var potentialSequences = [];
39573 for (var sequenceKey in this._sequences) {
39574 if (!this._sequences.hasOwnProperty(sequenceKey) ||
39575 sequenceKey in this._cachingSequences$ ||
39576 sequenceKey === keepSequenceKey) {
39579 potentialSequences.push(this._sequences[sequenceKey]);
39581 var uncacheSequences = potentialSequences
39582 .sort(function (s1, s2) {
39583 return s2.accessed - s1.accessed;
39585 .slice(this._configuration.maxSequences);
39586 for (var _d = 0, uncacheSequences_1 = uncacheSequences; _d < uncacheSequences_1.length; _d++) {
39587 var sequenceAccess = uncacheSequences_1[_d];
39588 var sequenceKey = sequenceAccess.sequence.key;
39589 delete this._sequences[sequenceKey];
39590 if (sequenceKey in this._cachedSequenceNodes) {
39591 delete this._cachedSequenceNodes[sequenceKey];
39593 sequenceAccess.sequence.dispose();
39596 Graph.prototype._addNewKeys = function (keys, dict) {
39597 for (var key in dict) {
39598 if (!dict.hasOwnProperty(key) || !this.hasNode(key)) {
39601 if (!(key in keys)) {
39606 Graph.prototype._cacheSequence$ = function (sequenceKey) {
39608 if (sequenceKey in this._cachingSequences$) {
39609 return this._cachingSequences$[sequenceKey];
39611 this._cachingSequences$[sequenceKey] = this._apiV3.sequenceByKey$([sequenceKey]).pipe(operators_1.tap(function (sequenceByKey) {
39612 if (!(sequenceKey in _this._sequences)) {
39613 _this._sequences[sequenceKey] = {
39614 accessed: new Date().getTime(),
39615 sequence: new Graph_1.Sequence(sequenceByKey[sequenceKey]),
39618 delete _this._cachingSequences$[sequenceKey];
39619 }), operators_1.map(function (sequenceByKey) {
39621 }), operators_1.finalize(function () {
39622 if (sequenceKey in _this._cachingSequences$) {
39623 delete _this._cachingSequences$[sequenceKey];
39625 _this._changed$.next(_this);
39626 }), operators_1.publish(), operators_1.refCount());
39627 return this._cachingSequences$[sequenceKey];
39629 Graph.prototype._cacheTile$ = function (h) {
39631 this._cachingTiles$[h] = this._apiV3.imagesByH$([h]).pipe(operators_1.tap(function (imagesByH) {
39632 var coreNodes = imagesByH[h];
39633 if (h in _this._cachedTiles) {
39636 _this._nodeIndexTiles[h] = [];
39637 _this._cachedTiles[h] = { accessed: new Date().getTime(), nodes: [] };
39638 var hCache = _this._cachedTiles[h].nodes;
39639 var preStored = _this._removeFromPreStore(h);
39640 for (var index in coreNodes) {
39641 if (!coreNodes.hasOwnProperty(index)) {
39644 var coreNode = coreNodes[index];
39645 if (coreNode == null) {
39648 if (coreNode.sequence_key == null) {
39649 console.warn("Sequence missing, discarding node (" + coreNode.key + ")");
39652 if (preStored != null && coreNode.key in preStored) {
39653 var preStoredNode = preStored[coreNode.key];
39654 delete preStored[coreNode.key];
39655 hCache.push(preStoredNode);
39656 var preStoredNodeIndexItem = {
39657 lat: preStoredNode.latLon.lat,
39658 lon: preStoredNode.latLon.lon,
39659 node: preStoredNode,
39661 _this._nodeIndex.insert(preStoredNodeIndexItem);
39662 _this._nodeIndexTiles[h].push(preStoredNodeIndexItem);
39663 _this._nodeToTile[preStoredNode.key] = h;
39666 var node = new Graph_1.Node(coreNode);
39668 var nodeIndexItem = {
39669 lat: node.latLon.lat,
39670 lon: node.latLon.lon,
39673 _this._nodeIndex.insert(nodeIndexItem);
39674 _this._nodeIndexTiles[h].push(nodeIndexItem);
39675 _this._nodeToTile[node.key] = h;
39676 _this._setNode(node);
39678 delete _this._cachingTiles$[h];
39679 }), operators_1.map(function (imagesByH) {
39681 }), operators_1.catchError(function (error) {
39682 delete _this._cachingTiles$[h];
39684 }), operators_1.publish(), operators_1.refCount());
39685 return this._cachingTiles$[h];
39687 Graph.prototype._makeFull = function (node, fillNode) {
39688 if (fillNode.calt == null) {
39689 fillNode.calt = this._defaultAlt;
39691 if (fillNode.c_rotation == null) {
39692 fillNode.c_rotation = this._graphCalculator.rotationFromCompass(fillNode.ca, fillNode.orientation);
39694 node.makeFull(fillNode);
39696 Graph.prototype._preStore = function (h, node) {
39697 if (!(h in this._preStored)) {
39698 this._preStored[h] = {};
39700 this._preStored[h][node.key] = node;
39702 Graph.prototype._removeFromPreStore = function (h) {
39703 var preStored = null;
39704 if (h in this._preStored) {
39705 preStored = this._preStored[h];
39706 delete this._preStored[h];
39710 Graph.prototype._setNode = function (node) {
39711 var key = node.key;
39712 if (this.hasNode(key)) {
39713 throw new Error_1.GraphMapillaryError("Node already exist (" + key + ").");
39715 this._nodes[key] = node;
39717 Graph.prototype._uncacheTile = function (h, keepSequenceKey) {
39718 for (var _i = 0, _a = this._cachedTiles[h].nodes; _i < _a.length; _i++) {
39720 var key = node.key;
39721 delete this._nodeToTile[key];
39722 if (key in this._cachedNodes) {
39723 delete this._cachedNodes[key];
39725 if (key in this._cachedNodeTiles) {
39726 delete this._cachedNodeTiles[key];
39728 if (key in this._cachedSpatialEdges) {
39729 delete this._cachedSpatialEdges[key];
39731 if (node.sequenceKey === keepSequenceKey) {
39732 this._preStore(h, node);
39736 delete this._nodes[key];
39737 if (node.sequenceKey in this._cachedSequenceNodes) {
39738 delete this._cachedSequenceNodes[node.sequenceKey];
39743 for (var _b = 0, _c = this._nodeIndexTiles[h]; _b < _c.length; _b++) {
39744 var nodeIndexItem = _c[_b];
39745 this._nodeIndex.remove(nodeIndexItem);
39747 delete this._nodeIndexTiles[h];
39748 delete this._cachedTiles[h];
39750 Graph.prototype._uncachePreStored = function (preStored) {
39752 for (var _i = 0, preStored_1 = preStored; _i < preStored_1.length; _i++) {
39753 var _a = preStored_1[_i], key = _a[0], h = _a[1];
39754 if (key in this._nodes) {
39755 delete this._nodes[key];
39757 if (key in this._cachedNodes) {
39758 delete this._cachedNodes[key];
39760 var node = this._preStored[h][key];
39761 if (node.sequenceKey in this._cachedSequenceNodes) {
39762 delete this._cachedSequenceNodes[node.sequenceKey];
39764 delete this._preStored[h][key];
39768 for (var h in hs) {
39769 if (!hs.hasOwnProperty(h)) {
39772 if (Object.keys(this._preStored[h]).length === 0) {
39773 delete this._preStored[h];
39777 Graph.prototype._updateCachedTileAccess = function (key, accessed) {
39778 if (key in this._nodeToTile) {
39779 this._cachedTiles[this._nodeToTile[key]].accessed = accessed;
39782 Graph.prototype._updateCachedNodeAccess = function (key, accessed) {
39783 if (key in this._cachedNodes) {
39784 this._cachedNodes[key].accessed = accessed;
39789 exports.Graph = Graph;
39790 exports.default = Graph;
39792 },{"../Edge":276,"../Error":277,"../Graph":279,"rbush":26,"rxjs":27,"rxjs/operators":225}],391:[function(require,module,exports){
39794 Object.defineProperty(exports, "__esModule", { value: true });
39795 var geohash = require("latlon-geohash");
39796 var THREE = require("three");
39797 var Error_1 = require("../Error");
39798 var Geo_1 = require("../Geo");
39800 * @class GraphCalculator
39802 * @classdesc Represents a calculator for graph entities.
39804 var GraphCalculator = /** @class */ (function () {
39806 * Create a new graph calculator instance.
39808 * @param {GeoCoords} geoCoords - Geo coords instance.
39810 function GraphCalculator(geoCoords) {
39811 this._geoCoords = geoCoords != null ? geoCoords : new Geo_1.GeoCoords();
39814 * Encode the geohash tile for geodetic coordinates.
39816 * @param {ILatLon} latlon - Latitude and longitude to encode.
39817 * @param {number} precision - Precision of the encoding.
39819 * @returns {string} The geohash tile for the lat, lon and precision.
39821 GraphCalculator.prototype.encodeH = function (latLon, precision) {
39822 if (precision === void 0) { precision = 7; }
39823 return geohash.encode(latLon.lat, latLon.lon, precision);
39826 * Encode the geohash tiles within a threshold from a position
39827 * using Manhattan distance.
39829 * @param {ILatLon} latlon - Latitude and longitude to encode.
39830 * @param {number} precision - Precision of the encoding.
39831 * @param {number} threshold - Threshold of the encoding in meters.
39833 * @returns {string} The geohash tiles reachable within the threshold.
39835 GraphCalculator.prototype.encodeHs = function (latLon, precision, threshold) {
39836 if (precision === void 0) { precision = 7; }
39837 if (threshold === void 0) { threshold = 20; }
39838 var h = geohash.encode(latLon.lat, latLon.lon, precision);
39839 var bounds = geohash.bounds(h);
39840 var ne = bounds.ne;
39841 var sw = bounds.sw;
39842 var neighbours = geohash.neighbours(h);
39843 var bl = [0, 0, 0];
39844 var tr = this._geoCoords.geodeticToEnu(ne.lat, ne.lon, 0, sw.lat, sw.lon, 0);
39845 var position = this._geoCoords.geodeticToEnu(latLon.lat, latLon.lon, 0, sw.lat, sw.lon, 0);
39846 var left = position[0] - bl[0];
39847 var right = tr[0] - position[0];
39848 var bottom = position[1] - bl[1];
39849 var top = tr[1] - position[1];
39850 var l = left < threshold;
39851 var r = right < threshold;
39852 var b = bottom < threshold;
39853 var t = top < threshold;
39856 hs.push(neighbours.n);
39859 hs.push(neighbours.nw);
39862 hs.push(neighbours.w);
39865 hs.push(neighbours.sw);
39868 hs.push(neighbours.s);
39871 hs.push(neighbours.se);
39874 hs.push(neighbours.e);
39877 hs.push(neighbours.ne);
39882 * Encode the minimum set of geohash tiles containing a bounding box.
39884 * @description The current algorithm does expect the bounding box
39885 * to be sufficiently small to be contained in an area with the size
39886 * of maximally four tiles. Up to nine adjacent tiles may be returned.
39887 * The method currently uses the largest side as the threshold leading to
39888 * more tiles being returned than needed in edge cases.
39890 * @param {ILatLon} sw - South west corner of bounding box.
39891 * @param {ILatLon} ne - North east corner of bounding box.
39892 * @param {number} precision - Precision of the encoding.
39894 * @returns {string} The geohash tiles containing the bounding box.
39896 GraphCalculator.prototype.encodeHsFromBoundingBox = function (sw, ne, precision) {
39897 if (precision === void 0) { precision = 7; }
39898 if (ne.lat <= sw.lat || ne.lon <= sw.lon) {
39899 throw new Error_1.GraphMapillaryError("North east needs to be top right of south west");
39901 var centerLat = (sw.lat + ne.lat) / 2;
39902 var centerLon = (sw.lon + ne.lon) / 2;
39903 var enu = this._geoCoords.geodeticToEnu(ne.lat, ne.lon, 0, centerLat, centerLon, 0);
39904 var threshold = Math.max(enu[0], enu[1]);
39905 return this.encodeHs({ lat: centerLat, lon: centerLon }, precision, threshold);
39908 * Get the bounding box corners for a circle with radius of a threshold
39909 * with center in a geodetic position.
39911 * @param {ILatLon} latlon - Latitude and longitude to encode.
39912 * @param {number} threshold - Threshold distance from the position in meters.
39914 * @returns {Array<ILatLon>} The south west and north east corners of the
39917 GraphCalculator.prototype.boundingBoxCorners = function (latLon, threshold) {
39918 var bl = this._geoCoords.enuToGeodetic(-threshold, -threshold, 0, latLon.lat, latLon.lon, 0);
39919 var tr = this._geoCoords.enuToGeodetic(threshold, threshold, 0, latLon.lat, latLon.lon, 0);
39921 { lat: bl[0], lon: bl[1] },
39922 { lat: tr[0], lon: tr[1] },
39926 * Convert a compass angle to an angle axis rotation vector.
39928 * @param {number} compassAngle - The compass angle in degrees.
39929 * @param {number} orientation - The orientation of the original image.
39931 * @returns {Array<number>} Angle axis rotation vector.
39933 GraphCalculator.prototype.rotationFromCompass = function (compassAngle, orientation) {
39937 switch (orientation) {
39956 var rz = new THREE.Matrix4().makeRotationZ(z);
39957 var euler = new THREE.Euler(x, y, compassAngle * Math.PI / 180, "XYZ");
39958 var re = new THREE.Matrix4().makeRotationFromEuler(euler);
39959 var rotation = new THREE.Vector4().setAxisAngleFromRotationMatrix(re.multiply(rz));
39960 return rotation.multiplyScalar(rotation.w).toArray().slice(0, 3);
39962 return GraphCalculator;
39964 exports.GraphCalculator = GraphCalculator;
39965 exports.default = GraphCalculator;
39967 },{"../Error":277,"../Geo":278,"latlon-geohash":21,"three":226}],392:[function(require,module,exports){
39969 Object.defineProperty(exports, "__esModule", { value: true });
39971 * Enumeration for graph modes.
39974 * @description Modes for the retrieval and caching performed
39975 * by the graph service on the graph.
39978 (function (GraphMode) {
39980 * Caching is performed on sequences only and sequence edges are
39981 * calculated. Spatial tiles
39982 * are not retrieved and spatial edges are not calculated when
39983 * caching nodes. Complete sequences are being cached for requested
39984 * nodes within the graph.
39986 GraphMode[GraphMode["Sequence"] = 0] = "Sequence";
39988 * Caching is performed with emphasis on spatial data. Sequence edges
39989 * as well as spatial edges are cached. Sequence data
39990 * is still requested but complete sequences are not being cached
39991 * for requested nodes.
39993 * This is the initial mode of the graph service.
39995 GraphMode[GraphMode["Spatial"] = 1] = "Spatial";
39996 })(GraphMode = exports.GraphMode || (exports.GraphMode = {}));
39997 exports.default = GraphMode;
39999 },{}],393:[function(require,module,exports){
40001 Object.defineProperty(exports, "__esModule", { value: true });
40002 var rxjs_1 = require("rxjs");
40003 var operators_1 = require("rxjs/operators");
40004 var Graph_1 = require("../Graph");
40006 * @class GraphService
40008 * @classdesc Represents a service for graph operations.
40010 var GraphService = /** @class */ (function () {
40012 * Create a new graph service instance.
40014 * @param {Graph} graph - Graph instance to be operated on.
40016 function GraphService(graph, imageLoadingService) {
40017 this._graph$ = rxjs_1.concat(rxjs_1.of(graph), graph.changed$).pipe(operators_1.publishReplay(1), operators_1.refCount());
40018 this._graph$.subscribe(function () { });
40019 this._graphMode = Graph_1.GraphMode.Spatial;
40020 this._graphModeSubject$ = new rxjs_1.Subject();
40021 this._graphMode$ = this._graphModeSubject$.pipe(operators_1.startWith(this._graphMode), operators_1.publishReplay(1), operators_1.refCount());
40022 this._graphMode$.subscribe(function () { });
40023 this._imageLoadingService = imageLoadingService;
40024 this._firstGraphSubjects$ = [];
40025 this._initializeCacheSubscriptions = [];
40026 this._sequenceSubscriptions = [];
40027 this._spatialSubscriptions = [];
40029 Object.defineProperty(GraphService.prototype, "graphMode$", {
40031 * Get graph mode observable.
40033 * @description Emits the current graph mode.
40035 * @returns {Observable<GraphMode>} Observable
40036 * emitting the current graph mode when it changes.
40039 return this._graphMode$;
40045 * Cache full nodes in a bounding box.
40047 * @description When called, the full properties of
40048 * the node are retrieved. The node cache is not initialized
40049 * for any new nodes retrieved and the node assets are not
40050 * retrieved, {@link cacheNode$} needs to be called for caching
40053 * @param {ILatLon} sw - South west corner of bounding box.
40054 * @param {ILatLon} ne - North east corner of bounding box.
40055 * @return {Observable<Array<Node>>} Observable emitting a single item,
40056 * the nodes of the bounding box, when they have all been retrieved.
40057 * @throws {Error} Propagates any IO node caching errors to the caller.
40059 GraphService.prototype.cacheBoundingBox$ = function (sw, ne) {
40060 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
40061 return graph.cacheBoundingBox$(sw, ne);
40065 * Cache a node in the graph and retrieve it.
40067 * @description When called, the full properties of
40068 * the node are retrieved and the node cache is initialized.
40069 * After that the node assets are cached and the node
40070 * is emitted to the observable when.
40071 * In parallel to caching the node assets, the sequence and
40072 * spatial edges of the node are cached. For this, the sequence
40073 * of the node and the required tiles and spatial nodes are
40074 * retrieved. The sequence and spatial edges may be set before
40075 * or after the node is returned.
40077 * @param {string} key - Key of the node to cache.
40078 * @return {Observable<Node>} Observable emitting a single item,
40079 * the node, when it has been retrieved and its assets are cached.
40080 * @throws {Error} Propagates any IO node caching errors to the caller.
40082 GraphService.prototype.cacheNode$ = function (key) {
40084 var firstGraphSubject$ = new rxjs_1.Subject();
40085 this._firstGraphSubjects$.push(firstGraphSubject$);
40086 var firstGraph$ = firstGraphSubject$.pipe(operators_1.publishReplay(1), operators_1.refCount());
40087 var node$ = firstGraph$.pipe(operators_1.map(function (graph) {
40088 return graph.getNode(key);
40089 }), operators_1.mergeMap(function (node) {
40090 return node.assetsCached ?
40092 node.cacheAssets$();
40093 }), operators_1.publishReplay(1), operators_1.refCount());
40094 node$.subscribe(function (node) {
40095 _this._imageLoadingService.loadnode$.next(node);
40096 }, function (error) {
40097 console.error("Failed to cache node (" + key + ")", error);
40099 var initializeCacheSubscription = this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
40100 if (graph.isCachingFull(key) || !graph.hasNode(key)) {
40101 return graph.cacheFull$(key);
40103 if (graph.isCachingFill(key) || !graph.getNode(key).full) {
40104 return graph.cacheFill$(key);
40106 return rxjs_1.of(graph);
40107 }), operators_1.tap(function (graph) {
40108 if (!graph.hasInitializedCache(key)) {
40109 graph.initializeCache(key);
40111 }), operators_1.finalize(function () {
40112 if (initializeCacheSubscription == null) {
40115 _this._removeFromArray(initializeCacheSubscription, _this._initializeCacheSubscriptions);
40116 _this._removeFromArray(firstGraphSubject$, _this._firstGraphSubjects$);
40118 .subscribe(function (graph) {
40119 firstGraphSubject$.next(graph);
40120 firstGraphSubject$.complete();
40121 }, function (error) {
40122 firstGraphSubject$.error(error);
40124 if (!initializeCacheSubscription.closed) {
40125 this._initializeCacheSubscriptions.push(initializeCacheSubscription);
40127 var graphSequence$ = firstGraph$.pipe(operators_1.mergeMap(function (graph) {
40128 if (graph.isCachingNodeSequence(key) || !graph.hasNodeSequence(key)) {
40129 return graph.cacheNodeSequence$(key);
40131 return rxjs_1.of(graph);
40132 }), operators_1.publishReplay(1), operators_1.refCount());
40133 var sequenceSubscription = graphSequence$.pipe(operators_1.tap(function (graph) {
40134 if (!graph.getNode(key).sequenceEdges.cached) {
40135 graph.cacheSequenceEdges(key);
40137 }), operators_1.finalize(function () {
40138 if (sequenceSubscription == null) {
40141 _this._removeFromArray(sequenceSubscription, _this._sequenceSubscriptions);
40143 .subscribe(function (graph) { return; }, function (error) {
40144 console.error("Failed to cache sequence edges (" + key + ").", error);
40146 if (!sequenceSubscription.closed) {
40147 this._sequenceSubscriptions.push(sequenceSubscription);
40149 if (this._graphMode === Graph_1.GraphMode.Spatial) {
40150 var spatialSubscription_1 = firstGraph$.pipe(operators_1.expand(function (graph) {
40151 if (graph.hasTiles(key)) {
40152 return rxjs_1.empty();
40154 return rxjs_1.from(graph.cacheTiles$(key)).pipe(operators_1.mergeMap(function (graph$) {
40155 return graph$.pipe(operators_1.mergeMap(function (g) {
40156 if (g.isCachingTiles(key)) {
40157 return rxjs_1.empty();
40159 return rxjs_1.of(g);
40160 }), operators_1.catchError(function (error, caught$) {
40161 console.error("Failed to cache tile data (" + key + ").", error);
40162 return rxjs_1.empty();
40165 }), operators_1.last(), operators_1.mergeMap(function (graph) {
40166 if (graph.hasSpatialArea(key)) {
40167 return rxjs_1.of(graph);
40169 return rxjs_1.from(graph.cacheSpatialArea$(key)).pipe(operators_1.mergeMap(function (graph$) {
40170 return graph$.pipe(operators_1.catchError(function (error, caught$) {
40171 console.error("Failed to cache spatial nodes (" + key + ").", error);
40172 return rxjs_1.empty();
40175 }), operators_1.last(), operators_1.mergeMap(function (graph) {
40176 return graph.hasNodeSequence(key) ?
40178 graph.cacheNodeSequence$(key);
40179 }), operators_1.tap(function (graph) {
40180 if (!graph.getNode(key).spatialEdges.cached) {
40181 graph.cacheSpatialEdges(key);
40183 }), operators_1.finalize(function () {
40184 if (spatialSubscription_1 == null) {
40187 _this._removeFromArray(spatialSubscription_1, _this._spatialSubscriptions);
40189 .subscribe(function (graph) { return; }, function (error) {
40190 console.error("Failed to cache spatial edges (" + key + ").", error);
40192 if (!spatialSubscription_1.closed) {
40193 this._spatialSubscriptions.push(spatialSubscription_1);
40196 return node$.pipe(operators_1.first(function (node) {
40197 return node.assetsCached;
40201 * Cache a sequence in the graph and retrieve it.
40203 * @param {string} sequenceKey - Sequence key.
40204 * @returns {Observable<Sequence>} Observable emitting a single item,
40205 * the sequence, when it has been retrieved and its assets are cached.
40206 * @throws {Error} Propagates any IO node caching errors to the caller.
40208 GraphService.prototype.cacheSequence$ = function (sequenceKey) {
40209 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
40210 if (graph.isCachingSequence(sequenceKey) || !graph.hasSequence(sequenceKey)) {
40211 return graph.cacheSequence$(sequenceKey);
40213 return rxjs_1.of(graph);
40214 }), operators_1.map(function (graph) {
40215 return graph.getSequence(sequenceKey);
40219 * Cache a sequence and its nodes in the graph and retrieve the sequence.
40221 * @description Caches a sequence and its assets are cached and
40222 * retrieves all nodes belonging to the sequence. The node assets
40223 * or edges will not be cached.
40225 * @param {string} sequenceKey - Sequence key.
40226 * @param {string} referenceNodeKey - Key of node to use as reference
40227 * for optimized caching.
40228 * @returns {Observable<Sequence>} Observable emitting a single item,
40229 * the sequence, when it has been retrieved, its assets are cached and
40230 * all nodes belonging to the sequence has been retrieved.
40231 * @throws {Error} Propagates any IO node caching errors to the caller.
40233 GraphService.prototype.cacheSequenceNodes$ = function (sequenceKey, referenceNodeKey) {
40234 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
40235 if (graph.isCachingSequence(sequenceKey) || !graph.hasSequence(sequenceKey)) {
40236 return graph.cacheSequence$(sequenceKey);
40238 return rxjs_1.of(graph);
40239 }), operators_1.mergeMap(function (graph) {
40240 if (graph.isCachingSequenceNodes(sequenceKey) || !graph.hasSequenceNodes(sequenceKey)) {
40241 return graph.cacheSequenceNodes$(sequenceKey, referenceNodeKey);
40243 return rxjs_1.of(graph);
40244 }), operators_1.map(function (graph) {
40245 return graph.getSequence(sequenceKey);
40249 * Set a spatial edge filter on the graph.
40251 * @description Resets the spatial edges of all cached nodes.
40253 * @param {FilterExpression} filter - Filter expression to be applied.
40254 * @return {Observable<Graph>} Observable emitting a single item,
40255 * the graph, when the spatial edges have been reset.
40257 GraphService.prototype.setFilter$ = function (filter) {
40258 this._resetSubscriptions(this._spatialSubscriptions);
40259 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
40260 graph.resetSpatialEdges();
40261 graph.setFilter(filter);
40262 }), operators_1.map(function (graph) {
40267 * Set the graph mode.
40269 * @description If graph mode is set to spatial, caching
40270 * is performed with emphasis on spatial edges. If graph
40271 * mode is set to sequence no tile data is requested and
40272 * no spatial edges are computed.
40274 * When setting graph mode to sequence all spatial
40275 * subscriptions are aborted.
40277 * @param {GraphMode} mode - Graph mode to set.
40279 GraphService.prototype.setGraphMode = function (mode) {
40280 if (this._graphMode === mode) {
40283 if (mode === Graph_1.GraphMode.Sequence) {
40284 this._resetSubscriptions(this._spatialSubscriptions);
40286 this._graphMode = mode;
40287 this._graphModeSubject$.next(this._graphMode);
40292 * @description Resets the graph but keeps the nodes of the
40295 * @param {Array<string>} keepKeys - Keys of nodes to keep in graph.
40296 * @return {Observable<Node>} Observable emitting a single item,
40297 * the graph, when it has been reset.
40299 GraphService.prototype.reset$ = function (keepKeys) {
40300 this._abortSubjects(this._firstGraphSubjects$);
40301 this._resetSubscriptions(this._initializeCacheSubscriptions);
40302 this._resetSubscriptions(this._sequenceSubscriptions);
40303 this._resetSubscriptions(this._spatialSubscriptions);
40304 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
40305 graph.reset(keepKeys);
40306 }), operators_1.map(function (graph) {
40311 * Uncache the graph.
40313 * @description Uncaches the graph by removing tiles, nodes and
40314 * sequences. Keeps the nodes of the supplied keys and the tiles
40315 * related to those nodes.
40317 * @param {Array<string>} keepKeys - Keys of nodes to keep in graph.
40318 * @param {string} keepSequenceKey - Optional key of sequence
40319 * for which the belonging nodes should not be disposed or
40320 * removed from the graph. These nodes may still be uncached if
40321 * not specified in keep keys param.
40322 * @return {Observable<Graph>} Observable emitting a single item,
40323 * the graph, when the graph has been uncached.
40325 GraphService.prototype.uncache$ = function (keepKeys, keepSequenceKey) {
40326 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
40327 graph.uncache(keepKeys, keepSequenceKey);
40328 }), operators_1.map(function (graph) {
40332 GraphService.prototype._abortSubjects = function (subjects) {
40333 for (var _i = 0, _a = subjects.slice(); _i < _a.length; _i++) {
40334 var subject = _a[_i];
40335 this._removeFromArray(subject, subjects);
40336 subject.error(new Error("Cache node request was aborted."));
40339 GraphService.prototype._removeFromArray = function (object, objects) {
40340 var index = objects.indexOf(object);
40341 if (index !== -1) {
40342 objects.splice(index, 1);
40345 GraphService.prototype._resetSubscriptions = function (subscriptions) {
40346 for (var _i = 0, _a = subscriptions.slice(); _i < _a.length; _i++) {
40347 var subscription = _a[_i];
40348 this._removeFromArray(subscription, subscriptions);
40349 if (!subscription.closed) {
40350 subscription.unsubscribe();
40354 return GraphService;
40356 exports.GraphService = GraphService;
40357 exports.default = GraphService;
40359 },{"../Graph":279,"rxjs":27,"rxjs/operators":225}],394:[function(require,module,exports){
40361 Object.defineProperty(exports, "__esModule", { value: true });
40362 var operators_1 = require("rxjs/operators");
40363 var rxjs_1 = require("rxjs");
40364 var ImageLoadingService = /** @class */ (function () {
40365 function ImageLoadingService() {
40366 this._loadnode$ = new rxjs_1.Subject();
40367 this._loadstatus$ = this._loadnode$.pipe(operators_1.scan(function (_a, node) {
40369 var changed = false;
40370 if (node.loadStatus.total === 0 || node.loadStatus.loaded === node.loadStatus.total) {
40371 if (node.key in nodes) {
40372 delete nodes[node.key];
40377 nodes[node.key] = node.loadStatus;
40380 return [nodes, changed];
40381 }, [{}, false]), operators_1.filter(function (_a) {
40382 var nodes = _a[0], changed = _a[1];
40384 }), operators_1.map(function (_a) {
40387 }), operators_1.publishReplay(1), operators_1.refCount());
40388 this._loadstatus$.subscribe(function () { });
40390 Object.defineProperty(ImageLoadingService.prototype, "loadnode$", {
40392 return this._loadnode$;
40397 Object.defineProperty(ImageLoadingService.prototype, "loadstatus$", {
40399 return this._loadstatus$;
40404 return ImageLoadingService;
40406 exports.ImageLoadingService = ImageLoadingService;
40408 },{"rxjs":27,"rxjs/operators":225}],395:[function(require,module,exports){
40410 Object.defineProperty(exports, "__esModule", { value: true });
40411 var Pbf = require("pbf");
40412 var MeshReader = /** @class */ (function () {
40413 function MeshReader() {
40415 MeshReader.read = function (buffer) {
40416 var pbf = new Pbf(buffer);
40417 return pbf.readFields(MeshReader._readMeshField, { faces: [], vertices: [] });
40419 MeshReader._readMeshField = function (tag, mesh, pbf) {
40421 mesh.vertices.push(pbf.readFloat());
40423 else if (tag === 2) {
40424 mesh.faces.push(pbf.readVarint());
40429 exports.MeshReader = MeshReader;
40431 },{"pbf":24}],396:[function(require,module,exports){
40433 Object.defineProperty(exports, "__esModule", { value: true });
40434 var operators_1 = require("rxjs/operators");
40438 * @classdesc Represents a node in the navigation graph.
40440 * Explanation of position and bearing properties:
40442 * When images are uploaded they will have GPS information in the EXIF, this is what
40443 * is called `originalLatLon` {@link Node.originalLatLon}.
40445 * When Structure from Motions has been run for a node a `computedLatLon` that
40446 * differs from the `originalLatLon` will be created. It is different because
40447 * GPS positions are not very exact and SfM aligns the camera positions according
40448 * to the 3D reconstruction {@link Node.computedLatLon}.
40450 * At last there exist a `latLon` property which evaluates to
40451 * the `computedLatLon` from SfM if it exists but falls back
40452 * to the `originalLatLon` from the EXIF GPS otherwise {@link Node.latLon}.
40454 * Everything that is done in in the Viewer is based on the SfM positions,
40455 * i.e. `computedLatLon`. That is why the smooth transitions go in the right
40456 * direction (nd not in strange directions because of bad GPS).
40458 * E.g. when placing a marker in the Viewer it is relative to the SfM
40459 * position i.e. the `computedLatLon`.
40461 * The same concept as above also applies to the compass angle (or bearing) properties
40462 * `originalCa`, `computedCa` and `ca`.
40464 var Node = /** @class */ (function () {
40466 * Create a new node instance.
40468 * @description Nodes are always created internally by the library.
40469 * Nodes can not be added to the library through any API method.
40471 * @param {ICoreNode} coreNode - Raw core node data.
40474 function Node(core) {
40475 this._cache = null;
40479 Object.defineProperty(Node.prototype, "assetsCached", {
40481 * Get assets cached.
40483 * @description The assets that need to be cached for this property
40484 * to report true are the following: fill properties, image and mesh.
40485 * The library ensures that the current node will always have the
40488 * @returns {boolean} Value indicating whether all assets have been
40494 return this._core != null &&
40495 this._fill != null &&
40496 this._cache != null &&
40497 this._cache.image != null &&
40498 this._cache.mesh != null;
40503 Object.defineProperty(Node.prototype, "alt", {
40507 * @description If SfM has not been run the computed altitude is
40508 * set to a default value of two meters.
40510 * @returns {number} Altitude, in meters.
40513 return this._fill.calt;
40518 Object.defineProperty(Node.prototype, "ca", {
40522 * @description If the SfM computed compass angle exists it will
40523 * be returned, otherwise the original EXIF compass angle.
40525 * @returns {number} Compass angle, measured in degrees
40526 * clockwise with respect to north.
40529 return this._fill.cca != null ? this._fill.cca : this._fill.ca;
40534 Object.defineProperty(Node.prototype, "capturedAt", {
40538 * @returns {number} Timestamp when the image was captured.
40541 return this._fill.captured_at;
40546 Object.defineProperty(Node.prototype, "cameraUuid", {
40550 * @description Will be undefined if the camera uuid was not
40551 * recorded in the image exif information.
40553 * @returns {string} Universally unique id for camera used
40554 * when capturing image.
40557 return this._fill.captured_with_camera_uuid;
40562 Object.defineProperty(Node.prototype, "ck1", {
40566 * @description Will not be set if SfM has not been run.
40568 * @returns {number} SfM computed radial distortion parameter
40572 return this._fill.ck1;
40577 Object.defineProperty(Node.prototype, "ck2", {
40581 * @description Will not be set if SfM has not been run.
40583 * @returns {number} SfM computed radial distortion parameter
40587 return this._fill.ck2;
40592 Object.defineProperty(Node.prototype, "computedCA", {
40596 * @description Will not be set if SfM has not been run.
40598 * @returns {number} SfM computed compass angle, measured
40599 * in degrees clockwise with respect to north.
40602 return this._fill.cca;
40607 Object.defineProperty(Node.prototype, "computedLatLon", {
40609 * Get computedLatLon.
40611 * @description Will not be set if SfM has not been run.
40613 * @returns {ILatLon} SfM computed latitude longitude in WGS84 datum,
40614 * measured in degrees.
40617 return this._core.cl;
40622 Object.defineProperty(Node.prototype, "focal", {
40626 * @description Will not be set if SfM has not been run.
40628 * @returns {number} SfM computed focal length.
40631 return this._fill.cfocal;
40636 Object.defineProperty(Node.prototype, "full", {
40640 * @description The library ensures that the current node will
40643 * @returns {boolean} Value indicating whether the node has all
40644 * properties filled.
40649 return this._fill != null;
40654 Object.defineProperty(Node.prototype, "fullPano", {
40658 * @returns {boolean} Value indicating whether the node is a complete
40662 return this._fill.gpano != null &&
40663 this._fill.gpano.CroppedAreaLeftPixels === 0 &&
40664 this._fill.gpano.CroppedAreaTopPixels === 0 &&
40665 this._fill.gpano.CroppedAreaImageWidthPixels === this._fill.gpano.FullPanoWidthPixels &&
40666 this._fill.gpano.CroppedAreaImageHeightPixels === this._fill.gpano.FullPanoHeightPixels;
40671 Object.defineProperty(Node.prototype, "gpano", {
40675 * @description Will not be set for non panoramic images.
40677 * @returns {IGPano} Panorama information for panorama images.
40680 return this._fill.gpano;
40685 Object.defineProperty(Node.prototype, "height", {
40689 * @returns {number} Height of original image, not adjusted
40693 return this._fill.height;
40698 Object.defineProperty(Node.prototype, "image", {
40702 * @description The image will always be set on the current node.
40704 * @returns {HTMLImageElement} Cached image element of the node.
40707 return this._cache.image;
40712 Object.defineProperty(Node.prototype, "image$", {
40716 * @returns {Observable<HTMLImageElement>} Observable emitting
40717 * the cached image when it is updated.
40722 return this._cache.image$;
40727 Object.defineProperty(Node.prototype, "key", {
40731 * @returns {string} Unique key of the node.
40734 return this._core.key;
40739 Object.defineProperty(Node.prototype, "latLon", {
40743 * @description If the SfM computed latitude longitude exist
40744 * it will be returned, otherwise the original EXIF latitude
40747 * @returns {ILatLon} Latitude longitude in WGS84 datum,
40748 * measured in degrees.
40751 return this._core.cl != null ? this._core.cl : this._core.l;
40756 Object.defineProperty(Node.prototype, "loadStatus", {
40760 * @returns {ILoadStatus} Value indicating the load status
40761 * of the mesh and image.
40764 return this._cache.loadStatus;
40769 Object.defineProperty(Node.prototype, "merged", {
40773 * @returns {boolean} Value indicating whether SfM has been
40774 * run on the node and the node has been merged into a
40775 * connected component.
40778 return this._fill != null &&
40779 this._fill.merge_version != null &&
40780 this._fill.merge_version > 0;
40785 Object.defineProperty(Node.prototype, "mergeCC", {
40789 * @description Will not be set if SfM has not yet been run on
40792 * @returns {number} SfM connected component key to which
40796 return this._fill.merge_cc;
40801 Object.defineProperty(Node.prototype, "mergeVersion", {
40803 * Get mergeVersion.
40805 * @returns {number} Version for which SfM was run and image was merged.
40808 return this._fill.merge_version;
40813 Object.defineProperty(Node.prototype, "mesh", {
40817 * @description The mesh will always be set on the current node.
40819 * @returns {IMesh} SfM triangulated mesh of reconstructed
40820 * atomic 3D points.
40823 return this._cache.mesh;
40828 Object.defineProperty(Node.prototype, "organizationKey", {
40830 * Get organizationKey.
40832 * @returns {string} Unique key of the organization to which
40833 * the node belongs. If the node does not belong to an
40834 * organization the organization key will be undefined.
40837 return this._fill.organization_key;
40842 Object.defineProperty(Node.prototype, "orientation", {
40846 * @returns {number} EXIF orientation of original image.
40849 return this._fill.orientation;
40854 Object.defineProperty(Node.prototype, "originalCA", {
40858 * @returns {number} Original EXIF compass angle, measured in
40862 return this._fill.ca;
40867 Object.defineProperty(Node.prototype, "originalLatLon", {
40869 * Get originalLatLon.
40871 * @returns {ILatLon} Original EXIF latitude longitude in
40872 * WGS84 datum, measured in degrees.
40875 return this._core.l;
40880 Object.defineProperty(Node.prototype, "pano", {
40884 * @returns {boolean} Value indicating whether the node is a panorama.
40885 * It could be a cropped or full panorama.
40888 return this._fill.gpano != null &&
40889 this._fill.gpano.FullPanoWidthPixels != null;
40894 Object.defineProperty(Node.prototype, "private", {
40898 * @returns {boolean} Value specifying if image is accessible to
40899 * organization members only or to everyone.
40902 return this._fill.private;
40907 Object.defineProperty(Node.prototype, "projectKey", {
40911 * @returns {string} Unique key of the project to which
40912 * the node belongs. If the node does not belong to a
40913 * project the project key will be undefined.
40915 * @deprecated This property will be deprecated in favor
40916 * of the organization key and private properties.
40919 return this._fill.project != null ?
40920 this._fill.project.key :
40926 Object.defineProperty(Node.prototype, "rotation", {
40930 * @description Will not be set if SfM has not been run.
40932 * @returns {Array<number>} Rotation vector in angle axis representation.
40935 return this._fill.c_rotation;
40940 Object.defineProperty(Node.prototype, "scale", {
40944 * @description Will not be set if SfM has not been run.
40946 * @returns {number} Scale of atomic reconstruction.
40949 return this._fill.atomic_scale;
40954 Object.defineProperty(Node.prototype, "sequenceKey", {
40958 * @returns {string} Unique key of the sequence to which
40959 * the node belongs.
40962 return this._core.sequence_key;
40967 Object.defineProperty(Node.prototype, "sequenceEdges", {
40969 * Get sequenceEdges.
40971 * @returns {IEdgeStatus} Value describing the status of the
40975 return this._cache.sequenceEdges;
40980 Object.defineProperty(Node.prototype, "sequenceEdges$", {
40982 * Get sequenceEdges$.
40984 * @description Internal observable, should not be used as an API.
40986 * @returns {Observable<IEdgeStatus>} Observable emitting
40987 * values describing the status of the sequence edges.
40992 return this._cache.sequenceEdges$;
40997 Object.defineProperty(Node.prototype, "spatialEdges", {
40999 * Get spatialEdges.
41001 * @returns {IEdgeStatus} Value describing the status of the
41005 return this._cache.spatialEdges;
41010 Object.defineProperty(Node.prototype, "spatialEdges$", {
41012 * Get spatialEdges$.
41014 * @description Internal observable, should not be used as an API.
41016 * @returns {Observable<IEdgeStatus>} Observable emitting
41017 * values describing the status of the spatial edges.
41022 return this._cache.spatialEdges$;
41027 Object.defineProperty(Node.prototype, "userKey", {
41031 * @returns {string} Unique key of the user who uploaded
41035 return this._fill.user.key;
41040 Object.defineProperty(Node.prototype, "username", {
41044 * @returns {string} Username of the user who uploaded
41048 return this._fill.user.username;
41053 Object.defineProperty(Node.prototype, "width", {
41057 * @returns {number} Width of original image, not
41058 * adjusted for orientation.
41061 return this._fill.width;
41067 * Cache the image and mesh assets.
41069 * @description The assets are always cached internally by the
41070 * library prior to setting a node as the current node.
41072 * @returns {Observable<Node>} Observable emitting this node whenever the
41073 * load status has changed and when the mesh or image has been fully loaded.
41077 Node.prototype.cacheAssets$ = function () {
41079 return this._cache.cacheAssets$(this.key, this.pano, this.merged).pipe(operators_1.map(function () {
41084 * Cache the image asset.
41086 * @description Use for caching a differently sized image than
41087 * the one currently held by the node.
41089 * @returns {Observable<Node>} Observable emitting this node whenever the
41090 * load status has changed and when the mesh or image has been fully loaded.
41094 Node.prototype.cacheImage$ = function (imageSize) {
41096 return this._cache.cacheImage$(this.key, imageSize).pipe(operators_1.map(function () {
41101 * Cache the sequence edges.
41103 * @description The sequence edges are cached asynchronously
41104 * internally by the library.
41106 * @param {Array<IEdge>} edges - Sequence edges to cache.
41109 Node.prototype.cacheSequenceEdges = function (edges) {
41110 this._cache.cacheSequenceEdges(edges);
41113 * Cache the spatial edges.
41115 * @description The spatial edges are cached asynchronously
41116 * internally by the library.
41118 * @param {Array<IEdge>} edges - Spatial edges to cache.
41121 Node.prototype.cacheSpatialEdges = function (edges) {
41122 this._cache.cacheSpatialEdges(edges);
41125 * Dispose the node.
41127 * @description Disposes all cached assets.
41130 Node.prototype.dispose = function () {
41131 if (this._cache != null) {
41132 this._cache.dispose();
41133 this._cache = null;
41139 * Initialize the node cache.
41141 * @description The node cache is initialized internally by
41144 * @param {NodeCache} cache - The node cache to set as cache.
41147 Node.prototype.initializeCache = function (cache) {
41148 if (this._cache != null) {
41149 throw new Error("Node cache already initialized (" + this.key + ").");
41151 this._cache = cache;
41154 * Fill the node with all properties.
41156 * @description The node is filled internally by
41159 * @param {IFillNode} fill - The fill node struct.
41162 Node.prototype.makeFull = function (fill) {
41163 if (fill == null) {
41164 throw new Error("Fill can not be null.");
41169 * Reset the sequence edges.
41173 Node.prototype.resetSequenceEdges = function () {
41174 this._cache.resetSequenceEdges();
41177 * Reset the spatial edges.
41181 Node.prototype.resetSpatialEdges = function () {
41182 this._cache.resetSpatialEdges();
41185 * Clears the image and mesh assets, aborts
41186 * any outstanding requests and resets edges.
41190 Node.prototype.uncache = function () {
41191 if (this._cache == null) {
41194 this._cache.dispose();
41195 this._cache = null;
41199 exports.Node = Node;
41200 exports.default = Node;
41202 },{"rxjs/operators":225}],397:[function(require,module,exports){
41203 (function (Buffer){
41205 Object.defineProperty(exports, "__esModule", { value: true });
41206 var rxjs_1 = require("rxjs");
41207 var operators_1 = require("rxjs/operators");
41208 var Graph_1 = require("../Graph");
41209 var Utils_1 = require("../Utils");
41213 * @classdesc Represents the cached properties of a node.
41215 var NodeCache = /** @class */ (function () {
41217 * Create a new node cache instance.
41219 function NodeCache() {
41220 this._disposed = false;
41221 this._image = null;
41222 this._loadStatus = { loaded: 0, total: 0 };
41224 this._sequenceEdges = { cached: false, edges: [] };
41225 this._spatialEdges = { cached: false, edges: [] };
41226 this._imageChanged$ = new rxjs_1.Subject();
41227 this._image$ = this._imageChanged$.pipe(operators_1.startWith(null), operators_1.publishReplay(1), operators_1.refCount());
41228 this._iamgeSubscription = this._image$.subscribe();
41229 this._sequenceEdgesChanged$ = new rxjs_1.Subject();
41230 this._sequenceEdges$ = this._sequenceEdgesChanged$.pipe(operators_1.startWith(this._sequenceEdges), operators_1.publishReplay(1), operators_1.refCount());
41231 this._sequenceEdgesSubscription = this._sequenceEdges$.subscribe(function () { });
41232 this._spatialEdgesChanged$ = new rxjs_1.Subject();
41233 this._spatialEdges$ = this._spatialEdgesChanged$.pipe(operators_1.startWith(this._spatialEdges), operators_1.publishReplay(1), operators_1.refCount());
41234 this._spatialEdgesSubscription = this._spatialEdges$.subscribe(function () { });
41235 this._cachingAssets$ = null;
41237 Object.defineProperty(NodeCache.prototype, "image", {
41241 * @description Will not be set when assets have not been cached
41242 * or when the object has been disposed.
41244 * @returns {HTMLImageElement} Cached image element of the node.
41247 return this._image;
41252 Object.defineProperty(NodeCache.prototype, "image$", {
41256 * @returns {Observable<HTMLImageElement>} Observable emitting
41257 * the cached image when it is updated.
41260 return this._image$;
41265 Object.defineProperty(NodeCache.prototype, "loadStatus", {
41269 * @returns {ILoadStatus} Value indicating the load status
41270 * of the mesh and image.
41273 return this._loadStatus;
41278 Object.defineProperty(NodeCache.prototype, "mesh", {
41282 * @description Will not be set when assets have not been cached
41283 * or when the object has been disposed.
41285 * @returns {IMesh} SfM triangulated mesh of reconstructed
41286 * atomic 3D points.
41294 Object.defineProperty(NodeCache.prototype, "sequenceEdges", {
41296 * Get sequenceEdges.
41298 * @returns {IEdgeStatus} Value describing the status of the
41302 return this._sequenceEdges;
41307 Object.defineProperty(NodeCache.prototype, "sequenceEdges$", {
41309 * Get sequenceEdges$.
41311 * @returns {Observable<IEdgeStatus>} Observable emitting
41312 * values describing the status of the sequence edges.
41315 return this._sequenceEdges$;
41320 Object.defineProperty(NodeCache.prototype, "spatialEdges", {
41322 * Get spatialEdges.
41324 * @returns {IEdgeStatus} Value describing the status of the
41328 return this._spatialEdges;
41333 Object.defineProperty(NodeCache.prototype, "spatialEdges$", {
41335 * Get spatialEdges$.
41337 * @returns {Observable<IEdgeStatus>} Observable emitting
41338 * values describing the status of the spatial edges.
41341 return this._spatialEdges$;
41347 * Cache the image and mesh assets.
41349 * @param {string} key - Key of the node to cache.
41350 * @param {boolean} pano - Value indicating whether node is a panorama.
41351 * @param {boolean} merged - Value indicating whether node is merged.
41352 * @returns {Observable<NodeCache>} Observable emitting this node
41353 * cache whenever the load status has changed and when the mesh or image
41354 * has been fully loaded.
41356 NodeCache.prototype.cacheAssets$ = function (key, pano, merged) {
41358 if (this._cachingAssets$ != null) {
41359 return this._cachingAssets$;
41361 var imageSize = pano ?
41362 Utils_1.Settings.basePanoramaSize :
41363 Utils_1.Settings.baseImageSize;
41364 this._cachingAssets$ = rxjs_1.combineLatest(this._cacheImage$(key, imageSize), this._cacheMesh$(key, merged)).pipe(operators_1.map(function (_a) {
41365 var imageStatus = _a[0], meshStatus = _a[1];
41366 _this._loadStatus.loaded = 0;
41367 _this._loadStatus.total = 0;
41369 _this._mesh = meshStatus.object;
41370 _this._loadStatus.loaded += meshStatus.loaded.loaded;
41371 _this._loadStatus.total += meshStatus.loaded.total;
41374 _this._image = imageStatus.object;
41375 _this._loadStatus.loaded += imageStatus.loaded.loaded;
41376 _this._loadStatus.total += imageStatus.loaded.total;
41379 }), operators_1.finalize(function () {
41380 _this._cachingAssets$ = null;
41381 }), operators_1.publishReplay(1), operators_1.refCount());
41382 this._cachingAssets$.pipe(operators_1.first(function (nodeCache) {
41383 return !!nodeCache._image;
41385 .subscribe(function (nodeCache) {
41386 _this._imageChanged$.next(_this._image);
41387 }, function (error) { });
41388 return this._cachingAssets$;
41391 * Cache an image with a higher resolution than the current one.
41393 * @param {string} key - Key of the node to cache.
41394 * @param {ImageSize} imageSize - The size to cache.
41395 * @returns {Observable<NodeCache>} Observable emitting a single item,
41396 * the node cache, when the image has been cached. If supplied image
41397 * size is not larger than the current image size the node cache is
41398 * returned immediately.
41400 NodeCache.prototype.cacheImage$ = function (key, imageSize) {
41402 if (this._image != null && imageSize <= Math.max(this._image.width, this._image.height)) {
41403 return rxjs_1.of(this);
41405 var cacheImage$ = this._cacheImage$(key, imageSize).pipe(operators_1.first(function (status) {
41406 return status.object != null;
41407 }), operators_1.tap(function (status) {
41408 _this._disposeImage();
41409 _this._image = status.object;
41410 }), operators_1.map(function (imageStatus) {
41412 }), operators_1.publishReplay(1), operators_1.refCount());
41414 .subscribe(function (nodeCache) {
41415 _this._imageChanged$.next(_this._image);
41416 }, function (error) { });
41417 return cacheImage$;
41420 * Cache the sequence edges.
41422 * @param {Array<IEdge>} edges - Sequence edges to cache.
41424 NodeCache.prototype.cacheSequenceEdges = function (edges) {
41425 this._sequenceEdges = { cached: true, edges: edges };
41426 this._sequenceEdgesChanged$.next(this._sequenceEdges);
41429 * Cache the spatial edges.
41431 * @param {Array<IEdge>} edges - Spatial edges to cache.
41433 NodeCache.prototype.cacheSpatialEdges = function (edges) {
41434 this._spatialEdges = { cached: true, edges: edges };
41435 this._spatialEdgesChanged$.next(this._spatialEdges);
41438 * Dispose the node cache.
41440 * @description Disposes all cached assets and unsubscribes to
41443 NodeCache.prototype.dispose = function () {
41444 this._iamgeSubscription.unsubscribe();
41445 this._sequenceEdgesSubscription.unsubscribe();
41446 this._spatialEdgesSubscription.unsubscribe();
41447 this._disposeImage();
41449 this._loadStatus.loaded = 0;
41450 this._loadStatus.total = 0;
41451 this._sequenceEdges = { cached: false, edges: [] };
41452 this._spatialEdges = { cached: false, edges: [] };
41453 this._imageChanged$.next(null);
41454 this._sequenceEdgesChanged$.next(this._sequenceEdges);
41455 this._spatialEdgesChanged$.next(this._spatialEdges);
41456 this._disposed = true;
41457 if (this._imageRequest != null) {
41458 this._imageRequest.abort();
41460 if (this._meshRequest != null) {
41461 this._meshRequest.abort();
41465 * Reset the sequence edges.
41467 NodeCache.prototype.resetSequenceEdges = function () {
41468 this._sequenceEdges = { cached: false, edges: [] };
41469 this._sequenceEdgesChanged$.next(this._sequenceEdges);
41472 * Reset the spatial edges.
41474 NodeCache.prototype.resetSpatialEdges = function () {
41475 this._spatialEdges = { cached: false, edges: [] };
41476 this._spatialEdgesChanged$.next(this._spatialEdges);
41481 * @param {string} key - Key of the node to cache.
41482 * @param {boolean} pano - Value indicating whether node is a panorama.
41483 * @returns {Observable<ILoadStatusObject<HTMLImageElement>>} Observable
41484 * emitting a load status object every time the load status changes
41485 * and completes when the image is fully loaded.
41487 NodeCache.prototype._cacheImage$ = function (key, imageSize) {
41489 return rxjs_1.Observable.create(function (subscriber) {
41490 var xmlHTTP = new XMLHttpRequest();
41491 xmlHTTP.open("GET", Utils_1.Urls.thumbnail(key, imageSize, Utils_1.Urls.origin), true);
41492 xmlHTTP.responseType = "arraybuffer";
41493 xmlHTTP.timeout = 15000;
41494 xmlHTTP.onload = function (pe) {
41495 if (xmlHTTP.status !== 200) {
41496 _this._imageRequest = null;
41497 subscriber.error(new Error("Failed to fetch image (" + key + "). Status: " + xmlHTTP.status + ", " + xmlHTTP.statusText));
41500 var image = new Image();
41501 image.crossOrigin = "Anonymous";
41502 image.onload = function (e) {
41503 _this._imageRequest = null;
41504 if (_this._disposed) {
41505 window.URL.revokeObjectURL(image.src);
41506 subscriber.error(new Error("Image load was aborted (" + key + ")"));
41509 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: image });
41510 subscriber.complete();
41512 image.onerror = function (error) {
41513 _this._imageRequest = null;
41514 subscriber.error(new Error("Failed to load image (" + key + ")"));
41516 var blob = new Blob([xmlHTTP.response]);
41517 image.src = window.URL.createObjectURL(blob);
41519 xmlHTTP.onprogress = function (pe) {
41520 if (_this._disposed) {
41523 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: null });
41525 xmlHTTP.onerror = function (error) {
41526 _this._imageRequest = null;
41527 subscriber.error(new Error("Failed to fetch image (" + key + ")"));
41529 xmlHTTP.ontimeout = function (e) {
41530 _this._imageRequest = null;
41531 subscriber.error(new Error("Image request timed out (" + key + ")"));
41533 xmlHTTP.onabort = function (event) {
41534 _this._imageRequest = null;
41535 subscriber.error(new Error("Image request was aborted (" + key + ")"));
41537 _this._imageRequest = xmlHTTP;
41538 xmlHTTP.send(null);
41544 * @param {string} key - Key of the node to cache.
41545 * @param {boolean} merged - Value indicating whether node is merged.
41546 * @returns {Observable<ILoadStatusObject<IMesh>>} Observable emitting
41547 * a load status object every time the load status changes and completes
41548 * when the mesh is fully loaded.
41550 NodeCache.prototype._cacheMesh$ = function (key, merged) {
41552 return rxjs_1.Observable.create(function (subscriber) {
41554 subscriber.next(_this._createEmptyMeshLoadStatus());
41555 subscriber.complete();
41558 var xmlHTTP = new XMLHttpRequest();
41559 xmlHTTP.open("GET", Utils_1.Urls.protoMesh(key), true);
41560 xmlHTTP.responseType = "arraybuffer";
41561 xmlHTTP.timeout = 15000;
41562 xmlHTTP.onload = function (pe) {
41563 _this._meshRequest = null;
41564 if (_this._disposed) {
41567 var mesh = xmlHTTP.status === 200 ?
41568 Graph_1.MeshReader.read(new Buffer(xmlHTTP.response)) :
41569 { faces: [], vertices: [] };
41570 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: mesh });
41571 subscriber.complete();
41573 xmlHTTP.onprogress = function (pe) {
41574 if (_this._disposed) {
41577 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: null });
41579 xmlHTTP.onerror = function (e) {
41580 _this._meshRequest = null;
41581 console.error("Failed to cache mesh (" + key + ")");
41582 subscriber.next(_this._createEmptyMeshLoadStatus());
41583 subscriber.complete();
41585 xmlHTTP.ontimeout = function (e) {
41586 _this._meshRequest = null;
41587 console.error("Mesh request timed out (" + key + ")");
41588 subscriber.next(_this._createEmptyMeshLoadStatus());
41589 subscriber.complete();
41591 xmlHTTP.onabort = function (e) {
41592 _this._meshRequest = null;
41593 subscriber.error(new Error("Mesh request was aborted (" + key + ")"));
41595 _this._meshRequest = xmlHTTP;
41596 xmlHTTP.send(null);
41600 * Create a load status object with an empty mesh.
41602 * @returns {ILoadStatusObject<IMesh>} Load status object
41605 NodeCache.prototype._createEmptyMeshLoadStatus = function () {
41607 loaded: { loaded: 0, total: 0 },
41608 object: { faces: [], vertices: [] },
41611 NodeCache.prototype._disposeImage = function () {
41612 if (this._image != null) {
41613 window.URL.revokeObjectURL(this._image.src);
41615 this._image = null;
41619 exports.NodeCache = NodeCache;
41620 exports.default = NodeCache;
41622 }).call(this,require("buffer").Buffer)
41624 },{"../Graph":279,"../Utils":285,"buffer":7,"rxjs":27,"rxjs/operators":225}],398:[function(require,module,exports){
41626 Object.defineProperty(exports, "__esModule", { value: true });
41630 * @classdesc Represents a sequence of ordered nodes.
41632 var Sequence = /** @class */ (function () {
41634 * Create a new sequene instance.
41636 * @param {ISequence} sequence - Raw sequence data.
41638 function Sequence(sequence) {
41639 this._key = sequence.key;
41640 this._keys = sequence.keys;
41642 Object.defineProperty(Sequence.prototype, "key", {
41646 * @returns {string} Unique sequence key.
41654 Object.defineProperty(Sequence.prototype, "keys", {
41658 * @returns {Array<string>} Array of ordered node keys in the sequence.
41667 * Dispose the sequence.
41669 * @description Disposes all cached assets.
41671 Sequence.prototype.dispose = function () {
41676 * Find the next node key in the sequence with respect to
41677 * the provided node key.
41679 * @param {string} key - Reference node key.
41680 * @returns {string} Next key in sequence if it exists, null otherwise.
41682 Sequence.prototype.findNextKey = function (key) {
41683 var i = this._keys.indexOf(key);
41684 if ((i + 1) >= this._keys.length || i === -1) {
41688 return this._keys[i + 1];
41692 * Find the previous node key in the sequence with respect to
41693 * the provided node key.
41695 * @param {string} key - Reference node key.
41696 * @returns {string} Previous key in sequence if it exists, null otherwise.
41698 Sequence.prototype.findPrevKey = function (key) {
41699 var i = this._keys.indexOf(key);
41700 if (i === 0 || i === -1) {
41704 return this._keys[i - 1];
41709 exports.Sequence = Sequence;
41710 exports.default = Sequence;
41712 },{}],399:[function(require,module,exports){
41714 Object.defineProperty(exports, "__esModule", { value: true });
41715 var THREE = require("three");
41716 var Edge_1 = require("../../Edge");
41717 var Error_1 = require("../../Error");
41718 var Geo_1 = require("../../Geo");
41720 * @class EdgeCalculator
41722 * @classdesc Represents a class for calculating node edges.
41724 var EdgeCalculator = /** @class */ (function () {
41726 * Create a new edge calculator instance.
41728 * @param {EdgeCalculatorSettings} settings - Settings struct.
41729 * @param {EdgeCalculatorDirections} directions - Directions struct.
41730 * @param {EdgeCalculatorCoefficients} coefficients - Coefficients struct.
41732 function EdgeCalculator(settings, directions, coefficients) {
41733 this._spatial = new Geo_1.Spatial();
41734 this._geoCoords = new Geo_1.GeoCoords();
41735 this._settings = settings != null ? settings : new Edge_1.EdgeCalculatorSettings();
41736 this._directions = directions != null ? directions : new Edge_1.EdgeCalculatorDirections();
41737 this._coefficients = coefficients != null ? coefficients : new Edge_1.EdgeCalculatorCoefficients();
41740 * Returns the potential edges to destination nodes for a set
41741 * of nodes with respect to a source node.
41743 * @param {Node} node - Source node.
41744 * @param {Array<Node>} nodes - Potential destination nodes.
41745 * @param {Array<string>} fallbackKeys - Keys for destination nodes that should
41746 * be returned even if they do not meet the criteria for a potential edge.
41747 * @throws {ArgumentMapillaryError} If node is not full.
41749 EdgeCalculator.prototype.getPotentialEdges = function (node, potentialNodes, fallbackKeys) {
41751 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
41753 if (!node.merged) {
41756 var currentDirection = this._spatial.viewingDirection(node.rotation);
41757 var currentVerticalDirection = this._spatial.angleToPlane(currentDirection.toArray(), [0, 0, 1]);
41758 var potentialEdges = [];
41759 for (var _i = 0, potentialNodes_1 = potentialNodes; _i < potentialNodes_1.length; _i++) {
41760 var potential = potentialNodes_1[_i];
41761 if (!potential.merged ||
41762 potential.key === node.key) {
41765 var enu = this._geoCoords.geodeticToEnu(potential.latLon.lat, potential.latLon.lon, potential.alt, node.latLon.lat, node.latLon.lon, node.alt);
41766 var motion = new THREE.Vector3(enu[0], enu[1], enu[2]);
41767 var distance = motion.length();
41768 if (distance > this._settings.maxDistance &&
41769 fallbackKeys.indexOf(potential.key) < 0) {
41772 var motionChange = this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, motion.x, motion.y);
41773 var verticalMotion = this._spatial.angleToPlane(motion.toArray(), [0, 0, 1]);
41774 var direction = this._spatial.viewingDirection(potential.rotation);
41775 var directionChange = this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, direction.x, direction.y);
41776 var verticalDirection = this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
41777 var verticalDirectionChange = verticalDirection - currentVerticalDirection;
41778 var rotation = this._spatial.relativeRotationAngle(node.rotation, potential.rotation);
41779 var worldMotionAzimuth = this._spatial.angleBetweenVector2(1, 0, motion.x, motion.y);
41780 var sameSequence = potential.sequenceKey != null &&
41781 node.sequenceKey != null &&
41782 potential.sequenceKey === node.sequenceKey;
41783 var sameMergeCC = (potential.mergeCC == null && node.mergeCC == null) ||
41784 potential.mergeCC === node.mergeCC;
41785 var sameUser = potential.userKey === node.userKey;
41786 var potentialEdge = {
41787 capturedAt: potential.capturedAt,
41788 croppedPano: potential.pano && !potential.fullPano,
41789 directionChange: directionChange,
41790 distance: distance,
41791 fullPano: potential.fullPano,
41792 key: potential.key,
41793 motionChange: motionChange,
41794 rotation: rotation,
41795 sameMergeCC: sameMergeCC,
41796 sameSequence: sameSequence,
41797 sameUser: sameUser,
41798 sequenceKey: potential.sequenceKey,
41799 verticalDirectionChange: verticalDirectionChange,
41800 verticalMotion: verticalMotion,
41801 worldMotionAzimuth: worldMotionAzimuth,
41803 potentialEdges.push(potentialEdge);
41805 return potentialEdges;
41808 * Computes the sequence edges for a node.
41810 * @param {Node} node - Source node.
41811 * @throws {ArgumentMapillaryError} If node is not full.
41813 EdgeCalculator.prototype.computeSequenceEdges = function (node, sequence) {
41815 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
41817 if (node.sequenceKey !== sequence.key) {
41818 throw new Error_1.ArgumentMapillaryError("Node and sequence does not correspond.");
41821 var nextKey = sequence.findNextKey(node.key);
41822 if (nextKey != null) {
41825 direction: Edge_1.EdgeDirection.Next,
41826 worldMotionAzimuth: Number.NaN,
41832 var prevKey = sequence.findPrevKey(node.key);
41833 if (prevKey != null) {
41836 direction: Edge_1.EdgeDirection.Prev,
41837 worldMotionAzimuth: Number.NaN,
41846 * Computes the similar edges for a node.
41848 * @description Similar edges for perspective images and cropped panoramas
41849 * look roughly in the same direction and are positioned closed to the node.
41850 * Similar edges for full panoramas only target other full panoramas.
41852 * @param {Node} node - Source node.
41853 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
41854 * @throws {ArgumentMapillaryError} If node is not full.
41856 EdgeCalculator.prototype.computeSimilarEdges = function (node, potentialEdges) {
41859 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
41861 var nodeFullPano = node.fullPano;
41862 var sequenceGroups = {};
41863 for (var _i = 0, potentialEdges_1 = potentialEdges; _i < potentialEdges_1.length; _i++) {
41864 var potentialEdge = potentialEdges_1[_i];
41865 if (potentialEdge.sequenceKey == null) {
41868 if (potentialEdge.sameSequence) {
41871 if (nodeFullPano) {
41872 if (!potentialEdge.fullPano) {
41877 if (!potentialEdge.fullPano &&
41878 Math.abs(potentialEdge.directionChange) > this._settings.similarMaxDirectionChange) {
41882 if (potentialEdge.distance > this._settings.similarMaxDistance) {
41885 if (potentialEdge.sameUser &&
41886 Math.abs(potentialEdge.capturedAt - node.capturedAt) <
41887 this._settings.similarMinTimeDifference) {
41890 if (sequenceGroups[potentialEdge.sequenceKey] == null) {
41891 sequenceGroups[potentialEdge.sequenceKey] = [];
41893 sequenceGroups[potentialEdge.sequenceKey].push(potentialEdge);
41895 var similarEdges = [];
41896 var calculateScore = node.fullPano ?
41897 function (potentialEdge) {
41898 return potentialEdge.distance;
41900 function (potentialEdge) {
41901 return _this._coefficients.similarDistance * potentialEdge.distance +
41902 _this._coefficients.similarRotation * potentialEdge.rotation;
41904 for (var sequenceKey in sequenceGroups) {
41905 if (!sequenceGroups.hasOwnProperty(sequenceKey)) {
41908 var lowestScore = Number.MAX_VALUE;
41909 var similarEdge = null;
41910 for (var _a = 0, _b = sequenceGroups[sequenceKey]; _a < _b.length; _a++) {
41911 var potentialEdge = _b[_a];
41912 var score = calculateScore(potentialEdge);
41913 if (score < lowestScore) {
41914 lowestScore = score;
41915 similarEdge = potentialEdge;
41918 if (similarEdge == null) {
41921 similarEdges.push(similarEdge);
41923 return similarEdges
41924 .map(function (potentialEdge) {
41927 direction: Edge_1.EdgeDirection.Similar,
41928 worldMotionAzimuth: potentialEdge.worldMotionAzimuth,
41931 to: potentialEdge.key,
41936 * Computes the step edges for a perspective node.
41938 * @description Step edge targets can only be other perspective nodes.
41939 * Returns an empty array for cropped and full panoramas.
41941 * @param {Node} node - Source node.
41942 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
41943 * @param {string} prevKey - Key of previous node in sequence.
41944 * @param {string} prevKey - Key of next node in sequence.
41945 * @throws {ArgumentMapillaryError} If node is not full.
41947 EdgeCalculator.prototype.computeStepEdges = function (node, potentialEdges, prevKey, nextKey) {
41949 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
41955 for (var k in this._directions.steps) {
41956 if (!this._directions.steps.hasOwnProperty(k)) {
41959 var step = this._directions.steps[k];
41960 var lowestScore = Number.MAX_VALUE;
41962 var fallback = null;
41963 for (var _i = 0, potentialEdges_2 = potentialEdges; _i < potentialEdges_2.length; _i++) {
41964 var potential = potentialEdges_2[_i];
41965 if (potential.croppedPano || potential.fullPano) {
41968 if (Math.abs(potential.directionChange) > this._settings.stepMaxDirectionChange) {
41971 var motionDifference = this._spatial.angleDifference(step.motionChange, potential.motionChange);
41972 var directionMotionDifference = this._spatial.angleDifference(potential.directionChange, motionDifference);
41973 var drift = Math.max(Math.abs(motionDifference), Math.abs(directionMotionDifference));
41974 if (Math.abs(drift) > this._settings.stepMaxDrift) {
41977 var potentialKey = potential.key;
41978 if (step.useFallback && (potentialKey === prevKey || potentialKey === nextKey)) {
41979 fallback = potential;
41981 if (potential.distance > this._settings.stepMaxDistance) {
41984 motionDifference = Math.sqrt(motionDifference * motionDifference +
41985 potential.verticalMotion * potential.verticalMotion);
41986 var score = this._coefficients.stepPreferredDistance *
41987 Math.abs(potential.distance - this._settings.stepPreferredDistance) /
41988 this._settings.stepMaxDistance +
41989 this._coefficients.stepMotion * motionDifference / this._settings.stepMaxDrift +
41990 this._coefficients.stepRotation * potential.rotation / this._settings.stepMaxDirectionChange +
41991 this._coefficients.stepSequencePenalty * (potential.sameSequence ? 0 : 1) +
41992 this._coefficients.stepMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
41993 if (score < lowestScore) {
41994 lowestScore = score;
41998 edge = edge == null ? fallback : edge;
41999 if (edge != null) {
42002 direction: step.direction,
42003 worldMotionAzimuth: edge.worldMotionAzimuth,
42013 * Computes the turn edges for a perspective node.
42015 * @description Turn edge targets can only be other perspective images.
42016 * Returns an empty array for cropped and full panoramas.
42018 * @param {Node} node - Source node.
42019 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
42020 * @throws {ArgumentMapillaryError} If node is not full.
42022 EdgeCalculator.prototype.computeTurnEdges = function (node, potentialEdges) {
42024 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
42030 for (var k in this._directions.turns) {
42031 if (!this._directions.turns.hasOwnProperty(k)) {
42034 var turn = this._directions.turns[k];
42035 var lowestScore = Number.MAX_VALUE;
42037 for (var _i = 0, potentialEdges_3 = potentialEdges; _i < potentialEdges_3.length; _i++) {
42038 var potential = potentialEdges_3[_i];
42039 if (potential.croppedPano || potential.fullPano) {
42042 if (potential.distance > this._settings.turnMaxDistance) {
42045 var rig = turn.direction !== Edge_1.EdgeDirection.TurnU &&
42046 potential.distance < this._settings.turnMaxRigDistance &&
42047 Math.abs(potential.directionChange) > this._settings.turnMinRigDirectionChange;
42048 var directionDifference = this._spatial.angleDifference(turn.directionChange, potential.directionChange);
42049 var score = void 0;
42051 potential.directionChange * turn.directionChange > 0 &&
42052 Math.abs(potential.directionChange) < Math.abs(turn.directionChange)) {
42053 score = -Math.PI / 2 + Math.abs(potential.directionChange);
42056 if (Math.abs(directionDifference) > this._settings.turnMaxDirectionChange) {
42059 var motionDifference = turn.motionChange ?
42060 this._spatial.angleDifference(turn.motionChange, potential.motionChange) : 0;
42061 motionDifference = Math.sqrt(motionDifference * motionDifference +
42062 potential.verticalMotion * potential.verticalMotion);
42064 this._coefficients.turnDistance * potential.distance /
42065 this._settings.turnMaxDistance +
42066 this._coefficients.turnMotion * motionDifference / Math.PI +
42067 this._coefficients.turnSequencePenalty * (potential.sameSequence ? 0 : 1) +
42068 this._coefficients.turnMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
42070 if (score < lowestScore) {
42071 lowestScore = score;
42075 if (edge != null) {
42078 direction: turn.direction,
42079 worldMotionAzimuth: edge.worldMotionAzimuth,
42089 * Computes the pano edges for a perspective node.
42091 * @description Perspective to pano edge targets can only be
42092 * full pano nodes. Returns an empty array for cropped and full panoramas.
42094 * @param {Node} node - Source node.
42095 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
42096 * @throws {ArgumentMapillaryError} If node is not full.
42098 EdgeCalculator.prototype.computePerspectiveToPanoEdges = function (node, potentialEdges) {
42100 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
42105 var lowestScore = Number.MAX_VALUE;
42107 for (var _i = 0, potentialEdges_4 = potentialEdges; _i < potentialEdges_4.length; _i++) {
42108 var potential = potentialEdges_4[_i];
42109 if (!potential.fullPano) {
42112 var score = this._coefficients.panoPreferredDistance *
42113 Math.abs(potential.distance - this._settings.panoPreferredDistance) /
42114 this._settings.panoMaxDistance +
42115 this._coefficients.panoMotion * Math.abs(potential.motionChange) / Math.PI +
42116 this._coefficients.panoMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
42117 if (score < lowestScore) {
42118 lowestScore = score;
42122 if (edge == null) {
42128 direction: Edge_1.EdgeDirection.Pano,
42129 worldMotionAzimuth: edge.worldMotionAzimuth,
42137 * Computes the full pano and step edges for a full pano node.
42139 * @description Pano to pano edge targets can only be
42140 * full pano nodes. Pano to step edge targets can only be perspective
42142 * Returns an empty array for cropped panoramas and perspective nodes.
42144 * @param {Node} node - Source node.
42145 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
42146 * @throws {ArgumentMapillaryError} If node is not full.
42148 EdgeCalculator.prototype.computePanoEdges = function (node, potentialEdges) {
42150 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
42152 if (!node.fullPano) {
42155 var panoEdges = [];
42156 var potentialPanos = [];
42157 var potentialSteps = [];
42158 for (var _i = 0, potentialEdges_5 = potentialEdges; _i < potentialEdges_5.length; _i++) {
42159 var potential = potentialEdges_5[_i];
42160 if (potential.distance > this._settings.panoMaxDistance) {
42163 if (potential.fullPano) {
42164 if (potential.distance < this._settings.panoMinDistance) {
42167 potentialPanos.push(potential);
42170 if (potential.croppedPano) {
42173 for (var k in this._directions.panos) {
42174 if (!this._directions.panos.hasOwnProperty(k)) {
42177 var pano = this._directions.panos[k];
42178 var turn = this._spatial.angleDifference(potential.directionChange, potential.motionChange);
42179 var turnChange = this._spatial.angleDifference(pano.directionChange, turn);
42180 if (Math.abs(turnChange) > this._settings.panoMaxStepTurnChange) {
42183 potentialSteps.push([pano.direction, potential]);
42184 // break if step direction found
42189 var maxRotationDifference = Math.PI / this._settings.panoMaxItems;
42190 var occupiedAngles = [];
42191 var stepAngles = [];
42192 for (var index = 0; index < this._settings.panoMaxItems; index++) {
42193 var rotation = index / this._settings.panoMaxItems * 2 * Math.PI;
42194 var lowestScore = Number.MAX_VALUE;
42196 for (var _a = 0, potentialPanos_1 = potentialPanos; _a < potentialPanos_1.length; _a++) {
42197 var potential = potentialPanos_1[_a];
42198 var motionDifference = this._spatial.angleDifference(rotation, potential.motionChange);
42199 if (Math.abs(motionDifference) > maxRotationDifference) {
42202 var occupiedDifference = Number.MAX_VALUE;
42203 for (var _b = 0, occupiedAngles_1 = occupiedAngles; _b < occupiedAngles_1.length; _b++) {
42204 var occupiedAngle = occupiedAngles_1[_b];
42205 var difference = Math.abs(this._spatial.angleDifference(occupiedAngle, potential.motionChange));
42206 if (difference < occupiedDifference) {
42207 occupiedDifference = difference;
42210 if (occupiedDifference <= maxRotationDifference) {
42213 var score = this._coefficients.panoPreferredDistance *
42214 Math.abs(potential.distance - this._settings.panoPreferredDistance) /
42215 this._settings.panoMaxDistance +
42216 this._coefficients.panoMotion * Math.abs(motionDifference) / maxRotationDifference +
42217 this._coefficients.panoSequencePenalty * (potential.sameSequence ? 0 : 1) +
42218 this._coefficients.panoMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
42219 if (score < lowestScore) {
42220 lowestScore = score;
42224 if (edge != null) {
42225 occupiedAngles.push(edge.motionChange);
42228 direction: Edge_1.EdgeDirection.Pano,
42229 worldMotionAzimuth: edge.worldMotionAzimuth,
42236 stepAngles.push(rotation);
42239 var occupiedStepAngles = {};
42240 occupiedStepAngles[Edge_1.EdgeDirection.Pano] = occupiedAngles;
42241 occupiedStepAngles[Edge_1.EdgeDirection.StepForward] = [];
42242 occupiedStepAngles[Edge_1.EdgeDirection.StepLeft] = [];
42243 occupiedStepAngles[Edge_1.EdgeDirection.StepBackward] = [];
42244 occupiedStepAngles[Edge_1.EdgeDirection.StepRight] = [];
42245 for (var _c = 0, stepAngles_1 = stepAngles; _c < stepAngles_1.length; _c++) {
42246 var stepAngle = stepAngles_1[_c];
42247 var occupations = [];
42248 for (var k in this._directions.panos) {
42249 if (!this._directions.panos.hasOwnProperty(k)) {
42252 var pano = this._directions.panos[k];
42253 var allOccupiedAngles = occupiedStepAngles[Edge_1.EdgeDirection.Pano]
42254 .concat(occupiedStepAngles[pano.direction])
42255 .concat(occupiedStepAngles[pano.prev])
42256 .concat(occupiedStepAngles[pano.next]);
42257 var lowestScore = Number.MAX_VALUE;
42259 for (var _d = 0, potentialSteps_1 = potentialSteps; _d < potentialSteps_1.length; _d++) {
42260 var potential = potentialSteps_1[_d];
42261 if (potential[0] !== pano.direction) {
42264 var motionChange = this._spatial.angleDifference(stepAngle, potential[1].motionChange);
42265 if (Math.abs(motionChange) > maxRotationDifference) {
42268 var minOccupiedDifference = Number.MAX_VALUE;
42269 for (var _e = 0, allOccupiedAngles_1 = allOccupiedAngles; _e < allOccupiedAngles_1.length; _e++) {
42270 var occupiedAngle = allOccupiedAngles_1[_e];
42271 var occupiedDifference = Math.abs(this._spatial.angleDifference(occupiedAngle, potential[1].motionChange));
42272 if (occupiedDifference < minOccupiedDifference) {
42273 minOccupiedDifference = occupiedDifference;
42276 if (minOccupiedDifference <= maxRotationDifference) {
42279 var score = this._coefficients.panoPreferredDistance *
42280 Math.abs(potential[1].distance - this._settings.panoPreferredDistance) /
42281 this._settings.panoMaxDistance +
42282 this._coefficients.panoMotion * Math.abs(motionChange) / maxRotationDifference +
42283 this._coefficients.panoMergeCCPenalty * (potential[1].sameMergeCC ? 0 : 1);
42284 if (score < lowestScore) {
42285 lowestScore = score;
42289 if (edge != null) {
42290 occupations.push(edge);
42293 direction: edge[0],
42294 worldMotionAzimuth: edge[1].worldMotionAzimuth,
42301 for (var _f = 0, occupations_1 = occupations; _f < occupations_1.length; _f++) {
42302 var occupation = occupations_1[_f];
42303 occupiedStepAngles[occupation[0]].push(occupation[1].motionChange);
42308 return EdgeCalculator;
42310 exports.EdgeCalculator = EdgeCalculator;
42311 exports.default = EdgeCalculator;
42313 },{"../../Edge":276,"../../Error":277,"../../Geo":278,"three":226}],400:[function(require,module,exports){
42315 Object.defineProperty(exports, "__esModule", { value: true });
42316 var EdgeCalculatorCoefficients = /** @class */ (function () {
42317 function EdgeCalculatorCoefficients() {
42318 this.panoPreferredDistance = 2;
42319 this.panoMotion = 2;
42320 this.panoSequencePenalty = 1;
42321 this.panoMergeCCPenalty = 4;
42322 this.stepPreferredDistance = 4;
42323 this.stepMotion = 3;
42324 this.stepRotation = 4;
42325 this.stepSequencePenalty = 2;
42326 this.stepMergeCCPenalty = 6;
42327 this.similarDistance = 2;
42328 this.similarRotation = 3;
42329 this.turnDistance = 4;
42330 this.turnMotion = 2;
42331 this.turnSequencePenalty = 1;
42332 this.turnMergeCCPenalty = 4;
42334 return EdgeCalculatorCoefficients;
42336 exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients;
42337 exports.default = EdgeCalculatorCoefficients;
42339 },{}],401:[function(require,module,exports){
42341 Object.defineProperty(exports, "__esModule", { value: true });
42342 var Edge_1 = require("../../Edge");
42343 var EdgeCalculatorDirections = /** @class */ (function () {
42344 function EdgeCalculatorDirections() {
42348 this.steps[Edge_1.EdgeDirection.StepForward] = {
42349 direction: Edge_1.EdgeDirection.StepForward,
42353 this.steps[Edge_1.EdgeDirection.StepBackward] = {
42354 direction: Edge_1.EdgeDirection.StepBackward,
42355 motionChange: Math.PI,
42358 this.steps[Edge_1.EdgeDirection.StepLeft] = {
42359 direction: Edge_1.EdgeDirection.StepLeft,
42360 motionChange: Math.PI / 2,
42361 useFallback: false,
42363 this.steps[Edge_1.EdgeDirection.StepRight] = {
42364 direction: Edge_1.EdgeDirection.StepRight,
42365 motionChange: -Math.PI / 2,
42366 useFallback: false,
42368 this.turns[Edge_1.EdgeDirection.TurnLeft] = {
42369 direction: Edge_1.EdgeDirection.TurnLeft,
42370 directionChange: Math.PI / 2,
42371 motionChange: Math.PI / 4,
42373 this.turns[Edge_1.EdgeDirection.TurnRight] = {
42374 direction: Edge_1.EdgeDirection.TurnRight,
42375 directionChange: -Math.PI / 2,
42376 motionChange: -Math.PI / 4,
42378 this.turns[Edge_1.EdgeDirection.TurnU] = {
42379 direction: Edge_1.EdgeDirection.TurnU,
42380 directionChange: Math.PI,
42381 motionChange: null,
42383 this.panos[Edge_1.EdgeDirection.StepForward] = {
42384 direction: Edge_1.EdgeDirection.StepForward,
42385 directionChange: 0,
42386 next: Edge_1.EdgeDirection.StepLeft,
42387 prev: Edge_1.EdgeDirection.StepRight,
42389 this.panos[Edge_1.EdgeDirection.StepBackward] = {
42390 direction: Edge_1.EdgeDirection.StepBackward,
42391 directionChange: Math.PI,
42392 next: Edge_1.EdgeDirection.StepRight,
42393 prev: Edge_1.EdgeDirection.StepLeft,
42395 this.panos[Edge_1.EdgeDirection.StepLeft] = {
42396 direction: Edge_1.EdgeDirection.StepLeft,
42397 directionChange: Math.PI / 2,
42398 next: Edge_1.EdgeDirection.StepBackward,
42399 prev: Edge_1.EdgeDirection.StepForward,
42401 this.panos[Edge_1.EdgeDirection.StepRight] = {
42402 direction: Edge_1.EdgeDirection.StepRight,
42403 directionChange: -Math.PI / 2,
42404 next: Edge_1.EdgeDirection.StepForward,
42405 prev: Edge_1.EdgeDirection.StepBackward,
42408 return EdgeCalculatorDirections;
42410 exports.EdgeCalculatorDirections = EdgeCalculatorDirections;
42412 },{"../../Edge":276}],402:[function(require,module,exports){
42414 Object.defineProperty(exports, "__esModule", { value: true });
42415 var EdgeCalculatorSettings = /** @class */ (function () {
42416 function EdgeCalculatorSettings() {
42417 this.panoMinDistance = 0.1;
42418 this.panoMaxDistance = 20;
42419 this.panoPreferredDistance = 5;
42420 this.panoMaxItems = 4;
42421 this.panoMaxStepTurnChange = Math.PI / 8;
42422 this.rotationMaxDistance = this.turnMaxRigDistance;
42423 this.rotationMaxDirectionChange = Math.PI / 6;
42424 this.rotationMaxVerticalDirectionChange = Math.PI / 8;
42425 this.similarMaxDirectionChange = Math.PI / 8;
42426 this.similarMaxDistance = 12;
42427 this.similarMinTimeDifference = 12 * 3600 * 1000;
42428 this.stepMaxDistance = 20;
42429 this.stepMaxDirectionChange = Math.PI / 6;
42430 this.stepMaxDrift = Math.PI / 6;
42431 this.stepPreferredDistance = 4;
42432 this.turnMaxDistance = 15;
42433 this.turnMaxDirectionChange = 2 * Math.PI / 9;
42434 this.turnMaxRigDistance = 0.65;
42435 this.turnMinRigDirectionChange = Math.PI / 6;
42437 Object.defineProperty(EdgeCalculatorSettings.prototype, "maxDistance", {
42439 return Math.max(this.panoMaxDistance, this.similarMaxDistance, this.stepMaxDistance, this.turnMaxDistance);
42444 return EdgeCalculatorSettings;
42446 exports.EdgeCalculatorSettings = EdgeCalculatorSettings;
42447 exports.default = EdgeCalculatorSettings;
42449 },{}],403:[function(require,module,exports){
42451 Object.defineProperty(exports, "__esModule", { value: true });
42453 * Enumeration for edge directions
42456 * @description Directions for edges in node graph describing
42457 * sequence, spatial and node type relations between nodes.
42460 (function (EdgeDirection) {
42462 * Next node in the sequence.
42464 EdgeDirection[EdgeDirection["Next"] = 0] = "Next";
42466 * Previous node in the sequence.
42468 EdgeDirection[EdgeDirection["Prev"] = 1] = "Prev";
42470 * Step to the left keeping viewing direction.
42472 EdgeDirection[EdgeDirection["StepLeft"] = 2] = "StepLeft";
42474 * Step to the right keeping viewing direction.
42476 EdgeDirection[EdgeDirection["StepRight"] = 3] = "StepRight";
42478 * Step forward keeping viewing direction.
42480 EdgeDirection[EdgeDirection["StepForward"] = 4] = "StepForward";
42482 * Step backward keeping viewing direction.
42484 EdgeDirection[EdgeDirection["StepBackward"] = 5] = "StepBackward";
42486 * Turn 90 degrees counter clockwise.
42488 EdgeDirection[EdgeDirection["TurnLeft"] = 6] = "TurnLeft";
42490 * Turn 90 degrees clockwise.
42492 EdgeDirection[EdgeDirection["TurnRight"] = 7] = "TurnRight";
42494 * Turn 180 degrees.
42496 EdgeDirection[EdgeDirection["TurnU"] = 8] = "TurnU";
42498 * Panorama in general direction.
42500 EdgeDirection[EdgeDirection["Pano"] = 9] = "Pano";
42502 * Looking in roughly the same direction at rougly the same position.
42504 EdgeDirection[EdgeDirection["Similar"] = 10] = "Similar";
42505 })(EdgeDirection = exports.EdgeDirection || (exports.EdgeDirection = {}));
42507 },{}],404:[function(require,module,exports){
42509 Object.defineProperty(exports, "__esModule", { value: true });
42510 var rxjs_1 = require("rxjs");
42511 var operators_1 = require("rxjs/operators");
42512 var vd = require("virtual-dom");
42513 var rxjs_2 = require("rxjs");
42514 var Render_1 = require("../Render");
42515 var DOMRenderer = /** @class */ (function () {
42516 function DOMRenderer(element, renderService, currentFrame$) {
42517 this._adaptiveOperation$ = new rxjs_2.Subject();
42518 this._render$ = new rxjs_2.Subject();
42519 this._renderAdaptive$ = new rxjs_2.Subject();
42520 this._renderService = renderService;
42521 this._currentFrame$ = currentFrame$;
42522 var rootNode = vd.create(vd.h("div.domRenderer", []));
42523 element.appendChild(rootNode);
42524 this._offset$ = this._adaptiveOperation$.pipe(operators_1.scan(function (adaptive, operation) {
42525 return operation(adaptive);
42527 elementHeight: element.offsetHeight,
42528 elementWidth: element.offsetWidth,
42530 renderMode: Render_1.RenderMode.Fill,
42531 }), operators_1.filter(function (adaptive) {
42532 return adaptive.imageAspect > 0 && adaptive.elementWidth > 0 && adaptive.elementHeight > 0;
42533 }), operators_1.map(function (adaptive) {
42534 var elementAspect = adaptive.elementWidth / adaptive.elementHeight;
42535 var ratio = adaptive.imageAspect / elementAspect;
42536 var verticalOffset = 0;
42537 var horizontalOffset = 0;
42538 if (adaptive.renderMode === Render_1.RenderMode.Letterbox) {
42539 if (adaptive.imageAspect > elementAspect) {
42540 verticalOffset = adaptive.elementHeight * (1 - 1 / ratio) / 2;
42543 horizontalOffset = adaptive.elementWidth * (1 - ratio) / 2;
42547 if (adaptive.imageAspect > elementAspect) {
42548 horizontalOffset = -adaptive.elementWidth * (ratio - 1) / 2;
42551 verticalOffset = -adaptive.elementHeight * (1 / ratio - 1) / 2;
42555 bottom: verticalOffset,
42556 left: horizontalOffset,
42557 right: horizontalOffset,
42558 top: verticalOffset,
42561 this._currentFrame$.pipe(operators_1.filter(function (frame) {
42562 return frame.state.currentNode != null;
42563 }), operators_1.distinctUntilChanged(function (k1, k2) {
42565 }, function (frame) {
42566 return frame.state.currentNode.key;
42567 }), operators_1.map(function (frame) {
42568 return frame.state.currentTransform.basicAspect;
42569 }), operators_1.map(function (aspect) {
42570 return function (adaptive) {
42571 adaptive.imageAspect = aspect;
42575 .subscribe(this._adaptiveOperation$);
42576 rxjs_1.combineLatest(this._renderAdaptive$.pipe(operators_1.scan(function (vNodeHashes, vNodeHash) {
42577 if (vNodeHash.vnode == null) {
42578 delete vNodeHashes[vNodeHash.name];
42581 vNodeHashes[vNodeHash.name] = vNodeHash.vnode;
42583 return vNodeHashes;
42584 }, {})), this._offset$).pipe(operators_1.map(function (vo) {
42586 var hashes = vo[0];
42587 for (var name_1 in hashes) {
42588 if (!hashes.hasOwnProperty(name_1)) {
42591 vNodes.push(hashes[name_1]);
42593 var offset = vo[1];
42596 bottom: offset.bottom + "px",
42597 left: offset.left + "px",
42598 "pointer-events": "none",
42599 position: "absolute",
42600 right: offset.right + "px",
42601 top: offset.top + "px",
42605 name: "adaptiveDomRenderer",
42606 vnode: vd.h("div.adaptiveDomRenderer", properties, vNodes),
42609 .subscribe(this._render$);
42610 this._vNode$ = this._render$.pipe(operators_1.scan(function (vNodeHashes, vNodeHash) {
42611 if (vNodeHash.vnode == null) {
42612 delete vNodeHashes[vNodeHash.name];
42615 vNodeHashes[vNodeHash.name] = vNodeHash.vnode;
42617 return vNodeHashes;
42618 }, {}), operators_1.map(function (hashes) {
42620 for (var name_2 in hashes) {
42621 if (!hashes.hasOwnProperty(name_2)) {
42624 vNodes.push(hashes[name_2]);
42626 return vd.h("div.domRenderer", vNodes);
42628 this._vPatch$ = this._vNode$.pipe(operators_1.scan(function (nodePatch, vNode) {
42629 nodePatch.vpatch = vd.diff(nodePatch.vnode, vNode);
42630 nodePatch.vnode = vNode;
42632 }, { vnode: vd.h("div.domRenderer", []), vpatch: null }), operators_1.pluck("vpatch"));
42633 this._element$ = this._vPatch$.pipe(operators_1.scan(function (oldElement, vPatch) {
42634 return vd.patch(oldElement, vPatch);
42635 }, rootNode), operators_1.publishReplay(1), operators_1.refCount());
42636 this._element$.subscribe(function () { });
42637 this._renderService.size$.pipe(operators_1.map(function (size) {
42638 return function (adaptive) {
42639 adaptive.elementWidth = size.width;
42640 adaptive.elementHeight = size.height;
42644 .subscribe(this._adaptiveOperation$);
42645 this._renderService.renderMode$.pipe(operators_1.map(function (renderMode) {
42646 return function (adaptive) {
42647 adaptive.renderMode = renderMode;
42651 .subscribe(this._adaptiveOperation$);
42653 Object.defineProperty(DOMRenderer.prototype, "element$", {
42655 return this._element$;
42660 Object.defineProperty(DOMRenderer.prototype, "render$", {
42662 return this._render$;
42667 Object.defineProperty(DOMRenderer.prototype, "renderAdaptive$", {
42669 return this._renderAdaptive$;
42674 DOMRenderer.prototype.clear = function (name) {
42675 this._renderAdaptive$.next({ name: name, vnode: null });
42676 this._render$.next({ name: name, vnode: null });
42678 return DOMRenderer;
42680 exports.DOMRenderer = DOMRenderer;
42681 exports.default = DOMRenderer;
42684 },{"../Render":281,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],405:[function(require,module,exports){
42686 Object.defineProperty(exports, "__esModule", { value: true });
42688 (function (GLRenderStage) {
42689 GLRenderStage[GLRenderStage["Background"] = 0] = "Background";
42690 GLRenderStage[GLRenderStage["Foreground"] = 1] = "Foreground";
42691 })(GLRenderStage = exports.GLRenderStage || (exports.GLRenderStage = {}));
42692 exports.default = GLRenderStage;
42694 },{}],406:[function(require,module,exports){
42696 Object.defineProperty(exports, "__esModule", { value: true });
42697 var rxjs_1 = require("rxjs");
42698 var operators_1 = require("rxjs/operators");
42699 var THREE = require("three");
42700 var Render_1 = require("../Render");
42701 var Utils_1 = require("../Utils");
42702 var GLRenderer = /** @class */ (function () {
42703 function GLRenderer(canvasContainer, renderService, dom) {
42705 this._renderFrame$ = new rxjs_1.Subject();
42706 this._renderCameraOperation$ = new rxjs_1.Subject();
42707 this._render$ = new rxjs_1.Subject();
42708 this._clear$ = new rxjs_1.Subject();
42709 this._renderOperation$ = new rxjs_1.Subject();
42710 this._rendererOperation$ = new rxjs_1.Subject();
42711 this._eraserOperation$ = new rxjs_1.Subject();
42712 this._renderService = renderService;
42713 this._dom = !!dom ? dom : new Utils_1.DOM();
42714 this._renderer$ = this._rendererOperation$.pipe(operators_1.scan(function (renderer, operation) {
42715 return operation(renderer);
42716 }, { needsRender: false, renderer: null }), operators_1.filter(function (renderer) {
42717 return !!renderer.renderer;
42719 this._renderCollection$ = this._renderOperation$.pipe(operators_1.scan(function (hashes, operation) {
42720 return operation(hashes);
42721 }, {}), operators_1.share());
42722 this._renderCamera$ = this._renderCameraOperation$.pipe(operators_1.scan(function (rc, operation) {
42723 return operation(rc);
42724 }, { frameId: -1, needsRender: false, perspective: null }));
42725 this._eraser$ = this._eraserOperation$.pipe(operators_1.startWith(function (eraser) {
42727 }), operators_1.scan(function (eraser, operation) {
42728 return operation(eraser);
42729 }, { needsRender: false }));
42730 rxjs_1.combineLatest(this._renderer$, this._renderCollection$, this._renderCamera$, this._eraser$).pipe(operators_1.map(function (_a) {
42731 var renderer = _a[0], hashes = _a[1], rc = _a[2], eraser = _a[3];
42732 var renders = Object.keys(hashes)
42733 .map(function (key) {
42734 return hashes[key];
42736 return { camera: rc, eraser: eraser, renderer: renderer, renders: renders };
42737 }), operators_1.filter(function (co) {
42738 var needsRender = co.renderer.needsRender ||
42739 co.camera.needsRender ||
42740 co.eraser.needsRender;
42741 var frameId = co.camera.frameId;
42742 for (var _i = 0, _a = co.renders; _i < _a.length; _i++) {
42743 var render = _a[_i];
42744 if (render.frameId !== frameId) {
42747 needsRender = needsRender || render.needsRender;
42749 return needsRender;
42750 }), operators_1.distinctUntilChanged(function (n1, n2) {
42753 return co.eraser.needsRender ? -1 : co.camera.frameId;
42755 .subscribe(function (co) {
42756 co.renderer.needsRender = false;
42757 co.camera.needsRender = false;
42758 co.eraser.needsRender = false;
42759 var perspectiveCamera = co.camera.perspective;
42760 var backgroundRenders = [];
42761 var foregroundRenders = [];
42762 for (var _i = 0, _a = co.renders; _i < _a.length; _i++) {
42763 var render = _a[_i];
42764 if (render.stage === Render_1.GLRenderStage.Background) {
42765 backgroundRenders.push(render.render);
42767 else if (render.stage === Render_1.GLRenderStage.Foreground) {
42768 foregroundRenders.push(render.render);
42771 var renderer = co.renderer.renderer;
42773 for (var _b = 0, backgroundRenders_1 = backgroundRenders; _b < backgroundRenders_1.length; _b++) {
42774 var render = backgroundRenders_1[_b];
42775 render(perspectiveCamera, renderer);
42777 renderer.clearDepth();
42778 for (var _c = 0, foregroundRenders_1 = foregroundRenders; _c < foregroundRenders_1.length; _c++) {
42779 var render = foregroundRenders_1[_c];
42780 render(perspectiveCamera, renderer);
42783 this._renderFrame$.pipe(operators_1.map(function (rc) {
42784 return function (irc) {
42785 irc.frameId = rc.frameId;
42786 irc.perspective = rc.perspective;
42787 if (rc.changed === true) {
42788 irc.needsRender = true;
42793 .subscribe(this._renderCameraOperation$);
42794 this._renderFrameSubscribe();
42795 var renderHash$ = this._render$.pipe(operators_1.map(function (hash) {
42796 return function (hashes) {
42797 hashes[hash.name] = hash.render;
42801 var clearHash$ = this._clear$.pipe(operators_1.map(function (name) {
42802 return function (hashes) {
42803 delete hashes[name];
42807 rxjs_1.merge(renderHash$, clearHash$)
42808 .subscribe(this._renderOperation$);
42809 this._webGLRenderer$ = this._render$.pipe(operators_1.first(), operators_1.map(function (hash) {
42810 var canvas = _this._dom.createElement("canvas", "mapillary-js-canvas");
42811 canvas.style.position = "absolute";
42812 canvas.setAttribute("tabindex", "0");
42813 canvasContainer.appendChild(canvas);
42814 var element = renderService.element;
42815 var webGLRenderer = new THREE.WebGLRenderer({ canvas: canvas });
42816 webGLRenderer.setPixelRatio(window.devicePixelRatio);
42817 webGLRenderer.setSize(element.offsetWidth, element.offsetHeight);
42818 webGLRenderer.setClearColor(new THREE.Color(0x202020), 1.0);
42819 webGLRenderer.autoClear = false;
42820 return webGLRenderer;
42821 }), operators_1.publishReplay(1), operators_1.refCount());
42822 this._webGLRenderer$.subscribe(function () { });
42823 var createRenderer$ = this._webGLRenderer$.pipe(operators_1.first(), operators_1.map(function (webGLRenderer) {
42824 return function (renderer) {
42825 renderer.needsRender = true;
42826 renderer.renderer = webGLRenderer;
42830 var resizeRenderer$ = this._renderService.size$.pipe(operators_1.map(function (size) {
42831 return function (renderer) {
42832 if (renderer.renderer == null) {
42835 renderer.renderer.setSize(size.width, size.height);
42836 renderer.needsRender = true;
42840 var clearRenderer$ = this._clear$.pipe(operators_1.map(function (name) {
42841 return function (renderer) {
42842 if (renderer.renderer == null) {
42845 renderer.needsRender = true;
42849 rxjs_1.merge(createRenderer$, resizeRenderer$, clearRenderer$)
42850 .subscribe(this._rendererOperation$);
42851 var renderCollectionEmpty$ = this._renderCollection$.pipe(operators_1.filter(function (hashes) {
42852 return Object.keys(hashes).length === 0;
42853 }), operators_1.share());
42854 renderCollectionEmpty$
42855 .subscribe(function (hashes) {
42856 if (_this._renderFrameSubscription == null) {
42859 _this._renderFrameSubscription.unsubscribe();
42860 _this._renderFrameSubscription = null;
42861 _this._renderFrameSubscribe();
42863 renderCollectionEmpty$.pipe(operators_1.map(function (hashes) {
42864 return function (eraser) {
42865 eraser.needsRender = true;
42869 .subscribe(this._eraserOperation$);
42871 Object.defineProperty(GLRenderer.prototype, "render$", {
42873 return this._render$;
42878 Object.defineProperty(GLRenderer.prototype, "webGLRenderer$", {
42880 return this._webGLRenderer$;
42885 GLRenderer.prototype.clear = function (name) {
42886 this._clear$.next(name);
42888 GLRenderer.prototype._renderFrameSubscribe = function () {
42890 this._render$.pipe(operators_1.first(), operators_1.map(function (renderHash) {
42891 return function (irc) {
42892 irc.needsRender = true;
42896 .subscribe(function (operation) {
42897 _this._renderCameraOperation$.next(operation);
42899 this._renderFrameSubscription = this._render$.pipe(operators_1.first(), operators_1.mergeMap(function (hash) {
42900 return _this._renderService.renderCameraFrame$;
42902 .subscribe(this._renderFrame$);
42906 exports.GLRenderer = GLRenderer;
42907 exports.default = GLRenderer;
42910 },{"../Render":281,"../Utils":285,"rxjs":27,"rxjs/operators":225,"three":226}],407:[function(require,module,exports){
42912 Object.defineProperty(exports, "__esModule", { value: true });
42913 var THREE = require("three");
42914 var Geo_1 = require("../Geo");
42915 var Render_1 = require("../Render");
42916 var State_1 = require("../State");
42917 var RenderCamera = /** @class */ (function () {
42918 function RenderCamera(elementWidth, elementHeight, renderMode) {
42919 this._spatial = new Geo_1.Spatial();
42920 this._viewportCoords = new Geo_1.ViewportCoords();
42921 this._initialFov = 50;
42923 this._renderMode = renderMode;
42925 this._frameId = -1;
42926 this._changed = false;
42927 this._changedForFrame = -1;
42928 this._currentNodeId = null;
42929 this._previousNodeId = null;
42930 this._currentPano = false;
42931 this._previousPano = false;
42932 this._state = null;
42933 this._currentProjectedPoints = [];
42934 this._previousProjectedPoints = [];
42935 this._currentFov = this._initialFov;
42936 this._previousFov = this._initialFov;
42937 this._camera = new Geo_1.Camera();
42938 this._perspective = new THREE.PerspectiveCamera(this._initialFov, this._computeAspect(elementWidth, elementHeight), 0.16, 10000);
42939 this._perspective.matrixAutoUpdate = false;
42940 this._rotation = { phi: 0, theta: 0 };
42942 Object.defineProperty(RenderCamera.prototype, "alpha", {
42944 return this._alpha;
42949 Object.defineProperty(RenderCamera.prototype, "camera", {
42951 return this._camera;
42956 Object.defineProperty(RenderCamera.prototype, "changed", {
42958 return this._frameId === this._changedForFrame;
42963 Object.defineProperty(RenderCamera.prototype, "frameId", {
42965 return this._frameId;
42970 Object.defineProperty(RenderCamera.prototype, "perspective", {
42972 return this._perspective;
42977 Object.defineProperty(RenderCamera.prototype, "renderMode", {
42979 return this._renderMode;
42984 Object.defineProperty(RenderCamera.prototype, "rotation", {
42986 return this._rotation;
42991 Object.defineProperty(RenderCamera.prototype, "zoom", {
42998 RenderCamera.prototype.setFrame = function (frame) {
42999 var state = frame.state;
43000 if (state.state !== this._state) {
43001 this._state = state.state;
43002 this._changed = true;
43004 var currentNodeId = state.currentNode.key;
43005 var previousNodeId = !!state.previousNode ? state.previousNode.key : null;
43006 if (currentNodeId !== this._currentNodeId) {
43007 this._currentNodeId = currentNodeId;
43008 this._currentPano = !!state.currentTransform.gpano;
43009 this._currentProjectedPoints = this._computeProjectedPoints(state.currentTransform);
43010 this._changed = true;
43012 if (previousNodeId !== this._previousNodeId) {
43013 this._previousNodeId = previousNodeId;
43014 this._previousPano = !!state.previousTransform.gpano;
43015 this._previousProjectedPoints = this._computeProjectedPoints(state.previousTransform);
43016 this._changed = true;
43018 var zoom = state.zoom;
43019 if (zoom !== this._zoom) {
43021 this._changed = true;
43023 if (this._changed) {
43024 this._currentFov = this._computeCurrentFov();
43025 this._previousFov = this._computePreviousFov();
43027 var alpha = state.alpha;
43028 if (this._changed || alpha !== this._alpha) {
43029 this._alpha = alpha;
43030 this._perspective.fov = this._state === State_1.State.Earth ?
43032 this._interpolateFov(this._currentFov, this._previousFov, this._alpha);
43033 this._changed = true;
43035 var camera = state.camera;
43036 if (this._camera.diff(camera) > 1e-9) {
43037 this._camera.copy(camera);
43038 this._rotation = this._computeRotation(camera);
43039 this._perspective.up.copy(camera.up);
43040 this._perspective.position.copy(camera.position);
43041 this._perspective.lookAt(camera.lookat);
43042 this._perspective.updateMatrix();
43043 this._perspective.updateMatrixWorld(false);
43044 this._changed = true;
43046 if (this._changed) {
43047 this._perspective.updateProjectionMatrix();
43049 this._setFrameId(frame.id);
43051 RenderCamera.prototype.setRenderMode = function (renderMode) {
43052 this._renderMode = renderMode;
43053 this._perspective.fov = this._computeFov();
43054 this._perspective.updateProjectionMatrix();
43055 this._changed = true;
43057 RenderCamera.prototype.setSize = function (size) {
43058 this._perspective.aspect = this._computeAspect(size.width, size.height);
43059 this._perspective.fov = this._computeFov();
43060 this._perspective.updateProjectionMatrix();
43061 this._changed = true;
43063 RenderCamera.prototype._computeAspect = function (elementWidth, elementHeight) {
43064 return elementWidth === 0 ? 0 : elementWidth / elementHeight;
43066 RenderCamera.prototype._computeCurrentFov = function () {
43067 if (!this._currentNodeId) {
43068 return this._initialFov;
43070 return this._currentPano ?
43071 this._yToFov(1, this._zoom) :
43072 this._computeVerticalFov(this._currentProjectedPoints, this._renderMode, this._zoom, this.perspective.aspect);
43074 RenderCamera.prototype._computeFov = function () {
43075 this._currentFov = this._computeCurrentFov();
43076 this._previousFov = this._computePreviousFov();
43077 return this._interpolateFov(this._currentFov, this._previousFov, this._alpha);
43079 RenderCamera.prototype._computePreviousFov = function () {
43080 if (!this._currentNodeId) {
43081 return this._initialFov;
43083 return !this._previousNodeId ?
43085 this._previousPano ?
43086 this._yToFov(1, this._zoom) :
43087 this._computeVerticalFov(this._previousProjectedPoints, this._renderMode, this._zoom, this.perspective.aspect);
43089 RenderCamera.prototype._computeProjectedPoints = function (transform) {
43091 var os = [[0.5, 0], [1, 0]];
43092 var ds = [[0.5, 0], [0, 0.5]];
43093 var pointsPerSide = 100;
43094 var basicPoints = [];
43095 for (var side = 0; side < os.length; ++side) {
43098 for (var i = 0; i <= pointsPerSide; ++i) {
43099 basicPoints.push([o[0] + d[0] * i / pointsPerSide,
43100 o[1] + d[1] * i / pointsPerSide]);
43103 var camera = new THREE.Camera();
43104 camera.up.copy(transform.upVector());
43105 camera.position.copy(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0)));
43106 camera.lookAt(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10)));
43107 camera.updateMatrix();
43108 camera.updateMatrixWorld(true);
43109 var projectedPoints = basicPoints
43110 .map(function (basicPoint) {
43111 var worldPoint = transform.unprojectBasic(basicPoint, 10000);
43112 var cameraPoint = _this._viewportCoords.worldToCamera(worldPoint, camera);
43114 Math.abs(cameraPoint[0] / cameraPoint[2]),
43115 Math.abs(cameraPoint[1] / cameraPoint[2]),
43118 return projectedPoints;
43120 RenderCamera.prototype._computeRequiredVerticalFov = function (projectedPoint, zoom, aspect) {
43121 var maxY = Math.max(projectedPoint[0] / aspect, projectedPoint[1]);
43122 return this._yToFov(maxY, zoom);
43124 RenderCamera.prototype._computeRotation = function (camera) {
43125 var direction = camera.lookat.clone().sub(camera.position);
43126 var up = camera.up.clone();
43127 var upProjection = direction.clone().dot(up);
43128 var planeProjection = direction.clone().sub(up.clone().multiplyScalar(upProjection));
43129 var phi = Math.atan2(planeProjection.y, planeProjection.x);
43130 var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
43131 return { phi: phi, theta: theta };
43133 RenderCamera.prototype._computeVerticalFov = function (projectedPoints, renderMode, zoom, aspect) {
43135 var fovs = projectedPoints
43136 .map(function (projectedPoint) {
43137 return _this._computeRequiredVerticalFov(projectedPoint, zoom, aspect);
43139 var fov = renderMode === Render_1.RenderMode.Fill ?
43140 Math.min.apply(Math, fovs) * 0.995 : Math.max.apply(Math, fovs);
43143 RenderCamera.prototype._yToFov = function (y, zoom) {
43144 return 2 * Math.atan(y / Math.pow(2, zoom)) * 180 / Math.PI;
43146 RenderCamera.prototype._interpolateFov = function (v1, v2, alpha) {
43147 return alpha * v1 + (1 - alpha) * v2;
43149 RenderCamera.prototype._setFrameId = function (frameId) {
43150 this._frameId = frameId;
43151 if (this._changed) {
43152 this._changed = false;
43153 this._changedForFrame = frameId;
43156 return RenderCamera;
43158 exports.RenderCamera = RenderCamera;
43159 exports.default = RenderCamera;
43161 },{"../Geo":278,"../Render":281,"../State":282,"three":226}],408:[function(require,module,exports){
43163 Object.defineProperty(exports, "__esModule", { value: true });
43165 * Enumeration for render mode
43168 * @description Modes for specifying how rendering is done
43169 * in the viewer. All modes preserves the original aspect
43170 * ratio of the images.
43173 (function (RenderMode) {
43175 * Displays all content within the viewer.
43177 * @description Black bars shown on both
43178 * sides of the content. Bars are shown
43179 * either below and above or to the left
43180 * and right of the content depending on
43181 * the aspect ratio relation between the
43182 * image and the viewer.
43184 RenderMode[RenderMode["Letterbox"] = 0] = "Letterbox";
43186 * Fills the viewer by cropping content.
43188 * @description Cropping is done either
43189 * in horizontal or vertical direction
43190 * depending on the aspect ratio relation
43191 * between the image and the viewer.
43193 RenderMode[RenderMode["Fill"] = 1] = "Fill";
43194 })(RenderMode = exports.RenderMode || (exports.RenderMode = {}));
43195 exports.default = RenderMode;
43197 },{}],409:[function(require,module,exports){
43199 Object.defineProperty(exports, "__esModule", { value: true });
43200 var operators_1 = require("rxjs/operators");
43201 var rxjs_1 = require("rxjs");
43202 var Geo_1 = require("../Geo");
43203 var Render_1 = require("../Render");
43204 var RenderService = /** @class */ (function () {
43205 function RenderService(element, currentFrame$, renderMode, renderCamera) {
43207 this._element = element;
43208 this._currentFrame$ = currentFrame$;
43209 this._spatial = new Geo_1.Spatial();
43210 renderMode = renderMode != null ? renderMode : Render_1.RenderMode.Fill;
43211 this._resize$ = new rxjs_1.Subject();
43212 this._renderCameraOperation$ = new rxjs_1.Subject();
43214 new rxjs_1.BehaviorSubject({
43215 height: this._element.offsetHeight,
43216 width: this._element.offsetWidth,
43218 this._resize$.pipe(operators_1.map(function () {
43219 return { height: _this._element.offsetHeight, width: _this._element.offsetWidth };
43221 .subscribe(this._size$);
43222 this._renderMode$ = new rxjs_1.BehaviorSubject(renderMode);
43223 this._renderCameraHolder$ = this._renderCameraOperation$.pipe(operators_1.startWith(function (rc) {
43225 }), operators_1.scan(function (rc, operation) {
43226 return operation(rc);
43227 }, !!renderCamera ? renderCamera : new Render_1.RenderCamera(this._element.offsetWidth, this._element.offsetHeight, renderMode)), operators_1.publishReplay(1), operators_1.refCount());
43228 this._renderCameraFrame$ = this._currentFrame$.pipe(operators_1.withLatestFrom(this._renderCameraHolder$), operators_1.tap(function (_a) {
43229 var frame = _a[0], rc = _a[1];
43230 rc.setFrame(frame);
43231 }), operators_1.map(function (args) {
43233 }), operators_1.publishReplay(1), operators_1.refCount());
43234 this._renderCamera$ = this._renderCameraFrame$.pipe(operators_1.filter(function (rc) {
43236 }), operators_1.publishReplay(1), operators_1.refCount());
43237 this._bearing$ = this._renderCamera$.pipe(operators_1.map(function (rc) {
43238 var bearing = _this._spatial.radToDeg(_this._spatial.azimuthalToBearing(rc.rotation.phi));
43239 return _this._spatial.wrap(bearing, 0, 360);
43240 }), operators_1.publishReplay(1), operators_1.refCount());
43241 this._size$.pipe(operators_1.skip(1), operators_1.map(function (size) {
43242 return function (rc) {
43247 .subscribe(this._renderCameraOperation$);
43248 this._renderMode$.pipe(operators_1.skip(1), operators_1.map(function (rm) {
43249 return function (rc) {
43250 rc.setRenderMode(rm);
43254 .subscribe(this._renderCameraOperation$);
43255 this._bearing$.subscribe(function () { });
43256 this._renderCameraHolder$.subscribe(function () { });
43257 this._size$.subscribe(function () { });
43258 this._renderMode$.subscribe(function () { });
43259 this._renderCamera$.subscribe(function () { });
43260 this._renderCameraFrame$.subscribe(function () { });
43262 Object.defineProperty(RenderService.prototype, "bearing$", {
43264 return this._bearing$;
43269 Object.defineProperty(RenderService.prototype, "element", {
43271 return this._element;
43276 Object.defineProperty(RenderService.prototype, "resize$", {
43278 return this._resize$;
43283 Object.defineProperty(RenderService.prototype, "size$", {
43285 return this._size$;
43290 Object.defineProperty(RenderService.prototype, "renderMode$", {
43292 return this._renderMode$;
43297 Object.defineProperty(RenderService.prototype, "renderCameraFrame$", {
43299 return this._renderCameraFrame$;
43304 Object.defineProperty(RenderService.prototype, "renderCamera$", {
43306 return this._renderCamera$;
43311 return RenderService;
43313 exports.RenderService = RenderService;
43314 exports.default = RenderService;
43317 },{"../Geo":278,"../Render":281,"rxjs":27,"rxjs/operators":225}],410:[function(require,module,exports){
43319 Object.defineProperty(exports, "__esModule", { value: true });
43320 var FrameGenerator = /** @class */ (function () {
43321 function FrameGenerator(root) {
43322 if (root.requestAnimationFrame) {
43323 this._cancelAnimationFrame = root.cancelAnimationFrame.bind(root);
43324 this._requestAnimationFrame = root.requestAnimationFrame.bind(root);
43326 else if (root.mozRequestAnimationFrame) {
43327 this._cancelAnimationFrame = root.mozCancelAnimationFrame.bind(root);
43328 this._requestAnimationFrame = root.mozRequestAnimationFrame.bind(root);
43330 else if (root.webkitRequestAnimationFrame) {
43331 this._cancelAnimationFrame = root.webkitCancelAnimationFrame.bind(root);
43332 this._requestAnimationFrame = root.webkitRequestAnimationFrame.bind(root);
43334 else if (root.msRequestAnimationFrame) {
43335 this._cancelAnimationFrame = root.msCancelAnimationFrame.bind(root);
43336 this._requestAnimationFrame = root.msRequestAnimationFrame.bind(root);
43338 else if (root.oRequestAnimationFrame) {
43339 this._cancelAnimationFrame = root.oCancelAnimationFrame.bind(root);
43340 this._requestAnimationFrame = root.oRequestAnimationFrame.bind(root);
43343 this._cancelAnimationFrame = root.clearTimeout.bind(root);
43344 this._requestAnimationFrame = function (cb) { return root.setTimeout(cb, 1000 / 60); };
43347 Object.defineProperty(FrameGenerator.prototype, "cancelAnimationFrame", {
43349 return this._cancelAnimationFrame;
43354 Object.defineProperty(FrameGenerator.prototype, "requestAnimationFrame", {
43356 return this._requestAnimationFrame;
43361 return FrameGenerator;
43363 exports.FrameGenerator = FrameGenerator;
43364 exports.default = FrameGenerator;
43366 },{}],411:[function(require,module,exports){
43368 Object.defineProperty(exports, "__esModule", { value: true });
43369 var RotationDelta = /** @class */ (function () {
43370 function RotationDelta(phi, theta) {
43372 this._theta = theta;
43374 Object.defineProperty(RotationDelta.prototype, "phi", {
43378 set: function (value) {
43384 Object.defineProperty(RotationDelta.prototype, "theta", {
43386 return this._theta;
43388 set: function (value) {
43389 this._theta = value;
43394 Object.defineProperty(RotationDelta.prototype, "isZero", {
43396 return this._phi === 0 && this._theta === 0;
43401 RotationDelta.prototype.copy = function (delta) {
43402 this._phi = delta.phi;
43403 this._theta = delta.theta;
43405 RotationDelta.prototype.lerp = function (other, alpha) {
43406 this._phi = (1 - alpha) * this._phi + alpha * other.phi;
43407 this._theta = (1 - alpha) * this._theta + alpha * other.theta;
43409 RotationDelta.prototype.multiply = function (value) {
43410 this._phi *= value;
43411 this._theta *= value;
43413 RotationDelta.prototype.threshold = function (value) {
43414 this._phi = Math.abs(this._phi) > value ? this._phi : 0;
43415 this._theta = Math.abs(this._theta) > value ? this._theta : 0;
43417 RotationDelta.prototype.lengthSquared = function () {
43418 return this._phi * this._phi + this._theta * this._theta;
43420 RotationDelta.prototype.reset = function () {
43424 return RotationDelta;
43426 exports.RotationDelta = RotationDelta;
43427 exports.default = RotationDelta;
43429 },{}],412:[function(require,module,exports){
43431 Object.defineProperty(exports, "__esModule", { value: true });
43433 (function (State) {
43434 State[State["Earth"] = 0] = "Earth";
43435 State[State["Traversing"] = 1] = "Traversing";
43436 State[State["Waiting"] = 2] = "Waiting";
43437 State[State["WaitingInteractively"] = 3] = "WaitingInteractively";
43438 })(State = exports.State || (exports.State = {}));
43439 exports.default = State;
43441 },{}],413:[function(require,module,exports){
43443 Object.defineProperty(exports, "__esModule", { value: true });
43444 var State_1 = require("../State");
43445 var Geo_1 = require("../Geo");
43446 var StateContext = /** @class */ (function () {
43447 function StateContext(transitionMode) {
43448 this._state = new State_1.TraversingState({
43450 camera: new Geo_1.Camera(),
43452 reference: { alt: 0, lat: 0, lon: 0 },
43454 transitionMode: transitionMode == null ? State_1.TransitionMode.Default : transitionMode,
43458 StateContext.prototype.earth = function () {
43459 this._state = this._state.earth();
43461 StateContext.prototype.traverse = function () {
43462 this._state = this._state.traverse();
43464 StateContext.prototype.wait = function () {
43465 this._state = this._state.wait();
43467 StateContext.prototype.waitInteractively = function () {
43468 this._state = this._state.waitInteractively();
43470 Object.defineProperty(StateContext.prototype, "state", {
43472 if (this._state instanceof State_1.EarthState) {
43473 return State_1.State.Earth;
43475 else if (this._state instanceof State_1.TraversingState) {
43476 return State_1.State.Traversing;
43478 else if (this._state instanceof State_1.WaitingState) {
43479 return State_1.State.Waiting;
43481 else if (this._state instanceof State_1.InteractiveWaitingState) {
43482 return State_1.State.WaitingInteractively;
43484 throw new Error("Invalid state");
43489 Object.defineProperty(StateContext.prototype, "reference", {
43491 return this._state.reference;
43496 Object.defineProperty(StateContext.prototype, "alpha", {
43498 return this._state.alpha;
43503 Object.defineProperty(StateContext.prototype, "camera", {
43505 return this._state.camera;
43510 Object.defineProperty(StateContext.prototype, "zoom", {
43512 return this._state.zoom;
43517 Object.defineProperty(StateContext.prototype, "currentNode", {
43519 return this._state.currentNode;
43524 Object.defineProperty(StateContext.prototype, "previousNode", {
43526 return this._state.previousNode;
43531 Object.defineProperty(StateContext.prototype, "currentCamera", {
43533 return this._state.currentCamera;
43538 Object.defineProperty(StateContext.prototype, "currentTransform", {
43540 return this._state.currentTransform;
43545 Object.defineProperty(StateContext.prototype, "previousTransform", {
43547 return this._state.previousTransform;
43552 Object.defineProperty(StateContext.prototype, "trajectory", {
43554 return this._state.trajectory;
43559 Object.defineProperty(StateContext.prototype, "currentIndex", {
43561 return this._state.currentIndex;
43566 Object.defineProperty(StateContext.prototype, "lastNode", {
43568 return this._state.trajectory[this._state.trajectory.length - 1];
43573 Object.defineProperty(StateContext.prototype, "nodesAhead", {
43575 return this._state.trajectory.length - 1 - this._state.currentIndex;
43580 Object.defineProperty(StateContext.prototype, "motionless", {
43582 return this._state.motionless;
43587 StateContext.prototype.getCenter = function () {
43588 return this._state.getCenter();
43590 StateContext.prototype.setCenter = function (center) {
43591 this._state.setCenter(center);
43593 StateContext.prototype.setZoom = function (zoom) {
43594 this._state.setZoom(zoom);
43596 StateContext.prototype.update = function (fps) {
43597 this._state.update(fps);
43599 StateContext.prototype.append = function (nodes) {
43600 this._state.append(nodes);
43602 StateContext.prototype.prepend = function (nodes) {
43603 this._state.prepend(nodes);
43605 StateContext.prototype.remove = function (n) {
43606 this._state.remove(n);
43608 StateContext.prototype.clear = function () {
43609 this._state.clear();
43611 StateContext.prototype.clearPrior = function () {
43612 this._state.clearPrior();
43614 StateContext.prototype.cut = function () {
43617 StateContext.prototype.set = function (nodes) {
43618 this._state.set(nodes);
43620 StateContext.prototype.rotate = function (delta) {
43621 this._state.rotate(delta);
43623 StateContext.prototype.rotateUnbounded = function (delta) {
43624 this._state.rotateUnbounded(delta);
43626 StateContext.prototype.rotateWithoutInertia = function (delta) {
43627 this._state.rotateWithoutInertia(delta);
43629 StateContext.prototype.rotateBasic = function (basicRotation) {
43630 this._state.rotateBasic(basicRotation);
43632 StateContext.prototype.rotateBasicUnbounded = function (basicRotation) {
43633 this._state.rotateBasicUnbounded(basicRotation);
43635 StateContext.prototype.rotateBasicWithoutInertia = function (basicRotation) {
43636 this._state.rotateBasicWithoutInertia(basicRotation);
43638 StateContext.prototype.rotateToBasic = function (basic) {
43639 this._state.rotateToBasic(basic);
43641 StateContext.prototype.move = function (delta) {
43642 this._state.move(delta);
43644 StateContext.prototype.moveTo = function (delta) {
43645 this._state.moveTo(delta);
43647 StateContext.prototype.zoomIn = function (delta, reference) {
43648 this._state.zoomIn(delta, reference);
43650 StateContext.prototype.setSpeed = function (speed) {
43651 this._state.setSpeed(speed);
43653 StateContext.prototype.setTransitionMode = function (mode) {
43654 this._state.setTransitionMode(mode);
43656 StateContext.prototype.dolly = function (delta) {
43657 this._state.dolly(delta);
43659 StateContext.prototype.orbit = function (rotation) {
43660 this._state.orbit(rotation);
43662 StateContext.prototype.truck = function (direction) {
43663 this._state.truck(direction);
43665 return StateContext;
43667 exports.StateContext = StateContext;
43669 },{"../Geo":278,"../State":282}],414:[function(require,module,exports){
43671 Object.defineProperty(exports, "__esModule", { value: true });
43672 var rxjs_1 = require("rxjs");
43673 var operators_1 = require("rxjs/operators");
43674 var State_1 = require("../State");
43675 var StateService = /** @class */ (function () {
43676 function StateService(transitionMode) {
43678 this._appendNode$ = new rxjs_1.Subject();
43679 this._start$ = new rxjs_1.Subject();
43680 this._frame$ = new rxjs_1.Subject();
43681 this._fpsSampleRate = 30;
43682 this._contextOperation$ = new rxjs_1.BehaviorSubject(function (context) {
43685 this._context$ = this._contextOperation$.pipe(operators_1.scan(function (context, operation) {
43686 return operation(context);
43687 }, new State_1.StateContext(transitionMode)), operators_1.publishReplay(1), operators_1.refCount());
43688 this._state$ = this._context$.pipe(operators_1.map(function (context) {
43689 return context.state;
43690 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
43691 this._fps$ = this._start$.pipe(operators_1.switchMap(function () {
43692 return _this._frame$.pipe(operators_1.bufferCount(1, _this._fpsSampleRate), operators_1.map(function (frameIds) {
43693 return new Date().getTime();
43694 }), operators_1.pairwise(), operators_1.map(function (times) {
43695 return Math.max(20, 1000 * _this._fpsSampleRate / (times[1] - times[0]));
43696 }), operators_1.startWith(60));
43697 }), operators_1.share());
43698 this._currentState$ = this._frame$.pipe(operators_1.withLatestFrom(this._fps$, this._context$, function (frameId, fps, context) {
43699 return [frameId, fps, context];
43700 }), operators_1.filter(function (fc) {
43701 return fc[2].currentNode != null;
43702 }), operators_1.tap(function (fc) {
43703 fc[2].update(fc[1]);
43704 }), operators_1.map(function (fc) {
43705 return { fps: fc[1], id: fc[0], state: fc[2] };
43706 }), operators_1.share());
43707 this._lastState$ = this._currentState$.pipe(operators_1.publishReplay(1), operators_1.refCount());
43708 var nodeChanged$ = this._currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (f) {
43709 return f.state.currentNode.key;
43710 }), operators_1.publishReplay(1), operators_1.refCount());
43711 var nodeChangedSubject$ = new rxjs_1.Subject();
43713 .subscribe(nodeChangedSubject$);
43714 this._currentKey$ = new rxjs_1.BehaviorSubject(null);
43715 nodeChangedSubject$.pipe(operators_1.map(function (f) {
43716 return f.state.currentNode.key;
43718 .subscribe(this._currentKey$);
43719 this._currentNode$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
43720 return f.state.currentNode;
43721 }), operators_1.publishReplay(1), operators_1.refCount());
43722 this._currentCamera$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
43723 return f.state.currentCamera;
43724 }), operators_1.publishReplay(1), operators_1.refCount());
43725 this._currentTransform$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
43726 return f.state.currentTransform;
43727 }), operators_1.publishReplay(1), operators_1.refCount());
43728 this._reference$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
43729 return f.state.reference;
43730 }), operators_1.distinctUntilChanged(function (r1, r2) {
43731 return r1.lat === r2.lat && r1.lon === r2.lon;
43732 }, function (reference) {
43733 return { lat: reference.lat, lon: reference.lon };
43734 }), operators_1.publishReplay(1), operators_1.refCount());
43735 this._currentNodeExternal$ = nodeChanged$.pipe(operators_1.map(function (f) {
43736 return f.state.currentNode;
43737 }), operators_1.publishReplay(1), operators_1.refCount());
43738 this._appendNode$.pipe(operators_1.map(function (node) {
43739 return function (context) {
43740 context.append([node]);
43744 .subscribe(this._contextOperation$);
43745 this._inMotionOperation$ = new rxjs_1.Subject();
43746 nodeChanged$.pipe(operators_1.map(function (frame) {
43749 .subscribe(this._inMotionOperation$);
43750 this._inMotionOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.filter(function (moving) {
43752 }), operators_1.switchMap(function (moving) {
43753 return _this._currentState$.pipe(operators_1.filter(function (frame) {
43754 return frame.state.nodesAhead === 0;
43755 }), operators_1.map(function (frame) {
43756 return [frame.state.camera.clone(), frame.state.zoom];
43757 }), operators_1.pairwise(), operators_1.map(function (pair) {
43758 var c1 = pair[0][0];
43759 var c2 = pair[1][0];
43760 var z1 = pair[0][1];
43761 var z2 = pair[1][1];
43762 return c1.diff(c2) > 1e-5 || Math.abs(z1 - z2) > 1e-5;
43763 }), operators_1.first(function (changed) {
43767 .subscribe(this._inMotionOperation$);
43768 this._inMotion$ = this._inMotionOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
43769 this._inTranslationOperation$ = new rxjs_1.Subject();
43770 nodeChanged$.pipe(operators_1.map(function (frame) {
43773 .subscribe(this._inTranslationOperation$);
43774 this._inTranslationOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.filter(function (inTranslation) {
43775 return inTranslation;
43776 }), operators_1.switchMap(function (inTranslation) {
43777 return _this._currentState$.pipe(operators_1.filter(function (frame) {
43778 return frame.state.nodesAhead === 0;
43779 }), operators_1.map(function (frame) {
43780 return frame.state.camera.position.clone();
43781 }), operators_1.pairwise(), operators_1.map(function (pair) {
43782 return pair[0].distanceToSquared(pair[1]) !== 0;
43783 }), operators_1.first(function (changed) {
43787 .subscribe(this._inTranslationOperation$);
43788 this._inTranslation$ = this._inTranslationOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
43789 this._state$.subscribe(function () { });
43790 this._currentNode$.subscribe(function () { });
43791 this._currentCamera$.subscribe(function () { });
43792 this._currentTransform$.subscribe(function () { });
43793 this._reference$.subscribe(function () { });
43794 this._currentNodeExternal$.subscribe(function () { });
43795 this._lastState$.subscribe(function () { });
43796 this._inMotion$.subscribe(function () { });
43797 this._inTranslation$.subscribe(function () { });
43798 this._frameId = null;
43799 this._frameGenerator = new State_1.FrameGenerator(window);
43801 Object.defineProperty(StateService.prototype, "currentState$", {
43803 return this._currentState$;
43808 Object.defineProperty(StateService.prototype, "currentNode$", {
43810 return this._currentNode$;
43815 Object.defineProperty(StateService.prototype, "currentKey$", {
43817 return this._currentKey$;
43822 Object.defineProperty(StateService.prototype, "currentNodeExternal$", {
43824 return this._currentNodeExternal$;
43829 Object.defineProperty(StateService.prototype, "currentCamera$", {
43831 return this._currentCamera$;
43836 Object.defineProperty(StateService.prototype, "currentTransform$", {
43838 return this._currentTransform$;
43843 Object.defineProperty(StateService.prototype, "state$", {
43845 return this._state$;
43850 Object.defineProperty(StateService.prototype, "reference$", {
43852 return this._reference$;
43857 Object.defineProperty(StateService.prototype, "inMotion$", {
43859 return this._inMotion$;
43864 Object.defineProperty(StateService.prototype, "inTranslation$", {
43866 return this._inTranslation$;
43871 Object.defineProperty(StateService.prototype, "appendNode$", {
43873 return this._appendNode$;
43878 StateService.prototype.earth = function () {
43879 this._inMotionOperation$.next(true);
43880 this._invokeContextOperation(function (context) { context.earth(); });
43882 StateService.prototype.traverse = function () {
43883 this._inMotionOperation$.next(true);
43884 this._invokeContextOperation(function (context) { context.traverse(); });
43886 StateService.prototype.wait = function () {
43887 this._invokeContextOperation(function (context) { context.wait(); });
43889 StateService.prototype.waitInteractively = function () {
43890 this._invokeContextOperation(function (context) { context.waitInteractively(); });
43892 StateService.prototype.appendNodes = function (nodes) {
43893 this._invokeContextOperation(function (context) { context.append(nodes); });
43895 StateService.prototype.prependNodes = function (nodes) {
43896 this._invokeContextOperation(function (context) { context.prepend(nodes); });
43898 StateService.prototype.removeNodes = function (n) {
43899 this._invokeContextOperation(function (context) { context.remove(n); });
43901 StateService.prototype.clearNodes = function () {
43902 this._invokeContextOperation(function (context) { context.clear(); });
43904 StateService.prototype.clearPriorNodes = function () {
43905 this._invokeContextOperation(function (context) { context.clearPrior(); });
43907 StateService.prototype.cutNodes = function () {
43908 this._invokeContextOperation(function (context) { context.cut(); });
43910 StateService.prototype.setNodes = function (nodes) {
43911 this._invokeContextOperation(function (context) { context.set(nodes); });
43913 StateService.prototype.rotate = function (delta) {
43914 this._inMotionOperation$.next(true);
43915 this._invokeContextOperation(function (context) { context.rotate(delta); });
43917 StateService.prototype.rotateUnbounded = function (delta) {
43918 this._inMotionOperation$.next(true);
43919 this._invokeContextOperation(function (context) { context.rotateUnbounded(delta); });
43921 StateService.prototype.rotateWithoutInertia = function (delta) {
43922 this._inMotionOperation$.next(true);
43923 this._invokeContextOperation(function (context) { context.rotateWithoutInertia(delta); });
43925 StateService.prototype.rotateBasic = function (basicRotation) {
43926 this._inMotionOperation$.next(true);
43927 this._invokeContextOperation(function (context) { context.rotateBasic(basicRotation); });
43929 StateService.prototype.rotateBasicUnbounded = function (basicRotation) {
43930 this._inMotionOperation$.next(true);
43931 this._invokeContextOperation(function (context) { context.rotateBasicUnbounded(basicRotation); });
43933 StateService.prototype.rotateBasicWithoutInertia = function (basicRotation) {
43934 this._inMotionOperation$.next(true);
43935 this._invokeContextOperation(function (context) { context.rotateBasicWithoutInertia(basicRotation); });
43937 StateService.prototype.rotateToBasic = function (basic) {
43938 this._inMotionOperation$.next(true);
43939 this._invokeContextOperation(function (context) { context.rotateToBasic(basic); });
43941 StateService.prototype.move = function (delta) {
43942 this._inMotionOperation$.next(true);
43943 this._invokeContextOperation(function (context) { context.move(delta); });
43945 StateService.prototype.moveTo = function (position) {
43946 this._inMotionOperation$.next(true);
43947 this._invokeContextOperation(function (context) { context.moveTo(position); });
43949 StateService.prototype.dolly = function (delta) {
43950 this._inMotionOperation$.next(true);
43951 this._invokeContextOperation(function (context) { context.dolly(delta); });
43953 StateService.prototype.orbit = function (rotation) {
43954 this._inMotionOperation$.next(true);
43955 this._invokeContextOperation(function (context) { context.orbit(rotation); });
43957 StateService.prototype.truck = function (direction) {
43958 this._inMotionOperation$.next(true);
43959 this._invokeContextOperation(function (context) { context.truck(direction); });
43962 * Change zoom level while keeping the reference point position approximately static.
43964 * @parameter {number} delta - Change in zoom level.
43965 * @parameter {Array<number>} reference - Reference point in basic coordinates.
43967 StateService.prototype.zoomIn = function (delta, reference) {
43968 this._inMotionOperation$.next(true);
43969 this._invokeContextOperation(function (context) { context.zoomIn(delta, reference); });
43971 StateService.prototype.getCenter = function () {
43972 return this._lastState$.pipe(operators_1.first(), operators_1.map(function (frame) {
43973 return frame.state.getCenter();
43976 StateService.prototype.getZoom = function () {
43977 return this._lastState$.pipe(operators_1.first(), operators_1.map(function (frame) {
43978 return frame.state.zoom;
43981 StateService.prototype.setCenter = function (center) {
43982 this._inMotionOperation$.next(true);
43983 this._invokeContextOperation(function (context) { context.setCenter(center); });
43985 StateService.prototype.setSpeed = function (speed) {
43986 this._invokeContextOperation(function (context) { context.setSpeed(speed); });
43988 StateService.prototype.setTransitionMode = function (mode) {
43989 this._invokeContextOperation(function (context) { context.setTransitionMode(mode); });
43991 StateService.prototype.setZoom = function (zoom) {
43992 this._inMotionOperation$.next(true);
43993 this._invokeContextOperation(function (context) { context.setZoom(zoom); });
43995 StateService.prototype.start = function () {
43996 if (this._frameId == null) {
43997 this._start$.next(null);
43998 this._frameId = this._frameGenerator.requestAnimationFrame(this._frame.bind(this));
43999 this._frame$.next(this._frameId);
44002 StateService.prototype.stop = function () {
44003 if (this._frameId != null) {
44004 this._frameGenerator.cancelAnimationFrame(this._frameId);
44005 this._frameId = null;
44008 StateService.prototype._invokeContextOperation = function (action) {
44009 this._contextOperation$
44010 .next(function (context) {
44015 StateService.prototype._frame = function (time) {
44016 this._frameId = this._frameGenerator.requestAnimationFrame(this._frame.bind(this));
44017 this._frame$.next(this._frameId);
44019 return StateService;
44021 exports.StateService = StateService;
44023 },{"../State":282,"rxjs":27,"rxjs/operators":225}],415:[function(require,module,exports){
44025 Object.defineProperty(exports, "__esModule", { value: true });
44027 * Enumeration for transition mode
44030 * @description Modes for specifying how transitions
44031 * between nodes are performed.
44033 var TransitionMode;
44034 (function (TransitionMode) {
44036 * Default transitions.
44038 * @description The viewer dynamically determines
44039 * whether transitions should be performed with or
44040 * without motion and blending for each transition
44041 * based on the underlying data.
44043 TransitionMode[TransitionMode["Default"] = 0] = "Default";
44045 * Instantaneous transitions.
44047 * @description All transitions are performed
44048 * without motion or blending.
44050 TransitionMode[TransitionMode["Instantaneous"] = 1] = "Instantaneous";
44051 })(TransitionMode = exports.TransitionMode || (exports.TransitionMode = {}));
44052 exports.default = TransitionMode;
44054 },{}],416:[function(require,module,exports){
44056 var __extends = (this && this.__extends) || (function () {
44057 var extendStatics = function (d, b) {
44058 extendStatics = Object.setPrototypeOf ||
44059 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
44060 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
44061 return extendStatics(d, b);
44063 return function (d, b) {
44064 extendStatics(d, b);
44065 function __() { this.constructor = d; }
44066 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44069 Object.defineProperty(exports, "__esModule", { value: true });
44070 var THREE = require("three");
44071 var State_1 = require("../../State");
44072 var EarthState = /** @class */ (function (_super) {
44073 __extends(EarthState, _super);
44074 function EarthState(state) {
44075 var _this = _super.call(this, state) || this;
44076 var viewingDirection = _this._camera.lookat
44078 .sub(_this._camera.position)
44080 _this._camera.lookat.copy(_this._camera.position);
44081 _this._camera.position.z = state.camera.position.z + 20;
44082 _this._camera.position.x = state.camera.position.x - 16 * viewingDirection.x;
44083 _this._camera.position.y = state.camera.position.y - 16 * viewingDirection.y;
44084 _this._camera.up.set(0, 0, 1);
44087 EarthState.prototype.traverse = function () {
44088 return new State_1.TraversingState(this);
44090 EarthState.prototype.wait = function () {
44091 return new State_1.WaitingState(this);
44093 EarthState.prototype.waitInteractively = function () {
44094 return new State_1.InteractiveWaitingState(this);
44096 EarthState.prototype.dolly = function (delta) {
44097 var camera = this._camera;
44098 var offset = new THREE.Vector3()
44099 .copy(camera.position)
44100 .sub(camera.lookat);
44101 var length = offset.length();
44102 var scaled = length * Math.pow(2, -delta);
44103 var clipped = Math.max(1, Math.min(scaled, 1000));
44104 offset.normalize();
44105 offset.multiplyScalar(clipped);
44106 camera.position.copy(camera.lookat).add(offset);
44108 EarthState.prototype.orbit = function (rotation) {
44109 var camera = this._camera;
44110 var q = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
44111 var qInverse = q.clone().inverse();
44112 var offset = new THREE.Vector3();
44113 offset.copy(camera.position).sub(camera.lookat);
44114 offset.applyQuaternion(q);
44115 var length = offset.length();
44116 var phi = Math.atan2(offset.y, offset.x);
44117 phi += rotation.phi;
44118 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
44119 theta += rotation.theta;
44120 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
44121 offset.x = Math.sin(theta) * Math.cos(phi);
44122 offset.y = Math.sin(theta) * Math.sin(phi);
44123 offset.z = Math.cos(theta);
44124 offset.applyQuaternion(qInverse);
44125 camera.position.copy(camera.lookat).add(offset.multiplyScalar(length));
44127 EarthState.prototype.truck = function (direction) {
44128 this._camera.position.add(new THREE.Vector3().fromArray(direction));
44129 this._camera.lookat.add(new THREE.Vector3().fromArray(direction));
44131 EarthState.prototype.update = function () { };
44133 }(State_1.StateBase));
44134 exports.EarthState = EarthState;
44135 exports.default = EarthState;
44138 },{"../../State":282,"three":226}],417:[function(require,module,exports){
44140 var __extends = (this && this.__extends) || (function () {
44141 var extendStatics = function (d, b) {
44142 extendStatics = Object.setPrototypeOf ||
44143 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
44144 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
44145 return extendStatics(d, b);
44147 return function (d, b) {
44148 extendStatics(d, b);
44149 function __() { this.constructor = d; }
44150 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44153 Object.defineProperty(exports, "__esModule", { value: true });
44154 var THREE = require("three");
44155 var State_1 = require("../../State");
44156 var InteractiveStateBase = /** @class */ (function (_super) {
44157 __extends(InteractiveStateBase, _super);
44158 function InteractiveStateBase(state) {
44159 var _this = _super.call(this, state) || this;
44160 _this._animationSpeed = 1 / 40;
44161 _this._rotationDelta = new State_1.RotationDelta(0, 0);
44162 _this._requestedRotationDelta = null;
44163 _this._basicRotation = [0, 0];
44164 _this._requestedBasicRotation = null;
44165 _this._requestedBasicRotationUnbounded = null;
44166 _this._rotationAcceleration = 0.86;
44167 _this._rotationIncreaseAlpha = 0.97;
44168 _this._rotationDecreaseAlpha = 0.9;
44169 _this._rotationThreshold = 1e-3;
44170 _this._unboundedRotationAlpha = 0.8;
44171 _this._desiredZoom = state.zoom;
44172 _this._minZoom = 0;
44173 _this._maxZoom = 3;
44174 _this._lookatDepth = 10;
44175 _this._desiredLookat = null;
44176 _this._desiredCenter = null;
44179 InteractiveStateBase.prototype.rotate = function (rotationDelta) {
44180 if (this._currentNode == null) {
44183 this._desiredZoom = this._zoom;
44184 this._desiredLookat = null;
44185 this._requestedBasicRotation = null;
44186 if (this._requestedRotationDelta != null) {
44187 this._requestedRotationDelta.phi = this._requestedRotationDelta.phi + rotationDelta.phi;
44188 this._requestedRotationDelta.theta = this._requestedRotationDelta.theta + rotationDelta.theta;
44191 this._requestedRotationDelta = new State_1.RotationDelta(rotationDelta.phi, rotationDelta.theta);
44194 InteractiveStateBase.prototype.rotateUnbounded = function (delta) {
44195 if (this._currentNode == null) {
44198 this._requestedBasicRotation = null;
44199 this._requestedRotationDelta = null;
44200 this._applyRotation(delta, this._currentCamera);
44201 this._applyRotation(delta, this._previousCamera);
44202 if (!this._desiredLookat) {
44205 var q = new THREE.Quaternion().setFromUnitVectors(this._currentCamera.up, new THREE.Vector3(0, 0, 1));
44206 var qInverse = q.clone().inverse();
44207 var offset = new THREE.Vector3()
44208 .copy(this._desiredLookat)
44209 .sub(this._camera.position)
44210 .applyQuaternion(q);
44211 var length = offset.length();
44212 var phi = Math.atan2(offset.y, offset.x);
44214 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
44215 theta += delta.theta;
44216 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
44217 offset.x = Math.sin(theta) * Math.cos(phi);
44218 offset.y = Math.sin(theta) * Math.sin(phi);
44219 offset.z = Math.cos(theta);
44220 offset.applyQuaternion(qInverse);
44221 this._desiredLookat
44222 .copy(this._camera.position)
44223 .add(offset.multiplyScalar(length));
44225 InteractiveStateBase.prototype.rotateWithoutInertia = function (rotationDelta) {
44226 if (this._currentNode == null) {
44229 this._desiredZoom = this._zoom;
44230 this._desiredLookat = null;
44231 this._requestedBasicRotation = null;
44232 this._requestedRotationDelta = null;
44233 var threshold = Math.PI / (10 * Math.pow(2, this._zoom));
44235 phi: this._spatial.clamp(rotationDelta.phi, -threshold, threshold),
44236 theta: this._spatial.clamp(rotationDelta.theta, -threshold, threshold),
44238 this._applyRotation(delta, this._currentCamera);
44239 this._applyRotation(delta, this._previousCamera);
44241 InteractiveStateBase.prototype.rotateBasic = function (basicRotation) {
44242 if (this._currentNode == null) {
44245 this._desiredZoom = this._zoom;
44246 this._desiredLookat = null;
44247 this._requestedRotationDelta = null;
44248 if (this._requestedBasicRotation != null) {
44249 this._requestedBasicRotation[0] += basicRotation[0];
44250 this._requestedBasicRotation[1] += basicRotation[1];
44251 var threshold = 0.05 / Math.pow(2, this._zoom);
44252 this._requestedBasicRotation[0] =
44253 this._spatial.clamp(this._requestedBasicRotation[0], -threshold, threshold);
44254 this._requestedBasicRotation[1] =
44255 this._spatial.clamp(this._requestedBasicRotation[1], -threshold, threshold);
44258 this._requestedBasicRotation = basicRotation.slice();
44261 InteractiveStateBase.prototype.rotateBasicUnbounded = function (basicRotation) {
44262 if (this._currentNode == null) {
44265 if (this._requestedBasicRotationUnbounded != null) {
44266 this._requestedBasicRotationUnbounded[0] += basicRotation[0];
44267 this._requestedBasicRotationUnbounded[1] += basicRotation[1];
44270 this._requestedBasicRotationUnbounded = basicRotation.slice();
44273 InteractiveStateBase.prototype.rotateBasicWithoutInertia = function (basic) {
44274 if (this._currentNode == null) {
44277 this._desiredZoom = this._zoom;
44278 this._desiredLookat = null;
44279 this._requestedRotationDelta = null;
44280 this._requestedBasicRotation = null;
44281 var threshold = 0.05 / Math.pow(2, this._zoom);
44282 var basicRotation = basic.slice();
44283 basicRotation[0] = this._spatial.clamp(basicRotation[0], -threshold, threshold);
44284 basicRotation[1] = this._spatial.clamp(basicRotation[1], -threshold, threshold);
44285 this._applyRotationBasic(basicRotation);
44287 InteractiveStateBase.prototype.rotateToBasic = function (basic) {
44288 if (this._currentNode == null) {
44291 this._desiredZoom = this._zoom;
44292 this._desiredLookat = null;
44293 basic[0] = this._spatial.clamp(basic[0], 0, 1);
44294 basic[1] = this._spatial.clamp(basic[1], 0, 1);
44295 var lookat = this.currentTransform.unprojectBasic(basic, this._lookatDepth);
44296 this._currentCamera.lookat.fromArray(lookat);
44298 InteractiveStateBase.prototype.zoomIn = function (delta, reference) {
44299 if (this._currentNode == null) {
44302 this._desiredZoom = Math.max(this._minZoom, Math.min(this._maxZoom, this._desiredZoom + delta));
44303 var currentCenter = this.currentTransform.projectBasic(this._currentCamera.lookat.toArray());
44304 var currentCenterX = currentCenter[0];
44305 var currentCenterY = currentCenter[1];
44306 var zoom0 = Math.pow(2, this._zoom);
44307 var zoom1 = Math.pow(2, this._desiredZoom);
44308 var refX = reference[0];
44309 var refY = reference[1];
44310 if (this.currentTransform.gpano != null &&
44311 this.currentTransform.gpano.CroppedAreaImageWidthPixels === this.currentTransform.gpano.FullPanoWidthPixels) {
44312 if (refX - currentCenterX > 0.5) {
44315 else if (currentCenterX - refX > 0.5) {
44319 var newCenterX = refX - zoom0 / zoom1 * (refX - currentCenterX);
44320 var newCenterY = refY - zoom0 / zoom1 * (refY - currentCenterY);
44321 var gpano = this.currentTransform.gpano;
44322 if (this._currentNode.fullPano) {
44323 newCenterX = this._spatial.wrap(newCenterX + this._basicRotation[0], 0, 1);
44324 newCenterY = this._spatial.clamp(newCenterY + this._basicRotation[1], 0.05, 0.95);
44326 else if (gpano != null &&
44327 this.currentTransform.gpano.CroppedAreaImageWidthPixels === this.currentTransform.gpano.FullPanoWidthPixels) {
44328 newCenterX = this._spatial.wrap(newCenterX + this._basicRotation[0], 0, 1);
44329 newCenterY = this._spatial.clamp(newCenterY + this._basicRotation[1], 0, 1);
44332 newCenterX = this._spatial.clamp(newCenterX, 0, 1);
44333 newCenterY = this._spatial.clamp(newCenterY, 0, 1);
44335 this._desiredLookat = new THREE.Vector3()
44336 .fromArray(this.currentTransform.unprojectBasic([newCenterX, newCenterY], this._lookatDepth));
44338 InteractiveStateBase.prototype.setCenter = function (center) {
44339 this._desiredLookat = null;
44340 this._requestedRotationDelta = null;
44341 this._requestedBasicRotation = null;
44342 this._desiredZoom = this._zoom;
44344 this._spatial.clamp(center[0], 0, 1),
44345 this._spatial.clamp(center[1], 0, 1),
44347 if (this._currentNode == null) {
44348 this._desiredCenter = clamped;
44351 this._desiredCenter = null;
44352 var currentLookat = new THREE.Vector3()
44353 .fromArray(this.currentTransform.unprojectBasic(clamped, this._lookatDepth));
44354 var previousTransform = this.previousTransform != null ?
44355 this.previousTransform :
44356 this.currentTransform;
44357 var previousLookat = new THREE.Vector3()
44358 .fromArray(previousTransform.unprojectBasic(clamped, this._lookatDepth));
44359 this._currentCamera.lookat.copy(currentLookat);
44360 this._previousCamera.lookat.copy(previousLookat);
44362 InteractiveStateBase.prototype.setZoom = function (zoom) {
44363 this._desiredLookat = null;
44364 this._requestedRotationDelta = null;
44365 this._requestedBasicRotation = null;
44366 this._zoom = this._spatial.clamp(zoom, this._minZoom, this._maxZoom);
44367 this._desiredZoom = this._zoom;
44369 InteractiveStateBase.prototype._applyRotation = function (delta, camera) {
44370 if (camera == null) {
44373 var q = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
44374 var qInverse = q.clone().inverse();
44375 var offset = new THREE.Vector3();
44376 offset.copy(camera.lookat).sub(camera.position);
44377 offset.applyQuaternion(q);
44378 var length = offset.length();
44379 var phi = Math.atan2(offset.y, offset.x);
44381 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
44382 theta += delta.theta;
44383 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
44384 offset.x = Math.sin(theta) * Math.cos(phi);
44385 offset.y = Math.sin(theta) * Math.sin(phi);
44386 offset.z = Math.cos(theta);
44387 offset.applyQuaternion(qInverse);
44388 camera.lookat.copy(camera.position).add(offset.multiplyScalar(length));
44390 InteractiveStateBase.prototype._applyRotationBasic = function (basicRotation) {
44391 var currentNode = this._currentNode;
44392 var previousNode = this._previousNode != null ?
44393 this.previousNode :
44395 var currentCamera = this._currentCamera;
44396 var previousCamera = this._previousCamera;
44397 var currentTransform = this.currentTransform;
44398 var previousTransform = this.previousTransform != null ?
44399 this.previousTransform :
44400 this.currentTransform;
44401 var currentBasic = currentTransform.projectBasic(currentCamera.lookat.toArray());
44402 var previousBasic = previousTransform.projectBasic(previousCamera.lookat.toArray());
44403 var currentGPano = currentTransform.gpano;
44404 var previousGPano = previousTransform.gpano;
44405 if (currentNode.fullPano) {
44406 currentBasic[0] = this._spatial.wrap(currentBasic[0] + basicRotation[0], 0, 1);
44407 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0.05, 0.95);
44409 else if (currentGPano != null &&
44410 currentTransform.gpano.CroppedAreaImageWidthPixels === currentTransform.gpano.FullPanoWidthPixels) {
44411 currentBasic[0] = this._spatial.wrap(currentBasic[0] + basicRotation[0], 0, 1);
44412 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
44415 currentBasic[0] = this._spatial.clamp(currentBasic[0] + basicRotation[0], 0, 1);
44416 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
44418 if (previousNode.fullPano) {
44419 previousBasic[0] = this._spatial.wrap(previousBasic[0] + basicRotation[0], 0, 1);
44420 previousBasic[1] = this._spatial.clamp(previousBasic[1] + basicRotation[1], 0.05, 0.95);
44422 else if (previousGPano != null &&
44423 previousTransform.gpano.CroppedAreaImageWidthPixels === previousTransform.gpano.FullPanoWidthPixels) {
44424 previousBasic[0] = this._spatial.wrap(previousBasic[0] + basicRotation[0], 0, 1);
44425 previousBasic[1] = this._spatial.clamp(previousBasic[1] + basicRotation[1], 0, 1);
44428 previousBasic[0] = this._spatial.clamp(previousBasic[0] + basicRotation[0], 0, 1);
44429 previousBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
44431 var currentLookat = currentTransform.unprojectBasic(currentBasic, this._lookatDepth);
44432 currentCamera.lookat.fromArray(currentLookat);
44433 var previousLookat = previousTransform.unprojectBasic(previousBasic, this._lookatDepth);
44434 previousCamera.lookat.fromArray(previousLookat);
44436 InteractiveStateBase.prototype._updateZoom = function (animationSpeed) {
44437 var diff = this._desiredZoom - this._zoom;
44438 var sign = diff > 0 ? 1 : diff < 0 ? -1 : 0;
44442 else if (Math.abs(diff) < 2e-3) {
44443 this._zoom = this._desiredZoom;
44444 if (this._desiredLookat != null) {
44445 this._desiredLookat = null;
44449 this._zoom += sign * Math.max(Math.abs(5 * animationSpeed * diff), 2e-3);
44452 InteractiveStateBase.prototype._updateLookat = function (animationSpeed) {
44453 if (this._desiredLookat === null) {
44456 var diff = this._desiredLookat.distanceToSquared(this._currentCamera.lookat);
44457 if (Math.abs(diff) < 1e-6) {
44458 this._currentCamera.lookat.copy(this._desiredLookat);
44459 this._desiredLookat = null;
44462 this._currentCamera.lookat.lerp(this._desiredLookat, 5 * animationSpeed);
44465 InteractiveStateBase.prototype._updateRotation = function () {
44466 if (this._requestedRotationDelta != null) {
44467 var length_1 = this._rotationDelta.lengthSquared();
44468 var requestedLength = this._requestedRotationDelta.lengthSquared();
44469 if (requestedLength > length_1) {
44470 this._rotationDelta.lerp(this._requestedRotationDelta, this._rotationIncreaseAlpha);
44473 this._rotationDelta.lerp(this._requestedRotationDelta, this._rotationDecreaseAlpha);
44475 this._requestedRotationDelta = null;
44478 if (this._rotationDelta.isZero) {
44481 this._rotationDelta.multiply(this._rotationAcceleration);
44482 this._rotationDelta.threshold(this._rotationThreshold);
44484 InteractiveStateBase.prototype._updateRotationBasic = function () {
44485 if (this._requestedBasicRotation != null) {
44486 var x = this._basicRotation[0];
44487 var y = this._basicRotation[1];
44488 var reqX = this._requestedBasicRotation[0];
44489 var reqY = this._requestedBasicRotation[1];
44490 if (Math.abs(reqX) > Math.abs(x)) {
44491 this._basicRotation[0] = (1 - this._rotationIncreaseAlpha) * x + this._rotationIncreaseAlpha * reqX;
44494 this._basicRotation[0] = (1 - this._rotationDecreaseAlpha) * x + this._rotationDecreaseAlpha * reqX;
44496 if (Math.abs(reqY) > Math.abs(y)) {
44497 this._basicRotation[1] = (1 - this._rotationIncreaseAlpha) * y + this._rotationIncreaseAlpha * reqY;
44500 this._basicRotation[1] = (1 - this._rotationDecreaseAlpha) * y + this._rotationDecreaseAlpha * reqY;
44502 this._requestedBasicRotation = null;
44505 if (this._requestedBasicRotationUnbounded != null) {
44506 var reqX = this._requestedBasicRotationUnbounded[0];
44507 var reqY = this._requestedBasicRotationUnbounded[1];
44508 if (Math.abs(reqX) > 0) {
44509 this._basicRotation[0] = (1 - this._unboundedRotationAlpha) * this._basicRotation[0] + this._unboundedRotationAlpha * reqX;
44511 if (Math.abs(reqY) > 0) {
44512 this._basicRotation[1] = (1 - this._unboundedRotationAlpha) * this._basicRotation[1] + this._unboundedRotationAlpha * reqY;
44514 if (this._desiredLookat != null) {
44515 var desiredBasicLookat = this.currentTransform.projectBasic(this._desiredLookat.toArray());
44516 desiredBasicLookat[0] += reqX;
44517 desiredBasicLookat[1] += reqY;
44518 this._desiredLookat = new THREE.Vector3()
44519 .fromArray(this.currentTransform.unprojectBasic(desiredBasicLookat, this._lookatDepth));
44521 this._requestedBasicRotationUnbounded = null;
44523 if (this._basicRotation[0] === 0 && this._basicRotation[1] === 0) {
44526 this._basicRotation[0] = this._rotationAcceleration * this._basicRotation[0];
44527 this._basicRotation[1] = this._rotationAcceleration * this._basicRotation[1];
44528 if (Math.abs(this._basicRotation[0]) < this._rotationThreshold / Math.pow(2, this._zoom) &&
44529 Math.abs(this._basicRotation[1]) < this._rotationThreshold / Math.pow(2, this._zoom)) {
44530 this._basicRotation = [0, 0];
44533 InteractiveStateBase.prototype._clearRotation = function () {
44534 if (this._currentNode.fullPano) {
44537 if (this._requestedRotationDelta != null) {
44538 this._requestedRotationDelta = null;
44540 if (!this._rotationDelta.isZero) {
44541 this._rotationDelta.reset();
44543 if (this._requestedBasicRotation != null) {
44544 this._requestedBasicRotation = null;
44546 if (this._basicRotation[0] > 0 || this._basicRotation[1] > 0) {
44547 this._basicRotation = [0, 0];
44550 InteractiveStateBase.prototype._setDesiredCenter = function () {
44551 if (this._desiredCenter == null) {
44554 var lookatDirection = new THREE.Vector3()
44555 .fromArray(this.currentTransform.unprojectBasic(this._desiredCenter, this._lookatDepth))
44556 .sub(this._currentCamera.position);
44557 this._currentCamera.lookat.copy(this._currentCamera.position.clone().add(lookatDirection));
44558 this._previousCamera.lookat.copy(this._previousCamera.position.clone().add(lookatDirection));
44559 this._desiredCenter = null;
44561 InteractiveStateBase.prototype._setDesiredZoom = function () {
44562 this._desiredZoom =
44563 this._currentNode.fullPano || this._previousNode == null ?
44566 return InteractiveStateBase;
44567 }(State_1.StateBase));
44568 exports.InteractiveStateBase = InteractiveStateBase;
44569 exports.default = InteractiveStateBase;
44572 },{"../../State":282,"three":226}],418:[function(require,module,exports){
44574 var __extends = (this && this.__extends) || (function () {
44575 var extendStatics = function (d, b) {
44576 extendStatics = Object.setPrototypeOf ||
44577 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
44578 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
44579 return extendStatics(d, b);
44581 return function (d, b) {
44582 extendStatics(d, b);
44583 function __() { this.constructor = d; }
44584 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44587 Object.defineProperty(exports, "__esModule", { value: true });
44588 var State_1 = require("../../State");
44589 var InteractiveWaitingState = /** @class */ (function (_super) {
44590 __extends(InteractiveWaitingState, _super);
44591 function InteractiveWaitingState(state) {
44592 var _this = _super.call(this, state) || this;
44593 _this._adjustCameras();
44594 _this._motionless = _this._motionlessTransition();
44597 InteractiveWaitingState.prototype.traverse = function () {
44598 return new State_1.TraversingState(this);
44600 InteractiveWaitingState.prototype.wait = function () {
44601 return new State_1.WaitingState(this);
44603 InteractiveWaitingState.prototype.prepend = function (nodes) {
44604 _super.prototype.prepend.call(this, nodes);
44605 this._motionless = this._motionlessTransition();
44607 InteractiveWaitingState.prototype.set = function (nodes) {
44608 _super.prototype.set.call(this, nodes);
44609 this._motionless = this._motionlessTransition();
44611 InteractiveWaitingState.prototype.move = function (delta) {
44612 this._alpha = Math.max(0, Math.min(1, this._alpha + delta));
44614 InteractiveWaitingState.prototype.moveTo = function (position) {
44615 this._alpha = Math.max(0, Math.min(1, position));
44617 InteractiveWaitingState.prototype.update = function (fps) {
44618 this._updateRotation();
44619 if (!this._rotationDelta.isZero) {
44620 this._applyRotation(this._rotationDelta, this._previousCamera);
44621 this._applyRotation(this._rotationDelta, this._currentCamera);
44623 this._updateRotationBasic();
44624 if (this._basicRotation[0] !== 0 || this._basicRotation[1] !== 0) {
44625 this._applyRotationBasic(this._basicRotation);
44627 var animationSpeed = this._animationSpeed * (60 / fps);
44628 this._updateZoom(animationSpeed);
44629 this._updateLookat(animationSpeed);
44630 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
44632 InteractiveWaitingState.prototype._getAlpha = function () {
44633 return this._motionless ? Math.round(this._alpha) : this._alpha;
44635 InteractiveWaitingState.prototype._setCurrentCamera = function () {
44636 _super.prototype._setCurrentCamera.call(this);
44637 this._adjustCameras();
44639 InteractiveWaitingState.prototype._adjustCameras = function () {
44640 if (this._previousNode == null) {
44643 if (this._currentNode.fullPano) {
44644 var lookat = this._camera.lookat.clone().sub(this._camera.position);
44645 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
44647 if (this._previousNode.fullPano) {
44648 var lookat = this._currentCamera.lookat.clone().sub(this._currentCamera.position);
44649 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
44652 return InteractiveWaitingState;
44653 }(State_1.InteractiveStateBase));
44654 exports.InteractiveWaitingState = InteractiveWaitingState;
44655 exports.default = InteractiveWaitingState;
44657 },{"../../State":282}],419:[function(require,module,exports){
44659 Object.defineProperty(exports, "__esModule", { value: true });
44660 var Error_1 = require("../../Error");
44661 var Geo_1 = require("../../Geo");
44662 var State_1 = require("../../State");
44663 var StateBase = /** @class */ (function () {
44664 function StateBase(state) {
44665 this._spatial = new Geo_1.Spatial();
44666 this._geoCoords = new Geo_1.GeoCoords();
44667 this._referenceThreshold = 0.01;
44668 this._transitionMode = state.transitionMode;
44669 this._reference = state.reference;
44670 this._alpha = state.alpha;
44671 this._camera = state.camera.clone();
44672 this._zoom = state.zoom;
44673 this._currentIndex = state.currentIndex;
44674 this._trajectory = state.trajectory.slice();
44675 this._trajectoryTransforms = [];
44676 this._trajectoryCameras = [];
44677 for (var _i = 0, _a = this._trajectory; _i < _a.length; _i++) {
44679 var translation = this._nodeToTranslation(node, this._reference);
44680 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);
44681 this._trajectoryTransforms.push(transform);
44682 this._trajectoryCameras.push(new Geo_1.Camera(transform));
44684 this._currentNode = this._trajectory.length > 0 ?
44685 this._trajectory[this._currentIndex] :
44687 this._previousNode = this._trajectory.length > 1 && this.currentIndex > 0 ?
44688 this._trajectory[this._currentIndex - 1] :
44690 this._currentCamera = this._trajectoryCameras.length > 0 ?
44691 this._trajectoryCameras[this._currentIndex].clone() :
44692 new Geo_1.Camera();
44693 this._previousCamera = this._trajectoryCameras.length > 1 && this.currentIndex > 0 ?
44694 this._trajectoryCameras[this._currentIndex - 1].clone() :
44695 this._currentCamera.clone();
44697 Object.defineProperty(StateBase.prototype, "reference", {
44699 return this._reference;
44704 Object.defineProperty(StateBase.prototype, "alpha", {
44706 return this._getAlpha();
44711 Object.defineProperty(StateBase.prototype, "camera", {
44713 return this._camera;
44718 Object.defineProperty(StateBase.prototype, "zoom", {
44725 Object.defineProperty(StateBase.prototype, "trajectory", {
44727 return this._trajectory;
44732 Object.defineProperty(StateBase.prototype, "currentIndex", {
44734 return this._currentIndex;
44739 Object.defineProperty(StateBase.prototype, "currentNode", {
44741 return this._currentNode;
44746 Object.defineProperty(StateBase.prototype, "previousNode", {
44748 return this._previousNode;
44753 Object.defineProperty(StateBase.prototype, "currentCamera", {
44755 return this._currentCamera;
44760 Object.defineProperty(StateBase.prototype, "currentTransform", {
44762 return this._trajectoryTransforms.length > 0 ?
44763 this._trajectoryTransforms[this.currentIndex] : null;
44768 Object.defineProperty(StateBase.prototype, "previousTransform", {
44770 return this._trajectoryTransforms.length > 1 && this.currentIndex > 0 ?
44771 this._trajectoryTransforms[this.currentIndex - 1] : null;
44776 Object.defineProperty(StateBase.prototype, "motionless", {
44778 return this._motionless;
44783 Object.defineProperty(StateBase.prototype, "transitionMode", {
44785 return this._transitionMode;
44790 StateBase.prototype.earth = function () { throw new Error("Not implemented"); };
44791 StateBase.prototype.traverse = function () { throw new Error("Not implemented"); };
44792 StateBase.prototype.wait = function () { throw new Error("Not implemented"); };
44793 StateBase.prototype.waitInteractively = function () { throw new Error("Not implemented"); };
44794 StateBase.prototype.move = function (delta) { };
44795 StateBase.prototype.moveTo = function (position) { };
44796 StateBase.prototype.rotate = function (delta) { };
44797 StateBase.prototype.rotateUnbounded = function (delta) { };
44798 StateBase.prototype.rotateWithoutInertia = function (delta) { };
44799 StateBase.prototype.rotateBasic = function (basicRotation) { };
44800 StateBase.prototype.rotateBasicUnbounded = function (basicRotation) { };
44801 StateBase.prototype.rotateBasicWithoutInertia = function (basicRotation) { };
44802 StateBase.prototype.rotateToBasic = function (basic) { };
44803 StateBase.prototype.setSpeed = function (speed) { };
44804 StateBase.prototype.zoomIn = function (delta, reference) { };
44805 StateBase.prototype.update = function (fps) { };
44806 StateBase.prototype.setCenter = function (center) { };
44807 StateBase.prototype.setZoom = function (zoom) { };
44808 StateBase.prototype.dolly = function (delta) { };
44809 StateBase.prototype.orbit = function (rotation) { };
44810 StateBase.prototype.truck = function (direction) { };
44811 StateBase.prototype.append = function (nodes) {
44812 if (nodes.length < 1) {
44813 throw Error("Trajectory can not be empty");
44815 if (this._currentIndex < 0) {
44819 this._trajectory = this._trajectory.concat(nodes);
44820 this._appendToTrajectories(nodes);
44823 StateBase.prototype.prepend = function (nodes) {
44824 if (nodes.length < 1) {
44825 throw Error("Trajectory can not be empty");
44827 this._trajectory = nodes.slice().concat(this._trajectory);
44828 this._currentIndex += nodes.length;
44829 this._setCurrentNode();
44830 var referenceReset = this._setReference(this._currentNode);
44831 if (referenceReset) {
44832 this._setTrajectories();
44835 this._prependToTrajectories(nodes);
44837 this._setCurrentCamera();
44839 StateBase.prototype.remove = function (n) {
44841 throw Error("n must be a positive integer");
44843 if (this._currentIndex - 1 < n) {
44844 throw Error("Current and previous nodes can not be removed");
44846 for (var i = 0; i < n; i++) {
44847 this._trajectory.shift();
44848 this._trajectoryTransforms.shift();
44849 this._trajectoryCameras.shift();
44850 this._currentIndex--;
44852 this._setCurrentNode();
44854 StateBase.prototype.clearPrior = function () {
44855 if (this._currentIndex > 0) {
44856 this.remove(this._currentIndex - 1);
44859 StateBase.prototype.clear = function () {
44861 if (this._currentIndex > 0) {
44862 this.remove(this._currentIndex - 1);
44865 StateBase.prototype.cut = function () {
44866 while (this._trajectory.length - 1 > this._currentIndex) {
44867 this._trajectory.pop();
44868 this._trajectoryTransforms.pop();
44869 this._trajectoryCameras.pop();
44872 StateBase.prototype.set = function (nodes) {
44873 this._setTrajectory(nodes);
44874 this._setCurrentNode();
44875 this._setReference(this._currentNode);
44876 this._setTrajectories();
44877 this._setCurrentCamera();
44879 StateBase.prototype.getCenter = function () {
44880 return this._currentNode != null ?
44881 this.currentTransform.projectBasic(this._camera.lookat.toArray()) :
44884 StateBase.prototype.setTransitionMode = function (mode) {
44885 this._transitionMode = mode;
44887 StateBase.prototype._getAlpha = function () { return 1; };
44888 StateBase.prototype._setCurrent = function () {
44889 this._setCurrentNode();
44890 var referenceReset = this._setReference(this._currentNode);
44891 if (referenceReset) {
44892 this._setTrajectories();
44894 this._setCurrentCamera();
44896 StateBase.prototype._setCurrentCamera = function () {
44897 this._currentCamera = this._trajectoryCameras[this._currentIndex].clone();
44898 this._previousCamera = this._currentIndex > 0 ?
44899 this._trajectoryCameras[this._currentIndex - 1].clone() :
44900 this._currentCamera.clone();
44902 StateBase.prototype._motionlessTransition = function () {
44903 var nodesSet = this._currentNode != null && this._previousNode != null;
44904 return nodesSet && (this._transitionMode === State_1.TransitionMode.Instantaneous || !(this._currentNode.merged &&
44905 this._previousNode.merged &&
44906 this._withinOriginalDistance() &&
44907 this._sameConnectedComponent()));
44909 StateBase.prototype._setReference = function (node) {
44910 // do not reset reference if node is within threshold distance
44911 if (Math.abs(node.latLon.lat - this.reference.lat) < this._referenceThreshold &&
44912 Math.abs(node.latLon.lon - this.reference.lon) < this._referenceThreshold) {
44915 // do not reset reference if previous node exist and transition is with motion
44916 if (this._previousNode != null && !this._motionlessTransition()) {
44919 this._reference.lat = node.latLon.lat;
44920 this._reference.lon = node.latLon.lon;
44921 this._reference.alt = node.alt;
44924 StateBase.prototype._setCurrentNode = function () {
44925 this._currentNode = this._trajectory.length > 0 ?
44926 this._trajectory[this._currentIndex] :
44928 this._previousNode = this._currentIndex > 0 ?
44929 this._trajectory[this._currentIndex - 1] :
44932 StateBase.prototype._setTrajectory = function (nodes) {
44933 if (nodes.length < 1) {
44934 throw new Error_1.ArgumentMapillaryError("Trajectory can not be empty");
44936 if (this._currentNode != null) {
44937 this._trajectory = [this._currentNode].concat(nodes);
44938 this._currentIndex = 1;
44941 this._trajectory = nodes.slice();
44942 this._currentIndex = 0;
44945 StateBase.prototype._setTrajectories = function () {
44946 this._trajectoryTransforms.length = 0;
44947 this._trajectoryCameras.length = 0;
44948 this._appendToTrajectories(this._trajectory);
44950 StateBase.prototype._appendToTrajectories = function (nodes) {
44951 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
44952 var node = nodes_1[_i];
44953 if (!node.assetsCached) {
44954 throw new Error_1.ArgumentMapillaryError("Assets must be cached when node is added to trajectory");
44956 var translation = this._nodeToTranslation(node, this.reference);
44957 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);
44958 this._trajectoryTransforms.push(transform);
44959 this._trajectoryCameras.push(new Geo_1.Camera(transform));
44962 StateBase.prototype._prependToTrajectories = function (nodes) {
44963 for (var _i = 0, _a = nodes.reverse(); _i < _a.length; _i++) {
44965 if (!node.assetsCached) {
44966 throw new Error_1.ArgumentMapillaryError("Assets must be cached when added to trajectory");
44968 var translation = this._nodeToTranslation(node, this.reference);
44969 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);
44970 this._trajectoryTransforms.unshift(transform);
44971 this._trajectoryCameras.unshift(new Geo_1.Camera(transform));
44974 StateBase.prototype._nodeToTranslation = function (node, reference) {
44975 return Geo_1.Geo.computeTranslation({ alt: node.alt, lat: node.latLon.lat, lon: node.latLon.lon }, node.rotation, reference);
44977 StateBase.prototype._sameConnectedComponent = function () {
44978 var current = this._currentNode;
44979 var previous = this._previousNode;
44980 return !!current && !!previous &&
44981 current.mergeCC === previous.mergeCC;
44983 StateBase.prototype._withinOriginalDistance = function () {
44984 var current = this._currentNode;
44985 var previous = this._previousNode;
44986 if (!current || !previous) {
44989 // 50 km/h moves 28m in 2s
44990 var distance = this._spatial.distanceFromLatLon(current.originalLatLon.lat, current.originalLatLon.lon, previous.originalLatLon.lat, previous.originalLatLon.lon);
44991 return distance < 25;
44995 exports.StateBase = StateBase;
44997 },{"../../Error":277,"../../Geo":278,"../../State":282}],420:[function(require,module,exports){
44999 var __extends = (this && this.__extends) || (function () {
45000 var extendStatics = function (d, b) {
45001 extendStatics = Object.setPrototypeOf ||
45002 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45003 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45004 return extendStatics(d, b);
45006 return function (d, b) {
45007 extendStatics(d, b);
45008 function __() { this.constructor = d; }
45009 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45012 Object.defineProperty(exports, "__esModule", { value: true });
45013 var UnitBezier = require("@mapbox/unitbezier");
45014 var State_1 = require("../../State");
45015 var TraversingState = /** @class */ (function (_super) {
45016 __extends(TraversingState, _super);
45017 function TraversingState(state) {
45018 var _this = _super.call(this, state) || this;
45019 _this._adjustCameras();
45020 _this._motionless = _this._motionlessTransition();
45021 _this._baseAlpha = _this._alpha;
45022 _this._speedCoefficient = 1;
45023 _this._unitBezier = new UnitBezier(0.74, 0.67, 0.38, 0.96);
45024 _this._useBezier = false;
45027 TraversingState.prototype.earth = function () {
45028 return new State_1.EarthState(this);
45030 TraversingState.prototype.wait = function () {
45031 return new State_1.WaitingState(this);
45033 TraversingState.prototype.waitInteractively = function () {
45034 return new State_1.InteractiveWaitingState(this);
45036 TraversingState.prototype.append = function (nodes) {
45037 var emptyTrajectory = this._trajectory.length === 0;
45038 if (emptyTrajectory) {
45039 this._resetTransition();
45041 _super.prototype.append.call(this, nodes);
45042 if (emptyTrajectory) {
45043 this._setDesiredCenter();
45044 this._setDesiredZoom();
45047 TraversingState.prototype.prepend = function (nodes) {
45048 var emptyTrajectory = this._trajectory.length === 0;
45049 if (emptyTrajectory) {
45050 this._resetTransition();
45052 _super.prototype.prepend.call(this, nodes);
45053 if (emptyTrajectory) {
45054 this._setDesiredCenter();
45055 this._setDesiredZoom();
45058 TraversingState.prototype.set = function (nodes) {
45059 _super.prototype.set.call(this, nodes);
45060 this._desiredLookat = null;
45061 this._resetTransition();
45062 this._clearRotation();
45063 this._setDesiredCenter();
45064 this._setDesiredZoom();
45065 if (this._trajectory.length < 3) {
45066 this._useBezier = true;
45069 TraversingState.prototype.setSpeed = function (speed) {
45070 this._speedCoefficient = this._spatial.clamp(speed, 0, 10);
45072 TraversingState.prototype.update = function (fps) {
45073 if (this._alpha === 1 && this._currentIndex + this._alpha < this._trajectory.length) {
45074 this._currentIndex += 1;
45075 this._useBezier = this._trajectory.length < 3 &&
45076 this._currentIndex + 1 === this._trajectory.length;
45077 this._setCurrent();
45078 this._resetTransition();
45079 this._clearRotation();
45080 this._desiredZoom = this._currentNode.fullPano ? this._zoom : 0;
45081 this._desiredLookat = null;
45083 var animationSpeed = this._animationSpeed * (60 / fps);
45084 this._baseAlpha = Math.min(1, this._baseAlpha + this._speedCoefficient * animationSpeed);
45085 if (this._useBezier) {
45086 this._alpha = this._unitBezier.solve(this._baseAlpha);
45089 this._alpha = this._baseAlpha;
45091 this._updateRotation();
45092 if (!this._rotationDelta.isZero) {
45093 this._applyRotation(this._rotationDelta, this._previousCamera);
45094 this._applyRotation(this._rotationDelta, this._currentCamera);
45096 this._updateRotationBasic();
45097 if (this._basicRotation[0] !== 0 || this._basicRotation[1] !== 0) {
45098 this._applyRotationBasic(this._basicRotation);
45100 this._updateZoom(animationSpeed);
45101 this._updateLookat(animationSpeed);
45102 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
45104 TraversingState.prototype._getAlpha = function () {
45105 return this._motionless ? Math.ceil(this._alpha) : this._alpha;
45107 TraversingState.prototype._setCurrentCamera = function () {
45108 _super.prototype._setCurrentCamera.call(this);
45109 this._adjustCameras();
45111 TraversingState.prototype._adjustCameras = function () {
45112 if (this._previousNode == null) {
45115 var lookat = this._camera.lookat.clone().sub(this._camera.position);
45116 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
45117 if (this._currentNode.fullPano) {
45118 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
45121 TraversingState.prototype._resetTransition = function () {
45123 this._baseAlpha = 0;
45124 this._motionless = this._motionlessTransition();
45126 return TraversingState;
45127 }(State_1.InteractiveStateBase));
45128 exports.TraversingState = TraversingState;
45129 exports.default = TraversingState;
45131 },{"../../State":282,"@mapbox/unitbezier":2}],421:[function(require,module,exports){
45133 var __extends = (this && this.__extends) || (function () {
45134 var extendStatics = function (d, b) {
45135 extendStatics = Object.setPrototypeOf ||
45136 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45137 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45138 return extendStatics(d, b);
45140 return function (d, b) {
45141 extendStatics(d, b);
45142 function __() { this.constructor = d; }
45143 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45146 Object.defineProperty(exports, "__esModule", { value: true });
45147 var State_1 = require("../../State");
45148 var WaitingState = /** @class */ (function (_super) {
45149 __extends(WaitingState, _super);
45150 function WaitingState(state) {
45151 var _this = _super.call(this, state) || this;
45153 _this._adjustCameras();
45154 _this._motionless = _this._motionlessTransition();
45157 WaitingState.prototype.traverse = function () {
45158 return new State_1.TraversingState(this);
45160 WaitingState.prototype.waitInteractively = function () {
45161 return new State_1.InteractiveWaitingState(this);
45163 WaitingState.prototype.prepend = function (nodes) {
45164 _super.prototype.prepend.call(this, nodes);
45165 this._motionless = this._motionlessTransition();
45167 WaitingState.prototype.set = function (nodes) {
45168 _super.prototype.set.call(this, nodes);
45169 this._motionless = this._motionlessTransition();
45171 WaitingState.prototype.move = function (delta) {
45172 this._alpha = Math.max(0, Math.min(1, this._alpha + delta));
45174 WaitingState.prototype.moveTo = function (position) {
45175 this._alpha = Math.max(0, Math.min(1, position));
45177 WaitingState.prototype.update = function (fps) {
45178 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
45180 WaitingState.prototype._getAlpha = function () {
45181 return this._motionless ? Math.round(this._alpha) : this._alpha;
45183 WaitingState.prototype._setCurrentCamera = function () {
45184 _super.prototype._setCurrentCamera.call(this);
45185 this._adjustCameras();
45187 WaitingState.prototype._adjustCameras = function () {
45188 if (this._previousNode == null) {
45191 if (this._currentNode.fullPano) {
45192 var lookat = this._camera.lookat.clone().sub(this._camera.position);
45193 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
45195 if (this._previousNode.fullPano) {
45196 var lookat = this._currentCamera.lookat.clone().sub(this._currentCamera.position);
45197 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
45200 return WaitingState;
45201 }(State_1.StateBase));
45202 exports.WaitingState = WaitingState;
45203 exports.default = WaitingState;
45205 },{"../../State":282}],422:[function(require,module,exports){
45207 Object.defineProperty(exports, "__esModule", { value: true });
45208 var rxjs_1 = require("rxjs");
45210 * @class ImageTileLoader
45212 * @classdesc Represents a loader of image tiles.
45214 var ImageTileLoader = /** @class */ (function () {
45216 * Create a new node image tile loader instance.
45218 * @param {string} scheme - The URI scheme.
45219 * @param {string} host - The URI host.
45220 * @param {string} [origin] - The origin query param.
45222 function ImageTileLoader(scheme, host, origin) {
45223 this._scheme = scheme;
45225 this._origin = origin != null ? "?origin=" + origin : "";
45228 * Retrieve an image tile.
45230 * @description Retrieve an image tile by specifying the area
45231 * as well as the scaled size.
45233 * @param {string} identifier - The identifier of the image.
45234 * @param {number} x - The top left x pixel coordinate for the tile
45235 * in the original image.
45236 * @param {number} y - The top left y pixel coordinate for the tile
45237 * in the original image.
45238 * @param {number} w - The pixel width of the tile in the original image.
45239 * @param {number} h - The pixel height of the tile in the original image.
45240 * @param {number} scaledW - The scaled width of the returned tile.
45241 * @param {number} scaledH - The scaled height of the returned tile.
45243 ImageTileLoader.prototype.getTile = function (identifier, x, y, w, h, scaledW, scaledH) {
45244 var characteristics = "/" + identifier + "/" + x + "," + y + "," + w + "," + h + "/" + scaledW + "," + scaledH + "/0/default.jpg";
45245 var url = this._scheme +
45250 var xmlHTTP = null;
45251 return [rxjs_1.Observable.create(function (subscriber) {
45252 xmlHTTP = new XMLHttpRequest();
45253 xmlHTTP.open("GET", url, true);
45254 xmlHTTP.responseType = "arraybuffer";
45255 xmlHTTP.timeout = 15000;
45256 xmlHTTP.onload = function (event) {
45257 if (xmlHTTP.status !== 200) {
45258 subscriber.error(new Error("Failed to fetch tile (" + identifier + ": " + x + "," + y + "," + w + "," + h + "). " +
45259 ("Status: " + xmlHTTP.status + ", " + xmlHTTP.statusText)));
45262 var image = new Image();
45263 image.crossOrigin = "Anonymous";
45264 image.onload = function (e) {
45265 subscriber.next(image);
45266 subscriber.complete();
45268 image.onerror = function (error) {
45269 subscriber.error(new Error("Failed to load tile image (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
45271 var blob = new Blob([xmlHTTP.response]);
45272 image.src = window.URL.createObjectURL(blob);
45274 xmlHTTP.onerror = function (error) {
45275 subscriber.error(new Error("Failed to fetch tile (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
45277 xmlHTTP.ontimeout = function (error) {
45278 subscriber.error(new Error("Tile request timed out (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
45280 xmlHTTP.onabort = function (event) {
45281 subscriber.error(new Error("Tile request was aborted (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
45283 xmlHTTP.send(null);
45286 if (xmlHTTP != null) {
45292 return ImageTileLoader;
45294 exports.ImageTileLoader = ImageTileLoader;
45295 exports.default = ImageTileLoader;
45297 },{"rxjs":27}],423:[function(require,module,exports){
45299 Object.defineProperty(exports, "__esModule", { value: true });
45301 * @class ImageTileStore
45303 * @classdesc Represents a store for image tiles.
45305 var ImageTileStore = /** @class */ (function () {
45307 * Create a new node image tile store instance.
45309 function ImageTileStore() {
45313 * Add an image tile to the store.
45315 * @param {HTMLImageElement} image - The image tile.
45316 * @param {string} key - The identifier for the tile.
45317 * @param {number} level - The level of the tile.
45319 ImageTileStore.prototype.addImage = function (image, key, level) {
45320 if (!(level in this._images)) {
45321 this._images[level] = {};
45323 this._images[level][key] = image;
45326 * Dispose the store.
45328 * @description Disposes all cached assets.
45330 ImageTileStore.prototype.dispose = function () {
45331 for (var _i = 0, _a = Object.keys(this._images); _i < _a.length; _i++) {
45332 var level = _a[_i];
45333 var levelImages = this._images[level];
45334 for (var _b = 0, _c = Object.keys(levelImages); _b < _c.length; _b++) {
45336 window.URL.revokeObjectURL(levelImages[key].src);
45337 delete levelImages[key];
45339 delete this._images[level];
45343 * Get an image tile from the store.
45345 * @param {string} key - The identifier for the tile.
45346 * @param {number} level - The level of the tile.
45348 ImageTileStore.prototype.getImage = function (key, level) {
45349 return this._images[level][key];
45352 * Check if an image tile exist in the store.
45354 * @param {string} key - The identifier for the tile.
45355 * @param {number} level - The level of the tile.
45357 ImageTileStore.prototype.hasImage = function (key, level) {
45358 return level in this._images && key in this._images[level];
45360 return ImageTileStore;
45362 exports.ImageTileStore = ImageTileStore;
45363 exports.default = ImageTileStore;
45365 },{}],424:[function(require,module,exports){
45367 Object.defineProperty(exports, "__esModule", { value: true });
45368 var Geo_1 = require("../Geo");
45370 * @class RegionOfInterestCalculator
45372 * @classdesc Represents a calculator for regions of interest.
45374 var RegionOfInterestCalculator = /** @class */ (function () {
45375 function RegionOfInterestCalculator() {
45376 this._viewportCoords = new Geo_1.ViewportCoords();
45379 * Compute a region of interest based on the current render camera
45380 * and the viewport size.
45382 * @param {RenderCamera} renderCamera - Render camera used for unprojections.
45383 * @param {ISize} size - Viewport size in pixels.
45384 * @param {Transform} transform - Transform used for projections.
45386 * @returns {IRegionOfInterest} A region of interest.
45388 RegionOfInterestCalculator.prototype.computeRegionOfInterest = function (renderCamera, size, transform) {
45389 var viewportBoundaryPoints = this._viewportBoundaryPoints(4);
45390 var bbox = this._viewportPointsBoundingBox(viewportBoundaryPoints, renderCamera, transform);
45391 this._clipBoundingBox(bbox);
45392 var viewportPixelWidth = 2 / size.width;
45393 var viewportPixelHeight = 2 / size.height;
45394 var centralViewportPixel = [
45395 [-0.5 * viewportPixelWidth, 0.5 * viewportPixelHeight],
45396 [0.5 * viewportPixelWidth, 0.5 * viewportPixelHeight],
45397 [0.5 * viewportPixelWidth, -0.5 * viewportPixelHeight],
45398 [-0.5 * viewportPixelWidth, -0.5 * viewportPixelHeight],
45400 var cpbox = this._viewportPointsBoundingBox(centralViewportPixel, renderCamera, transform);
45403 pixelHeight: cpbox.maxY - cpbox.minY,
45404 pixelWidth: cpbox.maxX - cpbox.minX + (cpbox.minX < cpbox.maxX ? 0 : 1),
45407 RegionOfInterestCalculator.prototype._viewportBoundaryPoints = function (pointsPerSide) {
45409 var os = [[-1, 1], [1, 1], [1, -1], [-1, -1]];
45410 var ds = [[2, 0], [0, -2], [-2, 0], [0, 2]];
45411 for (var side = 0; side < 4; ++side) {
45414 for (var i = 0; i < pointsPerSide; ++i) {
45415 points.push([o[0] + d[0] * i / pointsPerSide,
45416 o[1] + d[1] * i / pointsPerSide]);
45421 RegionOfInterestCalculator.prototype._viewportPointsBoundingBox = function (viewportPoints, renderCamera, transform) {
45423 var basicPoints = viewportPoints
45424 .map(function (point) {
45425 return _this._viewportCoords
45426 .viewportToBasic(point[0], point[1], transform, renderCamera.perspective);
45428 if (transform.gpano != null) {
45429 return this._boundingBoxPano(basicPoints);
45432 return this._boundingBox(basicPoints);
45435 RegionOfInterestCalculator.prototype._boundingBox = function (points) {
45437 maxX: Number.NEGATIVE_INFINITY,
45438 maxY: Number.NEGATIVE_INFINITY,
45439 minX: Number.POSITIVE_INFINITY,
45440 minY: Number.POSITIVE_INFINITY,
45442 for (var i = 0; i < points.length; ++i) {
45443 bbox.minX = Math.min(bbox.minX, points[i][0]);
45444 bbox.maxX = Math.max(bbox.maxX, points[i][0]);
45445 bbox.minY = Math.min(bbox.minY, points[i][1]);
45446 bbox.maxY = Math.max(bbox.maxY, points[i][1]);
45450 RegionOfInterestCalculator.prototype._boundingBoxPano = function (points) {
45454 for (var i = 0; i < points.length; ++i) {
45455 xs.push(points[i][0]);
45456 ys.push(points[i][1]);
45458 xs.sort(function (a, b) { return _this._sign(a - b); });
45459 ys.sort(function (a, b) { return _this._sign(a - b); });
45460 var intervalX = this._intervalPano(xs);
45462 maxX: intervalX[1],
45463 maxY: ys[ys.length - 1],
45464 minX: intervalX[0],
45469 * Find the max interval between consecutive numbers.
45470 * Assumes numbers are between 0 and 1, sorted and that
45471 * x is equivalent to x + 1.
45473 RegionOfInterestCalculator.prototype._intervalPano = function (xs) {
45476 for (var i = 0; i < xs.length - 1; ++i) {
45477 var dx = xs[i + 1] - xs[i];
45483 var loopdx = xs[0] + 1 - xs[xs.length - 1];
45484 if (loopdx > maxdx) {
45485 return [xs[0], xs[xs.length - 1]];
45488 return [xs[maxi + 1], xs[maxi]];
45491 RegionOfInterestCalculator.prototype._clipBoundingBox = function (bbox) {
45492 bbox.minX = Math.max(0, Math.min(1, bbox.minX));
45493 bbox.maxX = Math.max(0, Math.min(1, bbox.maxX));
45494 bbox.minY = Math.max(0, Math.min(1, bbox.minY));
45495 bbox.maxY = Math.max(0, Math.min(1, bbox.maxY));
45497 RegionOfInterestCalculator.prototype._sign = function (n) {
45498 return n > 0 ? 1 : n < 0 ? -1 : 0;
45500 return RegionOfInterestCalculator;
45502 exports.RegionOfInterestCalculator = RegionOfInterestCalculator;
45503 exports.default = RegionOfInterestCalculator;
45505 },{"../Geo":278}],425:[function(require,module,exports){
45507 Object.defineProperty(exports, "__esModule", { value: true });
45508 var operators_1 = require("rxjs/operators");
45509 var THREE = require("three");
45510 var rxjs_1 = require("rxjs");
45512 * @class TextureProvider
45514 * @classdesc Represents a provider of textures.
45516 var TextureProvider = /** @class */ (function () {
45518 * Create a new node texture provider instance.
45520 * @param {string} key - The identifier of the image for which to request tiles.
45521 * @param {number} width - The full width of the original image.
45522 * @param {number} height - The full height of the original image.
45523 * @param {number} tileSize - The size used when requesting tiles.
45524 * @param {HTMLImageElement} background - Image to use as background.
45525 * @param {ImageTileLoader} imageTileLoader - Loader for retrieving tiles.
45526 * @param {ImageTileStore} imageTileStore - Store for saving tiles.
45527 * @param {THREE.WebGLRenderer} renderer - Renderer used for rendering tiles to texture.
45529 function TextureProvider(key, width, height, tileSize, background, imageTileLoader, imageTileStore, renderer) {
45530 this._disposed = false;
45532 if (width <= 0 || height <= 0) {
45533 console.warn("Original image size (" + width + ", " + height + ") is invalid (" + key + "). Tiles will not be loaded.");
45535 this._width = width;
45536 this._height = height;
45537 this._maxLevel = Math.ceil(Math.log(Math.max(height, width)) / Math.log(2));
45538 this._currentLevel = -1;
45539 this._tileSize = tileSize;
45540 this._updated$ = new rxjs_1.Subject();
45541 this._createdSubject$ = new rxjs_1.Subject();
45542 this._created$ = this._createdSubject$.pipe(operators_1.publishReplay(1), operators_1.refCount());
45543 this._createdSubscription = this._created$.subscribe(function () { });
45544 this._hasSubject$ = new rxjs_1.Subject();
45545 this._has$ = this._hasSubject$.pipe(operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
45546 this._hasSubscription = this._has$.subscribe(function () { });
45547 this._abortFunctions = [];
45548 this._tileSubscriptions = {};
45549 this._renderedCurrentLevelTiles = {};
45550 this._renderedTiles = {};
45551 this._background = background;
45552 this._camera = null;
45553 this._imageTileLoader = imageTileLoader;
45554 this._imageTileStore = imageTileStore;
45555 this._renderer = renderer;
45556 this._renderTarget = null;
45559 Object.defineProperty(TextureProvider.prototype, "disposed", {
45563 * @returns {boolean} Value indicating whether provider has
45567 return this._disposed;
45572 Object.defineProperty(TextureProvider.prototype, "hasTexture$", {
45576 * @returns {Observable<boolean>} Observable emitting
45577 * values indicating when the existance of a texture
45586 Object.defineProperty(TextureProvider.prototype, "key", {
45590 * @returns {boolean} The identifier of the image for
45591 * which to render textures.
45599 Object.defineProperty(TextureProvider.prototype, "textureUpdated$", {
45601 * Get textureUpdated$.
45603 * @returns {Observable<boolean>} Observable emitting
45604 * values when an existing texture has been updated.
45607 return this._updated$;
45612 Object.defineProperty(TextureProvider.prototype, "textureCreated$", {
45614 * Get textureCreated$.
45616 * @returns {Observable<boolean>} Observable emitting
45617 * values when a new texture has been created.
45620 return this._created$;
45626 * Abort all outstanding image tile requests.
45628 TextureProvider.prototype.abort = function () {
45629 for (var key in this._tileSubscriptions) {
45630 if (!this._tileSubscriptions.hasOwnProperty(key)) {
45633 this._tileSubscriptions[key].unsubscribe();
45635 this._tileSubscriptions = {};
45636 for (var _i = 0, _a = this._abortFunctions; _i < _a.length; _i++) {
45637 var abort = _a[_i];
45640 this._abortFunctions = [];
45643 * Dispose the provider.
45645 * @description Disposes all cached assets and
45646 * aborts all outstanding image tile requests.
45648 TextureProvider.prototype.dispose = function () {
45649 if (this._disposed) {
45650 console.warn("Texture already disposed (" + this._key + ")");
45654 if (this._renderTarget != null) {
45655 this._renderTarget.dispose();
45656 this._renderTarget = null;
45658 this._imageTileStore.dispose();
45659 this._imageTileStore = null;
45660 this._background = null;
45661 this._camera = null;
45662 this._imageTileLoader = null;
45663 this._renderer = null;
45665 this._createdSubscription.unsubscribe();
45666 this._hasSubscription.unsubscribe();
45667 this._disposed = true;
45670 * Set the region of interest.
45672 * @description When the region of interest is set the
45673 * the tile level is determined and tiles for the region
45674 * are fetched from the store or the loader and renderedLevel
45677 * @param {IRegionOfInterest} roi - Spatial edges to cache.
45679 TextureProvider.prototype.setRegionOfInterest = function (roi) {
45680 if (this._width <= 0 || this._height <= 0) {
45684 var width = 1 / this._roi.pixelWidth;
45685 var height = 1 / this._roi.pixelHeight;
45686 var size = Math.max(height, width);
45687 var currentLevel = Math.max(0, Math.min(this._maxLevel, Math.ceil(Math.log(size) / Math.log(2))));
45688 if (currentLevel !== this._currentLevel) {
45690 this._currentLevel = currentLevel;
45691 if (!(this._currentLevel in this._renderedTiles)) {
45692 this._renderedTiles[this._currentLevel] = [];
45694 this._renderedCurrentLevelTiles = {};
45695 for (var _i = 0, _a = this._renderedTiles[this._currentLevel]; _i < _a.length; _i++) {
45697 this._renderedCurrentLevelTiles[this._tileKey(this._tileSize, tile)] = true;
45700 var topLeft = this._getTileCoords([this._roi.bbox.minX, this._roi.bbox.minY]);
45701 var bottomRight = this._getTileCoords([this._roi.bbox.maxX, this._roi.bbox.maxY]);
45702 var tiles = this._getTiles(topLeft, bottomRight);
45703 if (this._camera == null) {
45704 this._camera = new THREE.OrthographicCamera(-this._width / 2, this._width / 2, this._height / 2, -this._height / 2, -1, 1);
45705 this._camera.position.z = 1;
45706 var gl = this._renderer.getContext();
45707 var maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
45708 var backgroundSize = Math.max(this._width, this._height);
45709 var scale = maxTextureSize > backgroundSize ? 1 : maxTextureSize / backgroundSize;
45710 var targetWidth = Math.floor(scale * this._width);
45711 var targetHeight = Math.floor(scale * this._height);
45712 this._renderTarget = new THREE.WebGLRenderTarget(targetWidth, targetHeight, {
45713 depthBuffer: false,
45714 format: THREE.RGBFormat,
45715 magFilter: THREE.LinearFilter,
45716 minFilter: THREE.LinearFilter,
45717 stencilBuffer: false,
45719 this._renderToTarget(0, 0, this._width, this._height, this._background);
45720 this._createdSubject$.next(this._renderTarget.texture);
45721 this._hasSubject$.next(true);
45723 this._fetchTiles(tiles);
45725 TextureProvider.prototype.setTileSize = function (tileSize) {
45726 this._tileSize = tileSize;
45729 * Update the image used as background for the texture.
45731 * @param {HTMLImageElement} background - The background image.
45733 TextureProvider.prototype.updateBackground = function (background) {
45734 this._background = background;
45737 * Retrieve an image tile.
45739 * @description Retrieve an image tile and render it to the
45740 * texture. Add the tile to the store and emit to the updated
45743 * @param {Array<number>} tile - The tile coordinates.
45744 * @param {number} level - The tile level.
45745 * @param {number} x - The top left x pixel coordinate of the tile.
45746 * @param {number} y - The top left y pixel coordinate of the tile.
45747 * @param {number} w - The pixel width of the tile.
45748 * @param {number} h - The pixel height of the tile.
45749 * @param {number} scaledW - The scaled width of the returned tile.
45750 * @param {number} scaledH - The scaled height of the returned tile.
45752 TextureProvider.prototype._fetchTile = function (tile, level, x, y, w, h, scaledX, scaledY) {
45754 var getTile = this._imageTileLoader.getTile(this._key, x, y, w, h, scaledX, scaledY);
45755 var tile$ = getTile[0];
45756 var abort = getTile[1];
45757 this._abortFunctions.push(abort);
45758 var tileKey = this._tileKey(this._tileSize, tile);
45759 var subscription = tile$
45760 .subscribe(function (image) {
45761 _this._renderToTarget(x, y, w, h, image);
45762 _this._removeFromDictionary(tileKey, _this._tileSubscriptions);
45763 _this._removeFromArray(abort, _this._abortFunctions);
45764 _this._setTileRendered(tile, _this._currentLevel);
45765 _this._imageTileStore.addImage(image, tileKey, level);
45766 _this._updated$.next(true);
45767 }, function (error) {
45768 _this._removeFromDictionary(tileKey, _this._tileSubscriptions);
45769 _this._removeFromArray(abort, _this._abortFunctions);
45770 console.error(error);
45772 if (!subscription.closed) {
45773 this._tileSubscriptions[tileKey] = subscription;
45777 * Retrieve image tiles.
45779 * @description Retrieve a image tiles and render them to the
45780 * texture. Retrieve from store if it exists, otherwise Retrieve
45783 * @param {Array<Array<number>>} tiles - Array of tile coordinates to
45786 TextureProvider.prototype._fetchTiles = function (tiles) {
45787 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
45788 for (var _i = 0, tiles_1 = tiles; _i < tiles_1.length; _i++) {
45789 var tile = tiles_1[_i];
45790 var tileKey = this._tileKey(this._tileSize, tile);
45791 if (tileKey in this._renderedCurrentLevelTiles ||
45792 tileKey in this._tileSubscriptions) {
45795 var tileX = tileSize * tile[0];
45796 var tileY = tileSize * tile[1];
45797 var tileWidth = tileX + tileSize > this._width ? this._width - tileX : tileSize;
45798 var tileHeight = tileY + tileSize > this._height ? this._height - tileY : tileSize;
45799 if (this._imageTileStore.hasImage(tileKey, this._currentLevel)) {
45800 this._renderToTarget(tileX, tileY, tileWidth, tileHeight, this._imageTileStore.getImage(tileKey, this._currentLevel));
45801 this._setTileRendered(tile, this._currentLevel);
45802 this._updated$.next(true);
45805 var scaledX = Math.floor(tileWidth / tileSize * this._tileSize);
45806 var scaledY = Math.floor(tileHeight / tileSize * this._tileSize);
45807 this._fetchTile(tile, this._currentLevel, tileX, tileY, tileWidth, tileHeight, scaledX, scaledY);
45811 * Get tile coordinates for a point using the current level.
45813 * @param {Array<number>} point - Point in basic coordinates.
45815 * @returns {Array<number>} x and y tile coodinates.
45817 TextureProvider.prototype._getTileCoords = function (point) {
45818 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
45819 var maxX = Math.ceil(this._width / tileSize) - 1;
45820 var maxY = Math.ceil(this._height / tileSize) - 1;
45822 Math.min(Math.floor(this._width * point[0] / tileSize), maxX),
45823 Math.min(Math.floor(this._height * point[1] / tileSize), maxY),
45827 * Get tile coordinates for all tiles contained in a bounding
45830 * @param {Array<number>} topLeft - Top left tile coordinate of bounding box.
45831 * @param {Array<number>} bottomRight - Bottom right tile coordinate of bounding box.
45833 * @returns {Array<Array<number>>} Array of x, y tile coodinates.
45835 TextureProvider.prototype._getTiles = function (topLeft, bottomRight) {
45837 if (topLeft[0] > bottomRight[0]) {
45838 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
45839 var maxX = Math.ceil(this._width / tileSize) - 1;
45840 for (var x = topLeft[0]; x <= maxX; x++) {
45843 for (var x = 0; x <= bottomRight[0]; x++) {
45848 for (var x = topLeft[0]; x <= bottomRight[0]; x++) {
45853 for (var _i = 0, xs_1 = xs; _i < xs_1.length; _i++) {
45855 for (var y = topLeft[1]; y <= bottomRight[1]; y++) {
45856 tiles.push([x, y]);
45862 * Remove an item from an array if it exists in array.
45864 * @param {T} item - Item to remove.
45865 * @param {Array<T>} array - Array from which item should be removed.
45867 TextureProvider.prototype._removeFromArray = function (item, array) {
45868 var index = array.indexOf(item);
45869 if (index !== -1) {
45870 array.splice(index, 1);
45874 * Remove an item from a dictionary.
45876 * @param {string} key - Key of the item to remove.
45877 * @param {Object} dict - Dictionary from which item should be removed.
45879 TextureProvider.prototype._removeFromDictionary = function (key, dict) {
45885 * Render an image tile to the target texture.
45887 * @param {number} x - The top left x pixel coordinate of the tile.
45888 * @param {number} y - The top left y pixel coordinate of the tile.
45889 * @param {number} w - The pixel width of the tile.
45890 * @param {number} h - The pixel height of the tile.
45891 * @param {HTMLImageElement} background - The image tile to render.
45893 TextureProvider.prototype._renderToTarget = function (x, y, w, h, image) {
45894 var texture = new THREE.Texture(image);
45895 texture.minFilter = THREE.LinearFilter;
45896 texture.needsUpdate = true;
45897 var geometry = new THREE.PlaneGeometry(w, h);
45898 var material = new THREE.MeshBasicMaterial({ map: texture, side: THREE.FrontSide });
45899 var mesh = new THREE.Mesh(geometry, material);
45900 mesh.position.x = -this._width / 2 + x + w / 2;
45901 mesh.position.y = this._height / 2 - y - h / 2;
45902 var scene = new THREE.Scene();
45904 this._renderer.render(scene, this._camera, this._renderTarget);
45905 this._renderer.setRenderTarget(undefined);
45906 scene.remove(mesh);
45907 geometry.dispose();
45908 material.dispose();
45912 * Mark a tile as rendered.
45914 * @description Clears tiles marked as rendered in other
45915 * levels of the tile pyramid if they were rendered on
45916 * top of or below the tile.
45918 * @param {Arrary<number>} tile - The tile coordinates.
45919 * @param {number} level - Tile level of the tile coordinates.
45921 TextureProvider.prototype._setTileRendered = function (tile, level) {
45922 var otherLevels = Object.keys(this._renderedTiles)
45923 .map(function (key) {
45924 return parseInt(key, 10);
45926 .filter(function (renderedLevel) {
45927 return renderedLevel !== level;
45929 for (var _i = 0, otherLevels_1 = otherLevels; _i < otherLevels_1.length; _i++) {
45930 var otherLevel = otherLevels_1[_i];
45931 var scale = Math.pow(2, otherLevel - level);
45932 if (otherLevel < level) {
45933 var x = Math.floor(scale * tile[0]);
45934 var y = Math.floor(scale * tile[1]);
45935 for (var _a = 0, _b = this._renderedTiles[otherLevel].slice(); _a < _b.length; _a++) {
45936 var otherTile = _b[_a];
45937 if (otherTile[0] === x && otherTile[1] === y) {
45938 var index = this._renderedTiles[otherLevel].indexOf(otherTile);
45939 this._renderedTiles[otherLevel].splice(index, 1);
45944 var startX = scale * tile[0];
45945 var endX = startX + scale - 1;
45946 var startY = scale * tile[1];
45947 var endY = startY + scale - 1;
45948 for (var _c = 0, _d = this._renderedTiles[otherLevel].slice(); _c < _d.length; _c++) {
45949 var otherTile = _d[_c];
45950 if (otherTile[0] >= startX && otherTile[0] <= endX &&
45951 otherTile[1] >= startY && otherTile[1] <= endY) {
45952 var index = this._renderedTiles[otherLevel].indexOf(otherTile);
45953 this._renderedTiles[otherLevel].splice(index, 1);
45957 if (this._renderedTiles[otherLevel].length === 0) {
45958 delete this._renderedTiles[otherLevel];
45961 this._renderedTiles[level].push(tile);
45962 this._renderedCurrentLevelTiles[this._tileKey(this._tileSize, tile)] = true;
45965 * Create a tile key from a tile coordinates.
45967 * @description Tile keys are used as a hash for
45968 * storing the tile in a dictionary.
45970 * @param {number} tileSize - The tile size.
45971 * @param {Arrary<number>} tile - The tile coordinates.
45973 TextureProvider.prototype._tileKey = function (tileSize, tile) {
45974 return tileSize + "-" + tile[0] + "-" + tile[1];
45976 return TextureProvider;
45978 exports.TextureProvider = TextureProvider;
45979 exports.default = TextureProvider;
45981 },{"rxjs":27,"rxjs/operators":225,"three":226}],426:[function(require,module,exports){
45983 Object.defineProperty(exports, "__esModule", { value: true });
45984 var DOM = /** @class */ (function () {
45985 function DOM(doc) {
45986 this._document = !!doc ? doc : document;
45988 Object.defineProperty(DOM.prototype, "document", {
45990 return this._document;
45995 DOM.prototype.createElement = function (tagName, className, container) {
45996 var element = this._document.createElement(tagName);
45998 element.className = className;
46001 container.appendChild(element);
46008 exports.default = DOM;
46010 },{}],427:[function(require,module,exports){
46012 Object.defineProperty(exports, "__esModule", { value: true });
46013 var EventEmitter = /** @class */ (function () {
46014 function EventEmitter() {
46018 * Subscribe to an event by its name.
46019 * @param {string }eventType - The name of the event to subscribe to.
46020 * @param {any} fn - The handler called when the event occurs.
46022 EventEmitter.prototype.on = function (eventType, fn) {
46023 this._events[eventType] = this._events[eventType] || [];
46024 this._events[eventType].push(fn);
46028 * Unsubscribe from an event by its name.
46029 * @param {string} eventType - The name of the event to subscribe to.
46030 * @param {any} fn - The handler to remove.
46032 EventEmitter.prototype.off = function (eventType, fn) {
46037 if (!this._listens(eventType)) {
46038 var idx = this._events[eventType].indexOf(fn);
46040 this._events[eventType].splice(idx, 1);
46042 if (this._events[eventType].length) {
46043 delete this._events[eventType];
46047 delete this._events[eventType];
46051 EventEmitter.prototype.fire = function (eventType, data) {
46052 if (!this._listens(eventType)) {
46055 for (var _i = 0, _a = this._events[eventType]; _i < _a.length; _i++) {
46057 fn.call(this, data);
46061 EventEmitter.prototype._listens = function (eventType) {
46062 return !!(this._events && this._events[eventType]);
46064 return EventEmitter;
46066 exports.EventEmitter = EventEmitter;
46067 exports.default = EventEmitter;
46069 },{}],428:[function(require,module,exports){
46071 Object.defineProperty(exports, "__esModule", { value: true });
46072 var Viewer_1 = require("../Viewer");
46073 var Settings = /** @class */ (function () {
46074 function Settings() {
46076 Settings.setOptions = function (options) {
46077 Settings._baseImageSize = options.baseImageSize != null ?
46078 options.baseImageSize :
46079 Viewer_1.ImageSize.Size640;
46080 Settings._basePanoramaSize = options.basePanoramaSize != null ?
46081 options.basePanoramaSize :
46082 Viewer_1.ImageSize.Size2048;
46083 Settings._maxImageSize = options.maxImageSize != null ?
46084 options.maxImageSize :
46085 Viewer_1.ImageSize.Size2048;
46087 Object.defineProperty(Settings, "baseImageSize", {
46089 return Settings._baseImageSize;
46094 Object.defineProperty(Settings, "basePanoramaSize", {
46096 return Settings._basePanoramaSize;
46101 Object.defineProperty(Settings, "maxImageSize", {
46103 return Settings._maxImageSize;
46110 exports.Settings = Settings;
46111 exports.default = Settings;
46113 },{"../Viewer":286}],429:[function(require,module,exports){
46115 Object.defineProperty(exports, "__esModule", { value: true });
46116 function isBrowser() {
46117 return typeof window !== "undefined" && typeof document !== "undefined";
46119 exports.isBrowser = isBrowser;
46120 function isArraySupported() {
46121 return !!(Array.prototype &&
46122 Array.prototype.filter &&
46123 Array.prototype.indexOf &&
46124 Array.prototype.map &&
46125 Array.prototype.reverse);
46127 exports.isArraySupported = isArraySupported;
46128 function isFunctionSupported() {
46129 return !!(Function.prototype && Function.prototype.bind);
46131 exports.isFunctionSupported = isFunctionSupported;
46132 function isJSONSupported() {
46133 return "JSON" in window && "parse" in JSON && "stringify" in JSON;
46135 exports.isJSONSupported = isJSONSupported;
46136 function isObjectSupported() {
46137 return !!(Object.keys &&
46140 exports.isObjectSupported = isObjectSupported;
46141 function isBlobSupported() {
46142 return "Blob" in window && "URL" in window;
46144 exports.isBlobSupported = isBlobSupported;
46145 var isWebGLSupportedCache = undefined;
46146 function isWebGLSupportedCached() {
46147 if (isWebGLSupportedCache === undefined) {
46148 isWebGLSupportedCache = isWebGLSupported();
46150 return isWebGLSupportedCache;
46152 exports.isWebGLSupportedCached = isWebGLSupportedCached;
46153 function isWebGLSupported() {
46154 var webGLContextAttributes = {
46158 failIfMajorPerformanceCaveat: false,
46159 premultipliedAlpha: true,
46160 preserveDrawingBuffer: false,
46163 var canvas = document.createElement("canvas");
46164 var context = canvas.getContext("webgl", webGLContextAttributes) ||
46165 canvas.getContext("experimental-webgl", webGLContextAttributes);
46169 var requiredExtensions = [
46170 "OES_standard_derivatives",
46172 var supportedExtensions = context.getSupportedExtensions();
46173 for (var _i = 0, requiredExtensions_1 = requiredExtensions; _i < requiredExtensions_1.length; _i++) {
46174 var requiredExtension = requiredExtensions_1[_i];
46175 if (supportedExtensions.indexOf(requiredExtension) === -1) {
46181 exports.isWebGLSupported = isWebGLSupported;
46183 },{}],430:[function(require,module,exports){
46185 Object.defineProperty(exports, "__esModule", { value: true });
46186 var Urls = /** @class */ (function () {
46189 Object.defineProperty(Urls, "explore", {
46191 return Urls._scheme + "://" + Urls._exploreHost;
46196 Object.defineProperty(Urls, "origin", {
46198 return Urls._origin;
46203 Object.defineProperty(Urls, "tileScheme", {
46205 return Urls._scheme;
46210 Object.defineProperty(Urls, "tileDomain", {
46212 return Urls._imageTileHost;
46217 Urls.atomicReconstruction = function (key) {
46218 return Urls._scheme + "://" + Urls._atomicReconstructionHost + "/" + key + "/sfm/v1.0/atomic_reconstruction.json";
46220 Urls.exporeImage = function (key) {
46221 return Urls._scheme + "://" + Urls._exploreHost + "/app/?pKey=" + key + "&focus=photo";
46223 Urls.exporeUser = function (username) {
46224 return Urls._scheme + "://" + Urls._exploreHost + "/app/user/" + username;
46226 Urls.falcorModel = function (clientId) {
46227 return Urls._scheme + "://" + Urls._apiHost + "/v3/model.json?client_id=" + clientId;
46229 Urls.protoMesh = function (key) {
46230 return Urls._scheme + "://" + Urls._meshHost + "/v2/mesh/" + key;
46232 Urls.thumbnail = function (key, size, origin) {
46233 var query = !!origin ? "?origin=" + origin : "";
46234 return Urls._scheme + "://" + Urls._imageHost + "/" + key + "/thumb-" + size + ".jpg" + query;
46236 Urls.setOptions = function (options) {
46240 if (!!options.apiHost) {
46241 Urls._apiHost = options.apiHost;
46243 if (!!options.atomicReconstructionHost) {
46244 Urls._atomicReconstructionHost = options.atomicReconstructionHost;
46246 if (!!options.exploreHost) {
46247 Urls._exploreHost = options.exploreHost;
46249 if (!!options.imageHost) {
46250 Urls._imageHost = options.imageHost;
46252 if (!!options.imageTileHost) {
46253 Urls._imageTileHost = options.imageTileHost;
46255 if (!!options.meshHost) {
46256 Urls._meshHost = options.meshHost;
46258 if (!!options.scheme) {
46259 Urls._scheme = options.scheme;
46262 Urls._apiHost = "a.mapillary.com";
46263 Urls._atomicReconstructionHost = "d3necqxnn15whe.cloudfront.net";
46264 Urls._exploreHost = "www.mapillary.com";
46265 Urls._imageHost = "d1cuyjsrcm0gby.cloudfront.net";
46266 Urls._imageTileHost = "d2qb1440i7l50o.cloudfront.net";
46267 Urls._meshHost = "d1brzeo354iq2l.cloudfront.net";
46268 Urls._origin = "mapillary.webgl";
46269 Urls._scheme = "https";
46272 exports.Urls = Urls;
46273 exports.default = Urls;
46275 },{}],431:[function(require,module,exports){
46277 Object.defineProperty(exports, "__esModule", { value: true });
46279 * Enumeration for alignments
46284 (function (Alignment) {
46288 Alignment[Alignment["Bottom"] = 0] = "Bottom";
46290 * Align to bottom left
46292 Alignment[Alignment["BottomLeft"] = 1] = "BottomLeft";
46294 * Align to bottom right
46296 Alignment[Alignment["BottomRight"] = 2] = "BottomRight";
46300 Alignment[Alignment["Center"] = 3] = "Center";
46304 Alignment[Alignment["Left"] = 4] = "Left";
46308 Alignment[Alignment["Right"] = 5] = "Right";
46312 Alignment[Alignment["Top"] = 6] = "Top";
46314 * Align to top left
46316 Alignment[Alignment["TopLeft"] = 7] = "TopLeft";
46318 * Align to top right
46320 Alignment[Alignment["TopRight"] = 8] = "TopRight";
46321 })(Alignment = exports.Alignment || (exports.Alignment = {}));
46322 exports.default = Alignment;
46324 },{}],432:[function(require,module,exports){
46326 Object.defineProperty(exports, "__esModule", { value: true });
46327 var rxjs_1 = require("rxjs");
46328 var operators_1 = require("rxjs/operators");
46329 var Graph_1 = require("../Graph");
46330 var CacheService = /** @class */ (function () {
46331 function CacheService(graphService, stateService) {
46332 this._graphService = graphService;
46333 this._stateService = stateService;
46334 this._started = false;
46336 Object.defineProperty(CacheService.prototype, "started", {
46338 return this._started;
46343 CacheService.prototype.start = function () {
46345 if (this._started) {
46348 this._uncacheSubscription = this._stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
46349 return frame.state.currentNode.key;
46350 }), operators_1.map(function (frame) {
46351 var trajectory = frame.state.trajectory;
46352 var trajectoryKeys = trajectory
46353 .map(function (n) {
46356 var sequenceKey = trajectory[trajectory.length - 1].sequenceKey;
46357 return [trajectoryKeys, sequenceKey];
46358 }), operators_1.bufferCount(1, 5), operators_1.withLatestFrom(this._graphService.graphMode$), operators_1.switchMap(function (_a) {
46359 var keepBuffer = _a[0], graphMode = _a[1];
46360 var keepKeys = keepBuffer[0][0];
46361 var keepSequenceKey = graphMode === Graph_1.GraphMode.Sequence ?
46362 keepBuffer[0][1] : undefined;
46363 return _this._graphService.uncache$(keepKeys, keepSequenceKey);
46365 .subscribe(function () { });
46366 this._cacheNodeSubscription = this._graphService.graphMode$.pipe(operators_1.skip(1), operators_1.withLatestFrom(this._stateService.currentState$), operators_1.switchMap(function (_a) {
46367 var mode = _a[0], frame = _a[1];
46368 return mode === Graph_1.GraphMode.Sequence ?
46369 _this._keyToEdges(frame.state.currentNode.key, function (node) {
46370 return node.sequenceEdges$;
46372 rxjs_1.from(frame.state.trajectory
46373 .map(function (node) {
46376 .slice(frame.state.currentIndex)).pipe(operators_1.mergeMap(function (key) {
46377 return _this._keyToEdges(key, function (node) {
46378 return node.spatialEdges$;
46382 .subscribe(function () { });
46383 this._started = true;
46385 CacheService.prototype.stop = function () {
46386 if (!this._started) {
46389 this._uncacheSubscription.unsubscribe();
46390 this._uncacheSubscription = null;
46391 this._cacheNodeSubscription.unsubscribe();
46392 this._cacheNodeSubscription = null;
46393 this._started = false;
46395 CacheService.prototype._keyToEdges = function (key, nodeToEdgeMap) {
46396 return this._graphService.cacheNode$(key).pipe(operators_1.switchMap(nodeToEdgeMap), operators_1.first(function (status) {
46397 return status.cached;
46398 }), operators_1.timeout(15000), operators_1.catchError(function (error) {
46399 console.error("Failed to cache edges (" + key + ").", error);
46400 return rxjs_1.empty();
46403 return CacheService;
46405 exports.CacheService = CacheService;
46406 exports.default = CacheService;
46408 },{"../Graph":279,"rxjs":27,"rxjs/operators":225}],433:[function(require,module,exports){
46410 Object.defineProperty(exports, "__esModule", { value: true });
46411 var operators_1 = require("rxjs/operators");
46412 var Component_1 = require("../Component");
46413 var ComponentController = /** @class */ (function () {
46414 function ComponentController(container, navigator, observer, key, options, componentService) {
46416 this._container = container;
46417 this._observer = observer;
46418 this._navigator = navigator;
46419 this._options = options != null ? options : {};
46421 this._navigable = key == null;
46422 this._componentService = !!componentService ?
46424 new Component_1.ComponentService(this._container, this._navigator);
46425 this._coverComponent = this._componentService.getCover();
46426 this._initializeComponents();
46428 this._initilizeCoverComponent();
46429 this._subscribeCoverComponent();
46432 this._navigator.movedToKey$.pipe(operators_1.first(function (k) {
46435 .subscribe(function (k) {
46437 _this._componentService.deactivateCover();
46438 _this._coverComponent.configure({ key: _this._key, state: Component_1.CoverState.Hidden });
46439 _this._subscribeCoverComponent();
46440 _this._navigator.stateService.start();
46441 _this._navigator.cacheService.start();
46442 _this._observer.startEmit();
46446 Object.defineProperty(ComponentController.prototype, "navigable", {
46448 return this._navigable;
46453 ComponentController.prototype.get = function (name) {
46454 return this._componentService.get(name);
46456 ComponentController.prototype.activate = function (name) {
46457 this._componentService.activate(name);
46459 ComponentController.prototype.activateCover = function () {
46460 this._coverComponent.configure({ state: Component_1.CoverState.Visible });
46462 ComponentController.prototype.deactivate = function (name) {
46463 this._componentService.deactivate(name);
46465 ComponentController.prototype.deactivateCover = function () {
46466 this._coverComponent.configure({ state: Component_1.CoverState.Loading });
46468 ComponentController.prototype._initializeComponents = function () {
46469 var options = this._options;
46470 this._uFalse(options.background, "background");
46471 this._uFalse(options.debug, "debug");
46472 this._uFalse(options.image, "image");
46473 this._uFalse(options.marker, "marker");
46474 this._uFalse(options.navigation, "navigation");
46475 this._uFalse(options.popup, "popup");
46476 this._uFalse(options.route, "route");
46477 this._uFalse(options.slider, "slider");
46478 this._uFalse(options.spatialData, "spatialData");
46479 this._uFalse(options.tag, "tag");
46480 this._uTrue(options.attribution, "attribution");
46481 this._uTrue(options.bearing, "bearing");
46482 this._uTrue(options.cache, "cache");
46483 this._uTrue(options.direction, "direction");
46484 this._uTrue(options.imagePlane, "imagePlane");
46485 this._uTrue(options.keyboard, "keyboard");
46486 this._uTrue(options.loading, "loading");
46487 this._uTrue(options.mouse, "mouse");
46488 this._uTrue(options.sequence, "sequence");
46489 this._uTrue(options.stats, "stats");
46490 this._uTrue(options.zoom, "zoom");
46492 ComponentController.prototype._initilizeCoverComponent = function () {
46493 var options = this._options;
46494 this._coverComponent.configure({ key: this._key });
46495 if (options.cover === undefined || options.cover) {
46496 this.activateCover();
46499 this.deactivateCover();
46502 ComponentController.prototype._setNavigable = function (navigable) {
46503 if (this._navigable === navigable) {
46506 this._navigable = navigable;
46507 this._observer.navigable$.next(navigable);
46509 ComponentController.prototype._subscribeCoverComponent = function () {
46511 this._coverComponent.configuration$.pipe(operators_1.distinctUntilChanged(undefined, function (c) {
46514 .subscribe(function (conf) {
46515 if (conf.state === Component_1.CoverState.Loading) {
46516 _this._navigator.stateService.currentKey$.pipe(operators_1.first(), operators_1.switchMap(function (key) {
46517 var keyChanged = key == null || key !== conf.key;
46519 _this._setNavigable(false);
46521 return keyChanged ?
46522 _this._navigator.moveToKey$(conf.key) :
46523 _this._navigator.stateService.currentNode$.pipe(operators_1.first());
46525 .subscribe(function () {
46526 _this._navigator.stateService.start();
46527 _this._navigator.cacheService.start();
46528 _this._observer.startEmit();
46529 _this._coverComponent.configure({ state: Component_1.CoverState.Hidden });
46530 _this._componentService.deactivateCover();
46531 _this._setNavigable(true);
46532 }, function (error) {
46533 console.error("Failed to deactivate cover.", error);
46534 _this._coverComponent.configure({ state: Component_1.CoverState.Visible });
46537 else if (conf.state === Component_1.CoverState.Visible) {
46538 _this._observer.stopEmit();
46539 _this._navigator.stateService.stop();
46540 _this._navigator.cacheService.stop();
46541 _this._navigator.playService.stop();
46542 _this._componentService.activateCover();
46543 _this._setNavigable(conf.key == null);
46547 ComponentController.prototype._uFalse = function (option, name) {
46548 if (option === undefined) {
46549 this._componentService.deactivate(name);
46552 if (typeof option === "boolean") {
46554 this._componentService.activate(name);
46557 this._componentService.deactivate(name);
46561 this._componentService.configure(name, option);
46562 this._componentService.activate(name);
46564 ComponentController.prototype._uTrue = function (option, name) {
46565 if (option === undefined) {
46566 this._componentService.activate(name);
46569 if (typeof option === "boolean") {
46571 this._componentService.activate(name);
46574 this._componentService.deactivate(name);
46578 this._componentService.configure(name, option);
46579 this._componentService.activate(name);
46581 return ComponentController;
46583 exports.ComponentController = ComponentController;
46585 },{"../Component":275,"rxjs/operators":225}],434:[function(require,module,exports){
46587 Object.defineProperty(exports, "__esModule", { value: true });
46588 var Render_1 = require("../Render");
46589 var Utils_1 = require("../Utils");
46590 var Viewer_1 = require("../Viewer");
46591 var Container = /** @class */ (function () {
46592 function Container(id, stateService, options, dom) {
46594 this._dom = !!dom ? dom : new Utils_1.DOM();
46595 this._container = this._dom.document.getElementById(id);
46596 if (!this._container) {
46597 throw new Error("Container '" + id + "' not found.");
46599 this._container.classList.add("mapillary-js");
46600 this._canvasContainer = this._dom.createElement("div", "mapillary-js-interactive", this._container);
46601 this._domContainer = this._dom.createElement("div", "mapillary-js-dom", this._container);
46602 this.renderService = new Render_1.RenderService(this._container, stateService.currentState$, options.renderMode);
46603 this.glRenderer = new Render_1.GLRenderer(this._canvasContainer, this.renderService, this._dom);
46604 this.domRenderer = new Render_1.DOMRenderer(this._domContainer, this.renderService, stateService.currentState$);
46605 this.keyboardService = new Viewer_1.KeyboardService(this._canvasContainer);
46606 this.mouseService = new Viewer_1.MouseService(this._container, this._canvasContainer, this._domContainer, document);
46607 this.touchService = new Viewer_1.TouchService(this._canvasContainer, this._domContainer);
46608 this.spriteService = new Viewer_1.SpriteService(options.sprite);
46610 Object.defineProperty(Container.prototype, "element", {
46612 return this._container;
46617 Object.defineProperty(Container.prototype, "canvasContainer", {
46619 return this._canvasContainer;
46624 Object.defineProperty(Container.prototype, "domContainer", {
46626 return this._domContainer;
46633 exports.Container = Container;
46634 exports.default = Container;
46636 },{"../Render":281,"../Utils":285,"../Viewer":286}],435:[function(require,module,exports){
46638 Object.defineProperty(exports, "__esModule", { value: true });
46640 * Enumeration for image sizes
46643 * @description Image sizes in pixels for the long side of the image.
46646 (function (ImageSize) {
46648 * 320 pixels image size
46650 ImageSize[ImageSize["Size320"] = 320] = "Size320";
46652 * 640 pixels image size
46654 ImageSize[ImageSize["Size640"] = 640] = "Size640";
46656 * 1024 pixels image size
46658 ImageSize[ImageSize["Size1024"] = 1024] = "Size1024";
46660 * 2048 pixels image size
46662 ImageSize[ImageSize["Size2048"] = 2048] = "Size2048";
46663 })(ImageSize = exports.ImageSize || (exports.ImageSize = {}));
46665 },{}],436:[function(require,module,exports){
46667 Object.defineProperty(exports, "__esModule", { value: true });
46668 var rxjs_1 = require("rxjs");
46669 var KeyboardService = /** @class */ (function () {
46670 function KeyboardService(canvasContainer) {
46671 this._keyDown$ = rxjs_1.fromEvent(canvasContainer, "keydown");
46672 this._keyUp$ = rxjs_1.fromEvent(canvasContainer, "keyup");
46674 Object.defineProperty(KeyboardService.prototype, "keyDown$", {
46676 return this._keyDown$;
46681 Object.defineProperty(KeyboardService.prototype, "keyUp$", {
46683 return this._keyUp$;
46688 return KeyboardService;
46690 exports.KeyboardService = KeyboardService;
46691 exports.default = KeyboardService;
46693 },{"rxjs":27}],437:[function(require,module,exports){
46695 Object.defineProperty(exports, "__esModule", { value: true });
46696 var operators_1 = require("rxjs/operators");
46697 var rxjs_1 = require("rxjs");
46698 var LoadingService = /** @class */ (function () {
46699 function LoadingService() {
46700 this._loadersSubject$ = new rxjs_1.Subject();
46701 this._loaders$ = this._loadersSubject$.pipe(operators_1.scan(function (loaders, loader) {
46702 if (loader.task !== undefined) {
46703 loaders[loader.task] = loader.loading;
46706 }, {}), operators_1.startWith({}), operators_1.publishReplay(1), operators_1.refCount());
46708 Object.defineProperty(LoadingService.prototype, "loading$", {
46710 return this._loaders$.pipe(operators_1.map(function (loaders) {
46711 for (var key in loaders) {
46712 if (!loaders.hasOwnProperty(key)) {
46715 if (loaders[key]) {
46720 }), operators_1.debounceTime(100), operators_1.distinctUntilChanged());
46725 LoadingService.prototype.taskLoading$ = function (task) {
46726 return this._loaders$.pipe(operators_1.map(function (loaders) {
46727 return !!loaders[task];
46728 }), operators_1.debounceTime(100), operators_1.distinctUntilChanged());
46730 LoadingService.prototype.startLoading = function (task) {
46731 this._loadersSubject$.next({ loading: true, task: task });
46733 LoadingService.prototype.stopLoading = function (task) {
46734 this._loadersSubject$.next({ loading: false, task: task });
46736 return LoadingService;
46738 exports.LoadingService = LoadingService;
46739 exports.default = LoadingService;
46741 },{"rxjs":27,"rxjs/operators":225}],438:[function(require,module,exports){
46743 Object.defineProperty(exports, "__esModule", { value: true });
46744 var rxjs_1 = require("rxjs");
46745 var operators_1 = require("rxjs/operators");
46746 var MouseService = /** @class */ (function () {
46747 function MouseService(container, canvasContainer, domContainer, doc) {
46749 this._activeSubject$ = new rxjs_1.BehaviorSubject(false);
46750 this._active$ = this._activeSubject$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
46751 this._claimMouse$ = new rxjs_1.Subject();
46752 this._claimWheel$ = new rxjs_1.Subject();
46753 this._deferPixelClaims$ = new rxjs_1.Subject();
46754 this._deferPixels$ = this._deferPixelClaims$.pipe(operators_1.scan(function (claims, claim) {
46755 if (claim.deferPixels == null) {
46756 delete claims[claim.name];
46759 claims[claim.name] = claim.deferPixels;
46762 }, {}), operators_1.map(function (claims) {
46763 var deferPixelMax = -1;
46764 for (var key in claims) {
46765 if (!claims.hasOwnProperty(key)) {
46768 var deferPixels = claims[key];
46769 if (deferPixels > deferPixelMax) {
46770 deferPixelMax = deferPixels;
46773 return deferPixelMax;
46774 }), operators_1.startWith(-1), operators_1.publishReplay(1), operators_1.refCount());
46775 this._deferPixels$.subscribe(function () { });
46776 this._documentMouseMove$ = rxjs_1.fromEvent(doc, "mousemove");
46777 this._documentMouseUp$ = rxjs_1.fromEvent(doc, "mouseup");
46778 this._mouseDown$ = rxjs_1.fromEvent(canvasContainer, "mousedown");
46779 this._mouseLeave$ = rxjs_1.fromEvent(canvasContainer, "mouseleave");
46780 this._mouseMove$ = rxjs_1.fromEvent(canvasContainer, "mousemove");
46781 this._mouseUp$ = rxjs_1.fromEvent(canvasContainer, "mouseup");
46782 this._mouseOut$ = rxjs_1.fromEvent(canvasContainer, "mouseout");
46783 this._mouseOver$ = rxjs_1.fromEvent(canvasContainer, "mouseover");
46784 this._domMouseDown$ = rxjs_1.fromEvent(domContainer, "mousedown");
46785 this._domMouseMove$ = rxjs_1.fromEvent(domContainer, "mousemove");
46786 this._click$ = rxjs_1.fromEvent(canvasContainer, "click");
46787 this._contextMenu$ = rxjs_1.fromEvent(canvasContainer, "contextmenu");
46788 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) {
46789 var event1 = events[0];
46790 var event2 = events[1];
46791 var event3 = events[2];
46792 return event1.type === "click" &&
46793 event2.type === "click" &&
46794 event3.type === "dblclick" &&
46795 event1.target.parentNode === canvasContainer &&
46796 event2.target.parentNode === canvasContainer;
46797 }), operators_1.map(function (events) {
46799 }), operators_1.share());
46800 rxjs_1.merge(this._domMouseDown$, this._domMouseMove$, this._dblClick$, this._contextMenu$)
46801 .subscribe(function (event) {
46802 event.preventDefault();
46804 this._mouseWheel$ = rxjs_1.merge(rxjs_1.fromEvent(canvasContainer, "wheel"), rxjs_1.fromEvent(domContainer, "wheel")).pipe(operators_1.share());
46805 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) {
46806 // fire context menu on mouse up both on mac and windows
46807 return events[0].type === "mousedown" &&
46808 events[1].type === "contextmenu" &&
46809 events[2].type === "mouseup";
46810 }), operators_1.map(function (events) {
46812 }), operators_1.share());
46813 var dragStop$ = rxjs_1.merge(rxjs_1.fromEvent(window, "blur"), this._documentMouseUp$.pipe(operators_1.filter(function (e) {
46814 return e.button === 0;
46815 }))).pipe(operators_1.share());
46816 var mouseDragInitiate$ = this._createMouseDragInitiate$(this._mouseDown$, dragStop$, true).pipe(operators_1.share());
46817 this._mouseDragStart$ = this._createMouseDragStart$(mouseDragInitiate$).pipe(operators_1.share());
46818 this._mouseDrag$ = this._createMouseDrag$(mouseDragInitiate$, dragStop$).pipe(operators_1.share());
46819 this._mouseDragEnd$ = this._createMouseDragEnd$(this._mouseDragStart$, dragStop$).pipe(operators_1.share());
46820 var domMouseDragInitiate$ = this._createMouseDragInitiate$(this._domMouseDown$, dragStop$, false).pipe(operators_1.share());
46821 this._domMouseDragStart$ = this._createMouseDragStart$(domMouseDragInitiate$).pipe(operators_1.share());
46822 this._domMouseDrag$ = this._createMouseDrag$(domMouseDragInitiate$, dragStop$).pipe(operators_1.share());
46823 this._domMouseDragEnd$ = this._createMouseDragEnd$(this._domMouseDragStart$, dragStop$).pipe(operators_1.share());
46824 this._proximateClick$ = this._mouseDown$.pipe(operators_1.switchMap(function (mouseDown) {
46825 return _this._click$.pipe(operators_1.takeUntil(_this._createDeferredMouseMove$(mouseDown, _this._documentMouseMove$)), operators_1.take(1));
46826 }), operators_1.share());
46827 this._staticClick$ = this._mouseDown$.pipe(operators_1.switchMap(function (e) {
46828 return _this._click$.pipe(operators_1.takeUntil(_this._documentMouseMove$), operators_1.take(1));
46829 }), operators_1.share());
46830 this._mouseDragStart$.subscribe();
46831 this._mouseDrag$.subscribe();
46832 this._mouseDragEnd$.subscribe();
46833 this._domMouseDragStart$.subscribe();
46834 this._domMouseDrag$.subscribe();
46835 this._domMouseDragEnd$.subscribe();
46836 this._staticClick$.subscribe();
46837 this._mouseOwner$ = this._createOwner$(this._claimMouse$).pipe(operators_1.publishReplay(1), operators_1.refCount());
46838 this._wheelOwner$ = this._createOwner$(this._claimWheel$).pipe(operators_1.publishReplay(1), operators_1.refCount());
46839 this._mouseOwner$.subscribe(function () { });
46840 this._wheelOwner$.subscribe(function () { });
46842 Object.defineProperty(MouseService.prototype, "active$", {
46844 return this._active$;
46849 Object.defineProperty(MouseService.prototype, "activate$", {
46851 return this._activeSubject$;
46856 Object.defineProperty(MouseService.prototype, "documentMouseMove$", {
46858 return this._documentMouseMove$;
46863 Object.defineProperty(MouseService.prototype, "documentMouseUp$", {
46865 return this._documentMouseUp$;
46870 Object.defineProperty(MouseService.prototype, "domMouseDragStart$", {
46872 return this._domMouseDragStart$;
46877 Object.defineProperty(MouseService.prototype, "domMouseDrag$", {
46879 return this._domMouseDrag$;
46884 Object.defineProperty(MouseService.prototype, "domMouseDragEnd$", {
46886 return this._domMouseDragEnd$;
46891 Object.defineProperty(MouseService.prototype, "domMouseDown$", {
46893 return this._domMouseDown$;
46898 Object.defineProperty(MouseService.prototype, "domMouseMove$", {
46900 return this._domMouseMove$;
46905 Object.defineProperty(MouseService.prototype, "mouseOwner$", {
46907 return this._mouseOwner$;
46912 Object.defineProperty(MouseService.prototype, "mouseDown$", {
46914 return this._mouseDown$;
46919 Object.defineProperty(MouseService.prototype, "mouseMove$", {
46921 return this._mouseMove$;
46926 Object.defineProperty(MouseService.prototype, "mouseLeave$", {
46928 return this._mouseLeave$;
46933 Object.defineProperty(MouseService.prototype, "mouseOut$", {
46935 return this._mouseOut$;
46940 Object.defineProperty(MouseService.prototype, "mouseOver$", {
46942 return this._mouseOver$;
46947 Object.defineProperty(MouseService.prototype, "mouseUp$", {
46949 return this._mouseUp$;
46954 Object.defineProperty(MouseService.prototype, "click$", {
46956 return this._click$;
46961 Object.defineProperty(MouseService.prototype, "dblClick$", {
46963 return this._dblClick$;
46968 Object.defineProperty(MouseService.prototype, "contextMenu$", {
46970 return this._consistentContextMenu$;
46975 Object.defineProperty(MouseService.prototype, "mouseWheel$", {
46977 return this._mouseWheel$;
46982 Object.defineProperty(MouseService.prototype, "mouseDragStart$", {
46984 return this._mouseDragStart$;
46989 Object.defineProperty(MouseService.prototype, "mouseDrag$", {
46991 return this._mouseDrag$;
46996 Object.defineProperty(MouseService.prototype, "mouseDragEnd$", {
46998 return this._mouseDragEnd$;
47003 Object.defineProperty(MouseService.prototype, "proximateClick$", {
47005 return this._proximateClick$;
47010 Object.defineProperty(MouseService.prototype, "staticClick$", {
47012 return this._staticClick$;
47017 MouseService.prototype.claimMouse = function (name, zindex) {
47018 this._claimMouse$.next({ name: name, zindex: zindex });
47020 MouseService.prototype.unclaimMouse = function (name) {
47021 this._claimMouse$.next({ name: name, zindex: null });
47023 MouseService.prototype.deferPixels = function (name, deferPixels) {
47024 this._deferPixelClaims$.next({ name: name, deferPixels: deferPixels });
47026 MouseService.prototype.undeferPixels = function (name) {
47027 this._deferPixelClaims$.next({ name: name, deferPixels: null });
47029 MouseService.prototype.claimWheel = function (name, zindex) {
47030 this._claimWheel$.next({ name: name, zindex: zindex });
47032 MouseService.prototype.unclaimWheel = function (name) {
47033 this._claimWheel$.next({ name: name, zindex: null });
47035 MouseService.prototype.filtered$ = function (name, observable$) {
47036 return this._filtered(name, observable$, this._mouseOwner$);
47038 MouseService.prototype.filteredWheel$ = function (name, observable$) {
47039 return this._filtered(name, observable$, this._wheelOwner$);
47041 MouseService.prototype._createDeferredMouseMove$ = function (origin, mouseMove$) {
47042 return mouseMove$.pipe(operators_1.map(function (mouseMove) {
47043 var deltaX = mouseMove.clientX - origin.clientX;
47044 var deltaY = mouseMove.clientY - origin.clientY;
47045 return [mouseMove, Math.sqrt(deltaX * deltaX + deltaY * deltaY)];
47046 }), operators_1.withLatestFrom(this._deferPixels$), operators_1.filter(function (_a) {
47047 var _b = _a[0], mouseMove = _b[0], delta = _b[1], deferPixels = _a[1];
47048 return delta > deferPixels;
47049 }), operators_1.map(function (_a) {
47050 var _b = _a[0], mouseMove = _b[0], delta = _b[1], deferPixels = _a[1];
47054 MouseService.prototype._createMouseDrag$ = function (mouseDragStartInitiate$, stop$) {
47056 return mouseDragStartInitiate$.pipe(operators_1.map(function (_a) {
47057 var mouseDown = _a[0], mouseMove = _a[1];
47059 }), operators_1.switchMap(function (mouseMove) {
47060 return rxjs_1.concat(rxjs_1.of(mouseMove), _this._documentMouseMove$).pipe(operators_1.takeUntil(stop$));
47063 MouseService.prototype._createMouseDragEnd$ = function (mouseDragStart$, stop$) {
47064 return mouseDragStart$.pipe(operators_1.switchMap(function (event) {
47065 return stop$.pipe(operators_1.first());
47068 MouseService.prototype._createMouseDragStart$ = function (mouseDragStartInitiate$) {
47069 return mouseDragStartInitiate$.pipe(operators_1.map(function (_a) {
47070 var mouseDown = _a[0], mouseMove = _a[1];
47074 MouseService.prototype._createMouseDragInitiate$ = function (mouseDown$, stop$, defer) {
47076 return mouseDown$.pipe(operators_1.filter(function (mouseDown) {
47077 return mouseDown.button === 0;
47078 }), operators_1.switchMap(function (mouseDown) {
47079 return rxjs_1.combineLatest(rxjs_1.of(mouseDown), defer ?
47080 _this._createDeferredMouseMove$(mouseDown, _this._documentMouseMove$) :
47081 _this._documentMouseMove$).pipe(operators_1.takeUntil(stop$), operators_1.take(1));
47084 MouseService.prototype._createOwner$ = function (claim$) {
47085 return claim$.pipe(operators_1.scan(function (claims, claim) {
47086 if (claim.zindex == null) {
47087 delete claims[claim.name];
47090 claims[claim.name] = claim.zindex;
47093 }, {}), operators_1.map(function (claims) {
47095 var zIndexMax = -1;
47096 for (var name_1 in claims) {
47097 if (!claims.hasOwnProperty(name_1)) {
47100 if (claims[name_1] > zIndexMax) {
47101 zIndexMax = claims[name_1];
47106 }), operators_1.startWith(null));
47108 MouseService.prototype._filtered = function (name, observable$, owner$) {
47109 return observable$.pipe(operators_1.withLatestFrom(owner$), operators_1.filter(function (_a) {
47110 var item = _a[0], owner = _a[1];
47111 return owner === name;
47112 }), operators_1.map(function (_a) {
47113 var item = _a[0], owner = _a[1];
47117 return MouseService;
47119 exports.MouseService = MouseService;
47120 exports.default = MouseService;
47122 },{"rxjs":27,"rxjs/operators":225}],439:[function(require,module,exports){
47124 Object.defineProperty(exports, "__esModule", { value: true });
47125 var rxjs_1 = require("rxjs");
47126 var operators_1 = require("rxjs/operators");
47127 var API_1 = require("../API");
47128 var Graph_1 = require("../Graph");
47129 var Edge_1 = require("../Edge");
47130 var Error_1 = require("../Error");
47131 var State_1 = require("../State");
47132 var Viewer_1 = require("../Viewer");
47133 var Navigator = /** @class */ (function () {
47134 function Navigator(clientId, options, token, apiV3, graphService, imageLoadingService, loadingService, stateService, cacheService, playService) {
47135 this._apiV3 = apiV3 != null ? apiV3 : new API_1.APIv3(clientId, token);
47136 this._imageLoadingService = imageLoadingService != null ? imageLoadingService : new Graph_1.ImageLoadingService();
47137 this._graphService = graphService != null ?
47139 new Graph_1.GraphService(new Graph_1.Graph(this.apiV3), this._imageLoadingService);
47140 this._loadingService = loadingService != null ? loadingService : new Viewer_1.LoadingService();
47141 this._loadingName = "navigator";
47142 this._stateService = stateService != null ? stateService : new State_1.StateService(options.transitionMode);
47143 this._cacheService = cacheService != null ?
47145 new Viewer_1.CacheService(this._graphService, this._stateService);
47146 this._playService = playService != null ?
47148 new Viewer_1.PlayService(this._graphService, this._stateService);
47149 this._keyRequested$ = new rxjs_1.BehaviorSubject(null);
47150 this._movedToKey$ = new rxjs_1.BehaviorSubject(null);
47151 this._request$ = null;
47152 this._requestSubscription = null;
47153 this._nodeRequestSubscription = null;
47155 Object.defineProperty(Navigator.prototype, "apiV3", {
47157 return this._apiV3;
47162 Object.defineProperty(Navigator.prototype, "cacheService", {
47164 return this._cacheService;
47169 Object.defineProperty(Navigator.prototype, "graphService", {
47171 return this._graphService;
47176 Object.defineProperty(Navigator.prototype, "imageLoadingService", {
47178 return this._imageLoadingService;
47183 Object.defineProperty(Navigator.prototype, "loadingService", {
47185 return this._loadingService;
47190 Object.defineProperty(Navigator.prototype, "movedToKey$", {
47192 return this._movedToKey$;
47197 Object.defineProperty(Navigator.prototype, "playService", {
47199 return this._playService;
47204 Object.defineProperty(Navigator.prototype, "stateService", {
47206 return this._stateService;
47211 Navigator.prototype.moveToKey$ = function (key) {
47212 this._abortRequest("to key " + key);
47213 this._loadingService.startLoading(this._loadingName);
47214 var node$ = this._moveToKey$(key);
47215 return this._makeRequest$(node$);
47217 Navigator.prototype.moveDir$ = function (direction) {
47219 this._abortRequest("in dir " + Edge_1.EdgeDirection[direction]);
47220 this._loadingService.startLoading(this._loadingName);
47221 var node$ = this.stateService.currentNode$.pipe(operators_1.first(), operators_1.mergeMap(function (node) {
47222 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
47223 node.sequenceEdges$ :
47224 node.spatialEdges$).pipe(operators_1.first(), operators_1.map(function (status) {
47225 for (var _i = 0, _a = status.edges; _i < _a.length; _i++) {
47227 if (edge.data.direction === direction) {
47233 }), operators_1.mergeMap(function (directionKey) {
47234 if (directionKey == null) {
47235 _this._loadingService.stopLoading(_this._loadingName);
47236 return rxjs_1.throwError(new Error("Direction (" + direction + ") does not exist for current node."));
47238 return _this._moveToKey$(directionKey);
47240 return this._makeRequest$(node$);
47242 Navigator.prototype.moveCloseTo$ = function (lat, lon) {
47244 this._abortRequest("to lat " + lat + ", lon " + lon);
47245 this._loadingService.startLoading(this._loadingName);
47246 var node$ = this.apiV3.imageCloseTo$(lat, lon).pipe(operators_1.mergeMap(function (fullNode) {
47247 if (fullNode == null) {
47248 _this._loadingService.stopLoading(_this._loadingName);
47249 return rxjs_1.throwError(new Error("No image found close to lat " + lat + ", lon " + lon + "."));
47251 return _this._moveToKey$(fullNode.key);
47253 return this._makeRequest$(node$);
47255 Navigator.prototype.setFilter$ = function (filter) {
47257 this._stateService.clearNodes();
47258 return this._movedToKey$.pipe(operators_1.first(), operators_1.mergeMap(function (key) {
47260 return _this._trajectoryKeys$().pipe(operators_1.mergeMap(function (keys) {
47261 return _this._graphService.setFilter$(filter).pipe(operators_1.mergeMap(function () {
47262 return _this._cacheKeys$(keys);
47264 }), operators_1.last());
47266 return _this._keyRequested$.pipe(operators_1.first(), operators_1.mergeMap(function (requestedKey) {
47267 if (requestedKey != null) {
47268 return _this._graphService.setFilter$(filter).pipe(operators_1.mergeMap(function () {
47269 return _this._graphService.cacheNode$(requestedKey);
47272 return _this._graphService.setFilter$(filter).pipe(operators_1.map(function () {
47276 }), operators_1.map(function (node) {
47280 Navigator.prototype.setToken$ = function (token) {
47282 this._abortRequest("to set token");
47283 this._stateService.clearNodes();
47284 return this._movedToKey$.pipe(operators_1.first(), operators_1.tap(function (key) {
47285 _this._apiV3.setToken(token);
47286 }), operators_1.mergeMap(function (key) {
47287 return key == null ?
47288 _this._graphService.reset$([]) :
47289 _this._trajectoryKeys$().pipe(operators_1.mergeMap(function (keys) {
47290 return _this._graphService.reset$(keys).pipe(operators_1.mergeMap(function () {
47291 return _this._cacheKeys$(keys);
47293 }), operators_1.last(), operators_1.map(function (node) {
47298 Navigator.prototype._cacheKeys$ = function (keys) {
47300 var cacheNodes$ = keys
47301 .map(function (key) {
47302 return _this._graphService.cacheNode$(key);
47304 return rxjs_1.from(cacheNodes$).pipe(operators_1.mergeAll());
47306 Navigator.prototype._abortRequest = function (reason) {
47307 if (this._requestSubscription != null) {
47308 this._requestSubscription.unsubscribe();
47309 this._requestSubscription = null;
47311 if (this._nodeRequestSubscription != null) {
47312 this._nodeRequestSubscription.unsubscribe();
47313 this._nodeRequestSubscription = null;
47315 if (this._request$ != null) {
47316 if (!(this._request$.isStopped || this._request$.hasError)) {
47317 this._request$.error(new Error_1.AbortMapillaryError("Request aborted by a subsequent request " + reason + "."));
47319 this._request$ = null;
47322 Navigator.prototype._makeRequest$ = function (node$) {
47324 var request$ = new rxjs_1.ReplaySubject(1);
47325 this._requestSubscription = request$
47326 .subscribe(undefined, function () { });
47327 this._request$ = request$;
47328 this._nodeRequestSubscription = node$
47329 .subscribe(function (node) {
47330 _this._request$ = null;
47331 request$.next(node);
47332 request$.complete();
47333 }, function (error) {
47334 _this._request$ = null;
47335 request$.error(error);
47339 Navigator.prototype._moveToKey$ = function (key) {
47341 this._keyRequested$.next(key);
47342 return this._graphService.cacheNode$(key).pipe(operators_1.tap(function (node) {
47343 _this._stateService.setNodes([node]);
47344 _this._movedToKey$.next(node.key);
47345 }), operators_1.finalize(function () {
47346 _this._loadingService.stopLoading(_this._loadingName);
47349 Navigator.prototype._trajectoryKeys$ = function () {
47350 return this._stateService.currentState$.pipe(operators_1.first(), operators_1.map(function (frame) {
47351 return frame.state.trajectory
47352 .map(function (node) {
47359 exports.Navigator = Navigator;
47360 exports.default = Navigator;
47362 },{"../API":274,"../Edge":276,"../Error":277,"../Graph":279,"../State":282,"../Viewer":286,"rxjs":27,"rxjs/operators":225}],440:[function(require,module,exports){
47364 Object.defineProperty(exports, "__esModule", { value: true });
47365 var rxjs_1 = require("rxjs");
47366 var operators_1 = require("rxjs/operators");
47367 var Viewer_1 = require("../Viewer");
47368 var Observer = /** @class */ (function () {
47369 function Observer(eventEmitter, navigator, container) {
47371 this._container = container;
47372 this._eventEmitter = eventEmitter;
47373 this._navigator = navigator;
47374 this._projection = new Viewer_1.Projection();
47375 this._started = false;
47376 this._navigable$ = new rxjs_1.Subject();
47377 // navigable and loading should always emit, also when cover is activated.
47379 .subscribe(function (navigable) {
47380 _this._eventEmitter.fire(Viewer_1.Viewer.navigablechanged, navigable);
47382 this._navigator.loadingService.loading$
47383 .subscribe(function (loading) {
47384 _this._eventEmitter.fire(Viewer_1.Viewer.loadingchanged, loading);
47387 Object.defineProperty(Observer.prototype, "started", {
47389 return this._started;
47394 Object.defineProperty(Observer.prototype, "navigable$", {
47396 return this._navigable$;
47401 Observer.prototype.projectBasic$ = function (basicPoint) {
47403 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) {
47404 var render = _a[0], transform = _a[1];
47405 var canvasPoint = _this._projection.basicToCanvas(basicPoint, _this._container.element, render, transform);
47406 return [Math.round(canvasPoint[0]), Math.round(canvasPoint[1])];
47409 Observer.prototype.startEmit = function () {
47411 if (this._started) {
47414 this._started = true;
47415 this._currentNodeSubscription = this._navigator.stateService.currentNodeExternal$
47416 .subscribe(function (node) {
47417 _this._eventEmitter.fire(Viewer_1.Viewer.nodechanged, node);
47419 this._sequenceEdgesSubscription = this._navigator.stateService.currentNodeExternal$.pipe(operators_1.switchMap(function (node) {
47420 return node.sequenceEdges$;
47422 .subscribe(function (status) {
47423 _this._eventEmitter.fire(Viewer_1.Viewer.sequenceedgeschanged, status);
47425 this._spatialEdgesSubscription = this._navigator.stateService.currentNodeExternal$.pipe(operators_1.switchMap(function (node) {
47426 return node.spatialEdges$;
47428 .subscribe(function (status) {
47429 _this._eventEmitter.fire(Viewer_1.Viewer.spatialedgeschanged, status);
47431 this._moveSubscription = rxjs_1.combineLatest(this._navigator.stateService.inMotion$, this._container.mouseService.active$, this._container.touchService.active$).pipe(operators_1.map(function (values) {
47432 return values[0] || values[1] || values[2];
47433 }), operators_1.distinctUntilChanged())
47434 .subscribe(function (started) {
47436 _this._eventEmitter.fire(Viewer_1.Viewer.movestart, null);
47439 _this._eventEmitter.fire(Viewer_1.Viewer.moveend, null);
47442 this._bearingSubscription = this._container.renderService.bearing$.pipe(operators_1.auditTime(100), operators_1.distinctUntilChanged(function (b1, b2) {
47443 return Math.abs(b2 - b1) < 1;
47445 .subscribe(function (bearing) {
47446 _this._eventEmitter.fire(Viewer_1.Viewer.bearingchanged, bearing);
47448 var mouseMove$ = this._container.mouseService.active$.pipe(operators_1.switchMap(function (active) {
47451 _this._container.mouseService.mouseMove$;
47453 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) {
47454 var _b = _a[0], type = _b[0], event = _b[1], render = _a[1], reference = _a[2], transform = _a[3];
47455 var unprojection = _this._projection.eventToUnprojection(event, _this._container.element, render, reference, transform);
47457 basicPoint: unprojection.basicPoint,
47458 latLon: unprojection.latLon,
47459 originalEvent: event,
47460 pixelPoint: unprojection.pixelPoint,
47461 target: _this._eventEmitter,
47465 .subscribe(function (event) {
47466 _this._eventEmitter.fire(event.type, event);
47469 Observer.prototype.stopEmit = function () {
47470 if (!this.started) {
47473 this._started = false;
47474 this._bearingSubscription.unsubscribe();
47475 this._currentNodeSubscription.unsubscribe();
47476 this._moveSubscription.unsubscribe();
47477 this._sequenceEdgesSubscription.unsubscribe();
47478 this._spatialEdgesSubscription.unsubscribe();
47479 this._viewerMouseEventSubscription.unsubscribe();
47480 this._bearingSubscription = null;
47481 this._currentNodeSubscription = null;
47482 this._moveSubscription = null;
47483 this._sequenceEdgesSubscription = null;
47484 this._spatialEdgesSubscription = null;
47485 this._viewerMouseEventSubscription = null;
47487 Observer.prototype.unproject$ = function (canvasPoint) {
47489 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) {
47490 var render = _a[0], reference = _a[1], transform = _a[2];
47491 var unprojection = _this._projection.canvasToUnprojection(canvasPoint, _this._container.element, render, reference, transform);
47492 return unprojection.latLon;
47495 Observer.prototype.unprojectBasic$ = function (canvasPoint) {
47497 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) {
47498 var render = _a[0], transform = _a[1];
47499 return _this._projection.canvasToBasic(canvasPoint, _this._container.element, render, transform);
47502 Observer.prototype._mapMouseEvent$ = function (type, mouseEvent$) {
47503 return mouseEvent$.pipe(operators_1.map(function (event) {
47504 return [type, event];
47509 exports.Observer = Observer;
47510 exports.default = Observer;
47512 },{"../Viewer":286,"rxjs":27,"rxjs/operators":225}],441:[function(require,module,exports){
47514 Object.defineProperty(exports, "__esModule", { value: true });
47515 var rxjs_1 = require("rxjs");
47516 var operators_1 = require("rxjs/operators");
47517 var Edge_1 = require("../Edge");
47518 var Graph_1 = require("../Graph");
47519 var PlayService = /** @class */ (function () {
47520 function PlayService(graphService, stateService, graphCalculator) {
47521 this._graphService = graphService;
47522 this._stateService = stateService;
47523 this._graphCalculator = !!graphCalculator ? graphCalculator : new Graph_1.GraphCalculator();
47524 this._directionSubject$ = new rxjs_1.Subject();
47525 this._direction$ = this._directionSubject$.pipe(operators_1.startWith(Edge_1.EdgeDirection.Next), operators_1.publishReplay(1), operators_1.refCount());
47526 this._direction$.subscribe();
47527 this._playing = false;
47528 this._playingSubject$ = new rxjs_1.Subject();
47529 this._playing$ = this._playingSubject$.pipe(operators_1.startWith(this._playing), operators_1.publishReplay(1), operators_1.refCount());
47530 this._playing$.subscribe();
47532 this._speedSubject$ = new rxjs_1.Subject();
47533 this._speed$ = this._speedSubject$.pipe(operators_1.startWith(this._speed), operators_1.publishReplay(1), operators_1.refCount());
47534 this._speed$.subscribe();
47535 this._nodesAhead = this._mapNodesAhead(this._mapSpeed(this._speed));
47536 this._bridging$ = null;
47538 Object.defineProperty(PlayService.prototype, "playing", {
47540 return this._playing;
47545 Object.defineProperty(PlayService.prototype, "direction$", {
47547 return this._direction$;
47552 Object.defineProperty(PlayService.prototype, "playing$", {
47554 return this._playing$;
47559 Object.defineProperty(PlayService.prototype, "speed$", {
47561 return this._speed$;
47566 PlayService.prototype.play = function () {
47568 if (this._playing) {
47571 this._stateService.cutNodes();
47572 var stateSpeed = this._setSpeed(this._speed);
47573 this._stateService.setSpeed(stateSpeed);
47574 this._graphModeSubscription = this._speed$.pipe(operators_1.map(function (speed) {
47575 return speed > PlayService.sequenceSpeed ? Graph_1.GraphMode.Sequence : Graph_1.GraphMode.Spatial;
47576 }), operators_1.distinctUntilChanged())
47577 .subscribe(function (mode) {
47578 _this._graphService.setGraphMode(mode);
47580 this._cacheSubscription = rxjs_1.combineLatest(this._stateService.currentNode$.pipe(operators_1.map(function (node) {
47581 return [node.sequenceKey, node.key];
47582 }), operators_1.distinctUntilChanged(undefined, function (_a) {
47583 var sequenceKey = _a[0], nodeKey = _a[1];
47584 return sequenceKey;
47585 })), this._graphService.graphMode$, this._direction$).pipe(operators_1.switchMap(function (_a) {
47586 var _b = _a[0], sequenceKey = _b[0], nodeKey = _b[1], mode = _a[1], direction = _a[2];
47587 if (direction !== Edge_1.EdgeDirection.Next && direction !== Edge_1.EdgeDirection.Prev) {
47588 return rxjs_1.of([undefined, direction]);
47590 var sequence$ = (mode === Graph_1.GraphMode.Sequence ?
47591 _this._graphService.cacheSequenceNodes$(sequenceKey, nodeKey) :
47592 _this._graphService.cacheSequence$(sequenceKey)).pipe(operators_1.retry(3), operators_1.catchError(function (error) {
47593 console.error(error);
47594 return rxjs_1.of(undefined);
47596 return rxjs_1.combineLatest(sequence$, rxjs_1.of(direction));
47597 }), operators_1.switchMap(function (_a) {
47598 var sequence = _a[0], direction = _a[1];
47599 if (sequence === undefined) {
47600 return rxjs_1.empty();
47602 var sequenceKeys = sequence.keys.slice();
47603 if (direction === Edge_1.EdgeDirection.Prev) {
47604 sequenceKeys.reverse();
47606 return _this._stateService.currentState$.pipe(operators_1.map(function (frame) {
47607 return [frame.state.trajectory[frame.state.trajectory.length - 1].key, frame.state.nodesAhead];
47608 }), operators_1.scan(function (_a, _b) {
47609 var lastRequestKey = _a[0], previousRequestKeys = _a[1];
47610 var lastTrajectoryKey = _b[0], nodesAhead = _b[1];
47611 if (lastRequestKey === undefined) {
47612 lastRequestKey = lastTrajectoryKey;
47614 var lastIndex = sequenceKeys.length - 1;
47615 if (nodesAhead >= _this._nodesAhead || sequenceKeys[lastIndex] === lastRequestKey) {
47616 return [lastRequestKey, []];
47618 var current = sequenceKeys.indexOf(lastTrajectoryKey);
47619 var start = sequenceKeys.indexOf(lastRequestKey) + 1;
47620 var end = Math.min(lastIndex, current + _this._nodesAhead - nodesAhead) + 1;
47621 if (end <= start) {
47622 return [lastRequestKey, []];
47624 return [sequenceKeys[end - 1], sequenceKeys.slice(start, end)];
47625 }, [undefined, []]), operators_1.mergeMap(function (_a) {
47626 var lastRequestKey = _a[0], newRequestKeys = _a[1];
47627 return rxjs_1.from(newRequestKeys);
47629 }), operators_1.mergeMap(function (key) {
47630 return _this._graphService.cacheNode$(key).pipe(operators_1.catchError(function () {
47631 return rxjs_1.empty();
47635 this._playingSubscription = this._stateService.currentState$.pipe(operators_1.filter(function (frame) {
47636 return frame.state.nodesAhead < _this._nodesAhead;
47637 }), operators_1.distinctUntilChanged(undefined, function (frame) {
47638 return frame.state.lastNode.key;
47639 }), operators_1.map(function (frame) {
47640 var lastNode = frame.state.lastNode;
47641 var trajectory = frame.state.trajectory;
47642 var increasingTime = undefined;
47643 for (var i = trajectory.length - 2; i >= 0; i--) {
47644 var node = trajectory[i];
47645 if (node.sequenceKey !== lastNode.sequenceKey) {
47648 if (node.capturedAt !== lastNode.capturedAt) {
47649 increasingTime = node.capturedAt < lastNode.capturedAt;
47653 return [frame.state.lastNode, increasingTime];
47654 }), operators_1.withLatestFrom(this._direction$), operators_1.switchMap(function (_a) {
47655 var _b = _a[0], node = _b[0], increasingTime = _b[1], direction = _a[1];
47656 return rxjs_1.zip(([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
47657 node.sequenceEdges$ :
47658 node.spatialEdges$).pipe(operators_1.first(function (status) {
47659 return status.cached;
47660 }), operators_1.timeout(15000)), rxjs_1.of(direction)).pipe(operators_1.map(function (_a) {
47661 var s = _a[0], d = _a[1];
47662 for (var _i = 0, _b = s.edges; _i < _b.length; _i++) {
47664 if (edge.data.direction === d) {
47669 }), operators_1.switchMap(function (key) {
47670 return key != null ?
47671 _this._graphService.cacheNode$(key) :
47672 _this._bridge$(node, increasingTime).pipe(operators_1.filter(function (n) {
47677 .subscribe(function (node) {
47678 _this._stateService.appendNodes([node]);
47679 }, function (error) {
47680 console.error(error);
47683 this._clearSubscription = this._stateService.currentNode$.pipe(operators_1.bufferCount(1, 10))
47684 .subscribe(function (nodes) {
47685 _this._stateService.clearPriorNodes();
47687 this._setPlaying(true);
47688 var currentLastNodes$ = this._stateService.currentState$.pipe(operators_1.map(function (frame) {
47689 return frame.state;
47690 }), operators_1.distinctUntilChanged(function (_a, _b) {
47691 var kc1 = _a[0], kl1 = _a[1];
47692 var kc2 = _b[0], kl2 = _b[1];
47693 return kc1 === kc2 && kl1 === kl2;
47694 }, function (state) {
47695 return [state.currentNode.key, state.lastNode.key];
47696 }), operators_1.filter(function (state) {
47697 return state.currentNode.key === state.lastNode.key &&
47698 state.currentIndex === state.trajectory.length - 1;
47699 }), operators_1.map(function (state) {
47700 return state.currentNode;
47702 this._stopSubscription = rxjs_1.combineLatest(currentLastNodes$, this._direction$).pipe(operators_1.switchMap(function (_a) {
47703 var node = _a[0], direction = _a[1];
47704 var edgeStatus$ = ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
47705 node.sequenceEdges$ :
47706 node.spatialEdges$).pipe(operators_1.first(function (status) {
47707 return status.cached;
47708 }), operators_1.timeout(15000), operators_1.catchError(function (error) {
47709 console.error(error);
47710 return rxjs_1.of({ cached: false, edges: [] });
47712 return rxjs_1.combineLatest(rxjs_1.of(direction), edgeStatus$).pipe(operators_1.map(function (_a) {
47713 var d = _a[0], es = _a[1];
47714 for (var _i = 0, _b = es.edges; _i < _b.length; _i++) {
47716 if (edge.data.direction === d) {
47722 }), operators_1.mergeMap(function (hasEdge) {
47723 if (hasEdge || !_this._bridging$) {
47724 return rxjs_1.of(hasEdge);
47726 return _this._bridging$.pipe(operators_1.map(function (node) {
47727 return node != null;
47728 }), operators_1.catchError(function (error) {
47729 console.error(error);
47730 return rxjs_1.of(false);
47732 }), operators_1.first(function (hasEdge) {
47735 .subscribe(undefined, undefined, function () { _this.stop(); });
47736 if (this._stopSubscription.closed) {
47737 this._stopSubscription = null;
47740 PlayService.prototype.setDirection = function (direction) {
47741 this._directionSubject$.next(direction);
47743 PlayService.prototype.setSpeed = function (speed) {
47744 speed = Math.max(0, Math.min(1, speed));
47745 if (speed === this._speed) {
47748 var stateSpeed = this._setSpeed(speed);
47749 if (this._playing) {
47750 this._stateService.setSpeed(stateSpeed);
47752 this._speedSubject$.next(this._speed);
47754 PlayService.prototype.stop = function () {
47755 if (!this._playing) {
47758 if (!!this._stopSubscription) {
47759 if (!this._stopSubscription.closed) {
47760 this._stopSubscription.unsubscribe();
47762 this._stopSubscription = null;
47764 this._graphModeSubscription.unsubscribe();
47765 this._graphModeSubscription = null;
47766 this._cacheSubscription.unsubscribe();
47767 this._cacheSubscription = null;
47768 this._playingSubscription.unsubscribe();
47769 this._playingSubscription = null;
47770 this._clearSubscription.unsubscribe();
47771 this._clearSubscription = null;
47772 this._stateService.setSpeed(1);
47773 this._stateService.cutNodes();
47774 this._graphService.setGraphMode(Graph_1.GraphMode.Spatial);
47775 this._setPlaying(false);
47777 PlayService.prototype._bridge$ = function (node, increasingTime) {
47779 if (increasingTime === undefined) {
47780 return rxjs_1.of(null);
47782 var boundingBox = this._graphCalculator.boundingBoxCorners(node.latLon, 25);
47783 this._bridging$ = this._graphService.cacheBoundingBox$(boundingBox[0], boundingBox[1]).pipe(operators_1.mergeMap(function (nodes) {
47784 var nextNode = null;
47785 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
47786 var n = nodes_1[_i];
47787 if (n.sequenceKey === node.sequenceKey ||
47789 n.cameraUuid !== node.cameraUuid ||
47790 n.capturedAt === node.capturedAt ||
47791 n.capturedAt > node.capturedAt !== increasingTime) {
47794 var delta = Math.abs(n.capturedAt - node.capturedAt);
47795 if (delta > 15000) {
47798 if (!nextNode || delta < Math.abs(nextNode.capturedAt - node.capturedAt)) {
47802 return !!nextNode ?
47803 _this._graphService.cacheNode$(nextNode.key) :
47805 }), operators_1.finalize(function () {
47806 _this._bridging$ = null;
47807 }), operators_1.publish(), operators_1.refCount());
47808 return this._bridging$;
47810 PlayService.prototype._mapSpeed = function (speed) {
47811 var x = 2 * speed - 1;
47812 return Math.pow(10, x) - 0.2 * x;
47814 PlayService.prototype._mapNodesAhead = function (stateSpeed) {
47815 return Math.round(Math.max(10, Math.min(50, 8 + 6 * stateSpeed)));
47817 PlayService.prototype._setPlaying = function (playing) {
47818 this._playing = playing;
47819 this._playingSubject$.next(playing);
47821 PlayService.prototype._setSpeed = function (speed) {
47822 this._speed = speed;
47823 var stateSpeed = this._mapSpeed(this._speed);
47824 this._nodesAhead = this._mapNodesAhead(stateSpeed);
47827 PlayService.sequenceSpeed = 0.54;
47828 return PlayService;
47830 exports.PlayService = PlayService;
47831 exports.default = PlayService;
47833 },{"../Edge":276,"../Graph":279,"rxjs":27,"rxjs/operators":225}],442:[function(require,module,exports){
47835 Object.defineProperty(exports, "__esModule", { value: true });
47836 var THREE = require("three");
47837 var Geo_1 = require("../Geo");
47838 var Projection = /** @class */ (function () {
47839 function Projection(geoCoords, viewportCoords) {
47840 this._geoCoords = !!geoCoords ? geoCoords : new Geo_1.GeoCoords();
47841 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
47843 Projection.prototype.basicToCanvas = function (basicPoint, container, render, transform) {
47844 return this._viewportCoords
47845 .basicToCanvas(basicPoint[0], basicPoint[1], container, transform, render.perspective);
47847 Projection.prototype.canvasToBasic = function (canvasPoint, container, render, transform) {
47848 var basicPoint = this._viewportCoords
47849 .canvasToBasic(canvasPoint[0], canvasPoint[1], container, transform, render.perspective);
47850 if (basicPoint[0] < 0 || basicPoint[0] > 1 || basicPoint[1] < 0 || basicPoint[1] > 1) {
47855 Projection.prototype.eventToUnprojection = function (event, container, render, reference, transform) {
47856 var pixelPoint = this._viewportCoords.canvasPosition(event, container);
47857 return this.canvasToUnprojection(pixelPoint, container, render, reference, transform);
47859 Projection.prototype.canvasToUnprojection = function (canvasPoint, container, render, reference, transform) {
47860 var canvasX = canvasPoint[0];
47861 var canvasY = canvasPoint[1];
47862 var _a = this._viewportCoords.canvasToViewport(canvasX, canvasY, container), viewportX = _a[0], viewportY = _a[1];
47863 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
47864 .unproject(render.perspective);
47865 var basicPoint = transform.projectBasic(point3d.toArray());
47866 if (basicPoint[0] < 0 || basicPoint[0] > 1 || basicPoint[1] < 0 || basicPoint[1] > 1) {
47869 var direction3d = point3d.clone().sub(render.camera.position).normalize();
47870 var dist = -2 / direction3d.z;
47872 if (dist > 0 && dist < 100 && !!basicPoint) {
47873 var point = direction3d.clone().multiplyScalar(dist).add(render.camera.position);
47874 var latLonArray = this._geoCoords
47875 .enuToGeodetic(point.x, point.y, point.z, reference.lat, reference.lon, reference.alt)
47877 latLon = { lat: latLonArray[0], lon: latLonArray[1] };
47879 var unprojection = {
47880 basicPoint: basicPoint,
47882 pixelPoint: [canvasX, canvasY],
47884 return unprojection;
47888 exports.Projection = Projection;
47889 exports.default = Projection;
47891 },{"../Geo":278,"three":226}],443:[function(require,module,exports){
47893 Object.defineProperty(exports, "__esModule", { value: true });
47894 var operators_1 = require("rxjs/operators");
47895 var THREE = require("three");
47896 var vd = require("virtual-dom");
47897 var rxjs_1 = require("rxjs");
47898 var Viewer_1 = require("../Viewer");
47899 var SpriteAtlas = /** @class */ (function () {
47900 function SpriteAtlas() {
47902 Object.defineProperty(SpriteAtlas.prototype, "json", {
47903 set: function (value) {
47904 this._json = value;
47909 Object.defineProperty(SpriteAtlas.prototype, "image", {
47910 set: function (value) {
47911 this._image = value;
47912 this._texture = new THREE.Texture(this._image);
47913 this._texture.minFilter = THREE.NearestFilter;
47918 Object.defineProperty(SpriteAtlas.prototype, "loaded", {
47920 return !!(this._image && this._json);
47925 SpriteAtlas.prototype.getGLSprite = function (name) {
47926 if (!this.loaded) {
47927 throw new Error("Sprites cannot be retrieved before the atlas is loaded.");
47929 var definition = this._json[name];
47931 console.warn("Sprite with key" + name + "does not exist in sprite definition.");
47932 return new THREE.Object3D();
47934 var texture = this._texture.clone();
47935 texture.needsUpdate = true;
47936 var width = this._image.width;
47937 var height = this._image.height;
47938 texture.offset.x = definition.x / width;
47939 texture.offset.y = (height - definition.y - definition.height) / height;
47940 texture.repeat.x = definition.width / width;
47941 texture.repeat.y = definition.height / height;
47942 var material = new THREE.SpriteMaterial({ map: texture });
47943 return new THREE.Sprite(material);
47945 SpriteAtlas.prototype.getDOMSprite = function (name, float) {
47946 if (!this.loaded) {
47947 throw new Error("Sprites cannot be retrieved before the atlas is loaded.");
47949 if (float == null) {
47950 float = Viewer_1.Alignment.Center;
47952 var definition = this._json[name];
47954 console.warn("Sprite with key" + name + "does not exist in sprite definition.");
47955 return vd.h("div", {}, []);
47957 var clipTop = definition.y;
47958 var clipRigth = definition.x + definition.width;
47959 var clipBottom = definition.y + definition.height;
47960 var clipLeft = definition.x;
47961 var left = -definition.x;
47962 var top = -definition.y;
47963 var height = this._image.height;
47964 var width = this._image.width;
47966 case Viewer_1.Alignment.Bottom:
47967 case Viewer_1.Alignment.Center:
47968 case Viewer_1.Alignment.Top:
47969 left -= definition.width / 2;
47971 case Viewer_1.Alignment.BottomLeft:
47972 case Viewer_1.Alignment.Left:
47973 case Viewer_1.Alignment.TopLeft:
47974 left -= definition.width;
47976 case Viewer_1.Alignment.BottomRight:
47977 case Viewer_1.Alignment.Right:
47978 case Viewer_1.Alignment.TopRight:
47983 case Viewer_1.Alignment.Center:
47984 case Viewer_1.Alignment.Left:
47985 case Viewer_1.Alignment.Right:
47986 top -= definition.height / 2;
47988 case Viewer_1.Alignment.Top:
47989 case Viewer_1.Alignment.TopLeft:
47990 case Viewer_1.Alignment.TopRight:
47991 top -= definition.height;
47993 case Viewer_1.Alignment.Bottom:
47994 case Viewer_1.Alignment.BottomLeft:
47995 case Viewer_1.Alignment.BottomRight:
47999 var pixelRatioInverse = 1 / definition.pixelRatio;
48000 clipTop *= pixelRatioInverse;
48001 clipRigth *= pixelRatioInverse;
48002 clipBottom *= pixelRatioInverse;
48003 clipLeft *= pixelRatioInverse;
48004 left *= pixelRatioInverse;
48005 top *= pixelRatioInverse;
48006 height *= pixelRatioInverse;
48007 width *= pixelRatioInverse;
48009 src: this._image.src,
48011 clip: "rect(" + clipTop + "px, " + clipRigth + "px, " + clipBottom + "px, " + clipLeft + "px)",
48012 height: height + "px",
48014 position: "absolute",
48016 width: width + "px",
48019 return vd.h("img", properties, []);
48021 return SpriteAtlas;
48023 var SpriteService = /** @class */ (function () {
48024 function SpriteService(sprite) {
48026 this._retina = window.devicePixelRatio > 1;
48027 this._spriteAtlasOperation$ = new rxjs_1.Subject();
48028 this._spriteAtlas$ = this._spriteAtlasOperation$.pipe(operators_1.startWith(function (atlas) {
48030 }), operators_1.scan(function (atlas, operation) {
48031 return operation(atlas);
48032 }, new SpriteAtlas()), operators_1.publishReplay(1), operators_1.refCount());
48033 this._spriteAtlas$.subscribe(function () { });
48034 if (sprite == null) {
48037 var format = this._retina ? "@2x" : "";
48038 var imageXmlHTTP = new XMLHttpRequest();
48039 imageXmlHTTP.open("GET", sprite + format + ".png", true);
48040 imageXmlHTTP.responseType = "arraybuffer";
48041 imageXmlHTTP.onload = function () {
48042 var image = new Image();
48043 image.onload = function () {
48044 _this._spriteAtlasOperation$.next(function (atlas) {
48045 atlas.image = image;
48049 var blob = new Blob([imageXmlHTTP.response]);
48050 image.src = window.URL.createObjectURL(blob);
48052 imageXmlHTTP.onerror = function (error) {
48053 console.error(new Error("Failed to fetch sprite sheet (" + sprite + format + ".png)"));
48055 imageXmlHTTP.send();
48056 var jsonXmlHTTP = new XMLHttpRequest();
48057 jsonXmlHTTP.open("GET", sprite + format + ".json", true);
48058 jsonXmlHTTP.responseType = "text";
48059 jsonXmlHTTP.onload = function () {
48060 var json = JSON.parse(jsonXmlHTTP.response);
48061 _this._spriteAtlasOperation$.next(function (atlas) {
48066 jsonXmlHTTP.onerror = function (error) {
48067 console.error(new Error("Failed to fetch sheet (" + sprite + format + ".json)"));
48069 jsonXmlHTTP.send();
48071 Object.defineProperty(SpriteService.prototype, "spriteAtlas$", {
48073 return this._spriteAtlas$;
48078 return SpriteService;
48080 exports.SpriteService = SpriteService;
48081 exports.default = SpriteService;
48084 },{"../Viewer":286,"rxjs":27,"rxjs/operators":225,"three":226,"virtual-dom":231}],444:[function(require,module,exports){
48086 Object.defineProperty(exports, "__esModule", { value: true });
48087 var rxjs_1 = require("rxjs");
48088 var operators_1 = require("rxjs/operators");
48089 var TouchService = /** @class */ (function () {
48090 function TouchService(canvasContainer, domContainer) {
48092 this._activeSubject$ = new rxjs_1.BehaviorSubject(false);
48093 this._active$ = this._activeSubject$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
48094 rxjs_1.fromEvent(domContainer, "touchmove")
48095 .subscribe(function (event) {
48096 event.preventDefault();
48098 this._touchStart$ = rxjs_1.fromEvent(canvasContainer, "touchstart");
48099 this._touchMove$ = rxjs_1.fromEvent(canvasContainer, "touchmove");
48100 this._touchEnd$ = rxjs_1.fromEvent(canvasContainer, "touchend");
48101 this._touchCancel$ = rxjs_1.fromEvent(canvasContainer, "touchcancel");
48102 var tapStart$ = this._touchStart$.pipe(operators_1.filter(function (te) {
48103 return te.touches.length === 1 && te.targetTouches.length === 1;
48104 }), operators_1.share());
48105 this._doubleTap$ = tapStart$.pipe(operators_1.bufferWhen(function () {
48106 return tapStart$.pipe(operators_1.first(), operators_1.switchMap(function (event) {
48107 return rxjs_1.merge(rxjs_1.timer(300), tapStart$).pipe(operators_1.take(1));
48109 }), operators_1.filter(function (events) {
48110 return events.length === 2;
48111 }), operators_1.map(function (events) {
48112 return events[events.length - 1];
48113 }), operators_1.share());
48115 .subscribe(function (event) {
48116 event.preventDefault();
48118 this._singleTouchMove$ = this._touchMove$.pipe(operators_1.filter(function (te) {
48119 return te.touches.length === 1 && te.targetTouches.length === 1;
48120 }), operators_1.share());
48121 var singleTouchStart$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
48122 return te.touches.length === 1 && te.targetTouches.length === 1;
48124 var multipleTouchStart$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
48125 return te.touches.length >= 1;
48127 var touchStop$ = rxjs_1.merge(this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
48128 return te.touches.length === 0;
48130 this._singleTouchDragStart$ = singleTouchStart$.pipe(operators_1.mergeMap(function (e) {
48131 return _this._singleTouchMove$.pipe(operators_1.takeUntil(rxjs_1.merge(touchStop$, multipleTouchStart$)), operators_1.take(1));
48133 this._singleTouchDragEnd$ = singleTouchStart$.pipe(operators_1.mergeMap(function (e) {
48134 return rxjs_1.merge(touchStop$, multipleTouchStart$).pipe(operators_1.first());
48136 this._singleTouchDrag$ = singleTouchStart$.pipe(operators_1.switchMap(function (te) {
48137 return _this._singleTouchMove$.pipe(operators_1.skip(1), operators_1.takeUntil(rxjs_1.merge(multipleTouchStart$, touchStop$)));
48139 var touchesChanged$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$);
48140 this._pinchStart$ = touchesChanged$.pipe(operators_1.filter(function (te) {
48141 return te.touches.length === 2 && te.targetTouches.length === 2;
48143 this._pinchEnd$ = touchesChanged$.pipe(operators_1.filter(function (te) {
48144 return te.touches.length !== 2 || te.targetTouches.length !== 2;
48146 this._pinchOperation$ = new rxjs_1.Subject();
48147 this._pinch$ = this._pinchOperation$.pipe(operators_1.scan(function (pinch, operation) {
48148 return operation(pinch);
48158 originalEvent: null,
48166 this._touchMove$.pipe(operators_1.filter(function (te) {
48167 return te.touches.length === 2 && te.targetTouches.length === 2;
48168 }), operators_1.map(function (te) {
48169 return function (previous) {
48170 var touch1 = te.touches[0];
48171 var touch2 = te.touches[1];
48172 var minX = Math.min(touch1.clientX, touch2.clientX);
48173 var maxX = Math.max(touch1.clientX, touch2.clientX);
48174 var minY = Math.min(touch1.clientY, touch2.clientY);
48175 var maxY = Math.max(touch1.clientY, touch2.clientY);
48176 var centerClientX = minX + (maxX - minX) / 2;
48177 var centerClientY = minY + (maxY - minY) / 2;
48178 var centerPageX = centerClientX + touch1.pageX - touch1.clientX;
48179 var centerPageY = centerClientY + touch1.pageY - touch1.clientY;
48180 var centerScreenX = centerClientX + touch1.screenX - touch1.clientX;
48181 var centerScreenY = centerClientY + touch1.screenY - touch1.clientY;
48182 var distanceX = Math.abs(touch1.clientX - touch2.clientX);
48183 var distanceY = Math.abs(touch1.clientY - touch2.clientY);
48184 var distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
48185 var distanceChange = distance - previous.distance;
48186 var changeX = distanceX - previous.distanceX;
48187 var changeY = distanceY - previous.distanceY;
48191 clientX: centerClientX,
48192 clientY: centerClientY,
48193 distance: distance,
48194 distanceChange: distanceChange,
48195 distanceX: distanceX,
48196 distanceY: distanceY,
48198 pageX: centerPageX,
48199 pageY: centerPageY,
48200 screenX: centerScreenX,
48201 screenY: centerScreenY,
48208 .subscribe(this._pinchOperation$);
48209 this._pinchChange$ = this._pinchStart$.pipe(operators_1.switchMap(function (te) {
48210 return _this._pinch$.pipe(operators_1.skip(1), operators_1.takeUntil(_this._pinchEnd$));
48213 Object.defineProperty(TouchService.prototype, "active$", {
48215 return this._active$;
48220 Object.defineProperty(TouchService.prototype, "activate$", {
48222 return this._activeSubject$;
48227 Object.defineProperty(TouchService.prototype, "doubleTap$", {
48229 return this._doubleTap$;
48234 Object.defineProperty(TouchService.prototype, "touchStart$", {
48236 return this._touchStart$;
48241 Object.defineProperty(TouchService.prototype, "touchMove$", {
48243 return this._touchMove$;
48248 Object.defineProperty(TouchService.prototype, "touchEnd$", {
48250 return this._touchEnd$;
48255 Object.defineProperty(TouchService.prototype, "touchCancel$", {
48257 return this._touchCancel$;
48262 Object.defineProperty(TouchService.prototype, "singleTouchDragStart$", {
48264 return this._singleTouchDragStart$;
48269 Object.defineProperty(TouchService.prototype, "singleTouchDrag$", {
48271 return this._singleTouchDrag$;
48276 Object.defineProperty(TouchService.prototype, "singleTouchDragEnd$", {
48278 return this._singleTouchDragEnd$;
48283 Object.defineProperty(TouchService.prototype, "pinch$", {
48285 return this._pinchChange$;
48290 Object.defineProperty(TouchService.prototype, "pinchStart$", {
48292 return this._pinchStart$;
48297 Object.defineProperty(TouchService.prototype, "pinchEnd$", {
48299 return this._pinchEnd$;
48304 return TouchService;
48306 exports.TouchService = TouchService;
48308 },{"rxjs":27,"rxjs/operators":225}],445:[function(require,module,exports){
48310 var __extends = (this && this.__extends) || (function () {
48311 var extendStatics = function (d, b) {
48312 extendStatics = Object.setPrototypeOf ||
48313 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
48314 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
48315 return extendStatics(d, b);
48317 return function (d, b) {
48318 extendStatics(d, b);
48319 function __() { this.constructor = d; }
48320 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
48323 Object.defineProperty(exports, "__esModule", { value: true });
48324 var rxjs_1 = require("rxjs");
48325 var operators_1 = require("rxjs/operators");
48326 var when = require("when");
48327 var Viewer_1 = require("../Viewer");
48328 var Utils_1 = require("../Utils");
48332 * @classdesc The Viewer object represents the navigable image viewer.
48333 * Create a Viewer by specifying a container, client ID, image key and
48334 * other options. The viewer exposes methods and events for programmatic
48337 * In the case of asynchronous methods, MapillaryJS returns promises to
48338 * the results. Notifications are always emitted through JavaScript events.
48340 * The viewer works with a few different coordinate systems.
48342 * Container pixel coordinates
48344 * Pixel coordinates are coordinates on the viewer container. The origin is
48345 * in the top left corner of the container. The axes are
48346 * directed according to the following for a viewer container with a width
48347 * of 640 pixels and height of 480 pixels.
48351 * +------------------------>
48356 * (0, 480) (640, 480)
48359 * Basic image coordinates
48361 * Basic image coordinates represents points in the original image adjusted for
48362 * orientation. They range from 0 to 1 on both axes. The origin is in the top left
48363 * corner of the image and the axes are directed
48364 * according to the following for all image types.
48368 * +------------------------>
48376 * For every camera viewing direction it is possible to convert between these
48377 * two coordinate systems for the current node. The image can be panned and
48378 * zoomed independently of the size of the viewer container resulting in
48379 * different conversion results for different viewing directions.
48381 var Viewer = /** @class */ (function (_super) {
48382 __extends(Viewer, _super);
48384 * Create a new viewer instance.
48386 * @description It is possible to initialize the viewer with or
48389 * When you want to show a specific image in the viewer from
48390 * the start you should initialize it with a key.
48392 * When you do not know the first image key at implementation
48393 * time, e.g. in a map-viewer application you should initialize
48394 * the viewer without a key and call `moveToKey` instead.
48396 * When initializing with a key the viewer is bound to that key
48397 * until the node for that key has been successfully loaded.
48398 * Also, a cover with the image of the key will be shown.
48399 * If the data for that key can not be loaded because the key is
48400 * faulty or other errors occur it is not possible to navigate
48401 * to another key because the viewer is not navigable. The viewer
48402 * becomes navigable when the data for the key has been loaded and
48403 * the image is shown in the viewer. This way of initializing
48404 * the viewer is mostly for embedding in blog posts and similar
48405 * where one wants to show a specific image initially.
48407 * If the viewer is initialized without a key (with null or
48408 * undefined) it is not bound to any particular key and it is
48409 * possible to move to any key with `viewer.moveToKey("<my-image-key>")`.
48410 * If the first move to a key fails it is possible to move to another
48411 * key. The viewer will show a black background until a move
48412 * succeeds. This way of intitializing is suited for a map-viewer
48413 * application when the initial key is not known at implementation
48416 * @param {string} id - Required `id` of a DOM element which will
48417 * be transformed into the viewer.
48418 * @param {string} clientId - Required `Mapillary API ClientID`. Can
48419 * be obtained from https://www.mapillary.com/app/settings/developers.
48420 * @param {string} key - Optional `image-key` to start from. The key
48421 * can be any Mapillary image. If a key is provided the viewer is
48422 * bound to that key until it has been fully loaded. If null is provided
48423 * no image is loaded at viewer initialization and the viewer is not
48424 * bound to any particular key. Any image can then be navigated to
48425 * with e.g. `viewer.moveToKey("<my-image-key>")`.
48426 * @param {IViewerOptions} options - Optional configuration object
48427 * specifing Viewer's and the components' initial setup.
48428 * @param {string} token - Optional bearer token for API requests of
48429 * protected resources.
48433 * var viewer = new Mapillary.Viewer("<element-id>", "<client-id>", "<image-key>");
48436 function Viewer(id, clientId, key, options, token) {
48437 var _this = _super.call(this) || this;
48438 options = options != null ? options : {};
48439 Utils_1.Settings.setOptions(options);
48440 Utils_1.Urls.setOptions(options.url);
48441 _this._navigator = new Viewer_1.Navigator(clientId, options, token);
48442 _this._container = new Viewer_1.Container(id, _this._navigator.stateService, options);
48443 _this._observer = new Viewer_1.Observer(_this, _this._navigator, _this._container);
48444 _this._componentController = new Viewer_1.ComponentController(_this._container, _this._navigator, _this._observer, key, options.component);
48447 Object.defineProperty(Viewer.prototype, "isNavigable", {
48449 * Return a boolean indicating if the viewer is in a navigable state.
48451 * @description The navigable state indicates if the viewer supports
48452 * moving, i.e. calling the {@link moveToKey}, {@link moveDir`}
48453 * and {@link moveCloseTo} methods or changing the authentication state,
48454 * i.e. calling {@link setAuthToken}. The viewer will not be in a navigable
48455 * state if the cover is activated and the viewer has been supplied a key.
48456 * When the cover is deactivated or the viewer is activated without being
48457 * supplied a key it will be navigable.
48459 * @returns {boolean} Boolean indicating whether the viewer is navigable.
48462 return this._componentController.navigable;
48468 * Activate a component.
48470 * @param {string} name - Name of the component which will become active.
48474 * viewer.activateComponent("marker");
48477 Viewer.prototype.activateComponent = function (name) {
48478 this._componentController.activate(name);
48481 * Activate the cover (deactivates all other components).
48483 Viewer.prototype.activateCover = function () {
48484 this._componentController.activateCover();
48487 * Deactivate a component.
48489 * @param {string} name - Name of component which become inactive.
48493 * viewer.deactivateComponent("mouse");
48496 Viewer.prototype.deactivateComponent = function (name) {
48497 this._componentController.deactivate(name);
48500 * Deactivate the cover (activates all components marked as active).
48502 Viewer.prototype.deactivateCover = function () {
48503 this._componentController.deactivateCover();
48506 * Get the bearing of the current viewer camera.
48508 * @description The bearing depends on how the camera
48509 * is currently rotated and does not correspond
48510 * to the compass angle of the current node if the view
48513 * Bearing is measured in degrees clockwise with respect to
48516 * @returns {Promise<number>} Promise to the bearing
48517 * of the current viewer camera.
48521 * viewer.getBearing().then((b) => { console.log(b); });
48524 Viewer.prototype.getBearing = function () {
48526 return when.promise(function (resolve, reject) {
48527 _this._container.renderService.bearing$.pipe(operators_1.first())
48528 .subscribe(function (bearing) {
48530 }, function (error) {
48536 * Get the basic coordinates of the current image that is
48537 * at the center of the viewport.
48539 * @description Basic coordinates are 2D coordinates on the [0, 1] interval
48540 * and have the origin point, (0, 0), at the top left corner and the
48541 * maximum value, (1, 1), at the bottom right corner of the original
48544 * @returns {Promise<number[]>} Promise to the basic coordinates
48545 * of the current image at the center for the viewport.
48549 * viewer.getCenter().then((c) => { console.log(c); });
48552 Viewer.prototype.getCenter = function () {
48554 return when.promise(function (resolve, reject) {
48555 _this._navigator.stateService.getCenter()
48556 .subscribe(function (center) {
48558 }, function (error) {
48566 * @param {string} name - Name of component.
48567 * @returns {Component} The requested component.
48571 * var mouseComponent = viewer.getComponent("mouse");
48574 Viewer.prototype.getComponent = function (name) {
48575 return this._componentController.get(name);
48578 * Returns the viewer's containing HTML element.
48580 * @returns {HTMLElement} The viewer's container.
48582 Viewer.prototype.getContainer = function () {
48583 return this._container.element;
48586 * Get the image's current zoom level.
48588 * @returns {Promise<number>} Promise to the viewers's current
48593 * viewer.getZoom().then((z) => { console.log(z); });
48596 Viewer.prototype.getZoom = function () {
48598 return when.promise(function (resolve, reject) {
48599 _this._navigator.stateService.getZoom()
48600 .subscribe(function (zoom) {
48602 }, function (error) {
48608 * Move close to given latitude and longitude.
48610 * @description Because the method propagates IO errors, these potential errors
48611 * need to be handled by the method caller (see example).
48613 * @param {Number} lat - Latitude, in degrees.
48614 * @param {Number} lon - Longitude, in degrees.
48615 * @returns {Promise<Node>} Promise to the node that was navigated to.
48616 * @throws {Error} If no nodes exist close to provided latitude
48618 * @throws {Error} Propagates any IO errors to the caller.
48619 * @throws {Error} When viewer is not navigable.
48620 * @throws {AbortMapillaryError} When a subsequent move request is made
48621 * before the move close to call has completed.
48625 * viewer.moveCloseTo(0, 0).then(
48626 * (n) => { console.log(n); },
48627 * (e) => { console.error(e); });
48630 Viewer.prototype.moveCloseTo = function (lat, lon) {
48631 var moveCloseTo$ = this.isNavigable ?
48632 this._navigator.moveCloseTo$(lat, lon) :
48633 rxjs_1.throwError(new Error("Calling moveCloseTo is not supported when viewer is not navigable."));
48634 return when.promise(function (resolve, reject) {
48635 moveCloseTo$.subscribe(function (node) {
48637 }, function (error) {
48643 * Navigate in a given direction.
48645 * @description This method has to be called through EdgeDirection enumeration as in the example.
48647 * @param {EdgeDirection} dir - Direction in which which to move.
48648 * @returns {Promise<Node>} Promise to the node that was navigated to.
48649 * @throws {Error} If the current node does not have the edge direction
48650 * or the edges has not yet been cached.
48651 * @throws {Error} Propagates any IO errors to the caller.
48652 * @throws {Error} When viewer is not navigable.
48653 * @throws {AbortMapillaryError} When a subsequent move request is made
48654 * before the move dir call has completed.
48658 * viewer.moveDir(Mapillary.EdgeDirection.Next).then(
48659 * (n) => { console.log(n); },
48660 * (e) => { console.error(e); });
48663 Viewer.prototype.moveDir = function (dir) {
48664 var moveDir$ = this.isNavigable ?
48665 this._navigator.moveDir$(dir) :
48666 rxjs_1.throwError(new Error("Calling moveDir is not supported when viewer is not navigable."));
48667 return when.promise(function (resolve, reject) {
48668 moveDir$.subscribe(function (node) {
48670 }, function (error) {
48676 * Navigate to a given image key.
48678 * @param {string} key - A valid Mapillary image key.
48679 * @returns {Promise<Node>} Promise to the node that was navigated to.
48680 * @throws {Error} Propagates any IO errors to the caller.
48681 * @throws {Error} When viewer is not navigable.
48682 * @throws {AbortMapillaryError} When a subsequent move request is made
48683 * before the move to key call has completed.
48687 * viewer.moveToKey("<my key>").then(
48688 * (n) => { console.log(n); },
48689 * (e) => { console.error(e); });
48692 Viewer.prototype.moveToKey = function (key) {
48693 var moveToKey$ = this.isNavigable ?
48694 this._navigator.moveToKey$(key) :
48695 rxjs_1.throwError(new Error("Calling moveToKey is not supported when viewer is not navigable."));
48696 return when.promise(function (resolve, reject) {
48697 moveToKey$.subscribe(function (node) {
48699 }, function (error) {
48705 * Project basic image coordinates for the current node to canvas pixel
48708 * @description The basic image coordinates may not always correspond to a
48709 * pixel point that lies in the visible area of the viewer container.
48711 * @param {Array<number>} basicPoint - Basic images coordinates to project.
48712 * @returns {Promise<Array<number>>} Promise to the pixel coordinates corresponding
48713 * to the basic image point.
48717 * viewer.projectFromBasic([0.3, 0.7])
48718 * .then((pixelPoint) => { console.log(pixelPoint); });
48721 Viewer.prototype.projectFromBasic = function (basicPoint) {
48723 return when.promise(function (resolve, reject) {
48724 _this._observer.projectBasic$(basicPoint)
48725 .subscribe(function (pixelPoint) {
48726 resolve(pixelPoint);
48727 }, function (error) {
48733 * Detect the viewer's new width and height and resize it.
48735 * @description The components will also detect the viewer's
48736 * new size and resize their rendered elements if needed.
48743 Viewer.prototype.resize = function () {
48744 this._container.renderService.resize$.next(null);
48747 * Set a bearer token for authenticated API requests of
48748 * protected resources.
48750 * @description When the supplied token is null or undefined,
48751 * any previously set bearer token will be cleared and the
48752 * viewer will make unauthenticated requests.
48754 * Calling setAuthToken aborts all outstanding move requests.
48755 * The promises of those move requests will be rejected with a
48756 * {@link AbortMapillaryError} the rejections need to be caught.
48758 * Calling setAuthToken also resets the complete viewer cache
48759 * so it should not be called repeatedly.
48761 * @param {string} [token] token - Bearer token.
48762 * @returns {Promise<void>} Promise that resolves after token
48765 * @throws {Error} When viewer is not navigable.
48769 * viewer.setAuthToken("<my token>")
48770 * .then(() => { console.log("token set"); });
48773 Viewer.prototype.setAuthToken = function (token) {
48774 var setToken$ = this.isNavigable ?
48775 this._navigator.setToken$(token) :
48776 rxjs_1.throwError(new Error("Calling setAuthToken is not supported when viewer is not navigable."));
48777 return when.promise(function (resolve, reject) {
48779 .subscribe(function () {
48780 resolve(undefined);
48781 }, function (error) {
48787 * Set the basic coordinates of the current image to be in the
48788 * center of the viewport.
48790 * @description Basic coordinates are 2D coordinates on the [0, 1] interval
48791 * and has the origin point, (0, 0), at the top left corner and the
48792 * maximum value, (1, 1), at the bottom right corner of the original
48795 * @param {number[]} The basic coordinates of the current
48796 * image to be at the center for the viewport.
48800 * viewer.setCenter([0.5, 0.5]);
48803 Viewer.prototype.setCenter = function (center) {
48804 this._navigator.stateService.setCenter(center);
48807 * Set the filter selecting nodes to use when calculating
48808 * the spatial edges.
48810 * @description The following filter types are supported:
48814 * `["==", key, value]` equality: `node[key] = value`
48816 * `["!=", key, value]` inequality: `node[key] ≠value`
48818 * `["<", key, value]` less than: `node[key] < value`
48820 * `["<=", key, value]` less than or equal: `node[key] ≤ value`
48822 * `[">", key, value]` greater than: `node[key] > value`
48824 * `[">=", key, value]` greater than or equal: `node[key] ≥ value`
48828 * `["in", key, v0, ..., vn]` set inclusion: `node[key] ∈ {v0, ..., vn}`
48830 * `["!in", key, v0, ..., vn]` set exclusion: `node[key] ∉ {v0, ..., vn}`
48834 * `["all", f0, ..., fn]` logical `AND`: `f0 ∧ ... ∧ fn`
48836 * A key must be a string that identifies a property name of a
48837 * simple {@link Node} property. A value must be a string, number, or
48838 * boolean. Strictly-typed comparisons are used. The values
48839 * `f0, ..., fn` of the combining filter must be filter expressions.
48841 * Clear the filter by setting it to null or empty array.
48843 * @param {FilterExpression} filter - The filter expression.
48844 * @returns {Promise<void>} Promise that resolves after filter is applied.
48848 * viewer.setFilter(["==", "sequenceKey", "<my sequence key>"]);
48851 Viewer.prototype.setFilter = function (filter) {
48853 return when.promise(function (resolve, reject) {
48854 _this._navigator.setFilter$(filter)
48855 .subscribe(function () {
48856 resolve(undefined);
48857 }, function (error) {
48863 * Set the viewer's render mode.
48865 * @param {RenderMode} renderMode - Render mode.
48869 * viewer.setRenderMode(Mapillary.RenderMode.Letterbox);
48872 Viewer.prototype.setRenderMode = function (renderMode) {
48873 this._container.renderService.renderMode$.next(renderMode);
48876 * Set the viewer's transition mode.
48878 * @param {TransitionMode} transitionMode - Transition mode.
48882 * viewer.setTransitionMode(Mapillary.TransitionMode.Instantaneous);
48885 Viewer.prototype.setTransitionMode = function (transitionMode) {
48886 this._navigator.stateService.setTransitionMode(transitionMode);
48889 * Set the image's current zoom level.
48891 * @description Possible zoom level values are on the [0, 3] interval.
48892 * Zero means zooming out to fit the image to the view whereas three
48893 * shows the highest level of detail.
48895 * @param {number} The image's current zoom level.
48899 * viewer.setZoom(2);
48902 Viewer.prototype.setZoom = function (zoom) {
48903 this._navigator.stateService.setZoom(zoom);
48906 * Unproject canvas pixel coordinates to an ILatLon representing geographical
48909 * @description The pixel point may not always correspond to geographical
48910 * coordinates. In the case of no correspondence the returned value will
48913 * @param {Array<number>} pixelPoint - Pixel coordinates to unproject.
48914 * @returns {Promise<ILatLon>} Promise to the latLon corresponding to the pixel point.
48918 * viewer.unproject([100, 100])
48919 * .then((latLon) => { console.log(latLon); });
48922 Viewer.prototype.unproject = function (pixelPoint) {
48924 return when.promise(function (resolve, reject) {
48925 _this._observer.unproject$(pixelPoint)
48926 .subscribe(function (latLon) {
48928 }, function (error) {
48934 * Unproject canvas pixel coordinates to basic image coordinates for the
48937 * @description The pixel point may not always correspond to basic image
48938 * coordinates. In the case of no correspondence the returned value will
48941 * @param {Array<number>} pixelPoint - Pixel coordinates to unproject.
48942 * @returns {Promise<ILatLon>} Promise to the basic coordinates corresponding
48943 * to the pixel point.
48947 * viewer.unprojectToBasic([100, 100])
48948 * .then((basicPoint) => { console.log(basicPoint); });
48951 Viewer.prototype.unprojectToBasic = function (pixelPoint) {
48953 return when.promise(function (resolve, reject) {
48954 _this._observer.unprojectBasic$(pixelPoint)
48955 .subscribe(function (basicPoint) {
48956 resolve(basicPoint);
48957 }, function (error) {
48963 * Fired when the viewing direction of the camera changes.
48965 * @description Related to the computed compass angle
48966 * ({@link Node.computedCa}) from SfM, not the original EXIF compass
48970 * @type {number} bearing - Value indicating the current bearing
48971 * measured in degrees clockwise with respect to north.
48973 Viewer.bearingchanged = "bearingchanged";
48975 * Fired when a pointing device (usually a mouse) is pressed and released at
48976 * the same point in the viewer.
48978 * @type {IViewerMouseEvent} event - Viewer mouse event data.
48980 Viewer.click = "click";
48982 * Fired when the right button of the mouse is clicked within the viewer.
48984 * @type {IViewerMouseEvent} event - Viewer mouse event data.
48986 Viewer.contextmenu = "contextmenu";
48988 * Fired when a pointing device (usually a mouse) is clicked twice at
48989 * the same point in the viewer.
48991 * @type {IViewerMouseEvent} event - Viewer mouse event data.
48993 Viewer.dblclick = "dblclick";
48995 * Fired when the viewer is loading more data.
48997 * @type {boolean} loading - Boolean indicating whether the viewer is loading.
48999 Viewer.loadingchanged = "loadingchanged";
49001 * Fired when a pointing device (usually a mouse) is pressed within the viewer.
49003 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49005 Viewer.mousedown = "mousedown";
49007 * Fired when a pointing device (usually a mouse) is moved within the viewer.
49008 * @description Will not fire when the mouse is actively used, e.g. for drag pan.
49010 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49012 Viewer.mousemove = "mousemove";
49014 * Fired when a pointing device (usually a mouse) leaves the viewer's canvas.
49016 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49018 Viewer.mouseout = "mouseout";
49020 * Fired when a pointing device (usually a mouse) is moved onto the viewer's canvas.
49022 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49024 Viewer.mouseover = "mouseover";
49026 * Fired when a pointing device (usually a mouse) is released within the viewer.
49028 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49030 Viewer.mouseup = "mouseup";
49032 * Fired when the viewer motion stops and it is in a fixed
49033 * position with a fixed point of view.
49036 Viewer.moveend = "moveend";
49038 * Fired when the motion from one view to another start,
49039 * either by changing the position (e.g. when changing node) or
49040 * when changing point of view (e.g. by interaction such as pan and zoom).
49043 Viewer.movestart = "movestart";
49045 * Fired when the navigable state of the viewer changes.
49047 * @description The navigable state indicates if the viewer supports
49048 * moving, i.e. calling the `moveToKey`, `moveDir` and `moveCloseTo`
49049 * methods. The viewer will not be in a navigable state if the cover
49050 * is activated and the viewer has been supplied a key. When the cover
49051 * is deactivated or activated without being supplied a key it will
49055 * @type {boolean} navigable - Boolean indicating whether the viewer is navigable.
49057 Viewer.navigablechanged = "navigablechanged";
49059 * Fired every time the viewer navigates to a new node.
49061 * @type {Node} node - Current node.
49063 Viewer.nodechanged = "nodechanged";
49065 * Fired every time the sequence edges of the current node changes.
49067 * @type {IEdgeStatus} status - The edge status object.
49069 Viewer.sequenceedgeschanged = "sequenceedgeschanged";
49071 * Fired every time the spatial edges of the current node changes.
49073 * @type {IEdgeStatus} status - The edge status object.
49075 Viewer.spatialedgeschanged = "spatialedgeschanged";
49077 }(Utils_1.EventEmitter));
49078 exports.Viewer = Viewer;
49080 },{"../Utils":285,"../Viewer":286,"rxjs":27,"rxjs/operators":225,"when":272}]},{},[280])(280)
49082 //# sourceMappingURL=mapillary.js.map