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":243}],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){
494 * The buffer module from node.js, for the browser.
496 * @author Feross Aboukhadijeh <https://feross.org>
499 /* eslint-disable no-proto */
503 var base64 = require('base64-js')
504 var ieee754 = require('ieee754')
506 exports.Buffer = Buffer
507 exports.SlowBuffer = SlowBuffer
508 exports.INSPECT_MAX_BYTES = 50
510 var K_MAX_LENGTH = 0x7fffffff
511 exports.kMaxLength = K_MAX_LENGTH
514 * If `Buffer.TYPED_ARRAY_SUPPORT`:
515 * === true Use Uint8Array implementation (fastest)
516 * === false Print warning and recommend using `buffer` v4.x which has an Object
517 * implementation (most compatible, even IE6)
519 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
520 * Opera 11.6+, iOS 4.2+.
522 * We report that the browser does not support typed arrays if the are not subclassable
523 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
524 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
525 * for __proto__ and has a buggy typed array implementation.
527 Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
529 if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
530 typeof console.error === 'function') {
532 'This browser lacks typed array (Uint8Array) support which is required by ' +
533 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
537 function typedArraySupport () {
538 // Can typed array instances can be augmented?
540 var arr = new Uint8Array(1)
541 arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
542 return arr.foo() === 42
548 Object.defineProperty(Buffer.prototype, 'parent', {
551 if (!Buffer.isBuffer(this)) return undefined
556 Object.defineProperty(Buffer.prototype, 'offset', {
559 if (!Buffer.isBuffer(this)) return undefined
560 return this.byteOffset
564 function createBuffer (length) {
565 if (length > K_MAX_LENGTH) {
566 throw new RangeError('The value "' + length + '" is invalid for option "size"')
568 // Return an augmented `Uint8Array` instance
569 var buf = new Uint8Array(length)
570 buf.__proto__ = Buffer.prototype
575 * The Buffer constructor returns instances of `Uint8Array` that have their
576 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
577 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
578 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
579 * returns a single octet.
581 * The `Uint8Array` prototype remains unmodified.
584 function Buffer (arg, encodingOrOffset, length) {
586 if (typeof arg === 'number') {
587 if (typeof encodingOrOffset === 'string') {
589 'The "string" argument must be of type string. Received type number'
592 return allocUnsafe(arg)
594 return from(arg, encodingOrOffset, length)
597 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
598 if (typeof Symbol !== 'undefined' && Symbol.species != null &&
599 Buffer[Symbol.species] === Buffer) {
600 Object.defineProperty(Buffer, Symbol.species, {
608 Buffer.poolSize = 8192 // not used by this implementation
610 function from (value, encodingOrOffset, length) {
611 if (typeof value === 'string') {
612 return fromString(value, encodingOrOffset)
615 if (ArrayBuffer.isView(value)) {
616 return fromArrayLike(value)
621 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
622 'or Array-like Object. Received type ' + (typeof value)
626 if (isInstance(value, ArrayBuffer) ||
627 (value && isInstance(value.buffer, ArrayBuffer))) {
628 return fromArrayBuffer(value, encodingOrOffset, length)
631 if (typeof value === 'number') {
633 'The "value" argument must not be of type number. Received type number'
637 var valueOf = value.valueOf && value.valueOf()
638 if (valueOf != null && valueOf !== value) {
639 return Buffer.from(valueOf, encodingOrOffset, length)
642 var b = fromObject(value)
645 if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
646 typeof value[Symbol.toPrimitive] === 'function') {
648 value[Symbol.toPrimitive]('string'), encodingOrOffset, length
653 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
654 'or Array-like Object. Received type ' + (typeof value)
659 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
660 * if value is a number.
661 * Buffer.from(str[, encoding])
663 * Buffer.from(buffer)
664 * Buffer.from(arrayBuffer[, byteOffset[, length]])
666 Buffer.from = function (value, encodingOrOffset, length) {
667 return from(value, encodingOrOffset, length)
670 // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
671 // https://github.com/feross/buffer/pull/148
672 Buffer.prototype.__proto__ = Uint8Array.prototype
673 Buffer.__proto__ = Uint8Array
675 function assertSize (size) {
676 if (typeof size !== 'number') {
677 throw new TypeError('"size" argument must be of type number')
678 } else if (size < 0) {
679 throw new RangeError('The value "' + size + '" is invalid for option "size"')
683 function alloc (size, fill, encoding) {
686 return createBuffer(size)
688 if (fill !== undefined) {
689 // Only pay attention to encoding if it's a string. This
690 // prevents accidentally sending in a number that would
691 // be interpretted as a start offset.
692 return typeof encoding === 'string'
693 ? createBuffer(size).fill(fill, encoding)
694 : createBuffer(size).fill(fill)
696 return createBuffer(size)
700 * Creates a new filled Buffer instance.
701 * alloc(size[, fill[, encoding]])
703 Buffer.alloc = function (size, fill, encoding) {
704 return alloc(size, fill, encoding)
707 function allocUnsafe (size) {
709 return createBuffer(size < 0 ? 0 : checked(size) | 0)
713 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
715 Buffer.allocUnsafe = function (size) {
716 return allocUnsafe(size)
719 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
721 Buffer.allocUnsafeSlow = function (size) {
722 return allocUnsafe(size)
725 function fromString (string, encoding) {
726 if (typeof encoding !== 'string' || encoding === '') {
730 if (!Buffer.isEncoding(encoding)) {
731 throw new TypeError('Unknown encoding: ' + encoding)
734 var length = byteLength(string, encoding) | 0
735 var buf = createBuffer(length)
737 var actual = buf.write(string, encoding)
739 if (actual !== length) {
740 // Writing a hex string, for example, that contains invalid characters will
741 // cause everything after the first invalid character to be ignored. (e.g.
742 // 'abxxcd' will be treated as 'ab')
743 buf = buf.slice(0, actual)
749 function fromArrayLike (array) {
750 var length = array.length < 0 ? 0 : checked(array.length) | 0
751 var buf = createBuffer(length)
752 for (var i = 0; i < length; i += 1) {
753 buf[i] = array[i] & 255
758 function fromArrayBuffer (array, byteOffset, length) {
759 if (byteOffset < 0 || array.byteLength < byteOffset) {
760 throw new RangeError('"offset" is outside of buffer bounds')
763 if (array.byteLength < byteOffset + (length || 0)) {
764 throw new RangeError('"length" is outside of buffer bounds')
768 if (byteOffset === undefined && length === undefined) {
769 buf = new Uint8Array(array)
770 } else if (length === undefined) {
771 buf = new Uint8Array(array, byteOffset)
773 buf = new Uint8Array(array, byteOffset, length)
776 // Return an augmented `Uint8Array` instance
777 buf.__proto__ = Buffer.prototype
781 function fromObject (obj) {
782 if (Buffer.isBuffer(obj)) {
783 var len = checked(obj.length) | 0
784 var buf = createBuffer(len)
786 if (buf.length === 0) {
790 obj.copy(buf, 0, 0, len)
794 if (obj.length !== undefined) {
795 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
796 return createBuffer(0)
798 return fromArrayLike(obj)
801 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
802 return fromArrayLike(obj.data)
806 function checked (length) {
807 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
808 // length is NaN (which is otherwise coerced to zero.)
809 if (length >= K_MAX_LENGTH) {
810 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
811 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
816 function SlowBuffer (length) {
817 if (+length != length) { // eslint-disable-line eqeqeq
820 return Buffer.alloc(+length)
823 Buffer.isBuffer = function isBuffer (b) {
824 return b != null && b._isBuffer === true &&
825 b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
828 Buffer.compare = function compare (a, b) {
829 if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
830 if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
831 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
833 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
837 if (a === b) return 0
842 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
855 Buffer.isEncoding = function isEncoding (encoding) {
856 switch (String(encoding).toLowerCase()) {
874 Buffer.concat = function concat (list, length) {
875 if (!Array.isArray(list)) {
876 throw new TypeError('"list" argument must be an Array of Buffers')
879 if (list.length === 0) {
880 return Buffer.alloc(0)
884 if (length === undefined) {
886 for (i = 0; i < list.length; ++i) {
887 length += list[i].length
891 var buffer = Buffer.allocUnsafe(length)
893 for (i = 0; i < list.length; ++i) {
895 if (isInstance(buf, Uint8Array)) {
896 buf = Buffer.from(buf)
898 if (!Buffer.isBuffer(buf)) {
899 throw new TypeError('"list" argument must be an Array of Buffers')
901 buf.copy(buffer, pos)
907 function byteLength (string, encoding) {
908 if (Buffer.isBuffer(string)) {
911 if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
912 return string.byteLength
914 if (typeof string !== 'string') {
916 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
917 'Received type ' + typeof string
921 var len = string.length
922 var mustMatch = (arguments.length > 2 && arguments[2] === true)
923 if (!mustMatch && len === 0) return 0
925 // Use a for loop to avoid recursion
926 var loweredCase = false
935 return utf8ToBytes(string).length
944 return base64ToBytes(string).length
947 return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
949 encoding = ('' + encoding).toLowerCase()
954 Buffer.byteLength = byteLength
956 function slowToString (encoding, start, end) {
957 var loweredCase = false
959 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
960 // property of a typed array.
962 // This behaves neither like String nor Uint8Array in that we set start/end
963 // to their upper/lower bounds if the value passed is out of range.
964 // undefined is handled specially as per ECMA-262 6th Edition,
965 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
966 if (start === undefined || start < 0) {
969 // Return early if start > this.length. Done here to prevent potential uint32
970 // coercion fail below.
971 if (start > this.length) {
975 if (end === undefined || end > this.length) {
983 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
991 if (!encoding) encoding = 'utf8'
996 return hexSlice(this, start, end)
1000 return utf8Slice(this, start, end)
1003 return asciiSlice(this, start, end)
1007 return latin1Slice(this, start, end)
1010 return base64Slice(this, start, end)
1016 return utf16leSlice(this, start, end)
1019 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1020 encoding = (encoding + '').toLowerCase()
1026 // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
1027 // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
1028 // reliably in a browserify context because there could be multiple different
1029 // copies of the 'buffer' package in use. This method works even for Buffer
1030 // instances that were created from another copy of the `buffer` package.
1031 // See: https://github.com/feross/buffer/issues/154
1032 Buffer.prototype._isBuffer = true
1034 function swap (b, n, m) {
1040 Buffer.prototype.swap16 = function swap16 () {
1041 var len = this.length
1042 if (len % 2 !== 0) {
1043 throw new RangeError('Buffer size must be a multiple of 16-bits')
1045 for (var i = 0; i < len; i += 2) {
1046 swap(this, i, i + 1)
1051 Buffer.prototype.swap32 = function swap32 () {
1052 var len = this.length
1053 if (len % 4 !== 0) {
1054 throw new RangeError('Buffer size must be a multiple of 32-bits')
1056 for (var i = 0; i < len; i += 4) {
1057 swap(this, i, i + 3)
1058 swap(this, i + 1, i + 2)
1063 Buffer.prototype.swap64 = function swap64 () {
1064 var len = this.length
1065 if (len % 8 !== 0) {
1066 throw new RangeError('Buffer size must be a multiple of 64-bits')
1068 for (var i = 0; i < len; i += 8) {
1069 swap(this, i, i + 7)
1070 swap(this, i + 1, i + 6)
1071 swap(this, i + 2, i + 5)
1072 swap(this, i + 3, i + 4)
1077 Buffer.prototype.toString = function toString () {
1078 var length = this.length
1079 if (length === 0) return ''
1080 if (arguments.length === 0) return utf8Slice(this, 0, length)
1081 return slowToString.apply(this, arguments)
1084 Buffer.prototype.toLocaleString = Buffer.prototype.toString
1086 Buffer.prototype.equals = function equals (b) {
1087 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
1088 if (this === b) return true
1089 return Buffer.compare(this, b) === 0
1092 Buffer.prototype.inspect = function inspect () {
1094 var max = exports.INSPECT_MAX_BYTES
1095 str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
1096 if (this.length > max) str += ' ... '
1097 return '<Buffer ' + str + '>'
1100 Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
1101 if (isInstance(target, Uint8Array)) {
1102 target = Buffer.from(target, target.offset, target.byteLength)
1104 if (!Buffer.isBuffer(target)) {
1105 throw new TypeError(
1106 'The "target" argument must be one of type Buffer or Uint8Array. ' +
1107 'Received type ' + (typeof target)
1111 if (start === undefined) {
1114 if (end === undefined) {
1115 end = target ? target.length : 0
1117 if (thisStart === undefined) {
1120 if (thisEnd === undefined) {
1121 thisEnd = this.length
1124 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1125 throw new RangeError('out of range index')
1128 if (thisStart >= thisEnd && start >= end) {
1131 if (thisStart >= thisEnd) {
1143 if (this === target) return 0
1145 var x = thisEnd - thisStart
1147 var len = Math.min(x, y)
1149 var thisCopy = this.slice(thisStart, thisEnd)
1150 var targetCopy = target.slice(start, end)
1152 for (var i = 0; i < len; ++i) {
1153 if (thisCopy[i] !== targetCopy[i]) {
1160 if (x < y) return -1
1165 // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1166 // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1169 // - buffer - a Buffer to search
1170 // - val - a string, Buffer, or number
1171 // - byteOffset - an index into `buffer`; will be clamped to an int32
1172 // - encoding - an optional encoding, relevant is val is a string
1173 // - dir - true for indexOf, false for lastIndexOf
1174 function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
1175 // Empty buffer means no match
1176 if (buffer.length === 0) return -1
1178 // Normalize byteOffset
1179 if (typeof byteOffset === 'string') {
1180 encoding = byteOffset
1182 } else if (byteOffset > 0x7fffffff) {
1183 byteOffset = 0x7fffffff
1184 } else if (byteOffset < -0x80000000) {
1185 byteOffset = -0x80000000
1187 byteOffset = +byteOffset // Coerce to Number.
1188 if (numberIsNaN(byteOffset)) {
1189 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1190 byteOffset = dir ? 0 : (buffer.length - 1)
1193 // Normalize byteOffset: negative offsets start from the end of the buffer
1194 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
1195 if (byteOffset >= buffer.length) {
1197 else byteOffset = buffer.length - 1
1198 } else if (byteOffset < 0) {
1199 if (dir) byteOffset = 0
1204 if (typeof val === 'string') {
1205 val = Buffer.from(val, encoding)
1208 // Finally, search either indexOf (if dir is true) or lastIndexOf
1209 if (Buffer.isBuffer(val)) {
1210 // Special case: looking for empty string/buffer always fails
1211 if (val.length === 0) {
1214 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1215 } else if (typeof val === 'number') {
1216 val = val & 0xFF // Search for a byte value [0-255]
1217 if (typeof Uint8Array.prototype.indexOf === 'function') {
1219 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1221 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1224 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
1227 throw new TypeError('val must be string, number or Buffer')
1230 function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1232 var arrLength = arr.length
1233 var valLength = val.length
1235 if (encoding !== undefined) {
1236 encoding = String(encoding).toLowerCase()
1237 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1238 encoding === 'utf16le' || encoding === 'utf-16le') {
1239 if (arr.length < 2 || val.length < 2) {
1249 function read (buf, i) {
1250 if (indexSize === 1) {
1253 return buf.readUInt16BE(i * indexSize)
1260 for (i = byteOffset; i < arrLength; i++) {
1261 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1262 if (foundIndex === -1) foundIndex = i
1263 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1265 if (foundIndex !== -1) i -= i - foundIndex
1270 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
1271 for (i = byteOffset; i >= 0; i--) {
1273 for (var j = 0; j < valLength; j++) {
1274 if (read(arr, i + j) !== read(val, j)) {
1286 Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1287 return this.indexOf(val, byteOffset, encoding) !== -1
1290 Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1291 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1294 Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1295 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1298 function hexWrite (buf, string, offset, length) {
1299 offset = Number(offset) || 0
1300 var remaining = buf.length - offset
1304 length = Number(length)
1305 if (length > remaining) {
1310 var strLen = string.length
1312 if (length > strLen / 2) {
1315 for (var i = 0; i < length; ++i) {
1316 var parsed = parseInt(string.substr(i * 2, 2), 16)
1317 if (numberIsNaN(parsed)) return i
1318 buf[offset + i] = parsed
1323 function utf8Write (buf, string, offset, length) {
1324 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1327 function asciiWrite (buf, string, offset, length) {
1328 return blitBuffer(asciiToBytes(string), buf, offset, length)
1331 function latin1Write (buf, string, offset, length) {
1332 return asciiWrite(buf, string, offset, length)
1335 function base64Write (buf, string, offset, length) {
1336 return blitBuffer(base64ToBytes(string), buf, offset, length)
1339 function ucs2Write (buf, string, offset, length) {
1340 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1343 Buffer.prototype.write = function write (string, offset, length, encoding) {
1344 // Buffer#write(string)
1345 if (offset === undefined) {
1347 length = this.length
1349 // Buffer#write(string, encoding)
1350 } else if (length === undefined && typeof offset === 'string') {
1352 length = this.length
1354 // Buffer#write(string, offset[, length][, encoding])
1355 } else if (isFinite(offset)) {
1356 offset = offset >>> 0
1357 if (isFinite(length)) {
1358 length = length >>> 0
1359 if (encoding === undefined) encoding = 'utf8'
1366 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1370 var remaining = this.length - offset
1371 if (length === undefined || length > remaining) length = remaining
1373 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1374 throw new RangeError('Attempt to write outside buffer bounds')
1377 if (!encoding) encoding = 'utf8'
1379 var loweredCase = false
1383 return hexWrite(this, string, offset, length)
1387 return utf8Write(this, string, offset, length)
1390 return asciiWrite(this, string, offset, length)
1394 return latin1Write(this, string, offset, length)
1397 // Warning: maxLength not taken into account in base64Write
1398 return base64Write(this, string, offset, length)
1404 return ucs2Write(this, string, offset, length)
1407 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1408 encoding = ('' + encoding).toLowerCase()
1414 Buffer.prototype.toJSON = function toJSON () {
1417 data: Array.prototype.slice.call(this._arr || this, 0)
1421 function base64Slice (buf, start, end) {
1422 if (start === 0 && end === buf.length) {
1423 return base64.fromByteArray(buf)
1425 return base64.fromByteArray(buf.slice(start, end))
1429 function utf8Slice (buf, start, end) {
1430 end = Math.min(buf.length, end)
1435 var firstByte = buf[i]
1436 var codePoint = null
1437 var bytesPerSequence = (firstByte > 0xEF) ? 4
1438 : (firstByte > 0xDF) ? 3
1439 : (firstByte > 0xBF) ? 2
1442 if (i + bytesPerSequence <= end) {
1443 var secondByte, thirdByte, fourthByte, tempCodePoint
1445 switch (bytesPerSequence) {
1447 if (firstByte < 0x80) {
1448 codePoint = firstByte
1452 secondByte = buf[i + 1]
1453 if ((secondByte & 0xC0) === 0x80) {
1454 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1455 if (tempCodePoint > 0x7F) {
1456 codePoint = tempCodePoint
1461 secondByte = buf[i + 1]
1462 thirdByte = buf[i + 2]
1463 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1464 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1465 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1466 codePoint = tempCodePoint
1471 secondByte = buf[i + 1]
1472 thirdByte = buf[i + 2]
1473 fourthByte = buf[i + 3]
1474 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1475 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1476 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1477 codePoint = tempCodePoint
1483 if (codePoint === null) {
1484 // we did not generate a valid codePoint so insert a
1485 // replacement char (U+FFFD) and advance only 1 byte
1487 bytesPerSequence = 1
1488 } else if (codePoint > 0xFFFF) {
1489 // encode to utf16 (surrogate pair dance)
1490 codePoint -= 0x10000
1491 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1492 codePoint = 0xDC00 | codePoint & 0x3FF
1496 i += bytesPerSequence
1499 return decodeCodePointsArray(res)
1502 // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1503 // the lowest limit is Chrome, with 0x10000 args.
1504 // We go 1 magnitude less, for safety
1505 var MAX_ARGUMENTS_LENGTH = 0x1000
1507 function decodeCodePointsArray (codePoints) {
1508 var len = codePoints.length
1509 if (len <= MAX_ARGUMENTS_LENGTH) {
1510 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1513 // Decode in chunks to avoid "call stack size exceeded".
1517 res += String.fromCharCode.apply(
1519 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1525 function asciiSlice (buf, start, end) {
1527 end = Math.min(buf.length, end)
1529 for (var i = start; i < end; ++i) {
1530 ret += String.fromCharCode(buf[i] & 0x7F)
1535 function latin1Slice (buf, start, end) {
1537 end = Math.min(buf.length, end)
1539 for (var i = start; i < end; ++i) {
1540 ret += String.fromCharCode(buf[i])
1545 function hexSlice (buf, start, end) {
1546 var len = buf.length
1548 if (!start || start < 0) start = 0
1549 if (!end || end < 0 || end > len) end = len
1552 for (var i = start; i < end; ++i) {
1553 out += toHex(buf[i])
1558 function utf16leSlice (buf, start, end) {
1559 var bytes = buf.slice(start, end)
1561 for (var i = 0; i < bytes.length; i += 2) {
1562 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
1567 Buffer.prototype.slice = function slice (start, end) {
1568 var len = this.length
1570 end = end === undefined ? len : ~~end
1574 if (start < 0) start = 0
1575 } else if (start > len) {
1581 if (end < 0) end = 0
1582 } else if (end > len) {
1586 if (end < start) end = start
1588 var newBuf = this.subarray(start, end)
1589 // Return an augmented `Uint8Array` instance
1590 newBuf.__proto__ = Buffer.prototype
1595 * Need to make sure that buffer isn't trying to write out of bounds.
1597 function checkOffset (offset, ext, length) {
1598 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1599 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1602 Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1603 offset = offset >>> 0
1604 byteLength = byteLength >>> 0
1605 if (!noAssert) checkOffset(offset, byteLength, this.length)
1607 var val = this[offset]
1610 while (++i < byteLength && (mul *= 0x100)) {
1611 val += this[offset + i] * mul
1617 Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1618 offset = offset >>> 0
1619 byteLength = byteLength >>> 0
1621 checkOffset(offset, byteLength, this.length)
1624 var val = this[offset + --byteLength]
1626 while (byteLength > 0 && (mul *= 0x100)) {
1627 val += this[offset + --byteLength] * mul
1633 Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1634 offset = offset >>> 0
1635 if (!noAssert) checkOffset(offset, 1, this.length)
1639 Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1640 offset = offset >>> 0
1641 if (!noAssert) checkOffset(offset, 2, this.length)
1642 return this[offset] | (this[offset + 1] << 8)
1645 Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1646 offset = offset >>> 0
1647 if (!noAssert) checkOffset(offset, 2, this.length)
1648 return (this[offset] << 8) | this[offset + 1]
1651 Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1652 offset = offset >>> 0
1653 if (!noAssert) checkOffset(offset, 4, this.length)
1655 return ((this[offset]) |
1656 (this[offset + 1] << 8) |
1657 (this[offset + 2] << 16)) +
1658 (this[offset + 3] * 0x1000000)
1661 Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1662 offset = offset >>> 0
1663 if (!noAssert) checkOffset(offset, 4, this.length)
1665 return (this[offset] * 0x1000000) +
1666 ((this[offset + 1] << 16) |
1667 (this[offset + 2] << 8) |
1671 Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1672 offset = offset >>> 0
1673 byteLength = byteLength >>> 0
1674 if (!noAssert) checkOffset(offset, byteLength, this.length)
1676 var val = this[offset]
1679 while (++i < byteLength && (mul *= 0x100)) {
1680 val += this[offset + i] * mul
1684 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1689 Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1690 offset = offset >>> 0
1691 byteLength = byteLength >>> 0
1692 if (!noAssert) checkOffset(offset, byteLength, this.length)
1696 var val = this[offset + --i]
1697 while (i > 0 && (mul *= 0x100)) {
1698 val += this[offset + --i] * mul
1702 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1707 Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1708 offset = offset >>> 0
1709 if (!noAssert) checkOffset(offset, 1, this.length)
1710 if (!(this[offset] & 0x80)) return (this[offset])
1711 return ((0xff - this[offset] + 1) * -1)
1714 Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1715 offset = offset >>> 0
1716 if (!noAssert) checkOffset(offset, 2, this.length)
1717 var val = this[offset] | (this[offset + 1] << 8)
1718 return (val & 0x8000) ? val | 0xFFFF0000 : val
1721 Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1722 offset = offset >>> 0
1723 if (!noAssert) checkOffset(offset, 2, this.length)
1724 var val = this[offset + 1] | (this[offset] << 8)
1725 return (val & 0x8000) ? val | 0xFFFF0000 : val
1728 Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1729 offset = offset >>> 0
1730 if (!noAssert) checkOffset(offset, 4, this.length)
1732 return (this[offset]) |
1733 (this[offset + 1] << 8) |
1734 (this[offset + 2] << 16) |
1735 (this[offset + 3] << 24)
1738 Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1739 offset = offset >>> 0
1740 if (!noAssert) checkOffset(offset, 4, this.length)
1742 return (this[offset] << 24) |
1743 (this[offset + 1] << 16) |
1744 (this[offset + 2] << 8) |
1748 Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1749 offset = offset >>> 0
1750 if (!noAssert) checkOffset(offset, 4, this.length)
1751 return ieee754.read(this, offset, true, 23, 4)
1754 Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1755 offset = offset >>> 0
1756 if (!noAssert) checkOffset(offset, 4, this.length)
1757 return ieee754.read(this, offset, false, 23, 4)
1760 Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1761 offset = offset >>> 0
1762 if (!noAssert) checkOffset(offset, 8, this.length)
1763 return ieee754.read(this, offset, true, 52, 8)
1766 Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1767 offset = offset >>> 0
1768 if (!noAssert) checkOffset(offset, 8, this.length)
1769 return ieee754.read(this, offset, false, 52, 8)
1772 function checkInt (buf, value, offset, ext, max, min) {
1773 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1774 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1775 if (offset + ext > buf.length) throw new RangeError('Index out of range')
1778 Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1780 offset = offset >>> 0
1781 byteLength = byteLength >>> 0
1783 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1784 checkInt(this, value, offset, byteLength, maxBytes, 0)
1789 this[offset] = value & 0xFF
1790 while (++i < byteLength && (mul *= 0x100)) {
1791 this[offset + i] = (value / mul) & 0xFF
1794 return offset + byteLength
1797 Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1799 offset = offset >>> 0
1800 byteLength = byteLength >>> 0
1802 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1803 checkInt(this, value, offset, byteLength, maxBytes, 0)
1806 var i = byteLength - 1
1808 this[offset + i] = value & 0xFF
1809 while (--i >= 0 && (mul *= 0x100)) {
1810 this[offset + i] = (value / mul) & 0xFF
1813 return offset + byteLength
1816 Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1818 offset = offset >>> 0
1819 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1820 this[offset] = (value & 0xff)
1824 Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1826 offset = offset >>> 0
1827 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1828 this[offset] = (value & 0xff)
1829 this[offset + 1] = (value >>> 8)
1833 Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1835 offset = offset >>> 0
1836 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1837 this[offset] = (value >>> 8)
1838 this[offset + 1] = (value & 0xff)
1842 Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1844 offset = offset >>> 0
1845 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1846 this[offset + 3] = (value >>> 24)
1847 this[offset + 2] = (value >>> 16)
1848 this[offset + 1] = (value >>> 8)
1849 this[offset] = (value & 0xff)
1853 Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1855 offset = offset >>> 0
1856 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1857 this[offset] = (value >>> 24)
1858 this[offset + 1] = (value >>> 16)
1859 this[offset + 2] = (value >>> 8)
1860 this[offset + 3] = (value & 0xff)
1864 Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1866 offset = offset >>> 0
1868 var limit = Math.pow(2, (8 * byteLength) - 1)
1870 checkInt(this, value, offset, byteLength, limit - 1, -limit)
1876 this[offset] = value & 0xFF
1877 while (++i < byteLength && (mul *= 0x100)) {
1878 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1881 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1884 return offset + byteLength
1887 Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1889 offset = offset >>> 0
1891 var limit = Math.pow(2, (8 * byteLength) - 1)
1893 checkInt(this, value, offset, byteLength, limit - 1, -limit)
1896 var i = byteLength - 1
1899 this[offset + i] = value & 0xFF
1900 while (--i >= 0 && (mul *= 0x100)) {
1901 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1904 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1907 return offset + byteLength
1910 Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1912 offset = offset >>> 0
1913 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1914 if (value < 0) value = 0xff + value + 1
1915 this[offset] = (value & 0xff)
1919 Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1921 offset = offset >>> 0
1922 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1923 this[offset] = (value & 0xff)
1924 this[offset + 1] = (value >>> 8)
1928 Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1930 offset = offset >>> 0
1931 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1932 this[offset] = (value >>> 8)
1933 this[offset + 1] = (value & 0xff)
1937 Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1939 offset = offset >>> 0
1940 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1941 this[offset] = (value & 0xff)
1942 this[offset + 1] = (value >>> 8)
1943 this[offset + 2] = (value >>> 16)
1944 this[offset + 3] = (value >>> 24)
1948 Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1950 offset = offset >>> 0
1951 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1952 if (value < 0) value = 0xffffffff + value + 1
1953 this[offset] = (value >>> 24)
1954 this[offset + 1] = (value >>> 16)
1955 this[offset + 2] = (value >>> 8)
1956 this[offset + 3] = (value & 0xff)
1960 function checkIEEE754 (buf, value, offset, ext, max, min) {
1961 if (offset + ext > buf.length) throw new RangeError('Index out of range')
1962 if (offset < 0) throw new RangeError('Index out of range')
1965 function writeFloat (buf, value, offset, littleEndian, noAssert) {
1967 offset = offset >>> 0
1969 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1971 ieee754.write(buf, value, offset, littleEndian, 23, 4)
1975 Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1976 return writeFloat(this, value, offset, true, noAssert)
1979 Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1980 return writeFloat(this, value, offset, false, noAssert)
1983 function writeDouble (buf, value, offset, littleEndian, noAssert) {
1985 offset = offset >>> 0
1987 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1989 ieee754.write(buf, value, offset, littleEndian, 52, 8)
1993 Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1994 return writeDouble(this, value, offset, true, noAssert)
1997 Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1998 return writeDouble(this, value, offset, false, noAssert)
2001 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
2002 Buffer.prototype.copy = function copy (target, targetStart, start, end) {
2003 if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
2004 if (!start) start = 0
2005 if (!end && end !== 0) end = this.length
2006 if (targetStart >= target.length) targetStart = target.length
2007 if (!targetStart) targetStart = 0
2008 if (end > 0 && end < start) end = start
2010 // Copy 0 bytes; we're done
2011 if (end === start) return 0
2012 if (target.length === 0 || this.length === 0) return 0
2014 // Fatal error conditions
2015 if (targetStart < 0) {
2016 throw new RangeError('targetStart out of bounds')
2018 if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
2019 if (end < 0) throw new RangeError('sourceEnd out of bounds')
2022 if (end > this.length) end = this.length
2023 if (target.length - targetStart < end - start) {
2024 end = target.length - targetStart + start
2027 var len = end - start
2029 if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
2030 // Use built-in when available, missing from IE11
2031 this.copyWithin(targetStart, start, end)
2032 } else if (this === target && start < targetStart && targetStart < end) {
2033 // descending copy from end
2034 for (var i = len - 1; i >= 0; --i) {
2035 target[i + targetStart] = this[i + start]
2038 Uint8Array.prototype.set.call(
2040 this.subarray(start, end),
2049 // buffer.fill(number[, offset[, end]])
2050 // buffer.fill(buffer[, offset[, end]])
2051 // buffer.fill(string[, offset[, end]][, encoding])
2052 Buffer.prototype.fill = function fill (val, start, end, encoding) {
2053 // Handle string cases:
2054 if (typeof val === 'string') {
2055 if (typeof start === 'string') {
2059 } else if (typeof end === 'string') {
2063 if (encoding !== undefined && typeof encoding !== 'string') {
2064 throw new TypeError('encoding must be a string')
2066 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
2067 throw new TypeError('Unknown encoding: ' + encoding)
2069 if (val.length === 1) {
2070 var code = val.charCodeAt(0)
2071 if ((encoding === 'utf8' && code < 128) ||
2072 encoding === 'latin1') {
2073 // Fast path: If `val` fits into a single byte, use that numeric value.
2077 } else if (typeof val === 'number') {
2081 // Invalid ranges are not set to a default, so can range check early.
2082 if (start < 0 || this.length < start || this.length < end) {
2083 throw new RangeError('Out of range index')
2091 end = end === undefined ? this.length : end >>> 0
2096 if (typeof val === 'number') {
2097 for (i = start; i < end; ++i) {
2101 var bytes = Buffer.isBuffer(val)
2103 : Buffer.from(val, encoding)
2104 var len = bytes.length
2106 throw new TypeError('The value "' + val +
2107 '" is invalid for argument "value"')
2109 for (i = 0; i < end - start; ++i) {
2110 this[i + start] = bytes[i % len]
2120 var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
2122 function base64clean (str) {
2123 // Node takes equal signs as end of the Base64 encoding
2124 str = str.split('=')[0]
2125 // Node strips out invalid characters like \n and \t from the string, base64-js does not
2126 str = str.trim().replace(INVALID_BASE64_RE, '')
2127 // Node converts strings with length < 2 to ''
2128 if (str.length < 2) return ''
2129 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2130 while (str.length % 4 !== 0) {
2136 function toHex (n) {
2137 if (n < 16) return '0' + n.toString(16)
2138 return n.toString(16)
2141 function utf8ToBytes (string, units) {
2142 units = units || Infinity
2144 var length = string.length
2145 var leadSurrogate = null
2148 for (var i = 0; i < length; ++i) {
2149 codePoint = string.charCodeAt(i)
2151 // is surrogate component
2152 if (codePoint > 0xD7FF && codePoint < 0xE000) {
2153 // last char was a lead
2154 if (!leadSurrogate) {
2156 if (codePoint > 0xDBFF) {
2158 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2160 } else if (i + 1 === length) {
2162 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2167 leadSurrogate = codePoint
2173 if (codePoint < 0xDC00) {
2174 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2175 leadSurrogate = codePoint
2179 // valid surrogate pair
2180 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
2181 } else if (leadSurrogate) {
2182 // valid bmp char, but last char was a lead
2183 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2186 leadSurrogate = null
2189 if (codePoint < 0x80) {
2190 if ((units -= 1) < 0) break
2191 bytes.push(codePoint)
2192 } else if (codePoint < 0x800) {
2193 if ((units -= 2) < 0) break
2195 codePoint >> 0x6 | 0xC0,
2196 codePoint & 0x3F | 0x80
2198 } else if (codePoint < 0x10000) {
2199 if ((units -= 3) < 0) break
2201 codePoint >> 0xC | 0xE0,
2202 codePoint >> 0x6 & 0x3F | 0x80,
2203 codePoint & 0x3F | 0x80
2205 } else if (codePoint < 0x110000) {
2206 if ((units -= 4) < 0) break
2208 codePoint >> 0x12 | 0xF0,
2209 codePoint >> 0xC & 0x3F | 0x80,
2210 codePoint >> 0x6 & 0x3F | 0x80,
2211 codePoint & 0x3F | 0x80
2214 throw new Error('Invalid code point')
2221 function asciiToBytes (str) {
2223 for (var i = 0; i < str.length; ++i) {
2224 // Node's code seems to be doing this and not & 0x7F..
2225 byteArray.push(str.charCodeAt(i) & 0xFF)
2230 function utf16leToBytes (str, units) {
2233 for (var i = 0; i < str.length; ++i) {
2234 if ((units -= 2) < 0) break
2236 c = str.charCodeAt(i)
2246 function base64ToBytes (str) {
2247 return base64.toByteArray(base64clean(str))
2250 function blitBuffer (src, dst, offset, length) {
2251 for (var i = 0; i < length; ++i) {
2252 if ((i + offset >= dst.length) || (i >= src.length)) break
2253 dst[i + offset] = src[i]
2258 // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
2259 // the `instanceof` check but they should be treated as of that type.
2260 // See: https://github.com/feross/buffer/issues/166
2261 function isInstance (obj, type) {
2262 return obj instanceof type ||
2263 (obj != null && obj.constructor != null && obj.constructor.name != null &&
2264 obj.constructor.name === type.name)
2266 function numberIsNaN (obj) {
2268 return obj !== obj // eslint-disable-line no-self-compare
2271 },{"base64-js":3,"ieee754":17}],7:[function(require,module,exports){
2272 // shim for using process in browser
2273 var process = module.exports = {};
2275 // cached from whatever global is present so that test runners that stub it
2276 // don't break things. But we need to wrap it in a try catch in case it is
2277 // wrapped in strict mode code which doesn't define any globals. It's inside a
2278 // function because try/catches deoptimize in certain engines.
2280 var cachedSetTimeout;
2281 var cachedClearTimeout;
2283 function defaultSetTimout() {
2284 throw new Error('setTimeout has not been defined');
2286 function defaultClearTimeout () {
2287 throw new Error('clearTimeout has not been defined');
2291 if (typeof setTimeout === 'function') {
2292 cachedSetTimeout = setTimeout;
2294 cachedSetTimeout = defaultSetTimout;
2297 cachedSetTimeout = defaultSetTimout;
2300 if (typeof clearTimeout === 'function') {
2301 cachedClearTimeout = clearTimeout;
2303 cachedClearTimeout = defaultClearTimeout;
2306 cachedClearTimeout = defaultClearTimeout;
2309 function runTimeout(fun) {
2310 if (cachedSetTimeout === setTimeout) {
2311 //normal enviroments in sane situations
2312 return setTimeout(fun, 0);
2314 // if setTimeout wasn't available but was latter defined
2315 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
2316 cachedSetTimeout = setTimeout;
2317 return setTimeout(fun, 0);
2320 // when when somebody has screwed with setTimeout but no I.E. maddness
2321 return cachedSetTimeout(fun, 0);
2324 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
2325 return cachedSetTimeout.call(null, fun, 0);
2327 // 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
2328 return cachedSetTimeout.call(this, fun, 0);
2334 function runClearTimeout(marker) {
2335 if (cachedClearTimeout === clearTimeout) {
2336 //normal enviroments in sane situations
2337 return clearTimeout(marker);
2339 // if clearTimeout wasn't available but was latter defined
2340 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
2341 cachedClearTimeout = clearTimeout;
2342 return clearTimeout(marker);
2345 // when when somebody has screwed with setTimeout but no I.E. maddness
2346 return cachedClearTimeout(marker);
2349 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
2350 return cachedClearTimeout.call(null, marker);
2352 // 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.
2353 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
2354 return cachedClearTimeout.call(this, marker);
2362 var draining = false;
2364 var queueIndex = -1;
2366 function cleanUpNextTick() {
2367 if (!draining || !currentQueue) {
2371 if (currentQueue.length) {
2372 queue = currentQueue.concat(queue);
2381 function drainQueue() {
2385 var timeout = runTimeout(cleanUpNextTick);
2388 var len = queue.length;
2390 currentQueue = queue;
2392 while (++queueIndex < len) {
2394 currentQueue[queueIndex].run();
2400 currentQueue = null;
2402 runClearTimeout(timeout);
2405 process.nextTick = function (fun) {
2406 var args = new Array(arguments.length - 1);
2407 if (arguments.length > 1) {
2408 for (var i = 1; i < arguments.length; i++) {
2409 args[i - 1] = arguments[i];
2412 queue.push(new Item(fun, args));
2413 if (queue.length === 1 && !draining) {
2414 runTimeout(drainQueue);
2418 // v8 likes predictible objects
2419 function Item(fun, array) {
2423 Item.prototype.run = function () {
2424 this.fun.apply(null, this.array);
2426 process.title = 'browser';
2427 process.browser = true;
2430 process.version = ''; // empty string to avoid regexp issues
2431 process.versions = {};
2436 process.addListener = noop;
2437 process.once = noop;
2439 process.removeListener = noop;
2440 process.removeAllListeners = noop;
2441 process.emit = noop;
2442 process.prependListener = noop;
2443 process.prependOnceListener = noop;
2445 process.listeners = function (name) { return [] }
2447 process.binding = function (name) {
2448 throw new Error('process.binding is not supported');
2451 process.cwd = function () { return '/' };
2452 process.chdir = function (dir) {
2453 throw new Error('process.chdir is not supported');
2455 process.umask = function() { return 0; };
2457 },{}],8:[function(require,module,exports){
2460 module.exports = earcut;
2461 module.exports.default = earcut;
2463 function earcut(data, holeIndices, dim) {
2467 var hasHoles = holeIndices && holeIndices.length,
2468 outerLen = hasHoles ? holeIndices[0] * dim : data.length,
2469 outerNode = linkedList(data, 0, outerLen, dim, true),
2472 if (!outerNode || outerNode.next === outerNode.prev) return triangles;
2474 var minX, minY, maxX, maxY, x, y, invSize;
2476 if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
2478 // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
2479 if (data.length > 80 * dim) {
2480 minX = maxX = data[0];
2481 minY = maxY = data[1];
2483 for (var i = dim; i < outerLen; i += dim) {
2486 if (x < minX) minX = x;
2487 if (y < minY) minY = y;
2488 if (x > maxX) maxX = x;
2489 if (y > maxY) maxY = y;
2492 // minX, minY and invSize are later used to transform coords into integers for z-order calculation
2493 invSize = Math.max(maxX - minX, maxY - minY);
2494 invSize = invSize !== 0 ? 1 / invSize : 0;
2497 earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
2502 // create a circular doubly linked list from polygon points in the specified winding order
2503 function linkedList(data, start, end, dim, clockwise) {
2506 if (clockwise === (signedArea(data, start, end, dim) > 0)) {
2507 for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
2509 for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
2512 if (last && equals(last, last.next)) {
2520 // eliminate colinear or duplicate points
2521 function filterPoints(start, end) {
2522 if (!start) return start;
2523 if (!end) end = start;
2530 if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
2533 if (p === p.next) break;
2539 } while (again || p !== end);
2544 // main ear slicing loop which triangulates a polygon (given as a linked list)
2545 function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
2548 // interlink polygon nodes in z-order
2549 if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
2554 // iterate through ears, slicing them one by one
2555 while (ear.prev !== ear.next) {
2559 if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
2560 // cut off the triangle
2561 triangles.push(prev.i / dim);
2562 triangles.push(ear.i / dim);
2563 triangles.push(next.i / dim);
2567 // skipping the next vertex leads to less sliver triangles
2576 // if we looped through the whole remaining polygon and can't find any more ears
2578 // try filtering points and slicing again
2580 earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
2582 // if this didn't work, try curing all small self-intersections locally
2583 } else if (pass === 1) {
2584 ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
2585 earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
2587 // as a last resort, try splitting the remaining polygon into two
2588 } else if (pass === 2) {
2589 splitEarcut(ear, triangles, dim, minX, minY, invSize);
2597 // check whether a polygon node forms a valid ear with adjacent nodes
2598 function isEar(ear) {
2603 if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
2605 // now make sure we don't have other points inside the potential ear
2606 var p = ear.next.next;
2608 while (p !== ear.prev) {
2609 if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2610 area(p.prev, p, p.next) >= 0) return false;
2617 function isEarHashed(ear, minX, minY, invSize) {
2622 if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
2624 // triangle bbox; min & max are calculated like this for speed
2625 var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x),
2626 minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y),
2627 maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x),
2628 maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y);
2630 // z-order range for the current triangle bbox;
2631 var minZ = zOrder(minTX, minTY, minX, minY, invSize),
2632 maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
2637 // look for points inside the triangle in both directions
2638 while (p && p.z >= minZ && n && n.z <= maxZ) {
2639 if (p !== ear.prev && p !== ear.next &&
2640 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2641 area(p.prev, p, p.next) >= 0) return false;
2644 if (n !== ear.prev && n !== ear.next &&
2645 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
2646 area(n.prev, n, n.next) >= 0) return false;
2650 // look for remaining points in decreasing z-order
2651 while (p && p.z >= minZ) {
2652 if (p !== ear.prev && p !== ear.next &&
2653 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2654 area(p.prev, p, p.next) >= 0) return false;
2658 // look for remaining points in increasing z-order
2659 while (n && n.z <= maxZ) {
2660 if (n !== ear.prev && n !== ear.next &&
2661 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
2662 area(n.prev, n, n.next) >= 0) return false;
2669 // go through all polygon nodes and cure small local self-intersections
2670 function cureLocalIntersections(start, triangles, dim) {
2676 if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
2678 triangles.push(a.i / dim);
2679 triangles.push(p.i / dim);
2680 triangles.push(b.i / dim);
2682 // remove two nodes involved
2689 } while (p !== start);
2691 return filterPoints(p);
2694 // try splitting polygon into two and triangulate them independently
2695 function splitEarcut(start, triangles, dim, minX, minY, invSize) {
2696 // look for a valid diagonal that divides the polygon into two
2699 var b = a.next.next;
2700 while (b !== a.prev) {
2701 if (a.i !== b.i && isValidDiagonal(a, b)) {
2702 // split the polygon in two by the diagonal
2703 var c = splitPolygon(a, b);
2705 // filter colinear points around the cuts
2706 a = filterPoints(a, a.next);
2707 c = filterPoints(c, c.next);
2709 // run earcut on each half
2710 earcutLinked(a, triangles, dim, minX, minY, invSize);
2711 earcutLinked(c, triangles, dim, minX, minY, invSize);
2717 } while (a !== start);
2720 // link every hole into the outer loop, producing a single-ring polygon without holes
2721 function eliminateHoles(data, holeIndices, outerNode, dim) {
2723 i, len, start, end, list;
2725 for (i = 0, len = holeIndices.length; i < len; i++) {
2726 start = holeIndices[i] * dim;
2727 end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
2728 list = linkedList(data, start, end, dim, false);
2729 if (list === list.next) list.steiner = true;
2730 queue.push(getLeftmost(list));
2733 queue.sort(compareX);
2735 // process holes from left to right
2736 for (i = 0; i < queue.length; i++) {
2737 eliminateHole(queue[i], outerNode);
2738 outerNode = filterPoints(outerNode, outerNode.next);
2744 function compareX(a, b) {
2748 // find a bridge between vertices that connects hole with an outer ring and and link it
2749 function eliminateHole(hole, outerNode) {
2750 outerNode = findHoleBridge(hole, outerNode);
2752 var b = splitPolygon(outerNode, hole);
2754 // filter collinear points around the cuts
2755 filterPoints(outerNode, outerNode.next);
2756 filterPoints(b, b.next);
2760 // David Eberly's algorithm for finding a bridge between hole and outer polygon
2761 function findHoleBridge(hole, outerNode) {
2768 // find a segment intersected by a ray from the hole's leftmost point to the left;
2769 // segment's endpoint with lesser x will be potential connection point
2771 if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
2772 var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
2773 if (x <= hx && x > qx) {
2776 if (hy === p.y) return p;
2777 if (hy === p.next.y) return p.next;
2779 m = p.x < p.next.x ? p : p.next;
2783 } while (p !== outerNode);
2785 if (!m) return null;
2787 if (hx === qx) return m; // hole touches outer segment; pick leftmost endpoint
2789 // look for points inside the triangle of hole point, segment intersection and endpoint;
2790 // if there are no points found, we have a valid connection;
2791 // otherwise choose the point of the minimum angle with the ray as connection point
2802 if (hx >= p.x && p.x >= mx && hx !== p.x &&
2803 pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
2805 tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
2807 if (locallyInside(p, hole) &&
2808 (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {
2815 } while (p !== stop);
2820 // whether sector in vertex m contains sector in vertex p in the same coordinates
2821 function sectorContainsSector(m, p) {
2822 return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
2825 // interlink polygon nodes in z-order
2826 function indexCurve(start, minX, minY, invSize) {
2829 if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize);
2833 } while (p !== start);
2835 p.prevZ.nextZ = null;
2841 // Simon Tatham's linked list merge sort algorithm
2842 // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
2843 function sortLinked(list) {
2844 var i, p, q, e, tail, numMerges, pSize, qSize,
2857 for (i = 0; i < inSize; i++) {
2864 while (pSize > 0 || (qSize > 0 && q)) {
2866 if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
2876 if (tail) tail.nextZ = e;
2889 } while (numMerges > 1);
2894 // z-order of a point given coords and inverse of the longer side of data bbox
2895 function zOrder(x, y, minX, minY, invSize) {
2896 // coords are transformed into non-negative 15-bit integer range
2897 x = 32767 * (x - minX) * invSize;
2898 y = 32767 * (y - minY) * invSize;
2900 x = (x | (x << 8)) & 0x00FF00FF;
2901 x = (x | (x << 4)) & 0x0F0F0F0F;
2902 x = (x | (x << 2)) & 0x33333333;
2903 x = (x | (x << 1)) & 0x55555555;
2905 y = (y | (y << 8)) & 0x00FF00FF;
2906 y = (y | (y << 4)) & 0x0F0F0F0F;
2907 y = (y | (y << 2)) & 0x33333333;
2908 y = (y | (y << 1)) & 0x55555555;
2910 return x | (y << 1);
2913 // find the leftmost node of a polygon ring
2914 function getLeftmost(start) {
2918 if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;
2920 } while (p !== start);
2925 // check if a point lies within a convex triangle
2926 function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
2927 return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
2928 (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
2929 (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
2932 // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
2933 function isValidDiagonal(a, b) {
2934 return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
2935 (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
2936 (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
2937 equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
2940 // signed area of a triangle
2941 function area(p, q, r) {
2942 return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
2945 // check if two points are equal
2946 function equals(p1, p2) {
2947 return p1.x === p2.x && p1.y === p2.y;
2950 // check if two segments intersect
2951 function intersects(p1, q1, p2, q2) {
2952 var o1 = sign(area(p1, q1, p2));
2953 var o2 = sign(area(p1, q1, q2));
2954 var o3 = sign(area(p2, q2, p1));
2955 var o4 = sign(area(p2, q2, q1));
2957 if (o1 !== o2 && o3 !== o4) return true; // general case
2959 if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
2960 if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
2961 if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
2962 if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
2967 // for collinear points p, q, r, check if point q lies on segment pr
2968 function onSegment(p, q, r) {
2969 return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
2972 function sign(num) {
2973 return num > 0 ? 1 : num < 0 ? -1 : 0;
2976 // check if a polygon diagonal intersects any polygon segments
2977 function intersectsPolygon(a, b) {
2980 if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
2981 intersects(p, p.next, a, b)) return true;
2988 // check if a polygon diagonal is locally inside the polygon
2989 function locallyInside(a, b) {
2990 return area(a.prev, a, a.next) < 0 ?
2991 area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
2992 area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
2995 // check if the middle point of a polygon diagonal is inside the polygon
2996 function middleInside(a, b) {
2999 px = (a.x + b.x) / 2,
3000 py = (a.y + b.y) / 2;
3002 if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
3003 (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
3011 // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
3012 // if one belongs to the outer ring and another to a hole, it merges it into a single ring
3013 function splitPolygon(a, b) {
3014 var a2 = new Node(a.i, a.x, a.y),
3015 b2 = new Node(b.i, b.x, b.y),
3034 // create a node and optionally link it with previous one (in a circular doubly linked list)
3035 function insertNode(i, x, y, last) {
3036 var p = new Node(i, x, y);
3051 function removeNode(p) {
3052 p.next.prev = p.prev;
3053 p.prev.next = p.next;
3055 if (p.prevZ) p.prevZ.nextZ = p.nextZ;
3056 if (p.nextZ) p.nextZ.prevZ = p.prevZ;
3059 function Node(i, x, y) {
3060 // vertex index in coordinates array
3063 // vertex coordinates
3067 // previous and next vertex nodes in a polygon ring
3071 // z-order curve value
3074 // previous and next nodes in z-order
3078 // indicates whether this is a steiner point
3079 this.steiner = false;
3082 // return a percentage difference between the polygon area and its triangulation area;
3083 // used to verify correctness of triangulation
3084 earcut.deviation = function (data, holeIndices, dim, triangles) {
3085 var hasHoles = holeIndices && holeIndices.length;
3086 var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
3088 var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
3090 for (var i = 0, len = holeIndices.length; i < len; i++) {
3091 var start = holeIndices[i] * dim;
3092 var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
3093 polygonArea -= Math.abs(signedArea(data, start, end, dim));
3097 var trianglesArea = 0;
3098 for (i = 0; i < triangles.length; i += 3) {
3099 var a = triangles[i] * dim;
3100 var b = triangles[i + 1] * dim;
3101 var c = triangles[i + 2] * dim;
3102 trianglesArea += Math.abs(
3103 (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
3104 (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
3107 return polygonArea === 0 && trianglesArea === 0 ? 0 :
3108 Math.abs((trianglesArea - polygonArea) / polygonArea);
3111 function signedArea(data, start, end, dim) {
3113 for (var i = start, j = end - dim; i < end; i += dim) {
3114 sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
3120 // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
3121 earcut.flatten = function (data) {
3122 var dim = data[0][0].length,
3123 result = {vertices: [], holes: [], dimensions: dim},
3126 for (var i = 0; i < data.length; i++) {
3127 for (var j = 0; j < data[i].length; j++) {
3128 for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
3131 holeIndex += data[i - 1].length;
3132 result.holes.push(holeIndex);
3138 },{}],9:[function(require,module,exports){
3141 var OneVersionConstraint = require('individual/one-version');
3143 var MY_VERSION = '7';
3144 OneVersionConstraint('ev-store', MY_VERSION);
3146 var hashKey = '__EV_STORE_KEY@' + MY_VERSION;
3148 module.exports = EvStore;
3150 function EvStore(elem) {
3151 var hash = elem[hashKey];
3154 hash = elem[hashKey] = {};
3160 },{"individual/one-version":19}],10:[function(require,module,exports){
3162 var request = require('./request');
3163 var buildQueryObject = require('./buildQueryObject');
3164 var isArray = Array.isArray;
3166 function simpleExtend(obj, obj2) {
3168 for (prop in obj2) {
3169 obj[prop] = obj2[prop];
3174 function XMLHttpSource(jsongUrl, config) {
3175 this._jsongUrl = jsongUrl;
3176 if (typeof config === 'number') {
3182 this._config = simpleExtend({
3188 XMLHttpSource.prototype = {
3189 // because javascript
3190 constructor: XMLHttpSource,
3192 * buildQueryObject helper
3194 buildQueryObject: buildQueryObject,
3197 * @inheritDoc DataSource#get
3199 get: function httpSourceGet(pathSet) {
3201 var queryObject = this.buildQueryObject(this._jsongUrl, method, {
3205 var config = simpleExtend(queryObject, this._config);
3206 // pass context for onBeforeRequest callback
3208 return request(method, config, context);
3212 * @inheritDoc DataSource#set
3214 set: function httpSourceSet(jsongEnv) {
3215 var method = 'POST';
3216 var queryObject = this.buildQueryObject(this._jsongUrl, method, {
3217 jsonGraph: jsongEnv,
3220 var config = simpleExtend(queryObject, this._config);
3221 config.headers["Content-Type"] = "application/x-www-form-urlencoded";
3223 // pass context for onBeforeRequest callback
3225 return request(method, config, context);
3230 * @inheritDoc DataSource#call
3232 call: function httpSourceCall(callPath, args, pathSuffix, paths) {
3233 // arguments defaults
3235 pathSuffix = pathSuffix || [];
3236 paths = paths || [];
3238 var method = 'POST';
3240 queryData.push('method=call');
3241 queryData.push('callPath=' + encodeURIComponent(JSON.stringify(callPath)));
3242 queryData.push('arguments=' + encodeURIComponent(JSON.stringify(args)));
3243 queryData.push('pathSuffixes=' + encodeURIComponent(JSON.stringify(pathSuffix)));
3244 queryData.push('paths=' + encodeURIComponent(JSON.stringify(paths)));
3246 var queryObject = this.buildQueryObject(this._jsongUrl, method, queryData.join('&'));
3247 var config = simpleExtend(queryObject, this._config);
3248 config.headers["Content-Type"] = "application/x-www-form-urlencoded";
3250 // pass context for onBeforeRequest callback
3252 return request(method, config, context);
3256 XMLHttpSource.XMLHttpSource = XMLHttpSource;
3257 XMLHttpSource['default'] = XMLHttpSource;
3259 module.exports = XMLHttpSource;
3261 },{"./buildQueryObject":11,"./request":14}],11:[function(require,module,exports){
3263 module.exports = function buildQueryObject(url, method, queryData) {
3266 var data = {url: url};
3267 var isQueryParamUrl = url.indexOf('?') !== -1;
3268 var startUrl = (isQueryParamUrl) ? '&' : '?';
3270 if (typeof queryData === 'string') {
3271 qData.push(queryData);
3274 keys = Object.keys(queryData);
3275 keys.forEach(function (k) {
3276 var value = (typeof queryData[k] === 'object') ? JSON.stringify(queryData[k]) : queryData[k];
3277 qData.push(k + '=' + encodeURIComponent(value));
3281 if (method === 'GET') {
3282 data.url += startUrl + qData.join('&');
3284 data.data = qData.join('&');
3290 },{}],12:[function(require,module,exports){
3293 // Get CORS support even for older IE
3294 module.exports = function getCORSRequest() {
3295 var xhr = new global.XMLHttpRequest();
3296 if ('withCredentials' in xhr) {
3298 } else if (!!global.XDomainRequest) {
3299 return new XDomainRequest();
3301 throw new Error('CORS is not supported by your browser');
3305 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3307 },{}],13:[function(require,module,exports){
3310 module.exports = function getXMLHttpRequest() {
3314 if (global.XMLHttpRequest) {
3315 return new global.XMLHttpRequest();
3318 progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
3319 for (i = 0; i < 3; i++) {
3321 progId = progIds[i];
3322 if (new global.ActiveXObject(progId)) {
3327 return new global.ActiveXObject(progId);
3329 throw new Error('XMLHttpRequest is not supported by your browser');
3334 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3336 },{}],14:[function(require,module,exports){
3338 var getXMLHttpRequest = require('./getXMLHttpRequest');
3339 var getCORSRequest = require('./getCORSRequest');
3340 var hasOwnProp = Object.prototype.hasOwnProperty;
3342 var noop = function() {};
3344 function Observable() {}
3346 Observable.create = function(subscribe) {
3347 var o = new Observable();
3349 o.subscribe = function(onNext, onError, onCompleted) {
3354 if (typeof onNext === 'function') {
3357 onError: (onError || noop),
3358 onCompleted: (onCompleted || noop)
3364 disposable = subscribe(observer);
3366 if (typeof disposable === 'function') {
3378 function request(method, options, context) {
3379 return Observable.create(function requestObserver(observer) {
3382 method: method || 'GET',
3386 responseType: 'json'
3395 for (prop in options) {
3396 if (hasOwnProp.call(options, prop)) {
3397 config[prop] = options[prop];
3401 // Add request with Headers
3402 if (!config.crossDomain && !config.headers['X-Requested-With']) {
3403 config.headers['X-Requested-With'] = 'XMLHttpRequest';
3406 // allow the user to mutate the config open
3407 if (context.onBeforeRequest != null) {
3408 context.onBeforeRequest(config);
3413 xhr = config.crossDomain ? getCORSRequest() : getXMLHttpRequest();
3415 observer.onError(err);
3418 // Takes the url and opens the connection
3420 xhr.open(config.method, config.url, config.async, config.user, config.password);
3422 xhr.open(config.method, config.url, config.async);
3425 // Sets timeout information
3426 xhr.timeout = config.timeout;
3428 // Anything but explicit false results in true.
3429 xhr.withCredentials = config.withCredentials !== false;
3431 // Fills the request headers
3432 headers = config.headers;
3433 for (header in headers) {
3434 if (hasOwnProp.call(headers, header)) {
3435 xhr.setRequestHeader(header, headers[header]);
3439 if (config.responseType) {
3441 xhr.responseType = config.responseType;
3443 // WebKit added support for the json responseType value on 09/03/2013
3444 // https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are
3445 // known to throw when setting the value "json" as the response type. Other older
3446 // browsers implementing the responseType
3448 // The json response type can be ignored if not supported, because JSON payloads are
3449 // parsed on the client-side regardless.
3450 if (config.responseType !== 'json') {
3456 xhr.onreadystatechange = function onreadystatechange(e) {
3458 if (xhr.readyState === 4) {
3461 onXhrLoad(observer, xhr, e);
3467 xhr.ontimeout = function ontimeout(e) {
3470 onXhrError(observer, xhr, 'timeout error', e);
3475 xhr.send(config.data);
3478 observer.onError(e);
3481 return function dispose() {
3482 // Doesn't work in IE9
3483 if (!isDone && xhr.readyState !== 4) {
3492 * General handling of ultimate failure (after appropriate retries)
3494 function _handleXhrError(observer, textStatus, errorThrown) {
3495 // IE9: cross-domain request may be considered errors
3497 errorThrown = new Error(textStatus);
3500 observer.onError(errorThrown);
3503 function onXhrLoad(observer, xhr, e) {
3508 // If there's no observer, the request has been (or is being) cancelled.
3509 if (xhr && observer) {
3510 responseType = xhr.responseType;
3511 // responseText is the old-school way of retrieving response (supported by IE8 & 9)
3512 // response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
3513 responseData = ('response' in xhr) ? xhr.response : xhr.responseText;
3515 // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
3516 var status = (xhr.status === 1223) ? 204 : xhr.status;
3518 if (status >= 200 && status <= 399) {
3520 if (responseType !== 'json') {
3521 responseData = JSON.parse(responseData || '');
3523 if (typeof responseData === 'string') {
3524 responseData = JSON.parse(responseData || '');
3527 _handleXhrError(observer, 'invalid json', e);
3529 observer.onNext(responseData);
3530 observer.onCompleted();
3533 } else if (status === 401 || status === 403 || status === 407) {
3535 return _handleXhrError(observer, responseData);
3537 } else if (status === 410) {
3539 return _handleXhrError(observer, responseData);
3541 } else if (status === 408 || status === 504) {
3543 return _handleXhrError(observer, responseData);
3547 return _handleXhrError(observer, responseData || ('Response code ' + status));
3553 function onXhrError(observer, xhr, status, e) {
3554 _handleXhrError(observer, status || xhr.statusText || 'request error', e);
3557 module.exports = request;
3559 },{"./getCORSRequest":12,"./getXMLHttpRequest":13}],15:[function(require,module,exports){
3561 !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(){
3562 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);
3563 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(){
3564 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(){
3565 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)});
3566 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3568 },{}],16:[function(require,module,exports){
3570 var topLevel = typeof global !== 'undefined' ? global :
3571 typeof window !== 'undefined' ? window : {}
3572 var minDoc = require('min-document');
3576 if (typeof document !== 'undefined') {
3579 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
3582 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
3586 module.exports = doccy;
3588 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3590 },{"min-document":4}],17:[function(require,module,exports){
3591 exports.read = function (buffer, offset, isLE, mLen, nBytes) {
3593 var eLen = nBytes * 8 - mLen - 1
3594 var eMax = (1 << eLen) - 1
3595 var eBias = eMax >> 1
3597 var i = isLE ? (nBytes - 1) : 0
3598 var d = isLE ? -1 : 1
3599 var s = buffer[offset + i]
3603 e = s & ((1 << (-nBits)) - 1)
3606 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
3608 m = e & ((1 << (-nBits)) - 1)
3611 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
3615 } else if (e === eMax) {
3616 return m ? NaN : ((s ? -1 : 1) * Infinity)
3618 m = m + Math.pow(2, mLen)
3621 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
3624 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
3626 var eLen = nBytes * 8 - mLen - 1
3627 var eMax = (1 << eLen) - 1
3628 var eBias = eMax >> 1
3629 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
3630 var i = isLE ? 0 : (nBytes - 1)
3631 var d = isLE ? 1 : -1
3632 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
3634 value = Math.abs(value)
3636 if (isNaN(value) || value === Infinity) {
3637 m = isNaN(value) ? 1 : 0
3640 e = Math.floor(Math.log(value) / Math.LN2)
3641 if (value * (c = Math.pow(2, -e)) < 1) {
3645 if (e + eBias >= 1) {
3648 value += rt * Math.pow(2, 1 - eBias)
3650 if (value * c >= 2) {
3655 if (e + eBias >= eMax) {
3658 } else if (e + eBias >= 1) {
3659 m = (value * c - 1) * Math.pow(2, mLen)
3662 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
3667 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
3671 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
3673 buffer[offset + i - d] |= s * 128
3676 },{}],18:[function(require,module,exports){
3680 /*global window, global*/
3682 var root = typeof window !== 'undefined' ?
3683 window : typeof global !== 'undefined' ?
3686 module.exports = Individual;
3688 function Individual(key, value) {
3698 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3700 },{}],19:[function(require,module,exports){
3703 var Individual = require('./index.js');
3705 module.exports = OneVersion;
3707 function OneVersion(moduleName, version, defaultValue) {
3708 var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName;
3709 var enforceKey = key + '_ENFORCE_SINGLETON';
3711 var versionValue = Individual(enforceKey, version);
3713 if (versionValue !== version) {
3714 throw new Error('Can only have one copy of ' +
3715 moduleName + '.\n' +
3716 'You already have version ' + versionValue +
3718 'This means you cannot install version ' + version);
3721 return Individual(key, defaultValue);
3724 },{"./index.js":18}],20:[function(require,module,exports){
3727 module.exports = function isObject(x) {
3728 return typeof x === "object" && x !== null;
3731 },{}],21:[function(require,module,exports){
3732 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3733 /* Geohash encoding/decoding and associated functions (c) Chris Veness 2014-2016 / MIT Licence */
3734 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3740 * Geohash encode, decode, bounds, neighbours.
3746 /* (Geohash-specific) Base32 map */
3747 Geohash.base32 = '0123456789bcdefghjkmnpqrstuvwxyz';
3750 * Encodes latitude/longitude to geohash, either to specified precision or to automatically
3751 * evaluated precision.
3753 * @param {number} lat - Latitude in degrees.
3754 * @param {number} lon - Longitude in degrees.
3755 * @param {number} [precision] - Number of characters in resulting geohash.
3756 * @returns {string} Geohash of supplied latitude/longitude.
3757 * @throws Invalid geohash.
3760 * var geohash = Geohash.encode(52.205, 0.119, 7); // geohash: 'u120fxw'
3762 Geohash.encode = function(lat, lon, precision) {
3764 if (typeof precision == 'undefined') {
3765 // refine geohash until it matches precision of supplied lat/lon
3766 for (var p=1; p<=12; p++) {
3767 var hash = Geohash.encode(lat, lon, p);
3768 var posn = Geohash.decode(hash);
3769 if (posn.lat==lat && posn.lon==lon) return hash;
3771 precision = 12; // set to maximum
3776 precision = Number(precision);
3778 if (isNaN(lat) || isNaN(lon) || isNaN(precision)) throw new Error('Invalid geohash');
3780 var idx = 0; // index into base32 map
3781 var bit = 0; // each char holds 5 bits
3785 var latMin = -90, latMax = 90;
3786 var lonMin = -180, lonMax = 180;
3788 while (geohash.length < precision) {
3790 // bisect E-W longitude
3791 var lonMid = (lonMin + lonMax) / 2;
3792 if (lon >= lonMid) {
3800 // bisect N-S latitude
3801 var latMid = (latMin + latMax) / 2;
3802 if (lat >= latMid) {
3813 // 5 bits gives us a character: append it and start over
3814 geohash += Geohash.base32.charAt(idx);
3825 * Decode geohash to latitude/longitude (location is approximate centre of geohash cell,
3826 * to reasonable precision).
3828 * @param {string} geohash - Geohash string to be converted to latitude/longitude.
3829 * @returns {{lat:number, lon:number}} (Center of) geohashed location.
3830 * @throws Invalid geohash.
3833 * var latlon = Geohash.decode('u120fxw'); // latlon: { lat: 52.205, lon: 0.1188 }
3835 Geohash.decode = function(geohash) {
3837 var bounds = Geohash.bounds(geohash); // <-- the hard work
3838 // now just determine the centre of the cell...
3840 var latMin = bounds.sw.lat, lonMin = bounds.sw.lon;
3841 var latMax = bounds.ne.lat, lonMax = bounds.ne.lon;
3844 var lat = (latMin + latMax)/2;
3845 var lon = (lonMin + lonMax)/2;
3847 // round to close to centre without excessive precision: ⌊2-log10(Δ°)⌋ decimal places
3848 lat = lat.toFixed(Math.floor(2-Math.log(latMax-latMin)/Math.LN10));
3849 lon = lon.toFixed(Math.floor(2-Math.log(lonMax-lonMin)/Math.LN10));
3851 return { lat: Number(lat), lon: Number(lon) };
3856 * Returns SW/NE latitude/longitude bounds of specified geohash.
3858 * @param {string} geohash - Cell that bounds are required of.
3859 * @returns {{sw: {lat: number, lon: number}, ne: {lat: number, lon: number}}}
3860 * @throws Invalid geohash.
3862 Geohash.bounds = function(geohash) {
3863 if (geohash.length === 0) throw new Error('Invalid geohash');
3865 geohash = geohash.toLowerCase();
3868 var latMin = -90, latMax = 90;
3869 var lonMin = -180, lonMax = 180;
3871 for (var i=0; i<geohash.length; i++) {
3872 var chr = geohash.charAt(i);
3873 var idx = Geohash.base32.indexOf(chr);
3874 if (idx == -1) throw new Error('Invalid geohash');
3876 for (var n=4; n>=0; n--) {
3877 var bitN = idx >> n & 1;
3880 var lonMid = (lonMin+lonMax) / 2;
3888 var latMid = (latMin+latMax) / 2;
3900 sw: { lat: latMin, lon: lonMin },
3901 ne: { lat: latMax, lon: lonMax },
3909 * Determines adjacent cell in given direction.
3911 * @param geohash - Cell to which adjacent cell is required.
3912 * @param direction - Direction from geohash (N/S/E/W).
3913 * @returns {string} Geocode of adjacent cell.
3914 * @throws Invalid geohash.
3916 Geohash.adjacent = function(geohash, direction) {
3917 // based on github.com/davetroy/geohash-js
3919 geohash = geohash.toLowerCase();
3920 direction = direction.toLowerCase();
3922 if (geohash.length === 0) throw new Error('Invalid geohash');
3923 if ('nsew'.indexOf(direction) == -1) throw new Error('Invalid direction');
3926 n: [ 'p0r21436x8zb9dcf5h7kjnmqesgutwvy', 'bc01fg45238967deuvhjyznpkmstqrwx' ],
3927 s: [ '14365h7k9dcfesgujnmqp0r2twvyx8zb', '238967debc01fg45kmstqrwxuvhjyznp' ],
3928 e: [ 'bc01fg45238967deuvhjyznpkmstqrwx', 'p0r21436x8zb9dcf5h7kjnmqesgutwvy' ],
3929 w: [ '238967debc01fg45kmstqrwxuvhjyznp', '14365h7k9dcfesgujnmqp0r2twvyx8zb' ],
3932 n: [ 'prxz', 'bcfguvyz' ],
3933 s: [ '028b', '0145hjnp' ],
3934 e: [ 'bcfguvyz', 'prxz' ],
3935 w: [ '0145hjnp', '028b' ],
3938 var lastCh = geohash.slice(-1); // last character of hash
3939 var parent = geohash.slice(0, -1); // hash without last character
3941 var type = geohash.length % 2;
3943 // check for edge-cases which don't share common prefix
3944 if (border[direction][type].indexOf(lastCh) != -1 && parent !== '') {
3945 parent = Geohash.adjacent(parent, direction);
3948 // append letter for direction to parent
3949 return parent + Geohash.base32.charAt(neighbour[direction][type].indexOf(lastCh));
3954 * Returns all 8 adjacent cells to specified geohash.
3956 * @param {string} geohash - Geohash neighbours are required of.
3957 * @returns {{n,ne,e,se,s,sw,w,nw: string}}
3958 * @throws Invalid geohash.
3960 Geohash.neighbours = function(geohash) {
3962 'n': Geohash.adjacent(geohash, 'n'),
3963 'ne': Geohash.adjacent(Geohash.adjacent(geohash, 'n'), 'e'),
3964 'e': Geohash.adjacent(geohash, 'e'),
3965 'se': Geohash.adjacent(Geohash.adjacent(geohash, 's'), 'e'),
3966 's': Geohash.adjacent(geohash, 's'),
3967 'sw': Geohash.adjacent(Geohash.adjacent(geohash, 's'), 'w'),
3968 'w': Geohash.adjacent(geohash, 'w'),
3969 'nw': Geohash.adjacent(Geohash.adjacent(geohash, 'n'), 'w'),
3974 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3975 if (typeof module != 'undefined' && module.exports) module.exports = Geohash; // CommonJS, node.js
3977 },{}],22:[function(require,module,exports){
3980 * Martinez polygon clipping algorithm, does boolean operation on polygons (multipolygons, polygons with holes etc): intersection, union, difference, xor
3982 * @author Alex Milevski <info@w8r.name>
3987 (function (global, factory) {
3988 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3989 typeof define === 'function' && define.amd ? define(['exports'], factory) :
3990 (global = global || self, factory(global.martinez = {}));
3991 }(this, (function (exports) { 'use strict';
3993 function DEFAULT_COMPARE (a, b) { return a > b ? 1 : a < b ? -1 : 0; }
3995 var SplayTree = function SplayTree(compare, noDuplicates) {
3996 if ( compare === void 0 ) compare = DEFAULT_COMPARE;
3997 if ( noDuplicates === void 0 ) noDuplicates = false;
3999 this._compare = compare;
4002 this._noDuplicates = !!noDuplicates;
4005 var prototypeAccessors = { size: { configurable: true } };
4008 SplayTree.prototype.rotateLeft = function rotateLeft (x) {
4012 if (y.left) { y.left.parent = x; }
4013 y.parent = x.parent;
4016 if (!x.parent) { this._root = y; }
4017 else if (x === x.parent.left) { x.parent.left = y; }
4018 else { x.parent.right = y; }
4019 if (y) { y.left = x; }
4024 SplayTree.prototype.rotateRight = function rotateRight (x) {
4028 if (y.right) { y.right.parent = x; }
4029 y.parent = x.parent;
4032 if (!x.parent) { this._root = y; }
4033 else if(x === x.parent.left) { x.parent.left = y; }
4034 else { x.parent.right = y; }
4035 if (y) { y.right = x; }
4040 SplayTree.prototype._splay = function _splay (x) {
4044 if (p.left === x) { this.rotateRight(p); }
4045 else { this.rotateLeft(p); }
4046 } else if (p.left === x && p.parent.left === p) {
4047 this.rotateRight(p.parent);
4048 this.rotateRight(p);
4049 } else if (p.right === x && p.parent.right === p) {
4050 this.rotateLeft(p.parent);
4052 } else if (p.left === x && p.parent.right === p) {
4053 this.rotateRight(p);
4057 this.rotateRight(p);
4063 SplayTree.prototype.splay = function splay (x) {
4064 var p, gp, ggp, l, r;
4070 if (gp && gp.parent) {
4072 if (ggp.left === gp) { ggp.left= x; }
4073 else { ggp.right = x; }
4080 l = x.left; r = x.right;
4082 if (x === p.left) { // left
4084 if (gp.left === p) {
4088 gp.left.parent = gp;
4089 } else { gp.left = null; }
4098 } else { gp.right = null; }
4107 } else { p.left = null; }
4113 if (gp.right === p) {
4117 gp.right.parent = gp;
4118 } else { gp.right = null; }
4127 } else { gp.left = null; }
4136 } else { p.right = null; }
4145 SplayTree.prototype.replace = function replace (u, v) {
4146 if (!u.parent) { this._root = v; }
4147 else if (u === u.parent.left) { u.parent.left = v; }
4148 else { u.parent.right = v; }
4149 if (v) { v.parent = u.parent; }
4153 SplayTree.prototype.minNode = function minNode (u) {
4154 if ( u === void 0 ) u = this._root;
4156 if (u) { while (u.left) { u = u.left; } }
4161 SplayTree.prototype.maxNode = function maxNode (u) {
4162 if ( u === void 0 ) u = this._root;
4164 if (u) { while (u.right) { u = u.right; } }
4169 SplayTree.prototype.insert = function insert (key, data) {
4172 var comp = this._compare;
4175 if (this._noDuplicates) {
4178 cmp = comp(z.key, key);
4179 if (cmp === 0) { return; }
4180 else if (comp(z.key, key) < 0) { z = z.right; }
4181 else { z = z.left; }
4186 if (comp(z.key, key) < 0) { z = z.right; }
4187 else { z = z.left; }
4191 z = { key: key, data: data, left: null, right: null, parent: p };
4193 if (!p) { this._root = z; }
4194 else if (comp(p.key, z.key) < 0) { p.right = z; }
4203 SplayTree.prototype.find = function find (key) {
4205 var comp = this._compare;
4207 var cmp = comp(z.key, key);
4208 if (cmp < 0) { z = z.right; }
4209 else if (cmp > 0) { z = z.left; }
4216 * Whether the tree contains a node with the given key
4218 * @return {boolean} true/false
4220 SplayTree.prototype.contains = function contains (key) {
4221 var node = this._root;
4222 var comparator = this._compare;
4224 var cmp = comparator(key, node.key);
4225 if (cmp === 0) { return true; }
4226 else if (cmp < 0) { node = node.left; }
4227 else { node = node.right; }
4234 SplayTree.prototype.remove = function remove (key) {
4235 var z = this.find(key);
4237 if (!z) { return false; }
4241 if (!z.left) { this.replace(z, z.right); }
4242 else if (!z.right) { this.replace(z, z.left); }
4244 var y = this.minNode(z.right);
4245 if (y.parent !== z) {
4246 this.replace(y, y.right);
4260 SplayTree.prototype.removeNode = function removeNode (z) {
4261 if (!z) { return false; }
4265 if (!z.left) { this.replace(z, z.right); }
4266 else if (!z.right) { this.replace(z, z.left); }
4268 var y = this.minNode(z.right);
4269 if (y.parent !== z) {
4270 this.replace(y, y.right);
4284 SplayTree.prototype.erase = function erase (key) {
4285 var z = this.find(key);
4296 sMax = this.maxNode(s);
4301 if (s) { sMax.right = t; }
4302 else { this._root = t; }
4310 * Removes and returns the node with smallest key
4313 SplayTree.prototype.pop = function pop () {
4314 var node = this._root, returnValue = null;
4316 while (node.left) { node = node.left; }
4317 returnValue = { key: node.key, data: node.data };
4318 this.remove(node.key);
4324 /* eslint-disable class-methods-use-this */
4331 SplayTree.prototype.next = function next (node) {
4332 var successor = node;
4334 if (successor.right) {
4335 successor = successor.right;
4336 while (successor && successor.left) { successor = successor.left; }
4338 successor = node.parent;
4339 while (successor && successor.right === node) {
4340 node = successor; successor = successor.parent;
4353 SplayTree.prototype.prev = function prev (node) {
4354 var predecessor = node;
4356 if (predecessor.left) {
4357 predecessor = predecessor.left;
4358 while (predecessor && predecessor.right) { predecessor = predecessor.right; }
4360 predecessor = node.parent;
4361 while (predecessor && predecessor.left === node) {
4363 predecessor = predecessor.parent;
4369 /* eslint-enable class-methods-use-this */
4373 * @param{forEachCallback} callback
4374 * @return {SplayTree}
4376 SplayTree.prototype.forEach = function forEach (callback) {
4377 var current = this._root;
4378 var s = [], done = false, i = 0;
4381 // Reach the left most Node of the current Node
4383 // Place pointer to a tree node on the stack
4384 // before traversing the node's left subtree
4386 current = current.left;
4388 // BackTrack from the empty subtree and visit the Node
4389 // at the top of the stack; however, if the stack is
4390 // empty you are done
4393 callback(current, i++);
4395 // We have visited the node and its left
4396 // subtree. Now, it's right subtree's turn
4397 current = current.right;
4398 } else { done = true; }
4406 * Walk key range from `low` to `high`. Stops if `fn` returns a value.
4409 * @param{Function} fn
4411 * @return {SplayTree}
4413 SplayTree.prototype.range = function range (low, high, fn, ctx) {
4415 var compare = this._compare;
4416 var node = this._root, cmp;
4418 while (Q.length !== 0 || node) {
4424 cmp = compare(node.key, high);
4427 } else if (compare(node.key, low) >= 0) {
4428 if (fn.call(ctx, node)) { return this; } // stop if smth is returned
4437 * Returns all keys in order
4438 * @return {Array<Key>}
4440 SplayTree.prototype.keys = function keys () {
4441 var current = this._root;
4442 var s = [], r = [], done = false;
4447 current = current.left;
4451 r.push(current.key);
4452 current = current.right;
4453 } else { done = true; }
4461 * Returns `data` fields of all nodes in order.
4462 * @return {Array<Value>}
4464 SplayTree.prototype.values = function values () {
4465 var current = this._root;
4466 var s = [], r = [], done = false;
4471 current = current.left;
4475 r.push(current.data);
4476 current = current.right;
4477 } else { done = true; }
4485 * Returns node at given index
4486 * @param{number} index
4489 SplayTree.prototype.at = function at (index) {
4490 // removed after a consideration, more misleading than useful
4491 // index = index % this.size;
4492 // if (index < 0) index = this.size - index;
4494 var current = this._root;
4495 var s = [], done = false, i = 0;
4500 current = current.left;
4504 if (i === index) { return current; }
4506 current = current.right;
4507 } else { done = true; }
4514 * Bulk-load items. Both array have to be same size
4515 * @param{Array<Key>} keys
4516 * @param{Array<Value>}[values]
4517 * @param{Boolean} [presort=false] Pre-sort keys and values, using
4518 * tree's comparator. Sorting is done
4522 SplayTree.prototype.load = function load (keys, values, presort) {
4523 if ( keys === void 0 ) keys = [];
4524 if ( values === void 0 ) values = [];
4525 if ( presort === void 0 ) presort = false;
4527 if (this._size !== 0) { throw new Error('bulk-load: tree is not empty'); }
4528 var size = keys.length;
4529 if (presort) { sort(keys, values, 0, size - 1, this._compare); }
4530 this._root = loadRecursive(null, keys, values, 0, size);
4536 SplayTree.prototype.min = function min () {
4537 var node = this.minNode(this._root);
4538 if (node) { return node.key; }
4539 else { return null; }
4543 SplayTree.prototype.max = function max () {
4544 var node = this.maxNode(this._root);
4545 if (node) { return node.key; }
4546 else { return null; }
4549 SplayTree.prototype.isEmpty = function isEmpty () { return this._root === null; };
4550 prototypeAccessors.size.get = function () { return this._size; };
4554 * Create a tree and load it with items
4555 * @param{Array<Key>} keys
4556 * @param{Array<Value>?} [values]
4558 * @param{Function?} [comparator]
4559 * @param{Boolean?} [presort=false] Pre-sort keys and values, using
4560 * tree's comparator. Sorting is done
4562 * @param{Boolean?} [noDuplicates=false] Allow duplicates
4563 * @return {SplayTree}
4565 SplayTree.createTree = function createTree (keys, values, comparator, presort, noDuplicates) {
4566 return new SplayTree(comparator, noDuplicates).load(keys, values, presort);
4569 Object.defineProperties( SplayTree.prototype, prototypeAccessors );
4572 function loadRecursive (parent, keys, values, start, end) {
4573 var size = end - start;
4575 var middle = start + Math.floor(size / 2);
4576 var key = keys[middle];
4577 var data = values[middle];
4578 var node = { key: key, data: data, parent: parent };
4579 node.left = loadRecursive(node, keys, values, start, middle);
4580 node.right = loadRecursive(node, keys, values, middle + 1, end);
4587 function sort(keys, values, left, right, compare) {
4588 if (left >= right) { return; }
4590 var pivot = keys[(left + right) >> 1];
4595 do { i++; } while (compare(keys[i], pivot) < 0);
4596 do { j--; } while (compare(keys[j], pivot) > 0);
4597 if (i >= j) { break; }
4604 values[i] = values[j];
4608 sort(keys, values, left, j, compare);
4609 sort(keys, values, j + 1, right, compare);
4613 var NON_CONTRIBUTING = 1;
4614 var SAME_TRANSITION = 2;
4615 var DIFFERENT_TRANSITION = 3;
4617 var INTERSECTION = 0;
4623 * @param {SweepEvent} event
4624 * @param {SweepEvent} prev
4625 * @param {Operation} operation
4627 function computeFields (event, prev, operation) {
4628 // compute inOut and otherInOut fields
4629 if (prev === null) {
4630 event.inOut = false;
4631 event.otherInOut = true;
4633 // previous line segment in sweepline belongs to the same polygon
4635 if (event.isSubject === prev.isSubject) {
4636 event.inOut = !prev.inOut;
4637 event.otherInOut = prev.otherInOut;
4639 // previous line segment in sweepline belongs to the clipping polygon
4641 event.inOut = !prev.otherInOut;
4642 event.otherInOut = prev.isVertical() ? !prev.inOut : prev.inOut;
4645 // compute prevInResult field
4647 event.prevInResult = (!inResult(prev, operation) || prev.isVertical())
4648 ? prev.prevInResult : prev;
4652 // check if the line segment belongs to the Boolean operation
4653 var isInResult = inResult(event, operation);
4655 event.resultTransition = determineResultTransition(event, operation);
4657 event.resultTransition = 0;
4662 /* eslint-disable indent */
4663 function inResult(event, operation) {
4664 switch (event.type) {
4666 switch (operation) {
4668 return !event.otherInOut;
4670 return event.otherInOut;
4672 // return (event.isSubject && !event.otherInOut) ||
4673 // (!event.isSubject && event.otherInOut);
4674 return (event.isSubject && event.otherInOut) ||
4675 (!event.isSubject && !event.otherInOut);
4680 case SAME_TRANSITION:
4681 return operation === INTERSECTION || operation === UNION;
4682 case DIFFERENT_TRANSITION:
4683 return operation === DIFFERENCE;
4684 case NON_CONTRIBUTING:
4689 /* eslint-enable indent */
4692 function determineResultTransition(event, operation) {
4693 var thisIn = !event.inOut;
4694 var thatIn = !event.otherInOut;
4697 switch (operation) {
4699 isIn = thisIn && thatIn; break;
4701 isIn = thisIn || thatIn; break;
4703 isIn = thisIn ^ thatIn; break;
4705 if (event.isSubject) {
4706 isIn = thisIn && !thatIn;
4708 isIn = thatIn && !thisIn;
4712 return isIn ? +1 : -1;
4715 var SweepEvent = function SweepEvent (point, left, otherEvent, isSubject, edgeType) {
4724 * @type {Array.<Number>}
4729 * Other edge reference
4730 * @type {SweepEvent}
4732 this.otherEvent = otherEvent;
4735 * Belongs to source or clipping polygon
4738 this.isSubject = isSubject;
4741 * Edge contribution type
4744 this.type = edgeType || NORMAL;
4748 * In-out transition for the sweepline crossing polygon
4757 this.otherInOut = false;
4760 * Previous event in result?
4761 * @type {SweepEvent}
4763 this.prevInResult = null;
4766 * Type of result transition (0 = not in result, +1 = out-in, -1, in-out)
4769 this.resultTransition = 0;
4781 this.outputContourId = -1;
4783 this.isExteriorRing = true; // TODO: Looks unused, remove?
4786 var prototypeAccessors$1 = { inResult: { configurable: true } };
4790 * @param{Array.<Number>}p
4793 SweepEvent.prototype.isBelow = function isBelow (p) {
4794 var p0 = this.point, p1 = this.otherEvent.point;
4796 ? (p0[0] - p[0]) * (p1[1] - p[1]) - (p1[0] - p[0]) * (p0[1] - p[1]) > 0
4797 // signedArea(this.point, this.otherEvent.point, p) > 0 :
4798 : (p1[0] - p[0]) * (p0[1] - p[1]) - (p0[0] - p[0]) * (p1[1] - p[1]) > 0;
4799 //signedArea(this.otherEvent.point, this.point, p) > 0;
4804 * @param{Array.<Number>}p
4807 SweepEvent.prototype.isAbove = function isAbove (p) {
4808 return !this.isBelow(p);
4815 SweepEvent.prototype.isVertical = function isVertical () {
4816 return this.point[0] === this.otherEvent.point[0];
4821 * Does event belong to result?
4824 prototypeAccessors$1.inResult.get = function () {
4825 return this.resultTransition !== 0;
4829 SweepEvent.prototype.clone = function clone () {
4830 var copy = new SweepEvent(
4831 this.point, this.left, this.otherEvent, this.isSubject, this.type);
4833 copy.contourId = this.contourId;
4834 copy.resultTransition = this.resultTransition;
4835 copy.prevInResult = this.prevInResult;
4836 copy.isExteriorRing = this.isExteriorRing;
4837 copy.inOut = this.inOut;
4838 copy.otherInOut = this.otherInOut;
4843 Object.defineProperties( SweepEvent.prototype, prototypeAccessors$1 );
4845 function equals(p1, p2) {
4846 if (p1[0] === p2[0]) {
4847 if (p1[1] === p2[1]) {
4856 // const EPSILON = 1e-9;
4857 // const abs = Math.abs;
4858 // TODO https://github.com/w8r/martinez/issues/6#issuecomment-262847164
4859 // Precision problem.
4861 // module.exports = function equals(p1, p2) {
4862 // return abs(p1[0] - p2[0]) <= EPSILON && abs(p1[1] - p2[1]) <= EPSILON;
4865 var epsilon = 1.1102230246251565e-16;
4866 var splitter = 134217729;
4867 var resulterrbound = (3 + 8 * epsilon) * epsilon;
4869 // fast_expansion_sum_zeroelim routine from oritinal code
4870 function sum(elen, e, flen, f, h) {
4871 var Q, Qnew, hh, bvirt;
4876 if ((fnow > enow) === (fnow > -enow)) {
4884 if (eindex < elen && findex < flen) {
4885 if ((fnow > enow) === (fnow > -enow)) {
4887 hh = Q - (Qnew - enow);
4891 hh = Q - (Qnew - fnow);
4898 while (eindex < elen && findex < flen) {
4899 if ((fnow > enow) === (fnow > -enow)) {
4902 hh = Q - (Qnew - bvirt) + (enow - bvirt);
4907 hh = Q - (Qnew - bvirt) + (fnow - bvirt);
4916 while (eindex < elen) {
4919 hh = Q - (Qnew - bvirt) + (enow - bvirt);
4926 while (findex < flen) {
4929 hh = Q - (Qnew - bvirt) + (fnow - bvirt);
4936 if (Q !== 0 || hindex === 0) {
4942 function estimate(elen, e) {
4944 for (var i = 1; i < elen; i++) { Q += e[i]; }
4949 return new Float64Array(n);
4952 var ccwerrboundA = (3 + 16 * epsilon) * epsilon;
4953 var ccwerrboundB = (2 + 12 * epsilon) * epsilon;
4954 var ccwerrboundC = (9 + 64 * epsilon) * epsilon * epsilon;
4962 function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
4963 var acxtail, acytail, bcxtail, bcytail;
4964 var bvirt, c, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u3;
4973 ahi = c - (c - acx);
4976 bhi = c - (c - bcy);
4978 s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
4981 ahi = c - (c - acy);
4984 bhi = c - (c - bcx);
4986 t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
4989 B[0] = s0 - (_i + bvirt) + (bvirt - t0);
4992 _0 = s1 - (_j - bvirt) + (_i - bvirt);
4995 B[1] = _0 - (_i + bvirt) + (bvirt - t1);
4998 B[2] = _j - (u3 - bvirt) + (_i - bvirt);
5001 var det = estimate(4, B);
5002 var errbound = ccwerrboundB * detsum;
5003 if (det >= errbound || -det >= errbound) {
5008 acxtail = ax - (acx + bvirt) + (bvirt - cx);
5010 bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
5012 acytail = ay - (acy + bvirt) + (bvirt - cy);
5014 bcytail = by - (bcy + bvirt) + (bvirt - cy);
5016 if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
5020 errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
5021 det += (acx * bcytail + bcy * acxtail) - (acy * bcxtail + bcx * acytail);
5022 if (det >= errbound || -det >= errbound) { return det; }
5025 c = splitter * acxtail;
5026 ahi = c - (c - acxtail);
5027 alo = acxtail - ahi;
5029 bhi = c - (c - bcy);
5031 s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
5033 c = splitter * acytail;
5034 ahi = c - (c - acytail);
5035 alo = acytail - ahi;
5037 bhi = c - (c - bcx);
5039 t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
5042 u[0] = s0 - (_i + bvirt) + (bvirt - t0);
5045 _0 = s1 - (_j - bvirt) + (_i - bvirt);
5048 u[1] = _0 - (_i + bvirt) + (bvirt - t1);
5051 u[2] = _j - (u3 - bvirt) + (_i - bvirt);
5053 var C1len = sum(4, B, 4, u, C1);
5057 ahi = c - (c - acx);
5059 c = splitter * bcytail;
5060 bhi = c - (c - bcytail);
5061 blo = bcytail - bhi;
5062 s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
5065 ahi = c - (c - acy);
5067 c = splitter * bcxtail;
5068 bhi = c - (c - bcxtail);
5069 blo = bcxtail - bhi;
5070 t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
5073 u[0] = s0 - (_i + bvirt) + (bvirt - t0);
5076 _0 = s1 - (_j - bvirt) + (_i - bvirt);
5079 u[1] = _0 - (_i + bvirt) + (bvirt - t1);
5082 u[2] = _j - (u3 - bvirt) + (_i - bvirt);
5084 var C2len = sum(C1len, C1, 4, u, C2);
5086 s1 = acxtail * bcytail;
5087 c = splitter * acxtail;
5088 ahi = c - (c - acxtail);
5089 alo = acxtail - ahi;
5090 c = splitter * bcytail;
5091 bhi = c - (c - bcytail);
5092 blo = bcytail - bhi;
5093 s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
5094 t1 = acytail * bcxtail;
5095 c = splitter * acytail;
5096 ahi = c - (c - acytail);
5097 alo = acytail - ahi;
5098 c = splitter * bcxtail;
5099 bhi = c - (c - bcxtail);
5100 blo = bcxtail - bhi;
5101 t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
5104 u[0] = s0 - (_i + bvirt) + (bvirt - t0);
5107 _0 = s1 - (_j - bvirt) + (_i - bvirt);
5110 u[1] = _0 - (_i + bvirt) + (bvirt - t1);
5113 u[2] = _j - (u3 - bvirt) + (_i - bvirt);
5115 var Dlen = sum(C2len, C2, 4, u, D);
5120 function orient2d(ax, ay, bx, by, cx, cy) {
5121 var detleft = (ay - cy) * (bx - cx);
5122 var detright = (ax - cx) * (by - cy);
5123 var det = detleft - detright;
5125 if (detleft === 0 || detright === 0 || (detleft > 0) !== (detright > 0)) { return det; }
5127 var detsum = Math.abs(detleft + detright);
5128 if (Math.abs(det) >= ccwerrboundA * detsum) { return det; }
5130 return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
5134 * Signed area of the triangle (p0, p1, p2)
5135 * @param {Array.<Number>} p0
5136 * @param {Array.<Number>} p1
5137 * @param {Array.<Number>} p2
5140 function signedArea(p0, p1, p2) {
5141 var res = orient2d(p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]);
5142 if (res > 0) { return -1; }
5143 if (res < 0) { return 1; }
5148 * @param {SweepEvent} e1
5149 * @param {SweepEvent} e2
5152 function compareEvents(e1, e2) {
5156 // Different x-coordinate
5157 if (p1[0] > p2[0]) { return 1; }
5158 if (p1[0] < p2[0]) { return -1; }
5160 // Different points, but same x-coordinate
5161 // Event with lower y-coordinate is processed first
5162 if (p1[1] !== p2[1]) { return p1[1] > p2[1] ? 1 : -1; }
5164 return specialCases(e1, e2, p1);
5168 /* eslint-disable no-unused-vars */
5169 function specialCases(e1, e2, p1, p2) {
5170 // Same coordinates, but one is a left endpoint and the other is
5171 // a right endpoint. The right endpoint is processed first
5172 if (e1.left !== e2.left)
5173 { return e1.left ? 1 : -1; }
5175 // const p2 = e1.otherEvent.point, p3 = e2.otherEvent.point;
5176 // const sa = (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1])
5177 // Same coordinates, both events
5178 // are left endpoints or right endpoints.
5180 if (signedArea(p1, e1.otherEvent.point, e2.otherEvent.point) !== 0) {
5181 // the event associate to the bottom segment is processed first
5182 return (!e1.isBelow(e2.otherEvent.point)) ? 1 : -1;
5185 return (!e1.isSubject && e2.isSubject) ? 1 : -1;
5187 /* eslint-enable no-unused-vars */
5190 * @param {SweepEvent} se
5191 * @param {Array.<Number>} p
5192 * @param {Queue} queue
5195 function divideSegment(se, p, queue) {
5196 var r = new SweepEvent(p, false, se, se.isSubject);
5197 var l = new SweepEvent(p, true, se.otherEvent, se.isSubject);
5199 /* eslint-disable no-console */
5200 if (equals(se.point, se.otherEvent.point)) {
5201 console.warn('what is that, a collapsed segment?', se);
5203 /* eslint-enable no-console */
5205 r.contourId = l.contourId = se.contourId;
5207 // avoid a rounding error. The left event would be processed after the right event
5208 if (compareEvents(l, se.otherEvent) > 0) {
5209 se.otherEvent.left = true;
5213 // avoid a rounding error. The left event would be processed after the right event
5214 // if (compareEvents(se, r) > 0) {}
5216 se.otherEvent.otherEvent = l;
5228 * Finds the magnitude of the cross product of two vectors (if we pretend
5229 * they're in three dimensions)
5231 * @param {Object} a First vector
5232 * @param {Object} b Second vector
5234 * @returns {Number} The magnitude of the cross product
5236 function crossProduct(a, b) {
5237 return (a[0] * b[1]) - (a[1] * b[0]);
5241 * Finds the dot product of two vectors.
5243 * @param {Object} a First vector
5244 * @param {Object} b Second vector
5246 * @returns {Number} The dot product
5248 function dotProduct(a, b) {
5249 return (a[0] * b[0]) + (a[1] * b[1]);
5253 * Finds the intersection (if any) between two line segments a and b, given the
5254 * line segments' end points a1, a2 and b1, b2.
5256 * This algorithm is based on Schneider and Eberly.
5257 * http://www.cimec.org.ar/~ncalvo/Schneider_Eberly.pdf
5260 * @param {Array.<Number>} a1 point of first line
5261 * @param {Array.<Number>} a2 point of first line
5262 * @param {Array.<Number>} b1 point of second line
5263 * @param {Array.<Number>} b2 point of second line
5264 * @param {Boolean=} noEndpointTouch whether to skip single touchpoints
5265 * (meaning connected segments) as
5267 * @returns {Array.<Array.<Number>>|Null} If the lines intersect, the point of
5268 * intersection. If they overlap, the two end points of the overlapping segment.
5271 function intersection (a1, a2, b1, b2, noEndpointTouch) {
5272 // The algorithm expects our lines in the form P + sd, where P is a point,
5273 // s is on the interval [0, 1], and d is a vector.
5274 // We are passed two points. P can be the first point of each pair. The
5275 // vector, then, could be thought of as the distance (in x and y components)
5276 // from the first point to the second point.
5277 // So first, let's make our vectors:
5278 var va = [a2[0] - a1[0], a2[1] - a1[1]];
5279 var vb = [b2[0] - b1[0], b2[1] - b1[1]];
5280 // We also define a function to convert back to regular point form:
5282 /* eslint-disable arrow-body-style */
5284 function toPoint(p, s, d) {
5291 /* eslint-enable arrow-body-style */
5293 // The rest is pretty much a straight port of the algorithm.
5294 var e = [b1[0] - a1[0], b1[1] - a1[1]];
5295 var kross = crossProduct(va, vb);
5296 var sqrKross = kross * kross;
5297 var sqrLenA = dotProduct(va, va);
5298 //const sqrLenB = dotProduct(vb, vb);
5300 // Check for line intersection. This works because of the properties of the
5301 // cross product -- specifically, two vectors are parallel if and only if the
5302 // cross product is the 0 vector. The full calculation involves relative error
5303 // to account for possible very small line segments. See Schneider & Eberly
5305 if (sqrKross > 0/* EPS * sqrLenB * sqLenA */) {
5306 // If they're not parallel, then (because these are line segments) they
5307 // still might not actually intersect. This code checks that the
5308 // intersection point of the lines is actually on both line segments.
5309 var s = crossProduct(e, vb) / kross;
5310 if (s < 0 || s > 1) {
5311 // not on line segment a
5314 var t = crossProduct(e, va) / kross;
5315 if (t < 0 || t > 1) {
5316 // not on line segment b
5319 if (s === 0 || s === 1) {
5320 // on an endpoint of line segment a
5321 return noEndpointTouch ? null : [toPoint(a1, s, va)];
5323 if (t === 0 || t === 1) {
5324 // on an endpoint of line segment b
5325 return noEndpointTouch ? null : [toPoint(b1, t, vb)];
5327 return [toPoint(a1, s, va)];
5330 // If we've reached this point, then the lines are either parallel or the
5331 // same, but the segments could overlap partially or fully, or not at all.
5332 // So we need to find the overlap, if any. To do that, we can use e, which is
5333 // the (vector) difference between the two initial points. If this is parallel
5334 // with the line itself, then the two lines are the same line, and there will
5336 //const sqrLenE = dotProduct(e, e);
5337 kross = crossProduct(e, va);
5338 sqrKross = kross * kross;
5340 if (sqrKross > 0 /* EPS * sqLenB * sqLenE */) {
5341 // Lines are just parallel, not the same. No overlap.
5345 var sa = dotProduct(va, e) / sqrLenA;
5346 var sb = sa + dotProduct(va, vb) / sqrLenA;
5347 var smin = Math.min(sa, sb);
5348 var smax = Math.max(sa, sb);
5350 // this is, essentially, the FindIntersection acting on floats from
5351 // Schneider & Eberly, just inlined into this function.
5352 if (smin <= 1 && smax >= 0) {
5354 // overlap on an end point
5356 return noEndpointTouch ? null : [toPoint(a1, smin > 0 ? smin : 0, va)];
5360 return noEndpointTouch ? null : [toPoint(a1, smax < 1 ? smax : 1, va)];
5363 if (noEndpointTouch && smin === 0 && smax === 1) { return null; }
5365 // There's overlap on a segment -- two points of intersection. Return both.
5367 toPoint(a1, smin > 0 ? smin : 0, va),
5368 toPoint(a1, smax < 1 ? smax : 1, va)
5376 * @param {SweepEvent} se1
5377 * @param {SweepEvent} se2
5378 * @param {Queue} queue
5381 function possibleIntersection (se1, se2, queue) {
5382 // that disallows self-intersecting polygons,
5383 // did cost us half a day, so I'll leave it
5385 // if (se1.isSubject === se2.isSubject) return;
5386 var inter = intersection(
5387 se1.point, se1.otherEvent.point,
5388 se2.point, se2.otherEvent.point
5391 var nintersections = inter ? inter.length : 0;
5392 if (nintersections === 0) { return 0; } // no intersection
5394 // the line segments intersect at an endpoint of both line segments
5395 if ((nintersections === 1) &&
5396 (equals(se1.point, se2.point) ||
5397 equals(se1.otherEvent.point, se2.otherEvent.point))) {
5401 if (nintersections === 2 && se1.isSubject === se2.isSubject) {
5402 // if(se1.contourId === se2.contourId){
5403 // console.warn('Edges of the same polygon overlap',
5404 // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point);
5406 //throw new Error('Edges of the same polygon overlap');
5410 // The line segments associated to se1 and se2 intersect
5411 if (nintersections === 1) {
5413 // if the intersection point is not an endpoint of se1
5414 if (!equals(se1.point, inter[0]) && !equals(se1.otherEvent.point, inter[0])) {
5415 divideSegment(se1, inter[0], queue);
5418 // if the intersection point is not an endpoint of se2
5419 if (!equals(se2.point, inter[0]) && !equals(se2.otherEvent.point, inter[0])) {
5420 divideSegment(se2, inter[0], queue);
5425 // The line segments associated to se1 and se2 overlap
5427 var leftCoincide = false;
5428 var rightCoincide = false;
5430 if (equals(se1.point, se2.point)) {
5431 leftCoincide = true; // linked
5432 } else if (compareEvents(se1, se2) === 1) {
5433 events.push(se2, se1);
5435 events.push(se1, se2);
5438 if (equals(se1.otherEvent.point, se2.otherEvent.point)) {
5439 rightCoincide = true;
5440 } else if (compareEvents(se1.otherEvent, se2.otherEvent) === 1) {
5441 events.push(se2.otherEvent, se1.otherEvent);
5443 events.push(se1.otherEvent, se2.otherEvent);
5446 if ((leftCoincide && rightCoincide) || leftCoincide) {
5447 // both line segments are equal or share the left endpoint
5448 se2.type = NON_CONTRIBUTING;
5449 se1.type = (se2.inOut === se1.inOut)
5450 ? SAME_TRANSITION : DIFFERENT_TRANSITION;
5452 if (leftCoincide && !rightCoincide) {
5453 // honestly no idea, but changing events selection from [2, 1]
5454 // to [0, 1] fixes the overlapping self-intersecting polygons issue
5455 divideSegment(events[1].otherEvent, events[0].point, queue);
5460 // the line segments share the right endpoint
5461 if (rightCoincide) {
5462 divideSegment(events[0], events[1].point, queue);
5466 // no line segment includes totally the other one
5467 if (events[0] !== events[3].otherEvent) {
5468 divideSegment(events[0], events[1].point, queue);
5469 divideSegment(events[1], events[2].point, queue);
5473 // one line segment includes the other one
5474 divideSegment(events[0], events[1].point, queue);
5475 divideSegment(events[3].otherEvent, events[2].point, queue);
5481 * @param {SweepEvent} le1
5482 * @param {SweepEvent} le2
5485 function compareSegments(le1, le2) {
5486 if (le1 === le2) { return 0; }
5488 // Segments are not collinear
5489 if (signedArea(le1.point, le1.otherEvent.point, le2.point) !== 0 ||
5490 signedArea(le1.point, le1.otherEvent.point, le2.otherEvent.point) !== 0) {
5492 // If they share their left endpoint use the right endpoint to sort
5493 if (equals(le1.point, le2.point)) { return le1.isBelow(le2.otherEvent.point) ? -1 : 1; }
5495 // Different left endpoint: use the left endpoint to sort
5496 if (le1.point[0] === le2.point[0]) { return le1.point[1] < le2.point[1] ? -1 : 1; }
5498 // has the line segment associated to e1 been inserted
5499 // into S after the line segment associated to e2 ?
5500 if (compareEvents(le1, le2) === 1) { return le2.isAbove(le1.point) ? -1 : 1; }
5502 // The line segment associated to e2 has been inserted
5503 // into S after the line segment associated to e1
5504 return le1.isBelow(le2.point) ? -1 : 1;
5507 if (le1.isSubject === le2.isSubject) { // same polygon
5508 var p1 = le1.point, p2 = le2.point;
5509 if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) {
5510 p1 = le1.otherEvent.point; p2 = le2.otherEvent.point;
5511 if (p1[0] === p2[0] && p1[1] === p2[1]) { return 0; }
5512 else { return le1.contourId > le2.contourId ? 1 : -1; }
5514 } else { // Segments are collinear, but belong to separate polygons
5515 return le1.isSubject ? -1 : 1;
5518 return compareEvents(le1, le2) === 1 ? 1 : -1;
5521 function subdivide(eventQueue, subject, clipping, sbbox, cbbox, operation) {
5522 var sweepLine = new SplayTree(compareSegments);
5523 var sortedEvents = [];
5525 var rightbound = Math.min(sbbox[2], cbbox[2]);
5527 var prev, next, begin;
5529 while (eventQueue.length !== 0) {
5530 var event = eventQueue.pop();
5531 sortedEvents.push(event);
5533 // optimization by bboxes for intersection and difference goes here
5534 if ((operation === INTERSECTION && event.point[0] > rightbound) ||
5535 (operation === DIFFERENCE && event.point[0] > sbbox[2])) {
5540 next = prev = sweepLine.insert(event);
5541 begin = sweepLine.minNode();
5543 if (prev !== begin) { prev = sweepLine.prev(prev); }
5544 else { prev = null; }
5546 next = sweepLine.next(next);
5548 var prevEvent = prev ? prev.key : null;
5549 var prevprevEvent = (void 0);
5550 computeFields(event, prevEvent, operation);
5552 if (possibleIntersection(event, next.key, eventQueue) === 2) {
5553 computeFields(event, prevEvent, operation);
5554 computeFields(event, next.key, operation);
5559 if (possibleIntersection(prev.key, event, eventQueue) === 2) {
5560 var prevprev = prev;
5561 if (prevprev !== begin) { prevprev = sweepLine.prev(prevprev); }
5562 else { prevprev = null; }
5564 prevprevEvent = prevprev ? prevprev.key : null;
5565 computeFields(prevEvent, prevprevEvent, operation);
5566 computeFields(event, prevEvent, operation);
5570 event = event.otherEvent;
5571 next = prev = sweepLine.find(event);
5575 if (prev !== begin) { prev = sweepLine.prev(prev); }
5576 else { prev = null; }
5578 next = sweepLine.next(next);
5579 sweepLine.remove(event);
5582 possibleIntersection(prev.key, next.key, eventQueue);
5587 return sortedEvents;
5590 var Contour = function Contour() {
5597 Contour.prototype.isExterior = function isExterior () {
5598 return this.holeOf == null;
5602 * @param {Array.<SweepEvent>} sortedEvents
5603 * @return {Array.<SweepEvent>}
5605 function orderEvents(sortedEvents) {
5606 var event, i, len, tmp;
5607 var resultEvents = [];
5608 for (i = 0, len = sortedEvents.length; i < len; i++) {
5609 event = sortedEvents[i];
5610 if ((event.left && event.inResult) ||
5611 (!event.left && event.otherEvent.inResult)) {
5612 resultEvents.push(event);
5615 // Due to overlapping edges the resultEvents array can be not wholly sorted
5619 for (i = 0, len = resultEvents.length; i < len; i++) {
5620 if ((i + 1) < len &&
5621 compareEvents(resultEvents[i], resultEvents[i + 1]) === 1) {
5622 tmp = resultEvents[i];
5623 resultEvents[i] = resultEvents[i + 1];
5624 resultEvents[i + 1] = tmp;
5631 for (i = 0, len = resultEvents.length; i < len; i++) {
5632 event = resultEvents[i];
5636 // imagine, the right event is found in the beginning of the queue,
5637 // when his left counterpart is not marked yet
5638 for (i = 0, len = resultEvents.length; i < len; i++) {
5639 event = resultEvents[i];
5641 tmp = event.otherPos;
5642 event.otherPos = event.otherEvent.otherPos;
5643 event.otherEvent.otherPos = tmp;
5647 return resultEvents;
5652 * @param {Number} pos
5653 * @param {Array.<SweepEvent>} resultEvents
5654 * @param {Object>} processed
5657 function nextPos(pos, resultEvents, processed, origPos) {
5658 var newPos = pos + 1,
5659 p = resultEvents[pos].point,
5661 var length = resultEvents.length;
5663 if (newPos < length)
5664 { p1 = resultEvents[newPos].point; }
5666 while (newPos < length && p1[0] === p[0] && p1[1] === p[1]) {
5667 if (!processed[newPos]) {
5672 p1 = resultEvents[newPos].point;
5677 while (processed[newPos] && newPos > origPos) {
5685 function initializeContourFromContext(event, contours, contourId) {
5686 var contour = new Contour();
5687 if (event.prevInResult != null) {
5688 var prevInResult = event.prevInResult;
5689 // Note that it is valid to query the "previous in result" for its output contour id,
5690 // because we must have already processed it (i.e., assigned an output contour id)
5691 // in an earlier iteration, otherwise it wouldn't be possible that it is "previous in
5693 var lowerContourId = prevInResult.outputContourId;
5694 var lowerResultTransition = prevInResult.resultTransition;
5695 if (lowerResultTransition > 0) {
5696 // We are inside. Now we have to check if the thing below us is another hole or
5697 // an exterior contour.
5698 var lowerContour = contours[lowerContourId];
5699 if (lowerContour.holeOf != null) {
5700 // The lower contour is a hole => Connect the new contour as a hole to its parent,
5701 // and use same depth.
5702 var parentContourId = lowerContour.holeOf;
5703 contours[parentContourId].holeIds.push(contourId);
5704 contour.holeOf = parentContourId;
5705 contour.depth = contours[lowerContourId].depth;
5707 // The lower contour is an exterior contour => Connect the new contour as a hole,
5708 // and increment depth.
5709 contours[lowerContourId].holeIds.push(contourId);
5710 contour.holeOf = lowerContourId;
5711 contour.depth = contours[lowerContourId].depth + 1;
5714 // We are outside => this contour is an exterior contour of same depth.
5715 contour.holeOf = null;
5716 contour.depth = contours[lowerContourId].depth;
5719 // There is no lower/previous contour => this contour is an exterior contour of depth 0.
5720 contour.holeOf = null;
5727 * @param {Array.<SweepEvent>} sortedEvents
5728 * @return {Array.<*>} polygons
5730 function connectEdges(sortedEvents) {
5732 var resultEvents = orderEvents(sortedEvents);
5734 // "false"-filled array
5738 var loop = function ( ) {
5744 var contourId = contours.length;
5745 var contour = initializeContourFromContext(resultEvents[i], contours, contourId);
5747 // Helper function that combines marking an event as processed with assigning its output contour ID
5748 var markAsProcessed = function (pos) {
5749 processed[pos] = true;
5750 resultEvents[pos].outputContourId = contourId;
5756 var initial = resultEvents[i].point;
5757 contour.points.push(initial);
5759 /* eslint no-constant-condition: "off" */
5761 markAsProcessed(pos);
5763 pos = resultEvents[pos].otherPos;
5765 markAsProcessed(pos);
5766 contour.points.push(resultEvents[pos].point);
5768 pos = nextPos(pos, resultEvents, processed, origPos);
5770 if (pos == origPos) {
5775 contours.push(contour);
5778 for (i = 0, len = resultEvents.length; i < len; i++) loop( );
5783 var tinyqueue = TinyQueue;
5784 var default_1 = TinyQueue;
5786 function TinyQueue(data, compare) {
5787 if (!(this instanceof TinyQueue)) { return new TinyQueue(data, compare); }
5789 this.data = data || [];
5790 this.length = this.data.length;
5791 this.compare = compare || defaultCompare;
5793 if (this.length > 0) {
5794 for (var i = (this.length >> 1) - 1; i >= 0; i--) { this._down(i); }
5798 function defaultCompare(a, b) {
5799 return a < b ? -1 : a > b ? 1 : 0;
5802 TinyQueue.prototype = {
5804 push: function (item) {
5805 this.data.push(item);
5807 this._up(this.length - 1);
5811 if (this.length === 0) { return undefined; }
5813 var top = this.data[0];
5816 if (this.length > 0) {
5817 this.data[0] = this.data[this.length];
5826 return this.data[0];
5829 _up: function (pos) {
5830 var data = this.data;
5831 var compare = this.compare;
5832 var item = data[pos];
5835 var parent = (pos - 1) >> 1;
5836 var current = data[parent];
5837 if (compare(item, current) >= 0) { break; }
5838 data[pos] = current;
5845 _down: function (pos) {
5846 var data = this.data;
5847 var compare = this.compare;
5848 var halfLength = this.length >> 1;
5849 var item = data[pos];
5851 while (pos < halfLength) {
5852 var left = (pos << 1) + 1;
5853 var right = left + 1;
5854 var best = data[left];
5856 if (right < this.length && compare(data[right], best) < 0) {
5860 if (compare(best, item) >= 0) { break; }
5869 tinyqueue.default = default_1;
5877 function processPolygon(contourOrHole, isSubject, depth, Q, bbox, isExteriorRing) {
5878 var i, len, s1, s2, e1, e2;
5879 for (i = 0, len = contourOrHole.length - 1; i < len; i++) {
5880 s1 = contourOrHole[i];
5881 s2 = contourOrHole[i + 1];
5882 e1 = new SweepEvent(s1, false, undefined, isSubject);
5883 e2 = new SweepEvent(s2, false, e1, isSubject);
5886 if (s1[0] === s2[0] && s1[1] === s2[1]) {
5887 continue; // skip collapsed edges, or it breaks
5890 e1.contourId = e2.contourId = depth;
5891 if (!isExteriorRing) {
5892 e1.isExteriorRing = false;
5893 e2.isExteriorRing = false;
5895 if (compareEvents(e1, e2) > 0) {
5901 var x = s1[0], y = s1[1];
5902 bbox[0] = min(bbox[0], x);
5903 bbox[1] = min(bbox[1], y);
5904 bbox[2] = max(bbox[2], x);
5905 bbox[3] = max(bbox[3], y);
5907 // Pushing it so the queue is sorted from left to right,
5908 // with object on the left having the highest priority.
5915 function fillQueue(subject, clipping, sbbox, cbbox, operation) {
5916 var eventQueue = new tinyqueue(null, compareEvents);
5917 var polygonSet, isExteriorRing, i, ii, j, jj; //, k, kk;
5919 for (i = 0, ii = subject.length; i < ii; i++) {
5920 polygonSet = subject[i];
5921 for (j = 0, jj = polygonSet.length; j < jj; j++) {
5922 isExteriorRing = j === 0;
5923 if (isExteriorRing) { contourId++; }
5924 processPolygon(polygonSet[j], true, contourId, eventQueue, sbbox, isExteriorRing);
5928 for (i = 0, ii = clipping.length; i < ii; i++) {
5929 polygonSet = clipping[i];
5930 for (j = 0, jj = polygonSet.length; j < jj; j++) {
5931 isExteriorRing = j === 0;
5932 if (operation === DIFFERENCE) { isExteriorRing = false; }
5933 if (isExteriorRing) { contourId++; }
5934 processPolygon(polygonSet[j], false, contourId, eventQueue, cbbox, isExteriorRing);
5944 function trivialOperation(subject, clipping, operation) {
5946 if (subject.length * clipping.length === 0) {
5947 if (operation === INTERSECTION) {
5949 } else if (operation === DIFFERENCE) {
5951 } else if (operation === UNION ||
5952 operation === XOR) {
5953 result = (subject.length === 0) ? clipping : subject;
5960 function compareBBoxes(subject, clipping, sbbox, cbbox, operation) {
5962 if (sbbox[0] > cbbox[2] ||
5963 cbbox[0] > sbbox[2] ||
5964 sbbox[1] > cbbox[3] ||
5965 cbbox[1] > sbbox[3]) {
5966 if (operation === INTERSECTION) {
5968 } else if (operation === DIFFERENCE) {
5970 } else if (operation === UNION ||
5971 operation === XOR) {
5972 result = subject.concat(clipping);
5979 function boolean(subject, clipping, operation) {
5980 if (typeof subject[0][0][0] === 'number') {
5981 subject = [subject];
5983 if (typeof clipping[0][0][0] === 'number') {
5984 clipping = [clipping];
5986 var trivial = trivialOperation(subject, clipping, operation);
5988 return trivial === EMPTY ? null : trivial;
5990 var sbbox = [Infinity, Infinity, -Infinity, -Infinity];
5991 var cbbox = [Infinity, Infinity, -Infinity, -Infinity];
5993 // console.time('fill queue');
5994 var eventQueue = fillQueue(subject, clipping, sbbox, cbbox, operation);
5995 //console.timeEnd('fill queue');
5997 trivial = compareBBoxes(subject, clipping, sbbox, cbbox, operation);
5999 return trivial === EMPTY ? null : trivial;
6001 // console.time('subdivide edges');
6002 var sortedEvents = subdivide(eventQueue, subject, clipping, sbbox, cbbox, operation);
6003 //console.timeEnd('subdivide edges');
6005 // console.time('connect vertices');
6006 var contours = connectEdges(sortedEvents);
6007 //console.timeEnd('connect vertices');
6009 // Convert contours to polygons
6011 for (var i = 0; i < contours.length; i++) {
6012 var contour = contours[i];
6013 if (contour.isExterior()) {
6014 // The exterior ring goes first
6015 var rings = [contour.points];
6016 // Followed by holes if any
6017 for (var j = 0; j < contour.holeIds.length; j++) {
6018 var holeId = contour.holeIds[j];
6019 rings.push(contours[holeId].points);
6021 polygons.push(rings);
6028 function union (subject, clipping) {
6029 return boolean(subject, clipping, UNION);
6032 function diff (subject, clipping) {
6033 return boolean(subject, clipping, DIFFERENCE);
6036 function xor (subject, clipping) {
6037 return boolean(subject, clipping, XOR);
6040 function intersection$1 (subject, clipping) {
6041 return boolean(subject, clipping, INTERSECTION);
6047 var operations = { UNION: UNION, DIFFERENCE: DIFFERENCE, INTERSECTION: INTERSECTION, XOR: XOR };
6049 exports.diff = diff;
6050 exports.intersection = intersection$1;
6051 exports.operations = operations;
6052 exports.union = union;
6055 Object.defineProperty(exports, '__esModule', { value: true });
6060 },{}],23:[function(require,module,exports){
6061 // Top level file is just a mixin of submodules & constants
6064 var assign = require('./lib/utils/common').assign;
6066 var deflate = require('./lib/deflate');
6067 var inflate = require('./lib/inflate');
6068 var constants = require('./lib/zlib/constants');
6072 assign(pako, deflate, inflate, constants);
6074 module.exports = pako;
6076 },{"./lib/deflate":24,"./lib/inflate":25,"./lib/utils/common":26,"./lib/zlib/constants":29}],24:[function(require,module,exports){
6080 var zlib_deflate = require('./zlib/deflate');
6081 var utils = require('./utils/common');
6082 var strings = require('./utils/strings');
6083 var msg = require('./zlib/messages');
6084 var ZStream = require('./zlib/zstream');
6086 var toString = Object.prototype.toString;
6088 /* Public constants ==========================================================*/
6089 /* ===========================================================================*/
6095 var Z_STREAM_END = 1;
6096 var Z_SYNC_FLUSH = 2;
6098 var Z_DEFAULT_COMPRESSION = -1;
6100 var Z_DEFAULT_STRATEGY = 0;
6104 /* ===========================================================================*/
6110 * Generic JS-style wrapper for zlib calls. If you don't need
6111 * streaming behaviour - use more simple functions: [[deflate]],
6112 * [[deflateRaw]] and [[gzip]].
6116 * Deflate.chunks -> Array
6118 * Chunks of output data, if [[Deflate#onData]] not overridden.
6122 * Deflate.result -> Uint8Array|Array
6124 * Compressed result, generated by default [[Deflate#onData]]
6125 * and [[Deflate#onEnd]] handlers. Filled after you push last chunk
6126 * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you
6127 * push a chunk with explicit flush (call [[Deflate#push]] with
6128 * `Z_SYNC_FLUSH` param).
6132 * Deflate.err -> Number
6134 * Error code after deflate finished. 0 (Z_OK) on success.
6135 * You will not need it in real life, because deflate errors
6136 * are possible only on wrong options or bad `onData` / `onEnd`
6141 * Deflate.msg -> String
6143 * Error message, if [[Deflate.err]] != 0
6148 * new Deflate(options)
6149 * - options (Object): zlib deflate options.
6151 * Creates new deflator instance with specified params. Throws exception
6152 * on bad params. Supported options:
6160 * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
6161 * for more information on these.
6163 * Additional options, for internal needs:
6165 * - `chunkSize` - size of generated data chunks (16K by default)
6166 * - `raw` (Boolean) - do raw deflate
6167 * - `gzip` (Boolean) - create gzip wrapper
6168 * - `to` (String) - if equal to 'string', then result will be "binary string"
6169 * (each char code [0..255])
6170 * - `header` (Object) - custom header for gzip
6171 * - `text` (Boolean) - true if compressed data believed to be text
6172 * - `time` (Number) - modification time, unix timestamp
6173 * - `os` (Number) - operation system code
6174 * - `extra` (Array) - array of bytes with extra data (max 65536)
6175 * - `name` (String) - file name (binary string)
6176 * - `comment` (String) - comment (binary string)
6177 * - `hcrc` (Boolean) - true if header crc should be added
6182 * var pako = require('pako')
6183 * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
6184 * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
6186 * var deflate = new pako.Deflate({ level: 3});
6188 * deflate.push(chunk1, false);
6189 * deflate.push(chunk2, true); // true -> last chunk
6191 * if (deflate.err) { throw new Error(deflate.err); }
6193 * console.log(deflate.result);
6196 function Deflate(options) {
6197 if (!(this instanceof Deflate)) return new Deflate(options);
6199 this.options = utils.assign({
6200 level: Z_DEFAULT_COMPRESSION,
6205 strategy: Z_DEFAULT_STRATEGY,
6209 var opt = this.options;
6211 if (opt.raw && (opt.windowBits > 0)) {
6212 opt.windowBits = -opt.windowBits;
6215 else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {
6216 opt.windowBits += 16;
6219 this.err = 0; // error code, if happens (0 = Z_OK)
6220 this.msg = ''; // error message
6221 this.ended = false; // used to avoid multiple onEnd() calls
6222 this.chunks = []; // chunks of compressed data
6224 this.strm = new ZStream();
6225 this.strm.avail_out = 0;
6227 var status = zlib_deflate.deflateInit2(
6236 if (status !== Z_OK) {
6237 throw new Error(msg[status]);
6241 zlib_deflate.deflateSetHeader(this.strm, opt.header);
6244 if (opt.dictionary) {
6246 // Convert data if needed
6247 if (typeof opt.dictionary === 'string') {
6248 // If we need to compress text, change encoding to utf8.
6249 dict = strings.string2buf(opt.dictionary);
6250 } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
6251 dict = new Uint8Array(opt.dictionary);
6253 dict = opt.dictionary;
6256 status = zlib_deflate.deflateSetDictionary(this.strm, dict);
6258 if (status !== Z_OK) {
6259 throw new Error(msg[status]);
6262 this._dict_set = true;
6267 * Deflate#push(data[, mode]) -> Boolean
6268 * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be
6269 * converted to utf8 byte sequence.
6270 * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
6271 * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.
6273 * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with
6274 * new compressed chunks. Returns `true` on success. The last data block must have
6275 * mode Z_FINISH (or `true`). That will flush internal pending buffers and call
6276 * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you
6277 * can use mode Z_SYNC_FLUSH, keeping the compression context.
6279 * On fail call [[Deflate#onEnd]] with error code and return false.
6281 * We strongly recommend to use `Uint8Array` on input for best speed (output
6282 * array format is detected automatically). Also, don't skip last param and always
6283 * use the same type in your code (boolean or number). That will improve JS speed.
6285 * For regular `Array`-s make sure all elements are [0..255].
6290 * push(chunk, false); // push one of data chunks
6292 * push(chunk, true); // push last chunk
6295 Deflate.prototype.push = function (data, mode) {
6296 var strm = this.strm;
6297 var chunkSize = this.options.chunkSize;
6300 if (this.ended) { return false; }
6302 _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);
6304 // Convert data if needed
6305 if (typeof data === 'string') {
6306 // If we need to compress text, change encoding to utf8.
6307 strm.input = strings.string2buf(data);
6308 } else if (toString.call(data) === '[object ArrayBuffer]') {
6309 strm.input = new Uint8Array(data);
6315 strm.avail_in = strm.input.length;
6318 if (strm.avail_out === 0) {
6319 strm.output = new utils.Buf8(chunkSize);
6321 strm.avail_out = chunkSize;
6323 status = zlib_deflate.deflate(strm, _mode); /* no bad return value */
6325 if (status !== Z_STREAM_END && status !== Z_OK) {
6330 if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {
6331 if (this.options.to === 'string') {
6332 this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));
6334 this.onData(utils.shrinkBuf(strm.output, strm.next_out));
6337 } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);
6339 // Finalize on the last chunk.
6340 if (_mode === Z_FINISH) {
6341 status = zlib_deflate.deflateEnd(this.strm);
6344 return status === Z_OK;
6347 // callback interim results if Z_SYNC_FLUSH.
6348 if (_mode === Z_SYNC_FLUSH) {
6359 * Deflate#onData(chunk) -> Void
6360 * - chunk (Uint8Array|Array|String): output data. Type of array depends
6361 * on js engine support. When string output requested, each chunk
6364 * By default, stores data blocks in `chunks[]` property and glue
6365 * those in `onEnd`. Override this handler, if you need another behaviour.
6367 Deflate.prototype.onData = function (chunk) {
6368 this.chunks.push(chunk);
6373 * Deflate#onEnd(status) -> Void
6374 * - status (Number): deflate status. 0 (Z_OK) on success,
6377 * Called once after you tell deflate that the input stream is
6378 * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
6379 * or if an error happened. By default - join collected chunks,
6380 * free memory and fill `results` / `err` properties.
6382 Deflate.prototype.onEnd = function (status) {
6383 // On success - join
6384 if (status === Z_OK) {
6385 if (this.options.to === 'string') {
6386 this.result = this.chunks.join('');
6388 this.result = utils.flattenChunks(this.chunks);
6393 this.msg = this.strm.msg;
6398 * deflate(data[, options]) -> Uint8Array|Array|String
6399 * - data (Uint8Array|Array|String): input data to compress.
6400 * - options (Object): zlib deflate options.
6402 * Compress `data` with deflate algorithm and `options`.
6404 * Supported options are:
6412 * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
6413 * for more information on these.
6417 * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
6418 * negative windowBits implicitly.
6419 * - `to` (String) - if equal to 'string', then result will be "binary string"
6420 * (each char code [0..255])
6425 * var pako = require('pako')
6426 * , data = Uint8Array([1,2,3,4,5,6,7,8,9]);
6428 * console.log(pako.deflate(data));
6431 function deflate(input, options) {
6432 var deflator = new Deflate(options);
6434 deflator.push(input, true);
6436 // That will never happens, if you don't cheat with options :)
6437 if (deflator.err) { throw deflator.msg || msg[deflator.err]; }
6439 return deflator.result;
6444 * deflateRaw(data[, options]) -> Uint8Array|Array|String
6445 * - data (Uint8Array|Array|String): input data to compress.
6446 * - options (Object): zlib deflate options.
6448 * The same as [[deflate]], but creates raw data, without wrapper
6449 * (header and adler32 crc).
6451 function deflateRaw(input, options) {
6452 options = options || {};
6454 return deflate(input, options);
6459 * gzip(data[, options]) -> Uint8Array|Array|String
6460 * - data (Uint8Array|Array|String): input data to compress.
6461 * - options (Object): zlib deflate options.
6463 * The same as [[deflate]], but create gzip wrapper instead of
6466 function gzip(input, options) {
6467 options = options || {};
6468 options.gzip = true;
6469 return deflate(input, options);
6473 exports.Deflate = Deflate;
6474 exports.deflate = deflate;
6475 exports.deflateRaw = deflateRaw;
6476 exports.gzip = gzip;
6478 },{"./utils/common":26,"./utils/strings":27,"./zlib/deflate":31,"./zlib/messages":36,"./zlib/zstream":38}],25:[function(require,module,exports){
6482 var zlib_inflate = require('./zlib/inflate');
6483 var utils = require('./utils/common');
6484 var strings = require('./utils/strings');
6485 var c = require('./zlib/constants');
6486 var msg = require('./zlib/messages');
6487 var ZStream = require('./zlib/zstream');
6488 var GZheader = require('./zlib/gzheader');
6490 var toString = Object.prototype.toString;
6495 * Generic JS-style wrapper for zlib calls. If you don't need
6496 * streaming behaviour - use more simple functions: [[inflate]]
6497 * and [[inflateRaw]].
6501 * inflate.chunks -> Array
6503 * Chunks of output data, if [[Inflate#onData]] not overridden.
6507 * Inflate.result -> Uint8Array|Array|String
6509 * Uncompressed result, generated by default [[Inflate#onData]]
6510 * and [[Inflate#onEnd]] handlers. Filled after you push last chunk
6511 * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you
6512 * push a chunk with explicit flush (call [[Inflate#push]] with
6513 * `Z_SYNC_FLUSH` param).
6517 * Inflate.err -> Number
6519 * Error code after inflate finished. 0 (Z_OK) on success.
6520 * Should be checked if broken data possible.
6524 * Inflate.msg -> String
6526 * Error message, if [[Inflate.err]] != 0
6531 * new Inflate(options)
6532 * - options (Object): zlib inflate options.
6534 * Creates new inflator instance with specified params. Throws exception
6535 * on bad params. Supported options:
6540 * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
6541 * for more information on these.
6543 * Additional options, for internal needs:
6545 * - `chunkSize` - size of generated data chunks (16K by default)
6546 * - `raw` (Boolean) - do raw inflate
6547 * - `to` (String) - if equal to 'string', then result will be converted
6548 * from utf8 to utf16 (javascript) string. When string output requested,
6549 * chunk length can differ from `chunkSize`, depending on content.
6551 * By default, when no options set, autodetect deflate/gzip data format via
6557 * var pako = require('pako')
6558 * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
6559 * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
6561 * var inflate = new pako.Inflate({ level: 3});
6563 * inflate.push(chunk1, false);
6564 * inflate.push(chunk2, true); // true -> last chunk
6566 * if (inflate.err) { throw new Error(inflate.err); }
6568 * console.log(inflate.result);
6571 function Inflate(options) {
6572 if (!(this instanceof Inflate)) return new Inflate(options);
6574 this.options = utils.assign({
6580 var opt = this.options;
6582 // Force window size for `raw` data, if not set directly,
6583 // because we have no header for autodetect.
6584 if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {
6585 opt.windowBits = -opt.windowBits;
6586 if (opt.windowBits === 0) { opt.windowBits = -15; }
6589 // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
6590 if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&
6591 !(options && options.windowBits)) {
6592 opt.windowBits += 32;
6595 // Gzip header has no info about windows size, we can do autodetect only
6596 // for deflate. So, if window size not set, force it to max when gzip possible
6597 if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
6598 // bit 3 (16) -> gzipped data
6599 // bit 4 (32) -> autodetect gzip/deflate
6600 if ((opt.windowBits & 15) === 0) {
6601 opt.windowBits |= 15;
6605 this.err = 0; // error code, if happens (0 = Z_OK)
6606 this.msg = ''; // error message
6607 this.ended = false; // used to avoid multiple onEnd() calls
6608 this.chunks = []; // chunks of compressed data
6610 this.strm = new ZStream();
6611 this.strm.avail_out = 0;
6613 var status = zlib_inflate.inflateInit2(
6618 if (status !== c.Z_OK) {
6619 throw new Error(msg[status]);
6622 this.header = new GZheader();
6624 zlib_inflate.inflateGetHeader(this.strm, this.header);
6627 if (opt.dictionary) {
6628 // Convert data if needed
6629 if (typeof opt.dictionary === 'string') {
6630 opt.dictionary = strings.string2buf(opt.dictionary);
6631 } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
6632 opt.dictionary = new Uint8Array(opt.dictionary);
6634 if (opt.raw) { //In raw mode we need to set the dictionary early
6635 status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);
6636 if (status !== c.Z_OK) {
6637 throw new Error(msg[status]);
6644 * Inflate#push(data[, mode]) -> Boolean
6645 * - data (Uint8Array|Array|ArrayBuffer|String): input data
6646 * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
6647 * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.
6649 * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with
6650 * new output chunks. Returns `true` on success. The last data block must have
6651 * mode Z_FINISH (or `true`). That will flush internal pending buffers and call
6652 * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you
6653 * can use mode Z_SYNC_FLUSH, keeping the decompression context.
6655 * On fail call [[Inflate#onEnd]] with error code and return false.
6657 * We strongly recommend to use `Uint8Array` on input for best speed (output
6658 * format is detected automatically). Also, don't skip last param and always
6659 * use the same type in your code (boolean or number). That will improve JS speed.
6661 * For regular `Array`-s make sure all elements are [0..255].
6666 * push(chunk, false); // push one of data chunks
6668 * push(chunk, true); // push last chunk
6671 Inflate.prototype.push = function (data, mode) {
6672 var strm = this.strm;
6673 var chunkSize = this.options.chunkSize;
6674 var dictionary = this.options.dictionary;
6676 var next_out_utf8, tail, utf8str;
6678 // Flag to properly process Z_BUF_ERROR on testing inflate call
6679 // when we check that all output data was flushed.
6680 var allowBufError = false;
6682 if (this.ended) { return false; }
6683 _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
6685 // Convert data if needed
6686 if (typeof data === 'string') {
6687 // Only binary strings can be decompressed on practice
6688 strm.input = strings.binstring2buf(data);
6689 } else if (toString.call(data) === '[object ArrayBuffer]') {
6690 strm.input = new Uint8Array(data);
6696 strm.avail_in = strm.input.length;
6699 if (strm.avail_out === 0) {
6700 strm.output = new utils.Buf8(chunkSize);
6702 strm.avail_out = chunkSize;
6705 status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */
6707 if (status === c.Z_NEED_DICT && dictionary) {
6708 status = zlib_inflate.inflateSetDictionary(this.strm, dictionary);
6711 if (status === c.Z_BUF_ERROR && allowBufError === true) {
6713 allowBufError = false;
6716 if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
6722 if (strm.next_out) {
6723 if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {
6725 if (this.options.to === 'string') {
6727 next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
6729 tail = strm.next_out - next_out_utf8;
6730 utf8str = strings.buf2string(strm.output, next_out_utf8);
6733 strm.next_out = tail;
6734 strm.avail_out = chunkSize - tail;
6735 if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }
6737 this.onData(utf8str);
6740 this.onData(utils.shrinkBuf(strm.output, strm.next_out));
6745 // When no more input data, we should check that internal inflate buffers
6746 // are flushed. The only way to do it when avail_out = 0 - run one more
6747 // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.
6748 // Here we set flag to process this error properly.
6750 // NOTE. Deflate does not return error in this case and does not needs such
6752 if (strm.avail_in === 0 && strm.avail_out === 0) {
6753 allowBufError = true;
6756 } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
6758 if (status === c.Z_STREAM_END) {
6762 // Finalize on the last chunk.
6763 if (_mode === c.Z_FINISH) {
6764 status = zlib_inflate.inflateEnd(this.strm);
6767 return status === c.Z_OK;
6770 // callback interim results if Z_SYNC_FLUSH.
6771 if (_mode === c.Z_SYNC_FLUSH) {
6782 * Inflate#onData(chunk) -> Void
6783 * - chunk (Uint8Array|Array|String): output data. Type of array depends
6784 * on js engine support. When string output requested, each chunk
6787 * By default, stores data blocks in `chunks[]` property and glue
6788 * those in `onEnd`. Override this handler, if you need another behaviour.
6790 Inflate.prototype.onData = function (chunk) {
6791 this.chunks.push(chunk);
6796 * Inflate#onEnd(status) -> Void
6797 * - status (Number): inflate status. 0 (Z_OK) on success,
6800 * Called either after you tell inflate that the input stream is
6801 * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
6802 * or if an error happened. By default - join collected chunks,
6803 * free memory and fill `results` / `err` properties.
6805 Inflate.prototype.onEnd = function (status) {
6806 // On success - join
6807 if (status === c.Z_OK) {
6808 if (this.options.to === 'string') {
6809 // Glue & convert here, until we teach pako to send
6810 // utf8 aligned strings to onData
6811 this.result = this.chunks.join('');
6813 this.result = utils.flattenChunks(this.chunks);
6818 this.msg = this.strm.msg;
6823 * inflate(data[, options]) -> Uint8Array|Array|String
6824 * - data (Uint8Array|Array|String): input data to decompress.
6825 * - options (Object): zlib inflate options.
6827 * Decompress `data` with inflate/ungzip and `options`. Autodetect
6828 * format via wrapper header by default. That's why we don't provide
6829 * separate `ungzip` method.
6831 * Supported options are:
6835 * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
6836 * for more information.
6840 * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
6841 * negative windowBits implicitly.
6842 * - `to` (String) - if equal to 'string', then result will be converted
6843 * from utf8 to utf16 (javascript) string. When string output requested,
6844 * chunk length can differ from `chunkSize`, depending on content.
6850 * var pako = require('pako')
6851 * , input = pako.deflate([1,2,3,4,5,6,7,8,9])
6855 * output = pako.inflate(input);
6861 function inflate(input, options) {
6862 var inflator = new Inflate(options);
6864 inflator.push(input, true);
6866 // That will never happens, if you don't cheat with options :)
6867 if (inflator.err) { throw inflator.msg || msg[inflator.err]; }
6869 return inflator.result;
6874 * inflateRaw(data[, options]) -> Uint8Array|Array|String
6875 * - data (Uint8Array|Array|String): input data to decompress.
6876 * - options (Object): zlib inflate options.
6878 * The same as [[inflate]], but creates raw data, without wrapper
6879 * (header and adler32 crc).
6881 function inflateRaw(input, options) {
6882 options = options || {};
6884 return inflate(input, options);
6889 * ungzip(data[, options]) -> Uint8Array|Array|String
6890 * - data (Uint8Array|Array|String): input data to decompress.
6891 * - options (Object): zlib inflate options.
6893 * Just shortcut to [[inflate]], because it autodetects format
6894 * by header.content. Done for convenience.
6898 exports.Inflate = Inflate;
6899 exports.inflate = inflate;
6900 exports.inflateRaw = inflateRaw;
6901 exports.ungzip = inflate;
6903 },{"./utils/common":26,"./utils/strings":27,"./zlib/constants":29,"./zlib/gzheader":32,"./zlib/inflate":34,"./zlib/messages":36,"./zlib/zstream":38}],26:[function(require,module,exports){
6907 var TYPED_OK = (typeof Uint8Array !== 'undefined') &&
6908 (typeof Uint16Array !== 'undefined') &&
6909 (typeof Int32Array !== 'undefined');
6911 function _has(obj, key) {
6912 return Object.prototype.hasOwnProperty.call(obj, key);
6915 exports.assign = function (obj /*from1, from2, from3, ...*/) {
6916 var sources = Array.prototype.slice.call(arguments, 1);
6917 while (sources.length) {
6918 var source = sources.shift();
6919 if (!source) { continue; }
6921 if (typeof source !== 'object') {
6922 throw new TypeError(source + 'must be non-object');
6925 for (var p in source) {
6926 if (_has(source, p)) {
6936 // reduce buffer size, avoiding mem copy
6937 exports.shrinkBuf = function (buf, size) {
6938 if (buf.length === size) { return buf; }
6939 if (buf.subarray) { return buf.subarray(0, size); }
6946 arraySet: function (dest, src, src_offs, len, dest_offs) {
6947 if (src.subarray && dest.subarray) {
6948 dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
6951 // Fallback to ordinary array
6952 for (var i = 0; i < len; i++) {
6953 dest[dest_offs + i] = src[src_offs + i];
6956 // Join array of chunks to single array.
6957 flattenChunks: function (chunks) {
6958 var i, l, len, pos, chunk, result;
6960 // calculate data length
6962 for (i = 0, l = chunks.length; i < l; i++) {
6963 len += chunks[i].length;
6967 result = new Uint8Array(len);
6969 for (i = 0, l = chunks.length; i < l; i++) {
6971 result.set(chunk, pos);
6972 pos += chunk.length;
6980 arraySet: function (dest, src, src_offs, len, dest_offs) {
6981 for (var i = 0; i < len; i++) {
6982 dest[dest_offs + i] = src[src_offs + i];
6985 // Join array of chunks to single array.
6986 flattenChunks: function (chunks) {
6987 return [].concat.apply([], chunks);
6992 // Enable/Disable typed arrays use, for testing
6994 exports.setTyped = function (on) {
6996 exports.Buf8 = Uint8Array;
6997 exports.Buf16 = Uint16Array;
6998 exports.Buf32 = Int32Array;
6999 exports.assign(exports, fnTyped);
7001 exports.Buf8 = Array;
7002 exports.Buf16 = Array;
7003 exports.Buf32 = Array;
7004 exports.assign(exports, fnUntyped);
7008 exports.setTyped(TYPED_OK);
7010 },{}],27:[function(require,module,exports){
7011 // String encode/decode helpers
7015 var utils = require('./common');
7018 // Quick check if we can use fast array to bin string conversion
7020 // - apply(Array) can fail on Android 2.2
7021 // - apply(Uint8Array) can fail on iOS 5.1 Safari
7023 var STR_APPLY_OK = true;
7024 var STR_APPLY_UIA_OK = true;
7026 try { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }
7027 try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }
7030 // Table with utf8 lengths (calculated by first byte of sequence)
7031 // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
7032 // because max possible codepoint is 0x10ffff
7033 var _utf8len = new utils.Buf8(256);
7034 for (var q = 0; q < 256; q++) {
7035 _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);
7037 _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
7040 // convert string to array (typed, when possible)
7041 exports.string2buf = function (str) {
7042 var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;
7044 // count binary size
7045 for (m_pos = 0; m_pos < str_len; m_pos++) {
7046 c = str.charCodeAt(m_pos);
7047 if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
7048 c2 = str.charCodeAt(m_pos + 1);
7049 if ((c2 & 0xfc00) === 0xdc00) {
7050 c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
7054 buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
7058 buf = new utils.Buf8(buf_len);
7061 for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
7062 c = str.charCodeAt(m_pos);
7063 if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
7064 c2 = str.charCodeAt(m_pos + 1);
7065 if ((c2 & 0xfc00) === 0xdc00) {
7066 c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
7073 } else if (c < 0x800) {
7075 buf[i++] = 0xC0 | (c >>> 6);
7076 buf[i++] = 0x80 | (c & 0x3f);
7077 } else if (c < 0x10000) {
7079 buf[i++] = 0xE0 | (c >>> 12);
7080 buf[i++] = 0x80 | (c >>> 6 & 0x3f);
7081 buf[i++] = 0x80 | (c & 0x3f);
7084 buf[i++] = 0xf0 | (c >>> 18);
7085 buf[i++] = 0x80 | (c >>> 12 & 0x3f);
7086 buf[i++] = 0x80 | (c >>> 6 & 0x3f);
7087 buf[i++] = 0x80 | (c & 0x3f);
7094 // Helper (used in 2 places)
7095 function buf2binstring(buf, len) {
7096 // On Chrome, the arguments in a function call that are allowed is `65534`.
7097 // If the length of the buffer is smaller than that, we can use this optimization,
7098 // otherwise we will take a slower path.
7100 if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {
7101 return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));
7106 for (var i = 0; i < len; i++) {
7107 result += String.fromCharCode(buf[i]);
7113 // Convert byte array to binary string
7114 exports.buf2binstring = function (buf) {
7115 return buf2binstring(buf, buf.length);
7119 // Convert binary string (typed, when possible)
7120 exports.binstring2buf = function (str) {
7121 var buf = new utils.Buf8(str.length);
7122 for (var i = 0, len = buf.length; i < len; i++) {
7123 buf[i] = str.charCodeAt(i);
7129 // convert array to string
7130 exports.buf2string = function (buf, max) {
7131 var i, out, c, c_len;
7132 var len = max || buf.length;
7134 // Reserve max possible length (2 words per char)
7135 // NB: by unknown reasons, Array is significantly faster for
7136 // String.fromCharCode.apply than Uint16Array.
7137 var utf16buf = new Array(len * 2);
7139 for (out = 0, i = 0; i < len;) {
7141 // quick process ascii
7142 if (c < 0x80) { utf16buf[out++] = c; continue; }
7144 c_len = _utf8len[c];
7145 // skip 5 & 6 byte codes
7146 if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }
7148 // apply mask on first byte
7149 c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;
7151 while (c_len > 1 && i < len) {
7152 c = (c << 6) | (buf[i++] & 0x3f);
7156 // terminated by end of string?
7157 if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }
7160 utf16buf[out++] = c;
7163 utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);
7164 utf16buf[out++] = 0xdc00 | (c & 0x3ff);
7168 return buf2binstring(utf16buf, out);
7172 // Calculate max possible position in utf8 buffer,
7173 // that will not break sequence. If that's not possible
7174 // - (very small limits) return max size as is.
7176 // buf[] - utf8 bytes array
7177 // max - length limit (mandatory);
7178 exports.utf8border = function (buf, max) {
7181 max = max || buf.length;
7182 if (max > buf.length) { max = buf.length; }
7184 // go back from last position, until start of sequence found
7186 while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }
7188 // Very small and broken sequence,
7189 // return max, because we should return something anyway.
7190 if (pos < 0) { return max; }
7192 // If we came to start of buffer - that means buffer is too small,
7194 if (pos === 0) { return max; }
7196 return (pos + _utf8len[buf[pos]] > max) ? pos : max;
7199 },{"./common":26}],28:[function(require,module,exports){
7202 // Note: adler32 takes 12% for level 0 and 2% for level 6.
7203 // It isn't worth it to make additional optimizations as in original.
7204 // Small size is preferable.
7206 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
7207 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
7209 // This software is provided 'as-is', without any express or implied
7210 // warranty. In no event will the authors be held liable for any damages
7211 // arising from the use of this software.
7213 // Permission is granted to anyone to use this software for any purpose,
7214 // including commercial applications, and to alter it and redistribute it
7215 // freely, subject to the following restrictions:
7217 // 1. The origin of this software must not be misrepresented; you must not
7218 // claim that you wrote the original software. If you use this software
7219 // in a product, an acknowledgment in the product documentation would be
7220 // appreciated but is not required.
7221 // 2. Altered source versions must be plainly marked as such, and must not be
7222 // misrepresented as being the original software.
7223 // 3. This notice may not be removed or altered from any source distribution.
7225 function adler32(adler, buf, len, pos) {
7226 var s1 = (adler & 0xffff) |0,
7227 s2 = ((adler >>> 16) & 0xffff) |0,
7231 // Set limit ~ twice less than 5552, to keep
7232 // s2 in 31-bits, because we force signed ints.
7233 // in other case %= will fail.
7234 n = len > 2000 ? 2000 : len;
7238 s1 = (s1 + buf[pos++]) |0;
7246 return (s1 | (s2 << 16)) |0;
7250 module.exports = adler32;
7252 },{}],29:[function(require,module,exports){
7255 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
7256 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
7258 // This software is provided 'as-is', without any express or implied
7259 // warranty. In no event will the authors be held liable for any damages
7260 // arising from the use of this software.
7262 // Permission is granted to anyone to use this software for any purpose,
7263 // including commercial applications, and to alter it and redistribute it
7264 // freely, subject to the following restrictions:
7266 // 1. The origin of this software must not be misrepresented; you must not
7267 // claim that you wrote the original software. If you use this software
7268 // in a product, an acknowledgment in the product documentation would be
7269 // appreciated but is not required.
7270 // 2. Altered source versions must be plainly marked as such, and must not be
7271 // misrepresented as being the original software.
7272 // 3. This notice may not be removed or altered from any source distribution.
7276 /* Allowed flush values; see deflate() and inflate() below for details */
7285 /* Return codes for the compression/decompression functions. Negative values
7286 * are errors, positive values are used for special but normal events.
7296 //Z_VERSION_ERROR: -6,
7298 /* compression levels */
7299 Z_NO_COMPRESSION: 0,
7301 Z_BEST_COMPRESSION: 9,
7302 Z_DEFAULT_COMPRESSION: -1,
7309 Z_DEFAULT_STRATEGY: 0,
7311 /* Possible values of the data_type field (though see inflate()) */
7314 //Z_ASCII: 1, // = Z_TEXT (deprecated)
7317 /* The deflate compression method */
7319 //Z_NULL: null // Use -1 or null inline, depending on var type
7322 },{}],30:[function(require,module,exports){
7325 // Note: we can't get significant speed boost here.
7326 // So write code to minimize size - no pregenerated tables
7327 // and array tools dependencies.
7329 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
7330 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
7332 // This software is provided 'as-is', without any express or implied
7333 // warranty. In no event will the authors be held liable for any damages
7334 // arising from the use of this software.
7336 // Permission is granted to anyone to use this software for any purpose,
7337 // including commercial applications, and to alter it and redistribute it
7338 // freely, subject to the following restrictions:
7340 // 1. The origin of this software must not be misrepresented; you must not
7341 // claim that you wrote the original software. If you use this software
7342 // in a product, an acknowledgment in the product documentation would be
7343 // appreciated but is not required.
7344 // 2. Altered source versions must be plainly marked as such, and must not be
7345 // misrepresented as being the original software.
7346 // 3. This notice may not be removed or altered from any source distribution.
7348 // Use ordinary array, since untyped makes no boost here
7349 function makeTable() {
7352 for (var n = 0; n < 256; n++) {
7354 for (var k = 0; k < 8; k++) {
7355 c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
7363 // Create table on load. Just 255 signed longs. Not a problem.
7364 var crcTable = makeTable();
7367 function crc32(crc, buf, len, pos) {
7373 for (var i = pos; i < end; i++) {
7374 crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
7377 return (crc ^ (-1)); // >>> 0;
7381 module.exports = crc32;
7383 },{}],31:[function(require,module,exports){
7386 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
7387 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
7389 // This software is provided 'as-is', without any express or implied
7390 // warranty. In no event will the authors be held liable for any damages
7391 // arising from the use of this software.
7393 // Permission is granted to anyone to use this software for any purpose,
7394 // including commercial applications, and to alter it and redistribute it
7395 // freely, subject to the following restrictions:
7397 // 1. The origin of this software must not be misrepresented; you must not
7398 // claim that you wrote the original software. If you use this software
7399 // in a product, an acknowledgment in the product documentation would be
7400 // appreciated but is not required.
7401 // 2. Altered source versions must be plainly marked as such, and must not be
7402 // misrepresented as being the original software.
7403 // 3. This notice may not be removed or altered from any source distribution.
7405 var utils = require('../utils/common');
7406 var trees = require('./trees');
7407 var adler32 = require('./adler32');
7408 var crc32 = require('./crc32');
7409 var msg = require('./messages');
7411 /* Public constants ==========================================================*/
7412 /* ===========================================================================*/
7415 /* Allowed flush values; see deflate() and inflate() below for details */
7417 var Z_PARTIAL_FLUSH = 1;
7418 //var Z_SYNC_FLUSH = 2;
7419 var Z_FULL_FLUSH = 3;
7425 /* Return codes for the compression/decompression functions. Negative values
7426 * are errors, positive values are used for special but normal events.
7429 var Z_STREAM_END = 1;
7430 //var Z_NEED_DICT = 2;
7432 var Z_STREAM_ERROR = -2;
7433 var Z_DATA_ERROR = -3;
7434 //var Z_MEM_ERROR = -4;
7435 var Z_BUF_ERROR = -5;
7436 //var Z_VERSION_ERROR = -6;
7439 /* compression levels */
7440 //var Z_NO_COMPRESSION = 0;
7441 //var Z_BEST_SPEED = 1;
7442 //var Z_BEST_COMPRESSION = 9;
7443 var Z_DEFAULT_COMPRESSION = -1;
7447 var Z_HUFFMAN_ONLY = 2;
7450 var Z_DEFAULT_STRATEGY = 0;
7452 /* Possible values of the data_type field (though see inflate()) */
7455 //var Z_ASCII = 1; // = Z_TEXT
7459 /* The deflate compression method */
7462 /*============================================================================*/
7465 var MAX_MEM_LEVEL = 9;
7466 /* Maximum value for memLevel in deflateInit2 */
7468 /* 32K LZ77 window */
7469 var DEF_MEM_LEVEL = 8;
7472 var LENGTH_CODES = 29;
7473 /* number of length codes, not counting the special END_BLOCK code */
7475 /* number of literal bytes 0..255 */
7476 var L_CODES = LITERALS + 1 + LENGTH_CODES;
7477 /* number of Literal or Length codes, including the END_BLOCK code */
7479 /* number of distance codes */
7481 /* number of codes used to transfer the bit lengths */
7482 var HEAP_SIZE = 2 * L_CODES + 1;
7483 /* maximum heap size */
7485 /* All codes must not exceed MAX_BITS bits */
7488 var MAX_MATCH = 258;
7489 var MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);
7491 var PRESET_DICT = 0x20;
7493 var INIT_STATE = 42;
7494 var EXTRA_STATE = 69;
7495 var NAME_STATE = 73;
7496 var COMMENT_STATE = 91;
7497 var HCRC_STATE = 103;
7498 var BUSY_STATE = 113;
7499 var FINISH_STATE = 666;
7501 var BS_NEED_MORE = 1; /* block not completed, need more input or more output */
7502 var BS_BLOCK_DONE = 2; /* block flush performed */
7503 var BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */
7504 var BS_FINISH_DONE = 4; /* finish done, accept no more input or output */
7506 var OS_CODE = 0x03; // Unix :) . Don't detect, use this default.
7508 function err(strm, errorCode) {
7509 strm.msg = msg[errorCode];
7514 return ((f) << 1) - ((f) > 4 ? 9 : 0);
7517 function zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }
7520 /* =========================================================================
7521 * Flush as much pending output as possible. All deflate() output goes
7522 * through this function so some applications may wish to modify it
7523 * to avoid allocating a large strm->output buffer and copying into it.
7524 * (See also read_buf()).
7526 function flush_pending(strm) {
7529 //_tr_flush_bits(s);
7530 var len = s.pending;
7531 if (len > strm.avail_out) {
7532 len = strm.avail_out;
7534 if (len === 0) { return; }
7536 utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);
7537 strm.next_out += len;
7538 s.pending_out += len;
7539 strm.total_out += len;
7540 strm.avail_out -= len;
7542 if (s.pending === 0) {
7548 function flush_block_only(s, last) {
7549 trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);
7550 s.block_start = s.strstart;
7551 flush_pending(s.strm);
7555 function put_byte(s, b) {
7556 s.pending_buf[s.pending++] = b;
7560 /* =========================================================================
7561 * Put a short in the pending buffer. The 16-bit value is put in MSB order.
7562 * IN assertion: the stream state is correct and there is enough room in
7565 function putShortMSB(s, b) {
7566 // put_byte(s, (Byte)(b >> 8));
7567 // put_byte(s, (Byte)(b & 0xff));
7568 s.pending_buf[s.pending++] = (b >>> 8) & 0xff;
7569 s.pending_buf[s.pending++] = b & 0xff;
7573 /* ===========================================================================
7574 * Read a new buffer from the current input stream, update the adler32
7575 * and total number of bytes read. All deflate() input goes through
7576 * this function so some applications may wish to modify it to avoid
7577 * allocating a large strm->input buffer and copying from it.
7578 * (See also flush_pending()).
7580 function read_buf(strm, buf, start, size) {
7581 var len = strm.avail_in;
7583 if (len > size) { len = size; }
7584 if (len === 0) { return 0; }
7586 strm.avail_in -= len;
7588 // zmemcpy(buf, strm->next_in, len);
7589 utils.arraySet(buf, strm.input, strm.next_in, len, start);
7590 if (strm.state.wrap === 1) {
7591 strm.adler = adler32(strm.adler, buf, len, start);
7594 else if (strm.state.wrap === 2) {
7595 strm.adler = crc32(strm.adler, buf, len, start);
7598 strm.next_in += len;
7599 strm.total_in += len;
7605 /* ===========================================================================
7606 * Set match_start to the longest match starting at the given string and
7607 * return its length. Matches shorter or equal to prev_length are discarded,
7608 * in which case the result is equal to prev_length and match_start is
7610 * IN assertions: cur_match is the head of the hash chain for the current
7611 * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
7612 * OUT assertion: the match length is not greater than s->lookahead.
7614 function longest_match(s, cur_match) {
7615 var chain_length = s.max_chain_length; /* max hash chain length */
7616 var scan = s.strstart; /* current string */
7617 var match; /* matched string */
7618 var len; /* length of current match */
7619 var best_len = s.prev_length; /* best match length so far */
7620 var nice_match = s.nice_match; /* stop if match long enough */
7621 var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?
7622 s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;
7624 var _win = s.window; // shortcut
7626 var wmask = s.w_mask;
7629 /* Stop when cur_match becomes <= limit. To simplify the code,
7630 * we prevent matches with the string of window index 0.
7633 var strend = s.strstart + MAX_MATCH;
7634 var scan_end1 = _win[scan + best_len - 1];
7635 var scan_end = _win[scan + best_len];
7637 /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
7638 * It is easy to get rid of this optimization if necessary.
7640 // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
7642 /* Do not waste too much time if we already have a good match: */
7643 if (s.prev_length >= s.good_match) {
7646 /* Do not look for matches beyond the end of the input. This is necessary
7647 * to make deflate deterministic.
7649 if (nice_match > s.lookahead) { nice_match = s.lookahead; }
7651 // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
7654 // Assert(cur_match < s->strstart, "no future");
7657 /* Skip to next match if the match length cannot increase
7658 * or if the match length is less than 2. Note that the checks below
7659 * for insufficient lookahead only occur occasionally for performance
7660 * reasons. Therefore uninitialized memory will be accessed, and
7661 * conditional jumps will be made that depend on those values.
7662 * However the length of the match is limited to the lookahead, so
7663 * the output of deflate is not affected by the uninitialized values.
7666 if (_win[match + best_len] !== scan_end ||
7667 _win[match + best_len - 1] !== scan_end1 ||
7668 _win[match] !== _win[scan] ||
7669 _win[++match] !== _win[scan + 1]) {
7673 /* The check at best_len-1 can be removed because it will be made
7674 * again later. (This heuristic is not always a win.)
7675 * It is not necessary to compare scan[2] and match[2] since they
7676 * are always equal when the other bytes match, given that
7677 * the hash keys are equal and that HASH_BITS >= 8.
7681 // Assert(*scan == *match, "match[2]?");
7683 /* We check for insufficient lookahead only every 8th comparison;
7684 * the 256th check will be made at strstart+258.
7687 /*jshint noempty:false*/
7688 } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&
7689 _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&
7690 _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&
7691 _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&
7694 // Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
7696 len = MAX_MATCH - (strend - scan);
7697 scan = strend - MAX_MATCH;
7699 if (len > best_len) {
7700 s.match_start = cur_match;
7702 if (len >= nice_match) {
7705 scan_end1 = _win[scan + best_len - 1];
7706 scan_end = _win[scan + best_len];
7708 } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);
7710 if (best_len <= s.lookahead) {
7717 /* ===========================================================================
7718 * Fill the window when the lookahead becomes insufficient.
7719 * Updates strstart and lookahead.
7721 * IN assertion: lookahead < MIN_LOOKAHEAD
7722 * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
7723 * At least one byte has been read, or avail_in == 0; reads are
7724 * performed for at least two bytes (required for the zip translate_eol
7725 * option -- not supported here).
7727 function fill_window(s) {
7728 var _w_size = s.w_size;
7729 var p, n, m, more, str;
7731 //Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
7734 more = s.window_size - s.lookahead - s.strstart;
7736 // JS ints have 32 bit, block below not needed
7737 /* Deal with !@#$% 64K limit: */
7738 //if (sizeof(int) <= 2) {
7739 // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
7742 // } else if (more == (unsigned)(-1)) {
7743 // /* Very unlikely, but possible on 16 bit machine if
7744 // * strstart == 0 && lookahead == 1 (input done a byte at time)
7751 /* If the window is almost full and there is insufficient lookahead,
7752 * move the upper half to the lower one to make room in the upper half.
7754 if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
7756 utils.arraySet(s.window, s.window, _w_size, _w_size, 0);
7757 s.match_start -= _w_size;
7758 s.strstart -= _w_size;
7759 /* we now have strstart >= MAX_DIST */
7760 s.block_start -= _w_size;
7762 /* Slide the hash table (could be avoided with 32 bit values
7763 at the expense of memory usage). We slide even when level == 0
7764 to keep the hash table consistent if we switch back to level > 0
7765 later. (Using level 0 permanently is not an optimal usage of
7766 zlib, so we don't care about this pathological case.)
7773 s.head[p] = (m >= _w_size ? m - _w_size : 0);
7780 s.prev[p] = (m >= _w_size ? m - _w_size : 0);
7781 /* If n is not on any hash chain, prev[n] is garbage but
7782 * its value will never be used.
7788 if (s.strm.avail_in === 0) {
7792 /* If there was no sliding:
7793 * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
7794 * more == window_size - lookahead - strstart
7795 * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
7796 * => more >= window_size - 2*WSIZE + 2
7797 * In the BIG_MEM or MMAP case (not yet supported),
7798 * window_size == input_size + MIN_LOOKAHEAD &&
7799 * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
7800 * Otherwise, window_size == 2*WSIZE so more >= 2.
7801 * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
7803 //Assert(more >= 2, "more < 2");
7804 n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
7807 /* Initialize the hash value now that we have some input: */
7808 if (s.lookahead + s.insert >= MIN_MATCH) {
7809 str = s.strstart - s.insert;
7810 s.ins_h = s.window[str];
7812 /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */
7813 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;
7814 //#if MIN_MATCH != 3
7815 // Call update_hash() MIN_MATCH-3 more times
7818 /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
7819 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
7821 s.prev[str & s.w_mask] = s.head[s.ins_h];
7822 s.head[s.ins_h] = str;
7825 if (s.lookahead + s.insert < MIN_MATCH) {
7830 /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
7831 * but this is not important since only literal bytes will be emitted.
7834 } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);
7836 /* If the WIN_INIT bytes after the end of the current data have never been
7837 * written, then zero those bytes in order to avoid memory check reports of
7838 * the use of uninitialized (or uninitialised as Julian writes) bytes by
7839 * the longest match routines. Update the high water mark for the next
7840 * time through here. WIN_INIT is set to MAX_MATCH since the longest match
7841 * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
7843 // if (s.high_water < s.window_size) {
7844 // var curr = s.strstart + s.lookahead;
7847 // if (s.high_water < curr) {
7848 // /* Previous high water mark below current data -- zero WIN_INIT
7849 // * bytes or up to end of window, whichever is less.
7851 // init = s.window_size - curr;
7852 // if (init > WIN_INIT)
7854 // zmemzero(s->window + curr, (unsigned)init);
7855 // s->high_water = curr + init;
7857 // else if (s->high_water < (ulg)curr + WIN_INIT) {
7858 // /* High water mark at or above current data, but below current data
7859 // * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
7860 // * to end of window, whichever is less.
7862 // init = (ulg)curr + WIN_INIT - s->high_water;
7863 // if (init > s->window_size - s->high_water)
7864 // init = s->window_size - s->high_water;
7865 // zmemzero(s->window + s->high_water, (unsigned)init);
7866 // s->high_water += init;
7870 // Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
7871 // "not enough room for search");
7874 /* ===========================================================================
7875 * Copy without compression as much as possible from the input stream, return
7876 * the current block state.
7877 * This function does not insert new strings in the dictionary since
7878 * uncompressible data is probably not useful. This function is used
7879 * only for the level=0 compression option.
7880 * NOTE: this function should be optimized to avoid extra copying from
7881 * window to pending_buf.
7883 function deflate_stored(s, flush) {
7884 /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
7885 * to pending_buf_size, and each stored block has a 5 byte header:
7887 var max_block_size = 0xffff;
7889 if (max_block_size > s.pending_buf_size - 5) {
7890 max_block_size = s.pending_buf_size - 5;
7893 /* Copy as much as possible from input to output: */
7895 /* Fill the window as much as possible: */
7896 if (s.lookahead <= 1) {
7898 //Assert(s->strstart < s->w_size+MAX_DIST(s) ||
7899 // s->block_start >= (long)s->w_size, "slide too late");
7900 // if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||
7901 // s.block_start >= s.w_size)) {
7902 // throw new Error("slide too late");
7906 if (s.lookahead === 0 && flush === Z_NO_FLUSH) {
7907 return BS_NEED_MORE;
7910 if (s.lookahead === 0) {
7913 /* flush the current block */
7915 //Assert(s->block_start >= 0L, "block gone");
7916 // if (s.block_start < 0) throw new Error("block gone");
7918 s.strstart += s.lookahead;
7921 /* Emit a stored block if pending_buf will be full: */
7922 var max_start = s.block_start + max_block_size;
7924 if (s.strstart === 0 || s.strstart >= max_start) {
7925 /* strstart == 0 is possible when wraparound on 16-bit machine */
7926 s.lookahead = s.strstart - max_start;
7927 s.strstart = max_start;
7928 /*** FLUSH_BLOCK(s, 0); ***/
7929 flush_block_only(s, false);
7930 if (s.strm.avail_out === 0) {
7931 return BS_NEED_MORE;
7937 /* Flush if we may have to slide, otherwise block_start may become
7938 * negative and the data will be gone:
7940 if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {
7941 /*** FLUSH_BLOCK(s, 0); ***/
7942 flush_block_only(s, false);
7943 if (s.strm.avail_out === 0) {
7944 return BS_NEED_MORE;
7952 if (flush === Z_FINISH) {
7953 /*** FLUSH_BLOCK(s, 1); ***/
7954 flush_block_only(s, true);
7955 if (s.strm.avail_out === 0) {
7956 return BS_FINISH_STARTED;
7959 return BS_FINISH_DONE;
7962 if (s.strstart > s.block_start) {
7963 /*** FLUSH_BLOCK(s, 0); ***/
7964 flush_block_only(s, false);
7965 if (s.strm.avail_out === 0) {
7966 return BS_NEED_MORE;
7971 return BS_NEED_MORE;
7974 /* ===========================================================================
7975 * Compress as much as possible from the input stream, return the current
7977 * This function does not perform lazy evaluation of matches and inserts
7978 * new strings in the dictionary only for unmatched strings or for short
7979 * matches. It is used only for the fast compression options.
7981 function deflate_fast(s, flush) {
7982 var hash_head; /* head of the hash chain */
7983 var bflush; /* set if current block must be flushed */
7986 /* Make sure that we always have enough lookahead, except
7987 * at the end of the input file. We need MAX_MATCH bytes
7988 * for the next match, plus MIN_MATCH bytes to insert the
7989 * string following the next match.
7991 if (s.lookahead < MIN_LOOKAHEAD) {
7993 if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
7994 return BS_NEED_MORE;
7996 if (s.lookahead === 0) {
7997 break; /* flush the current block */
8001 /* Insert the string window[strstart .. strstart+2] in the
8002 * dictionary, and set hash_head to the head of the hash chain:
8004 hash_head = 0/*NIL*/;
8005 if (s.lookahead >= MIN_MATCH) {
8006 /*** INSERT_STRING(s, s.strstart, hash_head); ***/
8007 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
8008 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
8009 s.head[s.ins_h] = s.strstart;
8013 /* Find the longest match, discarding those <= prev_length.
8014 * At this point we have always match_length < MIN_MATCH
8016 if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {
8017 /* To simplify the code, we prevent matches with the string
8018 * of window index 0 (in particular we have to avoid a match
8019 * of the string with itself at the start of the input file).
8021 s.match_length = longest_match(s, hash_head);
8022 /* longest_match() sets match_start */
8024 if (s.match_length >= MIN_MATCH) {
8025 // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only
8027 /*** _tr_tally_dist(s, s.strstart - s.match_start,
8028 s.match_length - MIN_MATCH, bflush); ***/
8029 bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);
8031 s.lookahead -= s.match_length;
8033 /* Insert new strings in the hash table only if the match length
8034 * is not too large. This saves time but degrades compression.
8036 if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {
8037 s.match_length--; /* string at strstart already in table */
8040 /*** INSERT_STRING(s, s.strstart, hash_head); ***/
8041 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
8042 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
8043 s.head[s.ins_h] = s.strstart;
8045 /* strstart never exceeds WSIZE-MAX_MATCH, so there are
8046 * always MIN_MATCH bytes ahead.
8048 } while (--s.match_length !== 0);
8052 s.strstart += s.match_length;
8054 s.ins_h = s.window[s.strstart];
8055 /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */
8056 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;
8058 //#if MIN_MATCH != 3
8059 // Call UPDATE_HASH() MIN_MATCH-3 more times
8061 /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
8062 * matter since it will be recomputed at next deflate call.
8066 /* No match, output a literal byte */
8067 //Tracevv((stderr,"%c", s.window[s.strstart]));
8068 /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
8069 bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
8075 /*** FLUSH_BLOCK(s, 0); ***/
8076 flush_block_only(s, false);
8077 if (s.strm.avail_out === 0) {
8078 return BS_NEED_MORE;
8083 s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);
8084 if (flush === Z_FINISH) {
8085 /*** FLUSH_BLOCK(s, 1); ***/
8086 flush_block_only(s, true);
8087 if (s.strm.avail_out === 0) {
8088 return BS_FINISH_STARTED;
8091 return BS_FINISH_DONE;
8094 /*** FLUSH_BLOCK(s, 0); ***/
8095 flush_block_only(s, false);
8096 if (s.strm.avail_out === 0) {
8097 return BS_NEED_MORE;
8101 return BS_BLOCK_DONE;
8104 /* ===========================================================================
8105 * Same as above, but achieves better compression. We use a lazy
8106 * evaluation for matches: a match is finally adopted only if there is
8107 * no better match at the next window position.
8109 function deflate_slow(s, flush) {
8110 var hash_head; /* head of hash chain */
8111 var bflush; /* set if current block must be flushed */
8115 /* Process the input block. */
8117 /* Make sure that we always have enough lookahead, except
8118 * at the end of the input file. We need MAX_MATCH bytes
8119 * for the next match, plus MIN_MATCH bytes to insert the
8120 * string following the next match.
8122 if (s.lookahead < MIN_LOOKAHEAD) {
8124 if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
8125 return BS_NEED_MORE;
8127 if (s.lookahead === 0) { break; } /* flush the current block */
8130 /* Insert the string window[strstart .. strstart+2] in the
8131 * dictionary, and set hash_head to the head of the hash chain:
8133 hash_head = 0/*NIL*/;
8134 if (s.lookahead >= MIN_MATCH) {
8135 /*** INSERT_STRING(s, s.strstart, hash_head); ***/
8136 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
8137 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
8138 s.head[s.ins_h] = s.strstart;
8142 /* Find the longest match, discarding those <= prev_length.
8144 s.prev_length = s.match_length;
8145 s.prev_match = s.match_start;
8146 s.match_length = MIN_MATCH - 1;
8148 if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&
8149 s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {
8150 /* To simplify the code, we prevent matches with the string
8151 * of window index 0 (in particular we have to avoid a match
8152 * of the string with itself at the start of the input file).
8154 s.match_length = longest_match(s, hash_head);
8155 /* longest_match() sets match_start */
8157 if (s.match_length <= 5 &&
8158 (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {
8160 /* If prev_match is also MIN_MATCH, match_start is garbage
8161 * but we will ignore the current match anyway.
8163 s.match_length = MIN_MATCH - 1;
8166 /* If there was a match at the previous step and the current
8167 * match is not better, output the previous match:
8169 if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {
8170 max_insert = s.strstart + s.lookahead - MIN_MATCH;
8171 /* Do not insert strings in hash table beyond this. */
8173 //check_match(s, s.strstart-1, s.prev_match, s.prev_length);
8175 /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,
8176 s.prev_length - MIN_MATCH, bflush);***/
8177 bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);
8178 /* Insert in hash table all strings up to the end of the match.
8179 * strstart-1 and strstart are already inserted. If there is not
8180 * enough lookahead, the last two strings are not inserted in
8183 s.lookahead -= s.prev_length - 1;
8186 if (++s.strstart <= max_insert) {
8187 /*** INSERT_STRING(s, s.strstart, hash_head); ***/
8188 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
8189 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
8190 s.head[s.ins_h] = s.strstart;
8193 } while (--s.prev_length !== 0);
8194 s.match_available = 0;
8195 s.match_length = MIN_MATCH - 1;
8199 /*** FLUSH_BLOCK(s, 0); ***/
8200 flush_block_only(s, false);
8201 if (s.strm.avail_out === 0) {
8202 return BS_NEED_MORE;
8207 } else if (s.match_available) {
8208 /* If there was no match at the previous position, output a
8209 * single literal. If there was a match but the current match
8210 * is longer, truncate the previous match to a single literal.
8212 //Tracevv((stderr,"%c", s->window[s->strstart-1]));
8213 /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
8214 bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
8217 /*** FLUSH_BLOCK_ONLY(s, 0) ***/
8218 flush_block_only(s, false);
8223 if (s.strm.avail_out === 0) {
8224 return BS_NEED_MORE;
8227 /* There is no previous match to compare with, wait for
8228 * the next step to decide.
8230 s.match_available = 1;
8235 //Assert (flush != Z_NO_FLUSH, "no flush?");
8236 if (s.match_available) {
8237 //Tracevv((stderr,"%c", s->window[s->strstart-1]));
8238 /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
8239 bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
8241 s.match_available = 0;
8243 s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
8244 if (flush === Z_FINISH) {
8245 /*** FLUSH_BLOCK(s, 1); ***/
8246 flush_block_only(s, true);
8247 if (s.strm.avail_out === 0) {
8248 return BS_FINISH_STARTED;
8251 return BS_FINISH_DONE;
8254 /*** FLUSH_BLOCK(s, 0); ***/
8255 flush_block_only(s, false);
8256 if (s.strm.avail_out === 0) {
8257 return BS_NEED_MORE;
8262 return BS_BLOCK_DONE;
8266 /* ===========================================================================
8267 * For Z_RLE, simply look for runs of bytes, generate matches only of distance
8268 * one. Do not maintain a hash table. (It will be regenerated if this run of
8269 * deflate switches away from Z_RLE.)
8271 function deflate_rle(s, flush) {
8272 var bflush; /* set if current block must be flushed */
8273 var prev; /* byte at distance one to match */
8274 var scan, strend; /* scan goes up to strend for length of run */
8276 var _win = s.window;
8279 /* Make sure that we always have enough lookahead, except
8280 * at the end of the input file. We need MAX_MATCH bytes
8281 * for the longest run, plus one for the unrolled loop.
8283 if (s.lookahead <= MAX_MATCH) {
8285 if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {
8286 return BS_NEED_MORE;
8288 if (s.lookahead === 0) { break; } /* flush the current block */
8291 /* See how many times the previous byte repeats */
8293 if (s.lookahead >= MIN_MATCH && s.strstart > 0) {
8294 scan = s.strstart - 1;
8296 if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {
8297 strend = s.strstart + MAX_MATCH;
8299 /*jshint noempty:false*/
8300 } while (prev === _win[++scan] && prev === _win[++scan] &&
8301 prev === _win[++scan] && prev === _win[++scan] &&
8302 prev === _win[++scan] && prev === _win[++scan] &&
8303 prev === _win[++scan] && prev === _win[++scan] &&
8305 s.match_length = MAX_MATCH - (strend - scan);
8306 if (s.match_length > s.lookahead) {
8307 s.match_length = s.lookahead;
8310 //Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
8313 /* Emit match if have run of MIN_MATCH or longer, else emit literal */
8314 if (s.match_length >= MIN_MATCH) {
8315 //check_match(s, s.strstart, s.strstart - 1, s.match_length);
8317 /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/
8318 bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);
8320 s.lookahead -= s.match_length;
8321 s.strstart += s.match_length;
8324 /* No match, output a literal byte */
8325 //Tracevv((stderr,"%c", s->window[s->strstart]));
8326 /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
8327 bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
8333 /*** FLUSH_BLOCK(s, 0); ***/
8334 flush_block_only(s, false);
8335 if (s.strm.avail_out === 0) {
8336 return BS_NEED_MORE;
8342 if (flush === Z_FINISH) {
8343 /*** FLUSH_BLOCK(s, 1); ***/
8344 flush_block_only(s, true);
8345 if (s.strm.avail_out === 0) {
8346 return BS_FINISH_STARTED;
8349 return BS_FINISH_DONE;
8352 /*** FLUSH_BLOCK(s, 0); ***/
8353 flush_block_only(s, false);
8354 if (s.strm.avail_out === 0) {
8355 return BS_NEED_MORE;
8359 return BS_BLOCK_DONE;
8362 /* ===========================================================================
8363 * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
8364 * (It will be regenerated if this run of deflate switches away from Huffman.)
8366 function deflate_huff(s, flush) {
8367 var bflush; /* set if current block must be flushed */
8370 /* Make sure that we have a literal to write. */
8371 if (s.lookahead === 0) {
8373 if (s.lookahead === 0) {
8374 if (flush === Z_NO_FLUSH) {
8375 return BS_NEED_MORE;
8377 break; /* flush the current block */
8381 /* Output a literal byte */
8383 //Tracevv((stderr,"%c", s->window[s->strstart]));
8384 /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
8385 bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
8389 /*** FLUSH_BLOCK(s, 0); ***/
8390 flush_block_only(s, false);
8391 if (s.strm.avail_out === 0) {
8392 return BS_NEED_MORE;
8398 if (flush === Z_FINISH) {
8399 /*** FLUSH_BLOCK(s, 1); ***/
8400 flush_block_only(s, true);
8401 if (s.strm.avail_out === 0) {
8402 return BS_FINISH_STARTED;
8405 return BS_FINISH_DONE;
8408 /*** FLUSH_BLOCK(s, 0); ***/
8409 flush_block_only(s, false);
8410 if (s.strm.avail_out === 0) {
8411 return BS_NEED_MORE;
8415 return BS_BLOCK_DONE;
8418 /* Values for max_lazy_match, good_match and max_chain_length, depending on
8419 * the desired pack level (0..9). The values given below have been tuned to
8420 * exclude worst case performance for pathological files. Better values may be
8421 * found for specific files.
8423 function Config(good_length, max_lazy, nice_length, max_chain, func) {
8424 this.good_length = good_length;
8425 this.max_lazy = max_lazy;
8426 this.nice_length = nice_length;
8427 this.max_chain = max_chain;
8431 var configuration_table;
8433 configuration_table = [
8434 /* good lazy nice chain */
8435 new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */
8436 new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */
8437 new Config(4, 5, 16, 8, deflate_fast), /* 2 */
8438 new Config(4, 6, 32, 32, deflate_fast), /* 3 */
8440 new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */
8441 new Config(8, 16, 32, 32, deflate_slow), /* 5 */
8442 new Config(8, 16, 128, 128, deflate_slow), /* 6 */
8443 new Config(8, 32, 128, 256, deflate_slow), /* 7 */
8444 new Config(32, 128, 258, 1024, deflate_slow), /* 8 */
8445 new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */
8449 /* ===========================================================================
8450 * Initialize the "longest match" routines for a new zlib stream
8452 function lm_init(s) {
8453 s.window_size = 2 * s.w_size;
8455 /*** CLEAR_HASH(s); ***/
8456 zero(s.head); // Fill with NIL (= 0);
8458 /* Set the default configuration parameters:
8460 s.max_lazy_match = configuration_table[s.level].max_lazy;
8461 s.good_match = configuration_table[s.level].good_length;
8462 s.nice_match = configuration_table[s.level].nice_length;
8463 s.max_chain_length = configuration_table[s.level].max_chain;
8469 s.match_length = s.prev_length = MIN_MATCH - 1;
8470 s.match_available = 0;
8475 function DeflateState() {
8476 this.strm = null; /* pointer back to this zlib stream */
8477 this.status = 0; /* as the name implies */
8478 this.pending_buf = null; /* output still pending */
8479 this.pending_buf_size = 0; /* size of pending_buf */
8480 this.pending_out = 0; /* next pending byte to output to the stream */
8481 this.pending = 0; /* nb of bytes in the pending buffer */
8482 this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
8483 this.gzhead = null; /* gzip header information to write */
8484 this.gzindex = 0; /* where in extra, name, or comment */
8485 this.method = Z_DEFLATED; /* can only be DEFLATED */
8486 this.last_flush = -1; /* value of flush param for previous deflate call */
8488 this.w_size = 0; /* LZ77 window size (32K by default) */
8489 this.w_bits = 0; /* log2(w_size) (8..16) */
8490 this.w_mask = 0; /* w_size - 1 */
8493 /* Sliding window. Input bytes are read into the second half of the window,
8494 * and move to the first half later to keep a dictionary of at least wSize
8495 * bytes. With this organization, matches are limited to a distance of
8496 * wSize-MAX_MATCH bytes, but this ensures that IO is always
8497 * performed with a length multiple of the block size.
8500 this.window_size = 0;
8501 /* Actual size of window: 2*wSize, except when the user input buffer
8502 * is directly used as sliding window.
8506 /* Link to older string with same hash index. To limit the size of this
8507 * array to 64K, this link is maintained only for the last 32K strings.
8508 * An index in this array is thus a window index modulo 32K.
8511 this.head = null; /* Heads of the hash chains or NIL. */
8513 this.ins_h = 0; /* hash index of string to be inserted */
8514 this.hash_size = 0; /* number of elements in hash table */
8515 this.hash_bits = 0; /* log2(hash_size) */
8516 this.hash_mask = 0; /* hash_size-1 */
8518 this.hash_shift = 0;
8519 /* Number of bits by which ins_h must be shifted at each input
8520 * step. It must be such that after MIN_MATCH steps, the oldest
8521 * byte no longer takes part in the hash key, that is:
8522 * hash_shift * MIN_MATCH >= hash_bits
8525 this.block_start = 0;
8526 /* Window position at the beginning of the current output block. Gets
8527 * negative when the window is moved backwards.
8530 this.match_length = 0; /* length of best match */
8531 this.prev_match = 0; /* previous match */
8532 this.match_available = 0; /* set if previous match exists */
8533 this.strstart = 0; /* start of string to insert */
8534 this.match_start = 0; /* start of matching string */
8535 this.lookahead = 0; /* number of valid bytes ahead in window */
8537 this.prev_length = 0;
8538 /* Length of the best match at previous step. Matches not greater than this
8539 * are discarded. This is used in the lazy match evaluation.
8542 this.max_chain_length = 0;
8543 /* To speed up deflation, hash chains are never searched beyond this
8544 * length. A higher limit improves compression ratio but degrades the
8548 this.max_lazy_match = 0;
8549 /* Attempt to find a better match only when the current match is strictly
8550 * smaller than this value. This mechanism is used only for compression
8553 // That's alias to max_lazy_match, don't use directly
8554 //this.max_insert_length = 0;
8555 /* Insert new strings in the hash table only if the match length is not
8556 * greater than this length. This saves time but degrades compression.
8557 * max_insert_length is used only for compression levels <= 3.
8560 this.level = 0; /* compression level (1..9) */
8561 this.strategy = 0; /* favor or force Huffman coding*/
8563 this.good_match = 0;
8564 /* Use a faster search when the previous match is longer than this */
8566 this.nice_match = 0; /* Stop searching when current match exceeds this */
8568 /* used by trees.c: */
8570 /* Didn't use ct_data typedef below to suppress compiler warning */
8572 // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
8573 // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
8574 // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
8576 // Use flat array of DOUBLE size, with interleaved fata,
8577 // because JS does not support effective
8578 this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);
8579 this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);
8580 this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);
8581 zero(this.dyn_ltree);
8582 zero(this.dyn_dtree);
8585 this.l_desc = null; /* desc. for literal tree */
8586 this.d_desc = null; /* desc. for distance tree */
8587 this.bl_desc = null; /* desc. for bit length tree */
8589 //ush bl_count[MAX_BITS+1];
8590 this.bl_count = new utils.Buf16(MAX_BITS + 1);
8591 /* number of codes at each bit length for an optimal tree */
8593 //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
8594 this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */
8597 this.heap_len = 0; /* number of elements in the heap */
8598 this.heap_max = 0; /* element of largest frequency */
8599 /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
8600 * The same heap array is used to build all trees.
8603 this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];
8605 /* Depth of each subtree used as tie breaker for trees of equal frequency
8608 this.l_buf = 0; /* buffer index for literals or lengths */
8610 this.lit_bufsize = 0;
8611 /* Size of match buffer for literals/lengths. There are 4 reasons for
8612 * limiting lit_bufsize to 64K:
8613 * - frequencies can be kept in 16 bit counters
8614 * - if compression is not successful for the first block, all input
8615 * data is still in the window so we can still emit a stored block even
8616 * when input comes from standard input. (This can also be done for
8617 * all blocks if lit_bufsize is not greater than 32K.)
8618 * - if compression is not successful for a file smaller than 64K, we can
8619 * even emit a stored file instead of a stored block (saving 5 bytes).
8620 * This is applicable only for zip (not gzip or zlib).
8621 * - creating new Huffman trees less frequently may not provide fast
8622 * adaptation to changes in the input data statistics. (Take for
8623 * example a binary file with poorly compressible code followed by
8624 * a highly compressible string table.) Smaller buffer sizes give
8625 * fast adaptation but have of course the overhead of transmitting
8626 * trees more frequently.
8627 * - I can't count above 4
8630 this.last_lit = 0; /* running index in l_buf */
8633 /* Buffer index for distances. To simplify the code, d_buf and l_buf have
8634 * the same number of elements. To use different lengths, an extra flag
8635 * array would be necessary.
8638 this.opt_len = 0; /* bit length of current block with optimal trees */
8639 this.static_len = 0; /* bit length of current block with static trees */
8640 this.matches = 0; /* number of string matches in current block */
8641 this.insert = 0; /* bytes at end of window left to insert */
8645 /* Output buffer. bits are inserted starting at the bottom (least
8646 * significant bits).
8649 /* Number of valid bits in bi_buf. All bits above the last valid bit
8653 // Used for window memory init. We safely ignore it for JS. That makes
8654 // sense only for pointers and memory check tools.
8655 //this.high_water = 0;
8656 /* High water mark offset in window for initialized bytes -- bytes above
8657 * this are set to zero in order to avoid memory check warnings when
8658 * longest match routines access bytes past the input. This is then
8659 * updated to the new high water mark.
8664 function deflateResetKeep(strm) {
8667 if (!strm || !strm.state) {
8668 return err(strm, Z_STREAM_ERROR);
8671 strm.total_in = strm.total_out = 0;
8672 strm.data_type = Z_UNKNOWN;
8680 /* was made negative by deflate(..., Z_FINISH); */
8682 s.status = (s.wrap ? INIT_STATE : BUSY_STATE);
8683 strm.adler = (s.wrap === 2) ?
8684 0 // crc32(0, Z_NULL, 0)
8686 1; // adler32(0, Z_NULL, 0)
8687 s.last_flush = Z_NO_FLUSH;
8693 function deflateReset(strm) {
8694 var ret = deflateResetKeep(strm);
8696 lm_init(strm.state);
8702 function deflateSetHeader(strm, head) {
8703 if (!strm || !strm.state) { return Z_STREAM_ERROR; }
8704 if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; }
8705 strm.state.gzhead = head;
8710 function deflateInit2(strm, level, method, windowBits, memLevel, strategy) {
8711 if (!strm) { // === Z_NULL
8712 return Z_STREAM_ERROR;
8716 if (level === Z_DEFAULT_COMPRESSION) {
8720 if (windowBits < 0) { /* suppress zlib wrapper */
8722 windowBits = -windowBits;
8725 else if (windowBits > 15) {
8726 wrap = 2; /* write gzip wrapper instead */
8731 if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED ||
8732 windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
8733 strategy < 0 || strategy > Z_FIXED) {
8734 return err(strm, Z_STREAM_ERROR);
8738 if (windowBits === 8) {
8741 /* until 256-byte window bug fixed */
8743 var s = new DeflateState();
8750 s.w_bits = windowBits;
8751 s.w_size = 1 << s.w_bits;
8752 s.w_mask = s.w_size - 1;
8754 s.hash_bits = memLevel + 7;
8755 s.hash_size = 1 << s.hash_bits;
8756 s.hash_mask = s.hash_size - 1;
8757 s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);
8759 s.window = new utils.Buf8(s.w_size * 2);
8760 s.head = new utils.Buf16(s.hash_size);
8761 s.prev = new utils.Buf16(s.w_size);
8763 // Don't need mem init magic for JS.
8764 //s.high_water = 0; /* nothing written to s->window yet */
8766 s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
8768 s.pending_buf_size = s.lit_bufsize * 4;
8770 //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
8771 //s->pending_buf = (uchf *) overlay;
8772 s.pending_buf = new utils.Buf8(s.pending_buf_size);
8774 // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)
8775 //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
8776 s.d_buf = 1 * s.lit_bufsize;
8778 //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
8779 s.l_buf = (1 + 2) * s.lit_bufsize;
8782 s.strategy = strategy;
8785 return deflateReset(strm);
8788 function deflateInit(strm, level) {
8789 return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
8793 function deflate(strm, flush) {
8795 var beg, val; // for gzip header write only
8797 if (!strm || !strm.state ||
8798 flush > Z_BLOCK || flush < 0) {
8799 return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;
8805 (!strm.input && strm.avail_in !== 0) ||
8806 (s.status === FINISH_STATE && flush !== Z_FINISH)) {
8807 return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR);
8810 s.strm = strm; /* just in case */
8811 old_flush = s.last_flush;
8812 s.last_flush = flush;
8814 /* Write the header */
8815 if (s.status === INIT_STATE) {
8817 if (s.wrap === 2) { // GZIP header
8818 strm.adler = 0; //crc32(0L, Z_NULL, 0);
8822 if (!s.gzhead) { // s->gzhead == Z_NULL
8828 put_byte(s, s.level === 9 ? 2 :
8829 (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?
8831 put_byte(s, OS_CODE);
8832 s.status = BUSY_STATE;
8835 put_byte(s, (s.gzhead.text ? 1 : 0) +
8836 (s.gzhead.hcrc ? 2 : 0) +
8837 (!s.gzhead.extra ? 0 : 4) +
8838 (!s.gzhead.name ? 0 : 8) +
8839 (!s.gzhead.comment ? 0 : 16)
8841 put_byte(s, s.gzhead.time & 0xff);
8842 put_byte(s, (s.gzhead.time >> 8) & 0xff);
8843 put_byte(s, (s.gzhead.time >> 16) & 0xff);
8844 put_byte(s, (s.gzhead.time >> 24) & 0xff);
8845 put_byte(s, s.level === 9 ? 2 :
8846 (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?
8848 put_byte(s, s.gzhead.os & 0xff);
8849 if (s.gzhead.extra && s.gzhead.extra.length) {
8850 put_byte(s, s.gzhead.extra.length & 0xff);
8851 put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);
8853 if (s.gzhead.hcrc) {
8854 strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);
8857 s.status = EXTRA_STATE;
8860 else // DEFLATE header
8862 var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;
8863 var level_flags = -1;
8865 if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {
8867 } else if (s.level < 6) {
8869 } else if (s.level === 6) {
8874 header |= (level_flags << 6);
8875 if (s.strstart !== 0) { header |= PRESET_DICT; }
8876 header += 31 - (header % 31);
8878 s.status = BUSY_STATE;
8879 putShortMSB(s, header);
8881 /* Save the adler32 of the preset dictionary: */
8882 if (s.strstart !== 0) {
8883 putShortMSB(s, strm.adler >>> 16);
8884 putShortMSB(s, strm.adler & 0xffff);
8886 strm.adler = 1; // adler32(0L, Z_NULL, 0);
8891 if (s.status === EXTRA_STATE) {
8892 if (s.gzhead.extra/* != Z_NULL*/) {
8893 beg = s.pending; /* start of bytes to update crc */
8895 while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {
8896 if (s.pending === s.pending_buf_size) {
8897 if (s.gzhead.hcrc && s.pending > beg) {
8898 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
8900 flush_pending(strm);
8902 if (s.pending === s.pending_buf_size) {
8906 put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);
8909 if (s.gzhead.hcrc && s.pending > beg) {
8910 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
8912 if (s.gzindex === s.gzhead.extra.length) {
8914 s.status = NAME_STATE;
8918 s.status = NAME_STATE;
8921 if (s.status === NAME_STATE) {
8922 if (s.gzhead.name/* != Z_NULL*/) {
8923 beg = s.pending; /* start of bytes to update crc */
8927 if (s.pending === s.pending_buf_size) {
8928 if (s.gzhead.hcrc && s.pending > beg) {
8929 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
8931 flush_pending(strm);
8933 if (s.pending === s.pending_buf_size) {
8938 // JS specific: little magic to add zero terminator to end of string
8939 if (s.gzindex < s.gzhead.name.length) {
8940 val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;
8945 } while (val !== 0);
8947 if (s.gzhead.hcrc && s.pending > beg) {
8948 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
8952 s.status = COMMENT_STATE;
8956 s.status = COMMENT_STATE;
8959 if (s.status === COMMENT_STATE) {
8960 if (s.gzhead.comment/* != Z_NULL*/) {
8961 beg = s.pending; /* start of bytes to update crc */
8965 if (s.pending === s.pending_buf_size) {
8966 if (s.gzhead.hcrc && s.pending > beg) {
8967 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
8969 flush_pending(strm);
8971 if (s.pending === s.pending_buf_size) {
8976 // JS specific: little magic to add zero terminator to end of string
8977 if (s.gzindex < s.gzhead.comment.length) {
8978 val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;
8983 } while (val !== 0);
8985 if (s.gzhead.hcrc && s.pending > beg) {
8986 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
8989 s.status = HCRC_STATE;
8993 s.status = HCRC_STATE;
8996 if (s.status === HCRC_STATE) {
8997 if (s.gzhead.hcrc) {
8998 if (s.pending + 2 > s.pending_buf_size) {
8999 flush_pending(strm);
9001 if (s.pending + 2 <= s.pending_buf_size) {
9002 put_byte(s, strm.adler & 0xff);
9003 put_byte(s, (strm.adler >> 8) & 0xff);
9004 strm.adler = 0; //crc32(0L, Z_NULL, 0);
9005 s.status = BUSY_STATE;
9009 s.status = BUSY_STATE;
9014 /* Flush as much pending output as possible */
9015 if (s.pending !== 0) {
9016 flush_pending(strm);
9017 if (strm.avail_out === 0) {
9018 /* Since avail_out is 0, deflate will be called again with
9019 * more output space, but possibly with both pending and
9020 * avail_in equal to zero. There won't be anything to do,
9021 * but this is not an error situation so make sure we
9022 * return OK instead of BUF_ERROR at next call of deflate:
9028 /* Make sure there is something to do and avoid duplicate consecutive
9029 * flushes. For repeated and useless calls with Z_FINISH, we keep
9030 * returning Z_STREAM_END instead of Z_BUF_ERROR.
9032 } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&
9033 flush !== Z_FINISH) {
9034 return err(strm, Z_BUF_ERROR);
9037 /* User must not provide more input after the first FINISH: */
9038 if (s.status === FINISH_STATE && strm.avail_in !== 0) {
9039 return err(strm, Z_BUF_ERROR);
9042 /* Start a new block or continue the current one.
9044 if (strm.avail_in !== 0 || s.lookahead !== 0 ||
9045 (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {
9046 var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :
9047 (s.strategy === Z_RLE ? deflate_rle(s, flush) :
9048 configuration_table[s.level].func(s, flush));
9050 if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {
9051 s.status = FINISH_STATE;
9053 if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {
9054 if (strm.avail_out === 0) {
9056 /* avoid BUF_ERROR next call, see above */
9059 /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
9060 * of deflate should use the same flush parameter to make sure
9061 * that the flush is complete. So we don't have to output an
9062 * empty block here, this will be done at next call. This also
9063 * ensures that for a very small output buffer, we emit at most
9067 if (bstate === BS_BLOCK_DONE) {
9068 if (flush === Z_PARTIAL_FLUSH) {
9071 else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
9073 trees._tr_stored_block(s, 0, 0, false);
9074 /* For a full flush, this empty block will be recognized
9075 * as a special marker by inflate_sync().
9077 if (flush === Z_FULL_FLUSH) {
9078 /*** CLEAR_HASH(s); ***/ /* forget history */
9079 zero(s.head); // Fill with NIL (= 0);
9081 if (s.lookahead === 0) {
9088 flush_pending(strm);
9089 if (strm.avail_out === 0) {
9090 s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */
9095 //Assert(strm->avail_out > 0, "bug2");
9096 //if (strm.avail_out <= 0) { throw new Error("bug2");}
9098 if (flush !== Z_FINISH) { return Z_OK; }
9099 if (s.wrap <= 0) { return Z_STREAM_END; }
9101 /* Write the trailer */
9103 put_byte(s, strm.adler & 0xff);
9104 put_byte(s, (strm.adler >> 8) & 0xff);
9105 put_byte(s, (strm.adler >> 16) & 0xff);
9106 put_byte(s, (strm.adler >> 24) & 0xff);
9107 put_byte(s, strm.total_in & 0xff);
9108 put_byte(s, (strm.total_in >> 8) & 0xff);
9109 put_byte(s, (strm.total_in >> 16) & 0xff);
9110 put_byte(s, (strm.total_in >> 24) & 0xff);
9114 putShortMSB(s, strm.adler >>> 16);
9115 putShortMSB(s, strm.adler & 0xffff);
9118 flush_pending(strm);
9119 /* If avail_out is zero, the application will call deflate again
9120 * to flush the rest.
9122 if (s.wrap > 0) { s.wrap = -s.wrap; }
9123 /* write the trailer only once! */
9124 return s.pending !== 0 ? Z_OK : Z_STREAM_END;
9127 function deflateEnd(strm) {
9130 if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {
9131 return Z_STREAM_ERROR;
9134 status = strm.state.status;
9135 if (status !== INIT_STATE &&
9136 status !== EXTRA_STATE &&
9137 status !== NAME_STATE &&
9138 status !== COMMENT_STATE &&
9139 status !== HCRC_STATE &&
9140 status !== BUSY_STATE &&
9141 status !== FINISH_STATE
9143 return err(strm, Z_STREAM_ERROR);
9148 return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;
9152 /* =========================================================================
9153 * Initializes the compression dictionary from the given byte
9154 * sequence without producing any compressed output.
9156 function deflateSetDictionary(strm, dictionary) {
9157 var dictLength = dictionary.length;
9167 if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {
9168 return Z_STREAM_ERROR;
9174 if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {
9175 return Z_STREAM_ERROR;
9178 /* when using zlib wrappers, compute Adler-32 for provided dictionary */
9180 /* adler32(strm->adler, dictionary, dictLength); */
9181 strm.adler = adler32(strm.adler, dictionary, dictLength, 0);
9184 s.wrap = 0; /* avoid computing Adler-32 in read_buf */
9186 /* if dictionary would fill window, just replace the history */
9187 if (dictLength >= s.w_size) {
9188 if (wrap === 0) { /* already empty otherwise */
9189 /*** CLEAR_HASH(s); ***/
9190 zero(s.head); // Fill with NIL (= 0);
9196 // dictionary = dictionary.slice(dictLength - s.w_size);
9197 tmpDict = new utils.Buf8(s.w_size);
9198 utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);
9199 dictionary = tmpDict;
9200 dictLength = s.w_size;
9202 /* insert dictionary into window and hash */
9203 avail = strm.avail_in;
9204 next = strm.next_in;
9206 strm.avail_in = dictLength;
9208 strm.input = dictionary;
9210 while (s.lookahead >= MIN_MATCH) {
9212 n = s.lookahead - (MIN_MATCH - 1);
9214 /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
9215 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
9217 s.prev[str & s.w_mask] = s.head[s.ins_h];
9219 s.head[s.ins_h] = str;
9223 s.lookahead = MIN_MATCH - 1;
9226 s.strstart += s.lookahead;
9227 s.block_start = s.strstart;
9228 s.insert = s.lookahead;
9230 s.match_length = s.prev_length = MIN_MATCH - 1;
9231 s.match_available = 0;
9232 strm.next_in = next;
9234 strm.avail_in = avail;
9240 exports.deflateInit = deflateInit;
9241 exports.deflateInit2 = deflateInit2;
9242 exports.deflateReset = deflateReset;
9243 exports.deflateResetKeep = deflateResetKeep;
9244 exports.deflateSetHeader = deflateSetHeader;
9245 exports.deflate = deflate;
9246 exports.deflateEnd = deflateEnd;
9247 exports.deflateSetDictionary = deflateSetDictionary;
9248 exports.deflateInfo = 'pako deflate (from Nodeca project)';
9251 exports.deflateBound = deflateBound;
9252 exports.deflateCopy = deflateCopy;
9253 exports.deflateParams = deflateParams;
9254 exports.deflatePending = deflatePending;
9255 exports.deflatePrime = deflatePrime;
9256 exports.deflateTune = deflateTune;
9259 },{"../utils/common":26,"./adler32":28,"./crc32":30,"./messages":36,"./trees":37}],32:[function(require,module,exports){
9262 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
9263 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
9265 // This software is provided 'as-is', without any express or implied
9266 // warranty. In no event will the authors be held liable for any damages
9267 // arising from the use of this software.
9269 // Permission is granted to anyone to use this software for any purpose,
9270 // including commercial applications, and to alter it and redistribute it
9271 // freely, subject to the following restrictions:
9273 // 1. The origin of this software must not be misrepresented; you must not
9274 // claim that you wrote the original software. If you use this software
9275 // in a product, an acknowledgment in the product documentation would be
9276 // appreciated but is not required.
9277 // 2. Altered source versions must be plainly marked as such, and must not be
9278 // misrepresented as being the original software.
9279 // 3. This notice may not be removed or altered from any source distribution.
9281 function GZheader() {
9282 /* true if compressed data believed to be text */
9284 /* modification time */
9286 /* extra flags (not used when writing a gzip file) */
9288 /* operating system */
9290 /* pointer to extra field or Z_NULL if none */
9292 /* extra field length (valid if extra != Z_NULL) */
9293 this.extra_len = 0; // Actually, we don't need it in JS,
9294 // but leave for few code modifications
9297 // Setup limits is not necessary because in js we should not preallocate memory
9298 // for inflate use constant limit in 65536 bytes
9301 /* space at extra (only when reading header) */
9302 // this.extra_max = 0;
9303 /* pointer to zero-terminated file name or Z_NULL */
9305 /* space at name (only when reading header) */
9306 // this.name_max = 0;
9307 /* pointer to zero-terminated comment or Z_NULL */
9309 /* space at comment (only when reading header) */
9310 // this.comm_max = 0;
9311 /* true if there was or will be a header crc */
9313 /* true when done reading gzip header (not used when writing a gzip file) */
9317 module.exports = GZheader;
9319 },{}],33:[function(require,module,exports){
9322 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
9323 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
9325 // This software is provided 'as-is', without any express or implied
9326 // warranty. In no event will the authors be held liable for any damages
9327 // arising from the use of this software.
9329 // Permission is granted to anyone to use this software for any purpose,
9330 // including commercial applications, and to alter it and redistribute it
9331 // freely, subject to the following restrictions:
9333 // 1. The origin of this software must not be misrepresented; you must not
9334 // claim that you wrote the original software. If you use this software
9335 // in a product, an acknowledgment in the product documentation would be
9336 // appreciated but is not required.
9337 // 2. Altered source versions must be plainly marked as such, and must not be
9338 // misrepresented as being the original software.
9339 // 3. This notice may not be removed or altered from any source distribution.
9341 // See state defs from inflate.js
9342 var BAD = 30; /* got a data error -- remain here until reset */
9343 var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
9346 Decode literal, length, and distance codes and write out the resulting
9347 literal and match bytes until either not enough input or output is
9348 available, an end-of-block is encountered, or a data error is encountered.
9349 When large enough input and output buffers are supplied to inflate(), for
9350 example, a 16K input buffer and a 64K output buffer, more than 95% of the
9351 inflate execution time is spent in this routine.
9357 strm.avail_out >= 258
9358 start >= strm.avail_out
9361 On return, state.mode is one of:
9363 LEN -- ran out of enough output space or enough available input
9364 TYPE -- reached end of block code, inflate() to interpret next block
9365 BAD -- error in block data
9369 - The maximum input bits used by a length/distance pair is 15 bits for the
9370 length code, 5 bits for the length extra, 15 bits for the distance code,
9371 and 13 bits for the distance extra. This totals 48 bits, or six bytes.
9372 Therefore if strm.avail_in >= 6, then there is enough input to avoid
9373 checking for available input while decoding.
9375 - The maximum bytes that a single length/distance pair can output is 258
9376 bytes, which is the maximum length that can be coded. inflate_fast()
9377 requires strm.avail_out >= 258 for each loop to avoid checking for
9380 module.exports = function inflate_fast(strm, start) {
9382 var _in; /* local strm.input */
9383 var last; /* have enough input while in < last */
9384 var _out; /* local strm.output */
9385 var beg; /* inflate()'s initial strm.output */
9386 var end; /* while out < end, enough space available */
9387 //#ifdef INFLATE_STRICT
9388 var dmax; /* maximum distance from zlib header */
9390 var wsize; /* window size or zero if not using window */
9391 var whave; /* valid bytes in the window */
9392 var wnext; /* window write index */
9393 // Use `s_window` instead `window`, avoid conflict with instrumentation tools
9394 var s_window; /* allocated sliding window, if wsize != 0 */
9395 var hold; /* local strm.hold */
9396 var bits; /* local strm.bits */
9397 var lcode; /* local strm.lencode */
9398 var dcode; /* local strm.distcode */
9399 var lmask; /* mask for first level of length codes */
9400 var dmask; /* mask for first level of distance codes */
9401 var here; /* retrieved table entry */
9402 var op; /* code bits, operation, extra bits, or */
9403 /* window position, window bytes to copy */
9404 var len; /* match length, unused bytes */
9405 var dist; /* match distance */
9406 var from; /* where to copy match from */
9410 var input, output; // JS specific, because we have no pointers
9412 /* copy state to local variables */
9414 //here = state.here;
9417 last = _in + (strm.avail_in - 5);
9418 _out = strm.next_out;
9419 output = strm.output;
9420 beg = _out - (start - strm.avail_out);
9421 end = _out + (strm.avail_out - 257);
9422 //#ifdef INFLATE_STRICT
9425 wsize = state.wsize;
9426 whave = state.whave;
9427 wnext = state.wnext;
9428 s_window = state.window;
9431 lcode = state.lencode;
9432 dcode = state.distcode;
9433 lmask = (1 << state.lenbits) - 1;
9434 dmask = (1 << state.distbits) - 1;
9437 /* decode literals and length/distances until end-of-block or not enough
9438 input data or output space */
9443 hold += input[_in++] << bits;
9445 hold += input[_in++] << bits;
9449 here = lcode[hold & lmask];
9452 for (;;) { // Goto emulation
9453 op = here >>> 24/*here.bits*/;
9456 op = (here >>> 16) & 0xff/*here.op*/;
9457 if (op === 0) { /* literal */
9458 //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
9459 // "inflate: literal '%c'\n" :
9460 // "inflate: literal 0x%02x\n", here.val));
9461 output[_out++] = here & 0xffff/*here.val*/;
9463 else if (op & 16) { /* length base */
9464 len = here & 0xffff/*here.val*/;
9465 op &= 15; /* number of extra bits */
9468 hold += input[_in++] << bits;
9471 len += hold & ((1 << op) - 1);
9475 //Tracevv((stderr, "inflate: length %u\n", len));
9477 hold += input[_in++] << bits;
9479 hold += input[_in++] << bits;
9482 here = dcode[hold & dmask];
9485 for (;;) { // goto emulation
9486 op = here >>> 24/*here.bits*/;
9489 op = (here >>> 16) & 0xff/*here.op*/;
9491 if (op & 16) { /* distance base */
9492 dist = here & 0xffff/*here.val*/;
9493 op &= 15; /* number of extra bits */
9495 hold += input[_in++] << bits;
9498 hold += input[_in++] << bits;
9502 dist += hold & ((1 << op) - 1);
9503 //#ifdef INFLATE_STRICT
9505 strm.msg = 'invalid distance too far back';
9512 //Tracevv((stderr, "inflate: distance %u\n", dist));
9513 op = _out - beg; /* max distance in output */
9514 if (dist > op) { /* see if copy from window */
9515 op = dist - op; /* distance back in window */
9518 strm.msg = 'invalid distance too far back';
9523 // (!) This block is disabled in zlib defaults,
9524 // don't enable it for binary compatibility
9525 //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
9526 // if (len <= op - whave) {
9528 // output[_out++] = 0;
9532 // len -= op - whave;
9534 // output[_out++] = 0;
9535 // } while (--op > whave);
9537 // from = _out - dist;
9539 // output[_out++] = output[from++];
9545 from = 0; // window index
9546 from_source = s_window;
9547 if (wnext === 0) { /* very common case */
9549 if (op < len) { /* some from window */
9552 output[_out++] = s_window[from++];
9554 from = _out - dist; /* rest from output */
9555 from_source = output;
9558 else if (wnext < op) { /* wrap around window */
9559 from += wsize + wnext - op;
9561 if (op < len) { /* some from end of window */
9564 output[_out++] = s_window[from++];
9567 if (wnext < len) { /* some from start of window */
9571 output[_out++] = s_window[from++];
9573 from = _out - dist; /* rest from output */
9574 from_source = output;
9578 else { /* contiguous in window */
9580 if (op < len) { /* some from window */
9583 output[_out++] = s_window[from++];
9585 from = _out - dist; /* rest from output */
9586 from_source = output;
9590 output[_out++] = from_source[from++];
9591 output[_out++] = from_source[from++];
9592 output[_out++] = from_source[from++];
9596 output[_out++] = from_source[from++];
9598 output[_out++] = from_source[from++];
9603 from = _out - dist; /* copy direct from output */
9604 do { /* minimum length is three */
9605 output[_out++] = output[from++];
9606 output[_out++] = output[from++];
9607 output[_out++] = output[from++];
9611 output[_out++] = output[from++];
9613 output[_out++] = output[from++];
9618 else if ((op & 64) === 0) { /* 2nd level distance code */
9619 here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
9623 strm.msg = 'invalid distance code';
9628 break; // need to emulate goto via "continue"
9631 else if ((op & 64) === 0) { /* 2nd level length code */
9632 here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
9635 else if (op & 32) { /* end-of-block */
9636 //Tracevv((stderr, "inflate: end of block\n"));
9641 strm.msg = 'invalid literal/length code';
9646 break; // need to emulate goto via "continue"
9648 } while (_in < last && _out < end);
9650 /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
9654 hold &= (1 << bits) - 1;
9656 /* update state and return */
9658 strm.next_out = _out;
9659 strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));
9660 strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));
9666 },{}],34:[function(require,module,exports){
9669 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
9670 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
9672 // This software is provided 'as-is', without any express or implied
9673 // warranty. In no event will the authors be held liable for any damages
9674 // arising from the use of this software.
9676 // Permission is granted to anyone to use this software for any purpose,
9677 // including commercial applications, and to alter it and redistribute it
9678 // freely, subject to the following restrictions:
9680 // 1. The origin of this software must not be misrepresented; you must not
9681 // claim that you wrote the original software. If you use this software
9682 // in a product, an acknowledgment in the product documentation would be
9683 // appreciated but is not required.
9684 // 2. Altered source versions must be plainly marked as such, and must not be
9685 // misrepresented as being the original software.
9686 // 3. This notice may not be removed or altered from any source distribution.
9688 var utils = require('../utils/common');
9689 var adler32 = require('./adler32');
9690 var crc32 = require('./crc32');
9691 var inflate_fast = require('./inffast');
9692 var inflate_table = require('./inftrees');
9698 /* Public constants ==========================================================*/
9699 /* ===========================================================================*/
9702 /* Allowed flush values; see deflate() and inflate() below for details */
9703 //var Z_NO_FLUSH = 0;
9704 //var Z_PARTIAL_FLUSH = 1;
9705 //var Z_SYNC_FLUSH = 2;
9706 //var Z_FULL_FLUSH = 3;
9712 /* Return codes for the compression/decompression functions. Negative values
9713 * are errors, positive values are used for special but normal events.
9716 var Z_STREAM_END = 1;
9717 var Z_NEED_DICT = 2;
9719 var Z_STREAM_ERROR = -2;
9720 var Z_DATA_ERROR = -3;
9721 var Z_MEM_ERROR = -4;
9722 var Z_BUF_ERROR = -5;
9723 //var Z_VERSION_ERROR = -6;
9725 /* The deflate compression method */
9729 /* STATES ====================================================================*/
9730 /* ===========================================================================*/
9733 var HEAD = 1; /* i: waiting for magic header */
9734 var FLAGS = 2; /* i: waiting for method and flags (gzip) */
9735 var TIME = 3; /* i: waiting for modification time (gzip) */
9736 var OS = 4; /* i: waiting for extra flags and operating system (gzip) */
9737 var EXLEN = 5; /* i: waiting for extra length (gzip) */
9738 var EXTRA = 6; /* i: waiting for extra bytes (gzip) */
9739 var NAME = 7; /* i: waiting for end of file name (gzip) */
9740 var COMMENT = 8; /* i: waiting for end of comment (gzip) */
9741 var HCRC = 9; /* i: waiting for header crc (gzip) */
9742 var DICTID = 10; /* i: waiting for dictionary check value */
9743 var DICT = 11; /* waiting for inflateSetDictionary() call */
9744 var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
9745 var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */
9746 var STORED = 14; /* i: waiting for stored size (length and complement) */
9747 var COPY_ = 15; /* i/o: same as COPY below, but only first time in */
9748 var COPY = 16; /* i/o: waiting for input or output to copy stored block */
9749 var TABLE = 17; /* i: waiting for dynamic block table lengths */
9750 var LENLENS = 18; /* i: waiting for code length code lengths */
9751 var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */
9752 var LEN_ = 20; /* i: same as LEN below, but only first time in */
9753 var LEN = 21; /* i: waiting for length/lit/eob code */
9754 var LENEXT = 22; /* i: waiting for length extra bits */
9755 var DIST = 23; /* i: waiting for distance code */
9756 var DISTEXT = 24; /* i: waiting for distance extra bits */
9757 var MATCH = 25; /* o: waiting for output space to copy string */
9758 var LIT = 26; /* o: waiting for output space to write literal */
9759 var CHECK = 27; /* i: waiting for 32-bit check value */
9760 var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */
9761 var DONE = 29; /* finished check, done -- remain here until reset */
9762 var BAD = 30; /* got a data error -- remain here until reset */
9763 var MEM = 31; /* got an inflate() memory error -- remain here until reset */
9764 var SYNC = 32; /* looking for synchronization bytes to restart inflate() */
9766 /* ===========================================================================*/
9770 var ENOUGH_LENS = 852;
9771 var ENOUGH_DISTS = 592;
9772 //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
9775 /* 32K LZ77 window */
9776 var DEF_WBITS = MAX_WBITS;
9779 function zswap32(q) {
9780 return (((q >>> 24) & 0xff) +
9781 ((q >>> 8) & 0xff00) +
9782 ((q & 0xff00) << 8) +
9783 ((q & 0xff) << 24));
9787 function InflateState() {
9788 this.mode = 0; /* current inflate mode */
9789 this.last = false; /* true if processing last block */
9790 this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
9791 this.havedict = false; /* true if dictionary provided */
9792 this.flags = 0; /* gzip header method and flags (0 if zlib) */
9793 this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
9794 this.check = 0; /* protected copy of check value */
9795 this.total = 0; /* protected copy of output count */
9797 this.head = null; /* where to save gzip header information */
9799 /* sliding window */
9800 this.wbits = 0; /* log base 2 of requested window size */
9801 this.wsize = 0; /* window size or zero if not using window */
9802 this.whave = 0; /* valid bytes in the window */
9803 this.wnext = 0; /* window write index */
9804 this.window = null; /* allocated sliding window, if needed */
9806 /* bit accumulator */
9807 this.hold = 0; /* input bit accumulator */
9808 this.bits = 0; /* number of bits in "in" */
9810 /* for string and stored block copying */
9811 this.length = 0; /* literal or length of data to copy */
9812 this.offset = 0; /* distance back to copy string from */
9814 /* for table and code decoding */
9815 this.extra = 0; /* extra bits needed */
9817 /* fixed and dynamic code tables */
9818 this.lencode = null; /* starting table for length/literal codes */
9819 this.distcode = null; /* starting table for distance codes */
9820 this.lenbits = 0; /* index bits for lencode */
9821 this.distbits = 0; /* index bits for distcode */
9823 /* dynamic table building */
9824 this.ncode = 0; /* number of code length code lengths */
9825 this.nlen = 0; /* number of length code lengths */
9826 this.ndist = 0; /* number of distance code lengths */
9827 this.have = 0; /* number of code lengths in lens[] */
9828 this.next = null; /* next available space in codes[] */
9830 this.lens = new utils.Buf16(320); /* temporary storage for code lengths */
9831 this.work = new utils.Buf16(288); /* work area for code table building */
9834 because we don't have pointers in js, we use lencode and distcode directly
9835 as buffers so we don't need codes
9837 //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */
9838 this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */
9839 this.distdyn = null; /* dynamic table for distance codes (JS specific) */
9840 this.sane = 0; /* if false, allow invalid distance too far */
9841 this.back = 0; /* bits back of last unprocessed length/lit */
9842 this.was = 0; /* initial length of match */
9845 function inflateResetKeep(strm) {
9848 if (!strm || !strm.state) { return Z_STREAM_ERROR; }
9850 strm.total_in = strm.total_out = state.total = 0;
9851 strm.msg = ''; /*Z_NULL*/
9852 if (state.wrap) { /* to support ill-conceived Java test suite */
9853 strm.adler = state.wrap & 1;
9859 state.head = null/*Z_NULL*/;
9862 //state.lencode = state.distcode = state.next = state.codes;
9863 state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
9864 state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
9868 //Tracev((stderr, "inflate: reset\n"));
9872 function inflateReset(strm) {
9875 if (!strm || !strm.state) { return Z_STREAM_ERROR; }
9880 return inflateResetKeep(strm);
9884 function inflateReset2(strm, windowBits) {
9889 if (!strm || !strm.state) { return Z_STREAM_ERROR; }
9892 /* extract wrap request from windowBits parameter */
9893 if (windowBits < 0) {
9895 windowBits = -windowBits;
9898 wrap = (windowBits >> 4) + 1;
9899 if (windowBits < 48) {
9904 /* set number of window bits, free window if different */
9905 if (windowBits && (windowBits < 8 || windowBits > 15)) {
9906 return Z_STREAM_ERROR;
9908 if (state.window !== null && state.wbits !== windowBits) {
9909 state.window = null;
9912 /* update state and reset the rest of it */
9914 state.wbits = windowBits;
9915 return inflateReset(strm);
9918 function inflateInit2(strm, windowBits) {
9922 if (!strm) { return Z_STREAM_ERROR; }
9923 //strm.msg = Z_NULL; /* in case we return an error */
9925 state = new InflateState();
9927 //if (state === Z_NULL) return Z_MEM_ERROR;
9928 //Tracev((stderr, "inflate: allocated\n"));
9930 state.window = null/*Z_NULL*/;
9931 ret = inflateReset2(strm, windowBits);
9933 strm.state = null/*Z_NULL*/;
9938 function inflateInit(strm) {
9939 return inflateInit2(strm, DEF_WBITS);
9944 Return state with length and distance decoding tables and index sizes set to
9945 fixed code decoding. Normally this returns fixed tables from inffixed.h.
9946 If BUILDFIXED is defined, then instead this routine builds the tables the
9947 first time it's called, and returns those tables the first time and
9948 thereafter. This reduces the size of the code by about 2K bytes, in
9949 exchange for a little execution time. However, BUILDFIXED should not be
9950 used for threaded applications, since the rewriting of the tables and virgin
9951 may not be thread-safe.
9955 var lenfix, distfix; // We have no pointers in JS, so keep tables separate
9957 function fixedtables(state) {
9958 /* build fixed huffman tables if first call (may not be thread safe) */
9962 lenfix = new utils.Buf32(512);
9963 distfix = new utils.Buf32(32);
9965 /* literal/length table */
9967 while (sym < 144) { state.lens[sym++] = 8; }
9968 while (sym < 256) { state.lens[sym++] = 9; }
9969 while (sym < 280) { state.lens[sym++] = 7; }
9970 while (sym < 288) { state.lens[sym++] = 8; }
9972 inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });
9974 /* distance table */
9976 while (sym < 32) { state.lens[sym++] = 5; }
9978 inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });
9980 /* do this just once */
9984 state.lencode = lenfix;
9986 state.distcode = distfix;
9992 Update the window with the last wsize (normally 32K) bytes written before
9993 returning. If window does not exist yet, create it. This is only called
9994 when a window is already in use, or when output has been written during this
9995 inflate call, but the end of the deflate stream has not been reached yet.
9996 It is also called to create a window for dictionary data when a dictionary
9999 Providing output buffers larger than 32K to inflate() should provide a speed
10000 advantage, since only the last 32K of output is copied to the sliding window
10001 upon return from inflate(), and since all distances after the first 32K of
10002 output will fall in the output data, making match copies simpler and faster.
10003 The advantage may be dependent on the size of the processor's data caches.
10005 function updatewindow(strm, src, end, copy) {
10007 var state = strm.state;
10009 /* if it hasn't been done already, allocate space for the window */
10010 if (state.window === null) {
10011 state.wsize = 1 << state.wbits;
10015 state.window = new utils.Buf8(state.wsize);
10018 /* copy state->wsize or less output bytes into the circular window */
10019 if (copy >= state.wsize) {
10020 utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
10022 state.whave = state.wsize;
10025 dist = state.wsize - state.wnext;
10029 //zmemcpy(state->window + state->wnext, end - copy, dist);
10030 utils.arraySet(state.window, src, end - copy, dist, state.wnext);
10033 //zmemcpy(state->window, end - copy, copy);
10034 utils.arraySet(state.window, src, end - copy, copy, 0);
10035 state.wnext = copy;
10036 state.whave = state.wsize;
10039 state.wnext += dist;
10040 if (state.wnext === state.wsize) { state.wnext = 0; }
10041 if (state.whave < state.wsize) { state.whave += dist; }
10047 function inflate(strm, flush) {
10049 var input, output; // input/output buffers
10050 var next; /* next input INDEX */
10051 var put; /* next output INDEX */
10052 var have, left; /* available input and output */
10053 var hold; /* bit buffer */
10054 var bits; /* bits in bit buffer */
10055 var _in, _out; /* save starting available input and output */
10056 var copy; /* number of stored or match bytes to copy */
10057 var from; /* where to copy match bytes from */
10059 var here = 0; /* current decoding table entry */
10060 var here_bits, here_op, here_val; // paked "here" denormalized (JS specific)
10061 //var last; /* parent table entry */
10062 var last_bits, last_op, last_val; // paked "last" denormalized (JS specific)
10063 var len; /* length to copy for repeats, bits to drop */
10064 var ret; /* return code */
10065 var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */
10068 var n; // temporary var for NEED_BITS
10070 var order = /* permutation of code lengths */
10071 [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];
10074 if (!strm || !strm.state || !strm.output ||
10075 (!strm.input && strm.avail_in !== 0)) {
10076 return Z_STREAM_ERROR;
10079 state = strm.state;
10080 if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */
10084 put = strm.next_out;
10085 output = strm.output;
10086 left = strm.avail_out;
10087 next = strm.next_in;
10088 input = strm.input;
10089 have = strm.avail_in;
10098 inf_leave: // goto emulation
10100 switch (state.mode) {
10102 if (state.wrap === 0) {
10103 state.mode = TYPEDO;
10106 //=== NEEDBITS(16);
10107 while (bits < 16) {
10108 if (have === 0) { break inf_leave; }
10110 hold += input[next++] << bits;
10114 if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */
10115 state.check = 0/*crc32(0L, Z_NULL, 0)*/;
10116 //=== CRC2(state.check, hold);
10117 hbuf[0] = hold & 0xff;
10118 hbuf[1] = (hold >>> 8) & 0xff;
10119 state.check = crc32(state.check, hbuf, 2, 0);
10126 state.mode = FLAGS;
10129 state.flags = 0; /* expect zlib header */
10131 state.head.done = false;
10133 if (!(state.wrap & 1) || /* check if zlib header allowed */
10134 (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {
10135 strm.msg = 'incorrect header check';
10139 if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {
10140 strm.msg = 'unknown compression method';
10144 //--- DROPBITS(4) ---//
10148 len = (hold & 0x0f)/*BITS(4)*/ + 8;
10149 if (state.wbits === 0) {
10152 else if (len > state.wbits) {
10153 strm.msg = 'invalid window size';
10157 state.dmax = 1 << len;
10158 //Tracev((stderr, "inflate: zlib header ok\n"));
10159 strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
10160 state.mode = hold & 0x200 ? DICTID : TYPE;
10167 //=== NEEDBITS(16); */
10168 while (bits < 16) {
10169 if (have === 0) { break inf_leave; }
10171 hold += input[next++] << bits;
10175 state.flags = hold;
10176 if ((state.flags & 0xff) !== Z_DEFLATED) {
10177 strm.msg = 'unknown compression method';
10181 if (state.flags & 0xe000) {
10182 strm.msg = 'unknown header flags set';
10187 state.head.text = ((hold >> 8) & 1);
10189 if (state.flags & 0x0200) {
10190 //=== CRC2(state.check, hold);
10191 hbuf[0] = hold & 0xff;
10192 hbuf[1] = (hold >>> 8) & 0xff;
10193 state.check = crc32(state.check, hbuf, 2, 0);
10201 /* falls through */
10203 //=== NEEDBITS(32); */
10204 while (bits < 32) {
10205 if (have === 0) { break inf_leave; }
10207 hold += input[next++] << bits;
10212 state.head.time = hold;
10214 if (state.flags & 0x0200) {
10215 //=== CRC4(state.check, hold)
10216 hbuf[0] = hold & 0xff;
10217 hbuf[1] = (hold >>> 8) & 0xff;
10218 hbuf[2] = (hold >>> 16) & 0xff;
10219 hbuf[3] = (hold >>> 24) & 0xff;
10220 state.check = crc32(state.check, hbuf, 4, 0);
10228 /* falls through */
10230 //=== NEEDBITS(16); */
10231 while (bits < 16) {
10232 if (have === 0) { break inf_leave; }
10234 hold += input[next++] << bits;
10239 state.head.xflags = (hold & 0xff);
10240 state.head.os = (hold >> 8);
10242 if (state.flags & 0x0200) {
10243 //=== CRC2(state.check, hold);
10244 hbuf[0] = hold & 0xff;
10245 hbuf[1] = (hold >>> 8) & 0xff;
10246 state.check = crc32(state.check, hbuf, 2, 0);
10253 state.mode = EXLEN;
10254 /* falls through */
10256 if (state.flags & 0x0400) {
10257 //=== NEEDBITS(16); */
10258 while (bits < 16) {
10259 if (have === 0) { break inf_leave; }
10261 hold += input[next++] << bits;
10265 state.length = hold;
10267 state.head.extra_len = hold;
10269 if (state.flags & 0x0200) {
10270 //=== CRC2(state.check, hold);
10271 hbuf[0] = hold & 0xff;
10272 hbuf[1] = (hold >>> 8) & 0xff;
10273 state.check = crc32(state.check, hbuf, 2, 0);
10281 else if (state.head) {
10282 state.head.extra = null/*Z_NULL*/;
10284 state.mode = EXTRA;
10285 /* falls through */
10287 if (state.flags & 0x0400) {
10288 copy = state.length;
10289 if (copy > have) { copy = have; }
10292 len = state.head.extra_len - state.length;
10293 if (!state.head.extra) {
10294 // Use untyped array for more convenient processing later
10295 state.head.extra = new Array(state.head.extra_len);
10301 // extra field is limited to 65536 bytes
10302 // - no need for additional size check
10304 /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
10307 //zmemcpy(state.head.extra + len, next,
10308 // len + copy > state.head.extra_max ?
10309 // state.head.extra_max - len : copy);
10311 if (state.flags & 0x0200) {
10312 state.check = crc32(state.check, input, copy, next);
10316 state.length -= copy;
10318 if (state.length) { break inf_leave; }
10322 /* falls through */
10324 if (state.flags & 0x0800) {
10325 if (have === 0) { break inf_leave; }
10328 // TODO: 2 or 1 bytes?
10329 len = input[next + copy++];
10330 /* use constant limit because in js we should not preallocate memory */
10331 if (state.head && len &&
10332 (state.length < 65536 /*state.head.name_max*/)) {
10333 state.head.name += String.fromCharCode(len);
10335 } while (len && copy < have);
10337 if (state.flags & 0x0200) {
10338 state.check = crc32(state.check, input, copy, next);
10342 if (len) { break inf_leave; }
10344 else if (state.head) {
10345 state.head.name = null;
10348 state.mode = COMMENT;
10349 /* falls through */
10351 if (state.flags & 0x1000) {
10352 if (have === 0) { break inf_leave; }
10355 len = input[next + copy++];
10356 /* use constant limit because in js we should not preallocate memory */
10357 if (state.head && len &&
10358 (state.length < 65536 /*state.head.comm_max*/)) {
10359 state.head.comment += String.fromCharCode(len);
10361 } while (len && copy < have);
10362 if (state.flags & 0x0200) {
10363 state.check = crc32(state.check, input, copy, next);
10367 if (len) { break inf_leave; }
10369 else if (state.head) {
10370 state.head.comment = null;
10373 /* falls through */
10375 if (state.flags & 0x0200) {
10376 //=== NEEDBITS(16); */
10377 while (bits < 16) {
10378 if (have === 0) { break inf_leave; }
10380 hold += input[next++] << bits;
10384 if (hold !== (state.check & 0xffff)) {
10385 strm.msg = 'header crc mismatch';
10395 state.head.hcrc = ((state.flags >> 9) & 1);
10396 state.head.done = true;
10398 strm.adler = state.check = 0;
10402 //=== NEEDBITS(32); */
10403 while (bits < 32) {
10404 if (have === 0) { break inf_leave; }
10406 hold += input[next++] << bits;
10410 strm.adler = state.check = zswap32(hold);
10416 /* falls through */
10418 if (state.havedict === 0) {
10419 //--- RESTORE() ---
10420 strm.next_out = put;
10421 strm.avail_out = left;
10422 strm.next_in = next;
10423 strm.avail_in = have;
10427 return Z_NEED_DICT;
10429 strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
10431 /* falls through */
10433 if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }
10434 /* falls through */
10437 //--- BYTEBITS() ---//
10438 hold >>>= bits & 7;
10441 state.mode = CHECK;
10444 //=== NEEDBITS(3); */
10446 if (have === 0) { break inf_leave; }
10448 hold += input[next++] << bits;
10452 state.last = (hold & 0x01)/*BITS(1)*/;
10453 //--- DROPBITS(1) ---//
10458 switch ((hold & 0x03)/*BITS(2)*/) {
10459 case 0: /* stored block */
10460 //Tracev((stderr, "inflate: stored block%s\n",
10461 // state.last ? " (last)" : ""));
10462 state.mode = STORED;
10464 case 1: /* fixed block */
10465 fixedtables(state);
10466 //Tracev((stderr, "inflate: fixed codes block%s\n",
10467 // state.last ? " (last)" : ""));
10468 state.mode = LEN_; /* decode codes */
10469 if (flush === Z_TREES) {
10470 //--- DROPBITS(2) ---//
10477 case 2: /* dynamic block */
10478 //Tracev((stderr, "inflate: dynamic codes block%s\n",
10479 // state.last ? " (last)" : ""));
10480 state.mode = TABLE;
10483 strm.msg = 'invalid block type';
10486 //--- DROPBITS(2) ---//
10492 //--- BYTEBITS() ---// /* go to byte boundary */
10493 hold >>>= bits & 7;
10496 //=== NEEDBITS(32); */
10497 while (bits < 32) {
10498 if (have === 0) { break inf_leave; }
10500 hold += input[next++] << bits;
10504 if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {
10505 strm.msg = 'invalid stored block lengths';
10509 state.length = hold & 0xffff;
10510 //Tracev((stderr, "inflate: stored length %u\n",
10516 state.mode = COPY_;
10517 if (flush === Z_TREES) { break inf_leave; }
10518 /* falls through */
10521 /* falls through */
10523 copy = state.length;
10525 if (copy > have) { copy = have; }
10526 if (copy > left) { copy = left; }
10527 if (copy === 0) { break inf_leave; }
10528 //--- zmemcpy(put, next, copy); ---
10529 utils.arraySet(output, input, next, copy, put);
10535 state.length -= copy;
10538 //Tracev((stderr, "inflate: stored end\n"));
10542 //=== NEEDBITS(14); */
10543 while (bits < 14) {
10544 if (have === 0) { break inf_leave; }
10546 hold += input[next++] << bits;
10550 state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;
10551 //--- DROPBITS(5) ---//
10555 state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;
10556 //--- DROPBITS(5) ---//
10560 state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;
10561 //--- DROPBITS(4) ---//
10565 //#ifndef PKZIP_BUG_WORKAROUND
10566 if (state.nlen > 286 || state.ndist > 30) {
10567 strm.msg = 'too many length or distance symbols';
10572 //Tracev((stderr, "inflate: table sizes ok\n"));
10574 state.mode = LENLENS;
10575 /* falls through */
10577 while (state.have < state.ncode) {
10580 if (have === 0) { break inf_leave; }
10582 hold += input[next++] << bits;
10586 state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);
10587 //--- DROPBITS(3) ---//
10592 while (state.have < 19) {
10593 state.lens[order[state.have++]] = 0;
10595 // We have separate tables & no pointers. 2 commented lines below not needed.
10596 //state.next = state.codes;
10597 //state.lencode = state.next;
10598 // Switch to use dynamic table
10599 state.lencode = state.lendyn;
10602 opts = { bits: state.lenbits };
10603 ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
10604 state.lenbits = opts.bits;
10607 strm.msg = 'invalid code lengths set';
10611 //Tracev((stderr, "inflate: code lengths ok\n"));
10613 state.mode = CODELENS;
10614 /* falls through */
10616 while (state.have < state.nlen + state.ndist) {
10618 here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/
10619 here_bits = here >>> 24;
10620 here_op = (here >>> 16) & 0xff;
10621 here_val = here & 0xffff;
10623 if ((here_bits) <= bits) { break; }
10624 //--- PULLBYTE() ---//
10625 if (have === 0) { break inf_leave; }
10627 hold += input[next++] << bits;
10631 if (here_val < 16) {
10632 //--- DROPBITS(here.bits) ---//
10633 hold >>>= here_bits;
10636 state.lens[state.have++] = here_val;
10639 if (here_val === 16) {
10640 //=== NEEDBITS(here.bits + 2);
10643 if (have === 0) { break inf_leave; }
10645 hold += input[next++] << bits;
10649 //--- DROPBITS(here.bits) ---//
10650 hold >>>= here_bits;
10653 if (state.have === 0) {
10654 strm.msg = 'invalid bit length repeat';
10658 len = state.lens[state.have - 1];
10659 copy = 3 + (hold & 0x03);//BITS(2);
10660 //--- DROPBITS(2) ---//
10665 else if (here_val === 17) {
10666 //=== NEEDBITS(here.bits + 3);
10669 if (have === 0) { break inf_leave; }
10671 hold += input[next++] << bits;
10675 //--- DROPBITS(here.bits) ---//
10676 hold >>>= here_bits;
10680 copy = 3 + (hold & 0x07);//BITS(3);
10681 //--- DROPBITS(3) ---//
10687 //=== NEEDBITS(here.bits + 7);
10690 if (have === 0) { break inf_leave; }
10692 hold += input[next++] << bits;
10696 //--- DROPBITS(here.bits) ---//
10697 hold >>>= here_bits;
10701 copy = 11 + (hold & 0x7f);//BITS(7);
10702 //--- DROPBITS(7) ---//
10707 if (state.have + copy > state.nlen + state.ndist) {
10708 strm.msg = 'invalid bit length repeat';
10713 state.lens[state.have++] = len;
10718 /* handle error breaks in while */
10719 if (state.mode === BAD) { break; }
10721 /* check for end-of-block code (better have one) */
10722 if (state.lens[256] === 0) {
10723 strm.msg = 'invalid code -- missing end-of-block';
10728 /* build code tables -- note: do not change the lenbits or distbits
10729 values here (9 and 6) without reading the comments in inftrees.h
10730 concerning the ENOUGH constants, which depend on those values */
10733 opts = { bits: state.lenbits };
10734 ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
10735 // We have separate tables & no pointers. 2 commented lines below not needed.
10736 // state.next_index = opts.table_index;
10737 state.lenbits = opts.bits;
10738 // state.lencode = state.next;
10741 strm.msg = 'invalid literal/lengths set';
10746 state.distbits = 6;
10747 //state.distcode.copy(state.codes);
10748 // Switch to use dynamic table
10749 state.distcode = state.distdyn;
10750 opts = { bits: state.distbits };
10751 ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
10752 // We have separate tables & no pointers. 2 commented lines below not needed.
10753 // state.next_index = opts.table_index;
10754 state.distbits = opts.bits;
10755 // state.distcode = state.next;
10758 strm.msg = 'invalid distances set';
10762 //Tracev((stderr, 'inflate: codes ok\n'));
10764 if (flush === Z_TREES) { break inf_leave; }
10765 /* falls through */
10768 /* falls through */
10770 if (have >= 6 && left >= 258) {
10771 //--- RESTORE() ---
10772 strm.next_out = put;
10773 strm.avail_out = left;
10774 strm.next_in = next;
10775 strm.avail_in = have;
10779 inflate_fast(strm, _out);
10781 put = strm.next_out;
10782 output = strm.output;
10783 left = strm.avail_out;
10784 next = strm.next_in;
10785 input = strm.input;
10786 have = strm.avail_in;
10791 if (state.mode === TYPE) {
10798 here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/
10799 here_bits = here >>> 24;
10800 here_op = (here >>> 16) & 0xff;
10801 here_val = here & 0xffff;
10803 if (here_bits <= bits) { break; }
10804 //--- PULLBYTE() ---//
10805 if (have === 0) { break inf_leave; }
10807 hold += input[next++] << bits;
10811 if (here_op && (here_op & 0xf0) === 0) {
10812 last_bits = here_bits;
10814 last_val = here_val;
10816 here = state.lencode[last_val +
10817 ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
10818 here_bits = here >>> 24;
10819 here_op = (here >>> 16) & 0xff;
10820 here_val = here & 0xffff;
10822 if ((last_bits + here_bits) <= bits) { break; }
10823 //--- PULLBYTE() ---//
10824 if (have === 0) { break inf_leave; }
10826 hold += input[next++] << bits;
10830 //--- DROPBITS(last.bits) ---//
10831 hold >>>= last_bits;
10834 state.back += last_bits;
10836 //--- DROPBITS(here.bits) ---//
10837 hold >>>= here_bits;
10840 state.back += here_bits;
10841 state.length = here_val;
10842 if (here_op === 0) {
10843 //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
10844 // "inflate: literal '%c'\n" :
10845 // "inflate: literal 0x%02x\n", here.val));
10849 if (here_op & 32) {
10850 //Tracevv((stderr, "inflate: end of block\n"));
10855 if (here_op & 64) {
10856 strm.msg = 'invalid literal/length code';
10860 state.extra = here_op & 15;
10861 state.mode = LENEXT;
10862 /* falls through */
10865 //=== NEEDBITS(state.extra);
10868 if (have === 0) { break inf_leave; }
10870 hold += input[next++] << bits;
10874 state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
10875 //--- DROPBITS(state.extra) ---//
10876 hold >>>= state.extra;
10877 bits -= state.extra;
10879 state.back += state.extra;
10881 //Tracevv((stderr, "inflate: length %u\n", state.length));
10882 state.was = state.length;
10884 /* falls through */
10887 here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/
10888 here_bits = here >>> 24;
10889 here_op = (here >>> 16) & 0xff;
10890 here_val = here & 0xffff;
10892 if ((here_bits) <= bits) { break; }
10893 //--- PULLBYTE() ---//
10894 if (have === 0) { break inf_leave; }
10896 hold += input[next++] << bits;
10900 if ((here_op & 0xf0) === 0) {
10901 last_bits = here_bits;
10903 last_val = here_val;
10905 here = state.distcode[last_val +
10906 ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
10907 here_bits = here >>> 24;
10908 here_op = (here >>> 16) & 0xff;
10909 here_val = here & 0xffff;
10911 if ((last_bits + here_bits) <= bits) { break; }
10912 //--- PULLBYTE() ---//
10913 if (have === 0) { break inf_leave; }
10915 hold += input[next++] << bits;
10919 //--- DROPBITS(last.bits) ---//
10920 hold >>>= last_bits;
10923 state.back += last_bits;
10925 //--- DROPBITS(here.bits) ---//
10926 hold >>>= here_bits;
10929 state.back += here_bits;
10930 if (here_op & 64) {
10931 strm.msg = 'invalid distance code';
10935 state.offset = here_val;
10936 state.extra = (here_op) & 15;
10937 state.mode = DISTEXT;
10938 /* falls through */
10941 //=== NEEDBITS(state.extra);
10944 if (have === 0) { break inf_leave; }
10946 hold += input[next++] << bits;
10950 state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
10951 //--- DROPBITS(state.extra) ---//
10952 hold >>>= state.extra;
10953 bits -= state.extra;
10955 state.back += state.extra;
10957 //#ifdef INFLATE_STRICT
10958 if (state.offset > state.dmax) {
10959 strm.msg = 'invalid distance too far back';
10964 //Tracevv((stderr, "inflate: distance %u\n", state.offset));
10965 state.mode = MATCH;
10966 /* falls through */
10968 if (left === 0) { break inf_leave; }
10969 copy = _out - left;
10970 if (state.offset > copy) { /* copy from window */
10971 copy = state.offset - copy;
10972 if (copy > state.whave) {
10974 strm.msg = 'invalid distance too far back';
10978 // (!) This block is disabled in zlib defaults,
10979 // don't enable it for binary compatibility
10980 //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
10981 // Trace((stderr, "inflate.c too far\n"));
10982 // copy -= state.whave;
10983 // if (copy > state.length) { copy = state.length; }
10984 // if (copy > left) { copy = left; }
10986 // state.length -= copy;
10988 // output[put++] = 0;
10989 // } while (--copy);
10990 // if (state.length === 0) { state.mode = LEN; }
10994 if (copy > state.wnext) {
10995 copy -= state.wnext;
10996 from = state.wsize - copy;
10999 from = state.wnext - copy;
11001 if (copy > state.length) { copy = state.length; }
11002 from_source = state.window;
11004 else { /* copy from output */
11005 from_source = output;
11006 from = put - state.offset;
11007 copy = state.length;
11009 if (copy > left) { copy = left; }
11011 state.length -= copy;
11013 output[put++] = from_source[from++];
11015 if (state.length === 0) { state.mode = LEN; }
11018 if (left === 0) { break inf_leave; }
11019 output[put++] = state.length;
11025 //=== NEEDBITS(32);
11026 while (bits < 32) {
11027 if (have === 0) { break inf_leave; }
11029 // Use '|' instead of '+' to make sure that result is signed
11030 hold |= input[next++] << bits;
11035 strm.total_out += _out;
11036 state.total += _out;
11038 strm.adler = state.check =
11039 /*UPDATE(state.check, put - _out, _out);*/
11040 (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));
11044 // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
11045 if ((state.flags ? hold : zswap32(hold)) !== state.check) {
11046 strm.msg = 'incorrect data check';
11054 //Tracev((stderr, "inflate: check matches trailer\n"));
11056 state.mode = LENGTH;
11057 /* falls through */
11059 if (state.wrap && state.flags) {
11060 //=== NEEDBITS(32);
11061 while (bits < 32) {
11062 if (have === 0) { break inf_leave; }
11064 hold += input[next++] << bits;
11068 if (hold !== (state.total & 0xffffffff)) {
11069 strm.msg = 'incorrect length check';
11077 //Tracev((stderr, "inflate: length matches trailer\n"));
11080 /* falls through */
11082 ret = Z_STREAM_END;
11085 ret = Z_DATA_ERROR;
11088 return Z_MEM_ERROR;
11090 /* falls through */
11092 return Z_STREAM_ERROR;
11096 // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave"
11099 Return from inflate(), updating the total counts and the check value.
11100 If there was no progress during the inflate() call, return a buffer
11101 error. Call updatewindow() to create and/or update the window state.
11102 Note: a memory error from inflate() is non-recoverable.
11105 //--- RESTORE() ---
11106 strm.next_out = put;
11107 strm.avail_out = left;
11108 strm.next_in = next;
11109 strm.avail_in = have;
11114 if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&
11115 (state.mode < CHECK || flush !== Z_FINISH))) {
11116 if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
11118 return Z_MEM_ERROR;
11121 _in -= strm.avail_in;
11122 _out -= strm.avail_out;
11123 strm.total_in += _in;
11124 strm.total_out += _out;
11125 state.total += _out;
11126 if (state.wrap && _out) {
11127 strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
11128 (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));
11130 strm.data_type = state.bits + (state.last ? 64 : 0) +
11131 (state.mode === TYPE ? 128 : 0) +
11132 (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
11133 if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {
11139 function inflateEnd(strm) {
11141 if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {
11142 return Z_STREAM_ERROR;
11145 var state = strm.state;
11146 if (state.window) {
11147 state.window = null;
11153 function inflateGetHeader(strm, head) {
11157 if (!strm || !strm.state) { return Z_STREAM_ERROR; }
11158 state = strm.state;
11159 if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }
11161 /* save header structure */
11167 function inflateSetDictionary(strm, dictionary) {
11168 var dictLength = dictionary.length;
11175 if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }
11176 state = strm.state;
11178 if (state.wrap !== 0 && state.mode !== DICT) {
11179 return Z_STREAM_ERROR;
11182 /* check for correct dictionary identifier */
11183 if (state.mode === DICT) {
11184 dictid = 1; /* adler32(0, null, 0)*/
11185 /* dictid = adler32(dictid, dictionary, dictLength); */
11186 dictid = adler32(dictid, dictionary, dictLength, 0);
11187 if (dictid !== state.check) {
11188 return Z_DATA_ERROR;
11191 /* copy dictionary to window using updatewindow(), which will amend the
11192 existing dictionary if appropriate */
11193 ret = updatewindow(strm, dictionary, dictLength, dictLength);
11196 return Z_MEM_ERROR;
11198 state.havedict = 1;
11199 // Tracev((stderr, "inflate: dictionary set\n"));
11203 exports.inflateReset = inflateReset;
11204 exports.inflateReset2 = inflateReset2;
11205 exports.inflateResetKeep = inflateResetKeep;
11206 exports.inflateInit = inflateInit;
11207 exports.inflateInit2 = inflateInit2;
11208 exports.inflate = inflate;
11209 exports.inflateEnd = inflateEnd;
11210 exports.inflateGetHeader = inflateGetHeader;
11211 exports.inflateSetDictionary = inflateSetDictionary;
11212 exports.inflateInfo = 'pako inflate (from Nodeca project)';
11215 exports.inflateCopy = inflateCopy;
11216 exports.inflateGetDictionary = inflateGetDictionary;
11217 exports.inflateMark = inflateMark;
11218 exports.inflatePrime = inflatePrime;
11219 exports.inflateSync = inflateSync;
11220 exports.inflateSyncPoint = inflateSyncPoint;
11221 exports.inflateUndermine = inflateUndermine;
11224 },{"../utils/common":26,"./adler32":28,"./crc32":30,"./inffast":33,"./inftrees":35}],35:[function(require,module,exports){
11227 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
11228 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
11230 // This software is provided 'as-is', without any express or implied
11231 // warranty. In no event will the authors be held liable for any damages
11232 // arising from the use of this software.
11234 // Permission is granted to anyone to use this software for any purpose,
11235 // including commercial applications, and to alter it and redistribute it
11236 // freely, subject to the following restrictions:
11238 // 1. The origin of this software must not be misrepresented; you must not
11239 // claim that you wrote the original software. If you use this software
11240 // in a product, an acknowledgment in the product documentation would be
11241 // appreciated but is not required.
11242 // 2. Altered source versions must be plainly marked as such, and must not be
11243 // misrepresented as being the original software.
11244 // 3. This notice may not be removed or altered from any source distribution.
11246 var utils = require('../utils/common');
11249 var ENOUGH_LENS = 852;
11250 var ENOUGH_DISTS = 592;
11251 //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
11257 var lbase = [ /* Length codes 257..285 base */
11258 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
11259 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
11262 var lext = [ /* Length codes 257..285 extra */
11263 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
11264 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78
11267 var dbase = [ /* Distance codes 0..29 base */
11268 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
11269 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
11270 8193, 12289, 16385, 24577, 0, 0
11273 var dext = [ /* Distance codes 0..29 extra */
11274 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
11275 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
11276 28, 28, 29, 29, 64, 64
11279 module.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)
11281 var bits = opts.bits;
11282 //here = opts.here; /* table entry for duplication */
11284 var len = 0; /* a code's length in bits */
11285 var sym = 0; /* index of code symbols */
11286 var min = 0, max = 0; /* minimum and maximum code lengths */
11287 var root = 0; /* number of index bits for root table */
11288 var curr = 0; /* number of index bits for current table */
11289 var drop = 0; /* code bits to drop for sub-table */
11290 var left = 0; /* number of prefix codes available */
11291 var used = 0; /* code entries in table used */
11292 var huff = 0; /* Huffman code */
11293 var incr; /* for incrementing code, index */
11294 var fill; /* index for replicating entries */
11295 var low; /* low bits for current root entry */
11296 var mask; /* mask for low root bits */
11297 var next; /* next available space in table */
11298 var base = null; /* base value table to use */
11299 var base_index = 0;
11300 // var shoextra; /* extra bits table to use */
11301 var end; /* use base and extra for symbol > end */
11302 var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
11303 var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
11305 var extra_index = 0;
11307 var here_bits, here_op, here_val;
11310 Process a set of code lengths to create a canonical Huffman code. The
11311 code lengths are lens[0..codes-1]. Each length corresponds to the
11312 symbols 0..codes-1. The Huffman code is generated by first sorting the
11313 symbols by length from short to long, and retaining the symbol order
11314 for codes with equal lengths. Then the code starts with all zero bits
11315 for the first code of the shortest length, and the codes are integer
11316 increments for the same length, and zeros are appended as the length
11317 increases. For the deflate format, these bits are stored backwards
11318 from their more natural integer increment ordering, and so when the
11319 decoding tables are built in the large loop below, the integer codes
11320 are incremented backwards.
11322 This routine assumes, but does not check, that all of the entries in
11323 lens[] are in the range 0..MAXBITS. The caller must assure this.
11324 1..MAXBITS is interpreted as that code length. zero means that that
11325 symbol does not occur in this code.
11327 The codes are sorted by computing a count of codes for each length,
11328 creating from that a table of starting indices for each length in the
11329 sorted table, and then entering the symbols in order in the sorted
11330 table. The sorted table is work[], with that space being provided by
11333 The length counts are used for other purposes as well, i.e. finding
11334 the minimum and maximum length codes, determining if there are any
11335 codes at all, checking for a valid set of lengths, and looking ahead
11336 at length counts to determine sub-table sizes when building the
11340 /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
11341 for (len = 0; len <= MAXBITS; len++) {
11344 for (sym = 0; sym < codes; sym++) {
11345 count[lens[lens_index + sym]]++;
11348 /* bound code lengths, force root to be within code lengths */
11350 for (max = MAXBITS; max >= 1; max--) {
11351 if (count[max] !== 0) { break; }
11356 if (max === 0) { /* no symbols to code at all */
11357 //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */
11358 //table.bits[opts.table_index] = 1; //here.bits = (var char)1;
11359 //table.val[opts.table_index++] = 0; //here.val = (var short)0;
11360 table[table_index++] = (1 << 24) | (64 << 16) | 0;
11363 //table.op[opts.table_index] = 64;
11364 //table.bits[opts.table_index] = 1;
11365 //table.val[opts.table_index++] = 0;
11366 table[table_index++] = (1 << 24) | (64 << 16) | 0;
11369 return 0; /* no symbols, but wait for decoding to report error */
11371 for (min = 1; min < max; min++) {
11372 if (count[min] !== 0) { break; }
11378 /* check for an over-subscribed or incomplete set of lengths */
11380 for (len = 1; len <= MAXBITS; len++) {
11382 left -= count[len];
11385 } /* over-subscribed */
11387 if (left > 0 && (type === CODES || max !== 1)) {
11388 return -1; /* incomplete set */
11391 /* generate offsets into symbol table for each length for sorting */
11393 for (len = 1; len < MAXBITS; len++) {
11394 offs[len + 1] = offs[len] + count[len];
11397 /* sort symbols by length, by symbol order within each length */
11398 for (sym = 0; sym < codes; sym++) {
11399 if (lens[lens_index + sym] !== 0) {
11400 work[offs[lens[lens_index + sym]]++] = sym;
11405 Create and fill in decoding tables. In this loop, the table being
11406 filled is at next and has curr index bits. The code being used is huff
11407 with length len. That code is converted to an index by dropping drop
11408 bits off of the bottom. For codes where len is less than drop + curr,
11409 those top drop + curr - len bits are incremented through all values to
11410 fill the table with replicated entries.
11412 root is the number of index bits for the root table. When len exceeds
11413 root, sub-tables are created pointed to by the root entry with an index
11414 of the low root bits of huff. This is saved in low to check for when a
11415 new sub-table should be started. drop is zero when the root table is
11416 being filled, and drop is root when sub-tables are being filled.
11418 When a new sub-table is needed, it is necessary to look ahead in the
11419 code lengths to determine what size sub-table is needed. The length
11420 counts are used for this, and so count[] is decremented as codes are
11421 entered in the tables.
11423 used keeps track of how many table entries have been allocated from the
11424 provided *table space. It is checked for LENS and DIST tables against
11425 the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
11426 the initial root table size constants. See the comments in inftrees.h
11427 for more information.
11429 sym increments through all symbols, and the loop terminates when
11430 all codes of length max, i.e. all codes, have been processed. This
11431 routine permits incomplete codes, so another loop after this one fills
11432 in the rest of the decoding tables with invalid code markers.
11435 /* set up for code type */
11436 // poor man optimization - use if-else instead of switch,
11437 // to avoid deopts in old v8
11438 if (type === CODES) {
11439 base = extra = work; /* dummy value--not used */
11442 } else if (type === LENS) {
11446 extra_index -= 257;
11449 } else { /* DISTS */
11455 /* initialize opts for loop */
11456 huff = 0; /* starting code */
11457 sym = 0; /* starting code symbol */
11458 len = min; /* starting code length */
11459 next = table_index; /* current table to fill in */
11460 curr = root; /* current table index bits */
11461 drop = 0; /* current bits to drop from code for index */
11462 low = -1; /* trigger new sub-table when len > root */
11463 used = 1 << root; /* use root table entries */
11464 mask = used - 1; /* mask for comparing low */
11466 /* check available table space */
11467 if ((type === LENS && used > ENOUGH_LENS) ||
11468 (type === DISTS && used > ENOUGH_DISTS)) {
11472 /* process all codes and make table entries */
11474 /* create table entry */
11475 here_bits = len - drop;
11476 if (work[sym] < end) {
11478 here_val = work[sym];
11480 else if (work[sym] > end) {
11481 here_op = extra[extra_index + work[sym]];
11482 here_val = base[base_index + work[sym]];
11485 here_op = 32 + 64; /* end of block */
11489 /* replicate for those indices with low len bits equal to huff */
11490 incr = 1 << (len - drop);
11492 min = fill; /* save offset to next table */
11495 table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;
11496 } while (fill !== 0);
11498 /* backwards increment the len-bit code huff */
11499 incr = 1 << (len - 1);
11500 while (huff & incr) {
11510 /* go to next symbol, update count, len */
11512 if (--count[len] === 0) {
11513 if (len === max) { break; }
11514 len = lens[lens_index + work[sym]];
11517 /* create new sub-table if needed */
11518 if (len > root && (huff & mask) !== low) {
11519 /* if first time, transition to sub-tables */
11524 /* increment past last table */
11525 next += min; /* here min is 1 << curr */
11527 /* determine length of next table */
11530 while (curr + drop < max) {
11531 left -= count[curr + drop];
11532 if (left <= 0) { break; }
11537 /* check for enough space */
11539 if ((type === LENS && used > ENOUGH_LENS) ||
11540 (type === DISTS && used > ENOUGH_DISTS)) {
11544 /* point entry in root table to sub-table */
11546 /*table.op[low] = curr;
11547 table.bits[low] = root;
11548 table.val[low] = next - opts.table_index;*/
11549 table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;
11553 /* fill in remaining table entry if code is incomplete (guaranteed to have
11554 at most one remaining entry, since if the code is incomplete, the
11555 maximum code length that was allowed to get this far is one bit) */
11557 //table.op[next + huff] = 64; /* invalid code marker */
11558 //table.bits[next + huff] = len - drop;
11559 //table.val[next + huff] = 0;
11560 table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;
11563 /* set return parameters */
11564 //opts.table_index += used;
11569 },{"../utils/common":26}],36:[function(require,module,exports){
11572 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
11573 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
11575 // This software is provided 'as-is', without any express or implied
11576 // warranty. In no event will the authors be held liable for any damages
11577 // arising from the use of this software.
11579 // Permission is granted to anyone to use this software for any purpose,
11580 // including commercial applications, and to alter it and redistribute it
11581 // freely, subject to the following restrictions:
11583 // 1. The origin of this software must not be misrepresented; you must not
11584 // claim that you wrote the original software. If you use this software
11585 // in a product, an acknowledgment in the product documentation would be
11586 // appreciated but is not required.
11587 // 2. Altered source versions must be plainly marked as such, and must not be
11588 // misrepresented as being the original software.
11589 // 3. This notice may not be removed or altered from any source distribution.
11592 2: 'need dictionary', /* Z_NEED_DICT 2 */
11593 1: 'stream end', /* Z_STREAM_END 1 */
11594 0: '', /* Z_OK 0 */
11595 '-1': 'file error', /* Z_ERRNO (-1) */
11596 '-2': 'stream error', /* Z_STREAM_ERROR (-2) */
11597 '-3': 'data error', /* Z_DATA_ERROR (-3) */
11598 '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */
11599 '-5': 'buffer error', /* Z_BUF_ERROR (-5) */
11600 '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
11603 },{}],37:[function(require,module,exports){
11606 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
11607 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
11609 // This software is provided 'as-is', without any express or implied
11610 // warranty. In no event will the authors be held liable for any damages
11611 // arising from the use of this software.
11613 // Permission is granted to anyone to use this software for any purpose,
11614 // including commercial applications, and to alter it and redistribute it
11615 // freely, subject to the following restrictions:
11617 // 1. The origin of this software must not be misrepresented; you must not
11618 // claim that you wrote the original software. If you use this software
11619 // in a product, an acknowledgment in the product documentation would be
11620 // appreciated but is not required.
11621 // 2. Altered source versions must be plainly marked as such, and must not be
11622 // misrepresented as being the original software.
11623 // 3. This notice may not be removed or altered from any source distribution.
11625 /* eslint-disable space-unary-ops */
11627 var utils = require('../utils/common');
11629 /* Public constants ==========================================================*/
11630 /* ===========================================================================*/
11633 //var Z_FILTERED = 1;
11634 //var Z_HUFFMAN_ONLY = 2;
11637 //var Z_DEFAULT_STRATEGY = 0;
11639 /* Possible values of the data_type field (though see inflate()) */
11642 //var Z_ASCII = 1; // = Z_TEXT
11645 /*============================================================================*/
11648 function zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }
11652 var STORED_BLOCK = 0;
11653 var STATIC_TREES = 1;
11655 /* The three kinds of block type */
11658 var MAX_MATCH = 258;
11659 /* The minimum and maximum match lengths */
11662 /* ===========================================================================
11663 * Internal compression state.
11666 var LENGTH_CODES = 29;
11667 /* number of length codes, not counting the special END_BLOCK code */
11669 var LITERALS = 256;
11670 /* number of literal bytes 0..255 */
11672 var L_CODES = LITERALS + 1 + LENGTH_CODES;
11673 /* number of Literal or Length codes, including the END_BLOCK code */
11676 /* number of distance codes */
11679 /* number of codes used to transfer the bit lengths */
11681 var HEAP_SIZE = 2 * L_CODES + 1;
11682 /* maximum heap size */
11685 /* All codes must not exceed MAX_BITS bits */
11688 /* size of bit buffer in bi_buf */
11691 /* ===========================================================================
11695 var MAX_BL_BITS = 7;
11696 /* Bit length codes must not exceed MAX_BL_BITS bits */
11698 var END_BLOCK = 256;
11699 /* end of block literal code */
11702 /* repeat previous bit length 3-6 times (2 bits of repeat count) */
11704 var REPZ_3_10 = 17;
11705 /* repeat a zero length 3-10 times (3 bits of repeat count) */
11707 var REPZ_11_138 = 18;
11708 /* repeat a zero length 11-138 times (7 bits of repeat count) */
11710 /* eslint-disable comma-spacing,array-bracket-spacing */
11711 var extra_lbits = /* extra bits for each length code */
11712 [0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0];
11714 var extra_dbits = /* extra bits for each distance code */
11715 [0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];
11717 var extra_blbits = /* extra bits for each bit length code */
11718 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];
11721 [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];
11722 /* eslint-enable comma-spacing,array-bracket-spacing */
11724 /* The lengths of the bit length codes are sent in order of decreasing
11725 * probability, to avoid transmitting the lengths for unused bit length codes.
11728 /* ===========================================================================
11729 * Local data. These are initialized only once.
11732 // We pre-fill arrays with 0 to avoid uninitialized gaps
11734 var DIST_CODE_LEN = 512; /* see definition of array dist_code below */
11736 // !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1
11737 var static_ltree = new Array((L_CODES + 2) * 2);
11738 zero(static_ltree);
11739 /* The static literal tree. Since the bit lengths are imposed, there is no
11740 * need for the L_CODES extra codes used during heap construction. However
11741 * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
11745 var static_dtree = new Array(D_CODES * 2);
11746 zero(static_dtree);
11747 /* The static distance tree. (Actually a trivial tree since all codes use
11751 var _dist_code = new Array(DIST_CODE_LEN);
11753 /* Distance codes. The first 256 values correspond to the distances
11754 * 3 .. 258, the last 256 values correspond to the top 8 bits of
11755 * the 15 bit distances.
11758 var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);
11759 zero(_length_code);
11760 /* length code for each normalized match length (0 == MIN_MATCH) */
11762 var base_length = new Array(LENGTH_CODES);
11764 /* First normalized length for each code (0 = MIN_MATCH) */
11766 var base_dist = new Array(D_CODES);
11768 /* First normalized distance for each code (0 = distance of 1) */
11771 function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {
11773 this.static_tree = static_tree; /* static tree or NULL */
11774 this.extra_bits = extra_bits; /* extra bits for each code or NULL */
11775 this.extra_base = extra_base; /* base index for extra_bits */
11776 this.elems = elems; /* max number of elements in the tree */
11777 this.max_length = max_length; /* max bit length for the codes */
11779 // show if `static_tree` has data or dummy - needed for monomorphic objects
11780 this.has_stree = static_tree && static_tree.length;
11786 var static_bl_desc;
11789 function TreeDesc(dyn_tree, stat_desc) {
11790 this.dyn_tree = dyn_tree; /* the dynamic tree */
11791 this.max_code = 0; /* largest code with non zero frequency */
11792 this.stat_desc = stat_desc; /* the corresponding static tree */
11797 function d_code(dist) {
11798 return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];
11802 /* ===========================================================================
11803 * Output a short LSB first on the stream.
11804 * IN assertion: there is enough room in pendingBuf.
11806 function put_short(s, w) {
11807 // put_byte(s, (uch)((w) & 0xff));
11808 // put_byte(s, (uch)((ush)(w) >> 8));
11809 s.pending_buf[s.pending++] = (w) & 0xff;
11810 s.pending_buf[s.pending++] = (w >>> 8) & 0xff;
11814 /* ===========================================================================
11815 * Send a value on a given number of bits.
11816 * IN assertion: length <= 16 and value fits in length bits.
11818 function send_bits(s, value, length) {
11819 if (s.bi_valid > (Buf_size - length)) {
11820 s.bi_buf |= (value << s.bi_valid) & 0xffff;
11821 put_short(s, s.bi_buf);
11822 s.bi_buf = value >> (Buf_size - s.bi_valid);
11823 s.bi_valid += length - Buf_size;
11825 s.bi_buf |= (value << s.bi_valid) & 0xffff;
11826 s.bi_valid += length;
11831 function send_code(s, c, tree) {
11832 send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);
11836 /* ===========================================================================
11837 * Reverse the first len bits of a code, using straightforward code (a faster
11838 * method would use a table)
11839 * IN assertion: 1 <= len <= 15
11841 function bi_reverse(code, len) {
11847 } while (--len > 0);
11852 /* ===========================================================================
11853 * Flush the bit buffer, keeping at most 7 bits in it.
11855 function bi_flush(s) {
11856 if (s.bi_valid === 16) {
11857 put_short(s, s.bi_buf);
11861 } else if (s.bi_valid >= 8) {
11862 s.pending_buf[s.pending++] = s.bi_buf & 0xff;
11869 /* ===========================================================================
11870 * Compute the optimal bit lengths for a tree and update the total bit length
11871 * for the current block.
11872 * IN assertion: the fields freq and dad are set, heap[heap_max] and
11873 * above are the tree nodes sorted by increasing frequency.
11874 * OUT assertions: the field len is set to the optimal bit length, the
11875 * array bl_count contains the frequencies for each bit length.
11876 * The length opt_len is updated; static_len is also updated if stree is
11879 function gen_bitlen(s, desc)
11880 // deflate_state *s;
11881 // tree_desc *desc; /* the tree descriptor */
11883 var tree = desc.dyn_tree;
11884 var max_code = desc.max_code;
11885 var stree = desc.stat_desc.static_tree;
11886 var has_stree = desc.stat_desc.has_stree;
11887 var extra = desc.stat_desc.extra_bits;
11888 var base = desc.stat_desc.extra_base;
11889 var max_length = desc.stat_desc.max_length;
11890 var h; /* heap index */
11891 var n, m; /* iterate over the tree elements */
11892 var bits; /* bit length */
11893 var xbits; /* extra bits */
11894 var f; /* frequency */
11895 var overflow = 0; /* number of elements with bit length too large */
11897 for (bits = 0; bits <= MAX_BITS; bits++) {
11898 s.bl_count[bits] = 0;
11901 /* In a first pass, compute the optimal bit lengths (which may
11902 * overflow in the case of the bit length tree).
11904 tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */
11906 for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {
11908 bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;
11909 if (bits > max_length) {
11913 tree[n * 2 + 1]/*.Len*/ = bits;
11914 /* We overwrite tree[n].Dad which is no longer needed */
11916 if (n > max_code) { continue; } /* not a leaf node */
11918 s.bl_count[bits]++;
11921 xbits = extra[n - base];
11923 f = tree[n * 2]/*.Freq*/;
11924 s.opt_len += f * (bits + xbits);
11926 s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);
11929 if (overflow === 0) { return; }
11931 // Trace((stderr,"\nbit length overflow\n"));
11932 /* This happens for example on obj2 and pic of the Calgary corpus */
11934 /* Find the first bit length which could increase: */
11936 bits = max_length - 1;
11937 while (s.bl_count[bits] === 0) { bits--; }
11938 s.bl_count[bits]--; /* move one leaf down the tree */
11939 s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */
11940 s.bl_count[max_length]--;
11941 /* The brother of the overflow item also moves one step up,
11942 * but this does not affect bl_count[max_length]
11945 } while (overflow > 0);
11947 /* Now recompute all bit lengths, scanning in increasing frequency.
11948 * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
11949 * lengths instead of fixing only the wrong ones. This idea is taken
11950 * from 'ar' written by Haruhiko Okumura.)
11952 for (bits = max_length; bits !== 0; bits--) {
11953 n = s.bl_count[bits];
11956 if (m > max_code) { continue; }
11957 if (tree[m * 2 + 1]/*.Len*/ !== bits) {
11958 // Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
11959 s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;
11960 tree[m * 2 + 1]/*.Len*/ = bits;
11968 /* ===========================================================================
11969 * Generate the codes for a given tree and bit counts (which need not be
11971 * IN assertion: the array bl_count contains the bit length statistics for
11972 * the given tree and the field len is set for all tree elements.
11973 * OUT assertion: the field code is set for all tree elements of non
11974 * zero code length.
11976 function gen_codes(tree, max_code, bl_count)
11977 // ct_data *tree; /* the tree to decorate */
11978 // int max_code; /* largest code with non zero frequency */
11979 // ushf *bl_count; /* number of codes at each bit length */
11981 var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */
11982 var code = 0; /* running code value */
11983 var bits; /* bit index */
11984 var n; /* code index */
11986 /* The distribution counts are first used to generate the code values
11987 * without bit reversal.
11989 for (bits = 1; bits <= MAX_BITS; bits++) {
11990 next_code[bits] = code = (code + bl_count[bits - 1]) << 1;
11992 /* Check that the bit counts in bl_count are consistent. The last code
11993 * must be all ones.
11995 //Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
11996 // "inconsistent bit counts");
11997 //Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
11999 for (n = 0; n <= max_code; n++) {
12000 var len = tree[n * 2 + 1]/*.Len*/;
12001 if (len === 0) { continue; }
12002 /* Now reverse the bits */
12003 tree[n * 2]/*.Code*/ = bi_reverse(next_code[len]++, len);
12005 //Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
12006 // n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
12011 /* ===========================================================================
12012 * Initialize the various 'constant' tables.
12014 function tr_static_init() {
12015 var n; /* iterates over tree elements */
12016 var bits; /* bit counter */
12017 var length; /* length value */
12018 var code; /* code value */
12019 var dist; /* distance index */
12020 var bl_count = new Array(MAX_BITS + 1);
12021 /* number of codes at each bit length for an optimal tree */
12023 // do check in _tr_init()
12024 //if (static_init_done) return;
12026 /* For some embedded targets, global variables are not initialized: */
12027 /*#ifdef NO_INIT_GLOBAL_POINTERS
12028 static_l_desc.static_tree = static_ltree;
12029 static_l_desc.extra_bits = extra_lbits;
12030 static_d_desc.static_tree = static_dtree;
12031 static_d_desc.extra_bits = extra_dbits;
12032 static_bl_desc.extra_bits = extra_blbits;
12035 /* Initialize the mapping length (0..255) -> length code (0..28) */
12037 for (code = 0; code < LENGTH_CODES - 1; code++) {
12038 base_length[code] = length;
12039 for (n = 0; n < (1 << extra_lbits[code]); n++) {
12040 _length_code[length++] = code;
12043 //Assert (length == 256, "tr_static_init: length != 256");
12044 /* Note that the length 255 (match length 258) can be represented
12045 * in two different ways: code 284 + 5 bits or code 285, so we
12046 * overwrite length_code[255] to use the best encoding:
12048 _length_code[length - 1] = code;
12050 /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
12052 for (code = 0; code < 16; code++) {
12053 base_dist[code] = dist;
12054 for (n = 0; n < (1 << extra_dbits[code]); n++) {
12055 _dist_code[dist++] = code;
12058 //Assert (dist == 256, "tr_static_init: dist != 256");
12059 dist >>= 7; /* from now on, all distances are divided by 128 */
12060 for (; code < D_CODES; code++) {
12061 base_dist[code] = dist << 7;
12062 for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {
12063 _dist_code[256 + dist++] = code;
12066 //Assert (dist == 256, "tr_static_init: 256+dist != 512");
12068 /* Construct the codes of the static literal tree */
12069 for (bits = 0; bits <= MAX_BITS; bits++) {
12070 bl_count[bits] = 0;
12075 static_ltree[n * 2 + 1]/*.Len*/ = 8;
12080 static_ltree[n * 2 + 1]/*.Len*/ = 9;
12085 static_ltree[n * 2 + 1]/*.Len*/ = 7;
12090 static_ltree[n * 2 + 1]/*.Len*/ = 8;
12094 /* Codes 286 and 287 do not exist, but we must include them in the
12095 * tree construction to get a canonical Huffman tree (longest code
12098 gen_codes(static_ltree, L_CODES + 1, bl_count);
12100 /* The static distance tree is trivial: */
12101 for (n = 0; n < D_CODES; n++) {
12102 static_dtree[n * 2 + 1]/*.Len*/ = 5;
12103 static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);
12106 // Now data ready and we can init static trees
12107 static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);
12108 static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);
12109 static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);
12111 //static_init_done = true;
12115 /* ===========================================================================
12116 * Initialize a new block.
12118 function init_block(s) {
12119 var n; /* iterates over tree elements */
12121 /* Initialize the trees. */
12122 for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }
12123 for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }
12124 for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }
12126 s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;
12127 s.opt_len = s.static_len = 0;
12128 s.last_lit = s.matches = 0;
12132 /* ===========================================================================
12133 * Flush the bit buffer and align the output on a byte boundary
12135 function bi_windup(s)
12137 if (s.bi_valid > 8) {
12138 put_short(s, s.bi_buf);
12139 } else if (s.bi_valid > 0) {
12140 //put_byte(s, (Byte)s->bi_buf);
12141 s.pending_buf[s.pending++] = s.bi_buf;
12147 /* ===========================================================================
12148 * Copy a stored block, storing first the length and its
12149 * one's complement if requested.
12151 function copy_block(s, buf, len, header)
12153 //charf *buf; /* the input data */
12154 //unsigned len; /* its length */
12155 //int header; /* true if block header must be written */
12157 bi_windup(s); /* align on byte boundary */
12161 put_short(s, ~len);
12164 // put_byte(s, *buf++);
12166 utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);
12170 /* ===========================================================================
12171 * Compares to subtrees, using the tree depth as tie breaker when
12172 * the subtrees have equal frequency. This minimizes the worst case length.
12174 function smaller(tree, n, m, depth) {
12177 return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||
12178 (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));
12181 /* ===========================================================================
12182 * Restore the heap property by moving down the tree starting at node k,
12183 * exchanging a node with the smallest of its two sons if necessary, stopping
12184 * when the heap property is re-established (each father smaller than its
12187 function pqdownheap(s, tree, k)
12188 // deflate_state *s;
12189 // ct_data *tree; /* the tree to restore */
12190 // int k; /* node to move down */
12193 var j = k << 1; /* left son of k */
12194 while (j <= s.heap_len) {
12195 /* Set j to the smallest of the two sons: */
12196 if (j < s.heap_len &&
12197 smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {
12200 /* Exit if v is smaller than both sons */
12201 if (smaller(tree, v, s.heap[j], s.depth)) { break; }
12203 /* Exchange v with the smallest son */
12204 s.heap[k] = s.heap[j];
12207 /* And continue down the tree, setting j to the left son of k */
12214 // inlined manually
12215 // var SMALLEST = 1;
12217 /* ===========================================================================
12218 * Send the block data compressed using the given Huffman trees
12220 function compress_block(s, ltree, dtree)
12221 // deflate_state *s;
12222 // const ct_data *ltree; /* literal tree */
12223 // const ct_data *dtree; /* distance tree */
12225 var dist; /* distance of matched string */
12226 var lc; /* match length or unmatched char (if dist == 0) */
12227 var lx = 0; /* running index in l_buf */
12228 var code; /* the code to send */
12229 var extra; /* number of extra bits to send */
12231 if (s.last_lit !== 0) {
12233 dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);
12234 lc = s.pending_buf[s.l_buf + lx];
12238 send_code(s, lc, ltree); /* send a literal byte */
12239 //Tracecv(isgraph(lc), (stderr," '%c' ", lc));
12241 /* Here, lc is the match length - MIN_MATCH */
12242 code = _length_code[lc];
12243 send_code(s, code + LITERALS + 1, ltree); /* send the length code */
12244 extra = extra_lbits[code];
12246 lc -= base_length[code];
12247 send_bits(s, lc, extra); /* send the extra length bits */
12249 dist--; /* dist is now the match distance - 1 */
12250 code = d_code(dist);
12251 //Assert (code < D_CODES, "bad d_code");
12253 send_code(s, code, dtree); /* send the distance code */
12254 extra = extra_dbits[code];
12256 dist -= base_dist[code];
12257 send_bits(s, dist, extra); /* send the extra distance bits */
12259 } /* literal or match pair ? */
12261 /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
12262 //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
12263 // "pendingBuf overflow");
12265 } while (lx < s.last_lit);
12268 send_code(s, END_BLOCK, ltree);
12272 /* ===========================================================================
12273 * Construct one Huffman tree and assigns the code bit strings and lengths.
12274 * Update the total bit length for the current block.
12275 * IN assertion: the field freq is set for all tree elements.
12276 * OUT assertions: the fields len and code are set to the optimal bit length
12277 * and corresponding code. The length opt_len is updated; static_len is
12278 * also updated if stree is not null. The field max_code is set.
12280 function build_tree(s, desc)
12281 // deflate_state *s;
12282 // tree_desc *desc; /* the tree descriptor */
12284 var tree = desc.dyn_tree;
12285 var stree = desc.stat_desc.static_tree;
12286 var has_stree = desc.stat_desc.has_stree;
12287 var elems = desc.stat_desc.elems;
12288 var n, m; /* iterate over heap elements */
12289 var max_code = -1; /* largest code with non zero frequency */
12290 var node; /* new node being created */
12292 /* Construct the initial heap, with least frequent element in
12293 * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
12294 * heap[0] is not used.
12297 s.heap_max = HEAP_SIZE;
12299 for (n = 0; n < elems; n++) {
12300 if (tree[n * 2]/*.Freq*/ !== 0) {
12301 s.heap[++s.heap_len] = max_code = n;
12305 tree[n * 2 + 1]/*.Len*/ = 0;
12309 /* The pkzip format requires that at least one distance code exists,
12310 * and that at least one bit should be sent even if there is only one
12311 * possible code. So to avoid special checks later on we force at least
12312 * two codes of non zero frequency.
12314 while (s.heap_len < 2) {
12315 node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);
12316 tree[node * 2]/*.Freq*/ = 1;
12321 s.static_len -= stree[node * 2 + 1]/*.Len*/;
12323 /* node is 0 or 1 so it does not have extra bits */
12325 desc.max_code = max_code;
12327 /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
12328 * establish sub-heaps of increasing lengths:
12330 for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }
12332 /* Construct the Huffman tree by repeatedly combining the least two
12335 node = elems; /* next internal node of the tree */
12337 //pqremove(s, tree, n); /* n = node of least frequency */
12339 n = s.heap[1/*SMALLEST*/];
12340 s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];
12341 pqdownheap(s, tree, 1/*SMALLEST*/);
12344 m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */
12346 s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */
12347 s.heap[--s.heap_max] = m;
12349 /* Create a new node father of n and m */
12350 tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;
12351 s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;
12352 tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;
12354 /* and insert the new node in the heap */
12355 s.heap[1/*SMALLEST*/] = node++;
12356 pqdownheap(s, tree, 1/*SMALLEST*/);
12358 } while (s.heap_len >= 2);
12360 s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];
12362 /* At this point, the fields freq and dad are set. We can now
12363 * generate the bit lengths.
12365 gen_bitlen(s, desc);
12367 /* The field len is now set, we can generate the bit codes */
12368 gen_codes(tree, max_code, s.bl_count);
12372 /* ===========================================================================
12373 * Scan a literal or distance tree to determine the frequencies of the codes
12374 * in the bit length tree.
12376 function scan_tree(s, tree, max_code)
12377 // deflate_state *s;
12378 // ct_data *tree; /* the tree to be scanned */
12379 // int max_code; /* and its largest code of non zero frequency */
12381 var n; /* iterates over all tree elements */
12382 var prevlen = -1; /* last emitted length */
12383 var curlen; /* length of current code */
12385 var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */
12387 var count = 0; /* repeat count of the current code */
12388 var max_count = 7; /* max repeat count */
12389 var min_count = 4; /* min repeat count */
12391 if (nextlen === 0) {
12395 tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */
12397 for (n = 0; n <= max_code; n++) {
12399 nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;
12401 if (++count < max_count && curlen === nextlen) {
12404 } else if (count < min_count) {
12405 s.bl_tree[curlen * 2]/*.Freq*/ += count;
12407 } else if (curlen !== 0) {
12409 if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }
12410 s.bl_tree[REP_3_6 * 2]/*.Freq*/++;
12412 } else if (count <= 10) {
12413 s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;
12416 s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;
12422 if (nextlen === 0) {
12426 } else if (curlen === nextlen) {
12438 /* ===========================================================================
12439 * Send a literal or distance tree in compressed form, using the codes in
12442 function send_tree(s, tree, max_code)
12443 // deflate_state *s;
12444 // ct_data *tree; /* the tree to be scanned */
12445 // int max_code; /* and its largest code of non zero frequency */
12447 var n; /* iterates over all tree elements */
12448 var prevlen = -1; /* last emitted length */
12449 var curlen; /* length of current code */
12451 var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */
12453 var count = 0; /* repeat count of the current code */
12454 var max_count = 7; /* max repeat count */
12455 var min_count = 4; /* min repeat count */
12457 /* tree[max_code+1].Len = -1; */ /* guard already set */
12458 if (nextlen === 0) {
12463 for (n = 0; n <= max_code; n++) {
12465 nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;
12467 if (++count < max_count && curlen === nextlen) {
12470 } else if (count < min_count) {
12471 do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);
12473 } else if (curlen !== 0) {
12474 if (curlen !== prevlen) {
12475 send_code(s, curlen, s.bl_tree);
12478 //Assert(count >= 3 && count <= 6, " 3_6?");
12479 send_code(s, REP_3_6, s.bl_tree);
12480 send_bits(s, count - 3, 2);
12482 } else if (count <= 10) {
12483 send_code(s, REPZ_3_10, s.bl_tree);
12484 send_bits(s, count - 3, 3);
12487 send_code(s, REPZ_11_138, s.bl_tree);
12488 send_bits(s, count - 11, 7);
12493 if (nextlen === 0) {
12497 } else if (curlen === nextlen) {
12509 /* ===========================================================================
12510 * Construct the Huffman tree for the bit lengths and return the index in
12511 * bl_order of the last bit length code to send.
12513 function build_bl_tree(s) {
12514 var max_blindex; /* index of last bit length code of non zero freq */
12516 /* Determine the bit length frequencies for literal and distance trees */
12517 scan_tree(s, s.dyn_ltree, s.l_desc.max_code);
12518 scan_tree(s, s.dyn_dtree, s.d_desc.max_code);
12520 /* Build the bit length tree: */
12521 build_tree(s, s.bl_desc);
12522 /* opt_len now includes the length of the tree representations, except
12523 * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
12526 /* Determine the number of bit length codes to send. The pkzip format
12527 * requires that at least 4 bit length codes be sent. (appnote.txt says
12528 * 3 but the actual value used is 4.)
12530 for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {
12531 if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {
12535 /* Update opt_len to include the bit length tree and counts */
12536 s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;
12537 //Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
12538 // s->opt_len, s->static_len));
12540 return max_blindex;
12544 /* ===========================================================================
12545 * Send the header for a block using dynamic Huffman trees: the counts, the
12546 * lengths of the bit length codes, the literal tree and the distance tree.
12547 * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
12549 function send_all_trees(s, lcodes, dcodes, blcodes)
12550 // deflate_state *s;
12551 // int lcodes, dcodes, blcodes; /* number of codes for each tree */
12553 var rank; /* index in bl_order */
12555 //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
12556 //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
12557 // "too many codes");
12558 //Tracev((stderr, "\nbl counts: "));
12559 send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */
12560 send_bits(s, dcodes - 1, 5);
12561 send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */
12562 for (rank = 0; rank < blcodes; rank++) {
12563 //Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
12564 send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);
12566 //Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
12568 send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */
12569 //Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
12571 send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */
12572 //Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
12576 /* ===========================================================================
12577 * Check if the data type is TEXT or BINARY, using the following algorithm:
12578 * - TEXT if the two conditions below are satisfied:
12579 * a) There are no non-portable control characters belonging to the
12580 * "black list" (0..6, 14..25, 28..31).
12581 * b) There is at least one printable character belonging to the
12582 * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
12583 * - BINARY otherwise.
12584 * - The following partially-portable control characters form a
12585 * "gray list" that is ignored in this detection algorithm:
12586 * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
12587 * IN assertion: the fields Freq of dyn_ltree are set.
12589 function detect_data_type(s) {
12590 /* black_mask is the bit mask of black-listed bytes
12591 * set bits 0..6, 14..25, and 28..31
12592 * 0xf3ffc07f = binary 11110011111111111100000001111111
12594 var black_mask = 0xf3ffc07f;
12597 /* Check for non-textual ("black-listed") bytes. */
12598 for (n = 0; n <= 31; n++, black_mask >>>= 1) {
12599 if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {
12604 /* Check for textual ("white-listed") bytes. */
12605 if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||
12606 s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {
12609 for (n = 32; n < LITERALS; n++) {
12610 if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {
12615 /* There are no "black-listed" or "white-listed" bytes:
12616 * this stream either is empty or has tolerated ("gray-listed") bytes only.
12622 var static_init_done = false;
12624 /* ===========================================================================
12625 * Initialize the tree data structures for a new zlib stream.
12627 function _tr_init(s)
12630 if (!static_init_done) {
12632 static_init_done = true;
12635 s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);
12636 s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);
12637 s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);
12642 /* Initialize the first block of the first file: */
12647 /* ===========================================================================
12648 * Send a stored block
12650 function _tr_stored_block(s, buf, stored_len, last)
12652 //charf *buf; /* input block */
12653 //ulg stored_len; /* length of input block */
12654 //int last; /* one if this is the last block for a file */
12656 send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */
12657 copy_block(s, buf, stored_len, true); /* with header */
12661 /* ===========================================================================
12662 * Send one empty static block to give enough lookahead for inflate.
12663 * This takes 10 bits, of which 7 may remain in the bit buffer.
12665 function _tr_align(s) {
12666 send_bits(s, STATIC_TREES << 1, 3);
12667 send_code(s, END_BLOCK, static_ltree);
12672 /* ===========================================================================
12673 * Determine the best encoding for the current block: dynamic trees, static
12674 * trees or store, and output the encoded block to the zip file.
12676 function _tr_flush_block(s, buf, stored_len, last)
12678 //charf *buf; /* input block, or NULL if too old */
12679 //ulg stored_len; /* length of input block */
12680 //int last; /* one if this is the last block for a file */
12682 var opt_lenb, static_lenb; /* opt_len and static_len in bytes */
12683 var max_blindex = 0; /* index of last bit length code of non zero freq */
12685 /* Build the Huffman trees unless a stored block is forced */
12688 /* Check if the file is binary or text */
12689 if (s.strm.data_type === Z_UNKNOWN) {
12690 s.strm.data_type = detect_data_type(s);
12693 /* Construct the literal and distance trees */
12694 build_tree(s, s.l_desc);
12695 // Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
12696 // s->static_len));
12698 build_tree(s, s.d_desc);
12699 // Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
12700 // s->static_len));
12701 /* At this point, opt_len and static_len are the total bit lengths of
12702 * the compressed block data, excluding the tree representations.
12705 /* Build the bit length tree for the above two trees, and get the index
12706 * in bl_order of the last bit length code to send.
12708 max_blindex = build_bl_tree(s);
12710 /* Determine the best encoding. Compute the block lengths in bytes. */
12711 opt_lenb = (s.opt_len + 3 + 7) >>> 3;
12712 static_lenb = (s.static_len + 3 + 7) >>> 3;
12714 // Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
12715 // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
12718 if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }
12721 // Assert(buf != (char*)0, "lost buf");
12722 opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
12725 if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {
12726 /* 4: two words for the lengths */
12728 /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
12729 * Otherwise we can't have processed more than WSIZE input bytes since
12730 * the last block flush, because compression would have been
12731 * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
12732 * transform a block into a stored block.
12734 _tr_stored_block(s, buf, stored_len, last);
12736 } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {
12738 send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);
12739 compress_block(s, static_ltree, static_dtree);
12742 send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);
12743 send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);
12744 compress_block(s, s.dyn_ltree, s.dyn_dtree);
12746 // Assert (s->compressed_len == s->bits_sent, "bad compressed size");
12747 /* The above check is made mod 2^32, for files larger than 512 MB
12748 * and uLong implemented on 32 bits.
12755 // Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
12756 // s->compressed_len-7*last));
12759 /* ===========================================================================
12760 * Save the match info and tally the frequency counts. Return true if
12761 * the current block must be flushed.
12763 function _tr_tally(s, dist, lc)
12764 // deflate_state *s;
12765 // unsigned dist; /* distance of matched string */
12766 // unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
12768 //var out_length, in_length, dcode;
12770 s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;
12771 s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;
12773 s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;
12777 /* lc is the unmatched char */
12778 s.dyn_ltree[lc * 2]/*.Freq*/++;
12781 /* Here, lc is the match length - MIN_MATCH */
12782 dist--; /* dist = match distance - 1 */
12783 //Assert((ush)dist < (ush)MAX_DIST(s) &&
12784 // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
12785 // (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
12787 s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;
12788 s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;
12791 // (!) This block is disabled in zlib defaults,
12792 // don't enable it for binary compatibility
12794 //#ifdef TRUNCATE_BLOCK
12795 // /* Try to guess if it is profitable to stop the current block here */
12796 // if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {
12797 // /* Compute an upper bound for the compressed length */
12798 // out_length = s.last_lit*8;
12799 // in_length = s.strstart - s.block_start;
12801 // for (dcode = 0; dcode < D_CODES; dcode++) {
12802 // out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);
12804 // out_length >>>= 3;
12805 // //Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
12806 // // s->last_lit, in_length, out_length,
12807 // // 100L - out_length*100L/in_length));
12808 // if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {
12814 return (s.last_lit === s.lit_bufsize - 1);
12815 /* We avoid equality with lit_bufsize because of wraparound at 64K
12816 * on 16 bit machines and because stored blocks are restricted to
12821 exports._tr_init = _tr_init;
12822 exports._tr_stored_block = _tr_stored_block;
12823 exports._tr_flush_block = _tr_flush_block;
12824 exports._tr_tally = _tr_tally;
12825 exports._tr_align = _tr_align;
12827 },{"../utils/common":26}],38:[function(require,module,exports){
12830 // (C) 1995-2013 Jean-loup Gailly and Mark Adler
12831 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
12833 // This software is provided 'as-is', without any express or implied
12834 // warranty. In no event will the authors be held liable for any damages
12835 // arising from the use of this software.
12837 // Permission is granted to anyone to use this software for any purpose,
12838 // including commercial applications, and to alter it and redistribute it
12839 // freely, subject to the following restrictions:
12841 // 1. The origin of this software must not be misrepresented; you must not
12842 // claim that you wrote the original software. If you use this software
12843 // in a product, an acknowledgment in the product documentation would be
12844 // appreciated but is not required.
12845 // 2. Altered source versions must be plainly marked as such, and must not be
12846 // misrepresented as being the original software.
12847 // 3. This notice may not be removed or altered from any source distribution.
12849 function ZStream() {
12850 /* next input byte */
12851 this.input = null; // JS specific, because we have no pointers
12853 /* number of bytes available at input */
12855 /* total number of input bytes read so far */
12857 /* next output byte should be put there */
12858 this.output = null; // JS specific, because we have no pointers
12860 /* remaining free space at output */
12861 this.avail_out = 0;
12862 /* total number of bytes output so far */
12863 this.total_out = 0;
12864 /* last error message, NULL if no error */
12865 this.msg = ''/*Z_NULL*/;
12866 /* not visible by applications */
12868 /* best guess about the data type: binary or text */
12869 this.data_type = 2/*Z_UNKNOWN*/;
12870 /* adler32 value of the uncompressed data */
12874 module.exports = ZStream;
12876 },{}],39:[function(require,module,exports){
12877 (function (process){
12878 // Copyright Joyent, Inc. and other Node contributors.
12880 // Permission is hereby granted, free of charge, to any person obtaining a
12881 // copy of this software and associated documentation files (the
12882 // "Software"), to deal in the Software without restriction, including
12883 // without limitation the rights to use, copy, modify, merge, publish,
12884 // distribute, sublicense, and/or sell copies of the Software, and to permit
12885 // persons to whom the Software is furnished to do so, subject to the
12886 // following conditions:
12888 // The above copyright notice and this permission notice shall be included
12889 // in all copies or substantial portions of the Software.
12891 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12892 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12893 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
12894 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
12895 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
12896 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
12897 // USE OR OTHER DEALINGS IN THE SOFTWARE.
12899 // resolves . and .. elements in a path array with directory names there
12900 // must be no slashes, empty elements, or device names (c:\) in the array
12901 // (so also no leading and trailing slashes - it does not distinguish
12902 // relative and absolute paths)
12903 function normalizeArray(parts, allowAboveRoot) {
12904 // if the path tries to go above the root, `up` ends up > 0
12906 for (var i = parts.length - 1; i >= 0; i--) {
12907 var last = parts[i];
12908 if (last === '.') {
12909 parts.splice(i, 1);
12910 } else if (last === '..') {
12911 parts.splice(i, 1);
12914 parts.splice(i, 1);
12919 // if the path is allowed to go above the root, restore leading ..s
12920 if (allowAboveRoot) {
12922 parts.unshift('..');
12929 // Split a filename into [root, dir, basename, ext], unix version
12930 // 'root' is just a slash, or nothing.
12932 /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
12933 var splitPath = function(filename) {
12934 return splitPathRe.exec(filename).slice(1);
12937 // path.resolve([from ...], to)
12939 exports.resolve = function() {
12940 var resolvedPath = '',
12941 resolvedAbsolute = false;
12943 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
12944 var path = (i >= 0) ? arguments[i] : process.cwd();
12946 // Skip empty and invalid entries
12947 if (typeof path !== 'string') {
12948 throw new TypeError('Arguments to path.resolve must be strings');
12949 } else if (!path) {
12953 resolvedPath = path + '/' + resolvedPath;
12954 resolvedAbsolute = path.charAt(0) === '/';
12957 // At this point the path should be resolved to a full absolute path, but
12958 // handle relative paths to be safe (might happen when process.cwd() fails)
12960 // Normalize the path
12961 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
12963 }), !resolvedAbsolute).join('/');
12965 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
12968 // path.normalize(path)
12970 exports.normalize = function(path) {
12971 var isAbsolute = exports.isAbsolute(path),
12972 trailingSlash = substr(path, -1) === '/';
12974 // Normalize the path
12975 path = normalizeArray(filter(path.split('/'), function(p) {
12977 }), !isAbsolute).join('/');
12979 if (!path && !isAbsolute) {
12982 if (path && trailingSlash) {
12986 return (isAbsolute ? '/' : '') + path;
12990 exports.isAbsolute = function(path) {
12991 return path.charAt(0) === '/';
12995 exports.join = function() {
12996 var paths = Array.prototype.slice.call(arguments, 0);
12997 return exports.normalize(filter(paths, function(p, index) {
12998 if (typeof p !== 'string') {
12999 throw new TypeError('Arguments to path.join must be strings');
13006 // path.relative(from, to)
13008 exports.relative = function(from, to) {
13009 from = exports.resolve(from).substr(1);
13010 to = exports.resolve(to).substr(1);
13012 function trim(arr) {
13014 for (; start < arr.length; start++) {
13015 if (arr[start] !== '') break;
13018 var end = arr.length - 1;
13019 for (; end >= 0; end--) {
13020 if (arr[end] !== '') break;
13023 if (start > end) return [];
13024 return arr.slice(start, end - start + 1);
13027 var fromParts = trim(from.split('/'));
13028 var toParts = trim(to.split('/'));
13030 var length = Math.min(fromParts.length, toParts.length);
13031 var samePartsLength = length;
13032 for (var i = 0; i < length; i++) {
13033 if (fromParts[i] !== toParts[i]) {
13034 samePartsLength = i;
13039 var outputParts = [];
13040 for (var i = samePartsLength; i < fromParts.length; i++) {
13041 outputParts.push('..');
13044 outputParts = outputParts.concat(toParts.slice(samePartsLength));
13046 return outputParts.join('/');
13050 exports.delimiter = ':';
13052 exports.dirname = function(path) {
13053 var result = splitPath(path),
13057 if (!root && !dir) {
13058 // No dirname whatsoever
13063 // It has a dirname, strip trailing slash
13064 dir = dir.substr(0, dir.length - 1);
13071 exports.basename = function(path, ext) {
13072 var f = splitPath(path)[2];
13073 // TODO: make this comparison case-insensitive on windows?
13074 if (ext && f.substr(-1 * ext.length) === ext) {
13075 f = f.substr(0, f.length - ext.length);
13081 exports.extname = function(path) {
13082 return splitPath(path)[3];
13085 function filter (xs, f) {
13086 if (xs.filter) return xs.filter(f);
13088 for (var i = 0; i < xs.length; i++) {
13089 if (f(xs[i], i, xs)) res.push(xs[i]);
13094 // String.prototype.substr - negative index don't work in IE8
13095 var substr = 'ab'.substr(-1) === 'b'
13096 ? function (str, start, len) { return str.substr(start, len) }
13097 : function (str, start, len) {
13098 if (start < 0) start = str.length + start;
13099 return str.substr(start, len);
13103 }).call(this,require('_process'))
13105 },{"_process":7}],40:[function(require,module,exports){
13108 module.exports = Pbf;
13110 var ieee754 = require('ieee754');
13112 function Pbf(buf) {
13113 this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
13116 this.length = this.buf.length;
13119 Pbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum
13120 Pbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64
13121 Pbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields
13122 Pbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32
13124 var SHIFT_LEFT_32 = (1 << 16) * (1 << 16),
13125 SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
13127 // Threshold chosen based on both benchmarking and knowledge about browser string
13128 // data structures (which currently switch structure types at 12 bytes or more)
13129 var TEXT_DECODER_MIN_LENGTH = 12;
13130 var utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf8');
13134 destroy: function() {
13138 // === READING =================================================================
13140 readFields: function(readField, result, end) {
13141 end = end || this.length;
13143 while (this.pos < end) {
13144 var val = this.readVarint(),
13146 startPos = this.pos;
13148 this.type = val & 0x7;
13149 readField(tag, result, this);
13151 if (this.pos === startPos) this.skip(val);
13156 readMessage: function(readField, result) {
13157 return this.readFields(readField, result, this.readVarint() + this.pos);
13160 readFixed32: function() {
13161 var val = readUInt32(this.buf, this.pos);
13166 readSFixed32: function() {
13167 var val = readInt32(this.buf, this.pos);
13172 // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
13174 readFixed64: function() {
13175 var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
13180 readSFixed64: function() {
13181 var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
13186 readFloat: function() {
13187 var val = ieee754.read(this.buf, this.pos, true, 23, 4);
13192 readDouble: function() {
13193 var val = ieee754.read(this.buf, this.pos, true, 52, 8);
13198 readVarint: function(isSigned) {
13199 var buf = this.buf,
13202 b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;
13203 b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;
13204 b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;
13205 b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;
13206 b = buf[this.pos]; val |= (b & 0x0f) << 28;
13208 return readVarintRemainder(val, isSigned, this);
13211 readVarint64: function() { // for compatibility with v2.0.1
13212 return this.readVarint(true);
13215 readSVarint: function() {
13216 var num = this.readVarint();
13217 return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding
13220 readBoolean: function() {
13221 return Boolean(this.readVarint());
13224 readString: function() {
13225 var end = this.readVarint() + this.pos;
13226 var pos = this.pos;
13229 if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
13230 // longer strings are fast with the built-in browser TextDecoder API
13231 return readUtf8TextDecoder(this.buf, pos, end);
13233 // short strings are fast with our custom implementation
13234 return readUtf8(this.buf, pos, end);
13237 readBytes: function() {
13238 var end = this.readVarint() + this.pos,
13239 buffer = this.buf.subarray(this.pos, end);
13244 // verbose for performance reasons; doesn't affect gzipped size
13246 readPackedVarint: function(arr, isSigned) {
13247 if (this.type !== Pbf.Bytes) return arr.push(this.readVarint(isSigned));
13248 var end = readPackedEnd(this);
13250 while (this.pos < end) arr.push(this.readVarint(isSigned));
13253 readPackedSVarint: function(arr) {
13254 if (this.type !== Pbf.Bytes) return arr.push(this.readSVarint());
13255 var end = readPackedEnd(this);
13257 while (this.pos < end) arr.push(this.readSVarint());
13260 readPackedBoolean: function(arr) {
13261 if (this.type !== Pbf.Bytes) return arr.push(this.readBoolean());
13262 var end = readPackedEnd(this);
13264 while (this.pos < end) arr.push(this.readBoolean());
13267 readPackedFloat: function(arr) {
13268 if (this.type !== Pbf.Bytes) return arr.push(this.readFloat());
13269 var end = readPackedEnd(this);
13271 while (this.pos < end) arr.push(this.readFloat());
13274 readPackedDouble: function(arr) {
13275 if (this.type !== Pbf.Bytes) return arr.push(this.readDouble());
13276 var end = readPackedEnd(this);
13278 while (this.pos < end) arr.push(this.readDouble());
13281 readPackedFixed32: function(arr) {
13282 if (this.type !== Pbf.Bytes) return arr.push(this.readFixed32());
13283 var end = readPackedEnd(this);
13285 while (this.pos < end) arr.push(this.readFixed32());
13288 readPackedSFixed32: function(arr) {
13289 if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed32());
13290 var end = readPackedEnd(this);
13292 while (this.pos < end) arr.push(this.readSFixed32());
13295 readPackedFixed64: function(arr) {
13296 if (this.type !== Pbf.Bytes) return arr.push(this.readFixed64());
13297 var end = readPackedEnd(this);
13299 while (this.pos < end) arr.push(this.readFixed64());
13302 readPackedSFixed64: function(arr) {
13303 if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed64());
13304 var end = readPackedEnd(this);
13306 while (this.pos < end) arr.push(this.readSFixed64());
13310 skip: function(val) {
13311 var type = val & 0x7;
13312 if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}
13313 else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;
13314 else if (type === Pbf.Fixed32) this.pos += 4;
13315 else if (type === Pbf.Fixed64) this.pos += 8;
13316 else throw new Error('Unimplemented type: ' + type);
13319 // === WRITING =================================================================
13321 writeTag: function(tag, type) {
13322 this.writeVarint((tag << 3) | type);
13325 realloc: function(min) {
13326 var length = this.length || 16;
13328 while (length < this.pos + min) length *= 2;
13330 if (length !== this.length) {
13331 var buf = new Uint8Array(length);
13334 this.length = length;
13338 finish: function() {
13339 this.length = this.pos;
13341 return this.buf.subarray(0, this.length);
13344 writeFixed32: function(val) {
13346 writeInt32(this.buf, val, this.pos);
13350 writeSFixed32: function(val) {
13352 writeInt32(this.buf, val, this.pos);
13356 writeFixed64: function(val) {
13358 writeInt32(this.buf, val & -1, this.pos);
13359 writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
13363 writeSFixed64: function(val) {
13365 writeInt32(this.buf, val & -1, this.pos);
13366 writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
13370 writeVarint: function(val) {
13373 if (val > 0xfffffff || val < 0) {
13374 writeBigVarint(val, this);
13380 this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
13381 this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
13382 this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
13383 this.buf[this.pos++] = (val >>> 7) & 0x7f;
13386 writeSVarint: function(val) {
13387 this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
13390 writeBoolean: function(val) {
13391 this.writeVarint(Boolean(val));
13394 writeString: function(str) {
13396 this.realloc(str.length * 4);
13398 this.pos++; // reserve 1 byte for short string length
13400 var startPos = this.pos;
13401 // write the string directly to the buffer and see how much was written
13402 this.pos = writeUtf8(this.buf, str, this.pos);
13403 var len = this.pos - startPos;
13405 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
13407 // finally, write the message length in the reserved place and restore the position
13408 this.pos = startPos - 1;
13409 this.writeVarint(len);
13413 writeFloat: function(val) {
13415 ieee754.write(this.buf, val, this.pos, true, 23, 4);
13419 writeDouble: function(val) {
13421 ieee754.write(this.buf, val, this.pos, true, 52, 8);
13425 writeBytes: function(buffer) {
13426 var len = buffer.length;
13427 this.writeVarint(len);
13429 for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];
13432 writeRawMessage: function(fn, obj) {
13433 this.pos++; // reserve 1 byte for short message length
13435 // write the message directly to the buffer and see how much was written
13436 var startPos = this.pos;
13438 var len = this.pos - startPos;
13440 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
13442 // finally, write the message length in the reserved place and restore the position
13443 this.pos = startPos - 1;
13444 this.writeVarint(len);
13448 writeMessage: function(tag, fn, obj) {
13449 this.writeTag(tag, Pbf.Bytes);
13450 this.writeRawMessage(fn, obj);
13453 writePackedVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedVarint, arr); },
13454 writePackedSVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSVarint, arr); },
13455 writePackedBoolean: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedBoolean, arr); },
13456 writePackedFloat: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFloat, arr); },
13457 writePackedDouble: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedDouble, arr); },
13458 writePackedFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed32, arr); },
13459 writePackedSFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr); },
13460 writePackedFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed64, arr); },
13461 writePackedSFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr); },
13463 writeBytesField: function(tag, buffer) {
13464 this.writeTag(tag, Pbf.Bytes);
13465 this.writeBytes(buffer);
13467 writeFixed32Field: function(tag, val) {
13468 this.writeTag(tag, Pbf.Fixed32);
13469 this.writeFixed32(val);
13471 writeSFixed32Field: function(tag, val) {
13472 this.writeTag(tag, Pbf.Fixed32);
13473 this.writeSFixed32(val);
13475 writeFixed64Field: function(tag, val) {
13476 this.writeTag(tag, Pbf.Fixed64);
13477 this.writeFixed64(val);
13479 writeSFixed64Field: function(tag, val) {
13480 this.writeTag(tag, Pbf.Fixed64);
13481 this.writeSFixed64(val);
13483 writeVarintField: function(tag, val) {
13484 this.writeTag(tag, Pbf.Varint);
13485 this.writeVarint(val);
13487 writeSVarintField: function(tag, val) {
13488 this.writeTag(tag, Pbf.Varint);
13489 this.writeSVarint(val);
13491 writeStringField: function(tag, str) {
13492 this.writeTag(tag, Pbf.Bytes);
13493 this.writeString(str);
13495 writeFloatField: function(tag, val) {
13496 this.writeTag(tag, Pbf.Fixed32);
13497 this.writeFloat(val);
13499 writeDoubleField: function(tag, val) {
13500 this.writeTag(tag, Pbf.Fixed64);
13501 this.writeDouble(val);
13503 writeBooleanField: function(tag, val) {
13504 this.writeVarintField(tag, Boolean(val));
13508 function readVarintRemainder(l, s, p) {
13512 b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);
13513 b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);
13514 b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);
13515 b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);
13516 b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);
13517 b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);
13519 throw new Error('Expected varint not more than 10 bytes');
13522 function readPackedEnd(pbf) {
13523 return pbf.type === Pbf.Bytes ?
13524 pbf.readVarint() + pbf.pos : pbf.pos + 1;
13527 function toNum(low, high, isSigned) {
13529 return high * 0x100000000 + (low >>> 0);
13532 return ((high >>> 0) * 0x100000000) + (low >>> 0);
13535 function writeBigVarint(val, pbf) {
13539 low = (val % 0x100000000) | 0;
13540 high = (val / 0x100000000) | 0;
13542 low = ~(-val % 0x100000000);
13543 high = ~(-val / 0x100000000);
13545 if (low ^ 0xffffffff) {
13546 low = (low + 1) | 0;
13549 high = (high + 1) | 0;
13553 if (val >= 0x10000000000000000 || val < -0x10000000000000000) {
13554 throw new Error('Given varint doesn\'t fit into 10 bytes');
13559 writeBigVarintLow(low, high, pbf);
13560 writeBigVarintHigh(high, pbf);
13563 function writeBigVarintLow(low, high, pbf) {
13564 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
13565 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
13566 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
13567 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
13568 pbf.buf[pbf.pos] = low & 0x7f;
13571 function writeBigVarintHigh(high, pbf) {
13572 var lsb = (high & 0x07) << 4;
13574 pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;
13575 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
13576 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
13577 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
13578 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
13579 pbf.buf[pbf.pos++] = high & 0x7f;
13582 function makeRoomForExtraLength(startPos, len, pbf) {
13584 len <= 0x3fff ? 1 :
13585 len <= 0x1fffff ? 2 :
13586 len <= 0xfffffff ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
13588 // if 1 byte isn't enough for encoding message length, shift the data to the right
13589 pbf.realloc(extraLen);
13590 for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];
13593 function writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }
13594 function writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }
13595 function writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }
13596 function writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }
13597 function writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }
13598 function writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }
13599 function writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }
13600 function writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }
13601 function writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }
13603 // Buffer code below from https://github.com/feross/buffer, MIT-licensed
13605 function readUInt32(buf, pos) {
13606 return ((buf[pos]) |
13607 (buf[pos + 1] << 8) |
13608 (buf[pos + 2] << 16)) +
13609 (buf[pos + 3] * 0x1000000);
13612 function writeInt32(buf, val, pos) {
13614 buf[pos + 1] = (val >>> 8);
13615 buf[pos + 2] = (val >>> 16);
13616 buf[pos + 3] = (val >>> 24);
13619 function readInt32(buf, pos) {
13620 return ((buf[pos]) |
13621 (buf[pos + 1] << 8) |
13622 (buf[pos + 2] << 16)) +
13623 (buf[pos + 3] << 24);
13626 function readUtf8(buf, pos, end) {
13632 var c = null; // codepoint
13633 var bytesPerSequence =
13638 if (i + bytesPerSequence > end) break;
13642 if (bytesPerSequence === 1) {
13646 } else if (bytesPerSequence === 2) {
13648 if ((b1 & 0xC0) === 0x80) {
13649 c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);
13654 } else if (bytesPerSequence === 3) {
13657 if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {
13658 c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);
13659 if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {
13663 } else if (bytesPerSequence === 4) {
13667 if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
13668 c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);
13669 if (c <= 0xFFFF || c >= 0x110000) {
13677 bytesPerSequence = 1;
13679 } else if (c > 0xFFFF) {
13681 str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);
13682 c = 0xDC00 | c & 0x3FF;
13685 str += String.fromCharCode(c);
13686 i += bytesPerSequence;
13692 function readUtf8TextDecoder(buf, pos, end) {
13693 return utf8TextDecoder.decode(buf.subarray(pos, end));
13696 function writeUtf8(buf, str, pos) {
13697 for (var i = 0, c, lead; i < str.length; i++) {
13698 c = str.charCodeAt(i); // code point
13700 if (c > 0xD7FF && c < 0xE000) {
13709 c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;
13713 if (c > 0xDBFF || (i + 1 === str.length)) {
13733 buf[pos++] = c >> 0x6 | 0xC0;
13736 buf[pos++] = c >> 0xC | 0xE0;
13738 buf[pos++] = c >> 0x12 | 0xF0;
13739 buf[pos++] = c >> 0xC & 0x3F | 0x80;
13741 buf[pos++] = c >> 0x6 & 0x3F | 0x80;
13743 buf[pos++] = c & 0x3F | 0x80;
13749 },{"ieee754":41}],41:[function(require,module,exports){
13750 exports.read = function (buffer, offset, isLE, mLen, nBytes) {
13752 var eLen = (nBytes * 8) - mLen - 1
13753 var eMax = (1 << eLen) - 1
13754 var eBias = eMax >> 1
13756 var i = isLE ? (nBytes - 1) : 0
13757 var d = isLE ? -1 : 1
13758 var s = buffer[offset + i]
13762 e = s & ((1 << (-nBits)) - 1)
13765 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13767 m = e & ((1 << (-nBits)) - 1)
13770 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13774 } else if (e === eMax) {
13775 return m ? NaN : ((s ? -1 : 1) * Infinity)
13777 m = m + Math.pow(2, mLen)
13780 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
13783 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
13785 var eLen = (nBytes * 8) - mLen - 1
13786 var eMax = (1 << eLen) - 1
13787 var eBias = eMax >> 1
13788 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
13789 var i = isLE ? 0 : (nBytes - 1)
13790 var d = isLE ? 1 : -1
13791 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
13793 value = Math.abs(value)
13795 if (isNaN(value) || value === Infinity) {
13796 m = isNaN(value) ? 1 : 0
13799 e = Math.floor(Math.log(value) / Math.LN2)
13800 if (value * (c = Math.pow(2, -e)) < 1) {
13804 if (e + eBias >= 1) {
13807 value += rt * Math.pow(2, 1 - eBias)
13809 if (value * c >= 2) {
13814 if (e + eBias >= eMax) {
13817 } else if (e + eBias >= 1) {
13818 m = ((value * c) - 1) * Math.pow(2, mLen)
13821 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
13826 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
13828 e = (e << mLen) | m
13830 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
13832 buffer[offset + i - d] |= s * 128
13835 },{}],42:[function(require,module,exports){
13836 !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t=t||self).RBush=i()}(this,function(){"use strict";function t(t,r,e,a,h){!function t(n,r,e,a,h){for(;a>e;){if(a-e>600){var o=a-e+1,s=r-e+1,l=Math.log(o),f=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*f*(o-f)/o)*(s-o/2<0?-1:1),m=Math.max(e,Math.floor(r-s*f/o+u)),c=Math.min(a,Math.floor(r+(o-s)*f/o+u));t(n,r,m,c,h)}var p=n[r],d=e,x=a;for(i(n,e,r),h(n[a],p)>0&&i(n,e,a);d<x;){for(i(n,d,x),d++,x--;h(n[d],p)<0;)d++;for(;h(n[x],p)>0;)x--}0===h(n[e],p)?i(n,e,x):i(n,++x,a),x<=r&&(e=x+1),r<=x&&(a=x-1)}}(t,r,e||0,a||t.length-1,h||n)}function i(t,i,n){var r=t[i];t[i]=t[n],t[n]=r}function n(t,i){return t<i?-1:t>i?1:0}var r=function(t){void 0===t&&(t=9),this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function e(t,i,n){if(!n)return i.indexOf(t);for(var r=0;r<i.length;r++)if(n(t,i[r]))return r;return-1}function a(t,i){h(t,0,t.children.length,i,t)}function h(t,i,n,r,e){e||(e=p(null)),e.minX=1/0,e.minY=1/0,e.maxX=-1/0,e.maxY=-1/0;for(var a=i;a<n;a++){var h=t.children[a];o(e,t.leaf?r(h):h)}return e}function o(t,i){return t.minX=Math.min(t.minX,i.minX),t.minY=Math.min(t.minY,i.minY),t.maxX=Math.max(t.maxX,i.maxX),t.maxY=Math.max(t.maxY,i.maxY),t}function s(t,i){return t.minX-i.minX}function l(t,i){return t.minY-i.minY}function f(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function u(t){return t.maxX-t.minX+(t.maxY-t.minY)}function m(t,i){return t.minX<=i.minX&&t.minY<=i.minY&&i.maxX<=t.maxX&&i.maxY<=t.maxY}function c(t,i){return i.minX<=t.maxX&&i.minY<=t.maxY&&i.maxX>=t.minX&&i.maxY>=t.minY}function p(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function d(i,n,r,e,a){for(var h=[n,r];h.length;)if(!((r=h.pop())-(n=h.pop())<=e)){var o=n+Math.ceil((r-n)/e/2)*e;t(i,o,n,r,a),h.push(n,o,o,r)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(t){var i=this.data,n=[];if(!c(t,i))return n;for(var r=this.toBBox,e=[];i;){for(var a=0;a<i.children.length;a++){var h=i.children[a],o=i.leaf?r(h):h;c(t,o)&&(i.leaf?n.push(h):m(t,o)?this._all(h,n):e.push(h))}i=e.pop()}return n},r.prototype.collides=function(t){var i=this.data;if(!c(t,i))return!1;for(var n=[];i;){for(var r=0;r<i.children.length;r++){var e=i.children[r],a=i.leaf?this.toBBox(e):e;if(c(t,a)){if(i.leaf||m(t,a))return!0;n.push(e)}}i=n.pop()}return!1},r.prototype.load=function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var i=0;i<t.length;i++)this.insert(t[i]);return this}var n=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},r.prototype.insert=function(t){return t&&this._insert(t,this.data.height-1),this},r.prototype.clear=function(){return this.data=p([]),this},r.prototype.remove=function(t,i){if(!t)return this;for(var n,r,a,h=this.data,o=this.toBBox(t),s=[],l=[];h||s.length;){if(h||(h=s.pop(),r=s[s.length-1],n=l.pop(),a=!0),h.leaf){var f=e(t,h.children,i);if(-1!==f)return h.children.splice(f,1),s.push(h),this._condense(s),this}a||h.leaf||!m(h,o)?r?(n++,h=r.children[n],a=!1):h=null:(s.push(h),l.push(n),n=0,r=h,h=h.children[0])}return this},r.prototype.toBBox=function(t){return t},r.prototype.compareMinX=function(t,i){return t.minX-i.minX},r.prototype.compareMinY=function(t,i){return t.minY-i.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(t){return this.data=t,this},r.prototype._all=function(t,i){for(var n=[];t;)t.leaf?i.push.apply(i,t.children):n.push.apply(n,t.children),t=n.pop();return i},r.prototype._build=function(t,i,n,r){var e,h=n-i+1,o=this._maxEntries;if(h<=o)return a(e=p(t.slice(i,n+1)),this.toBBox),e;r||(r=Math.ceil(Math.log(h)/Math.log(o)),o=Math.ceil(h/Math.pow(o,r-1))),(e=p([])).leaf=!1,e.height=r;var s=Math.ceil(h/o),l=s*Math.ceil(Math.sqrt(o));d(t,i,n,l,this.compareMinX);for(var f=i;f<=n;f+=l){var u=Math.min(f+l-1,n);d(t,f,u,s,this.compareMinY);for(var m=f;m<=u;m+=s){var c=Math.min(m+s-1,u);e.children.push(this._build(t,m,c,r-1))}}return a(e,this.toBBox),e},r.prototype._chooseSubtree=function(t,i,n,r){for(;r.push(i),!i.leaf&&r.length-1!==n;){for(var e=1/0,a=1/0,h=void 0,o=0;o<i.children.length;o++){var s=i.children[o],l=f(s),u=(m=t,c=s,(Math.max(c.maxX,m.maxX)-Math.min(c.minX,m.minX))*(Math.max(c.maxY,m.maxY)-Math.min(c.minY,m.minY))-l);u<a?(a=u,e=l<e?l:e,h=s):u===a&&l<e&&(e=l,h=s)}i=h||i.children[0]}var m,c;return i},r.prototype._insert=function(t,i,n){var r=n?t:this.toBBox(t),e=[],a=this._chooseSubtree(r,this.data,i,e);for(a.children.push(t),o(a,r);i>=0&&e[i].children.length>this._maxEntries;)this._split(e,i),i--;this._adjustParentBBoxes(r,e,i)},r.prototype._split=function(t,i){var n=t[i],r=n.children.length,e=this._minEntries;this._chooseSplitAxis(n,e,r);var h=this._chooseSplitIndex(n,e,r),o=p(n.children.splice(h,n.children.length-h));o.height=n.height,o.leaf=n.leaf,a(n,this.toBBox),a(o,this.toBBox),i?t[i-1].children.push(o):this._splitRoot(n,o)},r.prototype._splitRoot=function(t,i){this.data=p([t,i]),this.data.height=t.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(t,i,n){for(var r,e,a,o,s,l,u,m=1/0,c=1/0,p=i;p<=n-i;p++){var d=h(t,0,p,this.toBBox),x=h(t,p,n,this.toBBox),v=(e=d,a=x,o=void 0,s=void 0,l=void 0,u=void 0,o=Math.max(e.minX,a.minX),s=Math.max(e.minY,a.minY),l=Math.min(e.maxX,a.maxX),u=Math.min(e.maxY,a.maxY),Math.max(0,l-o)*Math.max(0,u-s)),M=f(d)+f(x);v<m?(m=v,r=p,c=M<c?M:c):v===m&&M<c&&(c=M,r=p)}return r||n-i},r.prototype._chooseSplitAxis=function(t,i,n){var r=t.leaf?this.compareMinX:s,e=t.leaf?this.compareMinY:l;this._allDistMargin(t,i,n,r)<this._allDistMargin(t,i,n,e)&&t.children.sort(r)},r.prototype._allDistMargin=function(t,i,n,r){t.children.sort(r);for(var e=this.toBBox,a=h(t,0,i,e),s=h(t,n-i,n,e),l=u(a)+u(s),f=i;f<n-i;f++){var m=t.children[f];o(a,t.leaf?e(m):m),l+=u(a)}for(var c=n-i-1;c>=i;c--){var p=t.children[c];o(s,t.leaf?e(p):p),l+=u(s)}return l},r.prototype._adjustParentBBoxes=function(t,i,n){for(var r=n;r>=0;r--)o(i[r],t)},r.prototype._condense=function(t){for(var i=t.length-1,n=void 0;i>=0;i--)0===t[i].children.length?i>0?(n=t[i-1].children).splice(n.indexOf(t[i]),1):this.clear():a(t[i],this.toBBox)},r});
13838 },{}],43:[function(require,module,exports){
13840 Object.defineProperty(exports, "__esModule", { value: true });
13841 var Observable_1 = require("./internal/Observable");
13842 exports.Observable = Observable_1.Observable;
13843 var ConnectableObservable_1 = require("./internal/observable/ConnectableObservable");
13844 exports.ConnectableObservable = ConnectableObservable_1.ConnectableObservable;
13845 var groupBy_1 = require("./internal/operators/groupBy");
13846 exports.GroupedObservable = groupBy_1.GroupedObservable;
13847 var observable_1 = require("./internal/symbol/observable");
13848 exports.observable = observable_1.observable;
13849 var Subject_1 = require("./internal/Subject");
13850 exports.Subject = Subject_1.Subject;
13851 var BehaviorSubject_1 = require("./internal/BehaviorSubject");
13852 exports.BehaviorSubject = BehaviorSubject_1.BehaviorSubject;
13853 var ReplaySubject_1 = require("./internal/ReplaySubject");
13854 exports.ReplaySubject = ReplaySubject_1.ReplaySubject;
13855 var AsyncSubject_1 = require("./internal/AsyncSubject");
13856 exports.AsyncSubject = AsyncSubject_1.AsyncSubject;
13857 var asap_1 = require("./internal/scheduler/asap");
13858 exports.asapScheduler = asap_1.asap;
13859 var async_1 = require("./internal/scheduler/async");
13860 exports.asyncScheduler = async_1.async;
13861 var queue_1 = require("./internal/scheduler/queue");
13862 exports.queueScheduler = queue_1.queue;
13863 var animationFrame_1 = require("./internal/scheduler/animationFrame");
13864 exports.animationFrameScheduler = animationFrame_1.animationFrame;
13865 var VirtualTimeScheduler_1 = require("./internal/scheduler/VirtualTimeScheduler");
13866 exports.VirtualTimeScheduler = VirtualTimeScheduler_1.VirtualTimeScheduler;
13867 exports.VirtualAction = VirtualTimeScheduler_1.VirtualAction;
13868 var Scheduler_1 = require("./internal/Scheduler");
13869 exports.Scheduler = Scheduler_1.Scheduler;
13870 var Subscription_1 = require("./internal/Subscription");
13871 exports.Subscription = Subscription_1.Subscription;
13872 var Subscriber_1 = require("./internal/Subscriber");
13873 exports.Subscriber = Subscriber_1.Subscriber;
13874 var Notification_1 = require("./internal/Notification");
13875 exports.Notification = Notification_1.Notification;
13876 exports.NotificationKind = Notification_1.NotificationKind;
13877 var pipe_1 = require("./internal/util/pipe");
13878 exports.pipe = pipe_1.pipe;
13879 var noop_1 = require("./internal/util/noop");
13880 exports.noop = noop_1.noop;
13881 var identity_1 = require("./internal/util/identity");
13882 exports.identity = identity_1.identity;
13883 var isObservable_1 = require("./internal/util/isObservable");
13884 exports.isObservable = isObservable_1.isObservable;
13885 var ArgumentOutOfRangeError_1 = require("./internal/util/ArgumentOutOfRangeError");
13886 exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
13887 var EmptyError_1 = require("./internal/util/EmptyError");
13888 exports.EmptyError = EmptyError_1.EmptyError;
13889 var ObjectUnsubscribedError_1 = require("./internal/util/ObjectUnsubscribedError");
13890 exports.ObjectUnsubscribedError = ObjectUnsubscribedError_1.ObjectUnsubscribedError;
13891 var UnsubscriptionError_1 = require("./internal/util/UnsubscriptionError");
13892 exports.UnsubscriptionError = UnsubscriptionError_1.UnsubscriptionError;
13893 var TimeoutError_1 = require("./internal/util/TimeoutError");
13894 exports.TimeoutError = TimeoutError_1.TimeoutError;
13895 var bindCallback_1 = require("./internal/observable/bindCallback");
13896 exports.bindCallback = bindCallback_1.bindCallback;
13897 var bindNodeCallback_1 = require("./internal/observable/bindNodeCallback");
13898 exports.bindNodeCallback = bindNodeCallback_1.bindNodeCallback;
13899 var combineLatest_1 = require("./internal/observable/combineLatest");
13900 exports.combineLatest = combineLatest_1.combineLatest;
13901 var concat_1 = require("./internal/observable/concat");
13902 exports.concat = concat_1.concat;
13903 var defer_1 = require("./internal/observable/defer");
13904 exports.defer = defer_1.defer;
13905 var empty_1 = require("./internal/observable/empty");
13906 exports.empty = empty_1.empty;
13907 var forkJoin_1 = require("./internal/observable/forkJoin");
13908 exports.forkJoin = forkJoin_1.forkJoin;
13909 var from_1 = require("./internal/observable/from");
13910 exports.from = from_1.from;
13911 var fromEvent_1 = require("./internal/observable/fromEvent");
13912 exports.fromEvent = fromEvent_1.fromEvent;
13913 var fromEventPattern_1 = require("./internal/observable/fromEventPattern");
13914 exports.fromEventPattern = fromEventPattern_1.fromEventPattern;
13915 var generate_1 = require("./internal/observable/generate");
13916 exports.generate = generate_1.generate;
13917 var iif_1 = require("./internal/observable/iif");
13918 exports.iif = iif_1.iif;
13919 var interval_1 = require("./internal/observable/interval");
13920 exports.interval = interval_1.interval;
13921 var merge_1 = require("./internal/observable/merge");
13922 exports.merge = merge_1.merge;
13923 var never_1 = require("./internal/observable/never");
13924 exports.never = never_1.never;
13925 var of_1 = require("./internal/observable/of");
13926 exports.of = of_1.of;
13927 var onErrorResumeNext_1 = require("./internal/observable/onErrorResumeNext");
13928 exports.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext;
13929 var pairs_1 = require("./internal/observable/pairs");
13930 exports.pairs = pairs_1.pairs;
13931 var partition_1 = require("./internal/observable/partition");
13932 exports.partition = partition_1.partition;
13933 var race_1 = require("./internal/observable/race");
13934 exports.race = race_1.race;
13935 var range_1 = require("./internal/observable/range");
13936 exports.range = range_1.range;
13937 var throwError_1 = require("./internal/observable/throwError");
13938 exports.throwError = throwError_1.throwError;
13939 var timer_1 = require("./internal/observable/timer");
13940 exports.timer = timer_1.timer;
13941 var using_1 = require("./internal/observable/using");
13942 exports.using = using_1.using;
13943 var zip_1 = require("./internal/observable/zip");
13944 exports.zip = zip_1.zip;
13945 var scheduled_1 = require("./internal/scheduled/scheduled");
13946 exports.scheduled = scheduled_1.scheduled;
13947 var empty_2 = require("./internal/observable/empty");
13948 exports.EMPTY = empty_2.EMPTY;
13949 var never_2 = require("./internal/observable/never");
13950 exports.NEVER = never_2.NEVER;
13951 var config_1 = require("./internal/config");
13952 exports.config = config_1.config;
13954 },{"./internal/AsyncSubject":44,"./internal/BehaviorSubject":45,"./internal/Notification":47,"./internal/Observable":48,"./internal/ReplaySubject":51,"./internal/Scheduler":52,"./internal/Subject":53,"./internal/Subscriber":55,"./internal/Subscription":56,"./internal/config":57,"./internal/observable/ConnectableObservable":58,"./internal/observable/bindCallback":60,"./internal/observable/bindNodeCallback":61,"./internal/observable/combineLatest":62,"./internal/observable/concat":63,"./internal/observable/defer":64,"./internal/observable/empty":65,"./internal/observable/forkJoin":66,"./internal/observable/from":67,"./internal/observable/fromEvent":69,"./internal/observable/fromEventPattern":70,"./internal/observable/generate":71,"./internal/observable/iif":72,"./internal/observable/interval":73,"./internal/observable/merge":74,"./internal/observable/never":75,"./internal/observable/of":76,"./internal/observable/onErrorResumeNext":77,"./internal/observable/pairs":78,"./internal/observable/partition":79,"./internal/observable/race":80,"./internal/observable/range":81,"./internal/observable/throwError":82,"./internal/observable/timer":83,"./internal/observable/using":84,"./internal/observable/zip":85,"./internal/operators/groupBy":121,"./internal/scheduled/scheduled":193,"./internal/scheduler/VirtualTimeScheduler":203,"./internal/scheduler/animationFrame":204,"./internal/scheduler/asap":205,"./internal/scheduler/async":206,"./internal/scheduler/queue":207,"./internal/symbol/observable":209,"./internal/util/ArgumentOutOfRangeError":211,"./internal/util/EmptyError":212,"./internal/util/ObjectUnsubscribedError":214,"./internal/util/TimeoutError":215,"./internal/util/UnsubscriptionError":216,"./internal/util/identity":219,"./internal/util/isObservable":228,"./internal/util/noop":231,"./internal/util/pipe":233}],44:[function(require,module,exports){
13956 var __extends = (this && this.__extends) || (function () {
13957 var extendStatics = function (d, b) {
13958 extendStatics = Object.setPrototypeOf ||
13959 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13960 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13961 return extendStatics(d, b);
13963 return function (d, b) {
13964 extendStatics(d, b);
13965 function __() { this.constructor = d; }
13966 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13969 Object.defineProperty(exports, "__esModule", { value: true });
13970 var Subject_1 = require("./Subject");
13971 var Subscription_1 = require("./Subscription");
13972 var AsyncSubject = (function (_super) {
13973 __extends(AsyncSubject, _super);
13974 function AsyncSubject() {
13975 var _this = _super !== null && _super.apply(this, arguments) || this;
13976 _this.value = null;
13977 _this.hasNext = false;
13978 _this.hasCompleted = false;
13981 AsyncSubject.prototype._subscribe = function (subscriber) {
13982 if (this.hasError) {
13983 subscriber.error(this.thrownError);
13984 return Subscription_1.Subscription.EMPTY;
13986 else if (this.hasCompleted && this.hasNext) {
13987 subscriber.next(this.value);
13988 subscriber.complete();
13989 return Subscription_1.Subscription.EMPTY;
13991 return _super.prototype._subscribe.call(this, subscriber);
13993 AsyncSubject.prototype.next = function (value) {
13994 if (!this.hasCompleted) {
13995 this.value = value;
13996 this.hasNext = true;
13999 AsyncSubject.prototype.error = function (error) {
14000 if (!this.hasCompleted) {
14001 _super.prototype.error.call(this, error);
14004 AsyncSubject.prototype.complete = function () {
14005 this.hasCompleted = true;
14006 if (this.hasNext) {
14007 _super.prototype.next.call(this, this.value);
14009 _super.prototype.complete.call(this);
14011 return AsyncSubject;
14012 }(Subject_1.Subject));
14013 exports.AsyncSubject = AsyncSubject;
14015 },{"./Subject":53,"./Subscription":56}],45:[function(require,module,exports){
14017 var __extends = (this && this.__extends) || (function () {
14018 var extendStatics = function (d, b) {
14019 extendStatics = Object.setPrototypeOf ||
14020 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14021 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14022 return extendStatics(d, b);
14024 return function (d, b) {
14025 extendStatics(d, b);
14026 function __() { this.constructor = d; }
14027 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14030 Object.defineProperty(exports, "__esModule", { value: true });
14031 var Subject_1 = require("./Subject");
14032 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
14033 var BehaviorSubject = (function (_super) {
14034 __extends(BehaviorSubject, _super);
14035 function BehaviorSubject(_value) {
14036 var _this = _super.call(this) || this;
14037 _this._value = _value;
14040 Object.defineProperty(BehaviorSubject.prototype, "value", {
14042 return this.getValue();
14047 BehaviorSubject.prototype._subscribe = function (subscriber) {
14048 var subscription = _super.prototype._subscribe.call(this, subscriber);
14049 if (subscription && !subscription.closed) {
14050 subscriber.next(this._value);
14052 return subscription;
14054 BehaviorSubject.prototype.getValue = function () {
14055 if (this.hasError) {
14056 throw this.thrownError;
14058 else if (this.closed) {
14059 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
14062 return this._value;
14065 BehaviorSubject.prototype.next = function (value) {
14066 _super.prototype.next.call(this, this._value = value);
14068 return BehaviorSubject;
14069 }(Subject_1.Subject));
14070 exports.BehaviorSubject = BehaviorSubject;
14072 },{"./Subject":53,"./util/ObjectUnsubscribedError":214}],46:[function(require,module,exports){
14074 var __extends = (this && this.__extends) || (function () {
14075 var extendStatics = function (d, b) {
14076 extendStatics = Object.setPrototypeOf ||
14077 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14078 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14079 return extendStatics(d, b);
14081 return function (d, b) {
14082 extendStatics(d, b);
14083 function __() { this.constructor = d; }
14084 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14087 Object.defineProperty(exports, "__esModule", { value: true });
14088 var Subscriber_1 = require("./Subscriber");
14089 var InnerSubscriber = (function (_super) {
14090 __extends(InnerSubscriber, _super);
14091 function InnerSubscriber(parent, outerValue, outerIndex) {
14092 var _this = _super.call(this) || this;
14093 _this.parent = parent;
14094 _this.outerValue = outerValue;
14095 _this.outerIndex = outerIndex;
14099 InnerSubscriber.prototype._next = function (value) {
14100 this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
14102 InnerSubscriber.prototype._error = function (error) {
14103 this.parent.notifyError(error, this);
14104 this.unsubscribe();
14106 InnerSubscriber.prototype._complete = function () {
14107 this.parent.notifyComplete(this);
14108 this.unsubscribe();
14110 return InnerSubscriber;
14111 }(Subscriber_1.Subscriber));
14112 exports.InnerSubscriber = InnerSubscriber;
14114 },{"./Subscriber":55}],47:[function(require,module,exports){
14116 Object.defineProperty(exports, "__esModule", { value: true });
14117 var empty_1 = require("./observable/empty");
14118 var of_1 = require("./observable/of");
14119 var throwError_1 = require("./observable/throwError");
14120 var NotificationKind;
14121 (function (NotificationKind) {
14122 NotificationKind["NEXT"] = "N";
14123 NotificationKind["ERROR"] = "E";
14124 NotificationKind["COMPLETE"] = "C";
14125 })(NotificationKind = exports.NotificationKind || (exports.NotificationKind = {}));
14126 var Notification = (function () {
14127 function Notification(kind, value, error) {
14129 this.value = value;
14130 this.error = error;
14131 this.hasValue = kind === 'N';
14133 Notification.prototype.observe = function (observer) {
14134 switch (this.kind) {
14136 return observer.next && observer.next(this.value);
14138 return observer.error && observer.error(this.error);
14140 return observer.complete && observer.complete();
14143 Notification.prototype.do = function (next, error, complete) {
14144 var kind = this.kind;
14147 return next && next(this.value);
14149 return error && error(this.error);
14151 return complete && complete();
14154 Notification.prototype.accept = function (nextOrObserver, error, complete) {
14155 if (nextOrObserver && typeof nextOrObserver.next === 'function') {
14156 return this.observe(nextOrObserver);
14159 return this.do(nextOrObserver, error, complete);
14162 Notification.prototype.toObservable = function () {
14163 var kind = this.kind;
14166 return of_1.of(this.value);
14168 return throwError_1.throwError(this.error);
14170 return empty_1.empty();
14172 throw new Error('unexpected notification kind value');
14174 Notification.createNext = function (value) {
14175 if (typeof value !== 'undefined') {
14176 return new Notification('N', value);
14178 return Notification.undefinedValueNotification;
14180 Notification.createError = function (err) {
14181 return new Notification('E', undefined, err);
14183 Notification.createComplete = function () {
14184 return Notification.completeNotification;
14186 Notification.completeNotification = new Notification('C');
14187 Notification.undefinedValueNotification = new Notification('N', undefined);
14188 return Notification;
14190 exports.Notification = Notification;
14192 },{"./observable/empty":65,"./observable/of":76,"./observable/throwError":82}],48:[function(require,module,exports){
14194 Object.defineProperty(exports, "__esModule", { value: true });
14195 var canReportError_1 = require("./util/canReportError");
14196 var toSubscriber_1 = require("./util/toSubscriber");
14197 var observable_1 = require("./symbol/observable");
14198 var pipe_1 = require("./util/pipe");
14199 var config_1 = require("./config");
14200 var Observable = (function () {
14201 function Observable(subscribe) {
14202 this._isScalar = false;
14204 this._subscribe = subscribe;
14207 Observable.prototype.lift = function (operator) {
14208 var observable = new Observable();
14209 observable.source = this;
14210 observable.operator = operator;
14213 Observable.prototype.subscribe = function (observerOrNext, error, complete) {
14214 var operator = this.operator;
14215 var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
14217 sink.add(operator.call(sink, this.source));
14220 sink.add(this.source || (config_1.config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
14221 this._subscribe(sink) :
14222 this._trySubscribe(sink));
14224 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
14225 if (sink.syncErrorThrowable) {
14226 sink.syncErrorThrowable = false;
14227 if (sink.syncErrorThrown) {
14228 throw sink.syncErrorValue;
14234 Observable.prototype._trySubscribe = function (sink) {
14236 return this._subscribe(sink);
14239 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
14240 sink.syncErrorThrown = true;
14241 sink.syncErrorValue = err;
14243 if (canReportError_1.canReportError(sink)) {
14251 Observable.prototype.forEach = function (next, promiseCtor) {
14253 promiseCtor = getPromiseCtor(promiseCtor);
14254 return new promiseCtor(function (resolve, reject) {
14256 subscription = _this.subscribe(function (value) {
14262 if (subscription) {
14263 subscription.unsubscribe();
14266 }, reject, resolve);
14269 Observable.prototype._subscribe = function (subscriber) {
14270 var source = this.source;
14271 return source && source.subscribe(subscriber);
14273 Observable.prototype[observable_1.observable] = function () {
14276 Observable.prototype.pipe = function () {
14277 var operations = [];
14278 for (var _i = 0; _i < arguments.length; _i++) {
14279 operations[_i] = arguments[_i];
14281 if (operations.length === 0) {
14284 return pipe_1.pipeFromArray(operations)(this);
14286 Observable.prototype.toPromise = function (promiseCtor) {
14288 promiseCtor = getPromiseCtor(promiseCtor);
14289 return new promiseCtor(function (resolve, reject) {
14291 _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
14294 Observable.create = function (subscribe) {
14295 return new Observable(subscribe);
14299 exports.Observable = Observable;
14300 function getPromiseCtor(promiseCtor) {
14301 if (!promiseCtor) {
14302 promiseCtor = config_1.config.Promise || Promise;
14304 if (!promiseCtor) {
14305 throw new Error('no Promise impl found');
14307 return promiseCtor;
14310 },{"./config":57,"./symbol/observable":209,"./util/canReportError":217,"./util/pipe":233,"./util/toSubscriber":240}],49:[function(require,module,exports){
14312 Object.defineProperty(exports, "__esModule", { value: true });
14313 var config_1 = require("./config");
14314 var hostReportError_1 = require("./util/hostReportError");
14317 next: function (value) { },
14318 error: function (err) {
14319 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
14323 hostReportError_1.hostReportError(err);
14326 complete: function () { }
14329 },{"./config":57,"./util/hostReportError":218}],50:[function(require,module,exports){
14331 var __extends = (this && this.__extends) || (function () {
14332 var extendStatics = function (d, b) {
14333 extendStatics = Object.setPrototypeOf ||
14334 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14335 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14336 return extendStatics(d, b);
14338 return function (d, b) {
14339 extendStatics(d, b);
14340 function __() { this.constructor = d; }
14341 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14344 Object.defineProperty(exports, "__esModule", { value: true });
14345 var Subscriber_1 = require("./Subscriber");
14346 var OuterSubscriber = (function (_super) {
14347 __extends(OuterSubscriber, _super);
14348 function OuterSubscriber() {
14349 return _super !== null && _super.apply(this, arguments) || this;
14351 OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
14352 this.destination.next(innerValue);
14354 OuterSubscriber.prototype.notifyError = function (error, innerSub) {
14355 this.destination.error(error);
14357 OuterSubscriber.prototype.notifyComplete = function (innerSub) {
14358 this.destination.complete();
14360 return OuterSubscriber;
14361 }(Subscriber_1.Subscriber));
14362 exports.OuterSubscriber = OuterSubscriber;
14364 },{"./Subscriber":55}],51:[function(require,module,exports){
14366 var __extends = (this && this.__extends) || (function () {
14367 var extendStatics = function (d, b) {
14368 extendStatics = Object.setPrototypeOf ||
14369 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14370 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14371 return extendStatics(d, b);
14373 return function (d, b) {
14374 extendStatics(d, b);
14375 function __() { this.constructor = d; }
14376 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14379 Object.defineProperty(exports, "__esModule", { value: true });
14380 var Subject_1 = require("./Subject");
14381 var queue_1 = require("./scheduler/queue");
14382 var Subscription_1 = require("./Subscription");
14383 var observeOn_1 = require("./operators/observeOn");
14384 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
14385 var SubjectSubscription_1 = require("./SubjectSubscription");
14386 var ReplaySubject = (function (_super) {
14387 __extends(ReplaySubject, _super);
14388 function ReplaySubject(bufferSize, windowTime, scheduler) {
14389 if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
14390 if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
14391 var _this = _super.call(this) || this;
14392 _this.scheduler = scheduler;
14393 _this._events = [];
14394 _this._infiniteTimeWindow = false;
14395 _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
14396 _this._windowTime = windowTime < 1 ? 1 : windowTime;
14397 if (windowTime === Number.POSITIVE_INFINITY) {
14398 _this._infiniteTimeWindow = true;
14399 _this.next = _this.nextInfiniteTimeWindow;
14402 _this.next = _this.nextTimeWindow;
14406 ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
14407 var _events = this._events;
14408 _events.push(value);
14409 if (_events.length > this._bufferSize) {
14412 _super.prototype.next.call(this, value);
14414 ReplaySubject.prototype.nextTimeWindow = function (value) {
14415 this._events.push(new ReplayEvent(this._getNow(), value));
14416 this._trimBufferThenGetEvents();
14417 _super.prototype.next.call(this, value);
14419 ReplaySubject.prototype._subscribe = function (subscriber) {
14420 var _infiniteTimeWindow = this._infiniteTimeWindow;
14421 var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
14422 var scheduler = this.scheduler;
14423 var len = _events.length;
14426 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
14428 else if (this.isStopped || this.hasError) {
14429 subscription = Subscription_1.Subscription.EMPTY;
14432 this.observers.push(subscriber);
14433 subscription = new SubjectSubscription_1.SubjectSubscription(this, subscriber);
14436 subscriber.add(subscriber = new observeOn_1.ObserveOnSubscriber(subscriber, scheduler));
14438 if (_infiniteTimeWindow) {
14439 for (var i = 0; i < len && !subscriber.closed; i++) {
14440 subscriber.next(_events[i]);
14444 for (var i = 0; i < len && !subscriber.closed; i++) {
14445 subscriber.next(_events[i].value);
14448 if (this.hasError) {
14449 subscriber.error(this.thrownError);
14451 else if (this.isStopped) {
14452 subscriber.complete();
14454 return subscription;
14456 ReplaySubject.prototype._getNow = function () {
14457 return (this.scheduler || queue_1.queue).now();
14459 ReplaySubject.prototype._trimBufferThenGetEvents = function () {
14460 var now = this._getNow();
14461 var _bufferSize = this._bufferSize;
14462 var _windowTime = this._windowTime;
14463 var _events = this._events;
14464 var eventsCount = _events.length;
14465 var spliceCount = 0;
14466 while (spliceCount < eventsCount) {
14467 if ((now - _events[spliceCount].time) < _windowTime) {
14472 if (eventsCount > _bufferSize) {
14473 spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
14475 if (spliceCount > 0) {
14476 _events.splice(0, spliceCount);
14480 return ReplaySubject;
14481 }(Subject_1.Subject));
14482 exports.ReplaySubject = ReplaySubject;
14483 var ReplayEvent = (function () {
14484 function ReplayEvent(time, value) {
14486 this.value = value;
14488 return ReplayEvent;
14491 },{"./Subject":53,"./SubjectSubscription":54,"./Subscription":56,"./operators/observeOn":136,"./scheduler/queue":207,"./util/ObjectUnsubscribedError":214}],52:[function(require,module,exports){
14493 Object.defineProperty(exports, "__esModule", { value: true });
14494 var Scheduler = (function () {
14495 function Scheduler(SchedulerAction, now) {
14496 if (now === void 0) { now = Scheduler.now; }
14497 this.SchedulerAction = SchedulerAction;
14500 Scheduler.prototype.schedule = function (work, delay, state) {
14501 if (delay === void 0) { delay = 0; }
14502 return new this.SchedulerAction(this, work).schedule(state, delay);
14504 Scheduler.now = function () { return Date.now(); };
14507 exports.Scheduler = Scheduler;
14509 },{}],53:[function(require,module,exports){
14511 var __extends = (this && this.__extends) || (function () {
14512 var extendStatics = function (d, b) {
14513 extendStatics = Object.setPrototypeOf ||
14514 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14515 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14516 return extendStatics(d, b);
14518 return function (d, b) {
14519 extendStatics(d, b);
14520 function __() { this.constructor = d; }
14521 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14524 Object.defineProperty(exports, "__esModule", { value: true });
14525 var Observable_1 = require("./Observable");
14526 var Subscriber_1 = require("./Subscriber");
14527 var Subscription_1 = require("./Subscription");
14528 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
14529 var SubjectSubscription_1 = require("./SubjectSubscription");
14530 var rxSubscriber_1 = require("../internal/symbol/rxSubscriber");
14531 var SubjectSubscriber = (function (_super) {
14532 __extends(SubjectSubscriber, _super);
14533 function SubjectSubscriber(destination) {
14534 var _this = _super.call(this, destination) || this;
14535 _this.destination = destination;
14538 return SubjectSubscriber;
14539 }(Subscriber_1.Subscriber));
14540 exports.SubjectSubscriber = SubjectSubscriber;
14541 var Subject = (function (_super) {
14542 __extends(Subject, _super);
14543 function Subject() {
14544 var _this = _super.call(this) || this;
14545 _this.observers = [];
14546 _this.closed = false;
14547 _this.isStopped = false;
14548 _this.hasError = false;
14549 _this.thrownError = null;
14552 Subject.prototype[rxSubscriber_1.rxSubscriber] = function () {
14553 return new SubjectSubscriber(this);
14555 Subject.prototype.lift = function (operator) {
14556 var subject = new AnonymousSubject(this, this);
14557 subject.operator = operator;
14560 Subject.prototype.next = function (value) {
14562 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
14564 if (!this.isStopped) {
14565 var observers = this.observers;
14566 var len = observers.length;
14567 var copy = observers.slice();
14568 for (var i = 0; i < len; i++) {
14569 copy[i].next(value);
14573 Subject.prototype.error = function (err) {
14575 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
14577 this.hasError = true;
14578 this.thrownError = err;
14579 this.isStopped = true;
14580 var observers = this.observers;
14581 var len = observers.length;
14582 var copy = observers.slice();
14583 for (var i = 0; i < len; i++) {
14584 copy[i].error(err);
14586 this.observers.length = 0;
14588 Subject.prototype.complete = function () {
14590 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
14592 this.isStopped = true;
14593 var observers = this.observers;
14594 var len = observers.length;
14595 var copy = observers.slice();
14596 for (var i = 0; i < len; i++) {
14597 copy[i].complete();
14599 this.observers.length = 0;
14601 Subject.prototype.unsubscribe = function () {
14602 this.isStopped = true;
14603 this.closed = true;
14604 this.observers = null;
14606 Subject.prototype._trySubscribe = function (subscriber) {
14608 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
14611 return _super.prototype._trySubscribe.call(this, subscriber);
14614 Subject.prototype._subscribe = function (subscriber) {
14616 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
14618 else if (this.hasError) {
14619 subscriber.error(this.thrownError);
14620 return Subscription_1.Subscription.EMPTY;
14622 else if (this.isStopped) {
14623 subscriber.complete();
14624 return Subscription_1.Subscription.EMPTY;
14627 this.observers.push(subscriber);
14628 return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
14631 Subject.prototype.asObservable = function () {
14632 var observable = new Observable_1.Observable();
14633 observable.source = this;
14636 Subject.create = function (destination, source) {
14637 return new AnonymousSubject(destination, source);
14640 }(Observable_1.Observable));
14641 exports.Subject = Subject;
14642 var AnonymousSubject = (function (_super) {
14643 __extends(AnonymousSubject, _super);
14644 function AnonymousSubject(destination, source) {
14645 var _this = _super.call(this) || this;
14646 _this.destination = destination;
14647 _this.source = source;
14650 AnonymousSubject.prototype.next = function (value) {
14651 var destination = this.destination;
14652 if (destination && destination.next) {
14653 destination.next(value);
14656 AnonymousSubject.prototype.error = function (err) {
14657 var destination = this.destination;
14658 if (destination && destination.error) {
14659 this.destination.error(err);
14662 AnonymousSubject.prototype.complete = function () {
14663 var destination = this.destination;
14664 if (destination && destination.complete) {
14665 this.destination.complete();
14668 AnonymousSubject.prototype._subscribe = function (subscriber) {
14669 var source = this.source;
14671 return this.source.subscribe(subscriber);
14674 return Subscription_1.Subscription.EMPTY;
14677 return AnonymousSubject;
14679 exports.AnonymousSubject = AnonymousSubject;
14681 },{"../internal/symbol/rxSubscriber":210,"./Observable":48,"./SubjectSubscription":54,"./Subscriber":55,"./Subscription":56,"./util/ObjectUnsubscribedError":214}],54:[function(require,module,exports){
14683 var __extends = (this && this.__extends) || (function () {
14684 var extendStatics = function (d, b) {
14685 extendStatics = Object.setPrototypeOf ||
14686 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14687 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14688 return extendStatics(d, b);
14690 return function (d, b) {
14691 extendStatics(d, b);
14692 function __() { this.constructor = d; }
14693 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14696 Object.defineProperty(exports, "__esModule", { value: true });
14697 var Subscription_1 = require("./Subscription");
14698 var SubjectSubscription = (function (_super) {
14699 __extends(SubjectSubscription, _super);
14700 function SubjectSubscription(subject, subscriber) {
14701 var _this = _super.call(this) || this;
14702 _this.subject = subject;
14703 _this.subscriber = subscriber;
14704 _this.closed = false;
14707 SubjectSubscription.prototype.unsubscribe = function () {
14711 this.closed = true;
14712 var subject = this.subject;
14713 var observers = subject.observers;
14714 this.subject = null;
14715 if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
14718 var subscriberIndex = observers.indexOf(this.subscriber);
14719 if (subscriberIndex !== -1) {
14720 observers.splice(subscriberIndex, 1);
14723 return SubjectSubscription;
14724 }(Subscription_1.Subscription));
14725 exports.SubjectSubscription = SubjectSubscription;
14727 },{"./Subscription":56}],55:[function(require,module,exports){
14729 var __extends = (this && this.__extends) || (function () {
14730 var extendStatics = function (d, b) {
14731 extendStatics = Object.setPrototypeOf ||
14732 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14733 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14734 return extendStatics(d, b);
14736 return function (d, b) {
14737 extendStatics(d, b);
14738 function __() { this.constructor = d; }
14739 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14742 Object.defineProperty(exports, "__esModule", { value: true });
14743 var isFunction_1 = require("./util/isFunction");
14744 var Observer_1 = require("./Observer");
14745 var Subscription_1 = require("./Subscription");
14746 var rxSubscriber_1 = require("../internal/symbol/rxSubscriber");
14747 var config_1 = require("./config");
14748 var hostReportError_1 = require("./util/hostReportError");
14749 var Subscriber = (function (_super) {
14750 __extends(Subscriber, _super);
14751 function Subscriber(destinationOrNext, error, complete) {
14752 var _this = _super.call(this) || this;
14753 _this.syncErrorValue = null;
14754 _this.syncErrorThrown = false;
14755 _this.syncErrorThrowable = false;
14756 _this.isStopped = false;
14757 switch (arguments.length) {
14759 _this.destination = Observer_1.empty;
14762 if (!destinationOrNext) {
14763 _this.destination = Observer_1.empty;
14766 if (typeof destinationOrNext === 'object') {
14767 if (destinationOrNext instanceof Subscriber) {
14768 _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
14769 _this.destination = destinationOrNext;
14770 destinationOrNext.add(_this);
14773 _this.syncErrorThrowable = true;
14774 _this.destination = new SafeSubscriber(_this, destinationOrNext);
14779 _this.syncErrorThrowable = true;
14780 _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
14785 Subscriber.prototype[rxSubscriber_1.rxSubscriber] = function () { return this; };
14786 Subscriber.create = function (next, error, complete) {
14787 var subscriber = new Subscriber(next, error, complete);
14788 subscriber.syncErrorThrowable = false;
14791 Subscriber.prototype.next = function (value) {
14792 if (!this.isStopped) {
14796 Subscriber.prototype.error = function (err) {
14797 if (!this.isStopped) {
14798 this.isStopped = true;
14802 Subscriber.prototype.complete = function () {
14803 if (!this.isStopped) {
14804 this.isStopped = true;
14808 Subscriber.prototype.unsubscribe = function () {
14812 this.isStopped = true;
14813 _super.prototype.unsubscribe.call(this);
14815 Subscriber.prototype._next = function (value) {
14816 this.destination.next(value);
14818 Subscriber.prototype._error = function (err) {
14819 this.destination.error(err);
14820 this.unsubscribe();
14822 Subscriber.prototype._complete = function () {
14823 this.destination.complete();
14824 this.unsubscribe();
14826 Subscriber.prototype._unsubscribeAndRecycle = function () {
14827 var _parentOrParents = this._parentOrParents;
14828 this._parentOrParents = null;
14829 this.unsubscribe();
14830 this.closed = false;
14831 this.isStopped = false;
14832 this._parentOrParents = _parentOrParents;
14836 }(Subscription_1.Subscription));
14837 exports.Subscriber = Subscriber;
14838 var SafeSubscriber = (function (_super) {
14839 __extends(SafeSubscriber, _super);
14840 function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
14841 var _this = _super.call(this) || this;
14842 _this._parentSubscriber = _parentSubscriber;
14844 var context = _this;
14845 if (isFunction_1.isFunction(observerOrNext)) {
14846 next = observerOrNext;
14848 else if (observerOrNext) {
14849 next = observerOrNext.next;
14850 error = observerOrNext.error;
14851 complete = observerOrNext.complete;
14852 if (observerOrNext !== Observer_1.empty) {
14853 context = Object.create(observerOrNext);
14854 if (isFunction_1.isFunction(context.unsubscribe)) {
14855 _this.add(context.unsubscribe.bind(context));
14857 context.unsubscribe = _this.unsubscribe.bind(_this);
14860 _this._context = context;
14861 _this._next = next;
14862 _this._error = error;
14863 _this._complete = complete;
14866 SafeSubscriber.prototype.next = function (value) {
14867 if (!this.isStopped && this._next) {
14868 var _parentSubscriber = this._parentSubscriber;
14869 if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
14870 this.__tryOrUnsub(this._next, value);
14872 else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
14873 this.unsubscribe();
14877 SafeSubscriber.prototype.error = function (err) {
14878 if (!this.isStopped) {
14879 var _parentSubscriber = this._parentSubscriber;
14880 var useDeprecatedSynchronousErrorHandling = config_1.config.useDeprecatedSynchronousErrorHandling;
14882 if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
14883 this.__tryOrUnsub(this._error, err);
14884 this.unsubscribe();
14887 this.__tryOrSetError(_parentSubscriber, this._error, err);
14888 this.unsubscribe();
14891 else if (!_parentSubscriber.syncErrorThrowable) {
14892 this.unsubscribe();
14893 if (useDeprecatedSynchronousErrorHandling) {
14896 hostReportError_1.hostReportError(err);
14899 if (useDeprecatedSynchronousErrorHandling) {
14900 _parentSubscriber.syncErrorValue = err;
14901 _parentSubscriber.syncErrorThrown = true;
14904 hostReportError_1.hostReportError(err);
14906 this.unsubscribe();
14910 SafeSubscriber.prototype.complete = function () {
14912 if (!this.isStopped) {
14913 var _parentSubscriber = this._parentSubscriber;
14914 if (this._complete) {
14915 var wrappedComplete = function () { return _this._complete.call(_this._context); };
14916 if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
14917 this.__tryOrUnsub(wrappedComplete);
14918 this.unsubscribe();
14921 this.__tryOrSetError(_parentSubscriber, wrappedComplete);
14922 this.unsubscribe();
14926 this.unsubscribe();
14930 SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
14932 fn.call(this._context, value);
14935 this.unsubscribe();
14936 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
14940 hostReportError_1.hostReportError(err);
14944 SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
14945 if (!config_1.config.useDeprecatedSynchronousErrorHandling) {
14946 throw new Error('bad call');
14949 fn.call(this._context, value);
14952 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
14953 parent.syncErrorValue = err;
14954 parent.syncErrorThrown = true;
14958 hostReportError_1.hostReportError(err);
14964 SafeSubscriber.prototype._unsubscribe = function () {
14965 var _parentSubscriber = this._parentSubscriber;
14966 this._context = null;
14967 this._parentSubscriber = null;
14968 _parentSubscriber.unsubscribe();
14970 return SafeSubscriber;
14972 exports.SafeSubscriber = SafeSubscriber;
14974 },{"../internal/symbol/rxSubscriber":210,"./Observer":49,"./Subscription":56,"./config":57,"./util/hostReportError":218,"./util/isFunction":223}],56:[function(require,module,exports){
14976 Object.defineProperty(exports, "__esModule", { value: true });
14977 var isArray_1 = require("./util/isArray");
14978 var isObject_1 = require("./util/isObject");
14979 var isFunction_1 = require("./util/isFunction");
14980 var UnsubscriptionError_1 = require("./util/UnsubscriptionError");
14981 var Subscription = (function () {
14982 function Subscription(unsubscribe) {
14983 this.closed = false;
14984 this._parentOrParents = null;
14985 this._subscriptions = null;
14987 this._unsubscribe = unsubscribe;
14990 Subscription.prototype.unsubscribe = function () {
14995 var _a = this, _parentOrParents = _a._parentOrParents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
14996 this.closed = true;
14997 this._parentOrParents = null;
14998 this._subscriptions = null;
14999 if (_parentOrParents instanceof Subscription) {
15000 _parentOrParents.remove(this);
15002 else if (_parentOrParents !== null) {
15003 for (var index = 0; index < _parentOrParents.length; ++index) {
15004 var parent_1 = _parentOrParents[index];
15005 parent_1.remove(this);
15008 if (isFunction_1.isFunction(_unsubscribe)) {
15010 _unsubscribe.call(this);
15013 errors = e instanceof UnsubscriptionError_1.UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
15016 if (isArray_1.isArray(_subscriptions)) {
15018 var len = _subscriptions.length;
15019 while (++index < len) {
15020 var sub = _subscriptions[index];
15021 if (isObject_1.isObject(sub)) {
15026 errors = errors || [];
15027 if (e instanceof UnsubscriptionError_1.UnsubscriptionError) {
15028 errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
15038 throw new UnsubscriptionError_1.UnsubscriptionError(errors);
15041 Subscription.prototype.add = function (teardown) {
15042 var subscription = teardown;
15044 return Subscription.EMPTY;
15046 switch (typeof teardown) {
15048 subscription = new Subscription(teardown);
15050 if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
15051 return subscription;
15053 else if (this.closed) {
15054 subscription.unsubscribe();
15055 return subscription;
15057 else if (!(subscription instanceof Subscription)) {
15058 var tmp = subscription;
15059 subscription = new Subscription();
15060 subscription._subscriptions = [tmp];
15064 throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
15067 var _parentOrParents = subscription._parentOrParents;
15068 if (_parentOrParents === null) {
15069 subscription._parentOrParents = this;
15071 else if (_parentOrParents instanceof Subscription) {
15072 if (_parentOrParents === this) {
15073 return subscription;
15075 subscription._parentOrParents = [_parentOrParents, this];
15077 else if (_parentOrParents.indexOf(this) === -1) {
15078 _parentOrParents.push(this);
15081 return subscription;
15083 var subscriptions = this._subscriptions;
15084 if (subscriptions === null) {
15085 this._subscriptions = [subscription];
15088 subscriptions.push(subscription);
15090 return subscription;
15092 Subscription.prototype.remove = function (subscription) {
15093 var subscriptions = this._subscriptions;
15094 if (subscriptions) {
15095 var subscriptionIndex = subscriptions.indexOf(subscription);
15096 if (subscriptionIndex !== -1) {
15097 subscriptions.splice(subscriptionIndex, 1);
15101 Subscription.EMPTY = (function (empty) {
15102 empty.closed = true;
15104 }(new Subscription()));
15105 return Subscription;
15107 exports.Subscription = Subscription;
15108 function flattenUnsubscriptionErrors(errors) {
15109 return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []);
15112 },{"./util/UnsubscriptionError":216,"./util/isArray":220,"./util/isFunction":223,"./util/isObject":227}],57:[function(require,module,exports){
15114 Object.defineProperty(exports, "__esModule", { value: true });
15115 var _enable_super_gross_mode_that_will_cause_bad_things = false;
15117 Promise: undefined,
15118 set useDeprecatedSynchronousErrorHandling(value) {
15120 var error = new Error();
15121 console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
15123 else if (_enable_super_gross_mode_that_will_cause_bad_things) {
15124 console.log('RxJS: Back to a better error behavior. Thank you. <3');
15126 _enable_super_gross_mode_that_will_cause_bad_things = value;
15128 get useDeprecatedSynchronousErrorHandling() {
15129 return _enable_super_gross_mode_that_will_cause_bad_things;
15133 },{}],58:[function(require,module,exports){
15135 var __extends = (this && this.__extends) || (function () {
15136 var extendStatics = function (d, b) {
15137 extendStatics = Object.setPrototypeOf ||
15138 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15139 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15140 return extendStatics(d, b);
15142 return function (d, b) {
15143 extendStatics(d, b);
15144 function __() { this.constructor = d; }
15145 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15148 Object.defineProperty(exports, "__esModule", { value: true });
15149 var Subject_1 = require("../Subject");
15150 var Observable_1 = require("../Observable");
15151 var Subscriber_1 = require("../Subscriber");
15152 var Subscription_1 = require("../Subscription");
15153 var refCount_1 = require("../operators/refCount");
15154 var ConnectableObservable = (function (_super) {
15155 __extends(ConnectableObservable, _super);
15156 function ConnectableObservable(source, subjectFactory) {
15157 var _this = _super.call(this) || this;
15158 _this.source = source;
15159 _this.subjectFactory = subjectFactory;
15160 _this._refCount = 0;
15161 _this._isComplete = false;
15164 ConnectableObservable.prototype._subscribe = function (subscriber) {
15165 return this.getSubject().subscribe(subscriber);
15167 ConnectableObservable.prototype.getSubject = function () {
15168 var subject = this._subject;
15169 if (!subject || subject.isStopped) {
15170 this._subject = this.subjectFactory();
15172 return this._subject;
15174 ConnectableObservable.prototype.connect = function () {
15175 var connection = this._connection;
15177 this._isComplete = false;
15178 connection = this._connection = new Subscription_1.Subscription();
15179 connection.add(this.source
15180 .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
15181 if (connection.closed) {
15182 this._connection = null;
15183 connection = Subscription_1.Subscription.EMPTY;
15188 ConnectableObservable.prototype.refCount = function () {
15189 return refCount_1.refCount()(this);
15191 return ConnectableObservable;
15192 }(Observable_1.Observable));
15193 exports.ConnectableObservable = ConnectableObservable;
15194 exports.connectableObservableDescriptor = (function () {
15195 var connectableProto = ConnectableObservable.prototype;
15197 operator: { value: null },
15198 _refCount: { value: 0, writable: true },
15199 _subject: { value: null, writable: true },
15200 _connection: { value: null, writable: true },
15201 _subscribe: { value: connectableProto._subscribe },
15202 _isComplete: { value: connectableProto._isComplete, writable: true },
15203 getSubject: { value: connectableProto.getSubject },
15204 connect: { value: connectableProto.connect },
15205 refCount: { value: connectableProto.refCount }
15208 var ConnectableSubscriber = (function (_super) {
15209 __extends(ConnectableSubscriber, _super);
15210 function ConnectableSubscriber(destination, connectable) {
15211 var _this = _super.call(this, destination) || this;
15212 _this.connectable = connectable;
15215 ConnectableSubscriber.prototype._error = function (err) {
15216 this._unsubscribe();
15217 _super.prototype._error.call(this, err);
15219 ConnectableSubscriber.prototype._complete = function () {
15220 this.connectable._isComplete = true;
15221 this._unsubscribe();
15222 _super.prototype._complete.call(this);
15224 ConnectableSubscriber.prototype._unsubscribe = function () {
15225 var connectable = this.connectable;
15227 this.connectable = null;
15228 var connection = connectable._connection;
15229 connectable._refCount = 0;
15230 connectable._subject = null;
15231 connectable._connection = null;
15233 connection.unsubscribe();
15237 return ConnectableSubscriber;
15238 }(Subject_1.SubjectSubscriber));
15239 var RefCountOperator = (function () {
15240 function RefCountOperator(connectable) {
15241 this.connectable = connectable;
15243 RefCountOperator.prototype.call = function (subscriber, source) {
15244 var connectable = this.connectable;
15245 connectable._refCount++;
15246 var refCounter = new RefCountSubscriber(subscriber, connectable);
15247 var subscription = source.subscribe(refCounter);
15248 if (!refCounter.closed) {
15249 refCounter.connection = connectable.connect();
15251 return subscription;
15253 return RefCountOperator;
15255 var RefCountSubscriber = (function (_super) {
15256 __extends(RefCountSubscriber, _super);
15257 function RefCountSubscriber(destination, connectable) {
15258 var _this = _super.call(this, destination) || this;
15259 _this.connectable = connectable;
15262 RefCountSubscriber.prototype._unsubscribe = function () {
15263 var connectable = this.connectable;
15264 if (!connectable) {
15265 this.connection = null;
15268 this.connectable = null;
15269 var refCount = connectable._refCount;
15270 if (refCount <= 0) {
15271 this.connection = null;
15274 connectable._refCount = refCount - 1;
15275 if (refCount > 1) {
15276 this.connection = null;
15279 var connection = this.connection;
15280 var sharedConnection = connectable._connection;
15281 this.connection = null;
15282 if (sharedConnection && (!connection || sharedConnection === connection)) {
15283 sharedConnection.unsubscribe();
15286 return RefCountSubscriber;
15287 }(Subscriber_1.Subscriber));
15289 },{"../Observable":48,"../Subject":53,"../Subscriber":55,"../Subscription":56,"../operators/refCount":147}],59:[function(require,module,exports){
15291 var __extends = (this && this.__extends) || (function () {
15292 var extendStatics = function (d, b) {
15293 extendStatics = Object.setPrototypeOf ||
15294 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15295 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15296 return extendStatics(d, b);
15298 return function (d, b) {
15299 extendStatics(d, b);
15300 function __() { this.constructor = d; }
15301 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15304 Object.defineProperty(exports, "__esModule", { value: true });
15305 var Observable_1 = require("../Observable");
15306 var asap_1 = require("../scheduler/asap");
15307 var isNumeric_1 = require("../util/isNumeric");
15308 var SubscribeOnObservable = (function (_super) {
15309 __extends(SubscribeOnObservable, _super);
15310 function SubscribeOnObservable(source, delayTime, scheduler) {
15311 if (delayTime === void 0) { delayTime = 0; }
15312 if (scheduler === void 0) { scheduler = asap_1.asap; }
15313 var _this = _super.call(this) || this;
15314 _this.source = source;
15315 _this.delayTime = delayTime;
15316 _this.scheduler = scheduler;
15317 if (!isNumeric_1.isNumeric(delayTime) || delayTime < 0) {
15318 _this.delayTime = 0;
15320 if (!scheduler || typeof scheduler.schedule !== 'function') {
15321 _this.scheduler = asap_1.asap;
15325 SubscribeOnObservable.create = function (source, delay, scheduler) {
15326 if (delay === void 0) { delay = 0; }
15327 if (scheduler === void 0) { scheduler = asap_1.asap; }
15328 return new SubscribeOnObservable(source, delay, scheduler);
15330 SubscribeOnObservable.dispatch = function (arg) {
15331 var source = arg.source, subscriber = arg.subscriber;
15332 return this.add(source.subscribe(subscriber));
15334 SubscribeOnObservable.prototype._subscribe = function (subscriber) {
15335 var delay = this.delayTime;
15336 var source = this.source;
15337 var scheduler = this.scheduler;
15338 return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
15339 source: source, subscriber: subscriber
15342 return SubscribeOnObservable;
15343 }(Observable_1.Observable));
15344 exports.SubscribeOnObservable = SubscribeOnObservable;
15346 },{"../Observable":48,"../scheduler/asap":205,"../util/isNumeric":226}],60:[function(require,module,exports){
15348 Object.defineProperty(exports, "__esModule", { value: true });
15349 var Observable_1 = require("../Observable");
15350 var AsyncSubject_1 = require("../AsyncSubject");
15351 var map_1 = require("../operators/map");
15352 var canReportError_1 = require("../util/canReportError");
15353 var isArray_1 = require("../util/isArray");
15354 var isScheduler_1 = require("../util/isScheduler");
15355 function bindCallback(callbackFunc, resultSelector, scheduler) {
15356 if (resultSelector) {
15357 if (isScheduler_1.isScheduler(resultSelector)) {
15358 scheduler = resultSelector;
15361 return function () {
15363 for (var _i = 0; _i < arguments.length; _i++) {
15364 args[_i] = arguments[_i];
15366 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); }));
15370 return function () {
15372 for (var _i = 0; _i < arguments.length; _i++) {
15373 args[_i] = arguments[_i];
15375 var context = this;
15380 callbackFunc: callbackFunc,
15381 scheduler: scheduler,
15383 return new Observable_1.Observable(function (subscriber) {
15386 subject = new AsyncSubject_1.AsyncSubject();
15387 var handler = function () {
15388 var innerArgs = [];
15389 for (var _i = 0; _i < arguments.length; _i++) {
15390 innerArgs[_i] = arguments[_i];
15392 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
15393 subject.complete();
15396 callbackFunc.apply(context, args.concat([handler]));
15399 if (canReportError_1.canReportError(subject)) {
15400 subject.error(err);
15407 return subject.subscribe(subscriber);
15411 args: args, subscriber: subscriber, params: params,
15413 return scheduler.schedule(dispatch, 0, state);
15418 exports.bindCallback = bindCallback;
15419 function dispatch(state) {
15422 var args = state.args, subscriber = state.subscriber, params = state.params;
15423 var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
15424 var subject = params.subject;
15426 subject = params.subject = new AsyncSubject_1.AsyncSubject();
15427 var handler = function () {
15428 var innerArgs = [];
15429 for (var _i = 0; _i < arguments.length; _i++) {
15430 innerArgs[_i] = arguments[_i];
15432 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
15433 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
15436 callbackFunc.apply(context, args.concat([handler]));
15439 subject.error(err);
15442 this.add(subject.subscribe(subscriber));
15444 function dispatchNext(state) {
15445 var value = state.value, subject = state.subject;
15446 subject.next(value);
15447 subject.complete();
15449 function dispatchError(state) {
15450 var err = state.err, subject = state.subject;
15451 subject.error(err);
15454 },{"../AsyncSubject":44,"../Observable":48,"../operators/map":125,"../util/canReportError":217,"../util/isArray":220,"../util/isScheduler":230}],61:[function(require,module,exports){
15456 Object.defineProperty(exports, "__esModule", { value: true });
15457 var Observable_1 = require("../Observable");
15458 var AsyncSubject_1 = require("../AsyncSubject");
15459 var map_1 = require("../operators/map");
15460 var canReportError_1 = require("../util/canReportError");
15461 var isScheduler_1 = require("../util/isScheduler");
15462 var isArray_1 = require("../util/isArray");
15463 function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
15464 if (resultSelector) {
15465 if (isScheduler_1.isScheduler(resultSelector)) {
15466 scheduler = resultSelector;
15469 return function () {
15471 for (var _i = 0; _i < arguments.length; _i++) {
15472 args[_i] = arguments[_i];
15474 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); }));
15478 return function () {
15480 for (var _i = 0; _i < arguments.length; _i++) {
15481 args[_i] = arguments[_i];
15484 subject: undefined,
15486 callbackFunc: callbackFunc,
15487 scheduler: scheduler,
15490 return new Observable_1.Observable(function (subscriber) {
15491 var context = params.context;
15492 var subject = params.subject;
15495 subject = params.subject = new AsyncSubject_1.AsyncSubject();
15496 var handler = function () {
15497 var innerArgs = [];
15498 for (var _i = 0; _i < arguments.length; _i++) {
15499 innerArgs[_i] = arguments[_i];
15501 var err = innerArgs.shift();
15503 subject.error(err);
15506 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
15507 subject.complete();
15510 callbackFunc.apply(context, args.concat([handler]));
15513 if (canReportError_1.canReportError(subject)) {
15514 subject.error(err);
15521 return subject.subscribe(subscriber);
15524 return scheduler.schedule(dispatch, 0, { params: params, subscriber: subscriber, context: context });
15529 exports.bindNodeCallback = bindNodeCallback;
15530 function dispatch(state) {
15532 var params = state.params, subscriber = state.subscriber, context = state.context;
15533 var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
15534 var subject = params.subject;
15536 subject = params.subject = new AsyncSubject_1.AsyncSubject();
15537 var handler = function () {
15538 var innerArgs = [];
15539 for (var _i = 0; _i < arguments.length; _i++) {
15540 innerArgs[_i] = arguments[_i];
15542 var err = innerArgs.shift();
15544 _this.add(scheduler.schedule(dispatchError, 0, { err: err, subject: subject }));
15547 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
15548 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
15552 callbackFunc.apply(context, args.concat([handler]));
15555 this.add(scheduler.schedule(dispatchError, 0, { err: err, subject: subject }));
15558 this.add(subject.subscribe(subscriber));
15560 function dispatchNext(arg) {
15561 var value = arg.value, subject = arg.subject;
15562 subject.next(value);
15563 subject.complete();
15565 function dispatchError(arg) {
15566 var err = arg.err, subject = arg.subject;
15567 subject.error(err);
15570 },{"../AsyncSubject":44,"../Observable":48,"../operators/map":125,"../util/canReportError":217,"../util/isArray":220,"../util/isScheduler":230}],62:[function(require,module,exports){
15572 var __extends = (this && this.__extends) || (function () {
15573 var extendStatics = function (d, b) {
15574 extendStatics = Object.setPrototypeOf ||
15575 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15576 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15577 return extendStatics(d, b);
15579 return function (d, b) {
15580 extendStatics(d, b);
15581 function __() { this.constructor = d; }
15582 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15585 Object.defineProperty(exports, "__esModule", { value: true });
15586 var isScheduler_1 = require("../util/isScheduler");
15587 var isArray_1 = require("../util/isArray");
15588 var OuterSubscriber_1 = require("../OuterSubscriber");
15589 var subscribeToResult_1 = require("../util/subscribeToResult");
15590 var fromArray_1 = require("./fromArray");
15592 function combineLatest() {
15593 var observables = [];
15594 for (var _i = 0; _i < arguments.length; _i++) {
15595 observables[_i] = arguments[_i];
15597 var resultSelector = null;
15598 var scheduler = null;
15599 if (isScheduler_1.isScheduler(observables[observables.length - 1])) {
15600 scheduler = observables.pop();
15602 if (typeof observables[observables.length - 1] === 'function') {
15603 resultSelector = observables.pop();
15605 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
15606 observables = observables[0];
15608 return fromArray_1.fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
15610 exports.combineLatest = combineLatest;
15611 var CombineLatestOperator = (function () {
15612 function CombineLatestOperator(resultSelector) {
15613 this.resultSelector = resultSelector;
15615 CombineLatestOperator.prototype.call = function (subscriber, source) {
15616 return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
15618 return CombineLatestOperator;
15620 exports.CombineLatestOperator = CombineLatestOperator;
15621 var CombineLatestSubscriber = (function (_super) {
15622 __extends(CombineLatestSubscriber, _super);
15623 function CombineLatestSubscriber(destination, resultSelector) {
15624 var _this = _super.call(this, destination) || this;
15625 _this.resultSelector = resultSelector;
15628 _this.observables = [];
15631 CombineLatestSubscriber.prototype._next = function (observable) {
15632 this.values.push(NONE);
15633 this.observables.push(observable);
15635 CombineLatestSubscriber.prototype._complete = function () {
15636 var observables = this.observables;
15637 var len = observables.length;
15639 this.destination.complete();
15643 this.toRespond = len;
15644 for (var i = 0; i < len; i++) {
15645 var observable = observables[i];
15646 this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i));
15650 CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
15651 if ((this.active -= 1) === 0) {
15652 this.destination.complete();
15655 CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15656 var values = this.values;
15657 var oldVal = values[outerIndex];
15658 var toRespond = !this.toRespond
15660 : oldVal === NONE ? --this.toRespond : this.toRespond;
15661 values[outerIndex] = innerValue;
15662 if (toRespond === 0) {
15663 if (this.resultSelector) {
15664 this._tryResultSelector(values);
15667 this.destination.next(values.slice());
15671 CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
15674 result = this.resultSelector.apply(this, values);
15677 this.destination.error(err);
15680 this.destination.next(result);
15682 return CombineLatestSubscriber;
15683 }(OuterSubscriber_1.OuterSubscriber));
15684 exports.CombineLatestSubscriber = CombineLatestSubscriber;
15686 },{"../OuterSubscriber":50,"../util/isArray":220,"../util/isScheduler":230,"../util/subscribeToResult":239,"./fromArray":68}],63:[function(require,module,exports){
15688 Object.defineProperty(exports, "__esModule", { value: true });
15689 var of_1 = require("./of");
15690 var concatAll_1 = require("../operators/concatAll");
15691 function concat() {
15692 var observables = [];
15693 for (var _i = 0; _i < arguments.length; _i++) {
15694 observables[_i] = arguments[_i];
15696 return concatAll_1.concatAll()(of_1.of.apply(void 0, observables));
15698 exports.concat = concat;
15700 },{"../operators/concatAll":97,"./of":76}],64:[function(require,module,exports){
15702 Object.defineProperty(exports, "__esModule", { value: true });
15703 var Observable_1 = require("../Observable");
15704 var from_1 = require("./from");
15705 var empty_1 = require("./empty");
15706 function defer(observableFactory) {
15707 return new Observable_1.Observable(function (subscriber) {
15710 input = observableFactory();
15713 subscriber.error(err);
15716 var source = input ? from_1.from(input) : empty_1.empty();
15717 return source.subscribe(subscriber);
15720 exports.defer = defer;
15722 },{"../Observable":48,"./empty":65,"./from":67}],65:[function(require,module,exports){
15724 Object.defineProperty(exports, "__esModule", { value: true });
15725 var Observable_1 = require("../Observable");
15726 exports.EMPTY = new Observable_1.Observable(function (subscriber) { return subscriber.complete(); });
15727 function empty(scheduler) {
15728 return scheduler ? emptyScheduled(scheduler) : exports.EMPTY;
15730 exports.empty = empty;
15731 function emptyScheduled(scheduler) {
15732 return new Observable_1.Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
15735 },{"../Observable":48}],66:[function(require,module,exports){
15737 Object.defineProperty(exports, "__esModule", { value: true });
15738 var Observable_1 = require("../Observable");
15739 var isArray_1 = require("../util/isArray");
15740 var map_1 = require("../operators/map");
15741 var isObject_1 = require("../util/isObject");
15742 var from_1 = require("./from");
15743 function forkJoin() {
15745 for (var _i = 0; _i < arguments.length; _i++) {
15746 sources[_i] = arguments[_i];
15748 if (sources.length === 1) {
15749 var first_1 = sources[0];
15750 if (isArray_1.isArray(first_1)) {
15751 return forkJoinInternal(first_1, null);
15753 if (isObject_1.isObject(first_1) && Object.getPrototypeOf(first_1) === Object.prototype) {
15754 var keys = Object.keys(first_1);
15755 return forkJoinInternal(keys.map(function (key) { return first_1[key]; }), keys);
15758 if (typeof sources[sources.length - 1] === 'function') {
15759 var resultSelector_1 = sources.pop();
15760 sources = (sources.length === 1 && isArray_1.isArray(sources[0])) ? sources[0] : sources;
15761 return forkJoinInternal(sources, null).pipe(map_1.map(function (args) { return resultSelector_1.apply(void 0, args); }));
15763 return forkJoinInternal(sources, null);
15765 exports.forkJoin = forkJoin;
15766 function forkJoinInternal(sources, keys) {
15767 return new Observable_1.Observable(function (subscriber) {
15768 var len = sources.length;
15770 subscriber.complete();
15773 var values = new Array(len);
15776 var _loop_1 = function (i) {
15777 var source = from_1.from(sources[i]);
15778 var hasValue = false;
15779 subscriber.add(source.subscribe({
15780 next: function (value) {
15787 error: function (err) { return subscriber.error(err); },
15788 complete: function () {
15790 if (completed === len || !hasValue) {
15791 if (emitted === len) {
15792 subscriber.next(keys ?
15793 keys.reduce(function (result, key, i) { return (result[key] = values[i], result); }, {}) :
15796 subscriber.complete();
15801 for (var i = 0; i < len; i++) {
15807 },{"../Observable":48,"../operators/map":125,"../util/isArray":220,"../util/isObject":227,"./from":67}],67:[function(require,module,exports){
15809 Object.defineProperty(exports, "__esModule", { value: true });
15810 var Observable_1 = require("../Observable");
15811 var subscribeTo_1 = require("../util/subscribeTo");
15812 var scheduled_1 = require("../scheduled/scheduled");
15813 function from(input, scheduler) {
15815 if (input instanceof Observable_1.Observable) {
15818 return new Observable_1.Observable(subscribeTo_1.subscribeTo(input));
15821 return scheduled_1.scheduled(input, scheduler);
15824 exports.from = from;
15826 },{"../Observable":48,"../scheduled/scheduled":193,"../util/subscribeTo":234}],68:[function(require,module,exports){
15828 Object.defineProperty(exports, "__esModule", { value: true });
15829 var Observable_1 = require("../Observable");
15830 var subscribeToArray_1 = require("../util/subscribeToArray");
15831 var scheduleArray_1 = require("../scheduled/scheduleArray");
15832 function fromArray(input, scheduler) {
15834 return new Observable_1.Observable(subscribeToArray_1.subscribeToArray(input));
15837 return scheduleArray_1.scheduleArray(input, scheduler);
15840 exports.fromArray = fromArray;
15842 },{"../Observable":48,"../scheduled/scheduleArray":189,"../util/subscribeToArray":235}],69:[function(require,module,exports){
15844 Object.defineProperty(exports, "__esModule", { value: true });
15845 var Observable_1 = require("../Observable");
15846 var isArray_1 = require("../util/isArray");
15847 var isFunction_1 = require("../util/isFunction");
15848 var map_1 = require("../operators/map");
15849 var toString = (function () { return Object.prototype.toString; })();
15850 function fromEvent(target, eventName, options, resultSelector) {
15851 if (isFunction_1.isFunction(options)) {
15852 resultSelector = options;
15853 options = undefined;
15855 if (resultSelector) {
15856 return fromEvent(target, eventName, options).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
15858 return new Observable_1.Observable(function (subscriber) {
15859 function handler(e) {
15860 if (arguments.length > 1) {
15861 subscriber.next(Array.prototype.slice.call(arguments));
15864 subscriber.next(e);
15867 setupSubscription(target, eventName, handler, subscriber, options);
15870 exports.fromEvent = fromEvent;
15871 function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
15873 if (isEventTarget(sourceObj)) {
15874 var source_1 = sourceObj;
15875 sourceObj.addEventListener(eventName, handler, options);
15876 unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
15878 else if (isJQueryStyleEventEmitter(sourceObj)) {
15879 var source_2 = sourceObj;
15880 sourceObj.on(eventName, handler);
15881 unsubscribe = function () { return source_2.off(eventName, handler); };
15883 else if (isNodeStyleEventEmitter(sourceObj)) {
15884 var source_3 = sourceObj;
15885 sourceObj.addListener(eventName, handler);
15886 unsubscribe = function () { return source_3.removeListener(eventName, handler); };
15888 else if (sourceObj && sourceObj.length) {
15889 for (var i = 0, len = sourceObj.length; i < len; i++) {
15890 setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
15894 throw new TypeError('Invalid event target');
15896 subscriber.add(unsubscribe);
15898 function isNodeStyleEventEmitter(sourceObj) {
15899 return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
15901 function isJQueryStyleEventEmitter(sourceObj) {
15902 return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
15904 function isEventTarget(sourceObj) {
15905 return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
15908 },{"../Observable":48,"../operators/map":125,"../util/isArray":220,"../util/isFunction":223}],70:[function(require,module,exports){
15910 Object.defineProperty(exports, "__esModule", { value: true });
15911 var Observable_1 = require("../Observable");
15912 var isArray_1 = require("../util/isArray");
15913 var isFunction_1 = require("../util/isFunction");
15914 var map_1 = require("../operators/map");
15915 function fromEventPattern(addHandler, removeHandler, resultSelector) {
15916 if (resultSelector) {
15917 return fromEventPattern(addHandler, removeHandler).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
15919 return new Observable_1.Observable(function (subscriber) {
15920 var handler = function () {
15922 for (var _i = 0; _i < arguments.length; _i++) {
15923 e[_i] = arguments[_i];
15925 return subscriber.next(e.length === 1 ? e[0] : e);
15929 retValue = addHandler(handler);
15932 subscriber.error(err);
15935 if (!isFunction_1.isFunction(removeHandler)) {
15938 return function () { return removeHandler(handler, retValue); };
15941 exports.fromEventPattern = fromEventPattern;
15943 },{"../Observable":48,"../operators/map":125,"../util/isArray":220,"../util/isFunction":223}],71:[function(require,module,exports){
15945 Object.defineProperty(exports, "__esModule", { value: true });
15946 var Observable_1 = require("../Observable");
15947 var identity_1 = require("../util/identity");
15948 var isScheduler_1 = require("../util/isScheduler");
15949 function generate(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
15950 var resultSelector;
15952 if (arguments.length == 1) {
15953 var options = initialStateOrOptions;
15954 initialState = options.initialState;
15955 condition = options.condition;
15956 iterate = options.iterate;
15957 resultSelector = options.resultSelector || identity_1.identity;
15958 scheduler = options.scheduler;
15960 else if (resultSelectorOrObservable === undefined || isScheduler_1.isScheduler(resultSelectorOrObservable)) {
15961 initialState = initialStateOrOptions;
15962 resultSelector = identity_1.identity;
15963 scheduler = resultSelectorOrObservable;
15966 initialState = initialStateOrOptions;
15967 resultSelector = resultSelectorOrObservable;
15969 return new Observable_1.Observable(function (subscriber) {
15970 var state = initialState;
15972 return scheduler.schedule(dispatch, 0, {
15973 subscriber: subscriber,
15975 condition: condition,
15976 resultSelector: resultSelector,
15982 var conditionResult = void 0;
15984 conditionResult = condition(state);
15987 subscriber.error(err);
15990 if (!conditionResult) {
15991 subscriber.complete();
15995 var value = void 0;
15997 value = resultSelector(state);
16000 subscriber.error(err);
16003 subscriber.next(value);
16004 if (subscriber.closed) {
16008 state = iterate(state);
16011 subscriber.error(err);
16018 exports.generate = generate;
16019 function dispatch(state) {
16020 var subscriber = state.subscriber, condition = state.condition;
16021 if (subscriber.closed) {
16024 if (state.needIterate) {
16026 state.state = state.iterate(state.state);
16029 subscriber.error(err);
16034 state.needIterate = true;
16037 var conditionResult = void 0;
16039 conditionResult = condition(state.state);
16042 subscriber.error(err);
16045 if (!conditionResult) {
16046 subscriber.complete();
16049 if (subscriber.closed) {
16055 value = state.resultSelector(state.state);
16058 subscriber.error(err);
16061 if (subscriber.closed) {
16064 subscriber.next(value);
16065 if (subscriber.closed) {
16068 return this.schedule(state);
16071 },{"../Observable":48,"../util/identity":219,"../util/isScheduler":230}],72:[function(require,module,exports){
16073 Object.defineProperty(exports, "__esModule", { value: true });
16074 var defer_1 = require("./defer");
16075 var empty_1 = require("./empty");
16076 function iif(condition, trueResult, falseResult) {
16077 if (trueResult === void 0) { trueResult = empty_1.EMPTY; }
16078 if (falseResult === void 0) { falseResult = empty_1.EMPTY; }
16079 return defer_1.defer(function () { return condition() ? trueResult : falseResult; });
16083 },{"./defer":64,"./empty":65}],73:[function(require,module,exports){
16085 Object.defineProperty(exports, "__esModule", { value: true });
16086 var Observable_1 = require("../Observable");
16087 var async_1 = require("../scheduler/async");
16088 var isNumeric_1 = require("../util/isNumeric");
16089 function interval(period, scheduler) {
16090 if (period === void 0) { period = 0; }
16091 if (scheduler === void 0) { scheduler = async_1.async; }
16092 if (!isNumeric_1.isNumeric(period) || period < 0) {
16095 if (!scheduler || typeof scheduler.schedule !== 'function') {
16096 scheduler = async_1.async;
16098 return new Observable_1.Observable(function (subscriber) {
16099 subscriber.add(scheduler.schedule(dispatch, period, { subscriber: subscriber, counter: 0, period: period }));
16103 exports.interval = interval;
16104 function dispatch(state) {
16105 var subscriber = state.subscriber, counter = state.counter, period = state.period;
16106 subscriber.next(counter);
16107 this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
16110 },{"../Observable":48,"../scheduler/async":206,"../util/isNumeric":226}],74:[function(require,module,exports){
16112 Object.defineProperty(exports, "__esModule", { value: true });
16113 var Observable_1 = require("../Observable");
16114 var isScheduler_1 = require("../util/isScheduler");
16115 var mergeAll_1 = require("../operators/mergeAll");
16116 var fromArray_1 = require("./fromArray");
16118 var observables = [];
16119 for (var _i = 0; _i < arguments.length; _i++) {
16120 observables[_i] = arguments[_i];
16122 var concurrent = Number.POSITIVE_INFINITY;
16123 var scheduler = null;
16124 var last = observables[observables.length - 1];
16125 if (isScheduler_1.isScheduler(last)) {
16126 scheduler = observables.pop();
16127 if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
16128 concurrent = observables.pop();
16131 else if (typeof last === 'number') {
16132 concurrent = observables.pop();
16134 if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) {
16135 return observables[0];
16137 return mergeAll_1.mergeAll(concurrent)(fromArray_1.fromArray(observables, scheduler));
16139 exports.merge = merge;
16141 },{"../Observable":48,"../operators/mergeAll":130,"../util/isScheduler":230,"./fromArray":68}],75:[function(require,module,exports){
16143 Object.defineProperty(exports, "__esModule", { value: true });
16144 var Observable_1 = require("../Observable");
16145 var noop_1 = require("../util/noop");
16146 exports.NEVER = new Observable_1.Observable(noop_1.noop);
16148 return exports.NEVER;
16150 exports.never = never;
16152 },{"../Observable":48,"../util/noop":231}],76:[function(require,module,exports){
16154 Object.defineProperty(exports, "__esModule", { value: true });
16155 var isScheduler_1 = require("../util/isScheduler");
16156 var fromArray_1 = require("./fromArray");
16157 var scheduleArray_1 = require("../scheduled/scheduleArray");
16160 for (var _i = 0; _i < arguments.length; _i++) {
16161 args[_i] = arguments[_i];
16163 var scheduler = args[args.length - 1];
16164 if (isScheduler_1.isScheduler(scheduler)) {
16166 return scheduleArray_1.scheduleArray(args, scheduler);
16169 return fromArray_1.fromArray(args);
16174 },{"../scheduled/scheduleArray":189,"../util/isScheduler":230,"./fromArray":68}],77:[function(require,module,exports){
16176 Object.defineProperty(exports, "__esModule", { value: true });
16177 var Observable_1 = require("../Observable");
16178 var from_1 = require("./from");
16179 var isArray_1 = require("../util/isArray");
16180 var empty_1 = require("./empty");
16181 function onErrorResumeNext() {
16183 for (var _i = 0; _i < arguments.length; _i++) {
16184 sources[_i] = arguments[_i];
16186 if (sources.length === 0) {
16187 return empty_1.EMPTY;
16189 var first = sources[0], remainder = sources.slice(1);
16190 if (sources.length === 1 && isArray_1.isArray(first)) {
16191 return onErrorResumeNext.apply(void 0, first);
16193 return new Observable_1.Observable(function (subscriber) {
16194 var subNext = function () { return subscriber.add(onErrorResumeNext.apply(void 0, remainder).subscribe(subscriber)); };
16195 return from_1.from(first).subscribe({
16196 next: function (value) { subscriber.next(value); },
16202 exports.onErrorResumeNext = onErrorResumeNext;
16204 },{"../Observable":48,"../util/isArray":220,"./empty":65,"./from":67}],78:[function(require,module,exports){
16206 Object.defineProperty(exports, "__esModule", { value: true });
16207 var Observable_1 = require("../Observable");
16208 var Subscription_1 = require("../Subscription");
16209 function pairs(obj, scheduler) {
16211 return new Observable_1.Observable(function (subscriber) {
16212 var keys = Object.keys(obj);
16213 for (var i = 0; i < keys.length && !subscriber.closed; i++) {
16215 if (obj.hasOwnProperty(key)) {
16216 subscriber.next([key, obj[key]]);
16219 subscriber.complete();
16223 return new Observable_1.Observable(function (subscriber) {
16224 var keys = Object.keys(obj);
16225 var subscription = new Subscription_1.Subscription();
16226 subscription.add(scheduler.schedule(dispatch, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
16227 return subscription;
16231 exports.pairs = pairs;
16232 function dispatch(state) {
16233 var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
16234 if (!subscriber.closed) {
16235 if (index < keys.length) {
16236 var key = keys[index];
16237 subscriber.next([key, obj[key]]);
16238 subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
16241 subscriber.complete();
16245 exports.dispatch = dispatch;
16247 },{"../Observable":48,"../Subscription":56}],79:[function(require,module,exports){
16249 Object.defineProperty(exports, "__esModule", { value: true });
16250 var not_1 = require("../util/not");
16251 var subscribeTo_1 = require("../util/subscribeTo");
16252 var filter_1 = require("../operators/filter");
16253 var Observable_1 = require("../Observable");
16254 function partition(source, predicate, thisArg) {
16256 filter_1.filter(predicate, thisArg)(new Observable_1.Observable(subscribeTo_1.subscribeTo(source))),
16257 filter_1.filter(not_1.not(predicate, thisArg))(new Observable_1.Observable(subscribeTo_1.subscribeTo(source)))
16260 exports.partition = partition;
16262 },{"../Observable":48,"../operators/filter":116,"../util/not":232,"../util/subscribeTo":234}],80:[function(require,module,exports){
16264 var __extends = (this && this.__extends) || (function () {
16265 var extendStatics = function (d, b) {
16266 extendStatics = Object.setPrototypeOf ||
16267 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16268 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16269 return extendStatics(d, b);
16271 return function (d, b) {
16272 extendStatics(d, b);
16273 function __() { this.constructor = d; }
16274 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16277 Object.defineProperty(exports, "__esModule", { value: true });
16278 var isArray_1 = require("../util/isArray");
16279 var fromArray_1 = require("./fromArray");
16280 var OuterSubscriber_1 = require("../OuterSubscriber");
16281 var subscribeToResult_1 = require("../util/subscribeToResult");
16283 var observables = [];
16284 for (var _i = 0; _i < arguments.length; _i++) {
16285 observables[_i] = arguments[_i];
16287 if (observables.length === 1) {
16288 if (isArray_1.isArray(observables[0])) {
16289 observables = observables[0];
16292 return observables[0];
16295 return fromArray_1.fromArray(observables, undefined).lift(new RaceOperator());
16297 exports.race = race;
16298 var RaceOperator = (function () {
16299 function RaceOperator() {
16301 RaceOperator.prototype.call = function (subscriber, source) {
16302 return source.subscribe(new RaceSubscriber(subscriber));
16304 return RaceOperator;
16306 exports.RaceOperator = RaceOperator;
16307 var RaceSubscriber = (function (_super) {
16308 __extends(RaceSubscriber, _super);
16309 function RaceSubscriber(destination) {
16310 var _this = _super.call(this, destination) || this;
16311 _this.hasFirst = false;
16312 _this.observables = [];
16313 _this.subscriptions = [];
16316 RaceSubscriber.prototype._next = function (observable) {
16317 this.observables.push(observable);
16319 RaceSubscriber.prototype._complete = function () {
16320 var observables = this.observables;
16321 var len = observables.length;
16323 this.destination.complete();
16326 for (var i = 0; i < len && !this.hasFirst; i++) {
16327 var observable = observables[i];
16328 var subscription = subscribeToResult_1.subscribeToResult(this, observable, observable, i);
16329 if (this.subscriptions) {
16330 this.subscriptions.push(subscription);
16332 this.add(subscription);
16334 this.observables = null;
16337 RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
16338 if (!this.hasFirst) {
16339 this.hasFirst = true;
16340 for (var i = 0; i < this.subscriptions.length; i++) {
16341 if (i !== outerIndex) {
16342 var subscription = this.subscriptions[i];
16343 subscription.unsubscribe();
16344 this.remove(subscription);
16347 this.subscriptions = null;
16349 this.destination.next(innerValue);
16351 return RaceSubscriber;
16352 }(OuterSubscriber_1.OuterSubscriber));
16353 exports.RaceSubscriber = RaceSubscriber;
16355 },{"../OuterSubscriber":50,"../util/isArray":220,"../util/subscribeToResult":239,"./fromArray":68}],81:[function(require,module,exports){
16357 Object.defineProperty(exports, "__esModule", { value: true });
16358 var Observable_1 = require("../Observable");
16359 function range(start, count, scheduler) {
16360 if (start === void 0) { start = 0; }
16361 return new Observable_1.Observable(function (subscriber) {
16362 if (count === undefined) {
16367 var current = start;
16369 return scheduler.schedule(dispatch, 0, {
16370 index: index, count: count, start: start, subscriber: subscriber
16375 if (index++ >= count) {
16376 subscriber.complete();
16379 subscriber.next(current++);
16380 if (subscriber.closed) {
16388 exports.range = range;
16389 function dispatch(state) {
16390 var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
16391 if (index >= count) {
16392 subscriber.complete();
16395 subscriber.next(start);
16396 if (subscriber.closed) {
16399 state.index = index + 1;
16400 state.start = start + 1;
16401 this.schedule(state);
16403 exports.dispatch = dispatch;
16405 },{"../Observable":48}],82:[function(require,module,exports){
16407 Object.defineProperty(exports, "__esModule", { value: true });
16408 var Observable_1 = require("../Observable");
16409 function throwError(error, scheduler) {
16411 return new Observable_1.Observable(function (subscriber) { return subscriber.error(error); });
16414 return new Observable_1.Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });
16417 exports.throwError = throwError;
16418 function dispatch(_a) {
16419 var error = _a.error, subscriber = _a.subscriber;
16420 subscriber.error(error);
16423 },{"../Observable":48}],83:[function(require,module,exports){
16425 Object.defineProperty(exports, "__esModule", { value: true });
16426 var Observable_1 = require("../Observable");
16427 var async_1 = require("../scheduler/async");
16428 var isNumeric_1 = require("../util/isNumeric");
16429 var isScheduler_1 = require("../util/isScheduler");
16430 function timer(dueTime, periodOrScheduler, scheduler) {
16431 if (dueTime === void 0) { dueTime = 0; }
16433 if (isNumeric_1.isNumeric(periodOrScheduler)) {
16434 period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
16436 else if (isScheduler_1.isScheduler(periodOrScheduler)) {
16437 scheduler = periodOrScheduler;
16439 if (!isScheduler_1.isScheduler(scheduler)) {
16440 scheduler = async_1.async;
16442 return new Observable_1.Observable(function (subscriber) {
16443 var due = isNumeric_1.isNumeric(dueTime)
16445 : (+dueTime - scheduler.now());
16446 return scheduler.schedule(dispatch, due, {
16447 index: 0, period: period, subscriber: subscriber
16451 exports.timer = timer;
16452 function dispatch(state) {
16453 var index = state.index, period = state.period, subscriber = state.subscriber;
16454 subscriber.next(index);
16455 if (subscriber.closed) {
16458 else if (period === -1) {
16459 return subscriber.complete();
16461 state.index = index + 1;
16462 this.schedule(state, period);
16465 },{"../Observable":48,"../scheduler/async":206,"../util/isNumeric":226,"../util/isScheduler":230}],84:[function(require,module,exports){
16467 Object.defineProperty(exports, "__esModule", { value: true });
16468 var Observable_1 = require("../Observable");
16469 var from_1 = require("./from");
16470 var empty_1 = require("./empty");
16471 function using(resourceFactory, observableFactory) {
16472 return new Observable_1.Observable(function (subscriber) {
16475 resource = resourceFactory();
16478 subscriber.error(err);
16483 result = observableFactory(resource);
16486 subscriber.error(err);
16489 var source = result ? from_1.from(result) : empty_1.EMPTY;
16490 var subscription = source.subscribe(subscriber);
16491 return function () {
16492 subscription.unsubscribe();
16494 resource.unsubscribe();
16499 exports.using = using;
16501 },{"../Observable":48,"./empty":65,"./from":67}],85:[function(require,module,exports){
16503 var __extends = (this && this.__extends) || (function () {
16504 var extendStatics = function (d, b) {
16505 extendStatics = Object.setPrototypeOf ||
16506 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16507 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16508 return extendStatics(d, b);
16510 return function (d, b) {
16511 extendStatics(d, b);
16512 function __() { this.constructor = d; }
16513 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16516 Object.defineProperty(exports, "__esModule", { value: true });
16517 var fromArray_1 = require("./fromArray");
16518 var isArray_1 = require("../util/isArray");
16519 var Subscriber_1 = require("../Subscriber");
16520 var OuterSubscriber_1 = require("../OuterSubscriber");
16521 var subscribeToResult_1 = require("../util/subscribeToResult");
16522 var iterator_1 = require("../../internal/symbol/iterator");
16524 var observables = [];
16525 for (var _i = 0; _i < arguments.length; _i++) {
16526 observables[_i] = arguments[_i];
16528 var resultSelector = observables[observables.length - 1];
16529 if (typeof resultSelector === 'function') {
16532 return fromArray_1.fromArray(observables, undefined).lift(new ZipOperator(resultSelector));
16535 var ZipOperator = (function () {
16536 function ZipOperator(resultSelector) {
16537 this.resultSelector = resultSelector;
16539 ZipOperator.prototype.call = function (subscriber, source) {
16540 return source.subscribe(new ZipSubscriber(subscriber, this.resultSelector));
16542 return ZipOperator;
16544 exports.ZipOperator = ZipOperator;
16545 var ZipSubscriber = (function (_super) {
16546 __extends(ZipSubscriber, _super);
16547 function ZipSubscriber(destination, resultSelector, values) {
16548 if (values === void 0) { values = Object.create(null); }
16549 var _this = _super.call(this, destination) || this;
16550 _this.iterators = [];
16552 _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : null;
16553 _this.values = values;
16556 ZipSubscriber.prototype._next = function (value) {
16557 var iterators = this.iterators;
16558 if (isArray_1.isArray(value)) {
16559 iterators.push(new StaticArrayIterator(value));
16561 else if (typeof value[iterator_1.iterator] === 'function') {
16562 iterators.push(new StaticIterator(value[iterator_1.iterator]()));
16565 iterators.push(new ZipBufferIterator(this.destination, this, value));
16568 ZipSubscriber.prototype._complete = function () {
16569 var iterators = this.iterators;
16570 var len = iterators.length;
16571 this.unsubscribe();
16573 this.destination.complete();
16577 for (var i = 0; i < len; i++) {
16578 var iterator = iterators[i];
16579 if (iterator.stillUnsubscribed) {
16580 var destination = this.destination;
16581 destination.add(iterator.subscribe(iterator, i));
16588 ZipSubscriber.prototype.notifyInactive = function () {
16590 if (this.active === 0) {
16591 this.destination.complete();
16594 ZipSubscriber.prototype.checkIterators = function () {
16595 var iterators = this.iterators;
16596 var len = iterators.length;
16597 var destination = this.destination;
16598 for (var i = 0; i < len; i++) {
16599 var iterator = iterators[i];
16600 if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) {
16604 var shouldComplete = false;
16606 for (var i = 0; i < len; i++) {
16607 var iterator = iterators[i];
16608 var result = iterator.next();
16609 if (iterator.hasCompleted()) {
16610 shouldComplete = true;
16613 destination.complete();
16616 args.push(result.value);
16618 if (this.resultSelector) {
16619 this._tryresultSelector(args);
16622 destination.next(args);
16624 if (shouldComplete) {
16625 destination.complete();
16628 ZipSubscriber.prototype._tryresultSelector = function (args) {
16631 result = this.resultSelector.apply(this, args);
16634 this.destination.error(err);
16637 this.destination.next(result);
16639 return ZipSubscriber;
16640 }(Subscriber_1.Subscriber));
16641 exports.ZipSubscriber = ZipSubscriber;
16642 var StaticIterator = (function () {
16643 function StaticIterator(iterator) {
16644 this.iterator = iterator;
16645 this.nextResult = iterator.next();
16647 StaticIterator.prototype.hasValue = function () {
16650 StaticIterator.prototype.next = function () {
16651 var result = this.nextResult;
16652 this.nextResult = this.iterator.next();
16655 StaticIterator.prototype.hasCompleted = function () {
16656 var nextResult = this.nextResult;
16657 return nextResult && nextResult.done;
16659 return StaticIterator;
16661 var StaticArrayIterator = (function () {
16662 function StaticArrayIterator(array) {
16663 this.array = array;
16666 this.length = array.length;
16668 StaticArrayIterator.prototype[iterator_1.iterator] = function () {
16671 StaticArrayIterator.prototype.next = function (value) {
16672 var i = this.index++;
16673 var array = this.array;
16674 return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
16676 StaticArrayIterator.prototype.hasValue = function () {
16677 return this.array.length > this.index;
16679 StaticArrayIterator.prototype.hasCompleted = function () {
16680 return this.array.length === this.index;
16682 return StaticArrayIterator;
16684 var ZipBufferIterator = (function (_super) {
16685 __extends(ZipBufferIterator, _super);
16686 function ZipBufferIterator(destination, parent, observable) {
16687 var _this = _super.call(this, destination) || this;
16688 _this.parent = parent;
16689 _this.observable = observable;
16690 _this.stillUnsubscribed = true;
16692 _this.isComplete = false;
16695 ZipBufferIterator.prototype[iterator_1.iterator] = function () {
16698 ZipBufferIterator.prototype.next = function () {
16699 var buffer = this.buffer;
16700 if (buffer.length === 0 && this.isComplete) {
16701 return { value: null, done: true };
16704 return { value: buffer.shift(), done: false };
16707 ZipBufferIterator.prototype.hasValue = function () {
16708 return this.buffer.length > 0;
16710 ZipBufferIterator.prototype.hasCompleted = function () {
16711 return this.buffer.length === 0 && this.isComplete;
16713 ZipBufferIterator.prototype.notifyComplete = function () {
16714 if (this.buffer.length > 0) {
16715 this.isComplete = true;
16716 this.parent.notifyInactive();
16719 this.destination.complete();
16722 ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
16723 this.buffer.push(innerValue);
16724 this.parent.checkIterators();
16726 ZipBufferIterator.prototype.subscribe = function (value, index) {
16727 return subscribeToResult_1.subscribeToResult(this, this.observable, this, index);
16729 return ZipBufferIterator;
16730 }(OuterSubscriber_1.OuterSubscriber));
16732 },{"../../internal/symbol/iterator":208,"../OuterSubscriber":50,"../Subscriber":55,"../util/isArray":220,"../util/subscribeToResult":239,"./fromArray":68}],86:[function(require,module,exports){
16734 var __extends = (this && this.__extends) || (function () {
16735 var extendStatics = function (d, b) {
16736 extendStatics = Object.setPrototypeOf ||
16737 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16738 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16739 return extendStatics(d, b);
16741 return function (d, b) {
16742 extendStatics(d, b);
16743 function __() { this.constructor = d; }
16744 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16747 Object.defineProperty(exports, "__esModule", { value: true });
16748 var OuterSubscriber_1 = require("../OuterSubscriber");
16749 var subscribeToResult_1 = require("../util/subscribeToResult");
16750 function audit(durationSelector) {
16751 return function auditOperatorFunction(source) {
16752 return source.lift(new AuditOperator(durationSelector));
16755 exports.audit = audit;
16756 var AuditOperator = (function () {
16757 function AuditOperator(durationSelector) {
16758 this.durationSelector = durationSelector;
16760 AuditOperator.prototype.call = function (subscriber, source) {
16761 return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
16763 return AuditOperator;
16765 var AuditSubscriber = (function (_super) {
16766 __extends(AuditSubscriber, _super);
16767 function AuditSubscriber(destination, durationSelector) {
16768 var _this = _super.call(this, destination) || this;
16769 _this.durationSelector = durationSelector;
16770 _this.hasValue = false;
16773 AuditSubscriber.prototype._next = function (value) {
16774 this.value = value;
16775 this.hasValue = true;
16776 if (!this.throttled) {
16777 var duration = void 0;
16779 var durationSelector = this.durationSelector;
16780 duration = durationSelector(value);
16783 return this.destination.error(err);
16785 var innerSubscription = subscribeToResult_1.subscribeToResult(this, duration);
16786 if (!innerSubscription || innerSubscription.closed) {
16787 this.clearThrottle();
16790 this.add(this.throttled = innerSubscription);
16794 AuditSubscriber.prototype.clearThrottle = function () {
16795 var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
16797 this.remove(throttled);
16798 this.throttled = null;
16799 throttled.unsubscribe();
16803 this.hasValue = false;
16804 this.destination.next(value);
16807 AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
16808 this.clearThrottle();
16810 AuditSubscriber.prototype.notifyComplete = function () {
16811 this.clearThrottle();
16813 return AuditSubscriber;
16814 }(OuterSubscriber_1.OuterSubscriber));
16816 },{"../OuterSubscriber":50,"../util/subscribeToResult":239}],87:[function(require,module,exports){
16818 Object.defineProperty(exports, "__esModule", { value: true });
16819 var async_1 = require("../scheduler/async");
16820 var audit_1 = require("./audit");
16821 var timer_1 = require("../observable/timer");
16822 function auditTime(duration, scheduler) {
16823 if (scheduler === void 0) { scheduler = async_1.async; }
16824 return audit_1.audit(function () { return timer_1.timer(duration, scheduler); });
16826 exports.auditTime = auditTime;
16828 },{"../observable/timer":83,"../scheduler/async":206,"./audit":86}],88:[function(require,module,exports){
16830 var __extends = (this && this.__extends) || (function () {
16831 var extendStatics = function (d, b) {
16832 extendStatics = Object.setPrototypeOf ||
16833 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16834 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16835 return extendStatics(d, b);
16837 return function (d, b) {
16838 extendStatics(d, b);
16839 function __() { this.constructor = d; }
16840 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16843 Object.defineProperty(exports, "__esModule", { value: true });
16844 var OuterSubscriber_1 = require("../OuterSubscriber");
16845 var subscribeToResult_1 = require("../util/subscribeToResult");
16846 function buffer(closingNotifier) {
16847 return function bufferOperatorFunction(source) {
16848 return source.lift(new BufferOperator(closingNotifier));
16851 exports.buffer = buffer;
16852 var BufferOperator = (function () {
16853 function BufferOperator(closingNotifier) {
16854 this.closingNotifier = closingNotifier;
16856 BufferOperator.prototype.call = function (subscriber, source) {
16857 return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
16859 return BufferOperator;
16861 var BufferSubscriber = (function (_super) {
16862 __extends(BufferSubscriber, _super);
16863 function BufferSubscriber(destination, closingNotifier) {
16864 var _this = _super.call(this, destination) || this;
16866 _this.add(subscribeToResult_1.subscribeToResult(_this, closingNotifier));
16869 BufferSubscriber.prototype._next = function (value) {
16870 this.buffer.push(value);
16872 BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
16873 var buffer = this.buffer;
16875 this.destination.next(buffer);
16877 return BufferSubscriber;
16878 }(OuterSubscriber_1.OuterSubscriber));
16880 },{"../OuterSubscriber":50,"../util/subscribeToResult":239}],89:[function(require,module,exports){
16882 var __extends = (this && this.__extends) || (function () {
16883 var extendStatics = function (d, b) {
16884 extendStatics = Object.setPrototypeOf ||
16885 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16886 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16887 return extendStatics(d, b);
16889 return function (d, b) {
16890 extendStatics(d, b);
16891 function __() { this.constructor = d; }
16892 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16895 Object.defineProperty(exports, "__esModule", { value: true });
16896 var Subscriber_1 = require("../Subscriber");
16897 function bufferCount(bufferSize, startBufferEvery) {
16898 if (startBufferEvery === void 0) { startBufferEvery = null; }
16899 return function bufferCountOperatorFunction(source) {
16900 return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
16903 exports.bufferCount = bufferCount;
16904 var BufferCountOperator = (function () {
16905 function BufferCountOperator(bufferSize, startBufferEvery) {
16906 this.bufferSize = bufferSize;
16907 this.startBufferEvery = startBufferEvery;
16908 if (!startBufferEvery || bufferSize === startBufferEvery) {
16909 this.subscriberClass = BufferCountSubscriber;
16912 this.subscriberClass = BufferSkipCountSubscriber;
16915 BufferCountOperator.prototype.call = function (subscriber, source) {
16916 return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
16918 return BufferCountOperator;
16920 var BufferCountSubscriber = (function (_super) {
16921 __extends(BufferCountSubscriber, _super);
16922 function BufferCountSubscriber(destination, bufferSize) {
16923 var _this = _super.call(this, destination) || this;
16924 _this.bufferSize = bufferSize;
16928 BufferCountSubscriber.prototype._next = function (value) {
16929 var buffer = this.buffer;
16930 buffer.push(value);
16931 if (buffer.length == this.bufferSize) {
16932 this.destination.next(buffer);
16936 BufferCountSubscriber.prototype._complete = function () {
16937 var buffer = this.buffer;
16938 if (buffer.length > 0) {
16939 this.destination.next(buffer);
16941 _super.prototype._complete.call(this);
16943 return BufferCountSubscriber;
16944 }(Subscriber_1.Subscriber));
16945 var BufferSkipCountSubscriber = (function (_super) {
16946 __extends(BufferSkipCountSubscriber, _super);
16947 function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
16948 var _this = _super.call(this, destination) || this;
16949 _this.bufferSize = bufferSize;
16950 _this.startBufferEvery = startBufferEvery;
16951 _this.buffers = [];
16955 BufferSkipCountSubscriber.prototype._next = function (value) {
16956 var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
16958 if (count % startBufferEvery === 0) {
16961 for (var i = buffers.length; i--;) {
16962 var buffer = buffers[i];
16963 buffer.push(value);
16964 if (buffer.length === bufferSize) {
16965 buffers.splice(i, 1);
16966 this.destination.next(buffer);
16970 BufferSkipCountSubscriber.prototype._complete = function () {
16971 var _a = this, buffers = _a.buffers, destination = _a.destination;
16972 while (buffers.length > 0) {
16973 var buffer = buffers.shift();
16974 if (buffer.length > 0) {
16975 destination.next(buffer);
16978 _super.prototype._complete.call(this);
16980 return BufferSkipCountSubscriber;
16981 }(Subscriber_1.Subscriber));
16983 },{"../Subscriber":55}],90:[function(require,module,exports){
16985 var __extends = (this && this.__extends) || (function () {
16986 var extendStatics = function (d, b) {
16987 extendStatics = Object.setPrototypeOf ||
16988 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16989 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16990 return extendStatics(d, b);
16992 return function (d, b) {
16993 extendStatics(d, b);
16994 function __() { this.constructor = d; }
16995 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16998 Object.defineProperty(exports, "__esModule", { value: true });
16999 var async_1 = require("../scheduler/async");
17000 var Subscriber_1 = require("../Subscriber");
17001 var isScheduler_1 = require("../util/isScheduler");
17002 function bufferTime(bufferTimeSpan) {
17003 var length = arguments.length;
17004 var scheduler = async_1.async;
17005 if (isScheduler_1.isScheduler(arguments[arguments.length - 1])) {
17006 scheduler = arguments[arguments.length - 1];
17009 var bufferCreationInterval = null;
17011 bufferCreationInterval = arguments[1];
17013 var maxBufferSize = Number.POSITIVE_INFINITY;
17015 maxBufferSize = arguments[2];
17017 return function bufferTimeOperatorFunction(source) {
17018 return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
17021 exports.bufferTime = bufferTime;
17022 var BufferTimeOperator = (function () {
17023 function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
17024 this.bufferTimeSpan = bufferTimeSpan;
17025 this.bufferCreationInterval = bufferCreationInterval;
17026 this.maxBufferSize = maxBufferSize;
17027 this.scheduler = scheduler;
17029 BufferTimeOperator.prototype.call = function (subscriber, source) {
17030 return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
17032 return BufferTimeOperator;
17034 var Context = (function () {
17035 function Context() {
17040 var BufferTimeSubscriber = (function (_super) {
17041 __extends(BufferTimeSubscriber, _super);
17042 function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
17043 var _this = _super.call(this, destination) || this;
17044 _this.bufferTimeSpan = bufferTimeSpan;
17045 _this.bufferCreationInterval = bufferCreationInterval;
17046 _this.maxBufferSize = maxBufferSize;
17047 _this.scheduler = scheduler;
17048 _this.contexts = [];
17049 var context = _this.openContext();
17050 _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
17051 if (_this.timespanOnly) {
17052 var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
17053 _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
17056 var closeState = { subscriber: _this, context: context };
17057 var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
17058 _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
17059 _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
17063 BufferTimeSubscriber.prototype._next = function (value) {
17064 var contexts = this.contexts;
17065 var len = contexts.length;
17066 var filledBufferContext;
17067 for (var i = 0; i < len; i++) {
17068 var context_1 = contexts[i];
17069 var buffer = context_1.buffer;
17070 buffer.push(value);
17071 if (buffer.length == this.maxBufferSize) {
17072 filledBufferContext = context_1;
17075 if (filledBufferContext) {
17076 this.onBufferFull(filledBufferContext);
17079 BufferTimeSubscriber.prototype._error = function (err) {
17080 this.contexts.length = 0;
17081 _super.prototype._error.call(this, err);
17083 BufferTimeSubscriber.prototype._complete = function () {
17084 var _a = this, contexts = _a.contexts, destination = _a.destination;
17085 while (contexts.length > 0) {
17086 var context_2 = contexts.shift();
17087 destination.next(context_2.buffer);
17089 _super.prototype._complete.call(this);
17091 BufferTimeSubscriber.prototype._unsubscribe = function () {
17092 this.contexts = null;
17094 BufferTimeSubscriber.prototype.onBufferFull = function (context) {
17095 this.closeContext(context);
17096 var closeAction = context.closeAction;
17097 closeAction.unsubscribe();
17098 this.remove(closeAction);
17099 if (!this.closed && this.timespanOnly) {
17100 context = this.openContext();
17101 var bufferTimeSpan = this.bufferTimeSpan;
17102 var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
17103 this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
17106 BufferTimeSubscriber.prototype.openContext = function () {
17107 var context = new Context();
17108 this.contexts.push(context);
17111 BufferTimeSubscriber.prototype.closeContext = function (context) {
17112 this.destination.next(context.buffer);
17113 var contexts = this.contexts;
17114 var spliceIndex = contexts ? contexts.indexOf(context) : -1;
17115 if (spliceIndex >= 0) {
17116 contexts.splice(contexts.indexOf(context), 1);
17119 return BufferTimeSubscriber;
17120 }(Subscriber_1.Subscriber));
17121 function dispatchBufferTimeSpanOnly(state) {
17122 var subscriber = state.subscriber;
17123 var prevContext = state.context;
17125 subscriber.closeContext(prevContext);
17127 if (!subscriber.closed) {
17128 state.context = subscriber.openContext();
17129 state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
17132 function dispatchBufferCreation(state) {
17133 var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
17134 var context = subscriber.openContext();
17136 if (!subscriber.closed) {
17137 subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
17138 action.schedule(state, bufferCreationInterval);
17141 function dispatchBufferClose(arg) {
17142 var subscriber = arg.subscriber, context = arg.context;
17143 subscriber.closeContext(context);
17146 },{"../Subscriber":55,"../scheduler/async":206,"../util/isScheduler":230}],91:[function(require,module,exports){
17148 var __extends = (this && this.__extends) || (function () {
17149 var extendStatics = function (d, b) {
17150 extendStatics = Object.setPrototypeOf ||
17151 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17152 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17153 return extendStatics(d, b);
17155 return function (d, b) {
17156 extendStatics(d, b);
17157 function __() { this.constructor = d; }
17158 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17161 Object.defineProperty(exports, "__esModule", { value: true });
17162 var Subscription_1 = require("../Subscription");
17163 var subscribeToResult_1 = require("../util/subscribeToResult");
17164 var OuterSubscriber_1 = require("../OuterSubscriber");
17165 function bufferToggle(openings, closingSelector) {
17166 return function bufferToggleOperatorFunction(source) {
17167 return source.lift(new BufferToggleOperator(openings, closingSelector));
17170 exports.bufferToggle = bufferToggle;
17171 var BufferToggleOperator = (function () {
17172 function BufferToggleOperator(openings, closingSelector) {
17173 this.openings = openings;
17174 this.closingSelector = closingSelector;
17176 BufferToggleOperator.prototype.call = function (subscriber, source) {
17177 return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
17179 return BufferToggleOperator;
17181 var BufferToggleSubscriber = (function (_super) {
17182 __extends(BufferToggleSubscriber, _super);
17183 function BufferToggleSubscriber(destination, openings, closingSelector) {
17184 var _this = _super.call(this, destination) || this;
17185 _this.openings = openings;
17186 _this.closingSelector = closingSelector;
17187 _this.contexts = [];
17188 _this.add(subscribeToResult_1.subscribeToResult(_this, openings));
17191 BufferToggleSubscriber.prototype._next = function (value) {
17192 var contexts = this.contexts;
17193 var len = contexts.length;
17194 for (var i = 0; i < len; i++) {
17195 contexts[i].buffer.push(value);
17198 BufferToggleSubscriber.prototype._error = function (err) {
17199 var contexts = this.contexts;
17200 while (contexts.length > 0) {
17201 var context_1 = contexts.shift();
17202 context_1.subscription.unsubscribe();
17203 context_1.buffer = null;
17204 context_1.subscription = null;
17206 this.contexts = null;
17207 _super.prototype._error.call(this, err);
17209 BufferToggleSubscriber.prototype._complete = function () {
17210 var contexts = this.contexts;
17211 while (contexts.length > 0) {
17212 var context_2 = contexts.shift();
17213 this.destination.next(context_2.buffer);
17214 context_2.subscription.unsubscribe();
17215 context_2.buffer = null;
17216 context_2.subscription = null;
17218 this.contexts = null;
17219 _super.prototype._complete.call(this);
17221 BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
17222 outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
17224 BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
17225 this.closeBuffer(innerSub.context);
17227 BufferToggleSubscriber.prototype.openBuffer = function (value) {
17229 var closingSelector = this.closingSelector;
17230 var closingNotifier = closingSelector.call(this, value);
17231 if (closingNotifier) {
17232 this.trySubscribe(closingNotifier);
17239 BufferToggleSubscriber.prototype.closeBuffer = function (context) {
17240 var contexts = this.contexts;
17241 if (contexts && context) {
17242 var buffer = context.buffer, subscription = context.subscription;
17243 this.destination.next(buffer);
17244 contexts.splice(contexts.indexOf(context), 1);
17245 this.remove(subscription);
17246 subscription.unsubscribe();
17249 BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
17250 var contexts = this.contexts;
17252 var subscription = new Subscription_1.Subscription();
17253 var context = { buffer: buffer, subscription: subscription };
17254 contexts.push(context);
17255 var innerSubscription = subscribeToResult_1.subscribeToResult(this, closingNotifier, context);
17256 if (!innerSubscription || innerSubscription.closed) {
17257 this.closeBuffer(context);
17260 innerSubscription.context = context;
17261 this.add(innerSubscription);
17262 subscription.add(innerSubscription);
17265 return BufferToggleSubscriber;
17266 }(OuterSubscriber_1.OuterSubscriber));
17268 },{"../OuterSubscriber":50,"../Subscription":56,"../util/subscribeToResult":239}],92:[function(require,module,exports){
17270 var __extends = (this && this.__extends) || (function () {
17271 var extendStatics = function (d, b) {
17272 extendStatics = Object.setPrototypeOf ||
17273 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17274 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17275 return extendStatics(d, b);
17277 return function (d, b) {
17278 extendStatics(d, b);
17279 function __() { this.constructor = d; }
17280 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17283 Object.defineProperty(exports, "__esModule", { value: true });
17284 var Subscription_1 = require("../Subscription");
17285 var OuterSubscriber_1 = require("../OuterSubscriber");
17286 var subscribeToResult_1 = require("../util/subscribeToResult");
17287 function bufferWhen(closingSelector) {
17288 return function (source) {
17289 return source.lift(new BufferWhenOperator(closingSelector));
17292 exports.bufferWhen = bufferWhen;
17293 var BufferWhenOperator = (function () {
17294 function BufferWhenOperator(closingSelector) {
17295 this.closingSelector = closingSelector;
17297 BufferWhenOperator.prototype.call = function (subscriber, source) {
17298 return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
17300 return BufferWhenOperator;
17302 var BufferWhenSubscriber = (function (_super) {
17303 __extends(BufferWhenSubscriber, _super);
17304 function BufferWhenSubscriber(destination, closingSelector) {
17305 var _this = _super.call(this, destination) || this;
17306 _this.closingSelector = closingSelector;
17307 _this.subscribing = false;
17308 _this.openBuffer();
17311 BufferWhenSubscriber.prototype._next = function (value) {
17312 this.buffer.push(value);
17314 BufferWhenSubscriber.prototype._complete = function () {
17315 var buffer = this.buffer;
17317 this.destination.next(buffer);
17319 _super.prototype._complete.call(this);
17321 BufferWhenSubscriber.prototype._unsubscribe = function () {
17322 this.buffer = null;
17323 this.subscribing = false;
17325 BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
17328 BufferWhenSubscriber.prototype.notifyComplete = function () {
17329 if (this.subscribing) {
17336 BufferWhenSubscriber.prototype.openBuffer = function () {
17337 var closingSubscription = this.closingSubscription;
17338 if (closingSubscription) {
17339 this.remove(closingSubscription);
17340 closingSubscription.unsubscribe();
17342 var buffer = this.buffer;
17344 this.destination.next(buffer);
17347 var closingNotifier;
17349 var closingSelector = this.closingSelector;
17350 closingNotifier = closingSelector();
17353 return this.error(err);
17355 closingSubscription = new Subscription_1.Subscription();
17356 this.closingSubscription = closingSubscription;
17357 this.add(closingSubscription);
17358 this.subscribing = true;
17359 closingSubscription.add(subscribeToResult_1.subscribeToResult(this, closingNotifier));
17360 this.subscribing = false;
17362 return BufferWhenSubscriber;
17363 }(OuterSubscriber_1.OuterSubscriber));
17365 },{"../OuterSubscriber":50,"../Subscription":56,"../util/subscribeToResult":239}],93:[function(require,module,exports){
17367 var __extends = (this && this.__extends) || (function () {
17368 var extendStatics = function (d, b) {
17369 extendStatics = Object.setPrototypeOf ||
17370 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17371 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17372 return extendStatics(d, b);
17374 return function (d, b) {
17375 extendStatics(d, b);
17376 function __() { this.constructor = d; }
17377 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17380 Object.defineProperty(exports, "__esModule", { value: true });
17381 var OuterSubscriber_1 = require("../OuterSubscriber");
17382 var InnerSubscriber_1 = require("../InnerSubscriber");
17383 var subscribeToResult_1 = require("../util/subscribeToResult");
17384 function catchError(selector) {
17385 return function catchErrorOperatorFunction(source) {
17386 var operator = new CatchOperator(selector);
17387 var caught = source.lift(operator);
17388 return (operator.caught = caught);
17391 exports.catchError = catchError;
17392 var CatchOperator = (function () {
17393 function CatchOperator(selector) {
17394 this.selector = selector;
17396 CatchOperator.prototype.call = function (subscriber, source) {
17397 return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
17399 return CatchOperator;
17401 var CatchSubscriber = (function (_super) {
17402 __extends(CatchSubscriber, _super);
17403 function CatchSubscriber(destination, selector, caught) {
17404 var _this = _super.call(this, destination) || this;
17405 _this.selector = selector;
17406 _this.caught = caught;
17409 CatchSubscriber.prototype.error = function (err) {
17410 if (!this.isStopped) {
17411 var result = void 0;
17413 result = this.selector(err, this.caught);
17416 _super.prototype.error.call(this, err2);
17419 this._unsubscribeAndRecycle();
17420 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
17421 this.add(innerSubscriber);
17422 var innerSubscription = subscribeToResult_1.subscribeToResult(this, result, undefined, undefined, innerSubscriber);
17423 if (innerSubscription !== innerSubscriber) {
17424 this.add(innerSubscription);
17428 return CatchSubscriber;
17429 }(OuterSubscriber_1.OuterSubscriber));
17431 },{"../InnerSubscriber":46,"../OuterSubscriber":50,"../util/subscribeToResult":239}],94:[function(require,module,exports){
17433 Object.defineProperty(exports, "__esModule", { value: true });
17434 var combineLatest_1 = require("../observable/combineLatest");
17435 function combineAll(project) {
17436 return function (source) { return source.lift(new combineLatest_1.CombineLatestOperator(project)); };
17438 exports.combineAll = combineAll;
17440 },{"../observable/combineLatest":62}],95:[function(require,module,exports){
17442 Object.defineProperty(exports, "__esModule", { value: true });
17443 var isArray_1 = require("../util/isArray");
17444 var combineLatest_1 = require("../observable/combineLatest");
17445 var from_1 = require("../observable/from");
17447 function combineLatest() {
17448 var observables = [];
17449 for (var _i = 0; _i < arguments.length; _i++) {
17450 observables[_i] = arguments[_i];
17452 var project = null;
17453 if (typeof observables[observables.length - 1] === 'function') {
17454 project = observables.pop();
17456 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
17457 observables = observables[0].slice();
17459 return function (source) { return source.lift.call(from_1.from([source].concat(observables)), new combineLatest_1.CombineLatestOperator(project)); };
17461 exports.combineLatest = combineLatest;
17463 },{"../observable/combineLatest":62,"../observable/from":67,"../util/isArray":220}],96:[function(require,module,exports){
17465 Object.defineProperty(exports, "__esModule", { value: true });
17466 var concat_1 = require("../observable/concat");
17467 function concat() {
17468 var observables = [];
17469 for (var _i = 0; _i < arguments.length; _i++) {
17470 observables[_i] = arguments[_i];
17472 return function (source) { return source.lift.call(concat_1.concat.apply(void 0, [source].concat(observables))); };
17474 exports.concat = concat;
17476 },{"../observable/concat":63}],97:[function(require,module,exports){
17478 Object.defineProperty(exports, "__esModule", { value: true });
17479 var mergeAll_1 = require("./mergeAll");
17480 function concatAll() {
17481 return mergeAll_1.mergeAll(1);
17483 exports.concatAll = concatAll;
17485 },{"./mergeAll":130}],98:[function(require,module,exports){
17487 Object.defineProperty(exports, "__esModule", { value: true });
17488 var mergeMap_1 = require("./mergeMap");
17489 function concatMap(project, resultSelector) {
17490 return mergeMap_1.mergeMap(project, resultSelector, 1);
17492 exports.concatMap = concatMap;
17494 },{"./mergeMap":131}],99:[function(require,module,exports){
17496 Object.defineProperty(exports, "__esModule", { value: true });
17497 var concatMap_1 = require("./concatMap");
17498 function concatMapTo(innerObservable, resultSelector) {
17499 return concatMap_1.concatMap(function () { return innerObservable; }, resultSelector);
17501 exports.concatMapTo = concatMapTo;
17503 },{"./concatMap":98}],100:[function(require,module,exports){
17505 var __extends = (this && this.__extends) || (function () {
17506 var extendStatics = function (d, b) {
17507 extendStatics = Object.setPrototypeOf ||
17508 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17509 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17510 return extendStatics(d, b);
17512 return function (d, b) {
17513 extendStatics(d, b);
17514 function __() { this.constructor = d; }
17515 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17518 Object.defineProperty(exports, "__esModule", { value: true });
17519 var Subscriber_1 = require("../Subscriber");
17520 function count(predicate) {
17521 return function (source) { return source.lift(new CountOperator(predicate, source)); };
17523 exports.count = count;
17524 var CountOperator = (function () {
17525 function CountOperator(predicate, source) {
17526 this.predicate = predicate;
17527 this.source = source;
17529 CountOperator.prototype.call = function (subscriber, source) {
17530 return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
17532 return CountOperator;
17534 var CountSubscriber = (function (_super) {
17535 __extends(CountSubscriber, _super);
17536 function CountSubscriber(destination, predicate, source) {
17537 var _this = _super.call(this, destination) || this;
17538 _this.predicate = predicate;
17539 _this.source = source;
17544 CountSubscriber.prototype._next = function (value) {
17545 if (this.predicate) {
17546 this._tryPredicate(value);
17552 CountSubscriber.prototype._tryPredicate = function (value) {
17555 result = this.predicate(value, this.index++, this.source);
17558 this.destination.error(err);
17565 CountSubscriber.prototype._complete = function () {
17566 this.destination.next(this.count);
17567 this.destination.complete();
17569 return CountSubscriber;
17570 }(Subscriber_1.Subscriber));
17572 },{"../Subscriber":55}],101:[function(require,module,exports){
17574 var __extends = (this && this.__extends) || (function () {
17575 var extendStatics = function (d, b) {
17576 extendStatics = Object.setPrototypeOf ||
17577 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17578 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17579 return extendStatics(d, b);
17581 return function (d, b) {
17582 extendStatics(d, b);
17583 function __() { this.constructor = d; }
17584 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17587 Object.defineProperty(exports, "__esModule", { value: true });
17588 var OuterSubscriber_1 = require("../OuterSubscriber");
17589 var subscribeToResult_1 = require("../util/subscribeToResult");
17590 function debounce(durationSelector) {
17591 return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
17593 exports.debounce = debounce;
17594 var DebounceOperator = (function () {
17595 function DebounceOperator(durationSelector) {
17596 this.durationSelector = durationSelector;
17598 DebounceOperator.prototype.call = function (subscriber, source) {
17599 return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
17601 return DebounceOperator;
17603 var DebounceSubscriber = (function (_super) {
17604 __extends(DebounceSubscriber, _super);
17605 function DebounceSubscriber(destination, durationSelector) {
17606 var _this = _super.call(this, destination) || this;
17607 _this.durationSelector = durationSelector;
17608 _this.hasValue = false;
17609 _this.durationSubscription = null;
17612 DebounceSubscriber.prototype._next = function (value) {
17614 var result = this.durationSelector.call(this, value);
17616 this._tryNext(value, result);
17620 this.destination.error(err);
17623 DebounceSubscriber.prototype._complete = function () {
17625 this.destination.complete();
17627 DebounceSubscriber.prototype._tryNext = function (value, duration) {
17628 var subscription = this.durationSubscription;
17629 this.value = value;
17630 this.hasValue = true;
17631 if (subscription) {
17632 subscription.unsubscribe();
17633 this.remove(subscription);
17635 subscription = subscribeToResult_1.subscribeToResult(this, duration);
17636 if (subscription && !subscription.closed) {
17637 this.add(this.durationSubscription = subscription);
17640 DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
17643 DebounceSubscriber.prototype.notifyComplete = function () {
17646 DebounceSubscriber.prototype.emitValue = function () {
17647 if (this.hasValue) {
17648 var value = this.value;
17649 var subscription = this.durationSubscription;
17650 if (subscription) {
17651 this.durationSubscription = null;
17652 subscription.unsubscribe();
17653 this.remove(subscription);
17656 this.hasValue = false;
17657 _super.prototype._next.call(this, value);
17660 return DebounceSubscriber;
17661 }(OuterSubscriber_1.OuterSubscriber));
17663 },{"../OuterSubscriber":50,"../util/subscribeToResult":239}],102:[function(require,module,exports){
17665 var __extends = (this && this.__extends) || (function () {
17666 var extendStatics = function (d, b) {
17667 extendStatics = Object.setPrototypeOf ||
17668 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17669 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17670 return extendStatics(d, b);
17672 return function (d, b) {
17673 extendStatics(d, b);
17674 function __() { this.constructor = d; }
17675 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17678 Object.defineProperty(exports, "__esModule", { value: true });
17679 var Subscriber_1 = require("../Subscriber");
17680 var async_1 = require("../scheduler/async");
17681 function debounceTime(dueTime, scheduler) {
17682 if (scheduler === void 0) { scheduler = async_1.async; }
17683 return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
17685 exports.debounceTime = debounceTime;
17686 var DebounceTimeOperator = (function () {
17687 function DebounceTimeOperator(dueTime, scheduler) {
17688 this.dueTime = dueTime;
17689 this.scheduler = scheduler;
17691 DebounceTimeOperator.prototype.call = function (subscriber, source) {
17692 return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
17694 return DebounceTimeOperator;
17696 var DebounceTimeSubscriber = (function (_super) {
17697 __extends(DebounceTimeSubscriber, _super);
17698 function DebounceTimeSubscriber(destination, dueTime, scheduler) {
17699 var _this = _super.call(this, destination) || this;
17700 _this.dueTime = dueTime;
17701 _this.scheduler = scheduler;
17702 _this.debouncedSubscription = null;
17703 _this.lastValue = null;
17704 _this.hasValue = false;
17707 DebounceTimeSubscriber.prototype._next = function (value) {
17708 this.clearDebounce();
17709 this.lastValue = value;
17710 this.hasValue = true;
17711 this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this));
17713 DebounceTimeSubscriber.prototype._complete = function () {
17714 this.debouncedNext();
17715 this.destination.complete();
17717 DebounceTimeSubscriber.prototype.debouncedNext = function () {
17718 this.clearDebounce();
17719 if (this.hasValue) {
17720 var lastValue = this.lastValue;
17721 this.lastValue = null;
17722 this.hasValue = false;
17723 this.destination.next(lastValue);
17726 DebounceTimeSubscriber.prototype.clearDebounce = function () {
17727 var debouncedSubscription = this.debouncedSubscription;
17728 if (debouncedSubscription !== null) {
17729 this.remove(debouncedSubscription);
17730 debouncedSubscription.unsubscribe();
17731 this.debouncedSubscription = null;
17734 return DebounceTimeSubscriber;
17735 }(Subscriber_1.Subscriber));
17736 function dispatchNext(subscriber) {
17737 subscriber.debouncedNext();
17740 },{"../Subscriber":55,"../scheduler/async":206}],103:[function(require,module,exports){
17742 var __extends = (this && this.__extends) || (function () {
17743 var extendStatics = function (d, b) {
17744 extendStatics = Object.setPrototypeOf ||
17745 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17746 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17747 return extendStatics(d, b);
17749 return function (d, b) {
17750 extendStatics(d, b);
17751 function __() { this.constructor = d; }
17752 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17755 Object.defineProperty(exports, "__esModule", { value: true });
17756 var Subscriber_1 = require("../Subscriber");
17757 function defaultIfEmpty(defaultValue) {
17758 if (defaultValue === void 0) { defaultValue = null; }
17759 return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
17761 exports.defaultIfEmpty = defaultIfEmpty;
17762 var DefaultIfEmptyOperator = (function () {
17763 function DefaultIfEmptyOperator(defaultValue) {
17764 this.defaultValue = defaultValue;
17766 DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
17767 return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
17769 return DefaultIfEmptyOperator;
17771 var DefaultIfEmptySubscriber = (function (_super) {
17772 __extends(DefaultIfEmptySubscriber, _super);
17773 function DefaultIfEmptySubscriber(destination, defaultValue) {
17774 var _this = _super.call(this, destination) || this;
17775 _this.defaultValue = defaultValue;
17776 _this.isEmpty = true;
17779 DefaultIfEmptySubscriber.prototype._next = function (value) {
17780 this.isEmpty = false;
17781 this.destination.next(value);
17783 DefaultIfEmptySubscriber.prototype._complete = function () {
17784 if (this.isEmpty) {
17785 this.destination.next(this.defaultValue);
17787 this.destination.complete();
17789 return DefaultIfEmptySubscriber;
17790 }(Subscriber_1.Subscriber));
17792 },{"../Subscriber":55}],104:[function(require,module,exports){
17794 var __extends = (this && this.__extends) || (function () {
17795 var extendStatics = function (d, b) {
17796 extendStatics = Object.setPrototypeOf ||
17797 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17798 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17799 return extendStatics(d, b);
17801 return function (d, b) {
17802 extendStatics(d, b);
17803 function __() { this.constructor = d; }
17804 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17807 Object.defineProperty(exports, "__esModule", { value: true });
17808 var async_1 = require("../scheduler/async");
17809 var isDate_1 = require("../util/isDate");
17810 var Subscriber_1 = require("../Subscriber");
17811 var Notification_1 = require("../Notification");
17812 function delay(delay, scheduler) {
17813 if (scheduler === void 0) { scheduler = async_1.async; }
17814 var absoluteDelay = isDate_1.isDate(delay);
17815 var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
17816 return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
17818 exports.delay = delay;
17819 var DelayOperator = (function () {
17820 function DelayOperator(delay, scheduler) {
17821 this.delay = delay;
17822 this.scheduler = scheduler;
17824 DelayOperator.prototype.call = function (subscriber, source) {
17825 return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
17827 return DelayOperator;
17829 var DelaySubscriber = (function (_super) {
17830 __extends(DelaySubscriber, _super);
17831 function DelaySubscriber(destination, delay, scheduler) {
17832 var _this = _super.call(this, destination) || this;
17833 _this.delay = delay;
17834 _this.scheduler = scheduler;
17836 _this.active = false;
17837 _this.errored = false;
17840 DelaySubscriber.dispatch = function (state) {
17841 var source = state.source;
17842 var queue = source.queue;
17843 var scheduler = state.scheduler;
17844 var destination = state.destination;
17845 while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
17846 queue.shift().notification.observe(destination);
17848 if (queue.length > 0) {
17849 var delay_1 = Math.max(0, queue[0].time - scheduler.now());
17850 this.schedule(state, delay_1);
17853 this.unsubscribe();
17854 source.active = false;
17857 DelaySubscriber.prototype._schedule = function (scheduler) {
17858 this.active = true;
17859 var destination = this.destination;
17860 destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
17861 source: this, destination: this.destination, scheduler: scheduler
17864 DelaySubscriber.prototype.scheduleNotification = function (notification) {
17865 if (this.errored === true) {
17868 var scheduler = this.scheduler;
17869 var message = new DelayMessage(scheduler.now() + this.delay, notification);
17870 this.queue.push(message);
17871 if (this.active === false) {
17872 this._schedule(scheduler);
17875 DelaySubscriber.prototype._next = function (value) {
17876 this.scheduleNotification(Notification_1.Notification.createNext(value));
17878 DelaySubscriber.prototype._error = function (err) {
17879 this.errored = true;
17881 this.destination.error(err);
17882 this.unsubscribe();
17884 DelaySubscriber.prototype._complete = function () {
17885 this.scheduleNotification(Notification_1.Notification.createComplete());
17886 this.unsubscribe();
17888 return DelaySubscriber;
17889 }(Subscriber_1.Subscriber));
17890 var DelayMessage = (function () {
17891 function DelayMessage(time, notification) {
17893 this.notification = notification;
17895 return DelayMessage;
17898 },{"../Notification":47,"../Subscriber":55,"../scheduler/async":206,"../util/isDate":222}],105:[function(require,module,exports){
17900 var __extends = (this && this.__extends) || (function () {
17901 var extendStatics = function (d, b) {
17902 extendStatics = Object.setPrototypeOf ||
17903 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17904 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17905 return extendStatics(d, b);
17907 return function (d, b) {
17908 extendStatics(d, b);
17909 function __() { this.constructor = d; }
17910 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17913 Object.defineProperty(exports, "__esModule", { value: true });
17914 var Subscriber_1 = require("../Subscriber");
17915 var Observable_1 = require("../Observable");
17916 var OuterSubscriber_1 = require("../OuterSubscriber");
17917 var subscribeToResult_1 = require("../util/subscribeToResult");
17918 function delayWhen(delayDurationSelector, subscriptionDelay) {
17919 if (subscriptionDelay) {
17920 return function (source) {
17921 return new SubscriptionDelayObservable(source, subscriptionDelay)
17922 .lift(new DelayWhenOperator(delayDurationSelector));
17925 return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
17927 exports.delayWhen = delayWhen;
17928 var DelayWhenOperator = (function () {
17929 function DelayWhenOperator(delayDurationSelector) {
17930 this.delayDurationSelector = delayDurationSelector;
17932 DelayWhenOperator.prototype.call = function (subscriber, source) {
17933 return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
17935 return DelayWhenOperator;
17937 var DelayWhenSubscriber = (function (_super) {
17938 __extends(DelayWhenSubscriber, _super);
17939 function DelayWhenSubscriber(destination, delayDurationSelector) {
17940 var _this = _super.call(this, destination) || this;
17941 _this.delayDurationSelector = delayDurationSelector;
17942 _this.completed = false;
17943 _this.delayNotifierSubscriptions = [];
17947 DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
17948 this.destination.next(outerValue);
17949 this.removeSubscription(innerSub);
17950 this.tryComplete();
17952 DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
17953 this._error(error);
17955 DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
17956 var value = this.removeSubscription(innerSub);
17958 this.destination.next(value);
17960 this.tryComplete();
17962 DelayWhenSubscriber.prototype._next = function (value) {
17963 var index = this.index++;
17965 var delayNotifier = this.delayDurationSelector(value, index);
17966 if (delayNotifier) {
17967 this.tryDelay(delayNotifier, value);
17971 this.destination.error(err);
17974 DelayWhenSubscriber.prototype._complete = function () {
17975 this.completed = true;
17976 this.tryComplete();
17977 this.unsubscribe();
17979 DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
17980 subscription.unsubscribe();
17981 var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
17982 if (subscriptionIdx !== -1) {
17983 this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
17985 return subscription.outerValue;
17987 DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
17988 var notifierSubscription = subscribeToResult_1.subscribeToResult(this, delayNotifier, value);
17989 if (notifierSubscription && !notifierSubscription.closed) {
17990 var destination = this.destination;
17991 destination.add(notifierSubscription);
17992 this.delayNotifierSubscriptions.push(notifierSubscription);
17995 DelayWhenSubscriber.prototype.tryComplete = function () {
17996 if (this.completed && this.delayNotifierSubscriptions.length === 0) {
17997 this.destination.complete();
18000 return DelayWhenSubscriber;
18001 }(OuterSubscriber_1.OuterSubscriber));
18002 var SubscriptionDelayObservable = (function (_super) {
18003 __extends(SubscriptionDelayObservable, _super);
18004 function SubscriptionDelayObservable(source, subscriptionDelay) {
18005 var _this = _super.call(this) || this;
18006 _this.source = source;
18007 _this.subscriptionDelay = subscriptionDelay;
18010 SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
18011 this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
18013 return SubscriptionDelayObservable;
18014 }(Observable_1.Observable));
18015 var SubscriptionDelaySubscriber = (function (_super) {
18016 __extends(SubscriptionDelaySubscriber, _super);
18017 function SubscriptionDelaySubscriber(parent, source) {
18018 var _this = _super.call(this) || this;
18019 _this.parent = parent;
18020 _this.source = source;
18021 _this.sourceSubscribed = false;
18024 SubscriptionDelaySubscriber.prototype._next = function (unused) {
18025 this.subscribeToSource();
18027 SubscriptionDelaySubscriber.prototype._error = function (err) {
18028 this.unsubscribe();
18029 this.parent.error(err);
18031 SubscriptionDelaySubscriber.prototype._complete = function () {
18032 this.unsubscribe();
18033 this.subscribeToSource();
18035 SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
18036 if (!this.sourceSubscribed) {
18037 this.sourceSubscribed = true;
18038 this.unsubscribe();
18039 this.source.subscribe(this.parent);
18042 return SubscriptionDelaySubscriber;
18043 }(Subscriber_1.Subscriber));
18045 },{"../Observable":48,"../OuterSubscriber":50,"../Subscriber":55,"../util/subscribeToResult":239}],106:[function(require,module,exports){
18047 var __extends = (this && this.__extends) || (function () {
18048 var extendStatics = function (d, b) {
18049 extendStatics = Object.setPrototypeOf ||
18050 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18051 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18052 return extendStatics(d, b);
18054 return function (d, b) {
18055 extendStatics(d, b);
18056 function __() { this.constructor = d; }
18057 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18060 Object.defineProperty(exports, "__esModule", { value: true });
18061 var Subscriber_1 = require("../Subscriber");
18062 function dematerialize() {
18063 return function dematerializeOperatorFunction(source) {
18064 return source.lift(new DeMaterializeOperator());
18067 exports.dematerialize = dematerialize;
18068 var DeMaterializeOperator = (function () {
18069 function DeMaterializeOperator() {
18071 DeMaterializeOperator.prototype.call = function (subscriber, source) {
18072 return source.subscribe(new DeMaterializeSubscriber(subscriber));
18074 return DeMaterializeOperator;
18076 var DeMaterializeSubscriber = (function (_super) {
18077 __extends(DeMaterializeSubscriber, _super);
18078 function DeMaterializeSubscriber(destination) {
18079 return _super.call(this, destination) || this;
18081 DeMaterializeSubscriber.prototype._next = function (value) {
18082 value.observe(this.destination);
18084 return DeMaterializeSubscriber;
18085 }(Subscriber_1.Subscriber));
18087 },{"../Subscriber":55}],107:[function(require,module,exports){
18089 var __extends = (this && this.__extends) || (function () {
18090 var extendStatics = function (d, b) {
18091 extendStatics = Object.setPrototypeOf ||
18092 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18093 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18094 return extendStatics(d, b);
18096 return function (d, b) {
18097 extendStatics(d, b);
18098 function __() { this.constructor = d; }
18099 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18102 Object.defineProperty(exports, "__esModule", { value: true });
18103 var OuterSubscriber_1 = require("../OuterSubscriber");
18104 var subscribeToResult_1 = require("../util/subscribeToResult");
18105 function distinct(keySelector, flushes) {
18106 return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
18108 exports.distinct = distinct;
18109 var DistinctOperator = (function () {
18110 function DistinctOperator(keySelector, flushes) {
18111 this.keySelector = keySelector;
18112 this.flushes = flushes;
18114 DistinctOperator.prototype.call = function (subscriber, source) {
18115 return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
18117 return DistinctOperator;
18119 var DistinctSubscriber = (function (_super) {
18120 __extends(DistinctSubscriber, _super);
18121 function DistinctSubscriber(destination, keySelector, flushes) {
18122 var _this = _super.call(this, destination) || this;
18123 _this.keySelector = keySelector;
18124 _this.values = new Set();
18126 _this.add(subscribeToResult_1.subscribeToResult(_this, flushes));
18130 DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
18131 this.values.clear();
18133 DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
18134 this._error(error);
18136 DistinctSubscriber.prototype._next = function (value) {
18137 if (this.keySelector) {
18138 this._useKeySelector(value);
18141 this._finalizeNext(value, value);
18144 DistinctSubscriber.prototype._useKeySelector = function (value) {
18146 var destination = this.destination;
18148 key = this.keySelector(value);
18151 destination.error(err);
18154 this._finalizeNext(key, value);
18156 DistinctSubscriber.prototype._finalizeNext = function (key, value) {
18157 var values = this.values;
18158 if (!values.has(key)) {
18160 this.destination.next(value);
18163 return DistinctSubscriber;
18164 }(OuterSubscriber_1.OuterSubscriber));
18165 exports.DistinctSubscriber = DistinctSubscriber;
18167 },{"../OuterSubscriber":50,"../util/subscribeToResult":239}],108:[function(require,module,exports){
18169 var __extends = (this && this.__extends) || (function () {
18170 var extendStatics = function (d, b) {
18171 extendStatics = Object.setPrototypeOf ||
18172 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18173 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18174 return extendStatics(d, b);
18176 return function (d, b) {
18177 extendStatics(d, b);
18178 function __() { this.constructor = d; }
18179 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18182 Object.defineProperty(exports, "__esModule", { value: true });
18183 var Subscriber_1 = require("../Subscriber");
18184 function distinctUntilChanged(compare, keySelector) {
18185 return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
18187 exports.distinctUntilChanged = distinctUntilChanged;
18188 var DistinctUntilChangedOperator = (function () {
18189 function DistinctUntilChangedOperator(compare, keySelector) {
18190 this.compare = compare;
18191 this.keySelector = keySelector;
18193 DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
18194 return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
18196 return DistinctUntilChangedOperator;
18198 var DistinctUntilChangedSubscriber = (function (_super) {
18199 __extends(DistinctUntilChangedSubscriber, _super);
18200 function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
18201 var _this = _super.call(this, destination) || this;
18202 _this.keySelector = keySelector;
18203 _this.hasKey = false;
18204 if (typeof compare === 'function') {
18205 _this.compare = compare;
18209 DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
18212 DistinctUntilChangedSubscriber.prototype._next = function (value) {
18215 var keySelector = this.keySelector;
18216 key = keySelector ? keySelector(value) : value;
18219 return this.destination.error(err);
18221 var result = false;
18224 var compare = this.compare;
18225 result = compare(this.key, key);
18228 return this.destination.error(err);
18232 this.hasKey = true;
18236 this.destination.next(value);
18239 return DistinctUntilChangedSubscriber;
18240 }(Subscriber_1.Subscriber));
18242 },{"../Subscriber":55}],109:[function(require,module,exports){
18244 Object.defineProperty(exports, "__esModule", { value: true });
18245 var distinctUntilChanged_1 = require("./distinctUntilChanged");
18246 function distinctUntilKeyChanged(key, compare) {
18247 return distinctUntilChanged_1.distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
18249 exports.distinctUntilKeyChanged = distinctUntilKeyChanged;
18251 },{"./distinctUntilChanged":108}],110:[function(require,module,exports){
18253 Object.defineProperty(exports, "__esModule", { value: true });
18254 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
18255 var filter_1 = require("./filter");
18256 var throwIfEmpty_1 = require("./throwIfEmpty");
18257 var defaultIfEmpty_1 = require("./defaultIfEmpty");
18258 var take_1 = require("./take");
18259 function elementAt(index, defaultValue) {
18261 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError();
18263 var hasDefaultValue = arguments.length >= 2;
18264 return function (source) { return source.pipe(filter_1.filter(function (v, i) { return i === index; }), take_1.take(1), hasDefaultValue
18265 ? defaultIfEmpty_1.defaultIfEmpty(defaultValue)
18266 : throwIfEmpty_1.throwIfEmpty(function () { return new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError(); })); };
18268 exports.elementAt = elementAt;
18270 },{"../util/ArgumentOutOfRangeError":211,"./defaultIfEmpty":103,"./filter":116,"./take":168,"./throwIfEmpty":175}],111:[function(require,module,exports){
18272 Object.defineProperty(exports, "__esModule", { value: true });
18273 var concat_1 = require("../observable/concat");
18274 var of_1 = require("../observable/of");
18275 function endWith() {
18277 for (var _i = 0; _i < arguments.length; _i++) {
18278 array[_i] = arguments[_i];
18280 return function (source) { return concat_1.concat(source, of_1.of.apply(void 0, array)); };
18282 exports.endWith = endWith;
18284 },{"../observable/concat":63,"../observable/of":76}],112:[function(require,module,exports){
18286 var __extends = (this && this.__extends) || (function () {
18287 var extendStatics = function (d, b) {
18288 extendStatics = Object.setPrototypeOf ||
18289 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18290 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18291 return extendStatics(d, b);
18293 return function (d, b) {
18294 extendStatics(d, b);
18295 function __() { this.constructor = d; }
18296 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18299 Object.defineProperty(exports, "__esModule", { value: true });
18300 var Subscriber_1 = require("../Subscriber");
18301 function every(predicate, thisArg) {
18302 return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
18304 exports.every = every;
18305 var EveryOperator = (function () {
18306 function EveryOperator(predicate, thisArg, source) {
18307 this.predicate = predicate;
18308 this.thisArg = thisArg;
18309 this.source = source;
18311 EveryOperator.prototype.call = function (observer, source) {
18312 return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
18314 return EveryOperator;
18316 var EverySubscriber = (function (_super) {
18317 __extends(EverySubscriber, _super);
18318 function EverySubscriber(destination, predicate, thisArg, source) {
18319 var _this = _super.call(this, destination) || this;
18320 _this.predicate = predicate;
18321 _this.thisArg = thisArg;
18322 _this.source = source;
18324 _this.thisArg = thisArg || _this;
18327 EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
18328 this.destination.next(everyValueMatch);
18329 this.destination.complete();
18331 EverySubscriber.prototype._next = function (value) {
18332 var result = false;
18334 result = this.predicate.call(this.thisArg, value, this.index++, this.source);
18337 this.destination.error(err);
18341 this.notifyComplete(false);
18344 EverySubscriber.prototype._complete = function () {
18345 this.notifyComplete(true);
18347 return EverySubscriber;
18348 }(Subscriber_1.Subscriber));
18350 },{"../Subscriber":55}],113:[function(require,module,exports){
18352 var __extends = (this && this.__extends) || (function () {
18353 var extendStatics = function (d, b) {
18354 extendStatics = Object.setPrototypeOf ||
18355 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18356 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18357 return extendStatics(d, b);
18359 return function (d, b) {
18360 extendStatics(d, b);
18361 function __() { this.constructor = d; }
18362 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18365 Object.defineProperty(exports, "__esModule", { value: true });
18366 var OuterSubscriber_1 = require("../OuterSubscriber");
18367 var subscribeToResult_1 = require("../util/subscribeToResult");
18368 function exhaust() {
18369 return function (source) { return source.lift(new SwitchFirstOperator()); };
18371 exports.exhaust = exhaust;
18372 var SwitchFirstOperator = (function () {
18373 function SwitchFirstOperator() {
18375 SwitchFirstOperator.prototype.call = function (subscriber, source) {
18376 return source.subscribe(new SwitchFirstSubscriber(subscriber));
18378 return SwitchFirstOperator;
18380 var SwitchFirstSubscriber = (function (_super) {
18381 __extends(SwitchFirstSubscriber, _super);
18382 function SwitchFirstSubscriber(destination) {
18383 var _this = _super.call(this, destination) || this;
18384 _this.hasCompleted = false;
18385 _this.hasSubscription = false;
18388 SwitchFirstSubscriber.prototype._next = function (value) {
18389 if (!this.hasSubscription) {
18390 this.hasSubscription = true;
18391 this.add(subscribeToResult_1.subscribeToResult(this, value));
18394 SwitchFirstSubscriber.prototype._complete = function () {
18395 this.hasCompleted = true;
18396 if (!this.hasSubscription) {
18397 this.destination.complete();
18400 SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
18401 this.remove(innerSub);
18402 this.hasSubscription = false;
18403 if (this.hasCompleted) {
18404 this.destination.complete();
18407 return SwitchFirstSubscriber;
18408 }(OuterSubscriber_1.OuterSubscriber));
18410 },{"../OuterSubscriber":50,"../util/subscribeToResult":239}],114:[function(require,module,exports){
18412 var __extends = (this && this.__extends) || (function () {
18413 var extendStatics = function (d, b) {
18414 extendStatics = Object.setPrototypeOf ||
18415 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18416 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18417 return extendStatics(d, b);
18419 return function (d, b) {
18420 extendStatics(d, b);
18421 function __() { this.constructor = d; }
18422 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18425 Object.defineProperty(exports, "__esModule", { value: true });
18426 var OuterSubscriber_1 = require("../OuterSubscriber");
18427 var InnerSubscriber_1 = require("../InnerSubscriber");
18428 var subscribeToResult_1 = require("../util/subscribeToResult");
18429 var map_1 = require("./map");
18430 var from_1 = require("../observable/from");
18431 function exhaustMap(project, resultSelector) {
18432 if (resultSelector) {
18433 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); })); })); };
18435 return function (source) {
18436 return source.lift(new ExhaustMapOperator(project));
18439 exports.exhaustMap = exhaustMap;
18440 var ExhaustMapOperator = (function () {
18441 function ExhaustMapOperator(project) {
18442 this.project = project;
18444 ExhaustMapOperator.prototype.call = function (subscriber, source) {
18445 return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
18447 return ExhaustMapOperator;
18449 var ExhaustMapSubscriber = (function (_super) {
18450 __extends(ExhaustMapSubscriber, _super);
18451 function ExhaustMapSubscriber(destination, project) {
18452 var _this = _super.call(this, destination) || this;
18453 _this.project = project;
18454 _this.hasSubscription = false;
18455 _this.hasCompleted = false;
18459 ExhaustMapSubscriber.prototype._next = function (value) {
18460 if (!this.hasSubscription) {
18461 this.tryNext(value);
18464 ExhaustMapSubscriber.prototype.tryNext = function (value) {
18466 var index = this.index++;
18468 result = this.project(value, index);
18471 this.destination.error(err);
18474 this.hasSubscription = true;
18475 this._innerSub(result, value, index);
18477 ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
18478 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, value, index);
18479 var destination = this.destination;
18480 destination.add(innerSubscriber);
18481 var innerSubscription = subscribeToResult_1.subscribeToResult(this, result, undefined, undefined, innerSubscriber);
18482 if (innerSubscription !== innerSubscriber) {
18483 destination.add(innerSubscription);
18486 ExhaustMapSubscriber.prototype._complete = function () {
18487 this.hasCompleted = true;
18488 if (!this.hasSubscription) {
18489 this.destination.complete();
18491 this.unsubscribe();
18493 ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
18494 this.destination.next(innerValue);
18496 ExhaustMapSubscriber.prototype.notifyError = function (err) {
18497 this.destination.error(err);
18499 ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
18500 var destination = this.destination;
18501 destination.remove(innerSub);
18502 this.hasSubscription = false;
18503 if (this.hasCompleted) {
18504 this.destination.complete();
18507 return ExhaustMapSubscriber;
18508 }(OuterSubscriber_1.OuterSubscriber));
18510 },{"../InnerSubscriber":46,"../OuterSubscriber":50,"../observable/from":67,"../util/subscribeToResult":239,"./map":125}],115:[function(require,module,exports){
18512 var __extends = (this && this.__extends) || (function () {
18513 var extendStatics = function (d, b) {
18514 extendStatics = Object.setPrototypeOf ||
18515 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18516 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18517 return extendStatics(d, b);
18519 return function (d, b) {
18520 extendStatics(d, b);
18521 function __() { this.constructor = d; }
18522 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18525 Object.defineProperty(exports, "__esModule", { value: true });
18526 var OuterSubscriber_1 = require("../OuterSubscriber");
18527 var subscribeToResult_1 = require("../util/subscribeToResult");
18528 function expand(project, concurrent, scheduler) {
18529 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
18530 if (scheduler === void 0) { scheduler = undefined; }
18531 concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
18532 return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
18534 exports.expand = expand;
18535 var ExpandOperator = (function () {
18536 function ExpandOperator(project, concurrent, scheduler) {
18537 this.project = project;
18538 this.concurrent = concurrent;
18539 this.scheduler = scheduler;
18541 ExpandOperator.prototype.call = function (subscriber, source) {
18542 return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
18544 return ExpandOperator;
18546 exports.ExpandOperator = ExpandOperator;
18547 var ExpandSubscriber = (function (_super) {
18548 __extends(ExpandSubscriber, _super);
18549 function ExpandSubscriber(destination, project, concurrent, scheduler) {
18550 var _this = _super.call(this, destination) || this;
18551 _this.project = project;
18552 _this.concurrent = concurrent;
18553 _this.scheduler = scheduler;
18556 _this.hasCompleted = false;
18557 if (concurrent < Number.POSITIVE_INFINITY) {
18562 ExpandSubscriber.dispatch = function (arg) {
18563 var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
18564 subscriber.subscribeToProjection(result, value, index);
18566 ExpandSubscriber.prototype._next = function (value) {
18567 var destination = this.destination;
18568 if (destination.closed) {
18572 var index = this.index++;
18573 if (this.active < this.concurrent) {
18574 destination.next(value);
18576 var project = this.project;
18577 var result = project(value, index);
18578 if (!this.scheduler) {
18579 this.subscribeToProjection(result, value, index);
18582 var state = { subscriber: this, result: result, value: value, index: index };
18583 var destination_1 = this.destination;
18584 destination_1.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
18588 destination.error(e);
18592 this.buffer.push(value);
18595 ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
18597 var destination = this.destination;
18598 destination.add(subscribeToResult_1.subscribeToResult(this, result, value, index));
18600 ExpandSubscriber.prototype._complete = function () {
18601 this.hasCompleted = true;
18602 if (this.hasCompleted && this.active === 0) {
18603 this.destination.complete();
18605 this.unsubscribe();
18607 ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
18608 this._next(innerValue);
18610 ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
18611 var buffer = this.buffer;
18612 var destination = this.destination;
18613 destination.remove(innerSub);
18615 if (buffer && buffer.length > 0) {
18616 this._next(buffer.shift());
18618 if (this.hasCompleted && this.active === 0) {
18619 this.destination.complete();
18622 return ExpandSubscriber;
18623 }(OuterSubscriber_1.OuterSubscriber));
18624 exports.ExpandSubscriber = ExpandSubscriber;
18626 },{"../OuterSubscriber":50,"../util/subscribeToResult":239}],116:[function(require,module,exports){
18628 var __extends = (this && this.__extends) || (function () {
18629 var extendStatics = function (d, b) {
18630 extendStatics = Object.setPrototypeOf ||
18631 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18632 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18633 return extendStatics(d, b);
18635 return function (d, b) {
18636 extendStatics(d, b);
18637 function __() { this.constructor = d; }
18638 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18641 Object.defineProperty(exports, "__esModule", { value: true });
18642 var Subscriber_1 = require("../Subscriber");
18643 function filter(predicate, thisArg) {
18644 return function filterOperatorFunction(source) {
18645 return source.lift(new FilterOperator(predicate, thisArg));
18648 exports.filter = filter;
18649 var FilterOperator = (function () {
18650 function FilterOperator(predicate, thisArg) {
18651 this.predicate = predicate;
18652 this.thisArg = thisArg;
18654 FilterOperator.prototype.call = function (subscriber, source) {
18655 return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
18657 return FilterOperator;
18659 var FilterSubscriber = (function (_super) {
18660 __extends(FilterSubscriber, _super);
18661 function FilterSubscriber(destination, predicate, thisArg) {
18662 var _this = _super.call(this, destination) || this;
18663 _this.predicate = predicate;
18664 _this.thisArg = thisArg;
18668 FilterSubscriber.prototype._next = function (value) {
18671 result = this.predicate.call(this.thisArg, value, this.count++);
18674 this.destination.error(err);
18678 this.destination.next(value);
18681 return FilterSubscriber;
18682 }(Subscriber_1.Subscriber));
18684 },{"../Subscriber":55}],117:[function(require,module,exports){
18686 var __extends = (this && this.__extends) || (function () {
18687 var extendStatics = function (d, b) {
18688 extendStatics = Object.setPrototypeOf ||
18689 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18690 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18691 return extendStatics(d, b);
18693 return function (d, b) {
18694 extendStatics(d, b);
18695 function __() { this.constructor = d; }
18696 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18699 Object.defineProperty(exports, "__esModule", { value: true });
18700 var Subscriber_1 = require("../Subscriber");
18701 var Subscription_1 = require("../Subscription");
18702 function finalize(callback) {
18703 return function (source) { return source.lift(new FinallyOperator(callback)); };
18705 exports.finalize = finalize;
18706 var FinallyOperator = (function () {
18707 function FinallyOperator(callback) {
18708 this.callback = callback;
18710 FinallyOperator.prototype.call = function (subscriber, source) {
18711 return source.subscribe(new FinallySubscriber(subscriber, this.callback));
18713 return FinallyOperator;
18715 var FinallySubscriber = (function (_super) {
18716 __extends(FinallySubscriber, _super);
18717 function FinallySubscriber(destination, callback) {
18718 var _this = _super.call(this, destination) || this;
18719 _this.add(new Subscription_1.Subscription(callback));
18722 return FinallySubscriber;
18723 }(Subscriber_1.Subscriber));
18725 },{"../Subscriber":55,"../Subscription":56}],118:[function(require,module,exports){
18727 var __extends = (this && this.__extends) || (function () {
18728 var extendStatics = function (d, b) {
18729 extendStatics = Object.setPrototypeOf ||
18730 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18731 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18732 return extendStatics(d, b);
18734 return function (d, b) {
18735 extendStatics(d, b);
18736 function __() { this.constructor = d; }
18737 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18740 Object.defineProperty(exports, "__esModule", { value: true });
18741 var Subscriber_1 = require("../Subscriber");
18742 function find(predicate, thisArg) {
18743 if (typeof predicate !== 'function') {
18744 throw new TypeError('predicate is not a function');
18746 return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
18748 exports.find = find;
18749 var FindValueOperator = (function () {
18750 function FindValueOperator(predicate, source, yieldIndex, thisArg) {
18751 this.predicate = predicate;
18752 this.source = source;
18753 this.yieldIndex = yieldIndex;
18754 this.thisArg = thisArg;
18756 FindValueOperator.prototype.call = function (observer, source) {
18757 return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
18759 return FindValueOperator;
18761 exports.FindValueOperator = FindValueOperator;
18762 var FindValueSubscriber = (function (_super) {
18763 __extends(FindValueSubscriber, _super);
18764 function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
18765 var _this = _super.call(this, destination) || this;
18766 _this.predicate = predicate;
18767 _this.source = source;
18768 _this.yieldIndex = yieldIndex;
18769 _this.thisArg = thisArg;
18773 FindValueSubscriber.prototype.notifyComplete = function (value) {
18774 var destination = this.destination;
18775 destination.next(value);
18776 destination.complete();
18777 this.unsubscribe();
18779 FindValueSubscriber.prototype._next = function (value) {
18780 var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
18781 var index = this.index++;
18783 var result = predicate.call(thisArg || this, value, index, this.source);
18785 this.notifyComplete(this.yieldIndex ? index : value);
18789 this.destination.error(err);
18792 FindValueSubscriber.prototype._complete = function () {
18793 this.notifyComplete(this.yieldIndex ? -1 : undefined);
18795 return FindValueSubscriber;
18796 }(Subscriber_1.Subscriber));
18797 exports.FindValueSubscriber = FindValueSubscriber;
18799 },{"../Subscriber":55}],119:[function(require,module,exports){
18801 Object.defineProperty(exports, "__esModule", { value: true });
18802 var find_1 = require("../operators/find");
18803 function findIndex(predicate, thisArg) {
18804 return function (source) { return source.lift(new find_1.FindValueOperator(predicate, source, true, thisArg)); };
18806 exports.findIndex = findIndex;
18808 },{"../operators/find":118}],120:[function(require,module,exports){
18810 Object.defineProperty(exports, "__esModule", { value: true });
18811 var EmptyError_1 = require("../util/EmptyError");
18812 var filter_1 = require("./filter");
18813 var take_1 = require("./take");
18814 var defaultIfEmpty_1 = require("./defaultIfEmpty");
18815 var throwIfEmpty_1 = require("./throwIfEmpty");
18816 var identity_1 = require("../util/identity");
18817 function first(predicate, defaultValue) {
18818 var hasDefaultValue = arguments.length >= 2;
18819 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(); })); };
18821 exports.first = first;
18823 },{"../util/EmptyError":212,"../util/identity":219,"./defaultIfEmpty":103,"./filter":116,"./take":168,"./throwIfEmpty":175}],121:[function(require,module,exports){
18825 var __extends = (this && this.__extends) || (function () {
18826 var extendStatics = function (d, b) {
18827 extendStatics = Object.setPrototypeOf ||
18828 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18829 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
18830 return extendStatics(d, b);
18832 return function (d, b) {
18833 extendStatics(d, b);
18834 function __() { this.constructor = d; }
18835 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18838 Object.defineProperty(exports, "__esModule", { value: true });
18839 var Subscriber_1 = require("../Subscriber");
18840 var Subscription_1 = require("../Subscription");
18841 var Observable_1 = require("../Observable");
18842 var Subject_1 = require("../Subject");
18843 function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
18844 return function (source) {
18845 return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
18848 exports.groupBy = groupBy;
18849 var GroupByOperator = (function () {
18850 function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
18851 this.keySelector = keySelector;
18852 this.elementSelector = elementSelector;
18853 this.durationSelector = durationSelector;
18854 this.subjectSelector = subjectSelector;
18856 GroupByOperator.prototype.call = function (subscriber, source) {
18857 return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
18859 return GroupByOperator;
18861 var GroupBySubscriber = (function (_super) {
18862 __extends(GroupBySubscriber, _super);
18863 function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
18864 var _this = _super.call(this, destination) || this;
18865 _this.keySelector = keySelector;
18866 _this.elementSelector = elementSelector;
18867 _this.durationSelector = durationSelector;
18868 _this.subjectSelector = subjectSelector;
18869 _this.groups = null;
18870 _this.attemptedToUnsubscribe = false;
18874 GroupBySubscriber.prototype._next = function (value) {
18877 key = this.keySelector(value);
18883 this._group(value, key);
18885 GroupBySubscriber.prototype._group = function (value, key) {
18886 var groups = this.groups;
18888 groups = this.groups = new Map();
18890 var group = groups.get(key);
18892 if (this.elementSelector) {
18894 element = this.elementSelector(value);
18904 group = (this.subjectSelector ? this.subjectSelector() : new Subject_1.Subject());
18905 groups.set(key, group);
18906 var groupedObservable = new GroupedObservable(key, group, this);
18907 this.destination.next(groupedObservable);
18908 if (this.durationSelector) {
18909 var duration = void 0;
18911 duration = this.durationSelector(new GroupedObservable(key, group));
18917 this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
18920 if (!group.closed) {
18921 group.next(element);
18924 GroupBySubscriber.prototype._error = function (err) {
18925 var groups = this.groups;
18927 groups.forEach(function (group, key) {
18932 this.destination.error(err);
18934 GroupBySubscriber.prototype._complete = function () {
18935 var groups = this.groups;
18937 groups.forEach(function (group, key) {
18942 this.destination.complete();
18944 GroupBySubscriber.prototype.removeGroup = function (key) {
18945 this.groups.delete(key);
18947 GroupBySubscriber.prototype.unsubscribe = function () {
18948 if (!this.closed) {
18949 this.attemptedToUnsubscribe = true;
18950 if (this.count === 0) {
18951 _super.prototype.unsubscribe.call(this);
18955 return GroupBySubscriber;
18956 }(Subscriber_1.Subscriber));
18957 var GroupDurationSubscriber = (function (_super) {
18958 __extends(GroupDurationSubscriber, _super);
18959 function GroupDurationSubscriber(key, group, parent) {
18960 var _this = _super.call(this, group) || this;
18962 _this.group = group;
18963 _this.parent = parent;
18966 GroupDurationSubscriber.prototype._next = function (value) {
18969 GroupDurationSubscriber.prototype._unsubscribe = function () {
18970 var _a = this, parent = _a.parent, key = _a.key;
18971 this.key = this.parent = null;
18973 parent.removeGroup(key);
18976 return GroupDurationSubscriber;
18977 }(Subscriber_1.Subscriber));
18978 var GroupedObservable = (function (_super) {
18979 __extends(GroupedObservable, _super);
18980 function GroupedObservable(key, groupSubject, refCountSubscription) {
18981 var _this = _super.call(this) || this;
18983 _this.groupSubject = groupSubject;
18984 _this.refCountSubscription = refCountSubscription;
18987 GroupedObservable.prototype._subscribe = function (subscriber) {
18988 var subscription = new Subscription_1.Subscription();
18989 var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
18990 if (refCountSubscription && !refCountSubscription.closed) {
18991 subscription.add(new InnerRefCountSubscription(refCountSubscription));
18993 subscription.add(groupSubject.subscribe(subscriber));
18994 return subscription;
18996 return GroupedObservable;
18997 }(Observable_1.Observable));
18998 exports.GroupedObservable = GroupedObservable;
18999 var InnerRefCountSubscription = (function (_super) {
19000 __extends(InnerRefCountSubscription, _super);
19001 function InnerRefCountSubscription(parent) {
19002 var _this = _super.call(this) || this;
19003 _this.parent = parent;
19007 InnerRefCountSubscription.prototype.unsubscribe = function () {
19008 var parent = this.parent;
19009 if (!parent.closed && !this.closed) {
19010 _super.prototype.unsubscribe.call(this);
19012 if (parent.count === 0 && parent.attemptedToUnsubscribe) {
19013 parent.unsubscribe();
19017 return InnerRefCountSubscription;
19018 }(Subscription_1.Subscription));
19020 },{"../Observable":48,"../Subject":53,"../Subscriber":55,"../Subscription":56}],122:[function(require,module,exports){
19022 var __extends = (this && this.__extends) || (function () {
19023 var extendStatics = function (d, b) {
19024 extendStatics = Object.setPrototypeOf ||
19025 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19026 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19027 return extendStatics(d, b);
19029 return function (d, b) {
19030 extendStatics(d, b);
19031 function __() { this.constructor = d; }
19032 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19035 Object.defineProperty(exports, "__esModule", { value: true });
19036 var Subscriber_1 = require("../Subscriber");
19037 function ignoreElements() {
19038 return function ignoreElementsOperatorFunction(source) {
19039 return source.lift(new IgnoreElementsOperator());
19042 exports.ignoreElements = ignoreElements;
19043 var IgnoreElementsOperator = (function () {
19044 function IgnoreElementsOperator() {
19046 IgnoreElementsOperator.prototype.call = function (subscriber, source) {
19047 return source.subscribe(new IgnoreElementsSubscriber(subscriber));
19049 return IgnoreElementsOperator;
19051 var IgnoreElementsSubscriber = (function (_super) {
19052 __extends(IgnoreElementsSubscriber, _super);
19053 function IgnoreElementsSubscriber() {
19054 return _super !== null && _super.apply(this, arguments) || this;
19056 IgnoreElementsSubscriber.prototype._next = function (unused) {
19058 return IgnoreElementsSubscriber;
19059 }(Subscriber_1.Subscriber));
19061 },{"../Subscriber":55}],123:[function(require,module,exports){
19063 var __extends = (this && this.__extends) || (function () {
19064 var extendStatics = function (d, b) {
19065 extendStatics = Object.setPrototypeOf ||
19066 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19067 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19068 return extendStatics(d, b);
19070 return function (d, b) {
19071 extendStatics(d, b);
19072 function __() { this.constructor = d; }
19073 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19076 Object.defineProperty(exports, "__esModule", { value: true });
19077 var Subscriber_1 = require("../Subscriber");
19078 function isEmpty() {
19079 return function (source) { return source.lift(new IsEmptyOperator()); };
19081 exports.isEmpty = isEmpty;
19082 var IsEmptyOperator = (function () {
19083 function IsEmptyOperator() {
19085 IsEmptyOperator.prototype.call = function (observer, source) {
19086 return source.subscribe(new IsEmptySubscriber(observer));
19088 return IsEmptyOperator;
19090 var IsEmptySubscriber = (function (_super) {
19091 __extends(IsEmptySubscriber, _super);
19092 function IsEmptySubscriber(destination) {
19093 return _super.call(this, destination) || this;
19095 IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
19096 var destination = this.destination;
19097 destination.next(isEmpty);
19098 destination.complete();
19100 IsEmptySubscriber.prototype._next = function (value) {
19101 this.notifyComplete(false);
19103 IsEmptySubscriber.prototype._complete = function () {
19104 this.notifyComplete(true);
19106 return IsEmptySubscriber;
19107 }(Subscriber_1.Subscriber));
19109 },{"../Subscriber":55}],124:[function(require,module,exports){
19111 Object.defineProperty(exports, "__esModule", { value: true });
19112 var EmptyError_1 = require("../util/EmptyError");
19113 var filter_1 = require("./filter");
19114 var takeLast_1 = require("./takeLast");
19115 var throwIfEmpty_1 = require("./throwIfEmpty");
19116 var defaultIfEmpty_1 = require("./defaultIfEmpty");
19117 var identity_1 = require("../util/identity");
19118 function last(predicate, defaultValue) {
19119 var hasDefaultValue = arguments.length >= 2;
19120 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(); })); };
19122 exports.last = last;
19124 },{"../util/EmptyError":212,"../util/identity":219,"./defaultIfEmpty":103,"./filter":116,"./takeLast":169,"./throwIfEmpty":175}],125:[function(require,module,exports){
19126 var __extends = (this && this.__extends) || (function () {
19127 var extendStatics = function (d, b) {
19128 extendStatics = Object.setPrototypeOf ||
19129 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19130 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19131 return extendStatics(d, b);
19133 return function (d, b) {
19134 extendStatics(d, b);
19135 function __() { this.constructor = d; }
19136 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19139 Object.defineProperty(exports, "__esModule", { value: true });
19140 var Subscriber_1 = require("../Subscriber");
19141 function map(project, thisArg) {
19142 return function mapOperation(source) {
19143 if (typeof project !== 'function') {
19144 throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
19146 return source.lift(new MapOperator(project, thisArg));
19150 var MapOperator = (function () {
19151 function MapOperator(project, thisArg) {
19152 this.project = project;
19153 this.thisArg = thisArg;
19155 MapOperator.prototype.call = function (subscriber, source) {
19156 return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
19158 return MapOperator;
19160 exports.MapOperator = MapOperator;
19161 var MapSubscriber = (function (_super) {
19162 __extends(MapSubscriber, _super);
19163 function MapSubscriber(destination, project, thisArg) {
19164 var _this = _super.call(this, destination) || this;
19165 _this.project = project;
19167 _this.thisArg = thisArg || _this;
19170 MapSubscriber.prototype._next = function (value) {
19173 result = this.project.call(this.thisArg, value, this.count++);
19176 this.destination.error(err);
19179 this.destination.next(result);
19181 return MapSubscriber;
19182 }(Subscriber_1.Subscriber));
19184 },{"../Subscriber":55}],126:[function(require,module,exports){
19186 var __extends = (this && this.__extends) || (function () {
19187 var extendStatics = function (d, b) {
19188 extendStatics = Object.setPrototypeOf ||
19189 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19190 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19191 return extendStatics(d, b);
19193 return function (d, b) {
19194 extendStatics(d, b);
19195 function __() { this.constructor = d; }
19196 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19199 Object.defineProperty(exports, "__esModule", { value: true });
19200 var Subscriber_1 = require("../Subscriber");
19201 function mapTo(value) {
19202 return function (source) { return source.lift(new MapToOperator(value)); };
19204 exports.mapTo = mapTo;
19205 var MapToOperator = (function () {
19206 function MapToOperator(value) {
19207 this.value = value;
19209 MapToOperator.prototype.call = function (subscriber, source) {
19210 return source.subscribe(new MapToSubscriber(subscriber, this.value));
19212 return MapToOperator;
19214 var MapToSubscriber = (function (_super) {
19215 __extends(MapToSubscriber, _super);
19216 function MapToSubscriber(destination, value) {
19217 var _this = _super.call(this, destination) || this;
19218 _this.value = value;
19221 MapToSubscriber.prototype._next = function (x) {
19222 this.destination.next(this.value);
19224 return MapToSubscriber;
19225 }(Subscriber_1.Subscriber));
19227 },{"../Subscriber":55}],127:[function(require,module,exports){
19229 var __extends = (this && this.__extends) || (function () {
19230 var extendStatics = function (d, b) {
19231 extendStatics = Object.setPrototypeOf ||
19232 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19233 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19234 return extendStatics(d, b);
19236 return function (d, b) {
19237 extendStatics(d, b);
19238 function __() { this.constructor = d; }
19239 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19242 Object.defineProperty(exports, "__esModule", { value: true });
19243 var Subscriber_1 = require("../Subscriber");
19244 var Notification_1 = require("../Notification");
19245 function materialize() {
19246 return function materializeOperatorFunction(source) {
19247 return source.lift(new MaterializeOperator());
19250 exports.materialize = materialize;
19251 var MaterializeOperator = (function () {
19252 function MaterializeOperator() {
19254 MaterializeOperator.prototype.call = function (subscriber, source) {
19255 return source.subscribe(new MaterializeSubscriber(subscriber));
19257 return MaterializeOperator;
19259 var MaterializeSubscriber = (function (_super) {
19260 __extends(MaterializeSubscriber, _super);
19261 function MaterializeSubscriber(destination) {
19262 return _super.call(this, destination) || this;
19264 MaterializeSubscriber.prototype._next = function (value) {
19265 this.destination.next(Notification_1.Notification.createNext(value));
19267 MaterializeSubscriber.prototype._error = function (err) {
19268 var destination = this.destination;
19269 destination.next(Notification_1.Notification.createError(err));
19270 destination.complete();
19272 MaterializeSubscriber.prototype._complete = function () {
19273 var destination = this.destination;
19274 destination.next(Notification_1.Notification.createComplete());
19275 destination.complete();
19277 return MaterializeSubscriber;
19278 }(Subscriber_1.Subscriber));
19280 },{"../Notification":47,"../Subscriber":55}],128:[function(require,module,exports){
19282 Object.defineProperty(exports, "__esModule", { value: true });
19283 var reduce_1 = require("./reduce");
19284 function max(comparer) {
19285 var max = (typeof comparer === 'function')
19286 ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
19287 : function (x, y) { return x > y ? x : y; };
19288 return reduce_1.reduce(max);
19292 },{"./reduce":146}],129:[function(require,module,exports){
19294 Object.defineProperty(exports, "__esModule", { value: true });
19295 var merge_1 = require("../observable/merge");
19297 var observables = [];
19298 for (var _i = 0; _i < arguments.length; _i++) {
19299 observables[_i] = arguments[_i];
19301 return function (source) { return source.lift.call(merge_1.merge.apply(void 0, [source].concat(observables))); };
19303 exports.merge = merge;
19305 },{"../observable/merge":74}],130:[function(require,module,exports){
19307 Object.defineProperty(exports, "__esModule", { value: true });
19308 var mergeMap_1 = require("./mergeMap");
19309 var identity_1 = require("../util/identity");
19310 function mergeAll(concurrent) {
19311 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
19312 return mergeMap_1.mergeMap(identity_1.identity, concurrent);
19314 exports.mergeAll = mergeAll;
19316 },{"../util/identity":219,"./mergeMap":131}],131:[function(require,module,exports){
19318 var __extends = (this && this.__extends) || (function () {
19319 var extendStatics = function (d, b) {
19320 extendStatics = Object.setPrototypeOf ||
19321 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19322 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19323 return extendStatics(d, b);
19325 return function (d, b) {
19326 extendStatics(d, b);
19327 function __() { this.constructor = d; }
19328 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19331 Object.defineProperty(exports, "__esModule", { value: true });
19332 var subscribeToResult_1 = require("../util/subscribeToResult");
19333 var OuterSubscriber_1 = require("../OuterSubscriber");
19334 var InnerSubscriber_1 = require("../InnerSubscriber");
19335 var map_1 = require("./map");
19336 var from_1 = require("../observable/from");
19337 function mergeMap(project, resultSelector, concurrent) {
19338 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
19339 if (typeof resultSelector === 'function') {
19340 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)); };
19342 else if (typeof resultSelector === 'number') {
19343 concurrent = resultSelector;
19345 return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
19347 exports.mergeMap = mergeMap;
19348 var MergeMapOperator = (function () {
19349 function MergeMapOperator(project, concurrent) {
19350 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
19351 this.project = project;
19352 this.concurrent = concurrent;
19354 MergeMapOperator.prototype.call = function (observer, source) {
19355 return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
19357 return MergeMapOperator;
19359 exports.MergeMapOperator = MergeMapOperator;
19360 var MergeMapSubscriber = (function (_super) {
19361 __extends(MergeMapSubscriber, _super);
19362 function MergeMapSubscriber(destination, project, concurrent) {
19363 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
19364 var _this = _super.call(this, destination) || this;
19365 _this.project = project;
19366 _this.concurrent = concurrent;
19367 _this.hasCompleted = false;
19373 MergeMapSubscriber.prototype._next = function (value) {
19374 if (this.active < this.concurrent) {
19375 this._tryNext(value);
19378 this.buffer.push(value);
19381 MergeMapSubscriber.prototype._tryNext = function (value) {
19383 var index = this.index++;
19385 result = this.project(value, index);
19388 this.destination.error(err);
19392 this._innerSub(result, value, index);
19394 MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
19395 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, value, index);
19396 var destination = this.destination;
19397 destination.add(innerSubscriber);
19398 var innerSubscription = subscribeToResult_1.subscribeToResult(this, ish, undefined, undefined, innerSubscriber);
19399 if (innerSubscription !== innerSubscriber) {
19400 destination.add(innerSubscription);
19403 MergeMapSubscriber.prototype._complete = function () {
19404 this.hasCompleted = true;
19405 if (this.active === 0 && this.buffer.length === 0) {
19406 this.destination.complete();
19408 this.unsubscribe();
19410 MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
19411 this.destination.next(innerValue);
19413 MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
19414 var buffer = this.buffer;
19415 this.remove(innerSub);
19417 if (buffer.length > 0) {
19418 this._next(buffer.shift());
19420 else if (this.active === 0 && this.hasCompleted) {
19421 this.destination.complete();
19424 return MergeMapSubscriber;
19425 }(OuterSubscriber_1.OuterSubscriber));
19426 exports.MergeMapSubscriber = MergeMapSubscriber;
19428 },{"../InnerSubscriber":46,"../OuterSubscriber":50,"../observable/from":67,"../util/subscribeToResult":239,"./map":125}],132:[function(require,module,exports){
19430 Object.defineProperty(exports, "__esModule", { value: true });
19431 var mergeMap_1 = require("./mergeMap");
19432 function mergeMapTo(innerObservable, resultSelector, concurrent) {
19433 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
19434 if (typeof resultSelector === 'function') {
19435 return mergeMap_1.mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
19437 if (typeof resultSelector === 'number') {
19438 concurrent = resultSelector;
19440 return mergeMap_1.mergeMap(function () { return innerObservable; }, concurrent);
19442 exports.mergeMapTo = mergeMapTo;
19444 },{"./mergeMap":131}],133:[function(require,module,exports){
19446 var __extends = (this && this.__extends) || (function () {
19447 var extendStatics = function (d, b) {
19448 extendStatics = Object.setPrototypeOf ||
19449 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19450 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19451 return extendStatics(d, b);
19453 return function (d, b) {
19454 extendStatics(d, b);
19455 function __() { this.constructor = d; }
19456 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19459 Object.defineProperty(exports, "__esModule", { value: true });
19460 var subscribeToResult_1 = require("../util/subscribeToResult");
19461 var OuterSubscriber_1 = require("../OuterSubscriber");
19462 var InnerSubscriber_1 = require("../InnerSubscriber");
19463 function mergeScan(accumulator, seed, concurrent) {
19464 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
19465 return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
19467 exports.mergeScan = mergeScan;
19468 var MergeScanOperator = (function () {
19469 function MergeScanOperator(accumulator, seed, concurrent) {
19470 this.accumulator = accumulator;
19472 this.concurrent = concurrent;
19474 MergeScanOperator.prototype.call = function (subscriber, source) {
19475 return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
19477 return MergeScanOperator;
19479 exports.MergeScanOperator = MergeScanOperator;
19480 var MergeScanSubscriber = (function (_super) {
19481 __extends(MergeScanSubscriber, _super);
19482 function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
19483 var _this = _super.call(this, destination) || this;
19484 _this.accumulator = accumulator;
19486 _this.concurrent = concurrent;
19487 _this.hasValue = false;
19488 _this.hasCompleted = false;
19494 MergeScanSubscriber.prototype._next = function (value) {
19495 if (this.active < this.concurrent) {
19496 var index = this.index++;
19497 var destination = this.destination;
19500 var accumulator = this.accumulator;
19501 ish = accumulator(this.acc, value, index);
19504 return destination.error(e);
19507 this._innerSub(ish, value, index);
19510 this.buffer.push(value);
19513 MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
19514 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, value, index);
19515 var destination = this.destination;
19516 destination.add(innerSubscriber);
19517 var innerSubscription = subscribeToResult_1.subscribeToResult(this, ish, undefined, undefined, innerSubscriber);
19518 if (innerSubscription !== innerSubscriber) {
19519 destination.add(innerSubscription);
19522 MergeScanSubscriber.prototype._complete = function () {
19523 this.hasCompleted = true;
19524 if (this.active === 0 && this.buffer.length === 0) {
19525 if (this.hasValue === false) {
19526 this.destination.next(this.acc);
19528 this.destination.complete();
19530 this.unsubscribe();
19532 MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
19533 var destination = this.destination;
19534 this.acc = innerValue;
19535 this.hasValue = true;
19536 destination.next(innerValue);
19538 MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
19539 var buffer = this.buffer;
19540 var destination = this.destination;
19541 destination.remove(innerSub);
19543 if (buffer.length > 0) {
19544 this._next(buffer.shift());
19546 else if (this.active === 0 && this.hasCompleted) {
19547 if (this.hasValue === false) {
19548 this.destination.next(this.acc);
19550 this.destination.complete();
19553 return MergeScanSubscriber;
19554 }(OuterSubscriber_1.OuterSubscriber));
19555 exports.MergeScanSubscriber = MergeScanSubscriber;
19557 },{"../InnerSubscriber":46,"../OuterSubscriber":50,"../util/subscribeToResult":239}],134:[function(require,module,exports){
19559 Object.defineProperty(exports, "__esModule", { value: true });
19560 var reduce_1 = require("./reduce");
19561 function min(comparer) {
19562 var min = (typeof comparer === 'function')
19563 ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
19564 : function (x, y) { return x < y ? x : y; };
19565 return reduce_1.reduce(min);
19569 },{"./reduce":146}],135:[function(require,module,exports){
19571 Object.defineProperty(exports, "__esModule", { value: true });
19572 var ConnectableObservable_1 = require("../observable/ConnectableObservable");
19573 function multicast(subjectOrSubjectFactory, selector) {
19574 return function multicastOperatorFunction(source) {
19575 var subjectFactory;
19576 if (typeof subjectOrSubjectFactory === 'function') {
19577 subjectFactory = subjectOrSubjectFactory;
19580 subjectFactory = function subjectFactory() {
19581 return subjectOrSubjectFactory;
19584 if (typeof selector === 'function') {
19585 return source.lift(new MulticastOperator(subjectFactory, selector));
19587 var connectable = Object.create(source, ConnectableObservable_1.connectableObservableDescriptor);
19588 connectable.source = source;
19589 connectable.subjectFactory = subjectFactory;
19590 return connectable;
19593 exports.multicast = multicast;
19594 var MulticastOperator = (function () {
19595 function MulticastOperator(subjectFactory, selector) {
19596 this.subjectFactory = subjectFactory;
19597 this.selector = selector;
19599 MulticastOperator.prototype.call = function (subscriber, source) {
19600 var selector = this.selector;
19601 var subject = this.subjectFactory();
19602 var subscription = selector(subject).subscribe(subscriber);
19603 subscription.add(source.subscribe(subject));
19604 return subscription;
19606 return MulticastOperator;
19608 exports.MulticastOperator = MulticastOperator;
19610 },{"../observable/ConnectableObservable":58}],136:[function(require,module,exports){
19612 var __extends = (this && this.__extends) || (function () {
19613 var extendStatics = function (d, b) {
19614 extendStatics = Object.setPrototypeOf ||
19615 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19616 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19617 return extendStatics(d, b);
19619 return function (d, b) {
19620 extendStatics(d, b);
19621 function __() { this.constructor = d; }
19622 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19625 Object.defineProperty(exports, "__esModule", { value: true });
19626 var Subscriber_1 = require("../Subscriber");
19627 var Notification_1 = require("../Notification");
19628 function observeOn(scheduler, delay) {
19629 if (delay === void 0) { delay = 0; }
19630 return function observeOnOperatorFunction(source) {
19631 return source.lift(new ObserveOnOperator(scheduler, delay));
19634 exports.observeOn = observeOn;
19635 var ObserveOnOperator = (function () {
19636 function ObserveOnOperator(scheduler, delay) {
19637 if (delay === void 0) { delay = 0; }
19638 this.scheduler = scheduler;
19639 this.delay = delay;
19641 ObserveOnOperator.prototype.call = function (subscriber, source) {
19642 return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
19644 return ObserveOnOperator;
19646 exports.ObserveOnOperator = ObserveOnOperator;
19647 var ObserveOnSubscriber = (function (_super) {
19648 __extends(ObserveOnSubscriber, _super);
19649 function ObserveOnSubscriber(destination, scheduler, delay) {
19650 if (delay === void 0) { delay = 0; }
19651 var _this = _super.call(this, destination) || this;
19652 _this.scheduler = scheduler;
19653 _this.delay = delay;
19656 ObserveOnSubscriber.dispatch = function (arg) {
19657 var notification = arg.notification, destination = arg.destination;
19658 notification.observe(destination);
19659 this.unsubscribe();
19661 ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
19662 var destination = this.destination;
19663 destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
19665 ObserveOnSubscriber.prototype._next = function (value) {
19666 this.scheduleMessage(Notification_1.Notification.createNext(value));
19668 ObserveOnSubscriber.prototype._error = function (err) {
19669 this.scheduleMessage(Notification_1.Notification.createError(err));
19670 this.unsubscribe();
19672 ObserveOnSubscriber.prototype._complete = function () {
19673 this.scheduleMessage(Notification_1.Notification.createComplete());
19674 this.unsubscribe();
19676 return ObserveOnSubscriber;
19677 }(Subscriber_1.Subscriber));
19678 exports.ObserveOnSubscriber = ObserveOnSubscriber;
19679 var ObserveOnMessage = (function () {
19680 function ObserveOnMessage(notification, destination) {
19681 this.notification = notification;
19682 this.destination = destination;
19684 return ObserveOnMessage;
19686 exports.ObserveOnMessage = ObserveOnMessage;
19688 },{"../Notification":47,"../Subscriber":55}],137:[function(require,module,exports){
19690 var __extends = (this && this.__extends) || (function () {
19691 var extendStatics = function (d, b) {
19692 extendStatics = Object.setPrototypeOf ||
19693 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19694 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19695 return extendStatics(d, b);
19697 return function (d, b) {
19698 extendStatics(d, b);
19699 function __() { this.constructor = d; }
19700 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19703 Object.defineProperty(exports, "__esModule", { value: true });
19704 var from_1 = require("../observable/from");
19705 var isArray_1 = require("../util/isArray");
19706 var OuterSubscriber_1 = require("../OuterSubscriber");
19707 var InnerSubscriber_1 = require("../InnerSubscriber");
19708 var subscribeToResult_1 = require("../util/subscribeToResult");
19709 function onErrorResumeNext() {
19710 var nextSources = [];
19711 for (var _i = 0; _i < arguments.length; _i++) {
19712 nextSources[_i] = arguments[_i];
19714 if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) {
19715 nextSources = nextSources[0];
19717 return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
19719 exports.onErrorResumeNext = onErrorResumeNext;
19720 function onErrorResumeNextStatic() {
19721 var nextSources = [];
19722 for (var _i = 0; _i < arguments.length; _i++) {
19723 nextSources[_i] = arguments[_i];
19726 if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) {
19727 nextSources = nextSources[0];
19729 source = nextSources.shift();
19730 return from_1.from(source, null).lift(new OnErrorResumeNextOperator(nextSources));
19732 exports.onErrorResumeNextStatic = onErrorResumeNextStatic;
19733 var OnErrorResumeNextOperator = (function () {
19734 function OnErrorResumeNextOperator(nextSources) {
19735 this.nextSources = nextSources;
19737 OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
19738 return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
19740 return OnErrorResumeNextOperator;
19742 var OnErrorResumeNextSubscriber = (function (_super) {
19743 __extends(OnErrorResumeNextSubscriber, _super);
19744 function OnErrorResumeNextSubscriber(destination, nextSources) {
19745 var _this = _super.call(this, destination) || this;
19746 _this.destination = destination;
19747 _this.nextSources = nextSources;
19750 OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) {
19751 this.subscribeToNextSource();
19753 OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) {
19754 this.subscribeToNextSource();
19756 OnErrorResumeNextSubscriber.prototype._error = function (err) {
19757 this.subscribeToNextSource();
19758 this.unsubscribe();
19760 OnErrorResumeNextSubscriber.prototype._complete = function () {
19761 this.subscribeToNextSource();
19762 this.unsubscribe();
19764 OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
19765 var next = this.nextSources.shift();
19767 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
19768 var destination = this.destination;
19769 destination.add(innerSubscriber);
19770 var innerSubscription = subscribeToResult_1.subscribeToResult(this, next, undefined, undefined, innerSubscriber);
19771 if (innerSubscription !== innerSubscriber) {
19772 destination.add(innerSubscription);
19776 this.destination.complete();
19779 return OnErrorResumeNextSubscriber;
19780 }(OuterSubscriber_1.OuterSubscriber));
19782 },{"../InnerSubscriber":46,"../OuterSubscriber":50,"../observable/from":67,"../util/isArray":220,"../util/subscribeToResult":239}],138:[function(require,module,exports){
19784 var __extends = (this && this.__extends) || (function () {
19785 var extendStatics = function (d, b) {
19786 extendStatics = Object.setPrototypeOf ||
19787 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19788 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19789 return extendStatics(d, b);
19791 return function (d, b) {
19792 extendStatics(d, b);
19793 function __() { this.constructor = d; }
19794 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19797 Object.defineProperty(exports, "__esModule", { value: true });
19798 var Subscriber_1 = require("../Subscriber");
19799 function pairwise() {
19800 return function (source) { return source.lift(new PairwiseOperator()); };
19802 exports.pairwise = pairwise;
19803 var PairwiseOperator = (function () {
19804 function PairwiseOperator() {
19806 PairwiseOperator.prototype.call = function (subscriber, source) {
19807 return source.subscribe(new PairwiseSubscriber(subscriber));
19809 return PairwiseOperator;
19811 var PairwiseSubscriber = (function (_super) {
19812 __extends(PairwiseSubscriber, _super);
19813 function PairwiseSubscriber(destination) {
19814 var _this = _super.call(this, destination) || this;
19815 _this.hasPrev = false;
19818 PairwiseSubscriber.prototype._next = function (value) {
19820 if (this.hasPrev) {
19821 pair = [this.prev, value];
19824 this.hasPrev = true;
19828 this.destination.next(pair);
19831 return PairwiseSubscriber;
19832 }(Subscriber_1.Subscriber));
19834 },{"../Subscriber":55}],139:[function(require,module,exports){
19836 Object.defineProperty(exports, "__esModule", { value: true });
19837 var not_1 = require("../util/not");
19838 var filter_1 = require("./filter");
19839 function partition(predicate, thisArg) {
19840 return function (source) { return [
19841 filter_1.filter(predicate, thisArg)(source),
19842 filter_1.filter(not_1.not(predicate, thisArg))(source)
19845 exports.partition = partition;
19847 },{"../util/not":232,"./filter":116}],140:[function(require,module,exports){
19849 Object.defineProperty(exports, "__esModule", { value: true });
19850 var map_1 = require("./map");
19852 var properties = [];
19853 for (var _i = 0; _i < arguments.length; _i++) {
19854 properties[_i] = arguments[_i];
19856 var length = properties.length;
19857 if (length === 0) {
19858 throw new Error('list of properties cannot be empty.');
19860 return function (source) { return map_1.map(plucker(properties, length))(source); };
19862 exports.pluck = pluck;
19863 function plucker(props, length) {
19864 var mapper = function (x) {
19865 var currentProp = x;
19866 for (var i = 0; i < length; i++) {
19867 var p = currentProp[props[i]];
19868 if (typeof p !== 'undefined') {
19875 return currentProp;
19880 },{"./map":125}],141:[function(require,module,exports){
19882 Object.defineProperty(exports, "__esModule", { value: true });
19883 var Subject_1 = require("../Subject");
19884 var multicast_1 = require("./multicast");
19885 function publish(selector) {
19887 multicast_1.multicast(function () { return new Subject_1.Subject(); }, selector) :
19888 multicast_1.multicast(new Subject_1.Subject());
19890 exports.publish = publish;
19892 },{"../Subject":53,"./multicast":135}],142:[function(require,module,exports){
19894 Object.defineProperty(exports, "__esModule", { value: true });
19895 var BehaviorSubject_1 = require("../BehaviorSubject");
19896 var multicast_1 = require("./multicast");
19897 function publishBehavior(value) {
19898 return function (source) { return multicast_1.multicast(new BehaviorSubject_1.BehaviorSubject(value))(source); };
19900 exports.publishBehavior = publishBehavior;
19902 },{"../BehaviorSubject":45,"./multicast":135}],143:[function(require,module,exports){
19904 Object.defineProperty(exports, "__esModule", { value: true });
19905 var AsyncSubject_1 = require("../AsyncSubject");
19906 var multicast_1 = require("./multicast");
19907 function publishLast() {
19908 return function (source) { return multicast_1.multicast(new AsyncSubject_1.AsyncSubject())(source); };
19910 exports.publishLast = publishLast;
19912 },{"../AsyncSubject":44,"./multicast":135}],144:[function(require,module,exports){
19914 Object.defineProperty(exports, "__esModule", { value: true });
19915 var ReplaySubject_1 = require("../ReplaySubject");
19916 var multicast_1 = require("./multicast");
19917 function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
19918 if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
19919 scheduler = selectorOrScheduler;
19921 var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
19922 var subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler);
19923 return function (source) { return multicast_1.multicast(function () { return subject; }, selector)(source); };
19925 exports.publishReplay = publishReplay;
19927 },{"../ReplaySubject":51,"./multicast":135}],145:[function(require,module,exports){
19929 Object.defineProperty(exports, "__esModule", { value: true });
19930 var isArray_1 = require("../util/isArray");
19931 var race_1 = require("../observable/race");
19933 var observables = [];
19934 for (var _i = 0; _i < arguments.length; _i++) {
19935 observables[_i] = arguments[_i];
19937 return function raceOperatorFunction(source) {
19938 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
19939 observables = observables[0];
19941 return source.lift.call(race_1.race.apply(void 0, [source].concat(observables)));
19944 exports.race = race;
19946 },{"../observable/race":80,"../util/isArray":220}],146:[function(require,module,exports){
19948 Object.defineProperty(exports, "__esModule", { value: true });
19949 var scan_1 = require("./scan");
19950 var takeLast_1 = require("./takeLast");
19951 var defaultIfEmpty_1 = require("./defaultIfEmpty");
19952 var pipe_1 = require("../util/pipe");
19953 function reduce(accumulator, seed) {
19954 if (arguments.length >= 2) {
19955 return function reduceOperatorFunctionWithSeed(source) {
19956 return pipe_1.pipe(scan_1.scan(accumulator, seed), takeLast_1.takeLast(1), defaultIfEmpty_1.defaultIfEmpty(seed))(source);
19959 return function reduceOperatorFunction(source) {
19960 return pipe_1.pipe(scan_1.scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast_1.takeLast(1))(source);
19963 exports.reduce = reduce;
19965 },{"../util/pipe":233,"./defaultIfEmpty":103,"./scan":154,"./takeLast":169}],147:[function(require,module,exports){
19967 var __extends = (this && this.__extends) || (function () {
19968 var extendStatics = function (d, b) {
19969 extendStatics = Object.setPrototypeOf ||
19970 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19971 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19972 return extendStatics(d, b);
19974 return function (d, b) {
19975 extendStatics(d, b);
19976 function __() { this.constructor = d; }
19977 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19980 Object.defineProperty(exports, "__esModule", { value: true });
19981 var Subscriber_1 = require("../Subscriber");
19982 function refCount() {
19983 return function refCountOperatorFunction(source) {
19984 return source.lift(new RefCountOperator(source));
19987 exports.refCount = refCount;
19988 var RefCountOperator = (function () {
19989 function RefCountOperator(connectable) {
19990 this.connectable = connectable;
19992 RefCountOperator.prototype.call = function (subscriber, source) {
19993 var connectable = this.connectable;
19994 connectable._refCount++;
19995 var refCounter = new RefCountSubscriber(subscriber, connectable);
19996 var subscription = source.subscribe(refCounter);
19997 if (!refCounter.closed) {
19998 refCounter.connection = connectable.connect();
20000 return subscription;
20002 return RefCountOperator;
20004 var RefCountSubscriber = (function (_super) {
20005 __extends(RefCountSubscriber, _super);
20006 function RefCountSubscriber(destination, connectable) {
20007 var _this = _super.call(this, destination) || this;
20008 _this.connectable = connectable;
20011 RefCountSubscriber.prototype._unsubscribe = function () {
20012 var connectable = this.connectable;
20013 if (!connectable) {
20014 this.connection = null;
20017 this.connectable = null;
20018 var refCount = connectable._refCount;
20019 if (refCount <= 0) {
20020 this.connection = null;
20023 connectable._refCount = refCount - 1;
20024 if (refCount > 1) {
20025 this.connection = null;
20028 var connection = this.connection;
20029 var sharedConnection = connectable._connection;
20030 this.connection = null;
20031 if (sharedConnection && (!connection || sharedConnection === connection)) {
20032 sharedConnection.unsubscribe();
20035 return RefCountSubscriber;
20036 }(Subscriber_1.Subscriber));
20038 },{"../Subscriber":55}],148:[function(require,module,exports){
20040 var __extends = (this && this.__extends) || (function () {
20041 var extendStatics = function (d, b) {
20042 extendStatics = Object.setPrototypeOf ||
20043 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20044 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20045 return extendStatics(d, b);
20047 return function (d, b) {
20048 extendStatics(d, b);
20049 function __() { this.constructor = d; }
20050 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20053 Object.defineProperty(exports, "__esModule", { value: true });
20054 var Subscriber_1 = require("../Subscriber");
20055 var empty_1 = require("../observable/empty");
20056 function repeat(count) {
20057 if (count === void 0) { count = -1; }
20058 return function (source) {
20060 return empty_1.empty();
20062 else if (count < 0) {
20063 return source.lift(new RepeatOperator(-1, source));
20066 return source.lift(new RepeatOperator(count - 1, source));
20070 exports.repeat = repeat;
20071 var RepeatOperator = (function () {
20072 function RepeatOperator(count, source) {
20073 this.count = count;
20074 this.source = source;
20076 RepeatOperator.prototype.call = function (subscriber, source) {
20077 return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
20079 return RepeatOperator;
20081 var RepeatSubscriber = (function (_super) {
20082 __extends(RepeatSubscriber, _super);
20083 function RepeatSubscriber(destination, count, source) {
20084 var _this = _super.call(this, destination) || this;
20085 _this.count = count;
20086 _this.source = source;
20089 RepeatSubscriber.prototype.complete = function () {
20090 if (!this.isStopped) {
20091 var _a = this, source = _a.source, count = _a.count;
20093 return _super.prototype.complete.call(this);
20095 else if (count > -1) {
20096 this.count = count - 1;
20098 source.subscribe(this._unsubscribeAndRecycle());
20101 return RepeatSubscriber;
20102 }(Subscriber_1.Subscriber));
20104 },{"../Subscriber":55,"../observable/empty":65}],149:[function(require,module,exports){
20106 var __extends = (this && this.__extends) || (function () {
20107 var extendStatics = function (d, b) {
20108 extendStatics = Object.setPrototypeOf ||
20109 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20110 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20111 return extendStatics(d, b);
20113 return function (d, b) {
20114 extendStatics(d, b);
20115 function __() { this.constructor = d; }
20116 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20119 Object.defineProperty(exports, "__esModule", { value: true });
20120 var Subject_1 = require("../Subject");
20121 var OuterSubscriber_1 = require("../OuterSubscriber");
20122 var subscribeToResult_1 = require("../util/subscribeToResult");
20123 function repeatWhen(notifier) {
20124 return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
20126 exports.repeatWhen = repeatWhen;
20127 var RepeatWhenOperator = (function () {
20128 function RepeatWhenOperator(notifier) {
20129 this.notifier = notifier;
20131 RepeatWhenOperator.prototype.call = function (subscriber, source) {
20132 return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
20134 return RepeatWhenOperator;
20136 var RepeatWhenSubscriber = (function (_super) {
20137 __extends(RepeatWhenSubscriber, _super);
20138 function RepeatWhenSubscriber(destination, notifier, source) {
20139 var _this = _super.call(this, destination) || this;
20140 _this.notifier = notifier;
20141 _this.source = source;
20142 _this.sourceIsBeingSubscribedTo = true;
20145 RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
20146 this.sourceIsBeingSubscribedTo = true;
20147 this.source.subscribe(this);
20149 RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) {
20150 if (this.sourceIsBeingSubscribedTo === false) {
20151 return _super.prototype.complete.call(this);
20154 RepeatWhenSubscriber.prototype.complete = function () {
20155 this.sourceIsBeingSubscribedTo = false;
20156 if (!this.isStopped) {
20157 if (!this.retries) {
20158 this.subscribeToRetries();
20160 if (!this.retriesSubscription || this.retriesSubscription.closed) {
20161 return _super.prototype.complete.call(this);
20163 this._unsubscribeAndRecycle();
20164 this.notifications.next();
20167 RepeatWhenSubscriber.prototype._unsubscribe = function () {
20168 var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
20169 if (notifications) {
20170 notifications.unsubscribe();
20171 this.notifications = null;
20173 if (retriesSubscription) {
20174 retriesSubscription.unsubscribe();
20175 this.retriesSubscription = null;
20177 this.retries = null;
20179 RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
20180 var _unsubscribe = this._unsubscribe;
20181 this._unsubscribe = null;
20182 _super.prototype._unsubscribeAndRecycle.call(this);
20183 this._unsubscribe = _unsubscribe;
20186 RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
20187 this.notifications = new Subject_1.Subject();
20190 var notifier = this.notifier;
20191 retries = notifier(this.notifications);
20194 return _super.prototype.complete.call(this);
20196 this.retries = retries;
20197 this.retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries);
20199 return RepeatWhenSubscriber;
20200 }(OuterSubscriber_1.OuterSubscriber));
20202 },{"../OuterSubscriber":50,"../Subject":53,"../util/subscribeToResult":239}],150:[function(require,module,exports){
20204 var __extends = (this && this.__extends) || (function () {
20205 var extendStatics = function (d, b) {
20206 extendStatics = Object.setPrototypeOf ||
20207 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20208 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20209 return extendStatics(d, b);
20211 return function (d, b) {
20212 extendStatics(d, b);
20213 function __() { this.constructor = d; }
20214 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20217 Object.defineProperty(exports, "__esModule", { value: true });
20218 var Subscriber_1 = require("../Subscriber");
20219 function retry(count) {
20220 if (count === void 0) { count = -1; }
20221 return function (source) { return source.lift(new RetryOperator(count, source)); };
20223 exports.retry = retry;
20224 var RetryOperator = (function () {
20225 function RetryOperator(count, source) {
20226 this.count = count;
20227 this.source = source;
20229 RetryOperator.prototype.call = function (subscriber, source) {
20230 return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
20232 return RetryOperator;
20234 var RetrySubscriber = (function (_super) {
20235 __extends(RetrySubscriber, _super);
20236 function RetrySubscriber(destination, count, source) {
20237 var _this = _super.call(this, destination) || this;
20238 _this.count = count;
20239 _this.source = source;
20242 RetrySubscriber.prototype.error = function (err) {
20243 if (!this.isStopped) {
20244 var _a = this, source = _a.source, count = _a.count;
20246 return _super.prototype.error.call(this, err);
20248 else if (count > -1) {
20249 this.count = count - 1;
20251 source.subscribe(this._unsubscribeAndRecycle());
20254 return RetrySubscriber;
20255 }(Subscriber_1.Subscriber));
20257 },{"../Subscriber":55}],151:[function(require,module,exports){
20259 var __extends = (this && this.__extends) || (function () {
20260 var extendStatics = function (d, b) {
20261 extendStatics = Object.setPrototypeOf ||
20262 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20263 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20264 return extendStatics(d, b);
20266 return function (d, b) {
20267 extendStatics(d, b);
20268 function __() { this.constructor = d; }
20269 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20272 Object.defineProperty(exports, "__esModule", { value: true });
20273 var Subject_1 = require("../Subject");
20274 var OuterSubscriber_1 = require("../OuterSubscriber");
20275 var subscribeToResult_1 = require("../util/subscribeToResult");
20276 function retryWhen(notifier) {
20277 return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
20279 exports.retryWhen = retryWhen;
20280 var RetryWhenOperator = (function () {
20281 function RetryWhenOperator(notifier, source) {
20282 this.notifier = notifier;
20283 this.source = source;
20285 RetryWhenOperator.prototype.call = function (subscriber, source) {
20286 return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
20288 return RetryWhenOperator;
20290 var RetryWhenSubscriber = (function (_super) {
20291 __extends(RetryWhenSubscriber, _super);
20292 function RetryWhenSubscriber(destination, notifier, source) {
20293 var _this = _super.call(this, destination) || this;
20294 _this.notifier = notifier;
20295 _this.source = source;
20298 RetryWhenSubscriber.prototype.error = function (err) {
20299 if (!this.isStopped) {
20300 var errors = this.errors;
20301 var retries = this.retries;
20302 var retriesSubscription = this.retriesSubscription;
20304 errors = new Subject_1.Subject();
20306 var notifier = this.notifier;
20307 retries = notifier(errors);
20310 return _super.prototype.error.call(this, e);
20312 retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries);
20315 this.errors = null;
20316 this.retriesSubscription = null;
20318 this._unsubscribeAndRecycle();
20319 this.errors = errors;
20320 this.retries = retries;
20321 this.retriesSubscription = retriesSubscription;
20325 RetryWhenSubscriber.prototype._unsubscribe = function () {
20326 var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
20328 errors.unsubscribe();
20329 this.errors = null;
20331 if (retriesSubscription) {
20332 retriesSubscription.unsubscribe();
20333 this.retriesSubscription = null;
20335 this.retries = null;
20337 RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
20338 var _unsubscribe = this._unsubscribe;
20339 this._unsubscribe = null;
20340 this._unsubscribeAndRecycle();
20341 this._unsubscribe = _unsubscribe;
20342 this.source.subscribe(this);
20344 return RetryWhenSubscriber;
20345 }(OuterSubscriber_1.OuterSubscriber));
20347 },{"../OuterSubscriber":50,"../Subject":53,"../util/subscribeToResult":239}],152:[function(require,module,exports){
20349 var __extends = (this && this.__extends) || (function () {
20350 var extendStatics = function (d, b) {
20351 extendStatics = Object.setPrototypeOf ||
20352 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20353 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20354 return extendStatics(d, b);
20356 return function (d, b) {
20357 extendStatics(d, b);
20358 function __() { this.constructor = d; }
20359 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20362 Object.defineProperty(exports, "__esModule", { value: true });
20363 var OuterSubscriber_1 = require("../OuterSubscriber");
20364 var subscribeToResult_1 = require("../util/subscribeToResult");
20365 function sample(notifier) {
20366 return function (source) { return source.lift(new SampleOperator(notifier)); };
20368 exports.sample = sample;
20369 var SampleOperator = (function () {
20370 function SampleOperator(notifier) {
20371 this.notifier = notifier;
20373 SampleOperator.prototype.call = function (subscriber, source) {
20374 var sampleSubscriber = new SampleSubscriber(subscriber);
20375 var subscription = source.subscribe(sampleSubscriber);
20376 subscription.add(subscribeToResult_1.subscribeToResult(sampleSubscriber, this.notifier));
20377 return subscription;
20379 return SampleOperator;
20381 var SampleSubscriber = (function (_super) {
20382 __extends(SampleSubscriber, _super);
20383 function SampleSubscriber() {
20384 var _this = _super !== null && _super.apply(this, arguments) || this;
20385 _this.hasValue = false;
20388 SampleSubscriber.prototype._next = function (value) {
20389 this.value = value;
20390 this.hasValue = true;
20392 SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
20395 SampleSubscriber.prototype.notifyComplete = function () {
20398 SampleSubscriber.prototype.emitValue = function () {
20399 if (this.hasValue) {
20400 this.hasValue = false;
20401 this.destination.next(this.value);
20404 return SampleSubscriber;
20405 }(OuterSubscriber_1.OuterSubscriber));
20407 },{"../OuterSubscriber":50,"../util/subscribeToResult":239}],153:[function(require,module,exports){
20409 var __extends = (this && this.__extends) || (function () {
20410 var extendStatics = function (d, b) {
20411 extendStatics = Object.setPrototypeOf ||
20412 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20413 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20414 return extendStatics(d, b);
20416 return function (d, b) {
20417 extendStatics(d, b);
20418 function __() { this.constructor = d; }
20419 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20422 Object.defineProperty(exports, "__esModule", { value: true });
20423 var Subscriber_1 = require("../Subscriber");
20424 var async_1 = require("../scheduler/async");
20425 function sampleTime(period, scheduler) {
20426 if (scheduler === void 0) { scheduler = async_1.async; }
20427 return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
20429 exports.sampleTime = sampleTime;
20430 var SampleTimeOperator = (function () {
20431 function SampleTimeOperator(period, scheduler) {
20432 this.period = period;
20433 this.scheduler = scheduler;
20435 SampleTimeOperator.prototype.call = function (subscriber, source) {
20436 return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
20438 return SampleTimeOperator;
20440 var SampleTimeSubscriber = (function (_super) {
20441 __extends(SampleTimeSubscriber, _super);
20442 function SampleTimeSubscriber(destination, period, scheduler) {
20443 var _this = _super.call(this, destination) || this;
20444 _this.period = period;
20445 _this.scheduler = scheduler;
20446 _this.hasValue = false;
20447 _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
20450 SampleTimeSubscriber.prototype._next = function (value) {
20451 this.lastValue = value;
20452 this.hasValue = true;
20454 SampleTimeSubscriber.prototype.notifyNext = function () {
20455 if (this.hasValue) {
20456 this.hasValue = false;
20457 this.destination.next(this.lastValue);
20460 return SampleTimeSubscriber;
20461 }(Subscriber_1.Subscriber));
20462 function dispatchNotification(state) {
20463 var subscriber = state.subscriber, period = state.period;
20464 subscriber.notifyNext();
20465 this.schedule(state, period);
20468 },{"../Subscriber":55,"../scheduler/async":206}],154:[function(require,module,exports){
20470 var __extends = (this && this.__extends) || (function () {
20471 var extendStatics = function (d, b) {
20472 extendStatics = Object.setPrototypeOf ||
20473 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20474 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20475 return extendStatics(d, b);
20477 return function (d, b) {
20478 extendStatics(d, b);
20479 function __() { this.constructor = d; }
20480 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20483 Object.defineProperty(exports, "__esModule", { value: true });
20484 var Subscriber_1 = require("../Subscriber");
20485 function scan(accumulator, seed) {
20486 var hasSeed = false;
20487 if (arguments.length >= 2) {
20490 return function scanOperatorFunction(source) {
20491 return source.lift(new ScanOperator(accumulator, seed, hasSeed));
20494 exports.scan = scan;
20495 var ScanOperator = (function () {
20496 function ScanOperator(accumulator, seed, hasSeed) {
20497 if (hasSeed === void 0) { hasSeed = false; }
20498 this.accumulator = accumulator;
20500 this.hasSeed = hasSeed;
20502 ScanOperator.prototype.call = function (subscriber, source) {
20503 return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
20505 return ScanOperator;
20507 var ScanSubscriber = (function (_super) {
20508 __extends(ScanSubscriber, _super);
20509 function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
20510 var _this = _super.call(this, destination) || this;
20511 _this.accumulator = accumulator;
20512 _this._seed = _seed;
20513 _this.hasSeed = hasSeed;
20517 Object.defineProperty(ScanSubscriber.prototype, "seed", {
20521 set: function (value) {
20522 this.hasSeed = true;
20523 this._seed = value;
20528 ScanSubscriber.prototype._next = function (value) {
20529 if (!this.hasSeed) {
20531 this.destination.next(value);
20534 return this._tryNext(value);
20537 ScanSubscriber.prototype._tryNext = function (value) {
20538 var index = this.index++;
20541 result = this.accumulator(this.seed, value, index);
20544 this.destination.error(err);
20546 this.seed = result;
20547 this.destination.next(result);
20549 return ScanSubscriber;
20550 }(Subscriber_1.Subscriber));
20552 },{"../Subscriber":55}],155:[function(require,module,exports){
20554 var __extends = (this && this.__extends) || (function () {
20555 var extendStatics = function (d, b) {
20556 extendStatics = Object.setPrototypeOf ||
20557 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20558 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20559 return extendStatics(d, b);
20561 return function (d, b) {
20562 extendStatics(d, b);
20563 function __() { this.constructor = d; }
20564 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20567 Object.defineProperty(exports, "__esModule", { value: true });
20568 var Subscriber_1 = require("../Subscriber");
20569 function sequenceEqual(compareTo, comparator) {
20570 return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparator)); };
20572 exports.sequenceEqual = sequenceEqual;
20573 var SequenceEqualOperator = (function () {
20574 function SequenceEqualOperator(compareTo, comparator) {
20575 this.compareTo = compareTo;
20576 this.comparator = comparator;
20578 SequenceEqualOperator.prototype.call = function (subscriber, source) {
20579 return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparator));
20581 return SequenceEqualOperator;
20583 exports.SequenceEqualOperator = SequenceEqualOperator;
20584 var SequenceEqualSubscriber = (function (_super) {
20585 __extends(SequenceEqualSubscriber, _super);
20586 function SequenceEqualSubscriber(destination, compareTo, comparator) {
20587 var _this = _super.call(this, destination) || this;
20588 _this.compareTo = compareTo;
20589 _this.comparator = comparator;
20592 _this._oneComplete = false;
20593 _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
20596 SequenceEqualSubscriber.prototype._next = function (value) {
20597 if (this._oneComplete && this._b.length === 0) {
20601 this._a.push(value);
20602 this.checkValues();
20605 SequenceEqualSubscriber.prototype._complete = function () {
20606 if (this._oneComplete) {
20607 this.emit(this._a.length === 0 && this._b.length === 0);
20610 this._oneComplete = true;
20612 this.unsubscribe();
20614 SequenceEqualSubscriber.prototype.checkValues = function () {
20615 var _c = this, _a = _c._a, _b = _c._b, comparator = _c.comparator;
20616 while (_a.length > 0 && _b.length > 0) {
20617 var a = _a.shift();
20618 var b = _b.shift();
20619 var areEqual = false;
20621 areEqual = comparator ? comparator(a, b) : a === b;
20624 this.destination.error(e);
20631 SequenceEqualSubscriber.prototype.emit = function (value) {
20632 var destination = this.destination;
20633 destination.next(value);
20634 destination.complete();
20636 SequenceEqualSubscriber.prototype.nextB = function (value) {
20637 if (this._oneComplete && this._a.length === 0) {
20641 this._b.push(value);
20642 this.checkValues();
20645 SequenceEqualSubscriber.prototype.completeB = function () {
20646 if (this._oneComplete) {
20647 this.emit(this._a.length === 0 && this._b.length === 0);
20650 this._oneComplete = true;
20653 return SequenceEqualSubscriber;
20654 }(Subscriber_1.Subscriber));
20655 exports.SequenceEqualSubscriber = SequenceEqualSubscriber;
20656 var SequenceEqualCompareToSubscriber = (function (_super) {
20657 __extends(SequenceEqualCompareToSubscriber, _super);
20658 function SequenceEqualCompareToSubscriber(destination, parent) {
20659 var _this = _super.call(this, destination) || this;
20660 _this.parent = parent;
20663 SequenceEqualCompareToSubscriber.prototype._next = function (value) {
20664 this.parent.nextB(value);
20666 SequenceEqualCompareToSubscriber.prototype._error = function (err) {
20667 this.parent.error(err);
20668 this.unsubscribe();
20670 SequenceEqualCompareToSubscriber.prototype._complete = function () {
20671 this.parent.completeB();
20672 this.unsubscribe();
20674 return SequenceEqualCompareToSubscriber;
20675 }(Subscriber_1.Subscriber));
20677 },{"../Subscriber":55}],156:[function(require,module,exports){
20679 Object.defineProperty(exports, "__esModule", { value: true });
20680 var multicast_1 = require("./multicast");
20681 var refCount_1 = require("./refCount");
20682 var Subject_1 = require("../Subject");
20683 function shareSubjectFactory() {
20684 return new Subject_1.Subject();
20687 return function (source) { return refCount_1.refCount()(multicast_1.multicast(shareSubjectFactory)(source)); };
20689 exports.share = share;
20691 },{"../Subject":53,"./multicast":135,"./refCount":147}],157:[function(require,module,exports){
20693 Object.defineProperty(exports, "__esModule", { value: true });
20694 var ReplaySubject_1 = require("../ReplaySubject");
20695 function shareReplay(configOrBufferSize, windowTime, scheduler) {
20697 if (configOrBufferSize && typeof configOrBufferSize === 'object') {
20698 config = configOrBufferSize;
20702 bufferSize: configOrBufferSize,
20703 windowTime: windowTime,
20705 scheduler: scheduler
20708 return function (source) { return source.lift(shareReplayOperator(config)); };
20710 exports.shareReplay = shareReplay;
20711 function shareReplayOperator(_a) {
20712 var _b = _a.bufferSize, bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, _c = _a.windowTime, windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, useRefCount = _a.refCount, scheduler = _a.scheduler;
20716 var hasError = false;
20717 var isComplete = false;
20718 return function shareReplayOperation(source) {
20720 if (!subject || hasError) {
20722 subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler);
20723 subscription = source.subscribe({
20724 next: function (value) { subject.next(value); },
20725 error: function (err) {
20727 subject.error(err);
20729 complete: function () {
20731 subscription = undefined;
20732 subject.complete();
20736 var innerSub = subject.subscribe(this);
20737 this.add(function () {
20739 innerSub.unsubscribe();
20740 if (subscription && !isComplete && useRefCount && refCount === 0) {
20741 subscription.unsubscribe();
20742 subscription = undefined;
20743 subject = undefined;
20749 },{"../ReplaySubject":51}],158:[function(require,module,exports){
20751 var __extends = (this && this.__extends) || (function () {
20752 var extendStatics = function (d, b) {
20753 extendStatics = Object.setPrototypeOf ||
20754 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20755 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20756 return extendStatics(d, b);
20758 return function (d, b) {
20759 extendStatics(d, b);
20760 function __() { this.constructor = d; }
20761 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20764 Object.defineProperty(exports, "__esModule", { value: true });
20765 var Subscriber_1 = require("../Subscriber");
20766 var EmptyError_1 = require("../util/EmptyError");
20767 function single(predicate) {
20768 return function (source) { return source.lift(new SingleOperator(predicate, source)); };
20770 exports.single = single;
20771 var SingleOperator = (function () {
20772 function SingleOperator(predicate, source) {
20773 this.predicate = predicate;
20774 this.source = source;
20776 SingleOperator.prototype.call = function (subscriber, source) {
20777 return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source));
20779 return SingleOperator;
20781 var SingleSubscriber = (function (_super) {
20782 __extends(SingleSubscriber, _super);
20783 function SingleSubscriber(destination, predicate, source) {
20784 var _this = _super.call(this, destination) || this;
20785 _this.predicate = predicate;
20786 _this.source = source;
20787 _this.seenValue = false;
20791 SingleSubscriber.prototype.applySingleValue = function (value) {
20792 if (this.seenValue) {
20793 this.destination.error('Sequence contains more than one element');
20796 this.seenValue = true;
20797 this.singleValue = value;
20800 SingleSubscriber.prototype._next = function (value) {
20801 var index = this.index++;
20802 if (this.predicate) {
20803 this.tryNext(value, index);
20806 this.applySingleValue(value);
20809 SingleSubscriber.prototype.tryNext = function (value, index) {
20811 if (this.predicate(value, index, this.source)) {
20812 this.applySingleValue(value);
20816 this.destination.error(err);
20819 SingleSubscriber.prototype._complete = function () {
20820 var destination = this.destination;
20821 if (this.index > 0) {
20822 destination.next(this.seenValue ? this.singleValue : undefined);
20823 destination.complete();
20826 destination.error(new EmptyError_1.EmptyError);
20829 return SingleSubscriber;
20830 }(Subscriber_1.Subscriber));
20832 },{"../Subscriber":55,"../util/EmptyError":212}],159:[function(require,module,exports){
20834 var __extends = (this && this.__extends) || (function () {
20835 var extendStatics = function (d, b) {
20836 extendStatics = Object.setPrototypeOf ||
20837 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20838 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20839 return extendStatics(d, b);
20841 return function (d, b) {
20842 extendStatics(d, b);
20843 function __() { this.constructor = d; }
20844 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20847 Object.defineProperty(exports, "__esModule", { value: true });
20848 var Subscriber_1 = require("../Subscriber");
20849 function skip(count) {
20850 return function (source) { return source.lift(new SkipOperator(count)); };
20852 exports.skip = skip;
20853 var SkipOperator = (function () {
20854 function SkipOperator(total) {
20855 this.total = total;
20857 SkipOperator.prototype.call = function (subscriber, source) {
20858 return source.subscribe(new SkipSubscriber(subscriber, this.total));
20860 return SkipOperator;
20862 var SkipSubscriber = (function (_super) {
20863 __extends(SkipSubscriber, _super);
20864 function SkipSubscriber(destination, total) {
20865 var _this = _super.call(this, destination) || this;
20866 _this.total = total;
20870 SkipSubscriber.prototype._next = function (x) {
20871 if (++this.count > this.total) {
20872 this.destination.next(x);
20875 return SkipSubscriber;
20876 }(Subscriber_1.Subscriber));
20878 },{"../Subscriber":55}],160:[function(require,module,exports){
20880 var __extends = (this && this.__extends) || (function () {
20881 var extendStatics = function (d, b) {
20882 extendStatics = Object.setPrototypeOf ||
20883 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20884 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20885 return extendStatics(d, b);
20887 return function (d, b) {
20888 extendStatics(d, b);
20889 function __() { this.constructor = d; }
20890 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20893 Object.defineProperty(exports, "__esModule", { value: true });
20894 var Subscriber_1 = require("../Subscriber");
20895 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
20896 function skipLast(count) {
20897 return function (source) { return source.lift(new SkipLastOperator(count)); };
20899 exports.skipLast = skipLast;
20900 var SkipLastOperator = (function () {
20901 function SkipLastOperator(_skipCount) {
20902 this._skipCount = _skipCount;
20903 if (this._skipCount < 0) {
20904 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
20907 SkipLastOperator.prototype.call = function (subscriber, source) {
20908 if (this._skipCount === 0) {
20909 return source.subscribe(new Subscriber_1.Subscriber(subscriber));
20912 return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
20915 return SkipLastOperator;
20917 var SkipLastSubscriber = (function (_super) {
20918 __extends(SkipLastSubscriber, _super);
20919 function SkipLastSubscriber(destination, _skipCount) {
20920 var _this = _super.call(this, destination) || this;
20921 _this._skipCount = _skipCount;
20923 _this._ring = new Array(_skipCount);
20926 SkipLastSubscriber.prototype._next = function (value) {
20927 var skipCount = this._skipCount;
20928 var count = this._count++;
20929 if (count < skipCount) {
20930 this._ring[count] = value;
20933 var currentIndex = count % skipCount;
20934 var ring = this._ring;
20935 var oldValue = ring[currentIndex];
20936 ring[currentIndex] = value;
20937 this.destination.next(oldValue);
20940 return SkipLastSubscriber;
20941 }(Subscriber_1.Subscriber));
20943 },{"../Subscriber":55,"../util/ArgumentOutOfRangeError":211}],161:[function(require,module,exports){
20945 var __extends = (this && this.__extends) || (function () {
20946 var extendStatics = function (d, b) {
20947 extendStatics = Object.setPrototypeOf ||
20948 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20949 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20950 return extendStatics(d, b);
20952 return function (d, b) {
20953 extendStatics(d, b);
20954 function __() { this.constructor = d; }
20955 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20958 Object.defineProperty(exports, "__esModule", { value: true });
20959 var OuterSubscriber_1 = require("../OuterSubscriber");
20960 var InnerSubscriber_1 = require("../InnerSubscriber");
20961 var subscribeToResult_1 = require("../util/subscribeToResult");
20962 function skipUntil(notifier) {
20963 return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
20965 exports.skipUntil = skipUntil;
20966 var SkipUntilOperator = (function () {
20967 function SkipUntilOperator(notifier) {
20968 this.notifier = notifier;
20970 SkipUntilOperator.prototype.call = function (destination, source) {
20971 return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
20973 return SkipUntilOperator;
20975 var SkipUntilSubscriber = (function (_super) {
20976 __extends(SkipUntilSubscriber, _super);
20977 function SkipUntilSubscriber(destination, notifier) {
20978 var _this = _super.call(this, destination) || this;
20979 _this.hasValue = false;
20980 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(_this, undefined, undefined);
20981 _this.add(innerSubscriber);
20982 _this.innerSubscription = innerSubscriber;
20983 var innerSubscription = subscribeToResult_1.subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
20984 if (innerSubscription !== innerSubscriber) {
20985 _this.add(innerSubscription);
20986 _this.innerSubscription = innerSubscription;
20990 SkipUntilSubscriber.prototype._next = function (value) {
20991 if (this.hasValue) {
20992 _super.prototype._next.call(this, value);
20995 SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
20996 this.hasValue = true;
20997 if (this.innerSubscription) {
20998 this.innerSubscription.unsubscribe();
21001 SkipUntilSubscriber.prototype.notifyComplete = function () {
21003 return SkipUntilSubscriber;
21004 }(OuterSubscriber_1.OuterSubscriber));
21006 },{"../InnerSubscriber":46,"../OuterSubscriber":50,"../util/subscribeToResult":239}],162:[function(require,module,exports){
21008 var __extends = (this && this.__extends) || (function () {
21009 var extendStatics = function (d, b) {
21010 extendStatics = Object.setPrototypeOf ||
21011 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21012 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21013 return extendStatics(d, b);
21015 return function (d, b) {
21016 extendStatics(d, b);
21017 function __() { this.constructor = d; }
21018 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21021 Object.defineProperty(exports, "__esModule", { value: true });
21022 var Subscriber_1 = require("../Subscriber");
21023 function skipWhile(predicate) {
21024 return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
21026 exports.skipWhile = skipWhile;
21027 var SkipWhileOperator = (function () {
21028 function SkipWhileOperator(predicate) {
21029 this.predicate = predicate;
21031 SkipWhileOperator.prototype.call = function (subscriber, source) {
21032 return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
21034 return SkipWhileOperator;
21036 var SkipWhileSubscriber = (function (_super) {
21037 __extends(SkipWhileSubscriber, _super);
21038 function SkipWhileSubscriber(destination, predicate) {
21039 var _this = _super.call(this, destination) || this;
21040 _this.predicate = predicate;
21041 _this.skipping = true;
21045 SkipWhileSubscriber.prototype._next = function (value) {
21046 var destination = this.destination;
21047 if (this.skipping) {
21048 this.tryCallPredicate(value);
21050 if (!this.skipping) {
21051 destination.next(value);
21054 SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
21056 var result = this.predicate(value, this.index++);
21057 this.skipping = Boolean(result);
21060 this.destination.error(err);
21063 return SkipWhileSubscriber;
21064 }(Subscriber_1.Subscriber));
21066 },{"../Subscriber":55}],163:[function(require,module,exports){
21068 Object.defineProperty(exports, "__esModule", { value: true });
21069 var concat_1 = require("../observable/concat");
21070 var isScheduler_1 = require("../util/isScheduler");
21071 function startWith() {
21073 for (var _i = 0; _i < arguments.length; _i++) {
21074 array[_i] = arguments[_i];
21076 var scheduler = array[array.length - 1];
21077 if (isScheduler_1.isScheduler(scheduler)) {
21079 return function (source) { return concat_1.concat(array, source, scheduler); };
21082 return function (source) { return concat_1.concat(array, source); };
21085 exports.startWith = startWith;
21087 },{"../observable/concat":63,"../util/isScheduler":230}],164:[function(require,module,exports){
21089 Object.defineProperty(exports, "__esModule", { value: true });
21090 var SubscribeOnObservable_1 = require("../observable/SubscribeOnObservable");
21091 function subscribeOn(scheduler, delay) {
21092 if (delay === void 0) { delay = 0; }
21093 return function subscribeOnOperatorFunction(source) {
21094 return source.lift(new SubscribeOnOperator(scheduler, delay));
21097 exports.subscribeOn = subscribeOn;
21098 var SubscribeOnOperator = (function () {
21099 function SubscribeOnOperator(scheduler, delay) {
21100 this.scheduler = scheduler;
21101 this.delay = delay;
21103 SubscribeOnOperator.prototype.call = function (subscriber, source) {
21104 return new SubscribeOnObservable_1.SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
21106 return SubscribeOnOperator;
21109 },{"../observable/SubscribeOnObservable":59}],165:[function(require,module,exports){
21111 Object.defineProperty(exports, "__esModule", { value: true });
21112 var switchMap_1 = require("./switchMap");
21113 var identity_1 = require("../util/identity");
21114 function switchAll() {
21115 return switchMap_1.switchMap(identity_1.identity);
21117 exports.switchAll = switchAll;
21119 },{"../util/identity":219,"./switchMap":166}],166:[function(require,module,exports){
21121 var __extends = (this && this.__extends) || (function () {
21122 var extendStatics = function (d, b) {
21123 extendStatics = Object.setPrototypeOf ||
21124 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21125 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21126 return extendStatics(d, b);
21128 return function (d, b) {
21129 extendStatics(d, b);
21130 function __() { this.constructor = d; }
21131 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21134 Object.defineProperty(exports, "__esModule", { value: true });
21135 var OuterSubscriber_1 = require("../OuterSubscriber");
21136 var InnerSubscriber_1 = require("../InnerSubscriber");
21137 var subscribeToResult_1 = require("../util/subscribeToResult");
21138 var map_1 = require("./map");
21139 var from_1 = require("../observable/from");
21140 function switchMap(project, resultSelector) {
21141 if (typeof resultSelector === 'function') {
21142 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); })); })); };
21144 return function (source) { return source.lift(new SwitchMapOperator(project)); };
21146 exports.switchMap = switchMap;
21147 var SwitchMapOperator = (function () {
21148 function SwitchMapOperator(project) {
21149 this.project = project;
21151 SwitchMapOperator.prototype.call = function (subscriber, source) {
21152 return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
21154 return SwitchMapOperator;
21156 var SwitchMapSubscriber = (function (_super) {
21157 __extends(SwitchMapSubscriber, _super);
21158 function SwitchMapSubscriber(destination, project) {
21159 var _this = _super.call(this, destination) || this;
21160 _this.project = project;
21164 SwitchMapSubscriber.prototype._next = function (value) {
21166 var index = this.index++;
21168 result = this.project(value, index);
21171 this.destination.error(error);
21174 this._innerSub(result, value, index);
21176 SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
21177 var innerSubscription = this.innerSubscription;
21178 if (innerSubscription) {
21179 innerSubscription.unsubscribe();
21181 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, value, index);
21182 var destination = this.destination;
21183 destination.add(innerSubscriber);
21184 this.innerSubscription = subscribeToResult_1.subscribeToResult(this, result, undefined, undefined, innerSubscriber);
21185 if (this.innerSubscription !== innerSubscriber) {
21186 destination.add(this.innerSubscription);
21189 SwitchMapSubscriber.prototype._complete = function () {
21190 var innerSubscription = this.innerSubscription;
21191 if (!innerSubscription || innerSubscription.closed) {
21192 _super.prototype._complete.call(this);
21194 this.unsubscribe();
21196 SwitchMapSubscriber.prototype._unsubscribe = function () {
21197 this.innerSubscription = null;
21199 SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
21200 var destination = this.destination;
21201 destination.remove(innerSub);
21202 this.innerSubscription = null;
21203 if (this.isStopped) {
21204 _super.prototype._complete.call(this);
21207 SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
21208 this.destination.next(innerValue);
21210 return SwitchMapSubscriber;
21211 }(OuterSubscriber_1.OuterSubscriber));
21213 },{"../InnerSubscriber":46,"../OuterSubscriber":50,"../observable/from":67,"../util/subscribeToResult":239,"./map":125}],167:[function(require,module,exports){
21215 Object.defineProperty(exports, "__esModule", { value: true });
21216 var switchMap_1 = require("./switchMap");
21217 function switchMapTo(innerObservable, resultSelector) {
21218 return resultSelector ? switchMap_1.switchMap(function () { return innerObservable; }, resultSelector) : switchMap_1.switchMap(function () { return innerObservable; });
21220 exports.switchMapTo = switchMapTo;
21222 },{"./switchMap":166}],168:[function(require,module,exports){
21224 var __extends = (this && this.__extends) || (function () {
21225 var extendStatics = function (d, b) {
21226 extendStatics = Object.setPrototypeOf ||
21227 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21228 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21229 return extendStatics(d, b);
21231 return function (d, b) {
21232 extendStatics(d, b);
21233 function __() { this.constructor = d; }
21234 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21237 Object.defineProperty(exports, "__esModule", { value: true });
21238 var Subscriber_1 = require("../Subscriber");
21239 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
21240 var empty_1 = require("../observable/empty");
21241 function take(count) {
21242 return function (source) {
21244 return empty_1.empty();
21247 return source.lift(new TakeOperator(count));
21251 exports.take = take;
21252 var TakeOperator = (function () {
21253 function TakeOperator(total) {
21254 this.total = total;
21255 if (this.total < 0) {
21256 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
21259 TakeOperator.prototype.call = function (subscriber, source) {
21260 return source.subscribe(new TakeSubscriber(subscriber, this.total));
21262 return TakeOperator;
21264 var TakeSubscriber = (function (_super) {
21265 __extends(TakeSubscriber, _super);
21266 function TakeSubscriber(destination, total) {
21267 var _this = _super.call(this, destination) || this;
21268 _this.total = total;
21272 TakeSubscriber.prototype._next = function (value) {
21273 var total = this.total;
21274 var count = ++this.count;
21275 if (count <= total) {
21276 this.destination.next(value);
21277 if (count === total) {
21278 this.destination.complete();
21279 this.unsubscribe();
21283 return TakeSubscriber;
21284 }(Subscriber_1.Subscriber));
21286 },{"../Subscriber":55,"../observable/empty":65,"../util/ArgumentOutOfRangeError":211}],169:[function(require,module,exports){
21288 var __extends = (this && this.__extends) || (function () {
21289 var extendStatics = function (d, b) {
21290 extendStatics = Object.setPrototypeOf ||
21291 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21292 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21293 return extendStatics(d, b);
21295 return function (d, b) {
21296 extendStatics(d, b);
21297 function __() { this.constructor = d; }
21298 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21301 Object.defineProperty(exports, "__esModule", { value: true });
21302 var Subscriber_1 = require("../Subscriber");
21303 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
21304 var empty_1 = require("../observable/empty");
21305 function takeLast(count) {
21306 return function takeLastOperatorFunction(source) {
21308 return empty_1.empty();
21311 return source.lift(new TakeLastOperator(count));
21315 exports.takeLast = takeLast;
21316 var TakeLastOperator = (function () {
21317 function TakeLastOperator(total) {
21318 this.total = total;
21319 if (this.total < 0) {
21320 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
21323 TakeLastOperator.prototype.call = function (subscriber, source) {
21324 return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
21326 return TakeLastOperator;
21328 var TakeLastSubscriber = (function (_super) {
21329 __extends(TakeLastSubscriber, _super);
21330 function TakeLastSubscriber(destination, total) {
21331 var _this = _super.call(this, destination) || this;
21332 _this.total = total;
21333 _this.ring = new Array();
21337 TakeLastSubscriber.prototype._next = function (value) {
21338 var ring = this.ring;
21339 var total = this.total;
21340 var count = this.count++;
21341 if (ring.length < total) {
21345 var index = count % total;
21346 ring[index] = value;
21349 TakeLastSubscriber.prototype._complete = function () {
21350 var destination = this.destination;
21351 var count = this.count;
21353 var total = this.count >= this.total ? this.total : this.count;
21354 var ring = this.ring;
21355 for (var i = 0; i < total; i++) {
21356 var idx = (count++) % total;
21357 destination.next(ring[idx]);
21360 destination.complete();
21362 return TakeLastSubscriber;
21363 }(Subscriber_1.Subscriber));
21365 },{"../Subscriber":55,"../observable/empty":65,"../util/ArgumentOutOfRangeError":211}],170:[function(require,module,exports){
21367 var __extends = (this && this.__extends) || (function () {
21368 var extendStatics = function (d, b) {
21369 extendStatics = Object.setPrototypeOf ||
21370 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21371 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21372 return extendStatics(d, b);
21374 return function (d, b) {
21375 extendStatics(d, b);
21376 function __() { this.constructor = d; }
21377 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21380 Object.defineProperty(exports, "__esModule", { value: true });
21381 var OuterSubscriber_1 = require("../OuterSubscriber");
21382 var subscribeToResult_1 = require("../util/subscribeToResult");
21383 function takeUntil(notifier) {
21384 return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
21386 exports.takeUntil = takeUntil;
21387 var TakeUntilOperator = (function () {
21388 function TakeUntilOperator(notifier) {
21389 this.notifier = notifier;
21391 TakeUntilOperator.prototype.call = function (subscriber, source) {
21392 var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
21393 var notifierSubscription = subscribeToResult_1.subscribeToResult(takeUntilSubscriber, this.notifier);
21394 if (notifierSubscription && !takeUntilSubscriber.seenValue) {
21395 takeUntilSubscriber.add(notifierSubscription);
21396 return source.subscribe(takeUntilSubscriber);
21398 return takeUntilSubscriber;
21400 return TakeUntilOperator;
21402 var TakeUntilSubscriber = (function (_super) {
21403 __extends(TakeUntilSubscriber, _super);
21404 function TakeUntilSubscriber(destination) {
21405 var _this = _super.call(this, destination) || this;
21406 _this.seenValue = false;
21409 TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
21410 this.seenValue = true;
21413 TakeUntilSubscriber.prototype.notifyComplete = function () {
21415 return TakeUntilSubscriber;
21416 }(OuterSubscriber_1.OuterSubscriber));
21418 },{"../OuterSubscriber":50,"../util/subscribeToResult":239}],171:[function(require,module,exports){
21420 var __extends = (this && this.__extends) || (function () {
21421 var extendStatics = function (d, b) {
21422 extendStatics = Object.setPrototypeOf ||
21423 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21424 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21425 return extendStatics(d, b);
21427 return function (d, b) {
21428 extendStatics(d, b);
21429 function __() { this.constructor = d; }
21430 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21433 Object.defineProperty(exports, "__esModule", { value: true });
21434 var Subscriber_1 = require("../Subscriber");
21435 function takeWhile(predicate, inclusive) {
21436 if (inclusive === void 0) { inclusive = false; }
21437 return function (source) {
21438 return source.lift(new TakeWhileOperator(predicate, inclusive));
21441 exports.takeWhile = takeWhile;
21442 var TakeWhileOperator = (function () {
21443 function TakeWhileOperator(predicate, inclusive) {
21444 this.predicate = predicate;
21445 this.inclusive = inclusive;
21447 TakeWhileOperator.prototype.call = function (subscriber, source) {
21448 return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate, this.inclusive));
21450 return TakeWhileOperator;
21452 var TakeWhileSubscriber = (function (_super) {
21453 __extends(TakeWhileSubscriber, _super);
21454 function TakeWhileSubscriber(destination, predicate, inclusive) {
21455 var _this = _super.call(this, destination) || this;
21456 _this.predicate = predicate;
21457 _this.inclusive = inclusive;
21461 TakeWhileSubscriber.prototype._next = function (value) {
21462 var destination = this.destination;
21465 result = this.predicate(value, this.index++);
21468 destination.error(err);
21471 this.nextOrComplete(value, result);
21473 TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
21474 var destination = this.destination;
21475 if (Boolean(predicateResult)) {
21476 destination.next(value);
21479 if (this.inclusive) {
21480 destination.next(value);
21482 destination.complete();
21485 return TakeWhileSubscriber;
21486 }(Subscriber_1.Subscriber));
21488 },{"../Subscriber":55}],172:[function(require,module,exports){
21490 var __extends = (this && this.__extends) || (function () {
21491 var extendStatics = function (d, b) {
21492 extendStatics = Object.setPrototypeOf ||
21493 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21494 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21495 return extendStatics(d, b);
21497 return function (d, b) {
21498 extendStatics(d, b);
21499 function __() { this.constructor = d; }
21500 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21503 Object.defineProperty(exports, "__esModule", { value: true });
21504 var Subscriber_1 = require("../Subscriber");
21505 var noop_1 = require("../util/noop");
21506 var isFunction_1 = require("../util/isFunction");
21507 function tap(nextOrObserver, error, complete) {
21508 return function tapOperatorFunction(source) {
21509 return source.lift(new DoOperator(nextOrObserver, error, complete));
21513 var DoOperator = (function () {
21514 function DoOperator(nextOrObserver, error, complete) {
21515 this.nextOrObserver = nextOrObserver;
21516 this.error = error;
21517 this.complete = complete;
21519 DoOperator.prototype.call = function (subscriber, source) {
21520 return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
21524 var TapSubscriber = (function (_super) {
21525 __extends(TapSubscriber, _super);
21526 function TapSubscriber(destination, observerOrNext, error, complete) {
21527 var _this = _super.call(this, destination) || this;
21528 _this._tapNext = noop_1.noop;
21529 _this._tapError = noop_1.noop;
21530 _this._tapComplete = noop_1.noop;
21531 _this._tapError = error || noop_1.noop;
21532 _this._tapComplete = complete || noop_1.noop;
21533 if (isFunction_1.isFunction(observerOrNext)) {
21534 _this._context = _this;
21535 _this._tapNext = observerOrNext;
21537 else if (observerOrNext) {
21538 _this._context = observerOrNext;
21539 _this._tapNext = observerOrNext.next || noop_1.noop;
21540 _this._tapError = observerOrNext.error || noop_1.noop;
21541 _this._tapComplete = observerOrNext.complete || noop_1.noop;
21545 TapSubscriber.prototype._next = function (value) {
21547 this._tapNext.call(this._context, value);
21550 this.destination.error(err);
21553 this.destination.next(value);
21555 TapSubscriber.prototype._error = function (err) {
21557 this._tapError.call(this._context, err);
21560 this.destination.error(err);
21563 this.destination.error(err);
21565 TapSubscriber.prototype._complete = function () {
21567 this._tapComplete.call(this._context);
21570 this.destination.error(err);
21573 return this.destination.complete();
21575 return TapSubscriber;
21576 }(Subscriber_1.Subscriber));
21578 },{"../Subscriber":55,"../util/isFunction":223,"../util/noop":231}],173:[function(require,module,exports){
21580 var __extends = (this && this.__extends) || (function () {
21581 var extendStatics = function (d, b) {
21582 extendStatics = Object.setPrototypeOf ||
21583 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21584 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21585 return extendStatics(d, b);
21587 return function (d, b) {
21588 extendStatics(d, b);
21589 function __() { this.constructor = d; }
21590 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21593 Object.defineProperty(exports, "__esModule", { value: true });
21594 var OuterSubscriber_1 = require("../OuterSubscriber");
21595 var subscribeToResult_1 = require("../util/subscribeToResult");
21596 exports.defaultThrottleConfig = {
21600 function throttle(durationSelector, config) {
21601 if (config === void 0) { config = exports.defaultThrottleConfig; }
21602 return function (source) { return source.lift(new ThrottleOperator(durationSelector, config.leading, config.trailing)); };
21604 exports.throttle = throttle;
21605 var ThrottleOperator = (function () {
21606 function ThrottleOperator(durationSelector, leading, trailing) {
21607 this.durationSelector = durationSelector;
21608 this.leading = leading;
21609 this.trailing = trailing;
21611 ThrottleOperator.prototype.call = function (subscriber, source) {
21612 return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
21614 return ThrottleOperator;
21616 var ThrottleSubscriber = (function (_super) {
21617 __extends(ThrottleSubscriber, _super);
21618 function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
21619 var _this = _super.call(this, destination) || this;
21620 _this.destination = destination;
21621 _this.durationSelector = durationSelector;
21622 _this._leading = _leading;
21623 _this._trailing = _trailing;
21624 _this._hasValue = false;
21627 ThrottleSubscriber.prototype._next = function (value) {
21628 this._hasValue = true;
21629 this._sendValue = value;
21630 if (!this._throttled) {
21631 if (this._leading) {
21635 this.throttle(value);
21639 ThrottleSubscriber.prototype.send = function () {
21640 var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
21642 this.destination.next(_sendValue);
21643 this.throttle(_sendValue);
21645 this._hasValue = false;
21646 this._sendValue = null;
21648 ThrottleSubscriber.prototype.throttle = function (value) {
21649 var duration = this.tryDurationSelector(value);
21651 this.add(this._throttled = subscribeToResult_1.subscribeToResult(this, duration));
21654 ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
21656 return this.durationSelector(value);
21659 this.destination.error(err);
21663 ThrottleSubscriber.prototype.throttlingDone = function () {
21664 var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
21666 _throttled.unsubscribe();
21668 this._throttled = null;
21673 ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
21674 this.throttlingDone();
21676 ThrottleSubscriber.prototype.notifyComplete = function () {
21677 this.throttlingDone();
21679 return ThrottleSubscriber;
21680 }(OuterSubscriber_1.OuterSubscriber));
21682 },{"../OuterSubscriber":50,"../util/subscribeToResult":239}],174:[function(require,module,exports){
21684 var __extends = (this && this.__extends) || (function () {
21685 var extendStatics = function (d, b) {
21686 extendStatics = Object.setPrototypeOf ||
21687 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21688 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21689 return extendStatics(d, b);
21691 return function (d, b) {
21692 extendStatics(d, b);
21693 function __() { this.constructor = d; }
21694 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21697 Object.defineProperty(exports, "__esModule", { value: true });
21698 var Subscriber_1 = require("../Subscriber");
21699 var async_1 = require("../scheduler/async");
21700 var throttle_1 = require("./throttle");
21701 function throttleTime(duration, scheduler, config) {
21702 if (scheduler === void 0) { scheduler = async_1.async; }
21703 if (config === void 0) { config = throttle_1.defaultThrottleConfig; }
21704 return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
21706 exports.throttleTime = throttleTime;
21707 var ThrottleTimeOperator = (function () {
21708 function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
21709 this.duration = duration;
21710 this.scheduler = scheduler;
21711 this.leading = leading;
21712 this.trailing = trailing;
21714 ThrottleTimeOperator.prototype.call = function (subscriber, source) {
21715 return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
21717 return ThrottleTimeOperator;
21719 var ThrottleTimeSubscriber = (function (_super) {
21720 __extends(ThrottleTimeSubscriber, _super);
21721 function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
21722 var _this = _super.call(this, destination) || this;
21723 _this.duration = duration;
21724 _this.scheduler = scheduler;
21725 _this.leading = leading;
21726 _this.trailing = trailing;
21727 _this._hasTrailingValue = false;
21728 _this._trailingValue = null;
21731 ThrottleTimeSubscriber.prototype._next = function (value) {
21732 if (this.throttled) {
21733 if (this.trailing) {
21734 this._trailingValue = value;
21735 this._hasTrailingValue = true;
21739 this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, { subscriber: this }));
21740 if (this.leading) {
21741 this.destination.next(value);
21743 else if (this.trailing) {
21744 this._trailingValue = value;
21745 this._hasTrailingValue = true;
21749 ThrottleTimeSubscriber.prototype._complete = function () {
21750 if (this._hasTrailingValue) {
21751 this.destination.next(this._trailingValue);
21752 this.destination.complete();
21755 this.destination.complete();
21758 ThrottleTimeSubscriber.prototype.clearThrottle = function () {
21759 var throttled = this.throttled;
21761 if (this.trailing && this._hasTrailingValue) {
21762 this.destination.next(this._trailingValue);
21763 this._trailingValue = null;
21764 this._hasTrailingValue = false;
21766 throttled.unsubscribe();
21767 this.remove(throttled);
21768 this.throttled = null;
21771 return ThrottleTimeSubscriber;
21772 }(Subscriber_1.Subscriber));
21773 function dispatchNext(arg) {
21774 var subscriber = arg.subscriber;
21775 subscriber.clearThrottle();
21778 },{"../Subscriber":55,"../scheduler/async":206,"./throttle":173}],175:[function(require,module,exports){
21780 var __extends = (this && this.__extends) || (function () {
21781 var extendStatics = function (d, b) {
21782 extendStatics = Object.setPrototypeOf ||
21783 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21784 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21785 return extendStatics(d, b);
21787 return function (d, b) {
21788 extendStatics(d, b);
21789 function __() { this.constructor = d; }
21790 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21793 Object.defineProperty(exports, "__esModule", { value: true });
21794 var EmptyError_1 = require("../util/EmptyError");
21795 var Subscriber_1 = require("../Subscriber");
21796 function throwIfEmpty(errorFactory) {
21797 if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
21798 return function (source) {
21799 return source.lift(new ThrowIfEmptyOperator(errorFactory));
21802 exports.throwIfEmpty = throwIfEmpty;
21803 var ThrowIfEmptyOperator = (function () {
21804 function ThrowIfEmptyOperator(errorFactory) {
21805 this.errorFactory = errorFactory;
21807 ThrowIfEmptyOperator.prototype.call = function (subscriber, source) {
21808 return source.subscribe(new ThrowIfEmptySubscriber(subscriber, this.errorFactory));
21810 return ThrowIfEmptyOperator;
21812 var ThrowIfEmptySubscriber = (function (_super) {
21813 __extends(ThrowIfEmptySubscriber, _super);
21814 function ThrowIfEmptySubscriber(destination, errorFactory) {
21815 var _this = _super.call(this, destination) || this;
21816 _this.errorFactory = errorFactory;
21817 _this.hasValue = false;
21820 ThrowIfEmptySubscriber.prototype._next = function (value) {
21821 this.hasValue = true;
21822 this.destination.next(value);
21824 ThrowIfEmptySubscriber.prototype._complete = function () {
21825 if (!this.hasValue) {
21828 err = this.errorFactory();
21833 this.destination.error(err);
21836 return this.destination.complete();
21839 return ThrowIfEmptySubscriber;
21840 }(Subscriber_1.Subscriber));
21841 function defaultErrorFactory() {
21842 return new EmptyError_1.EmptyError();
21845 },{"../Subscriber":55,"../util/EmptyError":212}],176:[function(require,module,exports){
21847 Object.defineProperty(exports, "__esModule", { value: true });
21848 var async_1 = require("../scheduler/async");
21849 var scan_1 = require("./scan");
21850 var defer_1 = require("../observable/defer");
21851 var map_1 = require("./map");
21852 function timeInterval(scheduler) {
21853 if (scheduler === void 0) { scheduler = async_1.async; }
21854 return function (source) { return defer_1.defer(function () {
21855 return source.pipe(scan_1.scan(function (_a, value) {
21856 var current = _a.current;
21857 return ({ value: value, current: scheduler.now(), last: current });
21858 }, { current: scheduler.now(), value: undefined, last: undefined }), map_1.map(function (_a) {
21859 var current = _a.current, last = _a.last, value = _a.value;
21860 return new TimeInterval(value, current - last);
21864 exports.timeInterval = timeInterval;
21865 var TimeInterval = (function () {
21866 function TimeInterval(value, interval) {
21867 this.value = value;
21868 this.interval = interval;
21870 return TimeInterval;
21872 exports.TimeInterval = TimeInterval;
21874 },{"../observable/defer":64,"../scheduler/async":206,"./map":125,"./scan":154}],177:[function(require,module,exports){
21876 Object.defineProperty(exports, "__esModule", { value: true });
21877 var async_1 = require("../scheduler/async");
21878 var TimeoutError_1 = require("../util/TimeoutError");
21879 var timeoutWith_1 = require("./timeoutWith");
21880 var throwError_1 = require("../observable/throwError");
21881 function timeout(due, scheduler) {
21882 if (scheduler === void 0) { scheduler = async_1.async; }
21883 return timeoutWith_1.timeoutWith(due, throwError_1.throwError(new TimeoutError_1.TimeoutError()), scheduler);
21885 exports.timeout = timeout;
21887 },{"../observable/throwError":82,"../scheduler/async":206,"../util/TimeoutError":215,"./timeoutWith":178}],178:[function(require,module,exports){
21889 var __extends = (this && this.__extends) || (function () {
21890 var extendStatics = function (d, b) {
21891 extendStatics = Object.setPrototypeOf ||
21892 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21893 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21894 return extendStatics(d, b);
21896 return function (d, b) {
21897 extendStatics(d, b);
21898 function __() { this.constructor = d; }
21899 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21902 Object.defineProperty(exports, "__esModule", { value: true });
21903 var async_1 = require("../scheduler/async");
21904 var isDate_1 = require("../util/isDate");
21905 var OuterSubscriber_1 = require("../OuterSubscriber");
21906 var subscribeToResult_1 = require("../util/subscribeToResult");
21907 function timeoutWith(due, withObservable, scheduler) {
21908 if (scheduler === void 0) { scheduler = async_1.async; }
21909 return function (source) {
21910 var absoluteTimeout = isDate_1.isDate(due);
21911 var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
21912 return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
21915 exports.timeoutWith = timeoutWith;
21916 var TimeoutWithOperator = (function () {
21917 function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
21918 this.waitFor = waitFor;
21919 this.absoluteTimeout = absoluteTimeout;
21920 this.withObservable = withObservable;
21921 this.scheduler = scheduler;
21923 TimeoutWithOperator.prototype.call = function (subscriber, source) {
21924 return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
21926 return TimeoutWithOperator;
21928 var TimeoutWithSubscriber = (function (_super) {
21929 __extends(TimeoutWithSubscriber, _super);
21930 function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
21931 var _this = _super.call(this, destination) || this;
21932 _this.absoluteTimeout = absoluteTimeout;
21933 _this.waitFor = waitFor;
21934 _this.withObservable = withObservable;
21935 _this.scheduler = scheduler;
21936 _this.action = null;
21937 _this.scheduleTimeout();
21940 TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
21941 var withObservable = subscriber.withObservable;
21942 subscriber._unsubscribeAndRecycle();
21943 subscriber.add(subscribeToResult_1.subscribeToResult(subscriber, withObservable));
21945 TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
21946 var action = this.action;
21948 this.action = action.schedule(this, this.waitFor);
21951 this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
21954 TimeoutWithSubscriber.prototype._next = function (value) {
21955 if (!this.absoluteTimeout) {
21956 this.scheduleTimeout();
21958 _super.prototype._next.call(this, value);
21960 TimeoutWithSubscriber.prototype._unsubscribe = function () {
21961 this.action = null;
21962 this.scheduler = null;
21963 this.withObservable = null;
21965 return TimeoutWithSubscriber;
21966 }(OuterSubscriber_1.OuterSubscriber));
21968 },{"../OuterSubscriber":50,"../scheduler/async":206,"../util/isDate":222,"../util/subscribeToResult":239}],179:[function(require,module,exports){
21970 Object.defineProperty(exports, "__esModule", { value: true });
21971 var async_1 = require("../scheduler/async");
21972 var map_1 = require("./map");
21973 function timestamp(scheduler) {
21974 if (scheduler === void 0) { scheduler = async_1.async; }
21975 return map_1.map(function (value) { return new Timestamp(value, scheduler.now()); });
21977 exports.timestamp = timestamp;
21978 var Timestamp = (function () {
21979 function Timestamp(value, timestamp) {
21980 this.value = value;
21981 this.timestamp = timestamp;
21985 exports.Timestamp = Timestamp;
21987 },{"../scheduler/async":206,"./map":125}],180:[function(require,module,exports){
21989 Object.defineProperty(exports, "__esModule", { value: true });
21990 var reduce_1 = require("./reduce");
21991 function toArrayReducer(arr, item, index) {
21998 function toArray() {
21999 return reduce_1.reduce(toArrayReducer, []);
22001 exports.toArray = toArray;
22003 },{"./reduce":146}],181:[function(require,module,exports){
22005 var __extends = (this && this.__extends) || (function () {
22006 var extendStatics = function (d, b) {
22007 extendStatics = Object.setPrototypeOf ||
22008 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22009 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22010 return extendStatics(d, b);
22012 return function (d, b) {
22013 extendStatics(d, b);
22014 function __() { this.constructor = d; }
22015 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22018 Object.defineProperty(exports, "__esModule", { value: true });
22019 var Subject_1 = require("../Subject");
22020 var OuterSubscriber_1 = require("../OuterSubscriber");
22021 var subscribeToResult_1 = require("../util/subscribeToResult");
22022 function window(windowBoundaries) {
22023 return function windowOperatorFunction(source) {
22024 return source.lift(new WindowOperator(windowBoundaries));
22027 exports.window = window;
22028 var WindowOperator = (function () {
22029 function WindowOperator(windowBoundaries) {
22030 this.windowBoundaries = windowBoundaries;
22032 WindowOperator.prototype.call = function (subscriber, source) {
22033 var windowSubscriber = new WindowSubscriber(subscriber);
22034 var sourceSubscription = source.subscribe(windowSubscriber);
22035 if (!sourceSubscription.closed) {
22036 windowSubscriber.add(subscribeToResult_1.subscribeToResult(windowSubscriber, this.windowBoundaries));
22038 return sourceSubscription;
22040 return WindowOperator;
22042 var WindowSubscriber = (function (_super) {
22043 __extends(WindowSubscriber, _super);
22044 function WindowSubscriber(destination) {
22045 var _this = _super.call(this, destination) || this;
22046 _this.window = new Subject_1.Subject();
22047 destination.next(_this.window);
22050 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
22053 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
22054 this._error(error);
22056 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
22059 WindowSubscriber.prototype._next = function (value) {
22060 this.window.next(value);
22062 WindowSubscriber.prototype._error = function (err) {
22063 this.window.error(err);
22064 this.destination.error(err);
22066 WindowSubscriber.prototype._complete = function () {
22067 this.window.complete();
22068 this.destination.complete();
22070 WindowSubscriber.prototype._unsubscribe = function () {
22071 this.window = null;
22073 WindowSubscriber.prototype.openWindow = function () {
22074 var prevWindow = this.window;
22076 prevWindow.complete();
22078 var destination = this.destination;
22079 var newWindow = this.window = new Subject_1.Subject();
22080 destination.next(newWindow);
22082 return WindowSubscriber;
22083 }(OuterSubscriber_1.OuterSubscriber));
22085 },{"../OuterSubscriber":50,"../Subject":53,"../util/subscribeToResult":239}],182:[function(require,module,exports){
22087 var __extends = (this && this.__extends) || (function () {
22088 var extendStatics = function (d, b) {
22089 extendStatics = Object.setPrototypeOf ||
22090 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22091 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22092 return extendStatics(d, b);
22094 return function (d, b) {
22095 extendStatics(d, b);
22096 function __() { this.constructor = d; }
22097 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22100 Object.defineProperty(exports, "__esModule", { value: true });
22101 var Subscriber_1 = require("../Subscriber");
22102 var Subject_1 = require("../Subject");
22103 function windowCount(windowSize, startWindowEvery) {
22104 if (startWindowEvery === void 0) { startWindowEvery = 0; }
22105 return function windowCountOperatorFunction(source) {
22106 return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
22109 exports.windowCount = windowCount;
22110 var WindowCountOperator = (function () {
22111 function WindowCountOperator(windowSize, startWindowEvery) {
22112 this.windowSize = windowSize;
22113 this.startWindowEvery = startWindowEvery;
22115 WindowCountOperator.prototype.call = function (subscriber, source) {
22116 return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
22118 return WindowCountOperator;
22120 var WindowCountSubscriber = (function (_super) {
22121 __extends(WindowCountSubscriber, _super);
22122 function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
22123 var _this = _super.call(this, destination) || this;
22124 _this.destination = destination;
22125 _this.windowSize = windowSize;
22126 _this.startWindowEvery = startWindowEvery;
22127 _this.windows = [new Subject_1.Subject()];
22129 destination.next(_this.windows[0]);
22132 WindowCountSubscriber.prototype._next = function (value) {
22133 var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
22134 var destination = this.destination;
22135 var windowSize = this.windowSize;
22136 var windows = this.windows;
22137 var len = windows.length;
22138 for (var i = 0; i < len && !this.closed; i++) {
22139 windows[i].next(value);
22141 var c = this.count - windowSize + 1;
22142 if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
22143 windows.shift().complete();
22145 if (++this.count % startWindowEvery === 0 && !this.closed) {
22146 var window_1 = new Subject_1.Subject();
22147 windows.push(window_1);
22148 destination.next(window_1);
22151 WindowCountSubscriber.prototype._error = function (err) {
22152 var windows = this.windows;
22154 while (windows.length > 0 && !this.closed) {
22155 windows.shift().error(err);
22158 this.destination.error(err);
22160 WindowCountSubscriber.prototype._complete = function () {
22161 var windows = this.windows;
22163 while (windows.length > 0 && !this.closed) {
22164 windows.shift().complete();
22167 this.destination.complete();
22169 WindowCountSubscriber.prototype._unsubscribe = function () {
22171 this.windows = null;
22173 return WindowCountSubscriber;
22174 }(Subscriber_1.Subscriber));
22176 },{"../Subject":53,"../Subscriber":55}],183:[function(require,module,exports){
22178 var __extends = (this && this.__extends) || (function () {
22179 var extendStatics = function (d, b) {
22180 extendStatics = Object.setPrototypeOf ||
22181 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22182 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22183 return extendStatics(d, b);
22185 return function (d, b) {
22186 extendStatics(d, b);
22187 function __() { this.constructor = d; }
22188 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22191 Object.defineProperty(exports, "__esModule", { value: true });
22192 var Subject_1 = require("../Subject");
22193 var async_1 = require("../scheduler/async");
22194 var Subscriber_1 = require("../Subscriber");
22195 var isNumeric_1 = require("../util/isNumeric");
22196 var isScheduler_1 = require("../util/isScheduler");
22197 function windowTime(windowTimeSpan) {
22198 var scheduler = async_1.async;
22199 var windowCreationInterval = null;
22200 var maxWindowSize = Number.POSITIVE_INFINITY;
22201 if (isScheduler_1.isScheduler(arguments[3])) {
22202 scheduler = arguments[3];
22204 if (isScheduler_1.isScheduler(arguments[2])) {
22205 scheduler = arguments[2];
22207 else if (isNumeric_1.isNumeric(arguments[2])) {
22208 maxWindowSize = arguments[2];
22210 if (isScheduler_1.isScheduler(arguments[1])) {
22211 scheduler = arguments[1];
22213 else if (isNumeric_1.isNumeric(arguments[1])) {
22214 windowCreationInterval = arguments[1];
22216 return function windowTimeOperatorFunction(source) {
22217 return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
22220 exports.windowTime = windowTime;
22221 var WindowTimeOperator = (function () {
22222 function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
22223 this.windowTimeSpan = windowTimeSpan;
22224 this.windowCreationInterval = windowCreationInterval;
22225 this.maxWindowSize = maxWindowSize;
22226 this.scheduler = scheduler;
22228 WindowTimeOperator.prototype.call = function (subscriber, source) {
22229 return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
22231 return WindowTimeOperator;
22233 var CountedSubject = (function (_super) {
22234 __extends(CountedSubject, _super);
22235 function CountedSubject() {
22236 var _this = _super !== null && _super.apply(this, arguments) || this;
22237 _this._numberOfNextedValues = 0;
22240 CountedSubject.prototype.next = function (value) {
22241 this._numberOfNextedValues++;
22242 _super.prototype.next.call(this, value);
22244 Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
22246 return this._numberOfNextedValues;
22251 return CountedSubject;
22252 }(Subject_1.Subject));
22253 var WindowTimeSubscriber = (function (_super) {
22254 __extends(WindowTimeSubscriber, _super);
22255 function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
22256 var _this = _super.call(this, destination) || this;
22257 _this.destination = destination;
22258 _this.windowTimeSpan = windowTimeSpan;
22259 _this.windowCreationInterval = windowCreationInterval;
22260 _this.maxWindowSize = maxWindowSize;
22261 _this.scheduler = scheduler;
22262 _this.windows = [];
22263 var window = _this.openWindow();
22264 if (windowCreationInterval !== null && windowCreationInterval >= 0) {
22265 var closeState = { subscriber: _this, window: window, context: null };
22266 var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
22267 _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
22268 _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
22271 var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
22272 _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
22276 WindowTimeSubscriber.prototype._next = function (value) {
22277 var windows = this.windows;
22278 var len = windows.length;
22279 for (var i = 0; i < len; i++) {
22280 var window_1 = windows[i];
22281 if (!window_1.closed) {
22282 window_1.next(value);
22283 if (window_1.numberOfNextedValues >= this.maxWindowSize) {
22284 this.closeWindow(window_1);
22289 WindowTimeSubscriber.prototype._error = function (err) {
22290 var windows = this.windows;
22291 while (windows.length > 0) {
22292 windows.shift().error(err);
22294 this.destination.error(err);
22296 WindowTimeSubscriber.prototype._complete = function () {
22297 var windows = this.windows;
22298 while (windows.length > 0) {
22299 var window_2 = windows.shift();
22300 if (!window_2.closed) {
22301 window_2.complete();
22304 this.destination.complete();
22306 WindowTimeSubscriber.prototype.openWindow = function () {
22307 var window = new CountedSubject();
22308 this.windows.push(window);
22309 var destination = this.destination;
22310 destination.next(window);
22313 WindowTimeSubscriber.prototype.closeWindow = function (window) {
22315 var windows = this.windows;
22316 windows.splice(windows.indexOf(window), 1);
22318 return WindowTimeSubscriber;
22319 }(Subscriber_1.Subscriber));
22320 function dispatchWindowTimeSpanOnly(state) {
22321 var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
22323 subscriber.closeWindow(window);
22325 state.window = subscriber.openWindow();
22326 this.schedule(state, windowTimeSpan);
22328 function dispatchWindowCreation(state) {
22329 var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
22330 var window = subscriber.openWindow();
22332 var context = { action: action, subscription: null };
22333 var timeSpanState = { subscriber: subscriber, window: window, context: context };
22334 context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
22335 action.add(context.subscription);
22336 action.schedule(state, windowCreationInterval);
22338 function dispatchWindowClose(state) {
22339 var subscriber = state.subscriber, window = state.window, context = state.context;
22340 if (context && context.action && context.subscription) {
22341 context.action.remove(context.subscription);
22343 subscriber.closeWindow(window);
22346 },{"../Subject":53,"../Subscriber":55,"../scheduler/async":206,"../util/isNumeric":226,"../util/isScheduler":230}],184:[function(require,module,exports){
22348 var __extends = (this && this.__extends) || (function () {
22349 var extendStatics = function (d, b) {
22350 extendStatics = Object.setPrototypeOf ||
22351 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22352 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22353 return extendStatics(d, b);
22355 return function (d, b) {
22356 extendStatics(d, b);
22357 function __() { this.constructor = d; }
22358 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22361 Object.defineProperty(exports, "__esModule", { value: true });
22362 var Subject_1 = require("../Subject");
22363 var Subscription_1 = require("../Subscription");
22364 var OuterSubscriber_1 = require("../OuterSubscriber");
22365 var subscribeToResult_1 = require("../util/subscribeToResult");
22366 function windowToggle(openings, closingSelector) {
22367 return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
22369 exports.windowToggle = windowToggle;
22370 var WindowToggleOperator = (function () {
22371 function WindowToggleOperator(openings, closingSelector) {
22372 this.openings = openings;
22373 this.closingSelector = closingSelector;
22375 WindowToggleOperator.prototype.call = function (subscriber, source) {
22376 return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
22378 return WindowToggleOperator;
22380 var WindowToggleSubscriber = (function (_super) {
22381 __extends(WindowToggleSubscriber, _super);
22382 function WindowToggleSubscriber(destination, openings, closingSelector) {
22383 var _this = _super.call(this, destination) || this;
22384 _this.openings = openings;
22385 _this.closingSelector = closingSelector;
22386 _this.contexts = [];
22387 _this.add(_this.openSubscription = subscribeToResult_1.subscribeToResult(_this, openings, openings));
22390 WindowToggleSubscriber.prototype._next = function (value) {
22391 var contexts = this.contexts;
22393 var len = contexts.length;
22394 for (var i = 0; i < len; i++) {
22395 contexts[i].window.next(value);
22399 WindowToggleSubscriber.prototype._error = function (err) {
22400 var contexts = this.contexts;
22401 this.contexts = null;
22403 var len = contexts.length;
22405 while (++index < len) {
22406 var context_1 = contexts[index];
22407 context_1.window.error(err);
22408 context_1.subscription.unsubscribe();
22411 _super.prototype._error.call(this, err);
22413 WindowToggleSubscriber.prototype._complete = function () {
22414 var contexts = this.contexts;
22415 this.contexts = null;
22417 var len = contexts.length;
22419 while (++index < len) {
22420 var context_2 = contexts[index];
22421 context_2.window.complete();
22422 context_2.subscription.unsubscribe();
22425 _super.prototype._complete.call(this);
22427 WindowToggleSubscriber.prototype._unsubscribe = function () {
22428 var contexts = this.contexts;
22429 this.contexts = null;
22431 var len = contexts.length;
22433 while (++index < len) {
22434 var context_3 = contexts[index];
22435 context_3.window.unsubscribe();
22436 context_3.subscription.unsubscribe();
22440 WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
22441 if (outerValue === this.openings) {
22442 var closingNotifier = void 0;
22444 var closingSelector = this.closingSelector;
22445 closingNotifier = closingSelector(innerValue);
22448 return this.error(e);
22450 var window_1 = new Subject_1.Subject();
22451 var subscription = new Subscription_1.Subscription();
22452 var context_4 = { window: window_1, subscription: subscription };
22453 this.contexts.push(context_4);
22454 var innerSubscription = subscribeToResult_1.subscribeToResult(this, closingNotifier, context_4);
22455 if (innerSubscription.closed) {
22456 this.closeWindow(this.contexts.length - 1);
22459 innerSubscription.context = context_4;
22460 subscription.add(innerSubscription);
22462 this.destination.next(window_1);
22465 this.closeWindow(this.contexts.indexOf(outerValue));
22468 WindowToggleSubscriber.prototype.notifyError = function (err) {
22471 WindowToggleSubscriber.prototype.notifyComplete = function (inner) {
22472 if (inner !== this.openSubscription) {
22473 this.closeWindow(this.contexts.indexOf(inner.context));
22476 WindowToggleSubscriber.prototype.closeWindow = function (index) {
22477 if (index === -1) {
22480 var contexts = this.contexts;
22481 var context = contexts[index];
22482 var window = context.window, subscription = context.subscription;
22483 contexts.splice(index, 1);
22485 subscription.unsubscribe();
22487 return WindowToggleSubscriber;
22488 }(OuterSubscriber_1.OuterSubscriber));
22490 },{"../OuterSubscriber":50,"../Subject":53,"../Subscription":56,"../util/subscribeToResult":239}],185:[function(require,module,exports){
22492 var __extends = (this && this.__extends) || (function () {
22493 var extendStatics = function (d, b) {
22494 extendStatics = Object.setPrototypeOf ||
22495 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22496 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22497 return extendStatics(d, b);
22499 return function (d, b) {
22500 extendStatics(d, b);
22501 function __() { this.constructor = d; }
22502 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22505 Object.defineProperty(exports, "__esModule", { value: true });
22506 var Subject_1 = require("../Subject");
22507 var OuterSubscriber_1 = require("../OuterSubscriber");
22508 var subscribeToResult_1 = require("../util/subscribeToResult");
22509 function windowWhen(closingSelector) {
22510 return function windowWhenOperatorFunction(source) {
22511 return source.lift(new WindowOperator(closingSelector));
22514 exports.windowWhen = windowWhen;
22515 var WindowOperator = (function () {
22516 function WindowOperator(closingSelector) {
22517 this.closingSelector = closingSelector;
22519 WindowOperator.prototype.call = function (subscriber, source) {
22520 return source.subscribe(new WindowSubscriber(subscriber, this.closingSelector));
22522 return WindowOperator;
22524 var WindowSubscriber = (function (_super) {
22525 __extends(WindowSubscriber, _super);
22526 function WindowSubscriber(destination, closingSelector) {
22527 var _this = _super.call(this, destination) || this;
22528 _this.destination = destination;
22529 _this.closingSelector = closingSelector;
22530 _this.openWindow();
22533 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
22534 this.openWindow(innerSub);
22536 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
22537 this._error(error);
22539 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
22540 this.openWindow(innerSub);
22542 WindowSubscriber.prototype._next = function (value) {
22543 this.window.next(value);
22545 WindowSubscriber.prototype._error = function (err) {
22546 this.window.error(err);
22547 this.destination.error(err);
22548 this.unsubscribeClosingNotification();
22550 WindowSubscriber.prototype._complete = function () {
22551 this.window.complete();
22552 this.destination.complete();
22553 this.unsubscribeClosingNotification();
22555 WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
22556 if (this.closingNotification) {
22557 this.closingNotification.unsubscribe();
22560 WindowSubscriber.prototype.openWindow = function (innerSub) {
22561 if (innerSub === void 0) { innerSub = null; }
22563 this.remove(innerSub);
22564 innerSub.unsubscribe();
22566 var prevWindow = this.window;
22568 prevWindow.complete();
22570 var window = this.window = new Subject_1.Subject();
22571 this.destination.next(window);
22572 var closingNotifier;
22574 var closingSelector = this.closingSelector;
22575 closingNotifier = closingSelector();
22578 this.destination.error(e);
22579 this.window.error(e);
22582 this.add(this.closingNotification = subscribeToResult_1.subscribeToResult(this, closingNotifier));
22584 return WindowSubscriber;
22585 }(OuterSubscriber_1.OuterSubscriber));
22587 },{"../OuterSubscriber":50,"../Subject":53,"../util/subscribeToResult":239}],186:[function(require,module,exports){
22589 var __extends = (this && this.__extends) || (function () {
22590 var extendStatics = function (d, b) {
22591 extendStatics = Object.setPrototypeOf ||
22592 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22593 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22594 return extendStatics(d, b);
22596 return function (d, b) {
22597 extendStatics(d, b);
22598 function __() { this.constructor = d; }
22599 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22602 Object.defineProperty(exports, "__esModule", { value: true });
22603 var OuterSubscriber_1 = require("../OuterSubscriber");
22604 var subscribeToResult_1 = require("../util/subscribeToResult");
22605 function withLatestFrom() {
22607 for (var _i = 0; _i < arguments.length; _i++) {
22608 args[_i] = arguments[_i];
22610 return function (source) {
22612 if (typeof args[args.length - 1] === 'function') {
22613 project = args.pop();
22615 var observables = args;
22616 return source.lift(new WithLatestFromOperator(observables, project));
22619 exports.withLatestFrom = withLatestFrom;
22620 var WithLatestFromOperator = (function () {
22621 function WithLatestFromOperator(observables, project) {
22622 this.observables = observables;
22623 this.project = project;
22625 WithLatestFromOperator.prototype.call = function (subscriber, source) {
22626 return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
22628 return WithLatestFromOperator;
22630 var WithLatestFromSubscriber = (function (_super) {
22631 __extends(WithLatestFromSubscriber, _super);
22632 function WithLatestFromSubscriber(destination, observables, project) {
22633 var _this = _super.call(this, destination) || this;
22634 _this.observables = observables;
22635 _this.project = project;
22636 _this.toRespond = [];
22637 var len = observables.length;
22638 _this.values = new Array(len);
22639 for (var i = 0; i < len; i++) {
22640 _this.toRespond.push(i);
22642 for (var i = 0; i < len; i++) {
22643 var observable = observables[i];
22644 _this.add(subscribeToResult_1.subscribeToResult(_this, observable, observable, i));
22648 WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
22649 this.values[outerIndex] = innerValue;
22650 var toRespond = this.toRespond;
22651 if (toRespond.length > 0) {
22652 var found = toRespond.indexOf(outerIndex);
22653 if (found !== -1) {
22654 toRespond.splice(found, 1);
22658 WithLatestFromSubscriber.prototype.notifyComplete = function () {
22660 WithLatestFromSubscriber.prototype._next = function (value) {
22661 if (this.toRespond.length === 0) {
22662 var args = [value].concat(this.values);
22663 if (this.project) {
22664 this._tryProject(args);
22667 this.destination.next(args);
22671 WithLatestFromSubscriber.prototype._tryProject = function (args) {
22674 result = this.project.apply(this, args);
22677 this.destination.error(err);
22680 this.destination.next(result);
22682 return WithLatestFromSubscriber;
22683 }(OuterSubscriber_1.OuterSubscriber));
22685 },{"../OuterSubscriber":50,"../util/subscribeToResult":239}],187:[function(require,module,exports){
22687 Object.defineProperty(exports, "__esModule", { value: true });
22688 var zip_1 = require("../observable/zip");
22690 var observables = [];
22691 for (var _i = 0; _i < arguments.length; _i++) {
22692 observables[_i] = arguments[_i];
22694 return function zipOperatorFunction(source) {
22695 return source.lift.call(zip_1.zip.apply(void 0, [source].concat(observables)));
22700 },{"../observable/zip":85}],188:[function(require,module,exports){
22702 Object.defineProperty(exports, "__esModule", { value: true });
22703 var zip_1 = require("../observable/zip");
22704 function zipAll(project) {
22705 return function (source) { return source.lift(new zip_1.ZipOperator(project)); };
22707 exports.zipAll = zipAll;
22709 },{"../observable/zip":85}],189:[function(require,module,exports){
22711 Object.defineProperty(exports, "__esModule", { value: true });
22712 var Observable_1 = require("../Observable");
22713 var Subscription_1 = require("../Subscription");
22714 function scheduleArray(input, scheduler) {
22715 return new Observable_1.Observable(function (subscriber) {
22716 var sub = new Subscription_1.Subscription();
22718 sub.add(scheduler.schedule(function () {
22719 if (i === input.length) {
22720 subscriber.complete();
22723 subscriber.next(input[i++]);
22724 if (!subscriber.closed) {
22725 sub.add(this.schedule());
22731 exports.scheduleArray = scheduleArray;
22733 },{"../Observable":48,"../Subscription":56}],190:[function(require,module,exports){
22735 Object.defineProperty(exports, "__esModule", { value: true });
22736 var Observable_1 = require("../Observable");
22737 var Subscription_1 = require("../Subscription");
22738 var iterator_1 = require("../symbol/iterator");
22739 function scheduleIterable(input, scheduler) {
22741 throw new Error('Iterable cannot be null');
22743 return new Observable_1.Observable(function (subscriber) {
22744 var sub = new Subscription_1.Subscription();
22746 sub.add(function () {
22747 if (iterator && typeof iterator.return === 'function') {
22751 sub.add(scheduler.schedule(function () {
22752 iterator = input[iterator_1.iterator]();
22753 sub.add(scheduler.schedule(function () {
22754 if (subscriber.closed) {
22760 var result = iterator.next();
22761 value = result.value;
22762 done = result.done;
22765 subscriber.error(err);
22769 subscriber.complete();
22772 subscriber.next(value);
22780 exports.scheduleIterable = scheduleIterable;
22782 },{"../Observable":48,"../Subscription":56,"../symbol/iterator":208}],191:[function(require,module,exports){
22784 Object.defineProperty(exports, "__esModule", { value: true });
22785 var Observable_1 = require("../Observable");
22786 var Subscription_1 = require("../Subscription");
22787 var observable_1 = require("../symbol/observable");
22788 function scheduleObservable(input, scheduler) {
22789 return new Observable_1.Observable(function (subscriber) {
22790 var sub = new Subscription_1.Subscription();
22791 sub.add(scheduler.schedule(function () {
22792 var observable = input[observable_1.observable]();
22793 sub.add(observable.subscribe({
22794 next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
22795 error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
22796 complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
22802 exports.scheduleObservable = scheduleObservable;
22804 },{"../Observable":48,"../Subscription":56,"../symbol/observable":209}],192:[function(require,module,exports){
22806 Object.defineProperty(exports, "__esModule", { value: true });
22807 var Observable_1 = require("../Observable");
22808 var Subscription_1 = require("../Subscription");
22809 function schedulePromise(input, scheduler) {
22810 return new Observable_1.Observable(function (subscriber) {
22811 var sub = new Subscription_1.Subscription();
22812 sub.add(scheduler.schedule(function () { return input.then(function (value) {
22813 sub.add(scheduler.schedule(function () {
22814 subscriber.next(value);
22815 sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
22817 }, function (err) {
22818 sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
22823 exports.schedulePromise = schedulePromise;
22825 },{"../Observable":48,"../Subscription":56}],193:[function(require,module,exports){
22827 Object.defineProperty(exports, "__esModule", { value: true });
22828 var scheduleObservable_1 = require("./scheduleObservable");
22829 var schedulePromise_1 = require("./schedulePromise");
22830 var scheduleArray_1 = require("./scheduleArray");
22831 var scheduleIterable_1 = require("./scheduleIterable");
22832 var isInteropObservable_1 = require("../util/isInteropObservable");
22833 var isPromise_1 = require("../util/isPromise");
22834 var isArrayLike_1 = require("../util/isArrayLike");
22835 var isIterable_1 = require("../util/isIterable");
22836 function scheduled(input, scheduler) {
22837 if (input != null) {
22838 if (isInteropObservable_1.isInteropObservable(input)) {
22839 return scheduleObservable_1.scheduleObservable(input, scheduler);
22841 else if (isPromise_1.isPromise(input)) {
22842 return schedulePromise_1.schedulePromise(input, scheduler);
22844 else if (isArrayLike_1.isArrayLike(input)) {
22845 return scheduleArray_1.scheduleArray(input, scheduler);
22847 else if (isIterable_1.isIterable(input) || typeof input === 'string') {
22848 return scheduleIterable_1.scheduleIterable(input, scheduler);
22851 throw new TypeError((input !== null && typeof input || input) + ' is not observable');
22853 exports.scheduled = scheduled;
22855 },{"../util/isArrayLike":221,"../util/isInteropObservable":224,"../util/isIterable":225,"../util/isPromise":229,"./scheduleArray":189,"./scheduleIterable":190,"./scheduleObservable":191,"./schedulePromise":192}],194:[function(require,module,exports){
22857 var __extends = (this && this.__extends) || (function () {
22858 var extendStatics = function (d, b) {
22859 extendStatics = Object.setPrototypeOf ||
22860 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22861 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22862 return extendStatics(d, b);
22864 return function (d, b) {
22865 extendStatics(d, b);
22866 function __() { this.constructor = d; }
22867 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22870 Object.defineProperty(exports, "__esModule", { value: true });
22871 var Subscription_1 = require("../Subscription");
22872 var Action = (function (_super) {
22873 __extends(Action, _super);
22874 function Action(scheduler, work) {
22875 return _super.call(this) || this;
22877 Action.prototype.schedule = function (state, delay) {
22878 if (delay === void 0) { delay = 0; }
22882 }(Subscription_1.Subscription));
22883 exports.Action = Action;
22885 },{"../Subscription":56}],195:[function(require,module,exports){
22887 var __extends = (this && this.__extends) || (function () {
22888 var extendStatics = function (d, b) {
22889 extendStatics = Object.setPrototypeOf ||
22890 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22891 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22892 return extendStatics(d, b);
22894 return function (d, b) {
22895 extendStatics(d, b);
22896 function __() { this.constructor = d; }
22897 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22900 Object.defineProperty(exports, "__esModule", { value: true });
22901 var AsyncAction_1 = require("./AsyncAction");
22902 var AnimationFrameAction = (function (_super) {
22903 __extends(AnimationFrameAction, _super);
22904 function AnimationFrameAction(scheduler, work) {
22905 var _this = _super.call(this, scheduler, work) || this;
22906 _this.scheduler = scheduler;
22910 AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
22911 if (delay === void 0) { delay = 0; }
22912 if (delay !== null && delay > 0) {
22913 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
22915 scheduler.actions.push(this);
22916 return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
22918 AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
22919 if (delay === void 0) { delay = 0; }
22920 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
22921 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
22923 if (scheduler.actions.length === 0) {
22924 cancelAnimationFrame(id);
22925 scheduler.scheduled = undefined;
22929 return AnimationFrameAction;
22930 }(AsyncAction_1.AsyncAction));
22931 exports.AnimationFrameAction = AnimationFrameAction;
22933 },{"./AsyncAction":199}],196:[function(require,module,exports){
22935 var __extends = (this && this.__extends) || (function () {
22936 var extendStatics = function (d, b) {
22937 extendStatics = Object.setPrototypeOf ||
22938 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22939 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22940 return extendStatics(d, b);
22942 return function (d, b) {
22943 extendStatics(d, b);
22944 function __() { this.constructor = d; }
22945 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22948 Object.defineProperty(exports, "__esModule", { value: true });
22949 var AsyncScheduler_1 = require("./AsyncScheduler");
22950 var AnimationFrameScheduler = (function (_super) {
22951 __extends(AnimationFrameScheduler, _super);
22952 function AnimationFrameScheduler() {
22953 return _super !== null && _super.apply(this, arguments) || this;
22955 AnimationFrameScheduler.prototype.flush = function (action) {
22956 this.active = true;
22957 this.scheduled = undefined;
22958 var actions = this.actions;
22961 var count = actions.length;
22962 action = action || actions.shift();
22964 if (error = action.execute(action.state, action.delay)) {
22967 } while (++index < count && (action = actions.shift()));
22968 this.active = false;
22970 while (++index < count && (action = actions.shift())) {
22971 action.unsubscribe();
22976 return AnimationFrameScheduler;
22977 }(AsyncScheduler_1.AsyncScheduler));
22978 exports.AnimationFrameScheduler = AnimationFrameScheduler;
22980 },{"./AsyncScheduler":200}],197:[function(require,module,exports){
22982 var __extends = (this && this.__extends) || (function () {
22983 var extendStatics = function (d, b) {
22984 extendStatics = Object.setPrototypeOf ||
22985 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22986 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22987 return extendStatics(d, b);
22989 return function (d, b) {
22990 extendStatics(d, b);
22991 function __() { this.constructor = d; }
22992 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22995 Object.defineProperty(exports, "__esModule", { value: true });
22996 var Immediate_1 = require("../util/Immediate");
22997 var AsyncAction_1 = require("./AsyncAction");
22998 var AsapAction = (function (_super) {
22999 __extends(AsapAction, _super);
23000 function AsapAction(scheduler, work) {
23001 var _this = _super.call(this, scheduler, work) || this;
23002 _this.scheduler = scheduler;
23006 AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
23007 if (delay === void 0) { delay = 0; }
23008 if (delay !== null && delay > 0) {
23009 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
23011 scheduler.actions.push(this);
23012 return scheduler.scheduled || (scheduler.scheduled = Immediate_1.Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
23014 AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
23015 if (delay === void 0) { delay = 0; }
23016 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
23017 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
23019 if (scheduler.actions.length === 0) {
23020 Immediate_1.Immediate.clearImmediate(id);
23021 scheduler.scheduled = undefined;
23026 }(AsyncAction_1.AsyncAction));
23027 exports.AsapAction = AsapAction;
23029 },{"../util/Immediate":213,"./AsyncAction":199}],198:[function(require,module,exports){
23031 var __extends = (this && this.__extends) || (function () {
23032 var extendStatics = function (d, b) {
23033 extendStatics = Object.setPrototypeOf ||
23034 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23035 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23036 return extendStatics(d, b);
23038 return function (d, b) {
23039 extendStatics(d, b);
23040 function __() { this.constructor = d; }
23041 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23044 Object.defineProperty(exports, "__esModule", { value: true });
23045 var AsyncScheduler_1 = require("./AsyncScheduler");
23046 var AsapScheduler = (function (_super) {
23047 __extends(AsapScheduler, _super);
23048 function AsapScheduler() {
23049 return _super !== null && _super.apply(this, arguments) || this;
23051 AsapScheduler.prototype.flush = function (action) {
23052 this.active = true;
23053 this.scheduled = undefined;
23054 var actions = this.actions;
23057 var count = actions.length;
23058 action = action || actions.shift();
23060 if (error = action.execute(action.state, action.delay)) {
23063 } while (++index < count && (action = actions.shift()));
23064 this.active = false;
23066 while (++index < count && (action = actions.shift())) {
23067 action.unsubscribe();
23072 return AsapScheduler;
23073 }(AsyncScheduler_1.AsyncScheduler));
23074 exports.AsapScheduler = AsapScheduler;
23076 },{"./AsyncScheduler":200}],199:[function(require,module,exports){
23078 var __extends = (this && this.__extends) || (function () {
23079 var extendStatics = function (d, b) {
23080 extendStatics = Object.setPrototypeOf ||
23081 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23082 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23083 return extendStatics(d, b);
23085 return function (d, b) {
23086 extendStatics(d, b);
23087 function __() { this.constructor = d; }
23088 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23091 Object.defineProperty(exports, "__esModule", { value: true });
23092 var Action_1 = require("./Action");
23093 var AsyncAction = (function (_super) {
23094 __extends(AsyncAction, _super);
23095 function AsyncAction(scheduler, work) {
23096 var _this = _super.call(this, scheduler, work) || this;
23097 _this.scheduler = scheduler;
23099 _this.pending = false;
23102 AsyncAction.prototype.schedule = function (state, delay) {
23103 if (delay === void 0) { delay = 0; }
23107 this.state = state;
23109 var scheduler = this.scheduler;
23111 this.id = this.recycleAsyncId(scheduler, id, delay);
23113 this.pending = true;
23114 this.delay = delay;
23115 this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
23118 AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
23119 if (delay === void 0) { delay = 0; }
23120 return setInterval(scheduler.flush.bind(scheduler, this), delay);
23122 AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
23123 if (delay === void 0) { delay = 0; }
23124 if (delay !== null && this.delay === delay && this.pending === false) {
23130 AsyncAction.prototype.execute = function (state, delay) {
23132 return new Error('executing a cancelled action');
23134 this.pending = false;
23135 var error = this._execute(state, delay);
23139 else if (this.pending === false && this.id != null) {
23140 this.id = this.recycleAsyncId(this.scheduler, this.id, null);
23143 AsyncAction.prototype._execute = function (state, delay) {
23144 var errored = false;
23145 var errorValue = undefined;
23151 errorValue = !!e && e || new Error(e);
23154 this.unsubscribe();
23158 AsyncAction.prototype._unsubscribe = function () {
23160 var scheduler = this.scheduler;
23161 var actions = scheduler.actions;
23162 var index = actions.indexOf(this);
23165 this.pending = false;
23166 this.scheduler = null;
23167 if (index !== -1) {
23168 actions.splice(index, 1);
23171 this.id = this.recycleAsyncId(scheduler, id, null);
23175 return AsyncAction;
23176 }(Action_1.Action));
23177 exports.AsyncAction = AsyncAction;
23179 },{"./Action":194}],200:[function(require,module,exports){
23181 var __extends = (this && this.__extends) || (function () {
23182 var extendStatics = function (d, b) {
23183 extendStatics = Object.setPrototypeOf ||
23184 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23185 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23186 return extendStatics(d, b);
23188 return function (d, b) {
23189 extendStatics(d, b);
23190 function __() { this.constructor = d; }
23191 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23194 Object.defineProperty(exports, "__esModule", { value: true });
23195 var Scheduler_1 = require("../Scheduler");
23196 var AsyncScheduler = (function (_super) {
23197 __extends(AsyncScheduler, _super);
23198 function AsyncScheduler(SchedulerAction, now) {
23199 if (now === void 0) { now = Scheduler_1.Scheduler.now; }
23200 var _this = _super.call(this, SchedulerAction, function () {
23201 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
23202 return AsyncScheduler.delegate.now();
23208 _this.actions = [];
23209 _this.active = false;
23210 _this.scheduled = undefined;
23213 AsyncScheduler.prototype.schedule = function (work, delay, state) {
23214 if (delay === void 0) { delay = 0; }
23215 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
23216 return AsyncScheduler.delegate.schedule(work, delay, state);
23219 return _super.prototype.schedule.call(this, work, delay, state);
23222 AsyncScheduler.prototype.flush = function (action) {
23223 var actions = this.actions;
23225 actions.push(action);
23229 this.active = true;
23231 if (error = action.execute(action.state, action.delay)) {
23234 } while (action = actions.shift());
23235 this.active = false;
23237 while (action = actions.shift()) {
23238 action.unsubscribe();
23243 return AsyncScheduler;
23244 }(Scheduler_1.Scheduler));
23245 exports.AsyncScheduler = AsyncScheduler;
23247 },{"../Scheduler":52}],201:[function(require,module,exports){
23249 var __extends = (this && this.__extends) || (function () {
23250 var extendStatics = function (d, b) {
23251 extendStatics = Object.setPrototypeOf ||
23252 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23253 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23254 return extendStatics(d, b);
23256 return function (d, b) {
23257 extendStatics(d, b);
23258 function __() { this.constructor = d; }
23259 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23262 Object.defineProperty(exports, "__esModule", { value: true });
23263 var AsyncAction_1 = require("./AsyncAction");
23264 var QueueAction = (function (_super) {
23265 __extends(QueueAction, _super);
23266 function QueueAction(scheduler, work) {
23267 var _this = _super.call(this, scheduler, work) || this;
23268 _this.scheduler = scheduler;
23272 QueueAction.prototype.schedule = function (state, delay) {
23273 if (delay === void 0) { delay = 0; }
23275 return _super.prototype.schedule.call(this, state, delay);
23277 this.delay = delay;
23278 this.state = state;
23279 this.scheduler.flush(this);
23282 QueueAction.prototype.execute = function (state, delay) {
23283 return (delay > 0 || this.closed) ?
23284 _super.prototype.execute.call(this, state, delay) :
23285 this._execute(state, delay);
23287 QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
23288 if (delay === void 0) { delay = 0; }
23289 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
23290 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
23292 return scheduler.flush(this);
23294 return QueueAction;
23295 }(AsyncAction_1.AsyncAction));
23296 exports.QueueAction = QueueAction;
23298 },{"./AsyncAction":199}],202:[function(require,module,exports){
23300 var __extends = (this && this.__extends) || (function () {
23301 var extendStatics = function (d, b) {
23302 extendStatics = Object.setPrototypeOf ||
23303 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23304 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23305 return extendStatics(d, b);
23307 return function (d, b) {
23308 extendStatics(d, b);
23309 function __() { this.constructor = d; }
23310 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23313 Object.defineProperty(exports, "__esModule", { value: true });
23314 var AsyncScheduler_1 = require("./AsyncScheduler");
23315 var QueueScheduler = (function (_super) {
23316 __extends(QueueScheduler, _super);
23317 function QueueScheduler() {
23318 return _super !== null && _super.apply(this, arguments) || this;
23320 return QueueScheduler;
23321 }(AsyncScheduler_1.AsyncScheduler));
23322 exports.QueueScheduler = QueueScheduler;
23324 },{"./AsyncScheduler":200}],203:[function(require,module,exports){
23326 var __extends = (this && this.__extends) || (function () {
23327 var extendStatics = function (d, b) {
23328 extendStatics = Object.setPrototypeOf ||
23329 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23330 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23331 return extendStatics(d, b);
23333 return function (d, b) {
23334 extendStatics(d, b);
23335 function __() { this.constructor = d; }
23336 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23339 Object.defineProperty(exports, "__esModule", { value: true });
23340 var AsyncAction_1 = require("./AsyncAction");
23341 var AsyncScheduler_1 = require("./AsyncScheduler");
23342 var VirtualTimeScheduler = (function (_super) {
23343 __extends(VirtualTimeScheduler, _super);
23344 function VirtualTimeScheduler(SchedulerAction, maxFrames) {
23345 if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
23346 if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
23347 var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
23348 _this.maxFrames = maxFrames;
23353 VirtualTimeScheduler.prototype.flush = function () {
23354 var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
23356 while ((action = actions[0]) && action.delay <= maxFrames) {
23358 this.frame = action.delay;
23359 if (error = action.execute(action.state, action.delay)) {
23364 while (action = actions.shift()) {
23365 action.unsubscribe();
23370 VirtualTimeScheduler.frameTimeFactor = 10;
23371 return VirtualTimeScheduler;
23372 }(AsyncScheduler_1.AsyncScheduler));
23373 exports.VirtualTimeScheduler = VirtualTimeScheduler;
23374 var VirtualAction = (function (_super) {
23375 __extends(VirtualAction, _super);
23376 function VirtualAction(scheduler, work, index) {
23377 if (index === void 0) { index = scheduler.index += 1; }
23378 var _this = _super.call(this, scheduler, work) || this;
23379 _this.scheduler = scheduler;
23381 _this.index = index;
23382 _this.active = true;
23383 _this.index = scheduler.index = index;
23386 VirtualAction.prototype.schedule = function (state, delay) {
23387 if (delay === void 0) { delay = 0; }
23389 return _super.prototype.schedule.call(this, state, delay);
23391 this.active = false;
23392 var action = new VirtualAction(this.scheduler, this.work);
23394 return action.schedule(state, delay);
23396 VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
23397 if (delay === void 0) { delay = 0; }
23398 this.delay = scheduler.frame + delay;
23399 var actions = scheduler.actions;
23400 actions.push(this);
23401 actions.sort(VirtualAction.sortActions);
23404 VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
23405 if (delay === void 0) { delay = 0; }
23408 VirtualAction.prototype._execute = function (state, delay) {
23409 if (this.active === true) {
23410 return _super.prototype._execute.call(this, state, delay);
23413 VirtualAction.sortActions = function (a, b) {
23414 if (a.delay === b.delay) {
23415 if (a.index === b.index) {
23418 else if (a.index > b.index) {
23425 else if (a.delay > b.delay) {
23432 return VirtualAction;
23433 }(AsyncAction_1.AsyncAction));
23434 exports.VirtualAction = VirtualAction;
23436 },{"./AsyncAction":199,"./AsyncScheduler":200}],204:[function(require,module,exports){
23438 Object.defineProperty(exports, "__esModule", { value: true });
23439 var AnimationFrameAction_1 = require("./AnimationFrameAction");
23440 var AnimationFrameScheduler_1 = require("./AnimationFrameScheduler");
23441 exports.animationFrame = new AnimationFrameScheduler_1.AnimationFrameScheduler(AnimationFrameAction_1.AnimationFrameAction);
23443 },{"./AnimationFrameAction":195,"./AnimationFrameScheduler":196}],205:[function(require,module,exports){
23445 Object.defineProperty(exports, "__esModule", { value: true });
23446 var AsapAction_1 = require("./AsapAction");
23447 var AsapScheduler_1 = require("./AsapScheduler");
23448 exports.asap = new AsapScheduler_1.AsapScheduler(AsapAction_1.AsapAction);
23450 },{"./AsapAction":197,"./AsapScheduler":198}],206:[function(require,module,exports){
23452 Object.defineProperty(exports, "__esModule", { value: true });
23453 var AsyncAction_1 = require("./AsyncAction");
23454 var AsyncScheduler_1 = require("./AsyncScheduler");
23455 exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction);
23457 },{"./AsyncAction":199,"./AsyncScheduler":200}],207:[function(require,module,exports){
23459 Object.defineProperty(exports, "__esModule", { value: true });
23460 var QueueAction_1 = require("./QueueAction");
23461 var QueueScheduler_1 = require("./QueueScheduler");
23462 exports.queue = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction);
23464 },{"./QueueAction":201,"./QueueScheduler":202}],208:[function(require,module,exports){
23466 Object.defineProperty(exports, "__esModule", { value: true });
23467 function getSymbolIterator() {
23468 if (typeof Symbol !== 'function' || !Symbol.iterator) {
23469 return '@@iterator';
23471 return Symbol.iterator;
23473 exports.getSymbolIterator = getSymbolIterator;
23474 exports.iterator = getSymbolIterator();
23475 exports.$$iterator = exports.iterator;
23477 },{}],209:[function(require,module,exports){
23479 Object.defineProperty(exports, "__esModule", { value: true });
23480 exports.observable = (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
23482 },{}],210:[function(require,module,exports){
23484 Object.defineProperty(exports, "__esModule", { value: true });
23485 exports.rxSubscriber = (function () {
23486 return typeof Symbol === 'function'
23487 ? Symbol('rxSubscriber')
23488 : '@@rxSubscriber_' + Math.random();
23490 exports.$$rxSubscriber = exports.rxSubscriber;
23492 },{}],211:[function(require,module,exports){
23494 Object.defineProperty(exports, "__esModule", { value: true });
23495 var ArgumentOutOfRangeErrorImpl = (function () {
23496 function ArgumentOutOfRangeErrorImpl() {
23498 this.message = 'argument out of range';
23499 this.name = 'ArgumentOutOfRangeError';
23502 ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
23503 return ArgumentOutOfRangeErrorImpl;
23505 exports.ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
23507 },{}],212:[function(require,module,exports){
23509 Object.defineProperty(exports, "__esModule", { value: true });
23510 var EmptyErrorImpl = (function () {
23511 function EmptyErrorImpl() {
23513 this.message = 'no elements in sequence';
23514 this.name = 'EmptyError';
23517 EmptyErrorImpl.prototype = Object.create(Error.prototype);
23518 return EmptyErrorImpl;
23520 exports.EmptyError = EmptyErrorImpl;
23522 },{}],213:[function(require,module,exports){
23524 Object.defineProperty(exports, "__esModule", { value: true });
23525 var nextHandle = 1;
23526 var RESOLVED = (function () { return Promise.resolve(); })();
23527 var activeHandles = {};
23528 function findAndClearHandle(handle) {
23529 if (handle in activeHandles) {
23530 delete activeHandles[handle];
23535 exports.Immediate = {
23536 setImmediate: function (cb) {
23537 var handle = nextHandle++;
23538 activeHandles[handle] = true;
23539 RESOLVED.then(function () { return findAndClearHandle(handle) && cb(); });
23542 clearImmediate: function (handle) {
23543 findAndClearHandle(handle);
23546 exports.TestTools = {
23547 pending: function () {
23548 return Object.keys(activeHandles).length;
23552 },{}],214:[function(require,module,exports){
23554 Object.defineProperty(exports, "__esModule", { value: true });
23555 var ObjectUnsubscribedErrorImpl = (function () {
23556 function ObjectUnsubscribedErrorImpl() {
23558 this.message = 'object unsubscribed';
23559 this.name = 'ObjectUnsubscribedError';
23562 ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
23563 return ObjectUnsubscribedErrorImpl;
23565 exports.ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
23567 },{}],215:[function(require,module,exports){
23569 Object.defineProperty(exports, "__esModule", { value: true });
23570 var TimeoutErrorImpl = (function () {
23571 function TimeoutErrorImpl() {
23573 this.message = 'Timeout has occurred';
23574 this.name = 'TimeoutError';
23577 TimeoutErrorImpl.prototype = Object.create(Error.prototype);
23578 return TimeoutErrorImpl;
23580 exports.TimeoutError = TimeoutErrorImpl;
23582 },{}],216:[function(require,module,exports){
23584 Object.defineProperty(exports, "__esModule", { value: true });
23585 var UnsubscriptionErrorImpl = (function () {
23586 function UnsubscriptionErrorImpl(errors) {
23588 this.message = errors ?
23589 errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
23590 this.name = 'UnsubscriptionError';
23591 this.errors = errors;
23594 UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
23595 return UnsubscriptionErrorImpl;
23597 exports.UnsubscriptionError = UnsubscriptionErrorImpl;
23599 },{}],217:[function(require,module,exports){
23601 Object.defineProperty(exports, "__esModule", { value: true });
23602 var Subscriber_1 = require("../Subscriber");
23603 function canReportError(observer) {
23605 var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
23606 if (closed_1 || isStopped) {
23609 else if (destination && destination instanceof Subscriber_1.Subscriber) {
23610 observer = destination;
23618 exports.canReportError = canReportError;
23620 },{"../Subscriber":55}],218:[function(require,module,exports){
23622 Object.defineProperty(exports, "__esModule", { value: true });
23623 function hostReportError(err) {
23624 setTimeout(function () { throw err; }, 0);
23626 exports.hostReportError = hostReportError;
23628 },{}],219:[function(require,module,exports){
23630 Object.defineProperty(exports, "__esModule", { value: true });
23631 function identity(x) {
23634 exports.identity = identity;
23636 },{}],220:[function(require,module,exports){
23638 Object.defineProperty(exports, "__esModule", { value: true });
23639 exports.isArray = (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
23641 },{}],221:[function(require,module,exports){
23643 Object.defineProperty(exports, "__esModule", { value: true });
23644 exports.isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
23646 },{}],222:[function(require,module,exports){
23648 Object.defineProperty(exports, "__esModule", { value: true });
23649 function isDate(value) {
23650 return value instanceof Date && !isNaN(+value);
23652 exports.isDate = isDate;
23654 },{}],223:[function(require,module,exports){
23656 Object.defineProperty(exports, "__esModule", { value: true });
23657 function isFunction(x) {
23658 return typeof x === 'function';
23660 exports.isFunction = isFunction;
23662 },{}],224:[function(require,module,exports){
23664 Object.defineProperty(exports, "__esModule", { value: true });
23665 var observable_1 = require("../symbol/observable");
23666 function isInteropObservable(input) {
23667 return input && typeof input[observable_1.observable] === 'function';
23669 exports.isInteropObservable = isInteropObservable;
23671 },{"../symbol/observable":209}],225:[function(require,module,exports){
23673 Object.defineProperty(exports, "__esModule", { value: true });
23674 var iterator_1 = require("../symbol/iterator");
23675 function isIterable(input) {
23676 return input && typeof input[iterator_1.iterator] === 'function';
23678 exports.isIterable = isIterable;
23680 },{"../symbol/iterator":208}],226:[function(require,module,exports){
23682 Object.defineProperty(exports, "__esModule", { value: true });
23683 var isArray_1 = require("./isArray");
23684 function isNumeric(val) {
23685 return !isArray_1.isArray(val) && (val - parseFloat(val) + 1) >= 0;
23687 exports.isNumeric = isNumeric;
23689 },{"./isArray":220}],227:[function(require,module,exports){
23691 Object.defineProperty(exports, "__esModule", { value: true });
23692 function isObject(x) {
23693 return x !== null && typeof x === 'object';
23695 exports.isObject = isObject;
23697 },{}],228:[function(require,module,exports){
23699 Object.defineProperty(exports, "__esModule", { value: true });
23700 var Observable_1 = require("../Observable");
23701 function isObservable(obj) {
23702 return !!obj && (obj instanceof Observable_1.Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
23704 exports.isObservable = isObservable;
23706 },{"../Observable":48}],229:[function(require,module,exports){
23708 Object.defineProperty(exports, "__esModule", { value: true });
23709 function isPromise(value) {
23710 return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
23712 exports.isPromise = isPromise;
23714 },{}],230:[function(require,module,exports){
23716 Object.defineProperty(exports, "__esModule", { value: true });
23717 function isScheduler(value) {
23718 return value && typeof value.schedule === 'function';
23720 exports.isScheduler = isScheduler;
23722 },{}],231:[function(require,module,exports){
23724 Object.defineProperty(exports, "__esModule", { value: true });
23725 function noop() { }
23726 exports.noop = noop;
23728 },{}],232:[function(require,module,exports){
23730 Object.defineProperty(exports, "__esModule", { value: true });
23731 function not(pred, thisArg) {
23732 function notPred() {
23733 return !(notPred.pred.apply(notPred.thisArg, arguments));
23735 notPred.pred = pred;
23736 notPred.thisArg = thisArg;
23741 },{}],233:[function(require,module,exports){
23743 Object.defineProperty(exports, "__esModule", { value: true });
23744 var identity_1 = require("./identity");
23747 for (var _i = 0; _i < arguments.length; _i++) {
23748 fns[_i] = arguments[_i];
23750 return pipeFromArray(fns);
23752 exports.pipe = pipe;
23753 function pipeFromArray(fns) {
23754 if (fns.length === 0) {
23755 return identity_1.identity;
23757 if (fns.length === 1) {
23760 return function piped(input) {
23761 return fns.reduce(function (prev, fn) { return fn(prev); }, input);
23764 exports.pipeFromArray = pipeFromArray;
23766 },{"./identity":219}],234:[function(require,module,exports){
23768 Object.defineProperty(exports, "__esModule", { value: true });
23769 var subscribeToArray_1 = require("./subscribeToArray");
23770 var subscribeToPromise_1 = require("./subscribeToPromise");
23771 var subscribeToIterable_1 = require("./subscribeToIterable");
23772 var subscribeToObservable_1 = require("./subscribeToObservable");
23773 var isArrayLike_1 = require("./isArrayLike");
23774 var isPromise_1 = require("./isPromise");
23775 var isObject_1 = require("./isObject");
23776 var iterator_1 = require("../symbol/iterator");
23777 var observable_1 = require("../symbol/observable");
23778 exports.subscribeTo = function (result) {
23779 if (!!result && typeof result[observable_1.observable] === 'function') {
23780 return subscribeToObservable_1.subscribeToObservable(result);
23782 else if (isArrayLike_1.isArrayLike(result)) {
23783 return subscribeToArray_1.subscribeToArray(result);
23785 else if (isPromise_1.isPromise(result)) {
23786 return subscribeToPromise_1.subscribeToPromise(result);
23788 else if (!!result && typeof result[iterator_1.iterator] === 'function') {
23789 return subscribeToIterable_1.subscribeToIterable(result);
23792 var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'";
23793 var msg = "You provided " + value + " where a stream was expected."
23794 + ' You can provide an Observable, Promise, Array, or Iterable.';
23795 throw new TypeError(msg);
23799 },{"../symbol/iterator":208,"../symbol/observable":209,"./isArrayLike":221,"./isObject":227,"./isPromise":229,"./subscribeToArray":235,"./subscribeToIterable":236,"./subscribeToObservable":237,"./subscribeToPromise":238}],235:[function(require,module,exports){
23801 Object.defineProperty(exports, "__esModule", { value: true });
23802 exports.subscribeToArray = function (array) { return function (subscriber) {
23803 for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
23804 subscriber.next(array[i]);
23806 subscriber.complete();
23809 },{}],236:[function(require,module,exports){
23811 Object.defineProperty(exports, "__esModule", { value: true });
23812 var iterator_1 = require("../symbol/iterator");
23813 exports.subscribeToIterable = function (iterable) { return function (subscriber) {
23814 var iterator = iterable[iterator_1.iterator]();
23816 var item = iterator.next();
23818 subscriber.complete();
23821 subscriber.next(item.value);
23822 if (subscriber.closed) {
23826 if (typeof iterator.return === 'function') {
23827 subscriber.add(function () {
23828 if (iterator.return) {
23836 },{"../symbol/iterator":208}],237:[function(require,module,exports){
23838 Object.defineProperty(exports, "__esModule", { value: true });
23839 var observable_1 = require("../symbol/observable");
23840 exports.subscribeToObservable = function (obj) { return function (subscriber) {
23841 var obs = obj[observable_1.observable]();
23842 if (typeof obs.subscribe !== 'function') {
23843 throw new TypeError('Provided object does not correctly implement Symbol.observable');
23846 return obs.subscribe(subscriber);
23850 },{"../symbol/observable":209}],238:[function(require,module,exports){
23852 Object.defineProperty(exports, "__esModule", { value: true });
23853 var hostReportError_1 = require("./hostReportError");
23854 exports.subscribeToPromise = function (promise) { return function (subscriber) {
23855 promise.then(function (value) {
23856 if (!subscriber.closed) {
23857 subscriber.next(value);
23858 subscriber.complete();
23860 }, function (err) { return subscriber.error(err); })
23861 .then(null, hostReportError_1.hostReportError);
23865 },{"./hostReportError":218}],239:[function(require,module,exports){
23867 Object.defineProperty(exports, "__esModule", { value: true });
23868 var InnerSubscriber_1 = require("../InnerSubscriber");
23869 var subscribeTo_1 = require("./subscribeTo");
23870 var Observable_1 = require("../Observable");
23871 function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, innerSubscriber) {
23872 if (innerSubscriber === void 0) { innerSubscriber = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
23873 if (innerSubscriber.closed) {
23876 if (result instanceof Observable_1.Observable) {
23877 return result.subscribe(innerSubscriber);
23879 return subscribeTo_1.subscribeTo(result)(innerSubscriber);
23881 exports.subscribeToResult = subscribeToResult;
23883 },{"../InnerSubscriber":46,"../Observable":48,"./subscribeTo":234}],240:[function(require,module,exports){
23885 Object.defineProperty(exports, "__esModule", { value: true });
23886 var Subscriber_1 = require("../Subscriber");
23887 var rxSubscriber_1 = require("../symbol/rxSubscriber");
23888 var Observer_1 = require("../Observer");
23889 function toSubscriber(nextOrObserver, error, complete) {
23890 if (nextOrObserver) {
23891 if (nextOrObserver instanceof Subscriber_1.Subscriber) {
23892 return nextOrObserver;
23894 if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
23895 return nextOrObserver[rxSubscriber_1.rxSubscriber]();
23898 if (!nextOrObserver && !error && !complete) {
23899 return new Subscriber_1.Subscriber(Observer_1.empty);
23901 return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
23903 exports.toSubscriber = toSubscriber;
23905 },{"../Observer":49,"../Subscriber":55,"../symbol/rxSubscriber":210}],241:[function(require,module,exports){
23907 Object.defineProperty(exports, "__esModule", { value: true });
23908 var audit_1 = require("../internal/operators/audit");
23909 exports.audit = audit_1.audit;
23910 var auditTime_1 = require("../internal/operators/auditTime");
23911 exports.auditTime = auditTime_1.auditTime;
23912 var buffer_1 = require("../internal/operators/buffer");
23913 exports.buffer = buffer_1.buffer;
23914 var bufferCount_1 = require("../internal/operators/bufferCount");
23915 exports.bufferCount = bufferCount_1.bufferCount;
23916 var bufferTime_1 = require("../internal/operators/bufferTime");
23917 exports.bufferTime = bufferTime_1.bufferTime;
23918 var bufferToggle_1 = require("../internal/operators/bufferToggle");
23919 exports.bufferToggle = bufferToggle_1.bufferToggle;
23920 var bufferWhen_1 = require("../internal/operators/bufferWhen");
23921 exports.bufferWhen = bufferWhen_1.bufferWhen;
23922 var catchError_1 = require("../internal/operators/catchError");
23923 exports.catchError = catchError_1.catchError;
23924 var combineAll_1 = require("../internal/operators/combineAll");
23925 exports.combineAll = combineAll_1.combineAll;
23926 var combineLatest_1 = require("../internal/operators/combineLatest");
23927 exports.combineLatest = combineLatest_1.combineLatest;
23928 var concat_1 = require("../internal/operators/concat");
23929 exports.concat = concat_1.concat;
23930 var concatAll_1 = require("../internal/operators/concatAll");
23931 exports.concatAll = concatAll_1.concatAll;
23932 var concatMap_1 = require("../internal/operators/concatMap");
23933 exports.concatMap = concatMap_1.concatMap;
23934 var concatMapTo_1 = require("../internal/operators/concatMapTo");
23935 exports.concatMapTo = concatMapTo_1.concatMapTo;
23936 var count_1 = require("../internal/operators/count");
23937 exports.count = count_1.count;
23938 var debounce_1 = require("../internal/operators/debounce");
23939 exports.debounce = debounce_1.debounce;
23940 var debounceTime_1 = require("../internal/operators/debounceTime");
23941 exports.debounceTime = debounceTime_1.debounceTime;
23942 var defaultIfEmpty_1 = require("../internal/operators/defaultIfEmpty");
23943 exports.defaultIfEmpty = defaultIfEmpty_1.defaultIfEmpty;
23944 var delay_1 = require("../internal/operators/delay");
23945 exports.delay = delay_1.delay;
23946 var delayWhen_1 = require("../internal/operators/delayWhen");
23947 exports.delayWhen = delayWhen_1.delayWhen;
23948 var dematerialize_1 = require("../internal/operators/dematerialize");
23949 exports.dematerialize = dematerialize_1.dematerialize;
23950 var distinct_1 = require("../internal/operators/distinct");
23951 exports.distinct = distinct_1.distinct;
23952 var distinctUntilChanged_1 = require("../internal/operators/distinctUntilChanged");
23953 exports.distinctUntilChanged = distinctUntilChanged_1.distinctUntilChanged;
23954 var distinctUntilKeyChanged_1 = require("../internal/operators/distinctUntilKeyChanged");
23955 exports.distinctUntilKeyChanged = distinctUntilKeyChanged_1.distinctUntilKeyChanged;
23956 var elementAt_1 = require("../internal/operators/elementAt");
23957 exports.elementAt = elementAt_1.elementAt;
23958 var endWith_1 = require("../internal/operators/endWith");
23959 exports.endWith = endWith_1.endWith;
23960 var every_1 = require("../internal/operators/every");
23961 exports.every = every_1.every;
23962 var exhaust_1 = require("../internal/operators/exhaust");
23963 exports.exhaust = exhaust_1.exhaust;
23964 var exhaustMap_1 = require("../internal/operators/exhaustMap");
23965 exports.exhaustMap = exhaustMap_1.exhaustMap;
23966 var expand_1 = require("../internal/operators/expand");
23967 exports.expand = expand_1.expand;
23968 var filter_1 = require("../internal/operators/filter");
23969 exports.filter = filter_1.filter;
23970 var finalize_1 = require("../internal/operators/finalize");
23971 exports.finalize = finalize_1.finalize;
23972 var find_1 = require("../internal/operators/find");
23973 exports.find = find_1.find;
23974 var findIndex_1 = require("../internal/operators/findIndex");
23975 exports.findIndex = findIndex_1.findIndex;
23976 var first_1 = require("../internal/operators/first");
23977 exports.first = first_1.first;
23978 var groupBy_1 = require("../internal/operators/groupBy");
23979 exports.groupBy = groupBy_1.groupBy;
23980 var ignoreElements_1 = require("../internal/operators/ignoreElements");
23981 exports.ignoreElements = ignoreElements_1.ignoreElements;
23982 var isEmpty_1 = require("../internal/operators/isEmpty");
23983 exports.isEmpty = isEmpty_1.isEmpty;
23984 var last_1 = require("../internal/operators/last");
23985 exports.last = last_1.last;
23986 var map_1 = require("../internal/operators/map");
23987 exports.map = map_1.map;
23988 var mapTo_1 = require("../internal/operators/mapTo");
23989 exports.mapTo = mapTo_1.mapTo;
23990 var materialize_1 = require("../internal/operators/materialize");
23991 exports.materialize = materialize_1.materialize;
23992 var max_1 = require("../internal/operators/max");
23993 exports.max = max_1.max;
23994 var merge_1 = require("../internal/operators/merge");
23995 exports.merge = merge_1.merge;
23996 var mergeAll_1 = require("../internal/operators/mergeAll");
23997 exports.mergeAll = mergeAll_1.mergeAll;
23998 var mergeMap_1 = require("../internal/operators/mergeMap");
23999 exports.mergeMap = mergeMap_1.mergeMap;
24000 var mergeMap_2 = require("../internal/operators/mergeMap");
24001 exports.flatMap = mergeMap_2.mergeMap;
24002 var mergeMapTo_1 = require("../internal/operators/mergeMapTo");
24003 exports.mergeMapTo = mergeMapTo_1.mergeMapTo;
24004 var mergeScan_1 = require("../internal/operators/mergeScan");
24005 exports.mergeScan = mergeScan_1.mergeScan;
24006 var min_1 = require("../internal/operators/min");
24007 exports.min = min_1.min;
24008 var multicast_1 = require("../internal/operators/multicast");
24009 exports.multicast = multicast_1.multicast;
24010 var observeOn_1 = require("../internal/operators/observeOn");
24011 exports.observeOn = observeOn_1.observeOn;
24012 var onErrorResumeNext_1 = require("../internal/operators/onErrorResumeNext");
24013 exports.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext;
24014 var pairwise_1 = require("../internal/operators/pairwise");
24015 exports.pairwise = pairwise_1.pairwise;
24016 var partition_1 = require("../internal/operators/partition");
24017 exports.partition = partition_1.partition;
24018 var pluck_1 = require("../internal/operators/pluck");
24019 exports.pluck = pluck_1.pluck;
24020 var publish_1 = require("../internal/operators/publish");
24021 exports.publish = publish_1.publish;
24022 var publishBehavior_1 = require("../internal/operators/publishBehavior");
24023 exports.publishBehavior = publishBehavior_1.publishBehavior;
24024 var publishLast_1 = require("../internal/operators/publishLast");
24025 exports.publishLast = publishLast_1.publishLast;
24026 var publishReplay_1 = require("../internal/operators/publishReplay");
24027 exports.publishReplay = publishReplay_1.publishReplay;
24028 var race_1 = require("../internal/operators/race");
24029 exports.race = race_1.race;
24030 var reduce_1 = require("../internal/operators/reduce");
24031 exports.reduce = reduce_1.reduce;
24032 var repeat_1 = require("../internal/operators/repeat");
24033 exports.repeat = repeat_1.repeat;
24034 var repeatWhen_1 = require("../internal/operators/repeatWhen");
24035 exports.repeatWhen = repeatWhen_1.repeatWhen;
24036 var retry_1 = require("../internal/operators/retry");
24037 exports.retry = retry_1.retry;
24038 var retryWhen_1 = require("../internal/operators/retryWhen");
24039 exports.retryWhen = retryWhen_1.retryWhen;
24040 var refCount_1 = require("../internal/operators/refCount");
24041 exports.refCount = refCount_1.refCount;
24042 var sample_1 = require("../internal/operators/sample");
24043 exports.sample = sample_1.sample;
24044 var sampleTime_1 = require("../internal/operators/sampleTime");
24045 exports.sampleTime = sampleTime_1.sampleTime;
24046 var scan_1 = require("../internal/operators/scan");
24047 exports.scan = scan_1.scan;
24048 var sequenceEqual_1 = require("../internal/operators/sequenceEqual");
24049 exports.sequenceEqual = sequenceEqual_1.sequenceEqual;
24050 var share_1 = require("../internal/operators/share");
24051 exports.share = share_1.share;
24052 var shareReplay_1 = require("../internal/operators/shareReplay");
24053 exports.shareReplay = shareReplay_1.shareReplay;
24054 var single_1 = require("../internal/operators/single");
24055 exports.single = single_1.single;
24056 var skip_1 = require("../internal/operators/skip");
24057 exports.skip = skip_1.skip;
24058 var skipLast_1 = require("../internal/operators/skipLast");
24059 exports.skipLast = skipLast_1.skipLast;
24060 var skipUntil_1 = require("../internal/operators/skipUntil");
24061 exports.skipUntil = skipUntil_1.skipUntil;
24062 var skipWhile_1 = require("../internal/operators/skipWhile");
24063 exports.skipWhile = skipWhile_1.skipWhile;
24064 var startWith_1 = require("../internal/operators/startWith");
24065 exports.startWith = startWith_1.startWith;
24066 var subscribeOn_1 = require("../internal/operators/subscribeOn");
24067 exports.subscribeOn = subscribeOn_1.subscribeOn;
24068 var switchAll_1 = require("../internal/operators/switchAll");
24069 exports.switchAll = switchAll_1.switchAll;
24070 var switchMap_1 = require("../internal/operators/switchMap");
24071 exports.switchMap = switchMap_1.switchMap;
24072 var switchMapTo_1 = require("../internal/operators/switchMapTo");
24073 exports.switchMapTo = switchMapTo_1.switchMapTo;
24074 var take_1 = require("../internal/operators/take");
24075 exports.take = take_1.take;
24076 var takeLast_1 = require("../internal/operators/takeLast");
24077 exports.takeLast = takeLast_1.takeLast;
24078 var takeUntil_1 = require("../internal/operators/takeUntil");
24079 exports.takeUntil = takeUntil_1.takeUntil;
24080 var takeWhile_1 = require("../internal/operators/takeWhile");
24081 exports.takeWhile = takeWhile_1.takeWhile;
24082 var tap_1 = require("../internal/operators/tap");
24083 exports.tap = tap_1.tap;
24084 var throttle_1 = require("../internal/operators/throttle");
24085 exports.throttle = throttle_1.throttle;
24086 var throttleTime_1 = require("../internal/operators/throttleTime");
24087 exports.throttleTime = throttleTime_1.throttleTime;
24088 var throwIfEmpty_1 = require("../internal/operators/throwIfEmpty");
24089 exports.throwIfEmpty = throwIfEmpty_1.throwIfEmpty;
24090 var timeInterval_1 = require("../internal/operators/timeInterval");
24091 exports.timeInterval = timeInterval_1.timeInterval;
24092 var timeout_1 = require("../internal/operators/timeout");
24093 exports.timeout = timeout_1.timeout;
24094 var timeoutWith_1 = require("../internal/operators/timeoutWith");
24095 exports.timeoutWith = timeoutWith_1.timeoutWith;
24096 var timestamp_1 = require("../internal/operators/timestamp");
24097 exports.timestamp = timestamp_1.timestamp;
24098 var toArray_1 = require("../internal/operators/toArray");
24099 exports.toArray = toArray_1.toArray;
24100 var window_1 = require("../internal/operators/window");
24101 exports.window = window_1.window;
24102 var windowCount_1 = require("../internal/operators/windowCount");
24103 exports.windowCount = windowCount_1.windowCount;
24104 var windowTime_1 = require("../internal/operators/windowTime");
24105 exports.windowTime = windowTime_1.windowTime;
24106 var windowToggle_1 = require("../internal/operators/windowToggle");
24107 exports.windowToggle = windowToggle_1.windowToggle;
24108 var windowWhen_1 = require("../internal/operators/windowWhen");
24109 exports.windowWhen = windowWhen_1.windowWhen;
24110 var withLatestFrom_1 = require("../internal/operators/withLatestFrom");
24111 exports.withLatestFrom = withLatestFrom_1.withLatestFrom;
24112 var zip_1 = require("../internal/operators/zip");
24113 exports.zip = zip_1.zip;
24114 var zipAll_1 = require("../internal/operators/zipAll");
24115 exports.zipAll = zipAll_1.zipAll;
24117 },{"../internal/operators/audit":86,"../internal/operators/auditTime":87,"../internal/operators/buffer":88,"../internal/operators/bufferCount":89,"../internal/operators/bufferTime":90,"../internal/operators/bufferToggle":91,"../internal/operators/bufferWhen":92,"../internal/operators/catchError":93,"../internal/operators/combineAll":94,"../internal/operators/combineLatest":95,"../internal/operators/concat":96,"../internal/operators/concatAll":97,"../internal/operators/concatMap":98,"../internal/operators/concatMapTo":99,"../internal/operators/count":100,"../internal/operators/debounce":101,"../internal/operators/debounceTime":102,"../internal/operators/defaultIfEmpty":103,"../internal/operators/delay":104,"../internal/operators/delayWhen":105,"../internal/operators/dematerialize":106,"../internal/operators/distinct":107,"../internal/operators/distinctUntilChanged":108,"../internal/operators/distinctUntilKeyChanged":109,"../internal/operators/elementAt":110,"../internal/operators/endWith":111,"../internal/operators/every":112,"../internal/operators/exhaust":113,"../internal/operators/exhaustMap":114,"../internal/operators/expand":115,"../internal/operators/filter":116,"../internal/operators/finalize":117,"../internal/operators/find":118,"../internal/operators/findIndex":119,"../internal/operators/first":120,"../internal/operators/groupBy":121,"../internal/operators/ignoreElements":122,"../internal/operators/isEmpty":123,"../internal/operators/last":124,"../internal/operators/map":125,"../internal/operators/mapTo":126,"../internal/operators/materialize":127,"../internal/operators/max":128,"../internal/operators/merge":129,"../internal/operators/mergeAll":130,"../internal/operators/mergeMap":131,"../internal/operators/mergeMapTo":132,"../internal/operators/mergeScan":133,"../internal/operators/min":134,"../internal/operators/multicast":135,"../internal/operators/observeOn":136,"../internal/operators/onErrorResumeNext":137,"../internal/operators/pairwise":138,"../internal/operators/partition":139,"../internal/operators/pluck":140,"../internal/operators/publish":141,"../internal/operators/publishBehavior":142,"../internal/operators/publishLast":143,"../internal/operators/publishReplay":144,"../internal/operators/race":145,"../internal/operators/reduce":146,"../internal/operators/refCount":147,"../internal/operators/repeat":148,"../internal/operators/repeatWhen":149,"../internal/operators/retry":150,"../internal/operators/retryWhen":151,"../internal/operators/sample":152,"../internal/operators/sampleTime":153,"../internal/operators/scan":154,"../internal/operators/sequenceEqual":155,"../internal/operators/share":156,"../internal/operators/shareReplay":157,"../internal/operators/single":158,"../internal/operators/skip":159,"../internal/operators/skipLast":160,"../internal/operators/skipUntil":161,"../internal/operators/skipWhile":162,"../internal/operators/startWith":163,"../internal/operators/subscribeOn":164,"../internal/operators/switchAll":165,"../internal/operators/switchMap":166,"../internal/operators/switchMapTo":167,"../internal/operators/take":168,"../internal/operators/takeLast":169,"../internal/operators/takeUntil":170,"../internal/operators/takeWhile":171,"../internal/operators/tap":172,"../internal/operators/throttle":173,"../internal/operators/throttleTime":174,"../internal/operators/throwIfEmpty":175,"../internal/operators/timeInterval":176,"../internal/operators/timeout":177,"../internal/operators/timeoutWith":178,"../internal/operators/timestamp":179,"../internal/operators/toArray":180,"../internal/operators/window":181,"../internal/operators/windowCount":182,"../internal/operators/windowTime":183,"../internal/operators/windowToggle":184,"../internal/operators/windowWhen":185,"../internal/operators/withLatestFrom":186,"../internal/operators/zip":187,"../internal/operators/zipAll":188}],242:[function(require,module,exports){
24118 // threejs.org/license
24119 (function(k,ua){"object"===typeof exports&&"undefined"!==typeof module?ua(exports):"function"===typeof define&&define.amd?define(["exports"],ua):(k=k||self,ua(k.THREE={}))})(this,function(k){function ua(){}function v(a,b){this.x=a||0;this.y=b||0}function ya(){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 W(a,b,c,d,e,f,g,h,l,m){Object.defineProperty(this,"id",{value:ej++});this.uuid=O.generateUUID();
24120 this.name="";this.image=void 0!==a?a:W.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:W.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:1001;this.wrapT=void 0!==d?d:1001;this.magFilter=void 0!==e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==l?l:1;this.format=void 0!==g?g:1023;this.internalFormat=null;this.type=void 0!==h?h:1009;this.offset=new v(0,0);this.repeat=new v(1,1);this.center=new v(0,0);this.rotation=0;this.matrixAutoUpdate=!0;this.matrix=new ya;this.generateMipmaps=
24121 !0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==m?m:3E3;this.version=0;this.onUpdate=null}function R(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function Ba(a,b,c){this.width=a;this.height=b;this.scissor=new R(0,0,a,b);this.scissorTest=!1;this.viewport=new R(0,0,a,b);c=c||{};this.texture=new W(void 0,c.mapping,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.texture.image={};this.texture.image.width=
24122 a;this.texture.image.height=b;this.texture.generateMipmaps=void 0!==c.generateMipmaps?c.generateMipmaps:!1;this.texture.minFilter=void 0!==c.minFilter?c.minFilter:1006;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?c.depthTexture:null}function Xf(a,b,c){Ba.call(this,a,b,c);this.samples=4}function va(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,b,
24123 c){this.x=a||0;this.y=b||0;this.z=c||0}function N(){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 Ub(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||Ub.DefaultOrder}function De(){this.mask=1}function y(){Object.defineProperty(this,"id",{value:fj++});this.uuid=O.generateUUID();this.name="";this.type="Object3D";this.parent=null;this.children=[];this.up=y.DefaultUp.clone();
24124 var a=new p,b=new Ub,c=new va,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,{position:{configurable:!0,enumerable:!0,value:a},rotation:{configurable:!0,enumerable:!0,value:b},quaternion:{configurable:!0,enumerable:!0,value:c},scale:{configurable:!0,enumerable:!0,value:d},modelViewMatrix:{value:new N},normalMatrix:{value:new ya}});this.matrix=new N;this.matrixWorld=new N;this.matrixAutoUpdate=y.DefaultMatrixAutoUpdate;
24125 this.matrixWorldNeedsUpdate=!1;this.layers=new De;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=0;this.userData={}}function zc(){y.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.environment=this.background=null;this.autoUpdate=!0;"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Va(a,b){this.min=void 0!==a?a:new p(Infinity,Infinity,Infinity);this.max=void 0!==
24126 b?b:new p(-Infinity,-Infinity,-Infinity)}function Yf(a,b,c,d,e){var f;var g=0;for(f=a.length-3;g<=f;g+=3){Vb.fromArray(a,g);var h=e.x*Math.abs(Vb.x)+e.y*Math.abs(Vb.y)+e.z*Math.abs(Vb.z),l=b.dot(Vb),m=c.dot(Vb),z=d.dot(Vb);if(Math.max(-Math.max(l,m,z),Math.min(l,m,z))>h)return!1}return!0}function eb(a,b){this.center=void 0!==a?a:new p;this.radius=void 0!==b?b:-1}function Wb(a,b){this.origin=void 0!==a?a:new p;this.direction=void 0!==b?b:new p(0,0,-1)}function Wa(a,b){this.normal=void 0!==a?a:new p(1,
24127 0,0);this.constant=void 0!==b?b:0}function pa(a,b,c){this.a=void 0!==a?a:new p;this.b=void 0!==b?b:new p;this.c=void 0!==c?c:new p}function D(a,b,c){return void 0===b&&void 0===c?this.set(a):this.setRGB(a,b,c)}function Zf(a,b,c){0>c&&(c+=1);1<c&&--c;return c<1/6?a+6*(b-a)*c:.5>c?b:c<2/3?a+6*(b-a)*(2/3-c):a}function $f(a){return.04045>a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}function ag(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}function Ac(a,b,c,d,e,f){this.a=a;this.b=
24128 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 D;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=void 0!==f?f:0}function K(){Object.defineProperty(this,"id",{value:gj++});this.uuid=O.generateUUID();this.name="";this.type="Material";this.fog=!0;this.blending=1;this.side=0;this.vertexColors=this.flatShading=!1;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha=
24129 this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=3;this.depthWrite=this.depthTest=!0;this.stencilWriteMask=255;this.stencilFunc=519;this.stencilRef=0;this.stencilFuncMask=255;this.stencilZPass=this.stencilZFail=this.stencilFail=7680;this.stencilWrite=!1;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;this.alphaTest=0;this.premultipliedAlpha=
24130 !1;this.toneMapped=this.visible=!0;this.userData={};this.version=0}function Pa(a){K.call(this);this.type="MeshBasicMaterial";this.color=new D(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.morphTargets=this.skinning=!1;this.setValues(a)}
24131 function G(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="";this.array=a;this.itemSize=b;this.count=void 0!==a?a.length/b:0;this.normalized=!0===c;this.usage=35044;this.updateRange={offset:0,count:-1};this.version=0}function yd(a,b,c){G.call(this,new Int8Array(a),b,c)}function zd(a,b,c){G.call(this,new Uint8Array(a),b,c)}function Ad(a,b,c){G.call(this,new Uint8ClampedArray(a),b,c)}function Bd(a,b,c){G.call(this,new Int16Array(a),
24132 b,c)}function Xb(a,b,c){G.call(this,new Uint16Array(a),b,c)}function Cd(a,b,c){G.call(this,new Int32Array(a),b,c)}function Yb(a,b,c){G.call(this,new Uint32Array(a),b,c)}function B(a,b,c){G.call(this,new Float32Array(a),b,c)}function Dd(a,b,c){G.call(this,new Float64Array(a),b,c)}function rh(){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=
24133 this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function sh(a){if(0===a.length)return-Infinity;for(var b=a[0],c=1,d=a.length;c<d;++c)a[c]>b&&(b=a[c]);return b}function F(){Object.defineProperty(this,"id",{value:hj+=2});this.uuid=O.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.morphTargetsRelative=!1;this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity};
24134 this.userData={}}function ea(a,b){y.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new F;this.material=void 0!==b?b:new Pa;this.updateMorphTargets()}function th(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;Ee.copy(h);Ee.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(Ee);return b<c.near||b>c.far?null:{distance:b,point:Ee.clone(),object:a}}function Fe(a,b,c,d,e,f,g,h,l,m,z,n){Db.fromBufferAttribute(e,m);Eb.fromBufferAttribute(e,
24135 z);Fb.fromBufferAttribute(e,n);e=a.morphTargetInfluences;if(b.morphTargets&&f&&e){Ge.set(0,0,0);He.set(0,0,0);Ie.set(0,0,0);for(var t=0,r=f.length;t<r;t++){var k=e[t],u=f[t];0!==k&&(bg.fromBufferAttribute(u,m),cg.fromBufferAttribute(u,z),dg.fromBufferAttribute(u,n),g?(Ge.addScaledVector(bg,k),He.addScaledVector(cg,k),Ie.addScaledVector(dg,k)):(Ge.addScaledVector(bg.sub(Db),k),He.addScaledVector(cg.sub(Eb),k),Ie.addScaledVector(dg.sub(Fb),k)))}Db.add(Ge);Eb.add(He);Fb.add(Ie)}a.isSkinnedMesh&&(a.boneTransform(m,
24136 Db),a.boneTransform(z,Eb),a.boneTransform(n,Fb));if(a=th(a,b,c,d,Db,Eb,Fb,Ed))h&&(Bc.fromBufferAttribute(h,m),Cc.fromBufferAttribute(h,z),Dc.fromBufferAttribute(h,n),a.uv=pa.getUV(Ed,Db,Eb,Fb,Bc,Cc,Dc,new v)),l&&(Bc.fromBufferAttribute(l,m),Cc.fromBufferAttribute(l,z),Dc.fromBufferAttribute(l,n),a.uv2=pa.getUV(Ed,Db,Eb,Fb,Bc,Cc,Dc,new v)),h=new Ac(m,z,n),pa.getNormal(Db,Eb,Fb,h.normal),a.face=h;return a}function L(){Object.defineProperty(this,"id",{value:ij+=2});this.uuid=O.generateUUID();this.name=
24137 "";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 Ec(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||
24138 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}function wa(a){for(var b={},c=0;c<a.length;c++){var d=Ec(a[c]),e;for(e in d)b[e]=d[e]}return b}function Ca(a){K.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}";
24139 this.linewidth=1;this.wireframe=!1;this.wireframeLinewidth=1;this.morphNormals=this.morphTargets=this.skinning=this.clipping=this.lights=this.fog=!1;this.extensions={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))}
24140 function fb(){y.call(this);this.type="Camera";this.matrixWorldInverse=new N;this.projectionMatrix=new N;this.projectionMatrixInverse=new N}function P(a,b,c,d){fb.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;this.focus=10;this.aspect=void 0!==b?b:1;this.view=null;this.filmGauge=35;this.filmOffset=0;this.updateProjectionMatrix()}function Fc(a,b,c){y.call(this);this.type="CubeCamera";if(!0!==c.isWebGLCubeRenderTarget)console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");
24141 else{this.renderTarget=c;var d=new P(90,1,a,b);d.layers=this.layers;d.up.set(0,-1,0);d.lookAt(new p(1,0,0));this.add(d);var e=new P(90,1,a,b);e.layers=this.layers;e.up.set(0,-1,0);e.lookAt(new p(-1,0,0));this.add(e);var f=new P(90,1,a,b);f.layers=this.layers;f.up.set(0,0,1);f.lookAt(new p(0,1,0));this.add(f);var g=new P(90,1,a,b);g.layers=this.layers;g.up.set(0,0,-1);g.lookAt(new p(0,-1,0));this.add(g);var h=new P(90,1,a,b);h.layers=this.layers;h.up.set(0,-1,0);h.lookAt(new p(0,0,1));this.add(h);
24142 var l=new P(90,1,a,b);l.layers=this.layers;l.up.set(0,-1,0);l.lookAt(new p(0,0,-1));this.add(l);this.update=function(a,b){null===this.parent&&this.updateMatrixWorld();var m=a.xr.enabled,z=a.getRenderTarget();a.xr.enabled=!1;var r=c.texture.generateMipmaps;c.texture.generateMipmaps=!1;a.setRenderTarget(c,0);a.render(b,d);a.setRenderTarget(c,1);a.render(b,e);a.setRenderTarget(c,2);a.render(b,f);a.setRenderTarget(c,3);a.render(b,g);a.setRenderTarget(c,4);a.render(b,h);c.texture.generateMipmaps=r;a.setRenderTarget(c,
24143 5);a.render(b,l);a.setRenderTarget(z);a.xr.enabled=m};this.clear=function(a,b,d,e){for(var f=a.getRenderTarget(),g=0;6>g;g++)a.setRenderTarget(c,g),a.clear(b,d,e);a.setRenderTarget(f)}}}function Zb(a,b,c){Number.isInteger(b)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),b=c);Ba.call(this,a,a,b)}function $b(a,b,c,d,e,f,g,h,l,m,z,n){W.call(this,null,f,g,h,l,m,d,e,z,n);this.image={data:a||null,width:b||1,height:c||1};this.magFilter=
24144 void 0!==l?l:1003;this.minFilter=void 0!==m?m:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment=1;this.needsUpdate=!0}function Gc(a,b,c,d,e,f){this.planes=[void 0!==a?a:new Wa,void 0!==b?b:new Wa,void 0!==c?c:new Wa,void 0!==d?d:new Wa,void 0!==e?e:new Wa,void 0!==f?f:new Wa]}function uh(){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),c=!0)},stop:function(){c=!1},setAnimationLoop:function(a){d=
24145 a},setContext:function(a){b=a}}}function jj(a,b){function c(b,c){var d=b.array,e=b.usage,f=a.createBuffer();a.bindBuffer(c,f);a.bufferData(c,d,e);b.onUploadCallback();c=5126;d instanceof Float32Array?c=5126:d instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):d instanceof Uint16Array?c=5123:d instanceof Int16Array?c=5122:d instanceof Uint32Array?c=5125:d instanceof Int32Array?c=5124:d instanceof Int8Array?c=5120:d instanceof Uint8Array&&(c=
24146 5121);return{buffer:f,type:c,bytesPerElement:d.BYTES_PER_ELEMENT,version:b.version}}var d=b.isWebGL2,e=new WeakMap;return{get:function(a){a.isInterleavedBufferAttribute&&(a=a.data);return e.get(a)},remove:function(b){b.isInterleavedBufferAttribute&&(b=b.data);var c=e.get(b);c&&(a.deleteBuffer(c.buffer),e.delete(b))},update:function(b,g){b.isInterleavedBufferAttribute&&(b=b.data);var f=e.get(b);if(void 0===f)e.set(b,c(b,g));else if(f.version<b.version){var l=b.array,m=b.updateRange;a.bindBuffer(g,
24147 f.buffer);-1===m.count?a.bufferSubData(g,0,l):(d?a.bufferSubData(g,m.offset*l.BYTES_PER_ELEMENT,l,m.offset,m.count):a.bufferSubData(g,m.offset*l.BYTES_PER_ELEMENT,l.subarray(m.offset,m.offset+m.count)),m.count=-1);f.version=b.version}}}}function Fd(a,b,c,d){L.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new ac(a,b,c,d));this.mergeVertices()}function ac(a,b,c,d){F.call(this);this.type="PlaneBufferGeometry";this.parameters=
24148 {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,l=a/c,m=b/d,z=[],n=[],t=[],r=[];for(a=0;a<h;a++){var k=a*m-f;for(b=0;b<g;b++)n.push(b*l-e,-k,0),t.push(0,0,1),r.push(b/c),r.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,z.push(b+g*a,e,h),z.push(e,f,h);this.setIndex(z);this.setAttribute("position",new B(n,3));this.setAttribute("normal",new B(t,3));this.setAttribute("uv",new B(r,2))}
24149 function kj(a,b,c,d){function e(a,c){b.buffers.color.setClear(a.r,a.g,a.b,c,d)}var f=new D(0),g=0,h,l,m=null,z=0,n=null;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,d,k,u){d=d.background;k=a.xr;(k=k.getSession&&k.getSession())&&"additive"===k.environmentBlendMode&&(d=null);null===d?e(f,g):d&&d.isColor&&(e(d,1),u=!0);(a.autoClear||u)&&a.clear(a.autoClearColor,
24150 a.autoClearDepth,a.autoClearStencil);if(d&&(d.isCubeTexture||d.isWebGLCubeRenderTarget||306===d.mapping)){void 0===l&&(l=new ea(new Gd(1,1,1),new Ca({type:"BackgroundCubeMaterial",uniforms:Ec(gb.cube.uniforms),vertexShader:gb.cube.vertexShader,fragmentShader:gb.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(a,b,c){this.matrixWorld.copyPosition(c.matrixWorld)},Object.defineProperty(l.material,
24151 "envMap",{get:function(){return this.uniforms.envMap.value}}),c.update(l));u=d.isWebGLCubeRenderTarget?d.texture:d;l.material.uniforms.envMap.value=u;l.material.uniforms.flipEnvMap.value=u.isCubeTexture?-1:1;if(m!==d||z!==u.version||n!==a.toneMapping)l.material.needsUpdate=!0,m=d,z=u.version,n=a.toneMapping;b.unshift(l,l.geometry,l.material,0,0,null)}else if(d&&d.isTexture){void 0===h&&(h=new ea(new ac(2,2),new Ca({type:"BackgroundMaterial",uniforms:Ec(gb.background.uniforms),vertexShader:gb.background.vertexShader,
24152 fragmentShader:gb.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),c.update(h));h.material.uniforms.t2D.value=d;!0===d.matrixAutoUpdate&&d.updateMatrix();h.material.uniforms.uvTransform.value.copy(d.matrix);if(m!==d||z!==d.version||n!==a.toneMapping)h.material.needsUpdate=!0,m=d,z=d.version,n=a.toneMapping;b.unshift(h,h.geometry,h.material,0,0,null)}}}}
24153 function lj(a,b,c,d){var e=d.isWebGL2,f;this.setMode=function(a){f=a};this.render=function(b,d){a.drawArrays(f,b,d);c.update(d,f)};this.renderInstances=function(d,h,l,m){if(0!==m){if(e){d=a;var g="drawArraysInstanced"}else if(d=b.get("ANGLE_instanced_arrays"),g="drawArraysInstancedANGLE",null===d){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[g](f,h,l,m);c.update(l,f,m)}}}function mj(a,b,c){function d(b){if("highp"===
24154 b){if(0<a.getShaderPrecisionFormat(35633,36338).precision&&0<a.getShaderPrecisionFormat(35632,36338).precision)return"highp";b="mediump"}return"mediump"===b&&0<a.getShaderPrecisionFormat(35633,36337).precision&&0<a.getShaderPrecisionFormat(35632,36337).precision?"mediump":"lowp"}var e,f="undefined"!==typeof WebGL2RenderingContext&&a instanceof WebGL2RenderingContext||"undefined"!==typeof WebGL2ComputeRenderingContext&&a instanceof WebGL2ComputeRenderingContext,g=void 0!==c.precision?c.precision:"highp",
24155 h=d(g);h!==g&&(console.warn("THREE.WebGLRenderer:",g,"not supported, using",h,"instead."),g=h);c=!0===c.logarithmicDepthBuffer;h=a.getParameter(34930);var l=a.getParameter(35660),m=a.getParameter(3379),z=a.getParameter(34076),n=a.getParameter(34921),k=a.getParameter(36347),r=a.getParameter(36348),q=a.getParameter(36349),u=0<l,p=f||!!b.get("OES_texture_float"),x=u&&p,w=f?a.getParameter(36183):0;return{isWebGL2:f,getMaxAnisotropy:function(){if(void 0!==e)return e;var c=b.get("EXT_texture_filter_anisotropic");
24156 return e=null!==c?a.getParameter(c.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:d,precision:g,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:l,maxTextureSize:m,maxCubemapSize:z,maxAttributes:n,maxVertexUniforms:k,maxVaryings:r,maxFragmentUniforms:q,vertexTextures:u,floatFragmentTextures:p,floatVertexTextures:x,maxSamples:w}}function nj(){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!==
24157 f){g=m.value;if(!0!==e||null===g){e=d+4*f;b=b.matrixWorldInverse;l.getNormalMatrix(b);if(null===g||g.length<e)g=new Float32Array(e);for(e=0;e!==f;++e,d+=4)h.copy(a[e]).applyMatrix4(b,l),h.normal.toArray(g,d),g[d+3]=h.constant}m.value=g;m.needsUpdate=!0}c.numPlanes=f;c.numIntersection=0;return g}var c=this,d=null,e=0,f=!1,g=!1,h=new Wa,l=new ya,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);
24158 e=a.length;return h};this.beginShadows=function(){g=!0;b(null)};this.endShadows=function(){g=!1;a()};this.setState=function(c,h,l,k,q,u){if(!f||null===c||0===c.length||g&&!l)g?b(null):a();else{l=g?0:e;var n=4*l,z=q.clippingState||null;m.value=z;z=b(c,k,n,u);for(c=0;c!==n;++c)z[c]=d[c];q.clippingState=z;this.numIntersection=h?this.numPlanes:0;this.numPlanes+=l}}}function oj(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")||
24159 a.getExtension("MOZ_WEBGL_depth_texture")||a.getExtension("WEBKIT_WEBGL_depth_texture");break;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;
24160 case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported.");return b[c]=d}}}function pj(a,b,c){function d(a){var e=a.target;a=f.get(e);null!==a.index&&b.remove(a.index);for(var h in a.attributes)b.remove(a.attributes[h]);e.removeEventListener("dispose",d);f.delete(e);if(h=g.get(a))b.remove(h),g.delete(a);
24161 c.memory.geometries--}function e(a){var c=[],d=a.index,e=a.attributes.position;if(null!==d){var f=d.array;d=d.version;e=0;for(var h=f.length;e<h;e+=3){var k=f[e+0],q=f[e+1],u=f[e+2];c.push(k,q,q,u,u,k)}}else for(f=e.array,d=e.version,e=0,h=f.length/3-1;e<h;e+=3)k=e+0,q=e+1,u=e+2,c.push(k,q,q,u,u,k);c=new (65535<sh(c)?Yb:Xb)(c,1);c.version=d;b.update(c,34963);(f=g.get(a))&&b.remove(f);g.set(a,c)}var f=new WeakMap,g=new WeakMap;return{get:function(a,b){var e=f.get(b);if(e)return e;b.addEventListener("dispose",
24162 d);b.isBufferGeometry?e=b:b.isGeometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=(new F).setFromObject(a)),e=b._bufferGeometry);f.set(b,e);c.memory.geometries++;return e},update:function(a){var c=a.index,d=a.attributes;null!==c&&b.update(c,34963);for(var e in d)b.update(d[e],34962);a=a.morphAttributes;for(e in a){c=a[e];d=0;for(var f=c.length;d<f;d++)b.update(c[d],34962)}},getWireframeAttribute:function(a){var b=g.get(a);if(b){var c=a.index;null!==c&&b.version<c.version&&e(a)}else e(a);return g.get(a)}}}
24163 function qj(a,b,c,d){var e=d.isWebGL2,f,g,h;this.setMode=function(a){f=a};this.setIndex=function(a){g=a.type;h=a.bytesPerElement};this.render=function(b,d){a.drawElements(f,d,g,b*h);c.update(d,f)};this.renderInstances=function(d,m,z,n){if(0!==n){if(e){d=a;var l="drawElementsInstanced"}else if(d=b.get("ANGLE_instanced_arrays"),l="drawElementsInstancedANGLE",null===d){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
24164 return}d[l](f,z,g,m*h,n);c.update(z,f,n)}}}function rj(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++;b.calls=0;b.triangles=0;b.points=0;b.lines=0},update:function(a,d,e){e=e||1;b.calls++;switch(d){case 4:b.triangles+=a/3*e;break;case 1:b.lines+=a/2*e;break;case 3:b.lines+=e*(a-1);break;case 2:b.lines+=e*a;break;case 0:b.points+=e*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",
24165 d)}}}}function sj(a,b){return Math.abs(b[1])-Math.abs(a[1])}function tj(a){var b={},c=new Float32Array(8);return{update:function(d,e,f,g){var h=d.morphTargetInfluences,l=void 0===h?0:h.length;d=b[e.id];if(void 0===d){d=[];for(var m=0;m<l;m++)d[m]=[m,0];b[e.id]=d}var z=f.morphTargets&&e.morphAttributes.position;f=f.morphNormals&&e.morphAttributes.normal;for(m=0;m<l;m++){var n=d[m];0!==n[1]&&(z&&e.deleteAttribute("morphTarget"+m),f&&e.deleteAttribute("morphNormal"+m))}for(m=0;m<l;m++)n=d[m],n[0]=m,
24166 n[1]=h[m];d.sort(sj);for(m=h=0;8>m;m++){if(n=d[m])if(l=n[0],n=n[1]){z&&e.setAttribute("morphTarget"+m,z[l]);f&&e.setAttribute("morphNormal"+m,f[l]);c[m]=n;h+=n;continue}c[m]=0}e=e.morphTargetsRelative?1:1-h;g.getUniforms().setValue(a,"morphTargetBaseInfluence",e);g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function uj(a,b,c,d){var e=new WeakMap;return{update:function(a){var f=d.render.frame,h=a.geometry,l=b.get(a,h);e.get(l)!==f&&(h.isGeometry&&l.updateFromObject(a),b.update(l),e.set(l,
24167 f));a.isInstancedMesh&&c.update(a.instanceMatrix,34962);return l},dispose:function(){e=new WeakMap}}}function qb(a,b,c,d,e,f,g,h,l,m){a=void 0!==a?a:[];W.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!==g?g:1022,h,l,m);this.flipY=!1}function Hc(a,b,c,d){W.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Ic(a,b,c,d){W.call(this,null);this.image={data:a||null,width:b||
24168 1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Jc(a,b,c){var d=a[0];if(0>=d||0<d)return a;var e=b*c,f=vh[e];void 0===f&&(f=new Float32Array(e),vh[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 Qa(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 Ja(a,b){for(var c=0,d=b.length;c<d;c++)a[c]=b[c]}function wh(a,
24169 b){var c=xh[b];void 0===c&&(c=new Int32Array(b),xh[b]=c);for(var d=0;d!==b;++d)c[d]=a.allocateTextureUnit();return c}function vj(a,b){var c=this.cache;c[0]!==b&&(a.uniform1f(this.addr,b),c[0]=b)}function wj(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 Qa(c,b)||(a.uniform2fv(this.addr,b),Ja(c,b))}function xj(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,
24170 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 Qa(c,b)||(a.uniform3fv(this.addr,b),Ja(c,b))}function yj(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 Qa(c,b)||(a.uniform4fv(this.addr,b),Ja(c,b))}function zj(a,b){var c=this.cache,d=b.elements;void 0===d?Qa(c,b)||(a.uniformMatrix2fv(this.addr,
24171 !1,b),Ja(c,b)):Qa(c,d)||(yh.set(d),a.uniformMatrix2fv(this.addr,!1,yh),Ja(c,d))}function Aj(a,b){var c=this.cache,d=b.elements;void 0===d?Qa(c,b)||(a.uniformMatrix3fv(this.addr,!1,b),Ja(c,b)):Qa(c,d)||(zh.set(d),a.uniformMatrix3fv(this.addr,!1,zh),Ja(c,d))}function Bj(a,b){var c=this.cache,d=b.elements;void 0===d?Qa(c,b)||(a.uniformMatrix4fv(this.addr,!1,b),Ja(c,b)):Qa(c,d)||(Ah.set(d),a.uniformMatrix4fv(this.addr,!1,Ah),Ja(c,d))}function Cj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==
24172 e&&(a.uniform1i(this.addr,e),d[0]=e);c.safeSetTexture2D(b||Bh,e)}function Dj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture2DArray(b||Ej,e)}function Fj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture3D(b||Gj,e)}function Hj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.safeSetTextureCube(b||Ch,e)}function Ij(a,b){var c=this.cache;c[0]!==
24173 b&&(a.uniform1i(this.addr,b),c[0]=b)}function Jj(a,b){var c=this.cache;Qa(c,b)||(a.uniform2iv(this.addr,b),Ja(c,b))}function Kj(a,b){var c=this.cache;Qa(c,b)||(a.uniform3iv(this.addr,b),Ja(c,b))}function Lj(a,b){var c=this.cache;Qa(c,b)||(a.uniform4iv(this.addr,b),Ja(c,b))}function Mj(a,b){var c=this.cache;c[0]!==b&&(a.uniform1ui(this.addr,b),c[0]=b)}function Nj(a){switch(a){case 5126:return vj;case 35664:return wj;case 35665:return xj;case 35666:return yj;case 35674:return zj;case 35675:return Aj;
24174 case 35676:return Bj;case 5124:case 35670:return Ij;case 35667:case 35671:return Jj;case 35668:case 35672:return Kj;case 35669:case 35673:return Lj;case 5125:return Mj;case 35678:case 36198:case 36298:case 36306:case 35682:return Cj;case 35679:case 36299:case 36307:return Fj;case 35680:case 36300:case 36308:case 36293:return Hj;case 36289:case 36303:case 36311:case 36292:return Dj}}function Oj(a,b){a.uniform1fv(this.addr,b)}function Pj(a,b){a.uniform1iv(this.addr,b)}function Qj(a,b){a.uniform2iv(this.addr,
24175 b)}function Rj(a,b){a.uniform3iv(this.addr,b)}function Sj(a,b){a.uniform4iv(this.addr,b)}function Tj(a,b){b=Jc(b,this.size,2);a.uniform2fv(this.addr,b)}function Uj(a,b){b=Jc(b,this.size,3);a.uniform3fv(this.addr,b)}function Vj(a,b){b=Jc(b,this.size,4);a.uniform4fv(this.addr,b)}function Wj(a,b){b=Jc(b,this.size,4);a.uniformMatrix2fv(this.addr,!1,b)}function Xj(a,b){b=Jc(b,this.size,9);a.uniformMatrix3fv(this.addr,!1,b)}function Yj(a,b){b=Jc(b,this.size,16);a.uniformMatrix4fv(this.addr,!1,b)}function Zj(a,
24176 b,c){var d=b.length,e=wh(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.safeSetTexture2D(b[a]||Bh,e[a])}function ak(a,b,c){var d=b.length,e=wh(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.safeSetTextureCube(b[a]||Ch,e[a])}function bk(a){switch(a){case 5126:return Oj;case 35664:return Tj;case 35665:return Uj;case 35666:return Vj;case 35674:return Wj;case 35675:return Xj;case 35676:return Yj;case 5124:case 35670:return Pj;case 35667:case 35671:return Qj;case 35668:case 35672:return Rj;case 35669:case 35673:return Sj;
24177 case 35678:case 36198:case 36298:case 36306:case 35682:return Zj;case 35680:case 36300:case 36308:case 36293:return ak}}function ck(a,b,c){this.id=a;this.addr=c;this.cache=[];this.setValue=Nj(b.type)}function Dh(a,b,c){this.id=a;this.addr=c;this.cache=[];this.size=b.size;this.setValue=bk(b.type)}function Eh(a){this.id=a;this.seq=[];this.map={}}function Gb(a,b){this.seq=[];this.map={};for(var c=a.getProgramParameter(b,35718),d=0;d<c;++d){var e=a.getActiveUniform(b,d),f=a.getUniformLocation(b,e.name),
24178 g=this,h=e.name,l=h.length;for(eg.lastIndex=0;;){var m=eg.exec(h),z=eg.lastIndex,n=m[1],k=m[3];"]"===m[2]&&(n|=0);if(void 0===k||"["===k&&z+2===l){h=g;e=void 0===k?new ck(n,e,f):new Dh(n,e,f);h.seq.push(e);h.map[e.id]=e;break}else k=g.map[n],void 0===k&&(k=new Eh(n),n=g,g=k,n.seq.push(g),n.map[g.id]=g),g=k}}}function Fh(a,b,c){b=a.createShader(b);a.shaderSource(b,c);a.compileShader(b);return b}function Gh(a){switch(a){case 3E3:return["Linear","( value )"];case 3001:return["sRGB","( value )"];case 3002:return["RGBE",
24179 "( 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 ) )"];case 3003:return["LogLuv","( value )"];default:throw Error("unsupported encoding: "+a);}}function Hh(a,b,c){var d=a.getShaderParameter(b,35713),e=a.getShaderInfoLog(b).trim();if(d&&""===e)return"";a=a.getShaderSource(b).split("\n");for(b=0;b<a.length;b++)a[b]=b+1+": "+a[b];a=a.join("\n");return"THREE.WebGLShader: gl.getShaderInfoLog() "+
24180 c+"\n"+e+a}function Hd(a,b){b=Gh(b);return"vec4 "+a+"( vec4 value ) { return "+b[0]+"ToLinear"+b[1]+"; }"}function dk(a,b){b=Gh(b);return"vec4 "+a+"( vec4 value ) { return LinearTo"+b[0]+b[1]+"; }"}function ek(a,b){switch(b){case 1:b="Linear";break;case 2:b="Reinhard";break;case 3:b="Uncharted2";break;case 4:b="OptimizedCineon";break;case 5:b="ACESFilmic";break;default:throw Error("unsupported toneMapping: "+b);}return"vec3 "+a+"( vec3 color ) { return "+b+"ToneMapping( color ); }"}function fk(a){var b=
24181 [],c;for(c in a){var d=a[c];!1!==d&&b.push("#define "+c+" "+d)}return b.join("\n")}function Id(a){return""!==a}function Ih(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).replace(/NUM_DIR_LIGHT_SHADOWS/g,b.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,b.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,
24182 b.numPointLightShadows)}function Jh(a,b){return a.replace(/NUM_CLIPPING_PLANES/g,b.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,b.numClippingPlanes-b.numClipIntersection)}function fg(a,b){a=M[b];if(void 0===a)throw Error("Can not resolve #include <"+b+">");return a.replace(gg,fg)}function Kh(a,b,c,d){console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.");return hg(a,b,c,d)}function hg(a,b,c,d){a="";for(b=parseInt(b);b<
24183 parseInt(c);b++)a+=d.replace(/\[ i \]/g,"[ "+b+" ]").replace(/UNROLLED_LOOP_INDEX/g,b);return a}function Lh(a){var b="precision "+a.precision+" float;\nprecision "+a.precision+" int;";"highp"===a.precision?b+="\n#define HIGH_PRECISION":"mediump"===a.precision?b+="\n#define MEDIUM_PRECISION":"lowp"===a.precision&&(b+="\n#define LOW_PRECISION");return b}function gk(a){var b="SHADOWMAP_TYPE_BASIC";1===a.shadowMapType?b="SHADOWMAP_TYPE_PCF":2===a.shadowMapType?b="SHADOWMAP_TYPE_PCF_SOFT":3===a.shadowMapType&&
24184 (b="SHADOWMAP_TYPE_VSM");return b}function hk(a){var b="ENVMAP_TYPE_CUBE";if(a.envMap)switch(a.envMapMode){case 301:case 302:b="ENVMAP_TYPE_CUBE";break;case 306:case 307:b="ENVMAP_TYPE_CUBE_UV";break;case 303:case 304:b="ENVMAP_TYPE_EQUIREC";break;case 305:b="ENVMAP_TYPE_SPHERE"}return b}function ik(a){var b="ENVMAP_MODE_REFLECTION";if(a.envMap)switch(a.envMapMode){case 302:case 304:b="ENVMAP_MODE_REFRACTION"}return b}function jk(a){var b="ENVMAP_BLENDING_NONE";if(a.envMap)switch(a.combine){case 0:b=
24185 "ENVMAP_BLENDING_MULTIPLY";break;case 1:b="ENVMAP_BLENDING_MIX";break;case 2:b="ENVMAP_BLENDING_ADD"}return b}function kk(a,b,c){var d=a.getContext(),e=c.defines,f=c.vertexShader,g=c.fragmentShader,h=gk(c),l=hk(c),m=ik(c),z=jk(c),n=0<a.gammaFactor?a.gammaFactor:1,k=c.isWebGL2?"":[c.extensionDerivatives||c.envMapCubeUV||c.bumpMap||c.tangentSpaceNormalMap||c.clearcoatNormalMap||c.flatShading||"physical"===c.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(c.extensionFragDepth||c.logarithmicDepthBuffer)&&
24186 c.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",c.extensionDrawBuffers&&c.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(c.extensionShaderTextureLOD||c.envMap)&&c.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Id).join("\n"),r=fk(e),q=d.createProgram();c.isRawShaderMaterial?(e=[r].filter(Id).join("\n"),0<e.length&&(e+="\n"),h=[k,r].filter(Id).join("\n"),0<h.length&&(h+="\n")):(e=[Lh(c),"#define SHADER_NAME "+
24187 c.shaderName,r,c.instancing?"#define USE_INSTANCING":"",c.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+n,"#define MAX_BONES "+c.maxBones,c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.envMap?"#define "+m:"",c.lightMap?"#define USE_LIGHTMAP":"",c.aoMap?"#define USE_AOMAP":"",c.emissiveMap?"#define USE_EMISSIVEMAP":"",c.bumpMap?"#define USE_BUMPMAP":"",c.normalMap?"#define USE_NORMALMAP":
24188 "",c.normalMap&&c.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",c.normalMap&&c.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",c.clearcoatMap?"#define USE_CLEARCOATMAP":"",c.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",c.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",c.displacementMap&&c.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",c.specularMap?"#define USE_SPECULARMAP":"",c.roughnessMap?"#define USE_ROUGHNESSMAP":"",c.metalnessMap?"#define USE_METALNESSMAP":
24189 "",c.alphaMap?"#define USE_ALPHAMAP":"",c.vertexTangents?"#define USE_TANGENT":"",c.vertexColors?"#define USE_COLOR":"",c.vertexUvs?"#define USE_UV":"",c.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",c.flatShading?"#define FLAT_SHADED":"",c.skinning?"#define USE_SKINNING":"",c.useVertexTexture?"#define BONE_TEXTURE":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals&&!1===c.flatShading?"#define USE_MORPHNORMALS":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.flipSided?"#define FLIP_SIDED":
24190 "",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapEnabled?"#define "+h:"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"",c.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",c.logarithmicDepthBuffer&&c.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING",
24191 " attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#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;",
24192 "\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","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Id).join("\n"),h=[k,Lh(c),"#define SHADER_NAME "+c.shaderName,r,c.alphaTest?"#define ALPHATEST "+c.alphaTest+(c.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+n,c.useFog&&c.fog?"#define USE_FOG":
24193 "",c.useFog&&c.fogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.matcap?"#define USE_MATCAP":"",c.envMap?"#define USE_ENVMAP":"",c.envMap?"#define "+l:"",c.envMap?"#define "+m:"",c.envMap?"#define "+z:"",c.lightMap?"#define USE_LIGHTMAP":"",c.aoMap?"#define USE_AOMAP":"",c.emissiveMap?"#define USE_EMISSIVEMAP":"",c.bumpMap?"#define USE_BUMPMAP":"",c.normalMap?"#define USE_NORMALMAP":"",c.normalMap&&c.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",c.normalMap&&c.tangentSpaceNormalMap?
24194 "#define TANGENTSPACE_NORMALMAP":"",c.clearcoatMap?"#define USE_CLEARCOATMAP":"",c.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",c.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",c.specularMap?"#define USE_SPECULARMAP":"",c.roughnessMap?"#define USE_ROUGHNESSMAP":"",c.metalnessMap?"#define USE_METALNESSMAP":"",c.alphaMap?"#define USE_ALPHAMAP":"",c.sheen?"#define USE_SHEEN":"",c.vertexTangents?"#define USE_TANGENT":"",c.vertexColors?"#define USE_COLOR":"",c.vertexUvs?"#define USE_UV":
24195 "",c.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",c.gradientMap?"#define USE_GRADIENTMAP":"",c.flatShading?"#define FLAT_SHADED":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.flipSided?"#define FLIP_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapEnabled?"#define "+h:"",c.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",c.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",c.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",c.logarithmicDepthBuffer&&c.rendererExtensionFragDepth?
24196 "#define USE_LOGDEPTHBUF_EXT":"",(c.extensionShaderTextureLOD||c.envMap)&&c.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==c.toneMapping?"#define TONE_MAPPING":"",0!==c.toneMapping?M.tonemapping_pars_fragment:"",0!==c.toneMapping?ek("toneMapping",c.toneMapping):"",c.dithering?"#define DITHERING":"",c.outputEncoding||c.mapEncoding||c.matcapEncoding||c.envMapEncoding||c.emissiveMapEncoding||
24197 c.lightMapEncoding?M.encodings_pars_fragment:"",c.mapEncoding?Hd("mapTexelToLinear",c.mapEncoding):"",c.matcapEncoding?Hd("matcapTexelToLinear",c.matcapEncoding):"",c.envMapEncoding?Hd("envMapTexelToLinear",c.envMapEncoding):"",c.emissiveMapEncoding?Hd("emissiveMapTexelToLinear",c.emissiveMapEncoding):"",c.lightMapEncoding?Hd("lightMapTexelToLinear",c.lightMapEncoding):"",c.outputEncoding?dk("linearToOutputTexel",c.outputEncoding):"",c.depthPacking?"#define DEPTH_PACKING "+c.depthPacking:"","\n"].filter(Id).join("\n"));
24198 f=f.replace(gg,fg);f=Ih(f,c);f=Jh(f,c);g=g.replace(gg,fg);g=Ih(g,c);g=Jh(g,c);f=f.replace(Mh,hg).replace(Nh,Kh);g=g.replace(Mh,hg).replace(Nh,Kh);c.isWebGL2&&!c.isRawShaderMaterial&&(l=!1,m=/^\s*#version\s+300\s+es\s*\n/,c.isShaderMaterial&&null!==f.match(m)&&null!==g.match(m)&&(l=!0,f=f.replace(m,""),g=g.replace(m,"")),e="#version 300 es\n\n#define attribute in\n#define varying out\n#define texture2D texture\n"+e,h=["#version 300 es\n\n#define varying in",l?"":"out highp vec4 pc_fragColor;",l?"":
24199 "#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")+"\n"+h);g=h+g;f=Fh(d,35633,e+f);g=Fh(d,35632,g);d.attachShader(q,f);d.attachShader(q,
24200 g);void 0!==c.index0AttributeName?d.bindAttribLocation(q,0,c.index0AttributeName):!0===c.morphTargets&&d.bindAttribLocation(q,0,"position");d.linkProgram(q);if(a.debug.checkShaderErrors){a=d.getProgramInfoLog(q).trim();l=d.getShaderInfoLog(f).trim();m=d.getShaderInfoLog(g).trim();n=z=!0;if(!1===d.getProgramParameter(q,35714))z=!1,k=Hh(d,f,"vertex"),r=Hh(d,g,"fragment"),console.error("THREE.WebGLProgram: shader error: ",d.getError(),"35715",d.getProgramParameter(q,35715),"gl.getProgramInfoLog",a,k,
24201 r);else if(""!==a)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",a);else if(""===l||""===m)n=!1;n&&(this.diagnostics={runnable:z,programLog:a,vertexShader:{log:l,prefix:e},fragmentShader:{log:m,prefix:h}})}d.deleteShader(f);d.deleteShader(g);var u;this.getUniforms=function(){void 0===u&&(u=new Gb(d,q));return u};var p;this.getAttributes=function(){if(void 0===p){for(var a={},b=d.getProgramParameter(q,35721),c=0;c<b;c++){var e=d.getActiveAttrib(q,c).name;a[e]=d.getAttribLocation(q,e)}p=
24202 a}return p};this.destroy=function(){d.deleteProgram(q);this.program=void 0};this.name=c.shaderName;this.id=lk++;this.cacheKey=b;this.usedTimes=1;this.program=q;this.vertexShader=f;this.fragmentShader=g;return this}function mk(a,b,c){function d(a){if(a)a.isTexture?b=a.encoding:a.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),b=a.texture.encoding);else var b=3E3;return b}var e=[],f=c.isWebGL2,
24203 g=c.logarithmicDepthBuffer,h=c.floatVertexTextures,l=c.precision,m=c.maxVertexUniforms,z=c.vertexTextures,n={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},
24204 k="precision isWebGL2 supportsVertexTextures outputEncoding instancing map mapEncoding matcap matcapEncoding envMap envMapMode envMapEncoding envMapCubeUV lightMap lightMapEncoding aoMap emissiveMap emissiveMapEncoding bumpMap normalMap objectSpaceNormalMap tangentSpaceNormalMap clearcoatMap clearcoatRoughnessMap clearcoatNormalMap displacementMap specularMap roughnessMap metalnessMap gradientMap alphaMap combine vertexColors vertexTangents vertexUvs uvsVertexOnly fog useFog fogExp2 flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTargets maxMorphNormals premultipliedAlpha numDirLights numPointLights numSpotLights numHemiLights numRectAreaLights numDirLightShadows numPointLightShadows numSpotLightShadows shadowMapEnabled shadowMapType toneMapping physicallyCorrectLights alphaTest doubleSided flipSided numClippingPlanes numClipIntersection depthPacking dithering sheen".split(" ");
24205 this.getParameters=function(e,k,t,p,x,w,ja){var q=p.fog;p=e.isMeshStandardMaterial?p.environment:null;p=e.envMap||p;var r=n[e.type];if(ja.isSkinnedMesh){var u=ja.skeleton.bones;if(h)u=1024;else{var E=Math.min(Math.floor((m-20)/4),u.length);E<u.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+u.length+" bones. This GPU supports "+E+"."),u=0):u=E}}else u=0;null!==e.precision&&(l=c.getMaxPrecision(e.precision),l!==e.precision&&console.warn("THREE.WebGLProgram.getParameters:",e.precision,"not supported, using",
24206 l,"instead."));r?(E=gb[r],E={name:e.type,uniforms:Oh.clone(E.uniforms),vertexShader:E.vertexShader,fragmentShader:E.fragmentShader}):E={name:e.type,uniforms:e.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader};e.onBeforeCompile(E,a);var v=a.getRenderTarget();return{isWebGL2:f,shaderID:r,shaderName:E.name,uniforms:E.uniforms,vertexShader:E.vertexShader,fragmentShader:E.fragmentShader,defines:e.defines,isRawShaderMaterial:e.isRawShaderMaterial,isShaderMaterial:e.isShaderMaterial,
24207 precision:l,instancing:!0===ja.isInstancedMesh,supportsVertexTextures:z,outputEncoding:null!==v?d(v.texture):a.outputEncoding,map:!!e.map,mapEncoding:d(e.map),matcap:!!e.matcap,matcapEncoding:d(e.matcap),envMap:!!p,envMapMode:p&&p.mapping,envMapEncoding:d(p),envMapCubeUV:!!p&&(306===p.mapping||307===p.mapping),lightMap:!!e.lightMap,lightMapEncoding:d(e.lightMap),aoMap:!!e.aoMap,emissiveMap:!!e.emissiveMap,emissiveMapEncoding:d(e.emissiveMap),bumpMap:!!e.bumpMap,normalMap:!!e.normalMap,objectSpaceNormalMap:1===
24208 e.normalMapType,tangentSpaceNormalMap:0===e.normalMapType,clearcoatMap:!!e.clearcoatMap,clearcoatRoughnessMap:!!e.clearcoatRoughnessMap,clearcoatNormalMap:!!e.clearcoatNormalMap,displacementMap:!!e.displacementMap,roughnessMap:!!e.roughnessMap,metalnessMap:!!e.metalnessMap,specularMap:!!e.specularMap,alphaMap:!!e.alphaMap,gradientMap:!!e.gradientMap,sheen:!!e.sheen,combine:e.combine,vertexTangents:e.normalMap&&e.vertexTangents,vertexColors:e.vertexColors,vertexUvs:!!e.map||!!e.bumpMap||!!e.normalMap||
24209 !!e.specularMap||!!e.alphaMap||!!e.emissiveMap||!!e.roughnessMap||!!e.metalnessMap||!!e.clearcoatMap||!!e.clearcoatRoughnessMap||!!e.clearcoatNormalMap||!!e.displacementMap,uvsVertexOnly:!(e.map||e.bumpMap||e.normalMap||e.specularMap||e.alphaMap||e.emissiveMap||e.roughnessMap||e.metalnessMap||e.clearcoatNormalMap)&&!!e.displacementMap,fog:!!q,useFog:e.fog,fogExp2:q&&q.isFogExp2,flatShading:e.flatShading,sizeAttenuation:e.sizeAttenuation,logarithmicDepthBuffer:g,skinning:e.skinning&&0<u,maxBones:u,
24210 useVertexTexture:h,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:a.maxMorphTargets,maxMorphNormals:a.maxMorphNormals,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numClippingPlanes:x,numClipIntersection:w,dithering:e.dithering,shadowMapEnabled:a.shadowMap.enabled&&
24211 0<t.length,shadowMapType:a.shadowMap.type,toneMapping:e.toneMapped?a.toneMapping:0,physicallyCorrectLights:a.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:2===e.side,flipSided:1===e.side,depthPacking:void 0!==e.depthPacking?e.depthPacking:!1,index0AttributeName:e.index0AttributeName,extensionDerivatives:e.extensions&&e.extensions.derivatives,extensionFragDepth:e.extensions&&e.extensions.fragDepth,extensionDrawBuffers:e.extensions&&e.extensions.drawBuffers,
24212 extensionShaderTextureLOD:e.extensions&&e.extensions.shaderTextureLOD,rendererExtensionFragDepth:f||null!==b.get("EXT_frag_depth"),rendererExtensionDrawBuffers:f||null!==b.get("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:f||null!==b.get("EXT_shader_texture_lod"),onBeforeCompile:e.onBeforeCompile}};this.getProgramCacheKey=function(b){var c=[];b.shaderID?c.push(b.shaderID):(c.push(b.fragmentShader),c.push(b.vertexShader));if(void 0!==b.defines)for(var d in b.defines)c.push(d),c.push(b.defines[d]);
24213 if(void 0===b.isRawShaderMaterial){for(d=0;d<k.length;d++)c.push(b[k[d]]);c.push(a.outputEncoding);c.push(a.gammaFactor)}c.push(b.onBeforeCompile.toString());return c.join()};this.acquireProgram=function(b,c){for(var d,f=0,g=e.length;f<g;f++){var h=e[f];if(h.cacheKey===c){d=h;++d.usedTimes;break}}void 0===d&&(d=new kk(a,c,b),e.push(d));return d};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 nk(){var a=new WeakMap;
24214 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 ok(a,b){return a.groupOrder!==b.groupOrder?a.groupOrder-b.groupOrder:a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder: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 pk(a,b){return a.groupOrder!==b.groupOrder?
24215 a.groupOrder-b.groupOrder:a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function Ph(){function a(a,d,e,m,z,n){var g=b[c];void 0===g?(g={id:a.id,object:a,geometry:d,material:e,program:e.program||f,groupOrder:m,renderOrder:a.renderOrder,z:z,group:n},b[c]=g):(g.id=a.id,g.object=a,g.geometry=d,g.material=e,g.program=e.program||f,g.groupOrder=m,g.renderOrder=a.renderOrder,g.z=z,g.group=n);c++;return g}var b=[],c=0,d=[],e=[],f={id:-1};return{opaque:d,transparent:e,
24216 init:function(){c=0;d.length=0;e.length=0},push:function(b,c,f,m,z,n){b=a(b,c,f,m,z,n);(!0===f.transparent?e:d).push(b)},unshift:function(b,c,f,m,z,n){b=a(b,c,f,m,z,n);(!0===f.transparent?e:d).unshift(b)},finish:function(){for(var a=c,d=b.length;a<d;a++){var e=b[a];if(null===e.id)break;e.id=null;e.object=null;e.geometry=null;e.material=null;e.program=null;e.group=null}},sort:function(a,b){1<d.length&&d.sort(a||ok);1<e.length&&e.sort(b||pk)}}}function qk(){function a(c){c=c.target;c.removeEventListener("dispose",
24217 a);b.delete(c)}var b=new WeakMap;return{get:function(c,d){var e=b.get(c);if(void 0===e){var f=new Ph;b.set(c,new WeakMap);b.get(c).set(d,f);c.addEventListener("dispose",a)}else f=e.get(d),void 0===f&&(f=new Ph,e.set(d,f));return f},dispose:function(){b=new WeakMap}}}function rk(){var a={};return{get:function(b){if(void 0!==a[b.id])return a[b.id];switch(b.type){case "DirectionalLight":var c={direction:new p,color:new D};break;case "SpotLight":c={position:new p,direction:new p,color:new D,distance:0,
24218 coneCos:0,penumbraCos:0,decay:0};break;case "PointLight":c={position:new p,color:new D,distance:0,decay:0};break;case "HemisphereLight":c={direction:new p,skyColor:new D,groundColor:new D};break;case "RectAreaLight":c={color:new D,position:new p,halfWidth:new p,halfHeight:new p}}return a[b.id]=c}}}function sk(){var a={};return{get:function(b){if(void 0!==a[b.id])return a[b.id];switch(b.type){case "DirectionalLight":var c={shadowBias:0,shadowRadius:1,shadowMapSize:new v};break;case "SpotLight":c={shadowBias:0,
24219 shadowRadius:1,shadowMapSize:new v};break;case "PointLight":c={shadowBias:0,shadowRadius:1,shadowMapSize:new v,shadowCameraNear:1,shadowCameraFar:1E3}}return a[b.id]=c}}}function tk(a,b){return(b.castShadow?1:0)-(a.castShadow?1:0)}function uk(){for(var a=new rk,b=sk(),c={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],
24220 directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},d=0;9>d;d++)c.probe.push(new p);var e=new p,f=new N,g=new N;return{setup:function(d,l,m){for(var h=0,n=0,k=0,r=0;9>r;r++)c.probe[r].set(0,0,0);var q=l=0,u=0,p=0,x=0,w=0,ja=0,T=0;m=m.matrixWorldInverse;d.sort(tk);r=0;for(var Z=d.length;r<Z;r++){var C=d[r],v=C.color,Q=C.intensity,Da=C.distance,Ka=C.shadow&&C.shadow.map?C.shadow.map.texture:
24221 null;if(C.isAmbientLight)h+=v.r*Q,n+=v.g*Q,k+=v.b*Q;else if(C.isLightProbe)for(Ka=0;9>Ka;Ka++)c.probe[Ka].addScaledVector(C.sh.coefficients[Ka],Q);else if(C.isDirectionalLight){var U=a.get(C);U.color.copy(C.color).multiplyScalar(C.intensity);U.direction.setFromMatrixPosition(C.matrixWorld);e.setFromMatrixPosition(C.target.matrixWorld);U.direction.sub(e);U.direction.transformDirection(m);C.castShadow&&(Q=C.shadow,v=b.get(C),v.shadowBias=Q.bias,v.shadowRadius=Q.radius,v.shadowMapSize=Q.mapSize,c.directionalShadow[l]=
24222 v,c.directionalShadowMap[l]=Ka,c.directionalShadowMatrix[l]=C.shadow.matrix,w++);c.directional[l]=U;l++}else C.isSpotLight?(U=a.get(C),U.position.setFromMatrixPosition(C.matrixWorld),U.position.applyMatrix4(m),U.color.copy(v).multiplyScalar(Q),U.distance=Da,U.direction.setFromMatrixPosition(C.matrixWorld),e.setFromMatrixPosition(C.target.matrixWorld),U.direction.sub(e),U.direction.transformDirection(m),U.coneCos=Math.cos(C.angle),U.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),U.decay=C.decay,C.castShadow&&
24223 (Q=C.shadow,v=b.get(C),v.shadowBias=Q.bias,v.shadowRadius=Q.radius,v.shadowMapSize=Q.mapSize,c.spotShadow[u]=v,c.spotShadowMap[u]=Ka,c.spotShadowMatrix[u]=C.shadow.matrix,T++),c.spot[u]=U,u++):C.isRectAreaLight?(U=a.get(C),U.color.copy(v).multiplyScalar(Q),U.position.setFromMatrixPosition(C.matrixWorld),U.position.applyMatrix4(m),g.identity(),f.copy(C.matrixWorld),f.premultiply(m),g.extractRotation(f),U.halfWidth.set(.5*C.width,0,0),U.halfHeight.set(0,.5*C.height,0),U.halfWidth.applyMatrix4(g),U.halfHeight.applyMatrix4(g),
24224 c.rectArea[p]=U,p++):C.isPointLight?(U=a.get(C),U.position.setFromMatrixPosition(C.matrixWorld),U.position.applyMatrix4(m),U.color.copy(C.color).multiplyScalar(C.intensity),U.distance=C.distance,U.decay=C.decay,C.castShadow&&(Q=C.shadow,v=b.get(C),v.shadowBias=Q.bias,v.shadowRadius=Q.radius,v.shadowMapSize=Q.mapSize,v.shadowCameraNear=Q.camera.near,v.shadowCameraFar=Q.camera.far,c.pointShadow[q]=v,c.pointShadowMap[q]=Ka,c.pointShadowMatrix[q]=C.shadow.matrix,ja++),c.point[q]=U,q++):C.isHemisphereLight&&
24225 (U=a.get(C),U.direction.setFromMatrixPosition(C.matrixWorld),U.direction.transformDirection(m),U.direction.normalize(),U.skyColor.copy(C.color).multiplyScalar(Q),U.groundColor.copy(C.groundColor).multiplyScalar(Q),c.hemi[x]=U,x++)}c.ambient[0]=h;c.ambient[1]=n;c.ambient[2]=k;d=c.hash;if(d.directionalLength!==l||d.pointLength!==q||d.spotLength!==u||d.rectAreaLength!==p||d.hemiLength!==x||d.numDirectionalShadows!==w||d.numPointShadows!==ja||d.numSpotShadows!==T)c.directional.length=l,c.spot.length=
24226 u,c.rectArea.length=p,c.point.length=q,c.hemi.length=x,c.directionalShadow.length=w,c.directionalShadowMap.length=w,c.pointShadow.length=ja,c.pointShadowMap.length=ja,c.spotShadow.length=T,c.spotShadowMap.length=T,c.directionalShadowMatrix.length=w,c.pointShadowMatrix.length=ja,c.spotShadowMatrix.length=T,d.directionalLength=l,d.pointLength=q,d.spotLength=u,d.rectAreaLength=p,d.hemiLength=x,d.numDirectionalShadows=w,d.numPointShadows=ja,d.numSpotShadows=T,c.version=vk++},state:c}}function Qh(){var a=
24227 new uk,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 wk(){function a(c){c=c.target;c.removeEventListener("dispose",a);b.delete(c)}var b=new WeakMap;return{get:function(c,d){if(!1===b.has(c)){var e=new Qh;b.set(c,new WeakMap);b.get(c).set(d,e);c.addEventListener("dispose",a)}else!1===b.get(c).has(d)?(e=new Qh,b.get(c).set(d,e)):
24228 e=b.get(c).get(d);return e},dispose:function(){b=new WeakMap}}}function Hb(a){K.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.fog=!1;this.setValues(a)}function Ib(a){K.call(this);this.type="MeshDistanceMaterial";this.referencePosition=new p;this.nearDistance=1;this.farDistance=1E3;this.morphTargets=this.skinning=
24229 !1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.fog=!1;this.setValues(a)}function Rh(a,b,c){function d(a,b,c){c=a<<0|b<<1|c<<2;var d=n[c];void 0===d&&(d=new Hb({depthPacking:3201,morphTargets:a,skinning:b}),n[c]=d);return d}function e(a,b,c){c=a<<0|b<<1|c<<2;var d=k[c];void 0===d&&(d=new Ib({morphTargets:a,skinning:b}),k[c]=d);return d}function f(b,c,f,g,h,l,m){var n=d,k=b.customDepthMaterial;!0===g.isPointLight&&(n=e,k=b.customDistanceMaterial);
24230 void 0===k?(k=!1,!0===f.morphTargets&&(k=c.morphAttributes&&c.morphAttributes.position&&0<c.morphAttributes.position.length),c=!1,!0===b.isSkinnedMesh&&(!0===f.skinning?c=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",b)),b=n(k,c,!0===b.isInstancedMesh)):b=k;a.localClippingEnabled&&!0===f.clipShadows&&0!==f.clippingPlanes.length&&(k=b.uuid,n=f.uuid,c=r[k],void 0===c&&(c={},r[k]=c),k=c[n],void 0===k&&(k=b.clone(),c[n]=k),b=k);b.visible=f.visible;b.wireframe=
24231 f.wireframe;b.side=3===m?null!==f.shadowSide?f.shadowSide:f.side:null!==f.shadowSide?f.shadowSide:q[f.side];b.clipShadows=f.clipShadows;b.clippingPlanes=f.clippingPlanes;b.clipIntersection=f.clipIntersection;b.wireframeLinewidth=f.wireframeLinewidth;b.linewidth=f.linewidth;!0===g.isPointLight&&!0===b.isMeshDistanceMaterial&&(b.referencePosition.setFromMatrixPosition(g.matrixWorld),b.nearDistance=h,b.farDistance=l);return b}function g(c,d,e,l,m){if(!1!==c.visible){if(c.layers.test(d.layers)&&(c.isMesh||
24232 c.isLine||c.isPoints)&&(c.castShadow||c.receiveShadow&&3===m)&&(!c.frustumCulled||h.intersectsObject(c))){c.modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,c.matrixWorld);var n=b.update(c),k=c.material;if(Array.isArray(k))for(var z=n.groups,t=0,q=z.length;t<q;t++){var r=z[t],u=k[r.materialIndex];u&&u.visible&&(u=f(c,n,u,l,e.near,e.far,m),a.renderBufferDirect(e,null,n,u,c,r))}else k.visible&&(u=f(c,n,k,l,e.near,e.far,m),a.renderBufferDirect(e,null,n,u,c,null))}c=c.children;n=0;for(k=c.length;n<
24233 k;n++)g(c[n],d,e,l,m)}}var h=new Gc,l=new v,m=new v,z=new R,n=[],k=[],r={},q={0:1,1:0,2:2},u=new Ca({defines:{SAMPLE_RATE:.25,HALF_SAMPLE_RATE:.125},uniforms:{shadow_pass:{value:null},resolution:{value:new v},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n float mean = 0.0;\n float squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n #ifdef HORIZONAL_PASS\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n float std_dev = sqrt( squared_mean - mean * mean );\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),
24234 p=u.clone();p.defines.HORIZONAL_PASS=1;var x=new F;x.setAttribute("position",new G(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var w=new ea(x,u),ja=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=1;this.render=function(d,e,f){if(!1!==ja.enabled&&(!1!==ja.autoUpdate||!1!==ja.needsUpdate)&&0!==d.length){var n=a.getRenderTarget(),k=a.getActiveCubeFace(),t=a.getActiveMipmapLevel(),q=a.state;q.setBlending(0);q.buffers.color.setClear(1,1,1,1);q.buffers.depth.setTest(!0);q.setScissorTest(!1);
24235 for(var r=0,E=d.length;r<E;r++){var x=d[r],C=x.shadow;if(void 0===C)console.warn("THREE.WebGLShadowMap:",x,"has no shadow.");else{l.copy(C.mapSize);var v=C.getFrameExtents();l.multiply(v);m.copy(C.mapSize);if(l.x>c||l.y>c)l.x>c&&(m.x=Math.floor(c/v.x),l.x=m.x*v.x,C.mapSize.x=m.x),l.y>c&&(m.y=Math.floor(c/v.y),l.y=m.y*v.y,C.mapSize.y=m.y);null!==C.map||C.isPointLightShadow||3!==this.type||(v={minFilter:1006,magFilter:1006,format:1023},C.map=new Ba(l.x,l.y,v),C.map.texture.name=x.name+".shadowMap",
24236 C.mapPass=new Ba(l.x,l.y,v),C.camera.updateProjectionMatrix());null===C.map&&(v={minFilter:1003,magFilter:1003,format:1023},C.map=new Ba(l.x,l.y,v),C.map.texture.name=x.name+".shadowMap",C.camera.updateProjectionMatrix());a.setRenderTarget(C.map);a.clear();v=C.getViewportCount();for(var Z=0;Z<v;Z++){var T=C.getViewport(Z);z.set(m.x*T.x,m.y*T.y,m.x*T.z,m.y*T.w);q.viewport(z);C.updateMatrices(x,Z);h=C.getFrustum();g(e,f,C.camera,x,this.type)}C.isPointLightShadow||3!==this.type||(x=C,C=f,v=b.update(w),
24237 u.uniforms.shadow_pass.value=x.map.texture,u.uniforms.resolution.value=x.mapSize,u.uniforms.radius.value=x.radius,a.setRenderTarget(x.mapPass),a.clear(),a.renderBufferDirect(C,null,v,u,w,null),p.uniforms.shadow_pass.value=x.mapPass.texture,p.uniforms.resolution.value=x.mapSize,p.uniforms.radius.value=x.radius,a.setRenderTarget(x.map),a.clear(),a.renderBufferDirect(C,null,v,p,w,null))}}ja.needsUpdate=!1;a.setRenderTarget(n,k,t)}}}function xk(a,b,c){function d(b,c,d){var e=new Uint8Array(4),f=a.createTexture();
24238 a.bindTexture(b,f);a.texParameteri(b,10241,9728);a.texParameteri(b,10240,9728);for(b=0;b<d;b++)a.texImage2D(c+b,0,6408,1,1,0,6408,5121,e);return f}function e(c,d){p[c]=1;0===x[c]&&(a.enableVertexAttribArray(c),x[c]=1);w[c]!==d&&((t?a:b.get("ANGLE_instanced_arrays"))[t?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](c,d),w[c]=d)}function f(b){!0!==v[b]&&(a.enable(b),v[b]=!0)}function g(b){!1!==v[b]&&(a.disable(b),v[b]=!1)}function h(b,c,d,e,h,l,m,n){if(0===b)Z&&(g(3042),Z=!1);else if(Z||(f(3042),
24239 Z=!0),5!==b){if(b!==C||n!==y){if(100!==B||100!==Ka)a.blendEquation(32774),Ka=B=100;if(n)switch(b){case 1:a.blendFuncSeparate(1,771,1,771);break;case 2:a.blendFunc(1,1);break;case 3:a.blendFuncSeparate(0,0,769,771);break;case 4:a.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",b)}else switch(b){case 1:a.blendFuncSeparate(770,771,1,771);break;case 2:a.blendFunc(770,1);break;case 3:a.blendFunc(0,769);break;case 4:a.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",
24240 b)}A=U=Da=Q=null;C=b;y=n}}else{h=h||c;l=l||d;m=m||e;if(c!==B||h!==Ka)a.blendEquationSeparate(xa[c],xa[h]),B=c,Ka=h;if(d!==Q||e!==Da||l!==U||m!==A)a.blendFuncSeparate(J[d],J[e],J[l],J[m]),Q=d,Da=e,U=l,A=m;C=b;y=null}}function l(b){D!==b&&(b?a.frontFace(2304):a.frontFace(2305),D=b)}function m(b){0!==b?(f(2884),b!==F&&(1===b?a.cullFace(1029):2===b?a.cullFace(1028):a.cullFace(1032))):g(2884);F=b}function k(b,c,d){if(b){if(f(32823),G!==c||K!==d)a.polygonOffset(c,d),G=c,K=d}else g(32823)}function n(b){void 0===
24241 b&&(b=33984+L-1);N!==b&&(a.activeTexture(b),N=b)}var t=c.isWebGL2,r=new function(){var b=!1,c=new R,d=null,e=new R(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;d=null;e.set(-1,0,0,0)}}},q=new function(){var b=!1,c=null,d=null,e=null;return{setTest:function(a){a?f(2929):g(2929)},setMask:function(d){c===
24242 d||b||(a.depthMask(d),c=d)},setFunc:function(b){if(d!==b){if(b)switch(b){case 0:a.depthFunc(512);break;case 1:a.depthFunc(519);break;case 2:a.depthFunc(513);break;case 3:a.depthFunc(515);break;case 4:a.depthFunc(514);break;case 5:a.depthFunc(518);break;case 6:a.depthFunc(516);break;case 7:a.depthFunc(517);break;default:a.depthFunc(515)}else a.depthFunc(515);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}}},u=new function(){var b=
24243 !1,c=null,d=null,e=null,h=null,l=null,m=null,n=null,k=null;return{setTest:function(a){b||(a?f(2960):g(2960))},setMask:function(d){c===d||b||(a.stencilMask(d),c=d)},setFunc:function(b,c,f){if(d!==b||e!==c||h!==f)a.stencilFunc(b,c,f),d=b,e=c,h=f},setOp:function(b,c,d){if(l!==b||m!==c||n!==d)a.stencilOp(b,c,d),l=b,m=c,n=d},setLocked:function(a){b=a},setClear:function(b){k!==b&&(a.clearStencil(b),k=b)},reset:function(){b=!1;k=n=m=l=h=e=d=c=null}}};c=a.getParameter(34921);var p=new Uint8Array(c),x=new Uint8Array(c),
24244 w=new Uint8Array(c),v={},T=null,Z=null,C=null,B=null,Q=null,Da=null,Ka=null,U=null,A=null,y=!1,D=null,F=null,H=null,G=null,K=null,L=a.getParameter(35661),O=!1;c=0;c=a.getParameter(7938);-1!==c.indexOf("WebGL")?(c=parseFloat(/^WebGL ([0-9])/.exec(c)[1]),O=1<=c):-1!==c.indexOf("OpenGL ES")&&(c=parseFloat(/^OpenGL ES ([0-9])/.exec(c)[1]),O=2<=c);var N=null,Jd={},aa=new R,Sh=new R,Ra={};Ra[3553]=d(3553,3553,1);Ra[34067]=d(34067,34069,6);r.setClear(0,0,0,1);q.setClear(1);u.setClear(0);f(2929);q.setFunc(3);
24245 l(!1);m(1);f(2884);h(0);var xa={100:32774,101:32778,102:32779};t?(xa[103]=32775,xa[104]=32776):(c=b.get("EXT_blend_minmax"),null!==c&&(xa[103]=c.MIN_EXT,xa[104]=c.MAX_EXT));var J={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};return{buffers:{color:r,depth:q,stencil:u},initAttributes:function(){for(var a=0,b=p.length;a<b;a++)p[a]=0},enableAttribute:function(a){e(a,0)},enableAttributeAndDivisor:e,disableUnusedAttributes:function(){for(var b=0,c=x.length;b!==c;++b)x[b]!==
24246 p[b]&&(a.disableVertexAttribArray(b),x[b]=0)},vertexAttribPointer:function(b,c,d,e,f,g){!0!==t||5124!==d&&5125!==d?a.vertexAttribPointer(b,c,d,e,f,g):a.vertexAttribIPointer(b,c,d,e,f,g)},enable:f,disable:g,useProgram:function(b){return T!==b?(a.useProgram(b),T=b,!0):!1},setBlending:h,setMaterial:function(a,b){2===a.side?g(2884):f(2884);var c=1===a.side;b&&(c=!c);l(c);1===a.blending&&!1===a.transparent?h(0):h(a.blending,a.blendEquation,a.blendSrc,a.blendDst,a.blendEquationAlpha,a.blendSrcAlpha,a.blendDstAlpha,
24247 a.premultipliedAlpha);q.setFunc(a.depthFunc);q.setTest(a.depthTest);q.setMask(a.depthWrite);r.setMask(a.colorWrite);b=a.stencilWrite;u.setTest(b);b&&(u.setMask(a.stencilWriteMask),u.setFunc(a.stencilFunc,a.stencilRef,a.stencilFuncMask),u.setOp(a.stencilFail,a.stencilZFail,a.stencilZPass));k(a.polygonOffset,a.polygonOffsetFactor,a.polygonOffsetUnits)},setFlipSided:l,setCullFace:m,setLineWidth:function(b){b!==H&&(O&&a.lineWidth(b),H=b)},setPolygonOffset:k,setScissorTest:function(a){a?f(3089):g(3089)},
24248 activeTexture:n,bindTexture:function(b,c){null===N&&n();var d=Jd[N];void 0===d&&(d={type:void 0,texture:void 0},Jd[N]=d);if(d.type!==b||d.texture!==c)a.bindTexture(b,c||Ra[b]),d.type=b,d.texture=c},unbindTexture:function(){var b=Jd[N];void 0!==b&&void 0!==b.type&&(a.bindTexture(b.type,null),b.type=void 0,b.texture=void 0)},compressedTexImage2D:function(){try{a.compressedTexImage2D.apply(a,arguments)}catch(ca){console.error("THREE.WebGLState:",ca)}},texImage2D:function(){try{a.texImage2D.apply(a,arguments)}catch(ca){console.error("THREE.WebGLState:",
24249 ca)}},texImage3D:function(){try{a.texImage3D.apply(a,arguments)}catch(ca){console.error("THREE.WebGLState:",ca)}},scissor:function(b){!1===aa.equals(b)&&(a.scissor(b.x,b.y,b.z,b.w),aa.copy(b))},viewport:function(b){!1===Sh.equals(b)&&(a.viewport(b.x,b.y,b.z,b.w),Sh.copy(b))},reset:function(){for(var b=0;b<x.length;b++)1===x[b]&&(a.disableVertexAttribArray(b),x[b]=0);v={};N=null;Jd={};F=D=C=T=null;r.reset();q.reset();u.reset()}}}function yk(a,b,c,d,e,f,g){function h(a,b){return G?new OffscreenCanvas(a,
24250 b):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function l(a,b,c,d){var e=1;if(a.width>d||a.height>d)e=d/Math.max(a.width,a.height);if(1>e||!0===b){if("undefined"!==typeof HTMLImageElement&&a instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&a instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&a instanceof ImageBitmap)return d=b?O.floorPowerOfTwo:Math.floor,b=d(e*a.width),e=d(e*a.height),void 0===H&&(H=h(b,e)),c=c?h(b,e):H,c.width=b,c.height=e,
24251 c.getContext("2d").drawImage(a,0,0,b,e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+a.width+"x"+a.height+") to ("+b+"x"+e+")."),c;"data"in a&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+a.width+"x"+a.height+").")}return a}function m(a){return O.isPowerOfTwo(a.width)&&O.isPowerOfTwo(a.height)}function k(a,b){return a.generateMipmaps&&b&&1003!==a.minFilter&&1006!==a.minFilter}function n(b,c,e,f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e,
24252 f))*Math.LOG2E}function t(c,d,e){if(!1===Da)return d;if(null!==c){if(void 0!==a[c])return a[c];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+c+"'")}c=d;6403===d&&(5126===e&&(c=33326),5131===e&&(c=33325),5121===e&&(c=33321));6407===d&&(5126===e&&(c=34837),5131===e&&(c=34843),5121===e&&(c=32849));6408===d&&(5126===e&&(c=34836),5131===e&&(c=34842),5121===e&&(c=32856));33325!==c&&33326!==c&&34842!==c&&34836!==c||b.get("EXT_color_buffer_float");return c}function r(a){return 1003===
24253 a||1004===a||1005===a?9728:9729}function q(b){b=b.target;b.removeEventListener("dispose",q);var c=d.get(b);void 0!==c.__webglInit&&(a.deleteTexture(c.__webglTexture),d.remove(b));b.isVideoTexture&&F.delete(b);g.memory.textures--}function u(b){b=b.target;b.removeEventListener("dispose",u);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.isWebGLCubeRenderTarget)for(e=0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),
24254 c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer),c.__webglMultisampledFramebuffer&&a.deleteFramebuffer(c.__webglMultisampledFramebuffer),c.__webglColorRenderbuffer&&a.deleteRenderbuffer(c.__webglColorRenderbuffer),c.__webglDepthRenderbuffer&&a.deleteRenderbuffer(c.__webglDepthRenderbuffer);d.remove(b.texture);d.remove(b)}g.memory.textures--}function p(a,b){var e=d.get(a);
24255 if(a.isVideoTexture){var f=g.render.frame;F.get(a)!==f&&(F.set(a,f),a.update())}if(0<a.version&&e.__version!==a.version)if(f=a.image,void 0===f)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(!1===f.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(e,a,b);return}c.activeTexture(33984+b);c.bindTexture(3553,e.__webglTexture)}function x(b,e){if(6===b.image.length){var g=d.get(b);if(0<b.version&&g.__version!==
24256 b.version){T(g,b);c.activeTexture(33984+e);c.bindTexture(34067,g.__webglTexture);a.pixelStorei(37440,b.flipY);var h=b&&(b.isCompressedTexture||b.image[0].isCompressedTexture);e=b.image[0]&&b.image[0].isDataTexture;for(var z=[],q=0;6>q;q++)z[q]=h||e?e?b.image[q].image:b.image[q]:l(b.image[q],!1,!0,U);var r=z[0],u=m(r)||Da,p=f.convert(b.format),E=f.convert(b.type),w=t(b.internalFormat,p,E);v(34067,b,u);if(h){for(q=0;6>q;q++){var x=z[q].mipmaps;for(h=0;h<x.length;h++){var aa=x[h];1023!==b.format&&1022!==
24257 b.format?null!==p?c.compressedTexImage2D(34069+q,h,w,aa.width,aa.height,0,aa.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):c.texImage2D(34069+q,h,w,aa.width,aa.height,0,p,E,aa.data)}}g.__maxMipLevel=x.length-1}else{x=b.mipmaps;for(q=0;6>q;q++)if(e)for(c.texImage2D(34069+q,0,w,z[q].width,z[q].height,0,p,E,z[q].data),h=0;h<x.length;h++)aa=x[h],aa=aa.image[q].image,c.texImage2D(34069+q,h+1,w,aa.width,aa.height,0,p,E,aa.data);else for(c.texImage2D(34069+
24258 q,0,w,p,E,z[q]),h=0;h<x.length;h++)aa=x[h],c.texImage2D(34069+q,h+1,w,p,E,aa.image[q]);g.__maxMipLevel=x.length}k(b,u)&&n(34067,b,r.width,r.height);g.__version=b.version;if(b.onUpdate)b.onUpdate(b)}else c.activeTexture(33984+e),c.bindTexture(34067,g.__webglTexture)}}function w(a,b){c.activeTexture(33984+b);c.bindTexture(34067,d.get(a).__webglTexture)}function v(c,f,g){g?(a.texParameteri(c,10242,L[f.wrapS]),a.texParameteri(c,10243,L[f.wrapT]),32879!==c&&35866!==c||a.texParameteri(c,32882,L[f.wrapR]),
24259 a.texParameteri(c,10240,N[f.magFilter]),a.texParameteri(c,10241,N[f.minFilter])):(a.texParameteri(c,10242,33071),a.texParameteri(c,10243,33071),32879!==c&&35866!==c||a.texParameteri(c,32882,33071),1001===f.wrapS&&1001===f.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,10240,r(f.magFilter)),a.texParameteri(c,10241,r(f.minFilter)),1003!==f.minFilter&&1006!==f.minFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));
24260 !(g=b.get("EXT_texture_filter_anisotropic"))||1015===f.type&&null===b.get("OES_texture_float_linear")||1016===f.type&&null===(Da||b.get("OES_texture_half_float_linear"))||!(1<f.anisotropy||d.get(f).__currentAnisotropy)||(a.texParameterf(c,g.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(f.anisotropy,e.getMaxAnisotropy())),d.get(f).__currentAnisotropy=f.anisotropy)}function T(b,c){void 0===b.__webglInit&&(b.__webglInit=!0,c.addEventListener("dispose",q),b.__webglTexture=a.createTexture(),g.memory.textures++)}
24261 function Z(b,d,e){var g=3553;d.isDataTexture2DArray&&(g=35866);d.isDataTexture3D&&(g=32879);T(b,d);c.activeTexture(33984+e);c.bindTexture(g,b.__webglTexture);a.pixelStorei(37440,d.flipY);a.pixelStorei(37441,d.premultiplyAlpha);a.pixelStorei(3317,d.unpackAlignment);e=Da?!1:1001!==d.wrapS||1001!==d.wrapT||1003!==d.minFilter&&1006!==d.minFilter;e=e&&!1===m(d.image);e=l(d.image,e,!1,y);var h=m(e)||Da,z=f.convert(d.format),q=f.convert(d.type),r=t(d.internalFormat,z,q);v(g,d,h);var u=d.mipmaps;if(d.isDepthTexture)r=
24262 6402,Da?r=1015===d.type?36012:1014===d.type?33190:1020===d.type?35056:33189:1015===d.type&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),1026===d.format&&6402===r&&1012!==d.type&&1014!==d.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),d.type=1012,q=f.convert(d.type)),1027===d.format&&6402===r&&(r=34041,1020!==d.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),
24263 d.type=1020,q=f.convert(d.type))),c.texImage2D(3553,0,r,e.width,e.height,0,z,q,null);else if(d.isDataTexture)if(0<u.length&&h){for(var p=0,E=u.length;p<E;p++){var w=u[p];c.texImage2D(3553,p,r,w.width,w.height,0,z,q,w.data)}d.generateMipmaps=!1;b.__maxMipLevel=u.length-1}else c.texImage2D(3553,0,r,e.width,e.height,0,z,q,e.data),b.__maxMipLevel=0;else if(d.isCompressedTexture){p=0;for(E=u.length;p<E;p++)w=u[p],1023!==d.format&&1022!==d.format?null!==z?c.compressedTexImage2D(3553,p,r,w.width,w.height,
24264 0,w.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):c.texImage2D(3553,p,r,w.width,w.height,0,z,q,w.data);b.__maxMipLevel=u.length-1}else if(d.isDataTexture2DArray)c.texImage3D(35866,0,r,e.width,e.height,e.depth,0,z,q,e.data),b.__maxMipLevel=0;else if(d.isDataTexture3D)c.texImage3D(32879,0,r,e.width,e.height,e.depth,0,z,q,e.data),b.__maxMipLevel=0;else if(0<u.length&&h){p=0;for(E=u.length;p<E;p++)w=u[p],c.texImage2D(3553,p,r,z,q,
24265 w);d.generateMipmaps=!1;b.__maxMipLevel=u.length-1}else c.texImage2D(3553,0,r,z,q,e),b.__maxMipLevel=0;k(d,h)&&n(g,d,e.width,e.height);b.__version=d.version;if(d.onUpdate)d.onUpdate(d)}function C(b,e,g,h){var l=f.convert(e.texture.format),m=f.convert(e.texture.type),n=t(e.texture.internalFormat,l,m);c.texImage2D(h,0,n,e.width,e.height,0,l,m,null);a.bindFramebuffer(36160,b);a.framebufferTexture2D(36160,g,h,d.get(e.texture).__webglTexture,0);a.bindFramebuffer(36160,null)}function B(b,c,d){a.bindRenderbuffer(36161,
24266 b);if(c.depthBuffer&&!c.stencilBuffer){var e=33189;d?((d=c.depthTexture)&&d.isDepthTexture&&(1015===d.type?e=36012:1014===d.type&&(e=33190)),d=Q(c),a.renderbufferStorageMultisample(36161,d,e,c.width,c.height)):a.renderbufferStorage(36161,e,c.width,c.height);a.framebufferRenderbuffer(36160,36096,36161,b)}else c.depthBuffer&&c.stencilBuffer?(d?(d=Q(c),a.renderbufferStorageMultisample(36161,d,35056,c.width,c.height)):a.renderbufferStorage(36161,34041,c.width,c.height),a.framebufferRenderbuffer(36160,
24267 33306,36161,b)):(b=f.convert(c.texture.format),e=f.convert(c.texture.type),e=t(c.texture.internalFormat,b,e),d?(d=Q(c),a.renderbufferStorageMultisample(36161,d,e,c.width,c.height)):a.renderbufferStorage(36161,e,c.width,c.height));a.bindRenderbuffer(36161,null)}function Q(a){return Da&&a.isWebGLMultisampleRenderTarget?Math.min(D,a.samples):0}var Da=e.isWebGL2,A=e.maxTextures,U=e.maxCubemapSize,y=e.maxTextureSize,D=e.maxSamples,F=new WeakMap,H,G=!1;try{G="undefined"!==typeof OffscreenCanvas&&null!==
24268 (new OffscreenCanvas(1,1)).getContext("2d")}catch(Jd){}var K=0,L={1E3:10497,1001:33071,1002:33648},N={1003:9728,1004:9984,1005:9986,1006:9729,1007:9985,1008:9987},M=!1,R=!1;this.allocateTextureUnit=function(){var a=K;a>=A&&console.warn("THREE.WebGLTextures: Trying to use "+a+" texture units while this GPU supports only "+A);K+=1;return a};this.resetTextureUnits=function(){K=0};this.setTexture2D=p;this.setTexture2DArray=function(a,b){var e=d.get(a);0<a.version&&e.__version!==a.version?Z(e,a,b):(c.activeTexture(33984+
24269 b),c.bindTexture(35866,e.__webglTexture))};this.setTexture3D=function(a,b){var e=d.get(a);0<a.version&&e.__version!==a.version?Z(e,a,b):(c.activeTexture(33984+b),c.bindTexture(32879,e.__webglTexture))};this.setTextureCube=x;this.setTextureCubeDynamic=w;this.setupRenderTarget=function(b){var e=d.get(b),h=d.get(b.texture);b.addEventListener("dispose",u);h.__webglTexture=a.createTexture();g.memory.textures++;var l=!0===b.isWebGLCubeRenderTarget,z=!0===b.isWebGLMultisampleRenderTarget,q=m(b)||Da;!Da||
24270 1022!==b.texture.format||1015!==b.texture.type&&1016!==b.texture.type||(b.texture.format=1023,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead."));if(l)for(e.__webglFramebuffer=[],z=0;6>z;z++)e.__webglFramebuffer[z]=a.createFramebuffer();else if(e.__webglFramebuffer=a.createFramebuffer(),z)if(Da){e.__webglMultisampledFramebuffer=a.createFramebuffer();e.__webglColorRenderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161,e.__webglColorRenderbuffer);
24271 z=f.convert(b.texture.format);var r=f.convert(b.texture.type);z=t(b.texture.internalFormat,z,r);r=Q(b);a.renderbufferStorageMultisample(36161,r,z,b.width,b.height);a.bindFramebuffer(36160,e.__webglMultisampledFramebuffer);a.framebufferRenderbuffer(36160,36064,36161,e.__webglColorRenderbuffer);a.bindRenderbuffer(36161,null);b.depthBuffer&&(e.__webglDepthRenderbuffer=a.createRenderbuffer(),B(e.__webglDepthRenderbuffer,b,!0));a.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");
24272 if(l){c.bindTexture(34067,h.__webglTexture);v(34067,b.texture,q);for(z=0;6>z;z++)C(e.__webglFramebuffer[z],b,36064,34069+z);k(b.texture,q)&&n(34067,b.texture,b.width,b.height);c.bindTexture(34067,null)}else c.bindTexture(3553,h.__webglTexture),v(3553,b.texture,q),C(e.__webglFramebuffer,b,36064,3553),k(b.texture,q)&&n(3553,b.texture,b.width,b.height),c.bindTexture(3553,null);if(b.depthBuffer){e=d.get(b);h=!0===b.isWebGLCubeRenderTarget;if(b.depthTexture){if(h)throw Error("target.depthTexture not supported in Cube render targets");
24273 if(b&&b.isWebGLCubeRenderTarget)throw Error("Depth Texture with cube render targets is not supported");a.bindFramebuffer(36160,e.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&&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);
24274 p(b.depthTexture,0);e=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(36160,36096,3553,e,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(36160,33306,3553,e,0);else throw Error("Unknown depthTexture format");}else if(h)for(e.__webglDepthbuffer=[],h=0;6>h;h++)a.bindFramebuffer(36160,e.__webglFramebuffer[h]),e.__webglDepthbuffer[h]=a.createRenderbuffer(),B(e.__webglDepthbuffer[h],b,!1);else a.bindFramebuffer(36160,e.__webglFramebuffer),e.__webglDepthbuffer=
24275 a.createRenderbuffer(),B(e.__webglDepthbuffer,b,!1);a.bindFramebuffer(36160,null)}};this.updateRenderTargetMipmap=function(a){var b=a.texture,e=m(a)||Da;if(k(b,e)){e=a.isWebGLCubeRenderTarget?34067:3553;var f=d.get(b).__webglTexture;c.bindTexture(e,f);n(e,b,a.width,a.height);c.bindTexture(e,null)}};this.updateMultisampleRenderTarget=function(b){if(b.isWebGLMultisampleRenderTarget)if(Da){var c=d.get(b);a.bindFramebuffer(36008,c.__webglMultisampledFramebuffer);a.bindFramebuffer(36009,c.__webglFramebuffer);
24276 var e=b.width,f=b.height,g=16384;b.depthBuffer&&(g|=256);b.stencilBuffer&&(g|=1024);a.blitFramebuffer(0,0,e,f,0,0,e,f,g,9728);a.bindFramebuffer(36160,c.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")};this.safeSetTexture2D=function(a,b){a&&a.isWebGLRenderTarget&&(!1===M&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),M=!0),a=a.texture);
24277 p(a,b)};this.safeSetTextureCube=function(a,b){a&&a.isWebGLCubeRenderTarget&&(!1===R&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),R=!0),a=a.texture);a&&a.isCubeTexture||Array.isArray(a.image)&&6===a.image.length?x(a,b):w(a,b)}}function Th(a,b,c){var d=c.isWebGL2;return{convert:function(a){if(1009===a)return 5121;if(1017===a)return 32819;if(1018===a)return 32820;if(1019===a)return 33635;if(1010===a)return 5120;
24278 if(1011===a)return 5122;if(1012===a)return 5123;if(1013===a)return 5124;if(1014===a)return 5125;if(1015===a)return 5126;if(1016===a){if(d)return 5131;var c=b.get("OES_texture_half_float");return null!==c?c.HALF_FLOAT_OES:null}if(1021===a)return 6406;if(1022===a)return 6407;if(1023===a)return 6408;if(1024===a)return 6409;if(1025===a)return 6410;if(1026===a)return 6402;if(1027===a)return 34041;if(1028===a)return 6403;if(1029===a)return 36244;if(1030===a)return 33319;if(1031===a)return 33320;if(1032===
24279 a)return 36248;if(1033===a)return 36249;if(33776===a||33777===a||33778===a||33779===a)if(c=b.get("WEBGL_compressed_texture_s3tc"),null!==c){if(33776===a)return c.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===a)return c.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===a)return c.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===a)return c.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(35840===a||35841===a||35842===a||35843===a)if(c=b.get("WEBGL_compressed_texture_pvrtc"),null!==c){if(35840===a)return c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
24280 if(35841===a)return c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===a)return c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===a)return c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(36196===a)return c=b.get("WEBGL_compressed_texture_etc1"),null!==c?c.COMPRESSED_RGB_ETC1_WEBGL:null;if(37492===a||37496===a)if(c=b.get("WEBGL_compressed_texture_etc"),null!==c){if(37492===a)return c.COMPRESSED_RGB8_ETC2;if(37496===a)return c.COMPRESSED_RGBA8_ETC2_EAC}if(37808===a||37809===a||37810===a||37811===a||37812===
24281 a||37813===a||37814===a||37815===a||37816===a||37817===a||37818===a||37819===a||37820===a||37821===a||37840===a||37841===a||37842===a||37843===a||37844===a||37845===a||37846===a||37847===a||37848===a||37849===a||37850===a||37851===a||37852===a||37853===a)return c=b.get("WEBGL_compressed_texture_astc"),null!==c?a:null;if(36492===a)return c=b.get("EXT_texture_compression_bptc"),null!==c?a:null;if(1020===a){if(d)return 34042;c=b.get("WEBGL_depth_texture");return null!==c?c.UNSIGNED_INT_24_8_WEBGL:null}}}}
24282 function Le(a){P.call(this);this.cameras=a||[]}function Kc(){y.call(this);this.type="Group"}function Me(){this._grip=this._targetRay=null}function Uh(a,b){function c(a){var b=q.get(a.inputSource);b&&b.dispatchEvent({type:a.type})}function d(){q.forEach(function(a,b){a.disconnect(b)});q.clear();a.setFramebuffer(null);a.setRenderTarget(a.getRenderTarget());Q.stop();h.isPresenting=!1;h.dispatchEvent({type:"sessionend"})}function e(a){k=a;Q.setContext(l);Q.start();h.isPresenting=!0;h.dispatchEvent({type:"sessionstart"})}
24283 function f(a){for(var b=l.inputSources,c=0;c<r.length;c++)q.set(b[c],r[c]);for(c=0;c<a.removed.length;c++){b=a.removed[c];var d=q.get(b);d&&(d.dispatchEvent({type:"disconnected",data:b}),q.delete(b))}for(c=0;c<a.added.length;c++)b=a.added[c],(d=q.get(b))&&d.dispatchEvent({type:"connected",data:b})}function g(a,b){null===b?a.matrixWorld.copy(a.matrix):a.matrixWorld.multiplyMatrices(b.matrixWorld,a.matrix);a.matrixWorldInverse.getInverse(a.matrixWorld)}var h=this,l=null,m=1,k=null,n="local-floor",t=
24284 null,r=[],q=new Map,u=new P;u.layers.enable(1);u.viewport=new R;var E=new P;E.layers.enable(2);E.viewport=new R;var x=[u,E],w=new Le;w.layers.enable(1);w.layers.enable(2);var v=null,T=null;this.isPresenting=this.enabled=!1;this.getController=function(a){var b=r[a];void 0===b&&(b=new Me,r[a]=b);return b.getTargetRaySpace()};this.getControllerGrip=function(a){var b=r[a];void 0===b&&(b=new Me,r[a]=b);return b.getGripSpace()};this.setFramebufferScaleFactor=function(a){m=a;!0===h.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")};
24285 this.setReferenceSpaceType=function(a){n=a;!0===h.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")};this.getReferenceSpace=function(){return k};this.getSession=function(){return l};this.setSession=function(a){l=a;null!==l&&(l.addEventListener("select",c),l.addEventListener("selectstart",c),l.addEventListener("selectend",c),l.addEventListener("squeeze",c),l.addEventListener("squeezestart",c),l.addEventListener("squeezeend",c),l.addEventListener("end",
24286 d),a=b.getContextAttributes(),!0!==a.xrCompatible&&b.makeXRCompatible(),a=new XRWebGLLayer(l,b,{antialias:a.antialias,alpha:a.alpha,depth:a.depth,stencil:a.stencil,framebufferScaleFactor:m}),l.updateRenderState({baseLayer:a}),l.requestReferenceSpace(n).then(e),l.addEventListener("inputsourceschange",f))};var Z=new p,C=new p;this.getCamera=function(a){w.near=E.near=u.near=a.near;w.far=E.far=u.far=a.far;if(v!==w.near||T!==w.far)l.updateRenderState({depthNear:w.near,depthFar:w.far}),v=w.near,T=w.far;
24287 var b=a.parent,c=w.cameras;g(w,b);for(var d=0;d<c.length;d++)g(c[d],b);a.matrixWorld.copy(w.matrixWorld);a=a.children;d=0;for(b=a.length;d<b;d++)a[d].updateMatrixWorld(!0);if(2===c.length){Z.setFromMatrixPosition(u.matrixWorld);C.setFromMatrixPosition(E.matrixWorld);c=Z.distanceTo(C);var e=u.projectionMatrix.elements,f=E.projectionMatrix.elements,h=e[14]/(e[10]-1);d=e[14]/(e[10]+1);a=(e[9]+1)/e[5];b=(e[9]-1)/e[5];var m=(e[8]-1)/e[0],n=(f[8]+1)/f[0];f=h*m;e=h*n;n=c/(-m+n);m=n*-m;u.matrixWorld.decompose(w.position,
24288 w.quaternion,w.scale);w.translateX(m);w.translateZ(n);w.matrixWorld.compose(w.position,w.quaternion,w.scale);w.matrixWorldInverse.getInverse(w.matrixWorld);h+=n;n=d+n;w.projectionMatrix.makePerspective(f-m,e+(c-m),a*d/n*h,b*d/n*h,h,n)}else w.projectionMatrix.copy(u.projectionMatrix);return w};var B=null,Q=new uh;Q.setAnimationLoop(function(b,c){t=c.getViewerPose(k);if(null!==t){var d=t.views,e=l.renderState.baseLayer;a.setFramebuffer(e.framebuffer);var f=!1;d.length!==w.cameras.length&&(w.cameras.length=
24289 0,f=!0);for(var g=0;g<d.length;g++){var h=d[g],m=e.getViewport(h),n=x[g];n.matrix.fromArray(h.transform.matrix);n.projectionMatrix.fromArray(h.projectionMatrix);n.viewport.set(m.x,m.y,m.width,m.height);0===g&&w.matrix.copy(n.matrix);!0===f&&w.cameras.push(n)}}d=l.inputSources;for(g=0;g<r.length;g++)r[g].update(d[g],c,k);B&&B(b,c)});this.setAnimationLoop=function(a){B=a};this.dispose=function(){}}function zk(a){function b(b,c,f){b.opacity.value=c.opacity;c.color&&b.diffuse.value.copy(c.color);c.emissive&&
24290 b.emissive.value.copy(c.emissive).multiplyScalar(c.emissiveIntensity);c.map&&(b.map.value=c.map);c.alphaMap&&(b.alphaMap.value=c.alphaMap);c.specularMap&&(b.specularMap.value=c.specularMap);if(f=c.envMap||f)b.envMap.value=f,b.flipEnvMap.value=f.isCubeTexture?-1:1,b.reflectivity.value=c.reflectivity,b.refractionRatio.value=c.refractionRatio,b.maxMipLevel.value=a.get(f).__maxMipLevel;c.lightMap&&(b.lightMap.value=c.lightMap,b.lightMapIntensity.value=c.lightMapIntensity);c.aoMap&&(b.aoMap.value=c.aoMap,
24291 b.aoMapIntensity.value=c.aoMapIntensity);if(c.map)var d=c.map;else c.specularMap?d=c.specularMap:c.displacementMap?d=c.displacementMap:c.normalMap?d=c.normalMap:c.bumpMap?d=c.bumpMap:c.roughnessMap?d=c.roughnessMap:c.metalnessMap?d=c.metalnessMap:c.alphaMap?d=c.alphaMap:c.emissiveMap&&(d=c.emissiveMap);void 0!==d&&(d.isWebGLRenderTarget&&(d=d.texture),!0===d.matrixAutoUpdate&&d.updateMatrix(),b.uvTransform.value.copy(d.matrix));if(c.aoMap)var e=c.aoMap;else c.lightMap&&(e=c.lightMap);void 0!==e&&
24292 (e.isWebGLRenderTarget&&(e=e.texture),!0===e.matrixAutoUpdate&&e.updateMatrix(),b.uv2Transform.value.copy(e.matrix))}function c(a,b,c){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,
24293 a.normalScale.value.copy(b.normalScale),1===b.side&&a.normalScale.value.negate());b.displacementMap&&(a.displacementMap.value=b.displacementMap,a.displacementScale.value=b.displacementScale,a.displacementBias.value=b.displacementBias);if(b.envMap||c)a.envMapIntensity.value=b.envMapIntensity}return{refreshFogUniforms:function(a,b){a.fogColor.value.copy(b.color);b.isFog?(a.fogNear.value=b.near,a.fogFar.value=b.far):b.isFogExp2&&(a.fogDensity.value=b.density)},refreshMaterialUniforms:function(a,e,f,
24294 g,h){if(e.isMeshBasicMaterial)b(a,e);else if(e.isMeshLambertMaterial)b(a,e),e.emissiveMap&&(a.emissiveMap.value=e.emissiveMap);else if(e.isMeshToonMaterial)b(a,e),a.specular.value.copy(e.specular),a.shininess.value=Math.max(e.shininess,1E-4),e.gradientMap&&(a.gradientMap.value=e.gradientMap),e.emissiveMap&&(a.emissiveMap.value=e.emissiveMap),e.bumpMap&&(a.bumpMap.value=e.bumpMap,a.bumpScale.value=e.bumpScale,1===e.side&&(a.bumpScale.value*=-1)),e.normalMap&&(a.normalMap.value=e.normalMap,a.normalScale.value.copy(e.normalScale),
24295 1===e.side&&a.normalScale.value.negate()),e.displacementMap&&(a.displacementMap.value=e.displacementMap,a.displacementScale.value=e.displacementScale,a.displacementBias.value=e.displacementBias);else if(e.isMeshPhongMaterial)b(a,e),a.specular.value.copy(e.specular),a.shininess.value=Math.max(e.shininess,1E-4),e.emissiveMap&&(a.emissiveMap.value=e.emissiveMap),e.bumpMap&&(a.bumpMap.value=e.bumpMap,a.bumpScale.value=e.bumpScale,1===e.side&&(a.bumpScale.value*=-1)),e.normalMap&&(a.normalMap.value=e.normalMap,
24296 a.normalScale.value.copy(e.normalScale),1===e.side&&a.normalScale.value.negate()),e.displacementMap&&(a.displacementMap.value=e.displacementMap,a.displacementScale.value=e.displacementScale,a.displacementBias.value=e.displacementBias);else if(e.isMeshStandardMaterial)b(a,e,f),e.isMeshPhysicalMaterial?(c(a,e,f),a.reflectivity.value=e.reflectivity,a.clearcoat.value=e.clearcoat,a.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&a.sheen.value.copy(e.sheen),e.clearcoatMap&&(a.clearcoatMap.value=
24297 e.clearcoatMap),e.clearcoatRoughnessMap&&(a.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap),e.clearcoatNormalMap&&(a.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),a.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&a.clearcoatNormalScale.value.negate()),a.transparency.value=e.transparency):c(a,e,f);else if(e.isMeshMatcapMaterial)b(a,e),e.matcap&&(a.matcap.value=e.matcap),e.bumpMap&&(a.bumpMap.value=e.bumpMap,a.bumpScale.value=e.bumpScale,1===e.side&&(a.bumpScale.value*=-1)),
24298 e.normalMap&&(a.normalMap.value=e.normalMap,a.normalScale.value.copy(e.normalScale),1===e.side&&a.normalScale.value.negate()),e.displacementMap&&(a.displacementMap.value=e.displacementMap,a.displacementScale.value=e.displacementScale,a.displacementBias.value=e.displacementBias);else if(e.isMeshDepthMaterial)b(a,e),e.displacementMap&&(a.displacementMap.value=e.displacementMap,a.displacementScale.value=e.displacementScale,a.displacementBias.value=e.displacementBias);else if(e.isMeshDistanceMaterial)b(a,
24299 e),e.displacementMap&&(a.displacementMap.value=e.displacementMap,a.displacementScale.value=e.displacementScale,a.displacementBias.value=e.displacementBias),a.referencePosition.value.copy(e.referencePosition),a.nearDistance.value=e.nearDistance,a.farDistance.value=e.farDistance;else if(e.isMeshNormalMaterial)b(a,e),e.bumpMap&&(a.bumpMap.value=e.bumpMap,a.bumpScale.value=e.bumpScale,1===e.side&&(a.bumpScale.value*=-1)),e.normalMap&&(a.normalMap.value=e.normalMap,a.normalScale.value.copy(e.normalScale),
24300 1===e.side&&a.normalScale.value.negate()),e.displacementMap&&(a.displacementMap.value=e.displacementMap,a.displacementScale.value=e.displacementScale,a.displacementBias.value=e.displacementBias);else if(e.isLineBasicMaterial)a.diffuse.value.copy(e.color),a.opacity.value=e.opacity,e.isLineDashedMaterial&&(a.dashSize.value=e.dashSize,a.totalSize.value=e.dashSize+e.gapSize,a.scale.value=e.scale);else if(e.isPointsMaterial){a.diffuse.value.copy(e.color);a.opacity.value=e.opacity;a.size.value=e.size*g;
24301 a.scale.value=.5*h;e.map&&(a.map.value=e.map);e.alphaMap&&(a.alphaMap.value=e.alphaMap);if(e.map)var d=e.map;else e.alphaMap&&(d=e.alphaMap);void 0!==d&&(!0===d.matrixAutoUpdate&&d.updateMatrix(),a.uvTransform.value.copy(d.matrix))}else if(e.isSpriteMaterial){a.diffuse.value.copy(e.color);a.opacity.value=e.opacity;a.rotation.value=e.rotation;e.map&&(a.map.value=e.map);e.alphaMap&&(a.alphaMap.value=e.alphaMap);if(e.map)var m=e.map;else e.alphaMap&&(m=e.alphaMap);void 0!==m&&(!0===m.matrixAutoUpdate&&
24302 m.updateMatrix(),a.uvTransform.value.copy(m.matrix))}else e.isShadowMaterial?(a.color.value.copy(e.color),a.opacity.value=e.opacity):e.isShaderMaterial&&(e.uniformsNeedUpdate=!1)}}}function jg(a){var b;function c(){sa=new oj(I);Ha=new mj(I,sa,a);!1===Ha.isWebGL2&&(sa.get("WEBGL_depth_texture"),sa.get("OES_texture_float"),sa.get("OES_texture_half_float"),sa.get("OES_texture_half_float_linear"),sa.get("OES_standard_derivatives"),sa.get("OES_element_index_uint"),sa.get("ANGLE_instanced_arrays"));sa.get("OES_texture_float_linear");
24303 ra=new Th(I,sa,Ha);X=new xk(I,sa,Ha);X.scissor(S.copy(ka).multiplyScalar(xa).floor());X.viewport(Y.copy(da).multiplyScalar(xa).floor());fa=new rj(I);P=new nk;ba=new yk(I,sa,X,P,Ha,ra,fa);oa=new jj(I,Ha);va=new pj(I,oa,fa);pa=new uj(I,va,oa,fa);Aa=new tj(I);ta=new mk(y,sa,Ha);za=new zk(P);ya=new qk;wa=new wk;qa=new kj(y,X,pa,ja);Ca=new lj(I,sa,fa,Ha);Ea=new qj(I,sa,fa,Ha);fa.programs=ta.programs;y.capabilities=Ha;y.extensions=sa;y.properties=P;y.renderLists=ya;y.state=X;y.info=fa}function d(a){a.preventDefault();
24304 console.log("THREE.WebGLRenderer: Context Lost.");F=!0}function e(){console.log("THREE.WebGLRenderer: Context Restored.");F=!1;c()}function f(a){a=a.target;a.removeEventListener("dispose",f);g(a);P.remove(a)}function g(a){var b=P.get(a).program;a.program=void 0;void 0!==b&&ta.releaseProgram(b)}function h(a,b){a.render(function(a){y.renderBufferImmediate(a,b)})}function l(a,b,c,d){if(!1!==a.visible){if(a.layers.test(b.layers))if(a.isGroup)c=a.renderOrder;else if(a.isLOD)!0===a.autoUpdate&&a.update(b);
24305 else if(a.isLight)Q.pushLight(a),a.castShadow&&Q.pushShadow(a);else if(a.isSprite){if(!a.frustumCulled||na.intersectsSprite(a)){d&&Jb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(la);var e=pa.update(a),f=a.material;f.visible&&B.push(a,e,f,c,Jb.z,null)}}else if(a.isImmediateRenderObject)d&&Jb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(la),B.push(a,null,a.material,c,Jb.z,null);else if(a.isMesh||a.isLine||a.isPoints)if(a.isSkinnedMesh&&a.skeleton.frame!==fa.render.frame&&(a.skeleton.update(),
24306 a.skeleton.frame=fa.render.frame),!a.frustumCulled||na.intersectsObject(a))if(d&&Jb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(la),e=pa.update(a),f=a.material,Array.isArray(f))for(var g=e.groups,h=0,m=g.length;h<m;h++){var n=g[h],k=f[n.materialIndex];k&&k.visible&&B.push(a,e,k,c,Jb.z,n)}else f.visible&&B.push(a,e,f,c,Jb.z,null);a=a.children;h=0;for(m=a.length;h<m;h++)l(a[h],b,c,d)}}function m(a,b,c,d){for(var e=0,f=a.length;e<f;e++){var g=a[e],h=g.object,l=g.geometry,m=void 0===d?g.material:
24307 d;g=g.group;if(c.isArrayCamera){W=c;for(var n=c.cameras,z=0,q=n.length;z<q;z++){var t=n[z];h.layers.test(t.layers)&&(X.viewport(Y.copy(t.viewport)),Q.setupLights(t),k(h,b,t,l,m,g))}}else W=null,k(h,b,c,l,m,g)}}function k(a,c,d,e,f,g){a.onBeforeRender(y,c,d,e,f,g);Q=wa.get(c,W||d);a.modelViewMatrix.multiplyMatrices(d.matrixWorldInverse,a.matrixWorld);a.normalMatrix.getNormalMatrix(a.modelViewMatrix);if(a.isImmediateRenderObject){var l=t(d,c,f,a);X.setMaterial(f);V=b=null;Ke=!1;h(a,l)}else y.renderBufferDirect(d,
24308 c,e,f,a,g);a.onAfterRender(y,c,d,e,f,g);Q=wa.get(c,W||d)}function n(a,b,c){var d=P.get(a),e=Q.state.lights,h=e.state.version;c=ta.getParameters(a,e.state,Q.state.shadowsArray,b,ha.numPlanes,ha.numIntersection,c);var l=ta.getProgramCacheKey(c),m=d.program,n=!0;if(void 0===m)a.addEventListener("dispose",f);else if(m.cacheKey!==l)g(a);else{if(d.lightsStateVersion!==h)d.lightsStateVersion=h;else if(void 0!==c.shaderID)return;n=!1}n&&(m=ta.acquireProgram(c,l),d.program=m,d.uniforms=c.uniforms,d.outputEncoding=
24309 c.outputEncoding,a.program=m);c=m.getAttributes();if(a.morphTargets)for(l=a.numSupportedMorphTargets=0;l<y.maxMorphTargets;l++)0<=c["morphTarget"+l]&&a.numSupportedMorphTargets++;if(a.morphNormals)for(l=a.numSupportedMorphNormals=0;l<y.maxMorphNormals;l++)0<=c["morphNormal"+l]&&a.numSupportedMorphNormals++;c=d.uniforms;if(!a.isShaderMaterial&&!a.isRawShaderMaterial||!0===a.clipping)d.numClippingPlanes=ha.numPlanes,d.numIntersection=ha.numIntersection,c.clippingPlanes=ha.uniform;d.environment=a.isMeshStandardMaterial?
24310 b.environment:null;d.fog=b.fog;d.needsLights=a.isMeshLambertMaterial||a.isMeshToonMaterial||a.isMeshPhongMaterial||a.isMeshStandardMaterial||a.isShadowMaterial||a.isShaderMaterial&&!0===a.lights;d.lightsStateVersion=h;d.needsLights&&(c.ambientLightColor.value=e.state.ambient,c.lightProbe.value=e.state.probe,c.directionalLights.value=e.state.directional,c.directionalLightShadows.value=e.state.directionalShadow,c.spotLights.value=e.state.spot,c.spotLightShadows.value=e.state.spotShadow,c.rectAreaLights.value=
24311 e.state.rectArea,c.pointLights.value=e.state.point,c.pointLightShadows.value=e.state.pointShadow,c.hemisphereLights.value=e.state.hemi,c.directionalShadowMap.value=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=Gb.seqWithValue(a.seq,c);
24312 d.uniformsList=a}function t(a,b,c,d){ba.resetTextureUnits();var e=b.fog,f=c.isMeshStandardMaterial?b.environment:null,g=null===G?y.outputEncoding:G.texture.encoding,h=P.get(c),l=Q.state.lights;Je&&(ig||a!==ia)&&ha.setState(c.clippingPlanes,c.clipIntersection,c.clipShadows,a,h,a===ia&&c.id===M);c.version===h.__version?void 0===h.program?n(c,b,d):c.fog&&h.fog!==e?n(c,b,d):h.environment!==f?n(c,b,d):h.needsLights&&h.lightsStateVersion!==l.state.version?n(c,b,d):void 0===h.numClippingPlanes||h.numClippingPlanes===
24313 ha.numPlanes&&h.numIntersection===ha.numIntersection?h.outputEncoding!==g&&n(c,b,d):n(c,b,d):(n(c,b,d),h.__version=c.version);var m=!1,k=!1,z=!1;b=h.program;g=b.getUniforms();l=h.uniforms;X.useProgram(b.program)&&(z=k=m=!0);c.id!==M&&(M=c.id,k=!0);if(m||ia!==a){g.setValue(I,"projectionMatrix",a.projectionMatrix);Ha.logarithmicDepthBuffer&&g.setValue(I,"logDepthBufFC",2/(Math.log(a.far+1)/Math.LN2));ia!==a&&(ia=a,z=k=!0);if(c.isShaderMaterial||c.isMeshPhongMaterial||c.isMeshToonMaterial||c.isMeshStandardMaterial||
24314 c.envMap)m=g.map.cameraPosition,void 0!==m&&m.setValue(I,Jb.setFromMatrixPosition(a.matrixWorld));(c.isMeshPhongMaterial||c.isMeshToonMaterial||c.isMeshLambertMaterial||c.isMeshBasicMaterial||c.isMeshStandardMaterial||c.isShaderMaterial)&&g.setValue(I,"isOrthographic",!0===a.isOrthographicCamera);(c.isMeshPhongMaterial||c.isMeshToonMaterial||c.isMeshLambertMaterial||c.isMeshBasicMaterial||c.isMeshStandardMaterial||c.isShaderMaterial||c.skinning)&&g.setValue(I,"viewMatrix",a.matrixWorldInverse)}if(c.skinning&&
24315 (g.setOptional(I,d,"bindMatrix"),g.setOptional(I,d,"bindMatrixInverse"),a=d.skeleton))if(m=a.bones,Ha.floatVertexTextures){if(void 0===a.boneTexture){m=Math.sqrt(4*m.length);m=O.ceilPowerOfTwo(m);m=Math.max(m,4);var q=new Float32Array(m*m*4);q.set(a.boneMatrices);var t=new $b(q,m,m,1023,1015);a.boneMatrices=q;a.boneTexture=t;a.boneTextureSize=m}g.setValue(I,"boneTexture",a.boneTexture,ba);g.setValue(I,"boneTextureSize",a.boneTextureSize)}else g.setOptional(I,a,"boneMatrices");if(k||h.receiveShadow!==
24316 d.receiveShadow)h.receiveShadow=d.receiveShadow,g.setValue(I,"receiveShadow",d.receiveShadow);k&&(g.setValue(I,"toneMappingExposure",y.toneMappingExposure),g.setValue(I,"toneMappingWhitePoint",y.toneMappingWhitePoint),h.needsLights&&(k=z,l.ambientLightColor.needsUpdate=k,l.lightProbe.needsUpdate=k,l.directionalLights.needsUpdate=k,l.directionalLightShadows.needsUpdate=k,l.pointLights.needsUpdate=k,l.pointLightShadows.needsUpdate=k,l.spotLights.needsUpdate=k,l.spotLightShadows.needsUpdate=k,l.rectAreaLights.needsUpdate=
24317 k,l.hemisphereLights.needsUpdate=k),e&&c.fog&&za.refreshFogUniforms(l,e),za.refreshMaterialUniforms(l,c,f,xa,Ra),void 0!==l.ltc_1&&(l.ltc_1.value=A.LTC_1),void 0!==l.ltc_2&&(l.ltc_2.value=A.LTC_2),Gb.upload(I,h.uniformsList,l,ba));c.isShaderMaterial&&!0===c.uniformsNeedUpdate&&(Gb.upload(I,h.uniformsList,l,ba),c.uniformsNeedUpdate=!1);c.isSpriteMaterial&&g.setValue(I,"center",d.center);g.setValue(I,"modelViewMatrix",d.modelViewMatrix);g.setValue(I,"normalMatrix",d.normalMatrix);g.setValue(I,"modelMatrix",
24318 d.matrixWorld);return b}a=a||{};var r=void 0!==a.canvas?a.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),q=void 0!==a.context?a.context:null,u=void 0!==a.alpha?a.alpha:!1,E=void 0!==a.depth?a.depth:!0,x=void 0!==a.stencil?a.stencil:!0,w=void 0!==a.antialias?a.antialias:!1,ja=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,T=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,Z=void 0!==a.powerPreference?a.powerPreference:"default",C=void 0!==a.failIfMajorPerformanceCaveat?
24319 a.failIfMajorPerformanceCaveat:!1,B=null,Q=null;this.domElement=r;this.debug={checkShaderErrors:!0};this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.clippingPlanes=[];this.localClippingEnabled=!1;this.gammaFactor=2;this.outputEncoding=3E3;this.physicallyCorrectLights=!1;this.toneMapping=0;this.toneMappingWhitePoint=this.toneMappingExposure=1;this.maxMorphTargets=8;this.maxMorphNormals=4;var y=this,F=!1,D=null,H=0,K=0,G=null,L=null,M=-1;var V=b=
24320 null;var Ke=!1;var ia=null,W=null,Y=new R,S=new R,aa=null,ea=r.width,Ra=r.height,xa=1,J=null,ca=null,da=new R(0,0,ea,Ra),ka=new R(0,0,ea,Ra),ma=!1,na=new Gc,ha=new nj,Je=!1,ig=!1,la=new N,Jb=new p;try{u={alpha:u,depth:E,stencil:x,antialias:w,premultipliedAlpha:ja,preserveDrawingBuffer:T,powerPreference:Z,failIfMajorPerformanceCaveat:C};r.addEventListener("webglcontextlost",d,!1);r.addEventListener("webglcontextrestored",e,!1);var I=q||r.getContext("webgl",u)||r.getContext("experimental-webgl",u);
24321 if(null===I){if(null!==r.getContext("webgl"))throw Error("Error creating WebGL context with your selected attributes.");throw Error("Error creating WebGL context.");}void 0===I.getShaderPrecisionFormat&&(I.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Vh){throw console.error("THREE.WebGLRenderer: "+Vh.message),Vh;}var sa,Ha,X,fa,P,ba,oa,va,pa,ta,za,ya,wa,qa,Aa,Ca,Ea,ra;c();var ua=new Uh(y,I);this.xr=ua;var Ga=new Rh(y,pa,Ha.maxTextureSize);this.shadowMap=Ga;
24322 this.getContext=function(){return I};this.getContextAttributes=function(){return I.getContextAttributes()};this.forceContextLoss=function(){var a=sa.get("WEBGL_lose_context");a&&a.loseContext()};this.forceContextRestore=function(){var a=sa.get("WEBGL_lose_context");a&&a.restoreContext()};this.getPixelRatio=function(){return xa};this.setPixelRatio=function(a){void 0!==a&&(xa=a,this.setSize(ea,Ra,!1))};this.getSize=function(a){void 0===a&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),
24323 a=new v);return a.set(ea,Ra)};this.setSize=function(a,b,c){ua.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(ea=a,Ra=b,r.width=Math.floor(a*xa),r.height=Math.floor(b*xa),!1!==c&&(r.style.width=a+"px",r.style.height=b+"px"),this.setViewport(0,0,a,b))};this.getDrawingBufferSize=function(a){void 0===a&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),a=new v);return a.set(ea*xa,Ra*xa).floor()};this.setDrawingBufferSize=
24324 function(a,b,c){ea=a;Ra=b;xa=c;r.width=Math.floor(a*c);r.height=Math.floor(b*c);this.setViewport(0,0,a,b)};this.getCurrentViewport=function(a){void 0===a&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),a=new R);return a.copy(Y)};this.getViewport=function(a){return a.copy(da)};this.setViewport=function(a,b,c,d){a.isVector4?da.set(a.x,a.y,a.z,a.w):da.set(a,b,c,d);X.viewport(Y.copy(da).multiplyScalar(xa).floor())};this.getScissor=function(a){return a.copy(ka)};
24325 this.setScissor=function(a,b,c,d){a.isVector4?ka.set(a.x,a.y,a.z,a.w):ka.set(a,b,c,d);X.scissor(S.copy(ka).multiplyScalar(xa).floor())};this.getScissorTest=function(){return ma};this.setScissorTest=function(a){X.setScissorTest(ma=a)};this.setOpaqueSort=function(a){J=a};this.setTransparentSort=function(a){ca=a};this.getClearColor=function(){return qa.getClearColor()};this.setClearColor=function(){qa.setClearColor.apply(qa,arguments)};this.getClearAlpha=function(){return qa.getClearAlpha()};this.setClearAlpha=
24326 function(){qa.setClearAlpha.apply(qa,arguments)};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=16384;if(void 0===b||b)d|=256;if(void 0===c||c)d|=1024;I.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.dispose=function(){r.removeEventListener("webglcontextlost",d,!1);r.removeEventListener("webglcontextrestored",e,!1);ya.dispose();wa.dispose();P.dispose();pa.dispose();ua.dispose();
24327 Ba.stop()};this.renderBufferImmediate=function(a,b){X.initAttributes();var c=P.get(a);a.hasPositions&&!c.position&&(c.position=I.createBuffer());a.hasNormals&&!c.normal&&(c.normal=I.createBuffer());a.hasUvs&&!c.uv&&(c.uv=I.createBuffer());a.hasColors&&!c.color&&(c.color=I.createBuffer());b=b.getAttributes();a.hasPositions&&(I.bindBuffer(34962,c.position),I.bufferData(34962,a.positionArray,35048),X.enableAttribute(b.position),I.vertexAttribPointer(b.position,3,5126,!1,0,0));a.hasNormals&&(I.bindBuffer(34962,
24328 c.normal),I.bufferData(34962,a.normalArray,35048),X.enableAttribute(b.normal),I.vertexAttribPointer(b.normal,3,5126,!1,0,0));a.hasUvs&&(I.bindBuffer(34962,c.uv),I.bufferData(34962,a.uvArray,35048),X.enableAttribute(b.uv),I.vertexAttribPointer(b.uv,2,5126,!1,0,0));a.hasColors&&(I.bindBuffer(34962,c.color),I.bufferData(34962,a.colorArray,35048),X.enableAttribute(b.color),I.vertexAttribPointer(b.color,3,5126,!1,0,0));X.disableUnusedAttributes();I.drawArrays(4,0,a.count);a.count=0};var Ia=new zc;this.renderBufferDirect=
24329 function(a,c,d,e,f,g){null===c&&(c=Ia);var h=f.isMesh&&0>f.matrixWorld.determinant(),l=t(a,c,e,f);X.setMaterial(e,h);var m=!1;if(b!==d.id||V!==l.id||Ke!==(!0===e.wireframe))b=d.id,V=l.id,Ke=!0===e.wireframe,m=!0;if(e.morphTargets||e.morphNormals)Aa.update(f,d,e,l),m=!0;!0===f.isInstancedMesh&&(m=!0);a=d.index;c=d.attributes.position;if(null===a){if(void 0===c||0===c.count)return}else if(0===a.count)return;var n=1;!0===e.wireframe&&(a=va.getWireframeAttribute(d),n=2);h=Ca;if(null!==a){var k=oa.get(a);
24330 h=Ea;h.setIndex(k)}if(m){if(!1!==Ha.isWebGL2||!f.isInstancedMesh&&!d.isInstancedBufferGeometry||null!==sa.get("ANGLE_instanced_arrays")){X.initAttributes();m=d.attributes;l=l.getAttributes();var z=e.defaultAttributeValues;for(ja in l){var q=l[ja];if(0<=q){var r=m[ja];if(void 0!==r){var u=r.normalized,p=r.itemSize,w=oa.get(r);if(void 0!==w){var E=w.buffer,x=w.type;w=w.bytesPerElement;if(r.isInterleavedBufferAttribute){var v=r.data,C=v.stride;r=r.offset;v&&v.isInstancedInterleavedBuffer?(X.enableAttributeAndDivisor(q,
24331 v.meshPerAttribute),void 0===d._maxInstanceCount&&(d._maxInstanceCount=v.meshPerAttribute*v.count)):X.enableAttribute(q);I.bindBuffer(34962,E);X.vertexAttribPointer(q,p,x,u,C*w,r*w)}else r.isInstancedBufferAttribute?(X.enableAttributeAndDivisor(q,r.meshPerAttribute),void 0===d._maxInstanceCount&&(d._maxInstanceCount=r.meshPerAttribute*r.count)):X.enableAttribute(q),I.bindBuffer(34962,E),X.vertexAttribPointer(q,p,x,u,0,0)}}else if("instanceMatrix"===ja)w=oa.get(f.instanceMatrix),void 0!==w&&(E=w.buffer,
24332 x=w.type,X.enableAttributeAndDivisor(q+0,1),X.enableAttributeAndDivisor(q+1,1),X.enableAttributeAndDivisor(q+2,1),X.enableAttributeAndDivisor(q+3,1),I.bindBuffer(34962,E),I.vertexAttribPointer(q+0,4,x,!1,64,0),I.vertexAttribPointer(q+1,4,x,!1,64,16),I.vertexAttribPointer(q+2,4,x,!1,64,32),I.vertexAttribPointer(q+3,4,x,!1,64,48));else if(void 0!==z&&(u=z[ja],void 0!==u))switch(u.length){case 2:I.vertexAttrib2fv(q,u);break;case 3:I.vertexAttrib3fv(q,u);break;case 4:I.vertexAttrib4fv(q,u);break;default:I.vertexAttrib1fv(q,
24333 u)}}}X.disableUnusedAttributes()}null!==a&&I.bindBuffer(34963,k.buffer)}var ja=d.drawRange.start*n;m=null!==g?g.start*n:0;k=Math.max(ja,m);g=Math.max(0,Math.min(null!==a?a.count:c.count,ja+d.drawRange.count*n,m+(null!==g?g.count*n:Infinity))-1-k+1);0!==g&&(f.isMesh?!0===e.wireframe?(X.setLineWidth(e.wireframeLinewidth*(null===G?xa:1)),h.setMode(1)):h.setMode(4):f.isLine?(e=e.linewidth,void 0===e&&(e=1),X.setLineWidth(e*(null===G?xa:1)),f.isLineSegments?h.setMode(1):f.isLineLoop?h.setMode(2):h.setMode(3)):
24334 f.isPoints?h.setMode(0):f.isSprite&&h.setMode(4),f.isInstancedMesh?h.renderInstances(d,k,g,f.count):d.isInstancedBufferGeometry?h.renderInstances(d,k,g,Math.min(d.instanceCount,d._maxInstanceCount)):h.render(k,g))};this.compile=function(a,b){Q=wa.get(a,b);Q.init();a.traverse(function(a){a.isLight&&(Q.pushLight(a),a.castShadow&&Q.pushShadow(a))});Q.setupLights(b);var c={};a.traverse(function(b){var d=b.material;if(d)if(Array.isArray(d))for(var e=0;e<d.length;e++){var f=d[e];!1===f.uuid in c&&(n(f,
24335 a,b),c[f.uuid]=!0)}else!1===d.uuid in c&&(n(d,a,b),c[d.uuid]=!0)})};var Fa=null,Ba=new uh;Ba.setAnimationLoop(function(a){ua.isPresenting||Fa&&Fa(a)});"undefined"!==typeof window&&Ba.setContext(window);this.setAnimationLoop=function(a){Fa=a;ua.setAnimationLoop(a);Ba.start()};this.render=function(a,c,d,e){if(void 0!==d){console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead.");var f=d}if(void 0!==e){console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead.");
24336 var g=e}c&&c.isCamera?F||(V=b=null,Ke=!1,M=-1,ia=null,!0===a.autoUpdate&&a.updateMatrixWorld(),null===c.parent&&c.updateMatrixWorld(),ua.enabled&&ua.isPresenting&&(c=ua.getCamera(c)),a.onBeforeRender(y,a,c,f||G),Q=wa.get(a,c),Q.init(),la.multiplyMatrices(c.projectionMatrix,c.matrixWorldInverse),na.setFromProjectionMatrix(la),ig=this.localClippingEnabled,Je=ha.init(this.clippingPlanes,ig,c),B=ya.get(a,c),B.init(),l(a,c,0,y.sortObjects),B.finish(),!0===y.sortObjects&&B.sort(J,ca),Je&&ha.beginShadows(),
24337 Ga.render(Q.state.shadowsArray,a,c),Q.setupLights(c),Je&&ha.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==f&&this.setRenderTarget(f),qa.render(B,a,c,g),d=B.opaque,e=B.transparent,a.overrideMaterial?(f=a.overrideMaterial,d.length&&m(d,a,c,f),e.length&&m(e,a,c,f)):(d.length&&m(d,a,c),e.length&&m(e,a,c)),a.onAfterRender(y,a,c),null!==G&&(ba.updateRenderTargetMipmap(G),ba.updateMultisampleRenderTarget(G)),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),
24338 X.setPolygonOffset(!1),Q=B=null):console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")};this.setFramebuffer=function(a){D!==a&&null===G&&I.bindFramebuffer(36160,a);D=a};this.getActiveCubeFace=function(){return H};this.getActiveMipmapLevel=function(){return K};this.getRenderTarget=function(){return G};this.setRenderTarget=function(a,b,c){G=a;H=b;K=c;a&&void 0===P.get(a).__webglFramebuffer&&ba.setupRenderTarget(a);var d=D,e=!1;a?(d=P.get(a).__webglFramebuffer,a.isWebGLCubeRenderTarget?
24339 (d=d[b||0],e=!0):d=a.isWebGLMultisampleRenderTarget?P.get(a).__webglMultisampledFramebuffer:d,Y.copy(a.viewport),S.copy(a.scissor),aa=a.scissorTest):(Y.copy(da).multiplyScalar(xa).floor(),S.copy(ka).multiplyScalar(xa).floor(),aa=ma);L!==d&&(I.bindFramebuffer(36160,d),L=d);X.viewport(Y);X.scissor(S);X.setScissorTest(aa);e&&(a=P.get(a.texture),I.framebufferTexture2D(36160,36064,34069+(b||0),a.__webglTexture,c||0))};this.readRenderTargetPixels=function(a,b,c,d,e,f,g){if(a&&a.isWebGLRenderTarget){var h=
24340 P.get(a).__webglFramebuffer;a.isWebGLCubeRenderTarget&&void 0!==g&&(h=h[g]);if(h){g=!1;h!==L&&(I.bindFramebuffer(36160,h),g=!0);try{var l=a.texture,m=l.format,n=l.type;1023!==m&&ra.convert(m)!==I.getParameter(35739)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===n||ra.convert(n)===I.getParameter(35738)||1015===n&&(Ha.isWebGL2||sa.get("OES_texture_float")||sa.get("WEBGL_color_buffer_float"))||1016===n&&(Ha.isWebGL2?
24341 sa.get("EXT_color_buffer_float"):sa.get("EXT_color_buffer_half_float"))?36053===I.checkFramebufferStatus(36160)?0<=b&&b<=a.width-d&&0<=c&&c<=a.height-e&&I.readPixels(b,c,d,e,ra.convert(m),ra.convert(n),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{g&&I.bindFramebuffer(36160,L)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")};
24342 this.copyFramebufferToTexture=function(a,b,c){void 0===c&&(c=0);var d=Math.pow(2,-c),e=Math.floor(b.image.width*d);d=Math.floor(b.image.height*d);var f=ra.convert(b.format);ba.setTexture2D(b,0);I.copyTexImage2D(3553,c,f,a.x,a.y,e,d,0);X.unbindTexture()};this.copyTextureToTexture=function(a,b,c,d){void 0===d&&(d=0);var e=b.image.width,f=b.image.height,g=ra.convert(c.format),h=ra.convert(c.type);ba.setTexture2D(c,0);b.isDataTexture?I.texSubImage2D(3553,d,a.x,a.y,e,f,g,h,b.image.data):b.isCompressedTexture?
24343 I.compressedTexSubImage2D(3553,d,a.x,a.y,b.mipmaps[0].width,b.mipmaps[0].height,g,b.mipmaps[0].data):I.texSubImage2D(3553,d,a.x,a.y,g,h,b.image);0===d&&c.generateMipmaps&&I.generateMipmap(3553);X.unbindTexture()};this.initTexture=function(a){ba.setTexture2D(a,0);X.unbindTexture()};"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Ne(a,b){this.name="";this.color=new D(a);this.density=void 0!==b?b:2.5E-4}function Oe(a,b,c){this.name=
24344 "";this.color=new D(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3}function rb(a,b){this.array=a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.usage=35044;this.updateRange={offset:0,count:-1};this.version=0}function Kd(a,b,c,d){this.name="";this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0===d}function Kb(a){K.call(this);this.type="SpriteMaterial";this.color=new D(16777215);this.alphaMap=this.map=null;this.rotation=0;this.transparent=this.sizeAttenuation=!0;this.setValues(a)}
24345 function Ld(a){y.call(this);this.type="Sprite";if(void 0===Lc){Lc=new F;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 rb(b,5);Lc.setIndex([0,1,2,0,2,3]);Lc.setAttribute("position",new Kd(b,3,0,!1));Lc.setAttribute("uv",new Kd(b,2,3,!1))}this.geometry=Lc;this.material=void 0!==a?a:new Kb;this.center=new v(.5,.5)}function Pe(a,b,c,d,e,f){Mc.subVectors(a,c).addScalar(.5).multiply(d);void 0!==e?(Md.x=f*Mc.x-e*Mc.y,Md.y=e*Mc.x+f*Mc.y):Md.copy(Mc);a.copy(b);a.x+=Md.x;
24346 a.y+=Md.y;a.applyMatrix4(Wh)}function Nd(){y.call(this);this._currentLevel=0;this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]}});this.autoUpdate=!0}function Qe(a,b){a&&a.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");ea.call(this,a,b);this.type="SkinnedMesh";this.bindMode="attached";this.bindMatrix=new N;this.bindMatrixInverse=new N}function Re(a,b){a=a||[];this.bones=a.slice(0);this.boneMatrices=new Float32Array(16*
24347 this.bones.length);this.frame=-1;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."),this.boneInverses=[],a=0,b=this.bones.length;a<b;a++)this.boneInverses.push(new N)}function kg(){y.call(this);this.type="Bone"}function Se(a,b,c){ea.call(this,a,b);this.instanceMatrix=new G(new Float32Array(16*c),16);this.count=c;this.frustumCulled=!1}function da(a){K.call(this);this.type=
24348 "LineBasicMaterial";this.color=new D(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.morphTargets=!1;this.setValues(a)}function La(a,b,c){1===c&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.");y.call(this);this.type="Line";this.geometry=void 0!==a?a:new F;this.material=void 0!==b?b:new da;this.updateMorphTargets()}function ma(a,b){La.call(this,a,b);this.type="LineSegments"}function Te(a,b){La.call(this,a,b);this.type=
24349 "LineLoop"}function Xa(a){K.call(this);this.type="PointsMaterial";this.color=new D(16777215);this.alphaMap=this.map=null;this.size=1;this.sizeAttenuation=!0;this.morphTargets=!1;this.setValues(a)}function Nc(a,b){y.call(this);this.type="Points";this.geometry=void 0!==a?a:new F;this.material=void 0!==b?b:new Xa;this.updateMorphTargets()}function lg(a,b,c,d,e,f,g){var h=mg.distanceSqToPoint(a);h<c&&(c=new p,mg.closestPointToPoint(a,c),c.applyMatrix4(d),a=e.ray.origin.distanceTo(c),a<e.near||a>e.far||
24350 f.push({distance:a,distanceToRay:Math.sqrt(h),point:c,index:b,face:null,object:g}))}function ng(a,b,c,d,e,f,g,h,l){W.call(this,a,b,c,d,e,f,g,h,l);this.format=void 0!==g?g:1022;this.minFilter=void 0!==f?f:1006;this.magFilter=void 0!==e?e:1006;this.generateMipmaps=!1}function Oc(a,b,c,d,e,f,g,h,l,m,k,n){W.call(this,null,f,g,h,l,m,d,e,k,n);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function Od(a,b,c,d,e,f,g,h,l){W.call(this,a,b,c,d,e,f,g,h,l);this.needsUpdate=!0}
24351 function Pd(a,b,c,d,e,f,g,h,l,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);W.call(this,null,d,e,f,g,h,m,c,l);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 Pc(a){F.call(this);this.type="WireframeGeometry";var b=[],c,d,e,f=[0,0],g={},h=["a","b","c"];if(a&&
24352 a.isGeometry){var l=a.faces;var m=0;for(d=l.length;m<d;m++){var k=l[m];for(c=0;3>c;c++){var n=k[h[c]];var t=k[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){l=a.attributes.position;k=a.index;var r=a.groups;0===r.length&&(r=[{start:0,count:k.count,materialIndex:0}]);a=0;for(e=
24353 r.length;a<e;++a)for(m=r[a],c=m.start,d=m.count,m=c,d=c+d;m<d;m+=3)for(c=0;3>c;c++)n=k.getX(m+c),t=k.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(l,m.index1),b.push(h.x,h.y,h.z),h.fromBufferAttribute(l,m.index2),b.push(h.x,h.y,h.z)}else for(l=a.attributes.position,m=0,d=l.count/3;m<d;m++)for(c=0;3>c;c++)g=3*m+c,h.fromBufferAttribute(l,g),b.push(h.x,h.y,h.z),g=3*m+(c+1)%3,h.fromBufferAttribute(l,
24354 g),b.push(h.x,h.y,h.z);this.setAttribute("position",new B(b,3))}function Qd(a,b,c){L.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new Qc(a,b,c));this.mergeVertices()}function Qc(a,b,c){F.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g=[],h=new p,l=new p,m=new p,k=new p,n=new p,t,r;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");
24355 var q=b+1;for(t=0;t<=c;t++){var u=t/c;for(r=0;r<=b;r++){var E=r/b;a(E,u,l);e.push(l.x,l.y,l.z);0<=E-1E-5?(a(E-1E-5,u,m),k.subVectors(l,m)):(a(E+1E-5,u,m),k.subVectors(m,l));0<=u-1E-5?(a(E,u-1E-5,m),n.subVectors(l,m)):(a(E,u+1E-5,m),n.subVectors(m,l));h.crossVectors(k,n).normalize();f.push(h.x,h.y,h.z);g.push(E,u)}}for(t=0;t<c;t++)for(r=0;r<b;r++)a=t*q+r+1,h=(t+1)*q+r+1,l=(t+1)*q+r,d.push(t*q+r,a,l),d.push(a,h,l);this.setIndex(d);this.setAttribute("position",new B(e,3));this.setAttribute("normal",
24356 new B(f,3));this.setAttribute("uv",new B(g,2))}function Rd(a,b,c,d){L.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};this.fromBufferGeometry(new Ga(a,b,c,d));this.mergeVertices()}function Ga(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&&(l[b]=a.x-1);0===c.x&&0===c.z&&(l[b]=d/2/Math.PI+.5)}F.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a,
24357 indices:b,radius:c,detail:d};c=c||1;d=d||0;var h=[],l=[];(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 l,m,k=c,x=d,w=g,v=Math.pow(2,a),T=[];for(m=0;m<=v;m++){T[m]=[];var Z=k.clone().lerp(w,m/v),C=x.clone().lerp(w,m/v),y=v-m;for(l=0;l<=y;l++)T[m][l]=0===l&&m===v?Z:Z.clone().lerp(C,l/y)}for(m=0;m<v;m++)for(l=0;l<2*(v-m)-1;l++)k=Math.floor(l/2),0===l%2?(e(T[m][k+1]),e(T[m+1][k]),e(T[m][k])):(e(T[m][k+1]),e(T[m+1][k+1]),e(T[m+1][k]))}})(d);(function(a){for(var b=
24358 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],l.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 v,f=new v,k=new v,E=0,x=0;E<h.length;E+=9,x+=6){a.set(h[E+0],h[E+1],h[E+2]);b.set(h[E+3],h[E+4],h[E+5]);c.set(h[E+6],h[E+7],h[E+8]);e.set(l[x+0],
24359 l[x+1]);f.set(l[x+2],l[x+3]);k.set(l[x+4],l[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(k,x+4,c,w)}for(a=0;a<l.length;a+=6)b=l[a+0],c=l[a+2],d=l[a+4],e=Math.min(b,c,d),.9<Math.max(b,c,d)&&.1>e&&(.2>b&&(l[a+0]+=1),.2>c&&(l[a+2]+=1),.2>d&&(l[a+4]+=1))})();this.setAttribute("position",new B(h,3));this.setAttribute("normal",new B(h.slice(),3));this.setAttribute("uv",new B(l,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Sd(a,
24360 b){L.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Rc(a,b));this.mergeVertices()}function Rc(a,b){Ga.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 Td(a,b){L.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new bc(a,b));this.mergeVertices()}function bc(a,b){Ga.call(this,[1,0,0,
24361 -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 Ud(a,b){L.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Sc(a,b));this.mergeVertices()}function Sc(a,b){var c=(1+Math.sqrt(5))/2;Ga.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,
24362 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 Vd(a,b){L.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Tc(a,b));this.mergeVertices()}function Tc(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;Ga.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,
24363 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 Wd(a,b,c,d,e,f){L.call(this);this.type="TubeGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,
24364 closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new cc(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function cc(a,b,c,d,e){function f(e){k=a.getPointAt(e/b,k);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);l.x=m*f.x+n*e.x;l.y=m*f.y+n*e.y;l.z=m*f.z+n*e.z;l.normalize();q.push(l.x,l.y,l.z);h.x=k.x+c*l.x;h.y=k.y+c*l.y;h.z=
24365 k.z+c*l.z;r.push(h.x,h.y,h.z)}}F.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,l=new p,m=new v,k=new p,n,t,r=[],q=[],u=[],E=[];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,u.push(m.x,m.y);(function(){for(t=1;t<=b;t++)for(n=1;n<=d;n++){var a=
24366 (d+1)*t+(n-1),c=(d+1)*t+n,e=(d+1)*(t-1)+n;E.push((d+1)*(t-1)+(n-1),a,e);E.push(a,c,e)}})();this.setIndex(E);this.setAttribute("position",new B(r,3));this.setAttribute("normal",new B(q,3));this.setAttribute("uv",new B(u,2))}function Xd(a,b,c,d,e,f,g){L.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 Uc(a,
24367 b,c,d,e,f));this.mergeVertices()}function Uc(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}F.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=[],l=[],m=[],k=[],n,t=new p,r=new p,q=new p,u=new p,E=new p,x=new p,w=new p;for(n=0;n<=c;++n){var v=n/c*e*Math.PI*2;
24368 g(v,e,f,a,q);g(v+.01,e,f,a,u);x.subVectors(u,q);w.addVectors(u,q);E.crossVectors(x,w);w.crossVectors(E,x);E.normalize();w.normalize();for(v=0;v<=d;++v){var T=v/d*Math.PI*2,Z=-b*Math.cos(T);T=b*Math.sin(T);t.x=q.x+(Z*w.x+T*E.x);t.y=q.y+(Z*w.y+T*E.y);t.z=q.z+(Z*w.z+T*E.z);l.push(t.x,t.y,t.z);r.subVectors(t,q).normalize();m.push(r.x,r.y,r.z);k.push(n/c);k.push(v/d)}}for(v=1;v<=c;v++)for(n=1;n<=d;n++)a=(d+1)*v+(n-1),b=(d+1)*v+n,e=(d+1)*(v-1)+n,h.push((d+1)*(v-1)+(n-1),a,e),h.push(a,b,e);this.setIndex(h);
24369 this.setAttribute("position",new B(l,3));this.setAttribute("normal",new B(m,3));this.setAttribute("uv",new B(k,2))}function Yd(a,b,c,d,e){L.call(this);this.type="TorusGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};this.fromBufferGeometry(new Vc(a,b,c,d,e));this.mergeVertices()}function Vc(a,b,c,d,e){F.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)||
24370 6;e=e||2*Math.PI;var f=[],g=[],h=[],l=[],m=new p,k=new p,n=new p,t,r;for(t=0;t<=c;t++)for(r=0;r<=d;r++){var q=r/d*e,u=t/c*Math.PI*2;k.x=(a+b*Math.cos(u))*Math.cos(q);k.y=(a+b*Math.cos(u))*Math.sin(q);k.z=b*Math.sin(u);g.push(k.x,k.y,k.z);m.x=a*Math.cos(q);m.y=a*Math.sin(q);n.subVectors(k,m).normalize();h.push(n.x,n.y,n.z);l.push(r/d);l.push(t/c)}for(t=1;t<=c;t++)for(r=1;r<=d;r++)a=(d+1)*(t-1)+r-1,b=(d+1)*(t-1)+r,e=(d+1)*t+r,f.push((d+1)*t+r-1,a,e),f.push(a,b,e);this.setIndex(f);this.setAttribute("position",
24371 new B(g,3));this.setAttribute("normal",new B(h,3));this.setAttribute("uv",new B(l,2))}function Xh(a,b,c,d,e){for(var f,g=0,h=b,l=c-d;h<c;h+=d)g+=(a[l]-a[h])*(a[h+1]+a[l+1]),l=h;if(e===0<g)for(e=b;e<c;e+=d)f=Yh(e,a[e],a[e+1],f);else for(e=c-d;e>=b;e-=d)f=Yh(e,a[e],a[e+1],f);f&&Ue(f,f.next)&&(Zd(f),f=f.next);return f}function Lb(a,b){if(!a)return a;b||(b=a);do{var c=!1;if(a.steiner||!Ue(a,a.next)&&0!==na(a.prev,a,a.next))a=a.next;else{Zd(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b}
24372 function $d(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,l=h;do null===l.z&&(l.z=og(l.x,l.y,d,e,f)),l.prevZ=l.prev,l=l.nextZ=l.next;while(l!==h);l.prevZ.nextZ=null;l.prevZ=null;h=l;var m,k,n,t,r=1;do{l=h;var q=h=null;for(k=0;l;){k++;var p=l;for(m=n=0;m<r&&(n++,p=p.nextZ,p);m++);for(t=r;0<n||0<t&&p;)0!==n&&(0===t||!p||l.z<=p.z)?(m=l,l=l.nextZ,n--):(m=p,p=p.nextZ,t--),q?q.nextZ=m:h=m,m.prevZ=q,q=m;l=p}q.nextZ=null;r*=2}while(1<k)}for(h=a;a.prev!==a.next;){l=a.prev;p=a.next;if(f)q=Ak(a,d,e,f);else a:if(q=
24373 a,k=q.prev,n=q,r=q.next,0<=na(k,n,r))q=!1;else{for(m=q.next.next;m!==q.prev;){if(Wc(k.x,k.y,n.x,n.y,r.x,r.y,m.x,m.y)&&0<=na(m.prev,m,m.next)){q=!1;break a}m=m.next}q=!0}if(q)b.push(l.i/c),b.push(a.i/c),b.push(p.i/c),Zd(a),h=a=p.next;else if(a=p,a===h){if(!g)$d(Lb(a),b,c,d,e,f,1);else if(1===g){a=Lb(a);g=b;h=c;l=a;do p=l.prev,q=l.next.next,!Ue(p,q)&&Zh(p,l,l.next,q)&&ae(p,q)&&ae(q,p)&&(g.push(p.i/h),g.push(l.i/h),g.push(q.i/h),Zd(l),Zd(l.next),l=a=q),l=l.next;while(l!==a);a=Lb(l);$d(a,b,c,d,e,f,2)}else if(2===
24374 g)a:{g=a;do{for(h=g.next.next;h!==g.prev;){if(l=g.i!==h.i){l=g;p=h;if(q=l.next.i!==p.i&&l.prev.i!==p.i){b:{q=l;do{if(q.i!==l.i&&q.next.i!==l.i&&q.i!==p.i&&q.next.i!==p.i&&Zh(q,q.next,l,p)){q=!0;break b}q=q.next}while(q!==l);q=!1}q=!q}if(q){if(q=ae(l,p)&&ae(p,l)){q=l;k=!1;n=(l.x+p.x)/2;r=(l.y+p.y)/2;do q.y>r!==q.next.y>r&&q.next.y!==q.y&&n<(q.next.x-q.x)*(r-q.y)/(q.next.y-q.y)+q.x&&(k=!k),q=q.next;while(q!==l);q=k}q=q&&(na(l.prev,l,p.prev)||na(l,p.prev,p))||Ue(l,p)&&0<na(l.prev,l,l.next)&&0<na(p.prev,
24375 p,p.next)}l=q}if(l){a=$h(g,h);g=Lb(g,g.next);a=Lb(a,a.next);$d(g,b,c,d,e,f);$d(a,b,c,d,e,f);break a}h=h.next}g=g.next}while(g!==a)}break}}}}function Ak(a,b,c,d){var e=a.prev,f=a.next;if(0<=na(e,a,f))return!1;var g=e.x>a.x?e.x>f.x?e.x:f.x:a.x>f.x?a.x:f.x,h=e.y>a.y?e.y>f.y?e.y:f.y:a.y>f.y?a.y:f.y,l=og(e.x<a.x?e.x<f.x?e.x:f.x:a.x<f.x?a.x:f.x,e.y<a.y?e.y<f.y?e.y:f.y:a.y<f.y?a.y:f.y,b,c,d);b=og(g,h,b,c,d);c=a.prevZ;for(d=a.nextZ;c&&c.z>=l&&d&&d.z<=b;){if(c!==a.prev&&c!==a.next&&Wc(e.x,e.y,a.x,a.y,f.x,
24376 f.y,c.x,c.y)&&0<=na(c.prev,c,c.next))return!1;c=c.prevZ;if(d!==a.prev&&d!==a.next&&Wc(e.x,e.y,a.x,a.y,f.x,f.y,d.x,d.y)&&0<=na(d.prev,d,d.next))return!1;d=d.nextZ}for(;c&&c.z>=l;){if(c!==a.prev&&c!==a.next&&Wc(e.x,e.y,a.x,a.y,f.x,f.y,c.x,c.y)&&0<=na(c.prev,c,c.next))return!1;c=c.prevZ}for(;d&&d.z<=b;){if(d!==a.prev&&d!==a.next&&Wc(e.x,e.y,a.x,a.y,f.x,f.y,d.x,d.y)&&0<=na(d.prev,d,d.next))return!1;d=d.nextZ}return!0}function Bk(a,b){return a.x-b.x}function Ck(a,b){var c=b,d=a.x,e=a.y,f=-Infinity;do{if(e<=
24377 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;b=h;g=h.x;var l=h.y,m=Infinity;c=h;do{if(d>=c.x&&c.x>=g&&d!==c.x&&Wc(e<l?d:f,e,g,l,e<l?f:d,e,c.x,c.y)){var k=Math.abs(e-c.y)/(d-c.x);var n;if((n=ae(c,a))&&!(n=k<m)&&(n=k===m)&&!(n=c.x>h.x)&&(n=c.x===h.x)){n=h;var t=c;n=0>na(n.prev,n,t.prev)&&0>na(t.next,
24378 n,n.next)}n&&(h=c,m=k)}c=c.next}while(c!==b);return h}function og(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 Dk(a){var b=a,c=a;do{if(b.x<c.x||b.x===c.x&&b.y<c.y)c=b;b=b.next}while(b!==a);return c}function Wc(a,b,c,d,e,f,g,h){return 0<=(e-g)*(b-h)-(a-g)*(f-h)&&0<=(a-g)*(d-h)-(c-g)*(b-h)&&0<=(c-g)*(f-h)-(e-g)*(d-h)}function na(a,
24379 b,c){return(b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y)}function Ue(a,b){return a.x===b.x&&a.y===b.y}function Zh(a,b,c,d){var e=Ve(na(a,b,c)),f=Ve(na(a,b,d)),g=Ve(na(c,d,a)),h=Ve(na(c,d,b));return e!==f&&g!==h||0===e&&We(a,c,b)||0===f&&We(a,d,b)||0===g&&We(c,a,d)||0===h&&We(c,b,d)?!0:!1}function We(a,b,c){return b.x<=Math.max(a.x,c.x)&&b.x>=Math.min(a.x,c.x)&&b.y<=Math.max(a.y,c.y)&&b.y>=Math.min(a.y,c.y)}function Ve(a){return 0<a?1:0>a?-1:0}function ae(a,b){return 0>na(a.prev,a,a.next)?0<=na(a,b,a.next)&&
24380 0<=na(a,a.prev,b):0>na(a,b,a.prev)||0>na(a,a.next,b)}function $h(a,b){var c=new pg(a.i,a.x,a.y),d=new pg(b.i,b.x,b.y),e=a.next,f=b.prev;a.next=b;b.prev=a;c.next=e;e.prev=c;d.next=c;c.prev=d;f.next=d;d.prev=f;return d}function Yh(a,b,c,d){a=new pg(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 Zd(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 pg(a,b,c){this.i=a;this.x=b;this.y=c;this.nextZ=
24381 this.prevZ=this.z=this.next=this.prev=null;this.steiner=!1}function ai(a){var b=a.length;2<b&&a[b-1].equals(a[0])&&a.pop()}function bi(a,b){for(var c=0;c<b.length;c++)a.push(b[c].x),a.push(b[c].y)}function dc(a,b){L.call(this);this.type="ExtrudeGeometry";this.parameters={shapes:a,options:b};this.fromBufferGeometry(new hb(a,b));this.mergeVertices()}function hb(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)}
24382 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 l=Math.sqrt(h),m=Math.sqrt(f*f+g*g);h=b.x-e/l;b=b.y+d/l;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 v(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 v(f/e,d/
24383 e)}function h(a,b){for(J=a.length;0<=--J;){var c=J;var f=J-1;0>f&&(f=a.length-1);var g,h=w+2*B;for(g=0;g<h;g++){var l=W*g,m=W*(g+1),k=b+f+l,n=b+f+m;m=b+c+m;q(b+c+l);q(k);q(m);q(k);q(n);q(m);l=e.length/3;l=F.generateSideWallUV(d,e,l-6,l-3,l-2,l-1);u(l[0]);u(l[1]);u(l[3]);u(l[1]);u(l[2]);u(l[3])}}}function l(a,b,c){E.push(a);E.push(b);E.push(c)}function k(a,b,c){q(a);q(b);q(c);a=e.length/3;a=F.generateTopUV(d,e,a-3,a-2,a-1);u(a[0]);u(a[1]);u(a[2])}function q(a){e.push(E[3*a]);e.push(E[3*a+1]);e.push(E[3*
24384 a+2])}function u(a){f.push(a.x);f.push(a.y)}var E=[],x=void 0!==b.curveSegments?b.curveSegments:12,w=void 0!==b.steps?b.steps:1,ja=void 0!==b.depth?b.depth:100,T=void 0!==b.bevelEnabled?b.bevelEnabled:!0,Z=void 0!==b.bevelThickness?b.bevelThickness:6,C=void 0!==b.bevelSize?b.bevelSize:Z-2,y=void 0!==b.bevelOffset?b.bevelOffset:0,B=void 0!==b.bevelSegments?b.bevelSegments:3,A=b.extrudePath,F=void 0!==b.UVGenerator?b.UVGenerator:Ek;void 0!==b.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),
24385 ja=b.amount);var D=!1;if(A){var G=A.getSpacedPoints(w);D=!0;T=!1;var H=A.computeFrenetFrames(w,!1);var K=new p;var L=new p;var N=new p}T||(y=C=Z=B=0);var O;x=a.extractPoints(x);a=x.shape;var M=x.holes;if(!sb.isClockWise(a)){a=a.reverse();var ia=0;for(O=M.length;ia<O;ia++){var P=M[ia];sb.isClockWise(P)&&(M[ia]=P.reverse())}}var Y=sb.triangulateShape(a,M),V=a;ia=0;for(O=M.length;ia<O;ia++)P=M[ia],a=a.concat(P);var aa,W=a.length,R,ea=Y.length;x=[];var J=0;var ca=V.length;var S=ca-1;for(aa=J+1;J<ca;J++,
24386 S++,aa++)S===ca&&(S=0),aa===ca&&(aa=0),x[J]=g(V[J],V[S],V[aa]);A=[];var fa=x.concat();ia=0;for(O=M.length;ia<O;ia++){P=M[ia];var ba=[];J=0;ca=P.length;S=ca-1;for(aa=J+1;J<ca;J++,S++,aa++)S===ca&&(S=0),aa===ca&&(aa=0),ba[J]=g(P[J],P[S],P[aa]);A.push(ba);fa=fa.concat(ba)}for(S=0;S<B;S++){ca=S/B;var da=Z*Math.cos(ca*Math.PI/2);aa=C*Math.sin(ca*Math.PI/2)+y;J=0;for(ca=V.length;J<ca;J++){var ha=c(V[J],x[J],aa);l(ha.x,ha.y,-da)}ia=0;for(O=M.length;ia<O;ia++)for(P=M[ia],ba=A[ia],J=0,ca=P.length;J<ca;J++)ha=
24387 c(P[J],ba[J],aa),l(ha.x,ha.y,-da)}aa=C+y;for(J=0;J<W;J++)ha=T?c(a[J],fa[J],aa):a[J],D?(L.copy(H.normals[0]).multiplyScalar(ha.x),K.copy(H.binormals[0]).multiplyScalar(ha.y),N.copy(G[0]).add(L).add(K),l(N.x,N.y,N.z)):l(ha.x,ha.y,0);for(ca=1;ca<=w;ca++)for(J=0;J<W;J++)ha=T?c(a[J],fa[J],aa):a[J],D?(L.copy(H.normals[ca]).multiplyScalar(ha.x),K.copy(H.binormals[ca]).multiplyScalar(ha.y),N.copy(G[ca]).add(L).add(K),l(N.x,N.y,N.z)):l(ha.x,ha.y,ja/w*ca);for(S=B-1;0<=S;S--){ca=S/B;da=Z*Math.cos(ca*Math.PI/
24388 2);aa=C*Math.sin(ca*Math.PI/2)+y;J=0;for(ca=V.length;J<ca;J++)ha=c(V[J],x[J],aa),l(ha.x,ha.y,ja+da);ia=0;for(O=M.length;ia<O;ia++)for(P=M[ia],ba=A[ia],J=0,ca=P.length;J<ca;J++)ha=c(P[J],ba[J],aa),D?l(ha.x,ha.y+G[w-1].y,G[w-1].x+da):l(ha.x,ha.y,ja+da)}(function(){var a=e.length/3;if(T){var b=0*W;for(J=0;J<ea;J++)R=Y[J],k(R[2]+b,R[1]+b,R[0]+b);b=W*(w+2*B);for(J=0;J<ea;J++)R=Y[J],k(R[0]+b,R[1]+b,R[2]+b)}else{for(J=0;J<ea;J++)R=Y[J],k(R[2],R[1],R[0]);for(J=0;J<ea;J++)R=Y[J],k(R[0]+W*w,R[1]+W*w,R[2]+W*
24389 w)}d.addGroup(a,e.length/3-a,0)})();(function(){var a=e.length/3,b=0;h(V,b);b+=V.length;ia=0;for(O=M.length;ia<O;ia++)P=M[ia],h(P,b),b+=P.length;d.addGroup(a,e.length/3-a,1)})()}F.call(this);this.type="ExtrudeBufferGeometry";this.parameters={shapes:a,options:b};a=Array.isArray(a)?a:[a];for(var d=this,e=[],f=[],g=0,h=a.length;g<h;g++)c(a[g]);this.setAttribute("position",new B(e,3));this.setAttribute("uv",new B(f,2));this.computeVertexNormals()}function ci(a,b,c){c.shapes=[];if(Array.isArray(a))for(var d=
24390 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 be(a,b){L.call(this);this.type="TextGeometry";this.parameters={text:a,parameters:b};this.fromBufferGeometry(new Xc(a,b));this.mergeVertices()}function Xc(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 L;a=c.generateShapes(a,b.size);b.depth=void 0!==
24391 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);hb.call(this,a,b);this.type="TextBufferGeometry"}function ce(a,b,c,d,e,f,g){L.call(this);this.type="SphereGeometry";this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};this.fromBufferGeometry(new ec(a,b,c,d,e,f,g));this.mergeVertices()}function ec(a,b,c,d,e,f,g){F.call(this);this.type="SphereBufferGeometry";
24392 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=Math.min(f+g,Math.PI),l,m,k=0,n=[],t=new p,r=new p,q=[],u=[],E=[],v=[];for(m=0;m<=c;m++){var w=[],y=m/c,T=0;0==m&&0==f?T=.5/b:m==c&&h==Math.PI&&(T=-.5/b);for(l=0;l<=b;l++){var Z=l/b;t.x=-a*Math.cos(d+Z*e)*Math.sin(f+y*g);t.y=a*Math.cos(f+
24393 y*g);t.z=a*Math.sin(d+Z*e)*Math.sin(f+y*g);u.push(t.x,t.y,t.z);r.copy(t).normalize();E.push(r.x,r.y,r.z);v.push(Z+T,1-y);w.push(k++)}n.push(w)}for(m=0;m<c;m++)for(l=0;l<b;l++)a=n[m][l+1],d=n[m][l],e=n[m+1][l],g=n[m+1][l+1],(0!==m||0<f)&&q.push(a,d,g),(m!==c-1||h<Math.PI)&&q.push(d,e,g);this.setIndex(q);this.setAttribute("position",new B(u,3));this.setAttribute("normal",new B(E,3));this.setAttribute("uv",new B(v,2))}function de(a,b,c,d,e,f){L.call(this);this.type="RingGeometry";this.parameters={innerRadius:a,
24394 outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f};this.fromBufferGeometry(new Yc(a,b,c,d,e,f));this.mergeVertices()}function Yc(a,b,c,d,e,f){F.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;c=void 0!==c?Math.max(3,c):8;d=void 0!==d?Math.max(1,d):1;var g=[],h=[],l=[],m=[],k=a,n=(b-a)/d,t=new p,r=new v,q,u;for(q=0;q<=d;q++){for(u=
24395 0;u<=c;u++)a=e+u/c*f,t.x=k*Math.cos(a),t.y=k*Math.sin(a),h.push(t.x,t.y,t.z),l.push(0,0,1),r.x=(t.x/b+1)/2,r.y=(t.y/b+1)/2,m.push(r.x,r.y);k+=n}for(q=0;q<d;q++)for(b=q*(c+1),u=0;u<c;u++)a=u+b,e=a+c+1,f=a+c+2,k=a+1,g.push(a,e,k),g.push(e,f,k);this.setIndex(g);this.setAttribute("position",new B(h,3));this.setAttribute("normal",new B(l,3));this.setAttribute("uv",new B(m,2))}function ee(a,b,c,d){L.call(this);this.type="LatheGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};this.fromBufferGeometry(new Zc(a,
24396 b,c,d));this.mergeVertices()}function Zc(a,b,c,d){F.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=O.clamp(d,0,2*Math.PI);var e=[],f=[],g=[],h=1/b,l=new p,m=new v,k;for(k=0;k<=b;k++){var n=c+k*h*d;var t=Math.sin(n),r=Math.cos(n);for(n=0;n<=a.length-1;n++)l.x=a[n].x*t,l.y=a[n].y,l.z=a[n].x*r,f.push(l.x,l.y,l.z),m.x=k/b,m.y=n/(a.length-1),g.push(m.x,m.y)}for(k=0;k<b;k++)for(n=0;n<a.length-1;n++)c=n+
24397 k*a.length,h=c+a.length,l=c+a.length+1,m=c+1,e.push(c,h,m),e.push(h,l,m);this.setIndex(e);this.setAttribute("position",new B(f,3));this.setAttribute("uv",new B(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=k=0;k<a.length;k++,n+=3)e.x=d[n+0],e.y=d[n+1],e.z=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 fc(a,b){L.call(this);
24398 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 gc(a,b));this.mergeVertices()}function gc(a,b){function c(a){var c,h=e.length/3;a=a.extractPoints(b);var m=a.shape,k=a.holes;!1===sb.isClockWise(m)&&(m=m.reverse());a=0;for(c=k.length;a<c;a++){var z=k[a];!0===sb.isClockWise(z)&&(k[a]=z.reverse())}var p=sb.triangulateShape(m,k);a=0;for(c=k.length;a<
24399 c;a++)z=k[a],m=m.concat(z);a=0;for(c=m.length;a<c;a++)z=m[a],e.push(z.x,z.y,0),f.push(0,0,1),g.push(z.x,z.y);a=0;for(c=p.length;a<c;a++)m=p[a],d.push(m[0]+h,m[1]+h,m[2]+h),l+=3}F.call(this);this.type="ShapeBufferGeometry";this.parameters={shapes:a,curveSegments:b};b=b||12;var d=[],e=[],f=[],g=[],h=0,l=0;if(!1===Array.isArray(a))c(a);else for(var m=0;m<a.length;m++)c(a[m]),this.addGroup(h,l,m),h+=l,l=0;this.setIndex(d);this.setAttribute("position",new B(e,3));this.setAttribute("normal",new B(f,3));
24400 this.setAttribute("uv",new B(g,2))}function di(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 $c(a,b){F.call(this);this.type="EdgesGeometry";this.parameters={thresholdAngle:b};var c=[];b=Math.cos(O.DEG2RAD*(void 0!==b?b:1));var d=[0,0],e={},f=["a","b","c"];if(a.isBufferGeometry){var g=new L;g.fromBufferGeometry(a)}else g=a.clone();g.mergeVertices();g.computeFaceNormals();a=g.vertices;g=g.faces;for(var h=0,l=
24401 g.length;h<l;h++)for(var m=g[h],k=0;3>k;k++){var n=m[f[k]];var t=m[f[(k+1)%3]];d[0]=Math.min(n,t);d[1]=Math.max(n,t);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],c.push(f.x,f.y,f.z);this.setAttribute("position",new B(c,3))}function hc(a,b,c,d,e,f,g,h){L.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,
24402 radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new tb(a,b,c,d,e,f,g,h));this.mergeVertices()}function tb(a,b,c,d,e,f,g,h){function l(c){var e,f=new v,l=new p,z=0,u=!0===c?a:b,w=!0===c?1:-1;var y=q;for(e=1;e<=d;e++)n.push(0,E*w,0),t.push(0,w,0),r.push(.5,.5),q++;var B=q;for(e=0;e<=d;e++){var A=e/d*h+g,D=Math.cos(A);A=Math.sin(A);l.x=u*A;l.y=E*w;l.z=u*D;n.push(l.x,l.y,l.z);t.push(0,w,0);f.x=.5*D+.5;f.y=.5*A*w+.5;r.push(f.x,f.y);
24403 q++}for(e=0;e<d;e++)f=y+e,l=B+e,!0===c?k.push(l,l+1,f):k.push(l+1,l,f),z+=3;m.addGroup(x,z,!0===c?1:2);x+=z}F.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)||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 k=[],n=[],t=[],r=[],q=0,u=[],E=c/2,x=0;(function(){var f,l,z=new p,
24404 v=new p,C=0,y=(b-a)/c;for(l=0;l<=e;l++){var B=[],A=l/e,D=A*(b-a)+a;for(f=0;f<=d;f++){var F=f/d,G=F*h+g,H=Math.sin(G);G=Math.cos(G);v.x=D*H;v.y=-A*c+E;v.z=D*G;n.push(v.x,v.y,v.z);z.set(H,y,G).normalize();t.push(z.x,z.y,z.z);r.push(F,1-A);B.push(q++)}u.push(B)}for(f=0;f<d;f++)for(l=0;l<e;l++)z=u[l+1][f],v=u[l+1][f+1],y=u[l][f+1],k.push(u[l][f],z,y),k.push(z,v,y),C+=6;m.addGroup(x,C,0);x+=C})();!1===f&&(0<a&&l(!0),0<b&&l(!1));this.setIndex(k);this.setAttribute("position",new B(n,3));this.setAttribute("normal",
24405 new B(t,3));this.setAttribute("uv",new B(r,2))}function fe(a,b,c,d,e,f,g){hc.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 ge(a,b,c,d,e,f,g){tb.call(this,0,a,b,c,d,e,f,g);this.type="ConeBufferGeometry";this.parameters={radius:a,height:b,radialSegments:c,heightSegments:d,openEnded:e,thetaStart:f,thetaLength:g}}function he(a,b,c,d){L.call(this);this.type="CircleGeometry";this.parameters=
24406 {radius:a,segments:b,thetaStart:c,thetaLength:d};this.fromBufferGeometry(new ad(a,b,c,d));this.mergeVertices()}function ad(a,b,c,d){F.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=[],g=[],h=[],l,m=new p,k=new v;f.push(0,0,0);g.push(0,0,1);h.push(.5,.5);var n=0;for(l=3;n<=b;n++,l+=3){var t=c+n/b*d;m.x=a*Math.cos(t);m.y=a*Math.sin(t);f.push(m.x,m.y,
24407 m.z);g.push(0,0,1);k.x=(f[l]/a+1)/2;k.y=(f[l+1]/a+1)/2;h.push(k.x,k.y)}for(l=1;l<=b;l++)e.push(l,l+1,0);this.setIndex(e);this.setAttribute("position",new B(f,3));this.setAttribute("normal",new B(g,3));this.setAttribute("uv",new B(h,2))}function ic(a){K.call(this);this.type="ShadowMaterial";this.color=new D(0);this.transparent=!0;this.setValues(a)}function ub(a){Ca.call(this,a);this.type="RawShaderMaterial"}function ib(a){K.call(this);this.defines={STANDARD:""};this.type="MeshStandardMaterial";this.color=
24408 new D(16777215);this.roughness=1;this.metalness=0;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new D(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new v(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.envMap=this.alphaMap=this.metalnessMap=this.roughnessMap=null;this.envMapIntensity=1;this.refractionRatio=.98;this.wireframe=
24409 !1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexTangents=this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function jc(a){ib.call(this);this.defines={STANDARD:"",PHYSICAL:""};this.type="MeshPhysicalMaterial";this.clearcoat=0;this.clearcoatMap=null;this.clearcoatRoughness=0;this.clearcoatRoughnessMap=null;this.clearcoatNormalScale=new v(1,1);this.clearcoatNormalMap=null;this.reflectivity=.5;this.sheen=null;this.transparency=0;this.setValues(a)}
24410 function Mb(a){K.call(this);this.type="MeshPhongMaterial";this.color=new D(16777215);this.specular=new D(1118481);this.shininess=30;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new D(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new v(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.envMap=this.alphaMap=this.specularMap=
24411 null;this.combine=0;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 kc(a){K.call(this);this.defines={TOON:""};this.type="MeshToonMaterial";this.color=new D(16777215);this.specular=new D(1118481);this.shininess=30;this.lightMap=this.gradientMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=
24412 new D(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new v(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.alphaMap=this.specularMap=null;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function lc(a){K.call(this);this.type="MeshNormalMaterial";this.bumpMap=
24413 null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new v(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.morphNormals=this.morphTargets=this.skinning=this.fog=!1;this.setValues(a)}function mc(a){K.call(this);this.type="MeshLambertMaterial";this.color=new D(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new D(0);this.emissiveIntensity=
24414 1;this.envMap=this.alphaMap=this.specularMap=this.emissiveMap=null;this.combine=0;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 nc(a){K.call(this);this.defines={MATCAP:""};this.type="MeshMatcapMaterial";this.color=new D(16777215);this.bumpMap=this.map=this.matcap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=
24415 0;this.normalScale=new v(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.alphaMap=null;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function oc(a){da.call(this);this.type="LineDashedMaterial";this.scale=1;this.dashSize=3;this.gapSize=1;this.setValues(a)}function Ma(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 Xe(a,b,c,d){Ma.call(this,
24416 a,b,c,d);this._offsetNext=this._weightNext=this._offsetPrev=this._weightPrev=-0}function ie(a,b,c,d){Ma.call(this,a,b,c,d)}function Ye(a,b,c,d){Ma.call(this,a,b,c,d)}function ta(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=ka.convertArray(b,this.TimeBufferType);this.values=ka.convertArray(c,this.ValueBufferType);this.setInterpolation(d||this.DefaultInterpolation)}
24417 function Ze(a,b,c){ta.call(this,a,b,c)}function $e(a,b,c,d){ta.call(this,a,b,c,d)}function bd(a,b,c,d){ta.call(this,a,b,c,d)}function af(a,b,c,d){Ma.call(this,a,b,c,d)}function je(a,b,c,d){ta.call(this,a,b,c,d)}function bf(a,b,c,d){ta.call(this,a,b,c,d)}function cd(a,b,c,d){ta.call(this,a,b,c,d)}function Sa(a,b,c,d){this.name=a;this.tracks=c;this.duration=void 0!==b?b:-1;this.blendMode=void 0!==d?d:2500;this.uuid=O.generateUUID();0>this.duration&&this.resetDuration()}function Fk(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return bd;
24418 case "vector":case "vector2":case "vector3":case "vector4":return cd;case "color":return $e;case "quaternion":return je;case "bool":case "boolean":return Ze;case "string":return bf}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+a);}function Gk(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var b=Fk(a.type);if(void 0===a.times){var c=[],d=[];ka.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,
24419 a.times,a.values,a.interpolation)}function qg(a,b,c){var d=this,e=!1,f=0,g=0,h=void 0,l=[];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,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=
24420 a;return this};this.addHandler=function(a,b){l.push(a,b);return this};this.removeHandler=function(a){a=l.indexOf(a);-1!==a&&l.splice(a,2);return this};this.getHandler=function(a){for(var b=0,c=l.length;b<c;b+=2){var d=l[b],e=l[b+1];d.global&&(d.lastIndex=0);if(d.test(a))return e}return null}}function V(a){this.manager=void 0!==a?a:ei;this.crossOrigin="anonymous";this.resourcePath=this.path="";this.requestHeader={}}function Ta(a){V.call(this,a)}function rg(a){V.call(this,a)}function sg(a){V.call(this,
24421 a)}function cf(a){V.call(this,a)}function dd(a){V.call(this,a)}function df(a){V.call(this,a)}function ef(a){V.call(this,a)}function H(){this.type="Curve";this.arcLengthDivisions=200}function Na(a,b,c,d,e,f,g,h){H.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 ed(a,b,c,d,e,f){Na.call(this,a,b,c,c,d,e,f);this.type="ArcCurve"}function tg(){var a=0,b=
24422 0,c=0,d=0;return{initCatmullRom:function(e,f,g,h,l){e=l*(g-e);h=l*(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,l,m,k){e=((f-e)/l-(g-e)/(l+m)+(g-f)/m)*m;h=((g-f)/m-(h-f)/(m+k)+(h-g)/k)*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 qa(a,b,c,d){H.call(this);this.type="CatmullRomCurve3";this.points=a||[];this.closed=b||!1;this.curveType=c||"centripetal";this.tension=d||.5}function fi(a,b,c,d,e){b=.5*(d-
24423 b);e=.5*(e-c);var f=a*a;return(2*c-2*d+b+e)*a*f+(-3*c+3*d-2*b-e)*f+b*a+c}function ke(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}function le(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 Ya(a,b,c,d){H.call(this);this.type="CubicBezierCurve";this.v0=a||new v;this.v1=b||new v;this.v2=c||new v;this.v3=d||new v}function jb(a,b,c,d){H.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 Ia(a,b){H.call(this);
24424 this.type="LineCurve";this.v1=a||new v;this.v2=b||new v}function Za(a,b){H.call(this);this.type="LineCurve3";this.v1=a||new p;this.v2=b||new p}function $a(a,b,c){H.call(this);this.type="QuadraticBezierCurve";this.v0=a||new v;this.v1=b||new v;this.v2=c||new v}function kb(a,b,c){H.call(this);this.type="QuadraticBezierCurve3";this.v0=a||new p;this.v1=b||new p;this.v2=c||new p}function ab(a){H.call(this);this.type="SplineCurve";this.points=a||[]}function vb(){H.call(this);this.type="CurvePath";this.curves=
24425 [];this.autoClose=!1}function bb(a){vb.call(this);this.type="Path";this.currentPoint=new v;a&&this.setFromPoints(a)}function Nb(a){bb.call(this,a);this.uuid=O.generateUUID();this.type="Shape";this.holes=[]}function S(a,b){y.call(this);this.type="Light";this.color=new D(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0}function ff(a,b,c){S.call(this,a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.copy(y.DefaultUp);this.updateMatrix();this.groundColor=new D(b)}function lb(a){this.camera=
24426 a;this.bias=0;this.radius=1;this.mapSize=new v(512,512);this.mapPass=this.map=null;this.matrix=new N;this._frustum=new Gc;this._frameExtents=new v(1,1);this._viewportCount=1;this._viewports=[new R(0,0,1,1)]}function gf(){lb.call(this,new P(50,1,.5,500))}function hf(a,b,c,d,e,f){S.call(this,a,b);this.type="SpotLight";this.position.copy(y.DefaultUp);this.updateMatrix();this.target=new y;Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(a){this.intensity=
24427 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 gf}function ug(){lb.call(this,new P(90,1,.5,500));this._frameExtents=new v(4,2);this._viewportCount=6;this._viewports=[new R(2,1,1,1),new R(0,1,1,1),new R(3,1,1,1),new R(1,1,1,1),new R(3,0,1,1),new R(1,0,1,1)];this._cubeDirections=[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)];this._cubeUps=[new p(0,1,0),new p(0,1,0),
24428 new p(0,1,0),new p(0,1,0),new p(0,0,1),new p(0,0,-1)]}function jf(a,b,c,d){S.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 ug}function fd(a,b,c,d,e,f){fb.call(this);this.type="OrthographicCamera";this.zoom=1;this.view=null;this.left=void 0!==a?a:-1;this.right=void 0!==b?b:1;this.top=void 0!==c?c:1;this.bottom=
24429 void 0!==d?d:-1;this.near=void 0!==e?e:.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()}function kf(){lb.call(this,new fd(-5,5,5,-5,.5,500))}function lf(a,b){S.call(this,a,b);this.type="DirectionalLight";this.position.copy(y.DefaultUp);this.updateMatrix();this.target=new y;this.shadow=new kf}function mf(a,b){S.call(this,a,b);this.type="AmbientLight";this.castShadow=void 0}function nf(a,b,c,d){S.call(this,a,b);this.type="RectAreaLight";this.width=void 0!==c?c:10;this.height=void 0!==d?d:
24430 10}function of(){this.coefficients=[];for(var a=0;9>a;a++)this.coefficients.push(new p)}function Ua(a,b){S.call(this,void 0,b);this.type="LightProbe";this.sh=void 0!==a?a:new of}function pf(a){V.call(this,a);this.textures={}}function me(){F.call(this);this.type="InstancedBufferGeometry";this.instanceCount=Infinity}function qf(a,b,c,d){"number"===typeof c&&(d=c,c=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument."));G.call(this,a,b,c);this.meshPerAttribute=
24431 d||1}function rf(a){V.call(this,a)}function sf(a){V.call(this,a)}function vg(a){"undefined"===typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported.");"undefined"===typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported.");V.call(this,a);this.options=void 0}function wg(){this.type="ShapePath";this.color=new D;this.subPaths=[];this.currentPath=null}function xg(a){this.type="Font";this.data=a}function yg(a){V.call(this,a)}function tf(a){V.call(this,
24432 a)}function zg(a,b,c){Ua.call(this,void 0,c);a=(new D).set(a);c=(new D).set(b);b=new p(a.r,a.g,a.b);a=new p(c.r,c.g,c.b);c=Math.sqrt(Math.PI);var d=c*Math.sqrt(.75);this.sh.coefficients[0].copy(b).add(a).multiplyScalar(c);this.sh.coefficients[1].copy(b).sub(a).multiplyScalar(d)}function Ag(a,b){Ua.call(this,void 0,b);a=(new D).set(a);this.sh.coefficients[0].set(a.r,a.g,a.b).multiplyScalar(2*Math.sqrt(Math.PI))}function gi(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new P;
24433 this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new P;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1;this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}function Bg(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function Cg(){y.call(this);this.type="AudioListener";this.context=Dg.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);
24434 this.filter=null;this.timeDelta=0;this._clock=new Bg}function gd(a){y.call(this);this.type="Audio";this.listener=a;this.context=a.context;this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.buffer=null;this.detune=0;this.loop=!1;this.offset=this.loopEnd=this.loopStart=0;this.duration=void 0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this._progress=this._startedAt=0;this.filters=[]}function Eg(a){gd.call(this,a);this.panner=
24435 this.context.createPanner();this.panner.panningModel="HRTF";this.panner.connect(this.gain)}function Fg(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 Gg(a,b,c){this.binding=a;this.valueSize=c;switch(b){case "quaternion":a=this._slerp;b=this._slerpAdditive;var d=this._setAdditiveIdentityQuaternion;this.buffer=new Float64Array(6*c);this._workIndex=5;break;case "string":case "bool":b=
24436 a=this._select;d=this._setAdditiveIdentityOther;this.buffer=Array(5*c);break;default:a=this._lerp,b=this._lerpAdditive,d=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*c)}this._mixBufferRegion=a;this._mixBufferRegionAdditive=b;this._setIdentity=d;this._origIndex=3;this._addIndex=4;this.referenceCount=this.useCount=this.cumulativeWeightAdditive=this.cumulativeWeight=0}function hi(a,b,c){c=c||Aa.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)}function Aa(a,b,
24437 c){this.path=b;this.parsedPath=c||Aa.parseTrackName(b);this.node=Aa.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function ii(){this.uuid=O.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-
24438 d.nCachedObjects_}},get bindingsPerObject(){return d._bindings.length}}}function ji(a,b,c,d){this._mixer=a;this._clip=b;this._localRoot=c||null;this.blendMode=d||b.blendMode;a=b.tracks;b=a.length;c=Array(b);d={endingStart:2400,endingEnd:2400};for(var 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=
24439 2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function Hg(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function uf(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Ig(a,b,c){rb.call(this,
24440 a,b);this.meshPerAttribute=c||1}function Jg(a,b,c,d){this.ray=new Wb(a,b);this.near=c||0;this.far=d||Infinity;this.camera=null;this.layers=new De;this.params={Mesh:{},Line:{threshold:1},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 ki(a,b){return a.distance-b.distance}function Kg(a,b,c,d){a.layers.test(b.layers)&&a.raycast(b,
24441 c);if(!0===d){a=a.children;d=0;for(var e=a.length;d<e;d++)Kg(a[d],b,c,!0)}}function li(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 mi(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 Lg(a,b){this.min=void 0!==a?a:new v(Infinity,Infinity);this.max=void 0!==b?b:new v(-Infinity,-Infinity)}function Mg(a,b){this.start=void 0!==a?a:new p;this.end=void 0!==b?b:new p}function ne(a){y.call(this);
24442 this.material=a;this.render=function(){};this.hasUvs=this.hasColors=this.hasNormals=this.hasPositions=!1;this.uvArray=this.colorArray=this.normalArray=this.positionArray=null;this.count=0}function hd(a,b){y.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=b;a=new F;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,
24443 Math.cos(f),Math.sin(f),1)}a.setAttribute("position",new B(b,3));b=new da({fog:!1,toneMapped:!1});this.cone=new ma(a,b);this.add(this.cone);this.update()}function ni(a){var b=[];a&&a.isBone&&b.push(a);for(var c=0;c<a.children.length;c++)b.push.apply(b,ni(a.children[c]));return b}function pc(a){for(var b=ni(a),c=new F,d=[],e=[],f=new D(0,0,1),g=new D(0,1,0),h=0;h<b.length;h++){var l=b[h];l.parent&&l.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.setAttribute("position",
24444 new B(d,3));c.setAttribute("color",new B(e,3));d=new da({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});ma.call(this,c,d);this.type="SkeletonHelper";this.root=a;this.bones=b;this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1}function id(a,b,c){this.light=a;this.light.updateMatrixWorld();this.color=c;a=new ec(b,4,2);b=new Pa({wireframe:!0,fog:!1,toneMapped:!1});ea.call(this,a,b);this.type="PointLightHelper";this.matrix=this.light.matrixWorld;this.matrixAutoUpdate=!1;this.update()}
24445 function jd(a,b,c){y.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=c;a=new bc(b);a.rotateY(.5*Math.PI);this.material=new Pa({wireframe:!0,fog:!1,toneMapped:!1});void 0===this.color&&(this.material.vertexColors=!0);b=a.getAttribute("position");b=new Float32Array(3*b.count);a.setAttribute("color",new G(b,3));this.add(new ea(a,this.material));this.update()}function vf(a,b,c,d){a=a||10;b=b||10;c=new D(void 0!==c?c:4473924);d=new D(void 0!==
24446 d?d:8947848);var e=b/2,f=a/b,g=a/2;a=[];for(var h=[],l=0,m=0,k=-g;l<=b;l++,k+=f){a.push(-g,0,k,g,0,k);a.push(k,0,-g,k,0,g);var n=l===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 F;b.setAttribute("position",new B(a,3));b.setAttribute("color",new B(h,3));c=new da({vertexColors:!0,toneMapped:!1});ma.call(this,b,c);this.type="GridHelper"}function wf(a,b,c,d,e,f){a=a||10;b=b||16;c=c||8;d=d||64;e=new D(void 0!==e?e:4473924);f=new D(void 0!==f?f:8947848);var g=
24447 [],h=[],l;for(l=0;l<=b;l++){var m=l/b*2*Math.PI;var k=Math.sin(m)*a;m=Math.cos(m)*a;g.push(0,0,0);g.push(k,0,m);var n=l&1?e:f;h.push(n.r,n.g,n.b);h.push(n.r,n.g,n.b)}for(l=0;l<=c;l++){n=l&1?e:f;var t=a-a/c*l;for(b=0;b<d;b++)m=b/d*2*Math.PI,k=Math.sin(m)*t,m=Math.cos(m)*t,g.push(k,0,m),h.push(n.r,n.g,n.b),m=(b+1)/d*2*Math.PI,k=Math.sin(m)*t,m=Math.cos(m)*t,g.push(k,0,m),h.push(n.r,n.g,n.b)}a=new F;a.setAttribute("position",new B(g,3));a.setAttribute("color",new B(h,3));g=new da({vertexColors:!0,toneMapped:!1});
24448 ma.call(this,a,g);this.type="PolarGridHelper"}function kd(a,b,c){y.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 F;a.setAttribute("position",new B([-b,b,0,b,b,0,b,-b,0,-b,-b,0,-b,b,0],3));b=new da({fog:!1,toneMapped:!1});this.lightPlane=new La(a,b);this.add(this.lightPlane);a=new F;a.setAttribute("position",new B([0,0,0,0,0,1],3));this.targetLine=new La(a,b);this.add(this.targetLine);this.update()}function oe(a){function b(a,
24449 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 F,e=new da({color:16777215,vertexColors:!0,toneMapped:!1}),f=[],g=[],h={},l=new D(16755200),m=new D(16711680),k=new D(43775),n=new D(16777215),t=new D(3355443);b("n1","n2",l);b("n2","n4",l);b("n4","n3",l);b("n3","n1",l);b("f1","f2",l);b("f2","f4",l);b("f4","f3",l);b("f3","f1",l);b("n1","f1",l);b("n2","f2",l);b("n3","f3",l);b("n4","f4",l);b("p","n1",m);b("p","n2",m);b("p",
24450 "n3",m);b("p","n4",m);b("u1","u2",k);b("u2","u3",k);b("u3","u1",k);b("c","t",n);b("p","c",t);b("cn1","cn2",t);b("cn3","cn4",t);b("cf1","cf2",t);b("cf3","cf4",t);d.setAttribute("position",new B(f,3));d.setAttribute("color",new B(g,3));ma.call(this,d,e);this.type="CameraHelper";this.camera=a;this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=h;this.update()}function fa(a,b,c,d,e,f,g){xf.set(e,f,g).unproject(d);a=
24451 b[a];if(void 0!==a)for(c=c.getAttribute("position"),b=0,d=a.length;b<d;b++)c.setXYZ(a[b],xf.x,xf.y,xf.z)}function wb(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 F;d.setIndex(new G(a,1));d.setAttribute("position",new G(c,3));ma.call(this,d,new da({color:b,toneMapped:!1}));this.type="BoxHelper";this.matrixAutoUpdate=!1;this.update()}function pe(a,b){this.type="Box3Helper";this.box=a;b=b||16776960;a=
24452 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 F;c.setIndex(new G(a,1));c.setAttribute("position",new B([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));ma.call(this,c,new da({color:b,toneMapped:!1}));this.type="Box3Helper";this.geometry.computeBoundingSphere()}function qe(a,b,c){this.plane=a;this.size=void 0===b?1:b;a=void 0!==c?c:16776960;b=new F;b.setAttribute("position",new B([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));
24453 b.computeBoundingSphere();La.call(this,b,new da({color:a,toneMapped:!1}));this.type="PlaneHelper";b=new F;b.setAttribute("position",new B([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3));b.computeBoundingSphere();this.add(new ea(b,new Pa({color:a,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}function xb(a,b,c,d,e,f){y.call(this);this.type="ArrowHelper";void 0===a&&(a=new p(0,0,1));void 0===b&&(b=new p(0,0,0));void 0===c&&(c=1);void 0===d&&(d=16776960);void 0===e&&(e=.2*c);void 0===f&&(f=
24454 .2*e);void 0===yf&&(yf=new F,yf.setAttribute("position",new B([0,0,0,0,1,0],3)),Ng=new tb(0,.5,1,5,1),Ng.translate(0,-.5,0));this.position.copy(b);this.line=new La(yf,new da({color:d,toneMapped:!1}));this.line.matrixAutoUpdate=!1;this.add(this.line);this.cone=new ea(Ng,new Pa({color:d,toneMapped:!1}));this.cone.matrixAutoUpdate=!1;this.add(this.cone);this.setDirection(a);this.setLength(c,e,f)}function re(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 F;a.setAttribute("position",new B(b,
24455 3));a.setAttribute("color",new B([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));b=new da({vertexColors:!0,toneMapped:!1});ma.call(this,a,b);this.type="AxesHelper"}function Og(a){this._renderer=a;this._pingPongRenderTarget=null;a=new Float32Array(20);var b=new p(0,1,0);a=new ub({defines:{n:20},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:a},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:b},inputEncoding:{value:mb[3E3]},outputEncoding:{value:mb[3E3]}},vertexShader:Pg(),
24456 fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform int samples;\nuniform float weights[n];\nuniform bool latitudinal;\nuniform float dTheta;\nuniform float mipInt;\nuniform vec3 poleAxis;\n\n"+Qg()+"\n\n#define ENVMAP_TYPE_CUBE_UV\n#include <cube_uv_reflection_fragment>\n\nvec3 getSample(float theta, vec3 axis) {\n\tfloat cosTheta = cos(theta);\n\t// Rodrigues' axis-angle rotation\n\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t+ cross(axis, vOutputDirection) * sin(theta)\n\t\t+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n\treturn bilinearCubeUV(envMap, sampleDirection, mipInt);\n}\n\nvoid main() {\n\tvec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\tif (all(equal(axis, vec3(0.0))))\n\t\taxis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);\n\taxis = normalize(axis);\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb += weights[0] * getSample(0.0, axis);\n\tfor (int i = 1; i < n; i++) {\n\t\tif (i >= samples)\n\t\t\tbreak;\n\t\tfloat theta = dTheta * float(i);\n\t\tgl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);\n\t\tgl_FragColor.rgb += weights[i] * getSample(theta, axis);\n\t}\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t",
24457 blending:0,depthTest:!1,depthWrite:!1});a.type="SphericalGaussianBlur";this._blurMaterial=a;this._cubemapShader=this._equirectShader=null;this._compileMaterial(this._blurMaterial)}function oi(a){a=new Ba(3*nb,3*nb,a);a.texture.mapping=306;a.texture.name="PMREM.cubeUv";a.scissorTest=!0;return a}function Rg(a,b,c,d,e){a.viewport.set(b,c,d,e);a.scissor.set(b,c,d,e)}function pi(){var a=new v(1,1);a=new ub({uniforms:{envMap:{value:null},texelSize:{value:a},inputEncoding:{value:mb[3E3]},outputEncoding:{value:mb[3E3]}},
24458 vertexShader:Pg(),fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform vec2 texelSize;\n\n"+Qg()+"\n\n#include <common>\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tvec3 outputDirection = normalize(vOutputDirection);\n\tvec2 uv = equirectUv( outputDirection );\n\tvec2 f = fract(uv / texelSize - 0.5);\n\tuv -= f * texelSize;\n\tvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x += texelSize.x;\n\tvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.y += texelSize.y;\n\tvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x -= texelSize.x;\n\tvec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tvec3 tm = mix(tl, tr, f.x);\n\tvec3 bm = mix(bl, br, f.x);\n\tgl_FragColor.rgb = mix(tm, bm, f.y);\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t",
24459 blending:0,depthTest:!1,depthWrite:!1});a.type="EquirectangularToCubeUV";return a}function qi(){var a=new ub({uniforms:{envMap:{value:null},inputEncoding:{value:mb[3E3]},outputEncoding:{value:mb[3E3]}},vertexShader:Pg(),fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform samplerCube envMap;\n\n"+Qg()+"\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t",
24460 blending:0,depthTest:!1,depthWrite:!1});a.type="CubemapToCubeUV";return a}function Pg(){return"\nprecision mediump float;\nprecision mediump int;\nattribute vec3 position;\nattribute vec2 uv;\nattribute float faceIndex;\nvarying vec3 vOutputDirection;\n\n// RH coordinate system; PMREM face-indexing convention\nvec3 getDirection(vec2 uv, float face) {\n\tuv = 2.0 * uv - 1.0;\n\tvec3 direction = vec3(uv, 1.0);\n\tif (face == 0.0) {\n\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\t} else if (face == 1.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\t} else if (face == 2.0) {\n\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\t} else if (face == 3.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\t} else if (face == 4.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\t} else if (face == 5.0) {\n\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\t}\n\treturn direction;\n}\n\nvoid main() {\n\tvOutputDirection = getDirection(uv, faceIndex);\n\tgl_Position = vec4( position, 1.0 );\n}\n\t"}
24461 function Qg(){return"\nuniform int inputEncoding;\nuniform int outputEncoding;\n\n#include <encodings_pars_fragment>\n\nvec4 inputTexelToLinear(vec4 value){\n\tif(inputEncoding == 0){\n\t\treturn value;\n\t}else if(inputEncoding == 1){\n\t\treturn sRGBToLinear(value);\n\t}else if(inputEncoding == 2){\n\t\treturn RGBEToLinear(value);\n\t}else if(inputEncoding == 3){\n\t\treturn RGBMToLinear(value, 7.0);\n\t}else if(inputEncoding == 4){\n\t\treturn RGBMToLinear(value, 16.0);\n\t}else if(inputEncoding == 5){\n\t\treturn RGBDToLinear(value, 256.0);\n\t}else{\n\t\treturn GammaToLinear(value, 2.2);\n\t}\n}\n\nvec4 linearToOutputTexel(vec4 value){\n\tif(outputEncoding == 0){\n\t\treturn value;\n\t}else if(outputEncoding == 1){\n\t\treturn LinearTosRGB(value);\n\t}else if(outputEncoding == 2){\n\t\treturn LinearToRGBE(value);\n\t}else if(outputEncoding == 3){\n\t\treturn LinearToRGBM(value, 7.0);\n\t}else if(outputEncoding == 4){\n\t\treturn LinearToRGBM(value, 16.0);\n\t}else if(outputEncoding == 5){\n\t\treturn LinearToRGBD(value, 256.0);\n\t}else{\n\t\treturn LinearToGamma(value, 2.2);\n\t}\n}\n\nvec4 envMapTexelToLinear(vec4 color) {\n\treturn inputTexelToLinear(color);\n}\n\t"}
24462 function ri(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");qa.call(this,a);this.type="catmullrom";this.closed=!0}function si(a){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");qa.call(this,a);this.type="catmullrom"}function Sg(a){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.");qa.call(this,a);this.type="catmullrom"}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,
24463 -52));void 0===Number.isInteger&&(Number.isInteger=function(a){return"number"===typeof a&&isFinite(a)&&Math.floor(a)===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&&(Object.assign=function(a){if(void 0===a||null===a)throw new TypeError("Cannot convert undefined or null to object");for(var b=
24464 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,e)&&(b[e]=d[e])}return b});Object.assign(ua.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,
24465 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!==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)}}}});for(var za=[],se=0;256>se;se++)za[se]=(16>se?"0":"")+se.toString(16);var O={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var a=4294967295*Math.random()|0,b=4294967295*Math.random()|0,c=4294967295*Math.random()|
24466 0,d=4294967295*Math.random()|0;return(za[a&255]+za[a>>8&255]+za[a>>16&255]+za[a>>24&255]+"-"+za[b&255]+za[b>>8&255]+"-"+za[b>>16&15|64]+za[b>>24&255]+"-"+za[c&63|128]+za[c>>8&255]+"-"+za[c>>16&255]+za[c>>24&255]+za[d&255]+za[d>>8&255]+za[d>>16&255]+za[d>>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,
24467 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;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*O.DEG2RAD},radToDeg:function(a){return a*O.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},ceilPowerOfTwo:function(a){return Math.pow(2,
24468 Math.ceil(Math.log(a)/Math.LN2))},floorPowerOfTwo:function(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))},setQuaternionFromProperEuler:function(a,b,c,d,e){var f=Math.cos,g=Math.sin,h=f(c/2);c=g(c/2);var l=f((b+d)/2),m=g((b+d)/2),k=f((b-d)/2),n=g((b-d)/2);f=f((d-b)/2);b=g((d-b)/2);switch(e){case "XYX":a.set(h*m,c*k,c*n,h*l);break;case "YZY":a.set(c*n,h*m,c*k,h*l);break;case "ZXZ":a.set(c*k,c*n,h*m,h*l);break;case "XZX":a.set(h*m,c*b,c*f,h*l);break;case "YXY":a.set(c*f,h*m,c*b,h*l);break;case "ZYZ":a.set(c*
24469 b,c*f,h*m,h*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+e)}}};Object.defineProperties(v.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(v.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=
24470 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: "+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."),
24471 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},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},
24472 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*=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},
24473 max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);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));return this},clampScalar:function(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));return this},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);
24474 return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=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*
24475 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)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){return Math.atan2(-this.y,-this.x)+Math.PI},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-
24476 a.y)},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;return this},lerpVectors:function(a,b,c){this.x=a.x+(b.x-a.x)*c;this.y=a.y+(b.y-a.y)*c;return this},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!==
24477 c&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);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},random:function(){this.x=Math.random();this.y=Math.random();return this}});Object.assign(ya.prototype,{isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,l){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]=
24478 l;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;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},extractBasis:function(a,b,c){a.setFromMatrix3Column(this,0);b.setFromMatrix3Column(this,1);c.setFromMatrix3Column(this,2);return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],
24479 a[5],a[9],a[2],a[6],a[10]);return this},multiply:function(a){return 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[3],f=c[6],g=c[1],h=c[4],l=c[7],m=c[2],k=c[5];c=c[8];var n=d[0],t=d[3],p=d[6],q=d[1],u=d[4],v=d[7],x=d[2],w=d[5];d=d[8];b[0]=a*n+e*q+f*x;b[3]=a*t+e*u+f*w;b[6]=a*p+e*v+f*d;b[1]=g*n+h*q+l*x;b[4]=g*t+h*u+l*w;b[7]=g*p+h*v+l*d;b[2]=m*n+k*q+c*x;b[5]=m*t+k*
24480 u+c*w;b[8]=m*p+k*v+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]*=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],l=a[7];a=a[8];return b*f*a-b*g*l-c*e*a+c*g*h+d*e*l-d*f*h},getInverse:function(a,b){void 0!==b&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");var c=a.elements;a=this.elements;b=c[0];var d=c[1],
24481 e=c[2],f=c[3],g=c[4],h=c[5],l=c[6],m=c[7];c=c[8];var k=c*g-h*m,n=h*l-c*f,p=m*f-g*l,r=b*k+d*n+e*p;if(0===r)return this.set(0,0,0,0,0,0,0,0,0);r=1/r;a[0]=k*r;a[1]=(e*m-c*d)*r;a[2]=(h*d-e*g)*r;a[3]=n*r;a[4]=(c*b-e*l)*r;a[5]=(e*f-h*b)*r;a[6]=p*r;a[7]=(d*l-m*b)*r;a[8]=(g*b-d*f)*r;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()},
24482 transposeIntoArray:function(a){var b=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],
24483 l=c[7];c[0]=b*d+a*g;c[3]=b*e+a*h;c[6]=b*f+a*l;c[1]=-a*d+b*g;c[4]=-a*e+b*h;c[7]=-a*f+b*l;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=
24484 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];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}});var ld,Ob={getDataURL:function(a){if("undefined"==typeof HTMLCanvasElement)return a.src;if(!(a instanceof HTMLCanvasElement)){void 0===ld&&(ld=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"));ld.width=a.width;ld.height=a.height;var b=ld.getContext("2d");a instanceof ImageData?b.putImageData(a,0,0):b.drawImage(a,0,0,a.width,a.height);a=ld}return 2048<
24485 a.width||2048<a.height?a.toDataURL("image/jpeg",.6):a.toDataURL("image/png")}},ej=0;W.DEFAULT_IMAGE=void 0;W.DEFAULT_MAPPING=300;W.prototype=Object.assign(Object.create(ua.prototype),{constructor:W,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);
24486 this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=a.wrapT;this.magFilter=a.magFilter;this.minFilter=a.minFilter;this.anisotropy=a.anisotropy;this.format=a.format;this.internalFormat=a.internalFormat;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=
24487 a.unpackAlignment;this.encoding=a.encoding;return this},toJSON:function(a){var b=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,type:this.type,encoding:this.encoding,
24488 minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var d=this.image;void 0===d.uuid&&(d.uuid=O.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(Ob.getDataURL(d[f]))}else e=Ob.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"})},
24489 transformUv:function(a){if(300!==this.mapping)return a;a.applyMatrix3(this.matrix);if(0>a.x||1<a.x)switch(this.wrapS){case 1E3:a.x-=Math.floor(a.x);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);return a}});Object.defineProperty(W.prototype,
24490 "needsUpdate",{set:function(a){!0===a&&this.version++}});Object.defineProperties(R.prototype,{width:{get:function(){return this.z},set:function(a){this.z=a}},height:{get:function(){return this.w},set:function(a){this.w=a}}});Object.assign(R.prototype,{isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=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=
24491 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;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=
24492 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+=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*
24493 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-=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*=
24494 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/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=
24495 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 l=a[6];var m=a[10];if(.01>Math.abs(c-e)&&.01>Math.abs(d-h)&&.01>Math.abs(g-l)){if(.1>Math.abs(c+e)&&.1>Math.abs(d+h)&&.1>Math.abs(g+l)&&.1>Math.abs(b+f+m-3))return this.set(1,0,0,0),this;a=Math.PI;b=(b+1)/2;f=(f+1)/2;m=(m+1)/2;c=(c+e)/4;d=(d+h)/4;g=(g+l)/4;b>f&&b>m?.01>b?(l=0,c=h=.707106781):(l=Math.sqrt(b),h=c/l,c=d/l):f>m?.01>f?(l=.707106781,h=0,c=.707106781):(h=Math.sqrt(f),l=c/h,c=g/h):.01>m?(h=l=.707106781,c=0):(c=
24496 Math.sqrt(m),l=d/c,h=g/c);this.set(l,h,c,a);return this}a=Math.sqrt((l-g)*(l-g)+(d-h)*(d-h)+(e-c)*(e-c));.001>Math.abs(a)&&(a=1);this.x=(l-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,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,
24497 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(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));this.z=Math.max(a,Math.min(b,this.z));this.w=Math.max(a,Math.min(b,this.w));return this},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=
24498 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);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);
24499 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*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)+
24500 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,b,c){this.x=a.x+(b.x-a.x)*c;this.y=a.y+(b.y-a.y)*c;this.z=a.z+(b.z-a.z)*c;this.w=a.w+(b.w-a.w)*c;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&
24501 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().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);this.w=a.getW(b);return this},random:function(){this.x=Math.random();this.y=
24502 Math.random();this.z=Math.random();this.w=Math.random();return this}});Ba.prototype=Object.assign(Object.create(ua.prototype),{constructor:Ba,isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.texture.image.width=a,this.texture.image.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);
24503 this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Xf.prototype=Object.assign(Object.create(Ba.prototype),{constructor:Xf,isWebGLMultisampleRenderTarget:!0,copy:function(a){Ba.prototype.copy.call(this,a);this.samples=a.samples;return this}});Object.assign(va,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=
24504 c[d+0],l=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var k=e[f+1],n=e[f+2];e=e[f+3];if(c!==e||h!==d||l!==k||m!==n){f=1-g;var p=h*d+l*k+m*n+c*e,r=0<=p?1:-1,q=1-p*p;q>Number.EPSILON&&(q=Math.sqrt(q),p=Math.atan2(q,p*r),f=Math.sin(f*p)/q,g=Math.sin(g*p)/q);r*=g;h=h*f+d*r;l=l*f+k*r;m=m*f+n*r;c=c*f+e*r;f===1-g&&(g=1/Math.sqrt(h*h+l*l+m*m+c*c),h*=g,l*=g,m*=g,c*=g)}a[b]=h;a[b+1]=l;a[b+2]=m;a[b+3]=c},multiplyQuaternionsFlat:function(a,b,c,d,e,f){var g=c[d],h=c[d+1],l=c[d+2];c=c[d+3];d=e[f];var m=e[f+1],k=e[f+2];e=
24505 e[f+3];a[b]=g*e+c*d+h*k-l*m;a[b+1]=h*e+c*m+l*d-g*k;a[b+2]=l*e+c*k+g*m-h*d;a[b+3]=c*e-g*d-h*m-l*k;return a}});Object.defineProperties(va.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=a;this._onChangeCallback()}}});Object.assign(va.prototype,
24506 {isQuaternion:!0,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=a._x,d=a._y,e=a._z;a=a.order;var f=Math.cos,
24507 g=Math.sin,h=f(c/2),l=f(d/2);f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);switch(a){case "XYZ":this._x=c*l*f+h*d*e;this._y=h*d*f-c*l*e;this._z=h*l*e+c*d*f;this._w=h*l*f-c*d*e;break;case "YXZ":this._x=c*l*f+h*d*e;this._y=h*d*f-c*l*e;this._z=h*l*e-c*d*f;this._w=h*l*f+c*d*e;break;case "ZXY":this._x=c*l*f-h*d*e;this._y=h*d*f+c*l*e;this._z=h*l*e+c*d*f;this._w=h*l*f-c*d*e;break;case "ZYX":this._x=c*l*f-h*d*e;this._y=h*d*f+c*l*e;this._z=h*l*e-c*d*f;this._w=h*l*f+c*d*e;break;case "YZX":this._x=c*l*f+h*d*e;this._y=
24508 h*d*f+c*l*e;this._z=h*l*e-c*d*f;this._w=h*l*f-c*d*e;break;case "XZY":this._x=c*l*f-h*d*e;this._y=h*d*f-c*l*e;this._z=h*l*e+c*d*f;this._w=h*l*f+c*d*e;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}!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];
24509 a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],l=b[6];b=b[10];var m=c+f+b;0<m?(c=.5/Math.sqrt(m+1),this._w=.25/c,this._x=(l-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=(l-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+l)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+l)/c,this._z=.25*c);this._onChangeCallback();return this},setFromUnitVectors:function(a,
24510 b){var c=a.dot(b)+1;1E-6>c?(c=0,Math.abs(a.x)>Math.abs(a.z)?(this._x=-a.y,this._y=a.x,this._z=0):(this._x=0,this._y=-a.z,this._z=a.y)):(this._x=a.y*b.z-a.z*b.y,this._y=a.z*b.x-a.x*b.z,this._z=a.x*b.y-a.y*b.x);this._w=c;return this.normalize()},angleTo:function(a){return 2*Math.acos(Math.abs(O.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*=
24511 -1;this._y*=-1;this._z*=-1;this._onChangeCallback();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*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},
24512 multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),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();
24513 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;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(),this._onChangeCallback(),this;a=Math.sqrt(a);var h=Math.atan2(a,
24514 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===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+
24515 3]=this._w;return a},fromBufferAttribute:function(a,b){this._x=a.getX(b);this._y=a.getY(b);this._z=a.getZ(b);this._w=a.getW(b);return this},_onChange:function(a){this._onChangeCallback=a;return this},_onChangeCallback:function(){}});var Tg=new p,ti=new va;Object.assign(p.prototype,{isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},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=
24516 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,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."),
24517 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+=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;
24518 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."),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*
24519 b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(a){a&&a.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(ti.setFromEuler(a))},applyAxisAngle:function(a,b){return this.applyQuaternion(ti.setFromAxisAngle(a,b))},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},applyNormalMatrix:function(a){return this.applyMatrix3(a).normalize()},
24520 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,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,l=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+l*-g-m*-f;this.y=l*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-l*-e;return this},project:function(a){return this.applyMatrix4(a.matrixWorldInverse).applyMatrix4(a.projectionMatrix)},
24521 unproject:function(a){return this.applyMatrix4(a.projectionMatrixInverse).applyMatrix4(a.matrixWorld)},transformDirection:function(a){var b=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,
24522 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,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(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));this.z=Math.max(a,Math.min(b,this.z));return this},clampLength:function(a,b){var c=this.length();return this.divideScalar(c||
24523 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=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=
24524 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*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)},
24525 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,b,c){this.x=a.x+(b.x-a.x)*c;this.y=a.y+(b.y-a.y)*c;this.z=a.z+(b.z-a.z)*c;return this},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*
24526 e-c*b;this.z=c*f-d*e;return this},projectOnVector:function(a){var b=a.lengthSq();if(0===b)return this.set(0,0,0);b=a.dot(this)/b;return this.copy(a).multiplyScalar(b)},projectOnPlane:function(a){Tg.copy(this).projectOnVector(a);return this.sub(Tg)},reflect:function(a){return this.sub(Tg.copy(a).multiplyScalar(2*this.dot(a)))},angleTo:function(a){var b=Math.sqrt(this.lengthSq()*a.lengthSq());if(0===b)return Math.PI/2;a=this.dot(a)/b;return Math.acos(O.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},
24527 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-a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-a.z)},setFromSpherical:function(a){return this.setFromSphericalCoords(a.radius,a.phi,a.theta)},setFromSphericalCoords:function(a,b,c){var d=Math.sin(b)*a;this.x=d*Math.sin(c);this.y=Math.cos(b)*a;this.z=d*Math.cos(c);return this},setFromCylindrical:function(a){return this.setFromCylindricalCoords(a.radius,a.theta,
24528 a.y)},setFromCylindricalCoords:function(a,b,c){this.x=a*Math.sin(b);this.y=c;this.z=a*Math.cos(b);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(),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)},setFromMatrix3Column:function(a,
24529 b){return this.fromArray(a.elements,3*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!==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},
24530 random:function(){this.x=Math.random();this.y=Math.random();this.z=Math.random();return this}});var md=new p,ba=new N,Hk=new p(0,0,0),Ik=new p(1,1,1),Pb=new p,zf=new p,Ea=new p;Object.assign(N.prototype,{isMatrix4:!0,set:function(a,b,c,d,e,f,g,h,l,m,k,n,p,r,q,u){var z=this.elements;z[0]=a;z[4]=b;z[8]=c;z[12]=d;z[1]=e;z[5]=f;z[9]=g;z[13]=h;z[2]=l;z[6]=m;z[10]=k;z[14]=n;z[3]=p;z[7]=r;z[11]=q;z[15]=u;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 N).fromArray(this.elements)},
24531 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,
24532 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(a){var b=this.elements,c=a.elements,d=1/md.setFromMatrixColumn(a,0).length(),e=1/md.setFromMatrixColumn(a,1).length();a=1/md.setFromMatrixColumn(a,2).length();b[0]=c[0]*d;b[1]=c[1]*d;b[2]=c[2]*d;b[3]=0;b[4]=c[4]*e;b[5]=c[5]*e;b[6]=c[6]*e;b[7]=0;b[8]=c[8]*a;b[9]=c[9]*a;b[10]=c[10]*a;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[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.");
24533 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 l=f*e,m=c*h,k=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=l+m*d;b[5]=a-k*d;b[9]=-c*g;b[2]=k-a*d;b[6]=m+l*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,l=g*e,m=d*h,k=d*e,b[0]=a+k*c,b[4]=m*c-l,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=l*c-m,b[6]=k+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,l=g*e,m=d*h,k=d*e,b[0]=a-k*c,b[4]=-f*e,b[8]=m+l*c,b[1]=l+m*c,b[5]=f*h,b[9]=
24534 k-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,l=f*e,m=c*h,k=c*e,b[0]=g*h,b[4]=m*d-l,b[8]=a*d+k,b[1]=g*e,b[5]=k*d+a,b[9]=l*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,l=f*d,m=c*g,k=c*d,b[0]=g*h,b[4]=k-a*e,b[8]=m*e+l,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=l*e+m,b[10]=a-k*e):"XZY"===a.order&&(a=f*g,l=f*d,m=c*g,k=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+k,b[5]=f*h,b[9]=l*e-m,b[2]=m*e-l,b[6]=c*h,b[10]=k*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(a){return this.compose(Hk,
24535 a,Ik)},lookAt:function(a,b,c){var d=this.elements;Ea.subVectors(a,b);0===Ea.lengthSq()&&(Ea.z=1);Ea.normalize();Pb.crossVectors(c,Ea);0===Pb.lengthSq()&&(1===Math.abs(c.z)?Ea.x+=1E-4:Ea.z+=1E-4,Ea.normalize(),Pb.crossVectors(c,Ea));Pb.normalize();zf.crossVectors(Ea,Pb);d[0]=Pb.x;d[4]=zf.x;d[8]=Ea.x;d[1]=Pb.y;d[5]=zf.y;d[9]=Ea.y;d[2]=Pb.z;d[6]=zf.z;d[10]=Ea.z;return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),
24536 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],l=c[5],m=c[9],k=c[13],n=c[2],p=c[6],r=c[10],q=c[14],u=c[3],v=c[7],x=c[11];c=c[15];var w=d[0],y=d[4],B=d[8],Z=d[12],C=d[1],A=d[5],D=d[9],F=d[13],G=d[2],H=d[6],K=d[10],L=d[14],M=d[3],N=d[7],O=d[11];d=d[15];b[0]=a*w+e*C+f*G+g*M;b[4]=a*y+e*A+f*H+g*N;b[8]=a*B+e*D+f*K+
24537 g*O;b[12]=a*Z+e*F+f*L+g*d;b[1]=h*w+l*C+m*G+k*M;b[5]=h*y+l*A+m*H+k*N;b[9]=h*B+l*D+m*K+k*O;b[13]=h*Z+l*F+m*L+k*d;b[2]=n*w+p*C+r*G+q*M;b[6]=n*y+p*A+r*H+q*N;b[10]=n*B+p*D+r*K+q*O;b[14]=n*Z+p*F+r*L+q*d;b[3]=u*w+v*C+x*G+c*M;b[7]=u*y+v*A+x*H+c*N;b[11]=u*B+v*D+x*K+c*O;b[15]=u*Z+v*F+x*L+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]*=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},determinant:function(){var a=
24538 this.elements,b=a[0],c=a[4],d=a[8],e=a[12],f=a[1],g=a[5],h=a[9],l=a[13],m=a[2],k=a[6],n=a[10],p=a[14];return a[3]*(+e*h*k-d*l*k-e*g*n+c*l*n+d*g*p-c*h*p)+a[7]*(+b*h*p-b*l*n+e*f*n-d*f*p+d*l*m-e*h*m)+a[11]*(+b*l*k-b*g*p-e*f*k+c*f*p+e*g*m-c*l*m)+a[15]*(-d*g*m-b*h*k+b*g*n+d*f*k-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,
24539 b,c){var d=this.elements;a.isVector3?(d[12]=a.x,d[13]=a.y,d[14]=a.z):(d[12]=a,d[13]=b,d[14]=c);return this},getInverse:function(a,b){void 0!==b&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");b=this.elements;var c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],l=c[6],m=c[7],k=c[8],n=c[9],p=c[10],r=c[11],q=c[12],u=c[13],v=c[14];c=c[15];var x=n*v*m-u*p*m+u*l*r-h*v*r-n*l*c+h*p*c,w=q*p*m-k*v*m-q*l*r+g*v*r+k*l*c-g*p*c,y=k*u*m-q*n*m+q*h*r-g*u*
24540 r-k*h*c+g*n*c,B=q*n*l-k*u*l-q*h*p+g*u*p+k*h*v-g*n*v,A=a*x+d*w+e*y+f*B;if(0===A)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);A=1/A;b[0]=x*A;b[1]=(u*p*f-n*v*f-u*e*r+d*v*r+n*e*c-d*p*c)*A;b[2]=(h*v*f-u*l*f+u*e*m-d*v*m-h*e*c+d*l*c)*A;b[3]=(n*l*f-h*p*f-n*e*m+d*p*m+h*e*r-d*l*r)*A;b[4]=w*A;b[5]=(k*v*f-q*p*f+q*e*r-a*v*r-k*e*c+a*p*c)*A;b[6]=(q*l*f-g*v*f-q*e*m+a*v*m+g*e*c-a*l*c)*A;b[7]=(g*p*f-k*l*f+k*e*m-a*p*m-g*e*r+a*l*r)*A;b[8]=y*A;b[9]=(q*n*f-k*u*f-q*d*r+a*u*r+k*d*c-a*n*c)*A;b[10]=(g*u*f-q*h*f+q*d*m-
24541 a*u*m-g*d*c+a*h*c)*A;b[11]=(k*h*f-g*n*f-k*d*m+a*n*m+g*d*r-a*h*r)*A;b[12]=B*A;b[13]=(k*u*e-q*n*e+q*d*p-a*u*p-k*d*v+a*n*v)*A;b[14]=(q*h*e-g*u*e-q*d*l+a*u*l+g*d*v-a*h*v)*A;b[15]=(g*n*e-k*h*e+k*d*l-a*n*l-g*d*p+a*h*p)*A;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]*
24542 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=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,
24543 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,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,l=e+e,m=f+f,k=g+g;b=e*l;var n=e*m;e*=k;var p=f*m;f*=k;g*=k;l*=h;m*=h;h*=k;k=c.x;var r=
24544 c.y;c=c.z;d[0]=(1-(p+g))*k;d[1]=(n+h)*k;d[2]=(e-m)*k;d[3]=0;d[4]=(n-h)*r;d[5]=(1-(b+g))*r;d[6]=(f+l)*r;d[7]=0;d[8]=(e+m)*c;d[9]=(f-l)*c;d[10]=(1-(b+p))*c;d[11]=0;d[12]=a.x;d[13]=a.y;d[14]=a.z;d[15]=1;return this},decompose:function(a,b,c){var d=this.elements,e=md.set(d[0],d[1],d[2]).length(),f=md.set(d[4],d[5],d[6]).length(),g=md.set(d[8],d[9],d[10]).length();0>this.determinant()&&(e=-e);a.x=d[12];a.y=d[13];a.z=d[14];ba.copy(this);a=1/e;d=1/f;var h=1/g;ba.elements[0]*=a;ba.elements[1]*=a;ba.elements[2]*=
24545 a;ba.elements[4]*=d;ba.elements[5]*=d;ba.elements[6]*=d;ba.elements[8]*=h;ba.elements[9]*=h;ba.elements[10]*=h;b.setFromRotationMatrix(ba);c.x=e;c.y=f;c.z=g;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);
24546 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),l=1/(c-d),m=1/(f-e);g[0]=2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*l;g[9]=0;g[13]=-((c+d)*l);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},
24547 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];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}});var ui=new N,vi=new va;Ub.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");Ub.DefaultOrder="XYZ";Object.defineProperties(Ub.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this._onChangeCallback()}},
24548 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(Ub.prototype,{isEuler:!0,set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this._onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},
24549 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=O.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],l=e[5],m=e[9],k=e[2],n=e[6];e=e[10];b=b||this._order;switch(b){case "XYZ":this._y=Math.asin(d(g,-1,1));.9999999>Math.abs(g)?(this._x=Math.atan2(-m,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(n,l),this._z=0);break;case "YXZ":this._x=Math.asin(-d(m,-1,1));.9999999>Math.abs(m)?(this._y=
24550 Math.atan2(g,e),this._z=Math.atan2(h,l)):(this._y=Math.atan2(-k,a),this._z=0);break;case "ZXY":this._x=Math.asin(d(n,-1,1));.9999999>Math.abs(n)?(this._y=Math.atan2(-k,e),this._z=Math.atan2(-f,l)):(this._y=0,this._z=Math.atan2(h,a));break;case "ZYX":this._y=Math.asin(-d(k,-1,1));.9999999>Math.abs(k)?(this._x=Math.atan2(n,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,l));break;case "YZX":this._z=Math.asin(d(h,-1,1));.9999999>Math.abs(h)?(this._x=Math.atan2(-m,l),this._y=Math.atan2(-k,
24551 a)):(this._x=0,this._y=Math.atan2(g,e));break;case "XZY":this._z=Math.asin(-d(f,-1,1));.9999999>Math.abs(f)?(this._x=Math.atan2(n,l),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+b)}this._order=b;!1!==c&&this._onChangeCallback();return this},setFromQuaternion:function(a,b,c){ui.makeRotationFromQuaternion(a);return this.setFromRotationMatrix(ui,b,c)},setFromVector3:function(a,b){return this.set(a.x,
24552 a.y,a.z,b||this._order)},reorder:function(a){vi.setFromEuler(this);return this.setFromQuaternion(vi,a)},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=[]);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,
24553 this._y,this._z):new p(this._x,this._y,this._z)},_onChange:function(a){this._onChangeCallback=a;return this},_onChangeCallback:function(){}});Object.assign(De.prototype,{set:function(a){this.mask=1<<a|0},enable:function(a){this.mask=this.mask|1<<a|0},enableAll:function(){this.mask=-1},toggle:function(a){this.mask^=1<<a|0},disable:function(a){this.mask&=~(1<<a|0)},disableAll:function(){this.mask=0},test:function(a){return 0!==(this.mask&a.mask)}});var fj=0,wi=new p,nd=new va,yb=new N,Af=new p,te=new p,
24554 Jk=new p,Kk=new va,xi=new p(1,0,0),yi=new p(0,1,0),zi=new p(0,0,1),Lk={type:"added"},Mk={type:"removed"};y.DefaultUp=new p(0,1,0);y.DefaultMatrixAutoUpdate=!0;y.prototype=Object.assign(Object.create(ua.prototype),{constructor:y,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(a){this.matrixAutoUpdate&&this.updateMatrix();this.matrix.premultiply(a);this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(a){this.quaternion.premultiply(a);
24555 return this},setRotationFromAxisAngle:function(a,b){this.quaternion.setFromAxisAngle(a,b)},setRotationFromEuler:function(a){this.quaternion.setFromEuler(a,!0)},setRotationFromMatrix:function(a){this.quaternion.setFromRotationMatrix(a)},setRotationFromQuaternion:function(a){this.quaternion.copy(a)},rotateOnAxis:function(a,b){nd.setFromAxisAngle(a,b);this.quaternion.multiply(nd);return this},rotateOnWorldAxis:function(a,b){nd.setFromAxisAngle(a,b);this.quaternion.premultiply(nd);return this},rotateX:function(a){return this.rotateOnAxis(xi,
24556 a)},rotateY:function(a){return this.rotateOnAxis(yi,a)},rotateZ:function(a){return this.rotateOnAxis(zi,a)},translateOnAxis:function(a,b){wi.copy(a).applyQuaternion(this.quaternion);this.position.add(wi.multiplyScalar(b));return this},translateX:function(a){return this.translateOnAxis(xi,a)},translateY:function(a){return this.translateOnAxis(yi,a)},translateZ:function(a){return this.translateOnAxis(zi,a)},localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(a){return a.applyMatrix4(yb.getInverse(this.matrixWorld))},
24557 lookAt:function(a,b,c){a.isVector3?Af.copy(a):Af.set(a,b,c);a=this.parent;this.updateWorldMatrix(!0,!1);te.setFromMatrixPosition(this.matrixWorld);this.isCamera||this.isLight?yb.lookAt(te,Af,this.up):yb.lookAt(Af,te,this.up);this.quaternion.setFromRotationMatrix(yb);a&&(yb.extractRotation(a.matrixWorld),nd.setFromRotationMatrix(yb),this.quaternion.premultiply(nd.inverse()))},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.",
24558 a),this;a&&a.isObject3D?(null!==a.parent&&a.parent.remove(a),a.parent=this,this.children.push(a),a.dispatchEvent(Lk)):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]);return this}b=this.children.indexOf(a);-1!==b&&(a.parent=null,this.children.splice(b,1),a.dispatchEvent(Mk));return this},attach:function(a){this.updateWorldMatrix(!0,!1);yb.getInverse(this.matrixWorld);
24559 null!==a.parent&&(a.parent.updateWorldMatrix(!0,!1),yb.multiply(a.parent.matrixWorld));a.applyMatrix4(yb);a.updateWorldMatrix(!1,!1);this.add(a);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===
24560 a&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),a=new p);this.updateMatrixWorld(!0);return a.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(a){void 0===a&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),a=new va);this.updateMatrixWorld(!0);this.matrixWorld.decompose(te,a,Jk);return a},getWorldScale:function(a){void 0===a&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),a=new p);this.updateMatrixWorld(!0);
24561 this.matrixWorld.decompose(te,Kk,a);return a},getWorldDirection:function(a){void 0===a&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),a=new p);this.updateMatrixWorld(!0);var b=this.matrixWorld.elements;return a.set(b[8],b[9],b[10]).normalize()},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)}},
24562 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=
24563 0,d=b.length;c<d;c++)b[c].updateMatrixWorld(a)},updateWorldMatrix:function(a,b){var c=this.parent;!0===a&&null!==c&&c.updateWorldMatrix(!0,!1);this.matrixAutoUpdate&&this.updateMatrix();null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);if(!0===b)for(a=this.children,b=0,c=a.length;b<c;b++)a[b].updateWorldMatrix(!1,!0)},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=
24564 [],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&&(f.castShadow=!0);!0===this.receiveShadow&&(f.receiveShadow=!0);!1===this.visible&&(f.visible=!1);!1===this.frustumCulled&&(f.frustumCulled=!1);0!==this.renderOrder&&
24565 (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);this.isInstancedMesh&&(f.type="InstancedMesh",f.count=this.count,f.instanceMatrix=this.instanceMatrix.toJSON());if(this.isMesh||this.isLine||this.isPoints){f.geometry=b(a.geometries,this.geometry);var g=this.geometry.parameters;if(void 0!==g&&void 0!==g.shapes)if(g=g.shapes,Array.isArray(g))for(var h=
24566 0,l=g.length;h<l;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(l=this.material.length;h<l;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);l=c(a.textures);var m=c(a.images);g=c(a.shapes);0<d.length&&(e.geometries=d);
24567 0<h.length&&(e.materials=h);0<l.length&&(e.textures=l);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;this.matrixWorldNeedsUpdate=a.matrixWorldNeedsUpdate;
24568 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}});zc.prototype=Object.assign(Object.create(y.prototype),{constructor:zc,isScene:!0,copy:function(a,b){y.prototype.copy.call(this,a,b);null!==a.background&&(this.background=a.background.clone());
24569 null!==a.environment&&(this.environment=a.environment.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=y.prototype.toJSON.call(this,a);null!==this.background&&(b.object.background=this.background.toJSON(a));null!==this.environment&&(b.object.environment=this.environment.toJSON(a));null!==this.fog&&(b.object.fog=this.fog.toJSON());
24570 return b},dispose:function(){this.dispatchEvent({type:"dispose"})}});var zb=[new p,new p,new p,new p,new p,new p,new p,new p],ue=new p,Ug=new Va,od=new p,pd=new p,qd=new p,Qb=new p,Rb=new p,qc=new p,ve=new p,Bf=new p,Cf=new p,Vb=new p;Object.assign(Va.prototype,{isBox3:!0,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromArray:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,l=a.length;h<l;h+=3){var m=a[h],k=a[h+1],n=a[h+2];m<b&&(b=
24571 m);k<c&&(c=k);n<d&&(d=n);m>e&&(e=m);k>f&&(f=k);n>g&&(g=n)}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,l=a.count;h<l;h++){var m=a.getX(h),k=a.getY(h),n=a.getZ(h);m<b&&(b=m);k<c&&(c=k);n<d&&(d=n);m>e&&(e=m);k>f&&(f=k);n>g&&(g=n)}this.min.set(b,c,d);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]);
24572 return this},setFromCenterAndSize:function(a,b){b=ue.copy(b).multiplyScalar(.5);this.min.copy(a).sub(b);this.max.copy(a).add(b);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},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<
24573 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"),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);
24574 this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);this.max.addScalar(a);return this},expandByObject:function(a){a.updateWorldMatrix(!1,!1);var b=a.geometry;void 0!==b&&(null===b.boundingBox&&b.computeBoundingBox(),Ug.copy(b.boundingBox),Ug.applyMatrix4(a.matrixWorld),this.union(Ug));a=a.children;b=0;for(var c=a.length;b<c;b++)this.expandByObject(a[b]);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||
24575 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&&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||
24576 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(a){this.clampPoint(a.center,ue);return ue.distanceToSquared(a.center)<=a.radius*a.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*
24577 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(a){if(this.isEmpty())return!1;this.getCenter(ve);Bf.subVectors(this.max,ve);od.subVectors(a.a,ve);pd.subVectors(a.b,ve);qd.subVectors(a.c,ve);Qb.subVectors(pd,od);Rb.subVectors(qd,pd);qc.subVectors(od,qd);a=[0,-Qb.z,Qb.y,0,-Rb.z,Rb.y,0,-qc.z,qc.y,Qb.z,0,-Qb.x,Rb.z,0,-Rb.x,qc.z,0,-qc.x,-Qb.y,Qb.x,0,-Rb.y,Rb.x,0,-qc.y,qc.x,0];if(!Yf(a,od,pd,qd,Bf))return!1;
24578 a=[1,0,0,0,1,0,0,0,1];if(!Yf(a,od,pd,qd,Bf))return!1;Cf.crossVectors(Qb,Rb);a=[Cf.x,Cf.y,Cf.z];return Yf(a,od,pd,qd,Bf)},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(a){return ue.copy(a).clamp(this.min,this.max).sub(a).length()},getBoundingSphere:function(a){void 0===a&&console.error("THREE.Box3: .getBoundingSphere() target is now required");this.getCenter(a.center);
24579 a.radius=.5*this.getSize(ue).length();return a},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;zb[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(a);zb[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(a);zb[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(a);zb[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(a);
24580 zb[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(a);zb[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(a);zb[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(a);zb[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(a);this.setFromPoints(zb);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)}});var Nk=new Va;Object.assign(eb.prototype,{set:function(a,b){this.center.copy(a);this.radius=
24581 b;return this},setFromPoints:function(a,b){var c=this.center;void 0!==b?c.copy(b):Nk.setFromPoints(a).getCenter(c);for(var d=b=0,e=a.length;d<e;d++)b=Math.max(b,c.distanceToSquared(a[d]));this.radius=Math.sqrt(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.center.copy(a.center);this.radius=a.radius;return this},isEmpty:function(){return 0>this.radius},makeEmpty:function(){this.center.set(0,0,0);this.radius=-1;return this},containsPoint:function(a){return a.distanceToSquared(this.center)<=
24582 this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;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"),
24583 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===a&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),a=new Va);if(this.isEmpty())return a.makeEmpty(),a;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);
24584 return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}});var Ab=new p,Vg=new p,Df=new p,Sb=new p,Wg=new p,Ef=new p,Xg=new p;Object.assign(Wb.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,b){void 0===b&&(console.warn("THREE.Ray: .at() target is now required"),b=new p);
24585 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(a){this.origin.copy(this.at(a,Ab));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);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))},
24586 distanceSqToPoint:function(a){var b=Ab.subVectors(a,this.origin).dot(this.direction);if(0>b)return this.origin.distanceToSquared(a);Ab.copy(this.direction).multiplyScalar(b).add(this.origin);return Ab.distanceToSquared(a)},distanceSqToSegment:function(a,b,c,d){Vg.copy(a).add(b).multiplyScalar(.5);Df.copy(b).sub(a).normalize();Sb.copy(this.origin).sub(Vg);var e=.5*a.distanceTo(b),f=-this.direction.dot(Df),g=Sb.dot(this.direction),h=-Sb.dot(Df),l=Sb.lengthSq(),m=Math.abs(1-f*f);if(0<m){a=f*h-g;b=f*
24587 g-h;var k=e*m;0<=a?b>=-k?b<=k?(e=1/m,a*=e,b*=e,f=a*(a+f*b+2*g)+b*(f*a+b+2*h)+l):(b=e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+l):(b=-e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+l):b<=-k?(a=Math.max(0,-(-f*e+g)),b=0<a?-e:Math.min(Math.max(-e,-h),e),f=-a*a+b*(b+2*h)+l):b<=k?(a=0,b=Math.min(Math.max(-e,-h),e),f=b*(b+2*h)+l):(a=Math.max(0,-(f*e+g)),b=0<a?e:Math.min(Math.max(-e,-h),e),f=-a*a+b*(b+2*h)+l)}else b=0<f?-e:e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+l;c&&c.copy(this.direction).multiplyScalar(a).add(this.origin);
24588 d&&d.copy(Df).multiplyScalar(b).add(Vg);return f},intersectSphere:function(a,b){Ab.subVectors(a.center,this.origin);var c=Ab.dot(this.direction),d=Ab.dot(Ab)-c*c;a=a.radius*a.radius;if(d>a)return null;a=Math.sqrt(a-d);d=c-a;c+=a;return 0>d&&0>c?null:0>d?this.at(c,b):this.at(d,b)},intersectsSphere:function(a){return this.distanceSqToPoint(a.center)<=a.radius*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)+
24589 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,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-
24590 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(a){return null!==this.intersectBox(a,Ab)},intersectTriangle:function(a,b,c,d,e){Wg.subVectors(b,a);Ef.subVectors(c,a);Xg.crossVectors(Wg,Ef);b=this.direction.dot(Xg);if(0<b){if(d)return null;d=1}else if(0>b)d=-1,b=-b;else return null;
24591 Sb.subVectors(this.origin,a);a=d*this.direction.dot(Ef.crossVectors(Sb,Ef));if(0>a)return null;c=d*this.direction.dot(Wg.cross(Sb));if(0>c||a+c>b)return null;a=-d*Sb.dot(Xg);return 0>a?null:this.at(a/b,e)},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)}});var Yg=new p,Ok=new p,Pk=new ya;Object.assign(Wa.prototype,{isPlane:!0,set:function(a,b){this.normal.copy(a);
24592 this.constant=b;return this},setComponents:function(a,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(a,b,c){b=Yg.subVectors(c,b).cross(Ok.subVectors(a,b)).normalize();this.setFromNormalAndCoplanarPoint(b,a);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;
24593 return this},normalize:function(){var a=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)},
24594 intersectLine:function(a,b){void 0===b&&(console.warn("THREE.Plane: .intersectLine() target is now required"),b=new p);var c=a.delta(Yg),d=this.normal.dot(c);if(0===d){if(0===this.distanceToPoint(a.start))return b.copy(a.start)}else if(d=-(a.start.dot(this.normal)+this.constant)/d,!(0>d||1<d))return b.copy(c).multiplyScalar(d).add(a.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)},
24595 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(a,b){b=b||Pk.getNormalMatrix(a);a=this.coplanarPoint(Yg).applyMatrix4(a);b=this.normal.applyMatrix3(b).normalize();this.constant=-a.dot(b);return this},translate:function(a){this.constant-=a.dot(this.normal);return this},equals:function(a){return a.normal.equals(this.normal)&&
24596 a.constant===this.constant}});var cb=new p,Bb=new p,Zg=new p,Cb=new p,rd=new p,sd=new p,Ai=new p,$g=new p,ah=new p,bh=new p;Object.assign(pa,{getNormal:function(a,b,c,d){void 0===d&&(console.warn("THREE.Triangle: .getNormal() target is now required"),d=new p);d.subVectors(c,b);cb.subVectors(a,b);d.cross(cb);a=d.lengthSq();return 0<a?d.multiplyScalar(1/Math.sqrt(a)):d.set(0,0,0)},getBarycoord:function(a,b,c,d,e){cb.subVectors(d,b);Bb.subVectors(c,b);Zg.subVectors(a,b);a=cb.dot(cb);b=cb.dot(Bb);c=cb.dot(Zg);
24597 var f=Bb.dot(Bb);d=Bb.dot(Zg);var g=a*f-b*b;void 0===e&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),e=new p);if(0===g)return e.set(-2,-1,-1);g=1/g;f=(f*c-b*d)*g;a=(a*d-b*c)*g;return e.set(1-f-a,a,f)},containsPoint:function(a,b,c,d){pa.getBarycoord(a,b,c,d,Cb);return 0<=Cb.x&&0<=Cb.y&&1>=Cb.x+Cb.y},getUV:function(a,b,c,d,e,f,g,h){this.getBarycoord(a,b,c,d,Cb);h.set(0,0);h.addScaledVector(e,Cb.x);h.addScaledVector(f,Cb.y);h.addScaledVector(g,Cb.z);return h},isFrontFacing:function(a,
24598 b,c,d){cb.subVectors(c,b);Bb.subVectors(a,b);return 0>cb.cross(Bb).dot(d)?!0:!1}});Object.assign(pa.prototype,{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(){cb.subVectors(this.c,this.b);Bb.subVectors(this.a,
24599 this.b);return.5*cb.cross(Bb).length()},getMidpoint:function(a){void 0===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 pa.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 Wa);return a.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(a,b){return pa.getBarycoord(a,
24600 this.a,this.b,this.c,b)},getUV:function(a,b,c,d,e){return pa.getUV(a,this.a,this.b,this.c,b,c,d,e)},containsPoint:function(a){return pa.containsPoint(a,this.a,this.b,this.c)},isFrontFacing:function(a){return pa.isFrontFacing(this.a,this.b,this.c,a)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),b=new p);var c=this.a,d=this.b,e=this.c;rd.subVectors(d,c);sd.subVectors(e,
24601 c);$g.subVectors(a,c);var f=rd.dot($g),g=sd.dot($g);if(0>=f&&0>=g)return b.copy(c);ah.subVectors(a,d);var h=rd.dot(ah),l=sd.dot(ah);if(0<=h&&l<=h)return b.copy(d);var m=f*l-h*g;if(0>=m&&0<=f&&0>=h)return d=f/(f-h),b.copy(c).addScaledVector(rd,d);bh.subVectors(a,e);a=rd.dot(bh);var k=sd.dot(bh);if(0<=k&&a<=k)return b.copy(e);f=a*g-f*k;if(0>=f&&0<=g&&0>=k)return m=g/(g-k),b.copy(c).addScaledVector(sd,m);g=h*k-a*l;if(0>=g&&0<=l-h&&0<=a-k)return Ai.subVectors(e,d),m=(l-h)/(l-h+(a-k)),b.copy(d).addScaledVector(Ai,
24602 m);e=1/(g+f+m);d=f*e;m*=e;return b.copy(c).addScaledVector(rd,d).addScaledVector(sd,m)},equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});var Bi={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,
24603 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,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,
24604 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,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,
24605 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,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,
24606 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,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,
24607 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},Fa={h:0,s:0,l:0},Ff={h:0,s:0,l:0};Object.assign(D.prototype,{isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===
24608 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(a,b,c){a=O.euclideanModulo(a,1);b=O.clamp(b,0,1);c=O.clamp(c,0,1);0===b?this.r=this.g=this.b=c:(b=.5>=c?c*(1+b):c+b-c*b,c=2*c-b,this.r=Zf(c,b,a+1/3),this.g=Zf(c,b,a),this.b=Zf(c,b,a-1/3));return this},setStyle:function(a){function b(b){void 0!==
24609 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=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=
24610 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])/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)+
24611 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}return a&&0<a.length?this.setColorName(a):this},setColorName:function(a){var b=Bi[a];void 0!==b?this.setHex(b):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;
24612 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,a);return this},convertLinearToGamma:function(a){this.copyLinearToGamma(this,a);return this},copySRGBToLinear:function(a){this.r=
24613 $f(a.r);this.g=$f(a.g);this.b=$f(a.b);return this},copyLinearToSRGB:function(a){this.r=ag(a.r);this.g=ag(a.g);this.b=ag(a.b);return this},convertSRGBToLinear:function(){this.copySRGBToLinear(this);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"),
24614 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 l=e-f;f=.5>=h?l/(e+f):l/(2-e-f);switch(e){case b:g=(c-d)/l+(c<d?6:0);break;case c:g=(d-b)/l+2;break;case d:g=(b-c)/l+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(a,b,c){this.getHSL(Fa);Fa.h+=a;Fa.s+=b;Fa.l+=c;this.setHSL(Fa.h,Fa.s,Fa.l);return this},add:function(a){this.r+=a.r;this.g+=
24615 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+=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+=
24616 (a.b-this.b)*b;return this},lerpHSL:function(a,b){this.getHSL(Fa);a.getHSL(Ff);a=O.lerp(Fa.h,Ff.h,b);var c=O.lerp(Fa.s,Ff.s,b);b=O.lerp(Fa.l,Ff.l,b);this.setHSL(a,c,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=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()}});D.NAMES=
24617 Bi;Object.assign(Ac.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}});var gj=0;K.prototype=Object.assign(Object.create(ua.prototype),{constructor:K,isMaterial:!0,
24618 onBeforeCompile:function(){},setValues:function(a){if(void 0!==a)for(var b in a){var c=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]=
24619 c}}},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=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.sheen&&
24620 this.sheen.isColor&&(d.sheen=this.sheen.getHex());this.emissive&&this.emissive.isColor&&(d.emissive=this.emissive.getHex());this.emissiveIntensity&&1!==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.clearcoatMap&&
24621 this.clearcoatMap.isTexture&&(d.clearcoatMap=this.clearcoatMap.toJSON(a).uuid);this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(d.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(a).uuid);this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(d.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(a).uuid,d.clearcoatNormalScale=this.clearcoatNormalScale.toArray());this.map&&this.map.isTexture&&(d.map=this.map.toJSON(a).uuid);this.matcap&&this.matcap.isTexture&&(d.matcap=
24622 this.matcap.toJSON(a).uuid);this.alphaMap&&this.alphaMap.isTexture&&(d.alphaMap=this.alphaMap.toJSON(a).uuid);this.lightMap&&this.lightMap.isTexture&&(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=
24623 this.normalMapType,d.normalScale=this.normalScale.toArray());this.displacementMap&&this.displacementMap.isTexture&&(d.displacementMap=this.displacementMap.toJSON(a).uuid,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=
24624 this.emissiveMap.toJSON(a).uuid);this.specularMap&&this.specularMap.isTexture&&(d.specularMap=this.specularMap.toJSON(a).uuid);this.envMap&&this.envMap.isTexture&&(d.envMap=this.envMap.toJSON(a).uuid,d.reflectivity=this.reflectivity,d.refractionRatio=this.refractionRatio,void 0!==this.combine&&(d.combine=this.combine),void 0!==this.envMapIntensity&&(d.envMapIntensity=this.envMapIntensity));this.gradientMap&&this.gradientMap.isTexture&&(d.gradientMap=this.gradientMap.toJSON(a).uuid);void 0!==this.size&&
24625 (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);this.vertexColors&&(d.vertexColors=!0);1>this.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;d.stencilWrite=this.stencilWrite;d.stencilWriteMask=this.stencilWriteMask;
24626 d.stencilFunc=this.stencilFunc;d.stencilRef=this.stencilRef;d.stencilFuncMask=this.stencilFuncMask;d.stencilFail=this.stencilFail;d.stencilZFail=this.stencilZFail;d.stencilZPass=this.stencilZPass;this.rotation&&0!==this.rotation&&(d.rotation=this.rotation);!0===this.polygonOffset&&(d.polygonOffset=!0);0!==this.polygonOffsetFactor&&(d.polygonOffsetFactor=this.polygonOffsetFactor);0!==this.polygonOffsetUnits&&(d.polygonOffsetUnits=this.polygonOffsetUnits);this.linewidth&&1!==this.linewidth&&(d.linewidth=
24627 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=this.premultipliedAlpha);!0===this.wireframe&&(d.wireframe=this.wireframe);1<this.wireframeLinewidth&&(d.wireframeLinewidth=this.wireframeLinewidth);"round"!==this.wireframeLinecap&&(d.wireframeLinecap=this.wireframeLinecap);
24628 "round"!==this.wireframeLinejoin&&(d.wireframeLinejoin=this.wireframeLinejoin);!0===this.morphTargets&&(d.morphTargets=!0);!0===this.morphNormals&&(d.morphNormals=!0);!0===this.skinning&&(d.skinning=!0);!1===this.visible&&(d.visible=!1);!1===this.toneMapped&&(d.toneMapped=!1);"{}"!==JSON.stringify(this.userData)&&(d.userData=this.userData);c&&(c=b(a.textures),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=
24629 a.name;this.fog=a.fog;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=a.blendDstAlpha;this.blendEquationAlpha=a.blendEquationAlpha;this.depthFunc=a.depthFunc;this.depthTest=a.depthTest;this.depthWrite=a.depthWrite;this.stencilWriteMask=a.stencilWriteMask;
24630 this.stencilFunc=a.stencilFunc;this.stencilRef=a.stencilRef;this.stencilFuncMask=a.stencilFuncMask;this.stencilFail=a.stencilFail;this.stencilZFail=a.stencilZFail;this.stencilZPass=a.stencilZPass;this.stencilWrite=a.stencilWrite;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.clipIntersection=a.clipIntersection;this.clipShadows=a.clipShadows;this.shadowSide=a.shadowSide;this.colorWrite=a.colorWrite;this.precision=
24631 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.visible=a.visible;this.toneMapped=a.toneMapped;this.userData=JSON.parse(JSON.stringify(a.userData));return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Object.defineProperty(K.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});
24632 Pa.prototype=Object.create(K.prototype);Pa.prototype.constructor=Pa;Pa.prototype.isMeshBasicMaterial=!0;Pa.prototype.copy=function(a){K.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.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=
24633 a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;return this};var Y=new p;Object.defineProperty(G.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(G.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(a){this.usage=a;return this},copy:function(a){this.name=a.name;this.array=new a.array.constructor(a.array);
24634 this.itemSize=a.itemSize;this.count=a.count;this.normalized=a.normalized;this.usage=a.usage;return this},copyAt:function(a,b,c){a*=this.itemSize;c*=b.itemSize;for(var d=0,e=this.itemSize;d<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 D);b[c++]=f.r;b[c++]=f.g;b[c++]=
24635 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",d),f=new v);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=
24636 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 R);b[c++]=f.x;b[c++]=f.y;b[c++]=f.z;b[c++]=f.w}return this},applyMatrix3:function(a){for(var b=0,c=this.count;b<c;b++)Y.x=this.getX(b),Y.y=this.getY(b),Y.z=this.getZ(b),Y.applyMatrix3(a),this.setXYZ(b,Y.x,Y.y,Y.z);return this},applyMatrix4:function(a){for(var b=0,c=this.count;b<c;b++)Y.x=this.getX(b),Y.y=this.getY(b),Y.z=this.getZ(b),Y.applyMatrix4(a),
24637 this.setXYZ(b,Y.x,Y.y,Y.z);return this},applyNormalMatrix:function(a){for(var b=0,c=this.count;b<c;b++)Y.x=this.getX(b),Y.y=this.getY(b),Y.z=this.getZ(b),Y.applyNormalMatrix(a),this.setXYZ(b,Y.x,Y.y,Y.z);return this},transformDirection:function(a){for(var b=0,c=this.count;b<c;b++)Y.x=this.getX(b),Y.y=this.getY(b),Y.z=this.getZ(b),Y.transformDirection(a),this.setXYZ(b,Y.x,Y.y,Y.z);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*
24638 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+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+
24639 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,this.itemSize)).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),
24640 normalized:this.normalized}}});yd.prototype=Object.create(G.prototype);yd.prototype.constructor=yd;zd.prototype=Object.create(G.prototype);zd.prototype.constructor=zd;Ad.prototype=Object.create(G.prototype);Ad.prototype.constructor=Ad;Bd.prototype=Object.create(G.prototype);Bd.prototype.constructor=Bd;Xb.prototype=Object.create(G.prototype);Xb.prototype.constructor=Xb;Cd.prototype=Object.create(G.prototype);Cd.prototype.constructor=Cd;Yb.prototype=Object.create(G.prototype);Yb.prototype.constructor=
24641 Yb;B.prototype=Object.create(G.prototype);B.prototype.constructor=B;Dd.prototype=Object.create(G.prototype);Dd.prototype.constructor=Dd;Object.assign(rh.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,
24642 e=d[0]&&0<d[0].length,f=d[1]&&0<d[1].length,g=a.morphTargets,h=g.length;if(0<h){var l=[];for(var m=0;m<h;m++)l[m]={name:g[m].name,data:[]};this.morphTargets.position=l}var k=a.morphNormals,n=k.length;if(0<n){var p=[];for(m=0;m<n;m++)p[m]={name:k[m].name,data:[]};this.morphTargets.normal=p}var r=a.skinIndices,q=a.skinWeights,u=r.length===c.length,E=q.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=
24643 b[m];this.vertices.push(c[x.a],c[x.b],c[x.c]);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 v,new v,new v)));!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 ",
24644 m),this.uvs2.push(new v,new v,new v)));for(w=0;w<h;w++){var y=g[w].vertices;l[w].data.push(y[x.a],y[x.b],y[x.c])}for(w=0;w<n;w++)y=k[w].vertexNormals[m],p[w].data.push(y.a,y.b,y.c);u&&this.skinIndices.push(r[x.a],r[x.b],r[x.c]);E&&this.skinWeights.push(q[x.a],q[x.b],q[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;
24645 null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());return this}});var hj=1,ob=new N,ch=new y,td=new p,Oa=new Va,we=new Va,oa=new p;F.prototype=Object.assign(Object.create(ua.prototype),{constructor:F,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(a){Array.isArray(a)?this.index=new (65535<sh(a)?Yb:Xb)(a,1):this.index=a},getAttribute:function(a){return this.attributes[a]},setAttribute:function(a,
24646 b){this.attributes[a]=b;return this},deleteAttribute: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},applyMatrix4:function(a){var b=this.attributes.position;void 0!==b&&(b.applyMatrix4(a),b.needsUpdate=!0);b=this.attributes.normal;if(void 0!==b){var c=(new ya).getNormalMatrix(a);b.applyNormalMatrix(c);
24647 b.needsUpdate=!0}b=this.attributes.tangent;void 0!==b&&(b.transformDirection(a),b.needsUpdate=!0);null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();return this},rotateX:function(a){ob.makeRotationX(a);this.applyMatrix4(ob);return this},rotateY:function(a){ob.makeRotationY(a);this.applyMatrix4(ob);return this},rotateZ:function(a){ob.makeRotationZ(a);this.applyMatrix4(ob);return this},translate:function(a,b,c){ob.makeTranslation(a,b,c);this.applyMatrix4(ob);
24648 return this},scale:function(a,b,c){ob.makeScale(a,b,c);this.applyMatrix4(ob);return this},lookAt:function(a){ch.lookAt(a);ch.updateMatrix();this.applyMatrix4(ch.matrix);return this},center:function(){this.computeBoundingBox();this.boundingBox.getCenter(td).negate();this.translate(td.x,td.y,td.z);return this},setFromObject:function(a){var b=a.geometry;if(a.isPoints||a.isLine){a=new B(3*b.vertices.length,3);var c=new B(3*b.colors.length,3);this.setAttribute("position",a.copyVector3sArray(b.vertices));
24649 this.setAttribute("color",c.copyColorsArray(b.colors));b.lineDistances&&b.lineDistances.length===b.vertices.length&&(a=new B(b.lineDistances.length,1),this.setAttribute("lineDistance",a.copyArray(b.lineDistances)));null!==b.boundingSphere&&(this.boundingSphere=b.boundingSphere.clone());null!==b.boundingBox&&(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,
24650 e.y,e.z||0)}this.setAttribute("position",new B(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=b.normalsNeedUpdate;c.colorsNeedUpdate=b.colorsNeedUpdate;c.uvsNeedUpdate=b.uvsNeedUpdate;c.groupsNeedUpdate=b.groupsNeedUpdate;b.verticesNeedUpdate=!1;b.normalsNeedUpdate=!1;b.colorsNeedUpdate=
24651 !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=!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!==
24652 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},fromGeometry:function(a){a.__directGeometry=(new rh).fromGeometry(a);return this.fromDirectGeometry(a.__directGeometry)},fromDirectGeometry:function(a){var b=new Float32Array(3*
24653 a.vertices.length);this.setAttribute("position",(new G(b,3)).copyVector3sArray(a.vertices));0<a.normals.length&&(b=new Float32Array(3*a.normals.length),this.setAttribute("normal",(new G(b,3)).copyVector3sArray(a.normals)));0<a.colors.length&&(b=new Float32Array(3*a.colors.length),this.setAttribute("color",(new G(b,3)).copyColorsArray(a.colors)));0<a.uvs.length&&(b=new Float32Array(2*a.uvs.length),this.setAttribute("uv",(new G(b,2)).copyVector2sArray(a.uvs)));0<a.uvs2.length&&(b=new Float32Array(2*
24654 a.uvs2.length),this.setAttribute("uv2",(new G(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 B(3*g.data.length,3);h.name=g.name;b.push(h.copyVector3sArray(g.data))}this.morphAttributes[c]=b}0<a.skinIndices.length&&(c=new B(4*a.skinIndices.length,4),this.setAttribute("skinIndex",c.copyVector4sArray(a.skinIndices)));0<a.skinWeights.length&&(c=new B(4*a.skinWeights.length,4),this.setAttribute("skinWeight",
24655 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 Va);var a=this.attributes.position,b=this.morphAttributes.position;if(void 0!==a){if(this.boundingBox.setFromBufferAttribute(a),b){a=0;for(var c=b.length;a<c;a++)Oa.setFromBufferAttribute(b[a]),this.morphTargetsRelative?(oa.addVectors(this.boundingBox.min,
24656 Oa.min),this.boundingBox.expandByPoint(oa),oa.addVectors(this.boundingBox.max,Oa.max),this.boundingBox.expandByPoint(oa)):(this.boundingBox.expandByPoint(Oa.min),this.boundingBox.expandByPoint(Oa.max))}}else this.boundingBox.makeEmpty();(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(){null===
24657 this.boundingSphere&&(this.boundingSphere=new eb);var a=this.attributes.position,b=this.morphAttributes.position;if(a){var c=this.boundingSphere.center;Oa.setFromBufferAttribute(a);if(b)for(var d=0,e=b.length;d<e;d++){var f=b[d];we.setFromBufferAttribute(f);this.morphTargetsRelative?(oa.addVectors(Oa.min,we.min),Oa.expandByPoint(oa),oa.addVectors(Oa.max,we.max),Oa.expandByPoint(oa)):(Oa.expandByPoint(we.min),Oa.expandByPoint(we.max))}Oa.getCenter(c);var g=0;d=0;for(e=a.count;d<e;d++)oa.fromBufferAttribute(a,
24658 d),g=Math.max(g,c.distanceToSquared(oa));if(b)for(d=0,e=b.length;d<e;d++){f=b[d];for(var h=this.morphTargetsRelative,l=0,m=f.count;l<m;l++)oa.fromBufferAttribute(f,l),h&&(td.fromBufferAttribute(a,l),oa.add(td)),g=Math.max(g,c.distanceToSquared(oa))}this.boundingSphere.radius=Math.sqrt(g);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(){},
24659 computeVertexNormals:function(){var a=this.index,b=this.attributes;if(b.position){var c=b.position.array;if(void 0===b.normal)this.setAttribute("normal",new G(new Float32Array(c.length),3));else for(var d=b.normal.array,e=0,f=d.length;e<f;e++)d[e]=0;d=b.normal.array;var g=new p,h=new p,l=new p,m=new p,k=new p;if(a){var n=a.array;e=0;for(f=a.count;e<f;e+=3){a=3*n[e+0];var t=3*n[e+1];var r=3*n[e+2];g.fromArray(c,a);h.fromArray(c,t);l.fromArray(c,r);m.subVectors(l,h);k.subVectors(g,h);m.cross(k);d[a]+=
24660 m.x;d[a+1]+=m.y;d[a+2]+=m.z;d[t]+=m.x;d[t+1]+=m.y;d[t+2]+=m.z;d[r]+=m.x;d[r+1]+=m.y;d[r+2]+=m.z}}else for(e=0,f=c.length;e<f;e+=9)g.fromArray(c,e),h.fromArray(c,e+3),l.fromArray(c,e+6),m.subVectors(l,h),k.subVectors(g,h),m.cross(k),d[e]=m.x,d[e+1]=m.y,d[e+2]=m.z,d[e+3]=m.x,d[e+4]=m.y,d[e+5]=m.z,d[e+6]=m.x,d[e+7]=m.y,d[e+8]=m.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."));
24661 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=f.itemSize*b;f=Math.min(g.length,e.length-h);for(var l=0;l<f;l++,h++)e[h]=g[l]}return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",a)},normalizeNormals:function(){for(var a=this.attributes.normal,b=0,c=a.count;b<c;b++)oa.x=a.getX(b),oa.y=a.getY(b),oa.z=a.getZ(b),oa.normalize(),a.setXYZ(b,oa.x,oa.y,oa.z)},toNonIndexed:function(){function a(a,
24662 b){var c=a.array,d=a.itemSize;a=a.normalized;for(var e=new c.constructor(b.length*d),f,g=0,h=0,l=b.length;h<l;h++){f=b[h]*d;for(var m=0;m<d;m++)e[g++]=c[f++]}return new G(e,d,a)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var b=new F,c=this.index.array,d=this.attributes,e;for(e in d){var f=d[e];f=a(f,c);b.setAttribute(e,f)}var g=this.morphAttributes;for(e in g){var h=[],l=g[e];d=0;for(var m=l.length;d<m;d++)f=l[d],f=a(f,c),
24663 h.push(f);b.morphAttributes[e]=h}b.morphTargetsRelative=this.morphTargetsRelative;c=this.groups;d=0;for(e=c.length;d<e;d++)f=c[d],b.addGroup(f.start,f.count,f.materialIndex);return b},toJSON:function(){var a={metadata:{version:4.5,type:"BufferGeometry",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(m in b)void 0!==b[m]&&(a[m]=
24664 b[m]);return a}a.data={attributes:{}};b=this.index;null!==b&&(a.data.index={type:b.array.constructor.name,array:Array.prototype.slice.call(b.array)});var c=this.attributes;for(m in c){b=c[m];var d=b.toJSON();""!==b.name&&(d.name=b.name);a.data.attributes[m]=d}c={};var e=!1;for(m in this.morphAttributes){for(var f=this.morphAttributes[m],g=[],h=0,l=f.length;h<l;h++)b=f[h],d=b.toJSON(),""!==b.name&&(d.name=b.name),g.push(d);0<g.length&&(c[m]=g,e=!0)}e&&(a.data.morphAttributes=c,a.data.morphTargetsRelative=
24665 this.morphTargetsRelative);var m=this.groups;0<m.length&&(a.data.groups=JSON.parse(JSON.stringify(m)));m=this.boundingSphere;null!==m&&(a.data.boundingSphere={center:m.center.toArray(),radius:m.radius});return a},clone:function(){return(new F).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());c=a.attributes;for(g in c)this.setAttribute(g,
24666 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}this.morphTargetsRelative=a.morphTargetsRelative;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;
24667 return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var Ci=new N,rc=new Wb,dh=new eb,Db=new p,Eb=new p,Fb=new p,bg=new p,cg=new p,dg=new p,Ge=new p,He=new p,Ie=new p,Bc=new v,Cc=new v,Dc=new v,Ed=new p,Ee=new p;ea.prototype=Object.assign(Object.create(y.prototype),{constructor:ea,isMesh:!0,copy:function(a){y.prototype.copy.call(this,a);void 0!==a.morphTargetInfluences&&(this.morphTargetInfluences=a.morphTargetInfluences.slice());void 0!==a.morphTargetDictionary&&(this.morphTargetDictionary=
24668 Object.assign({},a.morphTargetDictionary));return this},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=a.morphAttributes;var b=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 a=a.morphTargets,void 0!==a&&0<a.length&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},
24669 raycast:function(a,b){var c=this.geometry,d=this.material,e=this.matrixWorld;if(void 0!==d&&(null===c.boundingSphere&&c.computeBoundingSphere(),dh.copy(c.boundingSphere),dh.applyMatrix4(e),!1!==a.ray.intersectsSphere(dh)&&(Ci.getInverse(e),rc.copy(a.ray).applyMatrix4(Ci),null===c.boundingBox||!1!==rc.intersectsBox(c.boundingBox))))if(c.isBufferGeometry){var f=c.index;e=c.attributes.position;var g=c.morphAttributes.position,h=c.morphTargetsRelative,l=c.attributes.uv,m=c.attributes.uv2,k=c.groups,n=
24670 c.drawRange,p,r;if(null!==f)if(Array.isArray(d)){var q=0;for(p=k.length;q<p;q++){var u=k[q];var E=d[u.materialIndex];var x=Math.max(u.start,n.start);for(r=c=Math.min(u.start+u.count,n.start+n.count);x<r;x+=3){c=f.getX(x);var w=f.getX(x+1);var y=f.getX(x+2);if(c=Fe(this,E,a,rc,e,g,h,l,m,c,w,y))c.faceIndex=Math.floor(x/3),c.face.materialIndex=u.materialIndex,b.push(c)}}}else for(x=Math.max(0,n.start),c=Math.min(f.count,n.start+n.count),q=x,p=c;q<p;q+=3){if(c=f.getX(q),w=f.getX(q+1),y=f.getX(q+2),c=
24671 Fe(this,d,a,rc,e,g,h,l,m,c,w,y))c.faceIndex=Math.floor(q/3),b.push(c)}else if(void 0!==e)if(Array.isArray(d))for(q=0,p=k.length;q<p;q++)for(u=k[q],E=d[u.materialIndex],x=Math.max(u.start,n.start),r=c=Math.min(u.start+u.count,n.start+n.count);x<r;x+=3){if(c=x,w=x+1,y=x+2,c=Fe(this,E,a,rc,e,g,h,l,m,c,w,y))c.faceIndex=Math.floor(x/3),c.face.materialIndex=u.materialIndex,b.push(c)}else for(x=Math.max(0,n.start),c=Math.min(e.count,n.start+n.count),q=x,p=c;q<p;q+=3)if(c=q,w=q+1,y=q+2,c=Fe(this,d,a,rc,e,
24672 g,h,l,m,c,w,y))c.faceIndex=Math.floor(q/3),b.push(c)}else if(c.isGeometry)for(e=Array.isArray(d),g=c.vertices,h=c.faces,c=c.faceVertexUvs[0],0<c.length&&(f=c),n=0,q=h.length;n<q;n++)if(p=h[n],c=e?d[p.materialIndex]:d,void 0!==c&&(l=g[p.a],m=g[p.b],k=g[p.c],c=th(this,c,a,rc,l,m,k,Ed)))f&&f[n]&&(u=f[n],Bc.copy(u[0]),Cc.copy(u[1]),Dc.copy(u[2]),c.uv=pa.getUV(Ed,l,m,k,Bc,Cc,Dc,new v)),c.face=p,c.faceIndex=n,b.push(c)},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});
24673 var ij=0,pb=new N,eh=new y,Gf=new p;L.prototype=Object.assign(Object.create(ua.prototype),{constructor:L,isGeometry:!0,applyMatrix4:function(a){for(var b=(new ya).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&&
24674 this.computeBoundingSphere();this.normalsNeedUpdate=this.verticesNeedUpdate=!0;return this},rotateX:function(a){pb.makeRotationX(a);this.applyMatrix4(pb);return this},rotateY:function(a){pb.makeRotationY(a);this.applyMatrix4(pb);return this},rotateZ:function(a){pb.makeRotationZ(a);this.applyMatrix4(pb);return this},translate:function(a,b,c){pb.makeTranslation(a,b,c);this.applyMatrix4(pb);return this},scale:function(a,b,c){pb.makeScale(a,b,c);this.applyMatrix4(pb);return this},lookAt:function(a){eh.lookAt(a);
24675 eh.updateMatrix();this.applyMatrix4(eh.matrix);return this},fromBufferGeometry:function(a){function b(a,b,d,e){var f=void 0===h?[]:[c.colors[a].clone(),c.colors[b].clone(),c.colors[d].clone()],k=void 0===g?[]:[(new p).fromArray(g,3*a),(new p).fromArray(g,3*b),(new p).fromArray(g,3*d)];e=new Ac(a,b,d,k,f,e);c.faces.push(e);void 0!==l&&c.faceVertexUvs[0].push([(new v).fromArray(l,2*a),(new v).fromArray(l,2*b),(new v).fromArray(l,2*d)]);void 0!==m&&c.faceVertexUvs[1].push([(new v).fromArray(m,2*a),(new v).fromArray(m,
24676 2*b),(new v).fromArray(m,2*d)])}var c=this,d=null!==a.index?a.index.array:void 0,e=a.attributes;if(void 0===e.position)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;var f=e.position.array,g=void 0!==e.normal?e.normal.array:void 0,h=void 0!==e.color?e.color.array:void 0,l=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(e=0;e<f.length;e+=3)c.vertices.push((new p).fromArray(f,
24677 e)),void 0!==h&&c.colors.push((new D).fromArray(h,e));var k=a.groups;if(0<k.length)for(e=0;e<k.length;e++){f=k[e];var n=f.start,t=n;for(n+=f.count;t<n;t+=3)void 0!==d?b(d[t],d[t+1],d[t+2],f.materialIndex):b(t,t+1,t+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&&(this.boundingSphere=a.boundingSphere.clone());
24678 return this},center:function(){this.computeBoundingBox();this.boundingBox.getCenter(Gf).negate();this.translate(Gf.x,Gf.y,Gf.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 N;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.applyMatrix4(c);return this},computeFaceNormals:function(){for(var a=new p,b=new p,c=0,d=this.faces.length;c<d;c++){var e=this.faces[c],f=this.vertices[e.a],g=this.vertices[e.b];
24679 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 l=this.vertices[b.c];e.subVectors(l,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(),
24680 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=!0)},computeFlatVertexNormals:function(){var a;this.computeFaceNormals();var b=0;for(a=this.faces.length;b<
24681 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):d.__originalFaceNormal=d.normal.clone();d.__originalVertexNormals||(d.__originalVertexNormals=[]);
24682 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 L;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;var g=this.morphNormals[e].vertexNormals;c=0;for(b=this.faces.length;c<b;c++){var h=
24683 new p;var l={a:new p,b:new p,c:new p};d.push(h);g.push(l)}}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],l=g.vertexNormals[c],h.copy(d.normal),l.a.copy(d.vertexNormals[0]),l.b.copy(d.vertexNormals[1]),l.c.copy(d.vertexNormals[2])}c=0;for(b=this.faces.length;c<b;c++)d=this.faces[c],d.normal=d.__originalFaceNormal,d.vertexNormals=d.__originalVertexNormals},computeBoundingBox:function(){null===
24684 this.boundingBox&&(this.boundingBox=new Va);this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new eb);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,l=a.faces,m=this.colors,k=a.colors;void 0===c&&(c=0);void 0!==b&&(d=(new ya).getNormalMatrix(b));for(var n=0,p=g.length;n<p;n++){var r=g[n].clone();void 0!==
24685 b&&r.applyMatrix4(b);f.push(r)}n=0;for(p=k.length;n<p;n++)m.push(k[n].clone());n=0;for(p=l.length;n<p;n++){g=l[n];var q=g.vertexNormals;k=g.vertexColors;m=new Ac(g.a+e,g.b+e,g.c+e);m.normal.copy(g.normal);void 0!==d&&m.normal.applyMatrix3(d).normalize();b=0;for(f=q.length;b<f;b++)r=q[b].clone(),void 0!==d&&r.applyMatrix3(d).normalize(),m.vertexNormals.push(r);m.color.copy(g.color);b=0;for(f=k.length;b<f;b++)r=k[b],m.vertexColors.push(r.clone());m.materialIndex=g.materialIndex+c;h.push(m)}n=0;for(p=
24686 a.faceVertexUvs.length;n<p;n++)for(c=a.faceVertexUvs[n],void 0===this.faceVertexUvs[n]&&(this.faceVertexUvs[n]=[]),b=0,f=c.length;b<f;b++){d=c[b];e=[];h=0;for(l=d.length;h<l;h++)e.push(d[h].clone());this.faceVertexUvs[n].push(e)}}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.",
24687 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=
24688 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&&
24689 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]=l.length/3;l.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]=k.length;k.push(a.getHex());return n[b]}function d(a){var b=
24690 a.x.toString()+a.y.toString();if(void 0!==r[b])return r[b];r[b]=p.length/2;p.push(a.x,a.y);return r[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 l=[],m={},k=[],n={},p=[],r={};for(g=0;g<this.faces.length;g++){var q=
24691 this.faces[g],u=void 0!==this.faceVertexUvs[0][g],v=0<q.normal.length(),x=0<q.vertexNormals.length,w=1!==q.color.r||1!==q.color.g||1!==q.color.b,y=0<q.vertexColors.length,A=0;A=a(A,0,0);A=a(A,1,!0);A=a(A,2,!1);A=a(A,3,u);A=a(A,4,v);A=a(A,5,x);A=a(A,6,w);A=a(A,7,y);h.push(A);h.push(q.a,q.b,q.c);h.push(q.materialIndex);u&&(u=this.faceVertexUvs[0][g],h.push(d(u[0]),d(u[1]),d(u[2])));v&&h.push(b(q.normal));x&&(v=q.vertexNormals,h.push(b(v[0]),b(v[1]),b(v[2])));w&&h.push(c(q.color));y&&(q=q.vertexColors,
24692 h.push(c(q[0]),c(q[1]),c(q[2])))}e.data={};e.data.vertices=f;e.data.normals=l;0<k.length&&(e.data.colors=k);0<p.length&&(e.data.uvs=[p]);e.data.faces=h;return e},clone:function(){return(new L).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<
24693 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],l=[];var m=0;for(d=h.length;m<d;m++)l.push(h[m].clone());this.faceVertexUvs[f].push(l)}}m=a.morphTargets;f=0;for(b=m.length;f<b;f++){d={};d.name=m[f].name;if(void 0!==
24694 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!==
24695 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=
24696 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"})}});var fh=function(a){function b(b,d,e,f,g,h){a.call(this);this.type="BoxGeometry";this.parameters={width:b,height:d,depth:e,widthSegments:f,heightSegments:g,
24697 depthSegments:h};this.fromBufferGeometry(new Gd(b,d,e,f,g,h));this.mergeVertices()}a&&(b.__proto__=a);b.prototype=Object.create(a&&a.prototype);return b.prototype.constructor=b}(L),Gd=function(a){function b(b,d,e,f,g,h){function c(a,b,c,d,e,f,g,h,l,z,v){var w=f/l,x=g/z,y=f/2,A=g/2,E=h/2;g=l+1;for(var C=z+1,B=f=0,D=new p,F=0;F<C;F++)for(var G=F*x-A,H=0;H<g;H++)D[a]=(H*w-y)*d,D[b]=G*e,D[c]=E,n.push(D.x,D.y,D.z),D[a]=0,D[b]=0,D[c]=0<h?1:-1,t.push(D.x,D.y,D.z),r.push(H/l),r.push(1-F/z),f+=1;for(a=0;a<
24698 z;a++)for(b=0;b<l;b++)c=q+b+g*(a+1),d=q+(b+1)+g*(a+1),e=q+(b+1)+g*a,k.push(q+b+g*a,c,e),k.push(c,d,e),B+=6;m.addGroup(u,B,v);u+=B;q+=f}a.call(this);this.type="BoxBufferGeometry";this.parameters={width:b,height:d,depth:e,widthSegments:f,heightSegments:g,depthSegments:h};var m=this;b=b||1;d=d||1;e=e||1;f=Math.floor(f)||1;g=Math.floor(g)||1;h=Math.floor(h)||1;var k=[],n=[],t=[],r=[],q=0,u=0;c("z","y","x",-1,-1,e,d,b,h,g,0);c("z","y","x",1,-1,e,d,-b,h,g,1);c("x","z","y",1,1,b,e,d,f,h,2);c("x","z","y",
24699 1,-1,b,e,-d,f,h,3);c("x","y","z",1,-1,b,d,e,f,g,4);c("x","y","z",-1,-1,b,d,-e,f,g,5);this.setIndex(k);this.setAttribute("position",new B(n,3));this.setAttribute("normal",new B(t,3));this.setAttribute("uv",new B(r,2))}a&&(b.__proto__=a);b.prototype=Object.create(a&&a.prototype);return b.prototype.constructor=b}(F),Oh={clone:Ec,merge:wa};Ca.prototype=Object.create(K.prototype);Ca.prototype.constructor=Ca;Ca.prototype.isShaderMaterial=!0;Ca.prototype.copy=function(a){K.prototype.copy.call(this,a);this.fragmentShader=
24700 a.fragmentShader;this.vertexShader=a.vertexShader;this.uniforms=Ec(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;this.morphNormals=a.morphNormals;this.extensions=Object.assign({},a.extensions);return this};Ca.prototype.toJSON=function(a){var b=K.prototype.toJSON.call(this,a);b.uniforms={};for(var c in this.uniforms){var d=
24701 this.uniforms[c].value;b.uniforms[c]=d&&d.isTexture?{type:"t",value:d.toJSON(a).uuid}:d&&d.isColor?{type:"c",value:d.getHex()}:d&&d.isVector2?{type:"v2",value:d.toArray()}:d&&d.isVector3?{type:"v3",value:d.toArray()}:d&&d.isVector4?{type:"v4",value:d.toArray()}:d&&d.isMatrix3?{type:"m3",value:d.toArray()}:d&&d.isMatrix4?{type:"m4",value:d.toArray()}:{value:d}}0<Object.keys(this.defines).length&&(b.defines=this.defines);b.vertexShader=this.vertexShader;b.fragmentShader=this.fragmentShader;a={};for(var e in this.extensions)!0===
24702 this.extensions[e]&&(a[e]=!0);0<Object.keys(a).length&&(b.extensions=a);return b};fb.prototype=Object.assign(Object.create(y.prototype),{constructor:fb,isCamera:!0,copy:function(a,b){y.prototype.copy.call(this,a,b);this.matrixWorldInverse.copy(a.matrixWorldInverse);this.projectionMatrix.copy(a.projectionMatrix);this.projectionMatrixInverse.copy(a.projectionMatrixInverse);return this},getWorldDirection:function(a){void 0===a&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),
24703 a=new p);this.updateMatrixWorld(!0);var b=this.matrixWorld.elements;return a.set(-b[8],-b[9],-b[10]).normalize()},updateMatrixWorld:function(a){y.prototype.updateMatrixWorld.call(this,a);this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(a,b){y.prototype.updateWorldMatrix.call(this,a,b);this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}});P.prototype=Object.assign(Object.create(fb.prototype),{constructor:P,
24704 isPerspectiveCamera:!0,copy:function(a,b){fb.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()/a;this.fov=2*O.RAD2DEG*Math.atan(a);this.updateProjectionMatrix()},getFocalLength:function(){var a=Math.tan(.5*O.DEG2RAD*this.fov);return.5*this.getFilmHeight()/
24705 a},getEffectiveFOV:function(){return 2*O.RAD2DEG*Math.atan(Math.tan(.5*O.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,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=
24706 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*O.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=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,
24707 e+d,b,b-c,a,this.far);this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(a){a=y.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=this.filmOffset;return a}});Fc.prototype=Object.create(y.prototype);Fc.prototype.constructor=Fc;Zb.prototype=
24708 Object.create(Ba.prototype);Zb.prototype.constructor=Zb;Zb.prototype.isWebGLCubeRenderTarget=!0;Zb.prototype.fromEquirectangularTexture=function(a,b){this.texture.type=b.type;this.texture.format=b.format;this.texture.encoding=b.encoding;var c=new zc,d=new Ca({type:"CubemapFromEquirect",uniforms:Ec({tEquirect:{value:null}}),vertexShader:"varying vec3 vWorldDirection;\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",
24709 fragmentShader:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}",side:1,blending:0});d.uniforms.tEquirect.value=b;b=new ea(new Gd(5,5,5),d);c.add(b);(new Fc(1,10,this)).update(a,c);b.geometry.dispose();b.material.dispose();return this};$b.prototype=Object.create(W.prototype);$b.prototype.constructor=$b;$b.prototype.isDataTexture=
24710 !0;var ud=new eb,Hf=new p;Object.assign(Gc.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},setFromProjectionMatrix: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],h=c[5],l=c[6],m=c[7],k=c[8],n=c[9],p=c[10],r=c[11],q=c[12],u=
24711 c[13],v=c[14];c=c[15];b[0].setComponents(f-a,m-g,r-k,c-q).normalize();b[1].setComponents(f+a,m+g,r+k,c+q).normalize();b[2].setComponents(f+d,m+h,r+n,c+u).normalize();b[3].setComponents(f-d,m-h,r-n,c-u).normalize();b[4].setComponents(f-e,m-l,r-p,c-v).normalize();b[5].setComponents(f+e,m+l,r+p,c+v).normalize();return this},intersectsObject:function(a){var b=a.geometry;null===b.boundingSphere&&b.computeBoundingSphere();ud.copy(b.boundingSphere).applyMatrix4(a.matrixWorld);return this.intersectsSphere(ud)},
24712 intersectsSprite:function(a){ud.center.set(0,0,0);ud.radius=.7071067811865476;ud.applyMatrix4(a.matrixWorld);return this.intersectsSphere(ud)},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(a){for(var b=this.planes,c=0;6>c;c++){var d=b[c];Hf.x=0<d.normal.x?a.max.x:a.min.x;Hf.y=0<d.normal.y?a.max.y:a.min.y;Hf.z=0<d.normal.z?a.max.z:a.min.z;if(0>d.distanceToPoint(Hf))return!1}return!0},
24713 containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}});var A={common:{diffuse:{value:new D(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new ya},uv2Transform:{value:new ya},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},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},
24714 lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new v(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},fogFar:{value:2E3},fogColor:{value:new D(16777215)}},
24715 lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},
24716 spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 D(15658734)},opacity:{value:1},
24717 size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new ya}},sprite:{diffuse:{value:new D(15658734)},opacity:{value:1},center:{value:new v(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new ya}}};Fd.prototype=Object.create(L.prototype);Fd.prototype.constructor=Fd;ac.prototype=Object.create(F.prototype);ac.prototype.constructor=ac;var M={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",
24718 alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",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( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",
24719 aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\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\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\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}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( 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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\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#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",
24720 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",
24721 clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",
24722 clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",
24723 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#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(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}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\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#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\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}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",
24724 cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x); } else if (face == 1.0) {\n uv = vec2(-direction.x, -direction.z) / abs(direction.y); } else if (face == 2.0) {\n uv = vec2(-direction.x, direction.y) / abs(direction.z); } else if (face == 3.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x); } else if (face == 4.0) {\n uv = vec2(-direction.x, direction.z) / abs(direction.y); } else {\n uv = vec2(direction.x, direction.y) / abs(direction.z); }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness); }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif",
24725 defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",
24726 displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",
24727 emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",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.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\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.a );\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.a );\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.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, 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.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.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 = cLogLuvM * value.rgb;\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 = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",
24728 envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, 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_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec2 sampleUV = equirectUv( reflectVec );\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\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\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",
24729 envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",
24730 envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\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\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 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 roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, 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\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV = equirectUv( reflectVec );\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",
24731 envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\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",
24732 fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\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",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",
24733 gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",
24734 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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",
24735 lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\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};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\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};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\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};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\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",
24736 lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\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_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",
24737 lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",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\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\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)",
24738 lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",
24739 lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#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#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\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 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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\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}",
24740 lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",
24741 lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * 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( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",
24742 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, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",
24743 logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",
24744 map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",
24745 map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",
24746 morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",
24747 morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",
24748 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\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",
24749 normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",
24750 normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",
24751 clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",
24752 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}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\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}",
24753 premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef 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",
24754 roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\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( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), 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( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), 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 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\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 ) || defined( SHADOWMAP_TYPE_VSM )\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",
24755 shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",
24756 shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",
24757 shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",
24758 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 highp 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",
24759 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",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\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",
24760 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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#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}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",
24761 uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\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\tuniform mat3 uv2Transform;\n#endif",
24762 uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",
24763 background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",
24764 cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\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>\nvarying vec2 vHighPrecisionZW;\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\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",
24765 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>\nvarying vec2 vHighPrecisionZW;\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\tvHighPrecisionZW = gl_Position.zw;\n}",
24766 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}",
24767 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}",
24768 equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",
24769 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 <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",
24770 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 <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",
24771 meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\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 <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_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\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * 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 <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",
24772 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}",
24773 meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\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_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_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\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\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}",
24774 meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\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}",
24775 meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_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 <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\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}",
24776 meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_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 <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#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\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\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",
24777 meshtoon_frag:"#define TOON\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 <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_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_toon_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}",
24778 meshtoon_vert:"#define TOON\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}",
24779 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_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_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}",
24780 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}",
24781 meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\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_common_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 <clearcoat_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 <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_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\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\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}",
24782 meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\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\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\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}",
24783 normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\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>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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}",
24784 normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\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 <logdepthbuf_pars_vertex>\n#include <clipping_planes_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\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\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#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",
24785 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 <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",
24786 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\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\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}",
24787 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 <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\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}",
24788 sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_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 <alphamap_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}",
24789 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\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\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\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\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\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}"},
24790 gb={basic:{uniforms:wa([A.common,A.specularmap,A.envmap,A.aomap,A.lightmap,A.fog]),vertexShader:M.meshbasic_vert,fragmentShader:M.meshbasic_frag},lambert:{uniforms:wa([A.common,A.specularmap,A.envmap,A.aomap,A.lightmap,A.emissivemap,A.fog,A.lights,{emissive:{value:new D(0)}}]),vertexShader:M.meshlambert_vert,fragmentShader:M.meshlambert_frag},phong:{uniforms:wa([A.common,A.specularmap,A.envmap,A.aomap,A.lightmap,A.emissivemap,A.bumpmap,A.normalmap,A.displacementmap,A.fog,A.lights,{emissive:{value:new D(0)},
24791 specular:{value:new D(1118481)},shininess:{value:30}}]),vertexShader:M.meshphong_vert,fragmentShader:M.meshphong_frag},standard:{uniforms:wa([A.common,A.envmap,A.aomap,A.lightmap,A.emissivemap,A.bumpmap,A.normalmap,A.displacementmap,A.roughnessmap,A.metalnessmap,A.fog,A.lights,{emissive:{value:new D(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:M.meshphysical_vert,fragmentShader:M.meshphysical_frag},toon:{uniforms:wa([A.common,A.specularmap,A.aomap,A.lightmap,
24792 A.emissivemap,A.bumpmap,A.normalmap,A.displacementmap,A.gradientmap,A.fog,A.lights,{emissive:{value:new D(0)},specular:{value:new D(1118481)},shininess:{value:30}}]),vertexShader:M.meshtoon_vert,fragmentShader:M.meshtoon_frag},matcap:{uniforms:wa([A.common,A.bumpmap,A.normalmap,A.displacementmap,A.fog,{matcap:{value:null}}]),vertexShader:M.meshmatcap_vert,fragmentShader:M.meshmatcap_frag},points:{uniforms:wa([A.points,A.fog]),vertexShader:M.points_vert,fragmentShader:M.points_frag},dashed:{uniforms:wa([A.common,
24793 A.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:M.linedashed_vert,fragmentShader:M.linedashed_frag},depth:{uniforms:wa([A.common,A.displacementmap]),vertexShader:M.depth_vert,fragmentShader:M.depth_frag},normal:{uniforms:wa([A.common,A.bumpmap,A.normalmap,A.displacementmap,{opacity:{value:1}}]),vertexShader:M.normal_vert,fragmentShader:M.normal_frag},sprite:{uniforms:wa([A.sprite,A.fog]),vertexShader:M.sprite_vert,fragmentShader:M.sprite_frag},background:{uniforms:{uvTransform:{value:new ya},
24794 t2D:{value:null}},vertexShader:M.background_vert,fragmentShader:M.background_frag},cube:{uniforms:wa([A.envmap,{opacity:{value:1}}]),vertexShader:M.cube_vert,fragmentShader:M.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:M.equirect_vert,fragmentShader:M.equirect_frag},distanceRGBA:{uniforms:wa([A.common,A.displacementmap,{referencePosition:{value:new p},nearDistance:{value:1},farDistance:{value:1E3}}]),vertexShader:M.distanceRGBA_vert,fragmentShader:M.distanceRGBA_frag},shadow:{uniforms:wa([A.lights,
24795 A.fog,{color:{value:new D(0)},opacity:{value:1}}]),vertexShader:M.shadow_vert,fragmentShader:M.shadow_frag}};gb.physical={uniforms:wa([gb.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new v(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new D(0)},transparency:{value:0}}]),vertexShader:M.meshphysical_vert,fragmentShader:M.meshphysical_frag};qb.prototype=Object.create(W.prototype);qb.prototype.constructor=
24796 qb;qb.prototype.isCubeTexture=!0;Object.defineProperty(qb.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});Hc.prototype=Object.create(W.prototype);Hc.prototype.constructor=Hc;Hc.prototype.isDataTexture2DArray=!0;Ic.prototype=Object.create(W.prototype);Ic.prototype.constructor=Ic;Ic.prototype.isDataTexture3D=!0;var Bh=new W,Ej=new Hc,Gj=new Ic,Ch=new qb,vh=[],xh=[],Ah=new Float32Array(16),zh=new Float32Array(9),yh=new Float32Array(4);Dh.prototype.updateCache=function(a){var b=
24797 this.cache;a instanceof Float32Array&&b.length!==a.length&&(this.cache=new Float32Array(a.length));Ja(b,a)};Eh.prototype.setValue=function(a,b,c){for(var d=this.seq,e=0,f=d.length;e!==f;++e){var g=d[e];g.setValue(a,b[g.id],c)}};var eg=/([\w\d_]+)(\])?(\[|\.)?/g;Gb.prototype.setValue=function(a,b,c,d){b=this.map[b];void 0!==b&&b.setValue(a,c,d)};Gb.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};Gb.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],
24798 h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};Gb.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 lk=0,gg=/^[ \t]*#include +<([\w\d./]+)>/gm,Nh=/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Mh=/#pragma unroll_loop_start[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}[\s]+?#pragma unroll_loop_end/g,vk=0;Hb.prototype=Object.create(K.prototype);Hb.prototype.constructor=
24799 Hb;Hb.prototype.isMeshDepthMaterial=!0;Hb.prototype.copy=function(a){K.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};Ib.prototype=Object.create(K.prototype);Ib.prototype.constructor=
24800 Ib;Ib.prototype.isMeshDistanceMaterial=!0;Ib.prototype.copy=function(a){K.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;return this};Le.prototype=Object.assign(Object.create(P.prototype),
24801 {constructor:Le,isArrayCamera:!0});Kc.prototype=Object.assign(Object.create(y.prototype),{constructor:Kc,isGroup:!0});Object.assign(Me.prototype,{constructor:Me,getTargetRaySpace:function(){null===this._targetRay&&(this._targetRay=new Kc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1);return this._targetRay},getGripSpace:function(){null===this._grip&&(this._grip=new Kc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1);return this._grip},dispatchEvent:function(a){null!==this._targetRay&&
24802 this._targetRay.dispatchEvent(a);null!==this._grip&&this._grip.dispatchEvent(a);return this},disconnect:function(a){this.dispatchEvent({type:"disconnected",data:a});null!==this._targetRay&&(this._targetRay.visible=!1);null!==this._grip&&(this._grip.visible=!1);return this},update:function(a,b,c){var d=null,e=null,f=this._targetRay,g=this._grip;a&&(null!==f&&(d=b.getPose(a.targetRaySpace,c),null!==d&&(f.matrix.fromArray(d.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale))),null!==
24803 g&&a.gripSpace&&(e=b.getPose(a.gripSpace,c),null!==e&&(g.matrix.fromArray(e.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale))));null!==f&&(f.visible=null!==d);null!==g&&(g.visible=null!==e);return this}});Object.assign(Uh.prototype,ua.prototype);Object.assign(Ne.prototype,{isFogExp2:!0,clone:function(){return new Ne(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}});Object.assign(Oe.prototype,{isFog:!0,clone:function(){return new Oe(this.color,
24804 this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}});Object.defineProperty(rb.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(rb.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(a){this.usage=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.count=a.count;this.stride=a.stride;this.usage=a.usage;return this},copyAt:function(a,b,c){a*=this.stride;
24805 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}});var sc=new p;Object.defineProperties(Kd.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}});Object.assign(Kd.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(a){for(var b=
24806 0,c=this.data.count;b<c;b++)sc.x=this.getX(b),sc.y=this.getY(b),sc.z=this.getZ(b),sc.applyMatrix4(a),this.setXYZ(b,sc.x,sc.y,sc.z);return this},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*
24807 this.data.stride+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},
24808 setXYZW:function(a,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},clone:function(){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");for(var a=[],b=0;b<this.count;b++)for(var c=b*this.data.stride+this.offset,d=0;d<this.itemSize;d++)a.push(this.data.array[c+d]);return new G(new this.array.constructor(a),this.itemSize,this.normalized)},
24809 toJSON:function(){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");for(var a=[],b=0;b<this.count;b++)for(var c=b*this.data.stride+this.offset,d=0;d<this.itemSize;d++)a.push(this.data.array[c+d]);return{itemSize:this.itemSize,type:this.array.constructor.name,array:a,normalized:this.normalized}}});Kb.prototype=Object.create(K.prototype);Kb.prototype.constructor=Kb;Kb.prototype.isSpriteMaterial=!0;Kb.prototype.copy=function(a){K.prototype.copy.call(this,
24810 a);this.color.copy(a.color);this.map=a.map;this.alphaMap=a.alphaMap;this.rotation=a.rotation;this.sizeAttenuation=a.sizeAttenuation;return this};var Lc,xe=new p,vd=new p,wd=new p,Mc=new v,Md=new v,Wh=new N,If=new p,ye=new p,Jf=new p,Di=new v,gh=new v,Ei=new v;Ld.prototype=Object.assign(Object.create(y.prototype),{constructor:Ld,isSprite:!0,raycast:function(a,b){null===a.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');vd.setFromMatrixScale(this.matrixWorld);
24811 Wh.copy(a.camera.matrixWorld);this.modelViewMatrix.multiplyMatrices(a.camera.matrixWorldInverse,this.matrixWorld);wd.setFromMatrixPosition(this.modelViewMatrix);a.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&vd.multiplyScalar(-wd.z);var c=this.material.rotation;if(0!==c){var d=Math.cos(c);var e=Math.sin(c)}c=this.center;Pe(If.set(-.5,-.5,0),wd,c,vd,e,d);Pe(ye.set(.5,-.5,0),wd,c,vd,e,d);Pe(Jf.set(.5,.5,0),wd,c,vd,e,d);Di.set(0,0);gh.set(1,0);Ei.set(1,1);var f=a.ray.intersectTriangle(If,
24812 ye,Jf,!1,xe);if(null===f&&(Pe(ye.set(-.5,.5,0),wd,c,vd,e,d),gh.set(0,1),f=a.ray.intersectTriangle(If,Jf,ye,!1,xe),null===f))return;e=a.ray.origin.distanceTo(xe);e<a.near||e>a.far||b.push({distance:e,point:xe.clone(),uv:pa.getUV(xe,If,ye,Jf,Di,gh,Ei,new v),face:null,object:this})},clone:function(){return(new this.constructor(this.material)).copy(this)},copy:function(a){y.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}});var Kf=new p,Fi=new p;Nd.prototype=Object.assign(Object.create(y.prototype),
24813 {constructor:Nd,isLOD:!0,copy:function(a){y.prototype.copy.call(this,a,!1);for(var b=a.levels,c=0,d=b.length;c<d;c++){var e=b[c];this.addLevel(e.object.clone(),e.distance)}this.autoUpdate=a.autoUpdate;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);return this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(a){var b=this.levels;if(0<
24814 b.length){for(var c=1,d=b.length;c<d&&!(a<b[c].distance);c++);return b[c-1].object}return null},raycast:function(a,b){if(0<this.levels.length){Kf.setFromMatrixPosition(this.matrixWorld);var c=a.ray.origin.distanceTo(Kf);this.getObjectForDistance(c).raycast(a,b)}},update:function(a){var b=this.levels;if(1<b.length){Kf.setFromMatrixPosition(a.matrixWorld);Fi.setFromMatrixPosition(this.matrixWorld);a=Kf.distanceTo(Fi)/a.zoom;b[0].object.visible=!0;for(var c=1,d=b.length;c<d;c++)if(a>=b[c].distance)b[c-
24815 1].object.visible=!1,b[c].object.visible=!0;else break;for(this._currentLevel=c-1;c<d;c++)b[c].object.visible=!1}},toJSON:function(a){a=y.prototype.toJSON.call(this,a);!1===this.autoUpdate&&(a.object.autoUpdate=!1);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}});Qe.prototype=Object.assign(Object.create(ea.prototype),{constructor:Qe,isSkinnedMesh:!0,bind:function(a,b){this.skeleton=a;void 0===b&&
24816 (this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),b=this.matrixWorld);this.bindMatrix.copy(b);this.bindMatrixInverse.getInverse(b)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){for(var a=new R,b=this.geometry.attributes.skinWeight,c=0,d=b.count;c<d;c++){a.x=b.getX(c);a.y=b.getY(c);a.z=b.getZ(c);a.w=b.getW(c);var e=1/a.manhattanLength();Infinity!==e?a.multiplyScalar(e):a.set(1,0,0,0);b.setXYZW(c,a.x,a.y,a.z,a.w)}},updateMatrixWorld:function(a){ea.prototype.updateMatrixWorld.call(this,
24817 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,this.material)).copy(this)},boneTransform:function(){var a=new p,b=new R,c=new R,d=new p,e=new N;return function(f,g){var h=this.skeleton,l=this.geometry;b.fromBufferAttribute(l.attributes.skinIndex,f);c.fromBufferAttribute(l.attributes.skinWeight,
24818 f);a.fromBufferAttribute(l.attributes.position,f).applyMatrix4(this.bindMatrix);g.set(0,0,0);for(f=0;4>f;f++)if(l=c.getComponent(f),0!==l){var m=b.getComponent(f);e.multiplyMatrices(h.bones[m].matrixWorld,h.boneInverses[m]);g.addScaledVector(d.copy(a).applyMatrix4(e),l)}return g.applyMatrix4(this.bindMatrixInverse)}}()});var Gi=new N,Qk=new N;Object.assign(Re.prototype,{calculateInverses:function(){this.boneInverses=[];for(var a=0,b=this.bones.length;a<b;a++){var c=new N;this.bones[a]&&c.getInverse(this.bones[a].matrixWorld);
24819 this.boneInverses.push(c)}},pose:function(){var a,b;var c=0;for(b=this.bones.length;c<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(){for(var a=this.bones,b=this.boneInverses,c=this.boneMatrices,d=this.boneTexture,e=0,f=
24820 a.length;e<f;e++)Gi.multiplyMatrices(a[e]?a[e].matrixWorld:Qk,b[e]),Gi.toArray(c,16*e);void 0!==d&&(d.needsUpdate=!0)},clone:function(){return new Re(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}},dispose:function(){this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=void 0)}});kg.prototype=Object.assign(Object.create(y.prototype),{constructor:kg,isBone:!0});var Hi=new N,Ii=new N,Lf=[],ze=new ea;
24821 Se.prototype=Object.assign(Object.create(ea.prototype),{constructor:Se,isInstancedMesh:!0,getMatrixAt:function(a,b){b.fromArray(this.instanceMatrix.array,16*a)},raycast:function(a,b){var c=this.matrixWorld,d=this.count;ze.geometry=this.geometry;ze.material=this.material;if(void 0!==ze.material)for(var e=0;e<d;e++){this.getMatrixAt(e,Hi);Ii.multiplyMatrices(c,Hi);ze.matrixWorld=Ii;ze.raycast(a,Lf);for(var f=0,g=Lf.length;f<g;f++){var h=Lf[f];h.instanceId=e;h.object=this;b.push(h)}Lf.length=0}},setMatrixAt:function(a,
24822 b){b.toArray(this.instanceMatrix.array,16*a)},updateMorphTargets:function(){}});da.prototype=Object.create(K.prototype);da.prototype.constructor=da;da.prototype.isLineBasicMaterial=!0;da.prototype.copy=function(a){K.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.linecap=a.linecap;this.linejoin=a.linejoin;this.morphTargets=a.morphTargets;return this};var Ji=new p,Ki=new p,Li=new N,Mf=new Wb,Ae=new eb;La.prototype=Object.assign(Object.create(y.prototype),{constructor:La,
24823 isLine:!0,computeLineDistances:function(){var a=this.geometry;if(a.isBufferGeometry)if(null===a.index){for(var b=a.attributes.position,c=[0],d=1,e=b.count;d<e;d++)Ji.fromBufferAttribute(b,d-1),Ki.fromBufferAttribute(b,d),c[d]=c[d-1],c[d]+=Ji.distanceTo(Ki);a.setAttribute("lineDistance",new B(c,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(a.isGeometry)for(b=a.vertices,c=a.lineDistances,c[0]=0,d=1,e=b.length;d<e;d++)c[d]=
24824 c[d-1],c[d]+=b[d-1].distanceTo(b[d]);return this},raycast:function(a,b){var c=this.geometry,d=this.matrixWorld,e=a.params.Line.threshold;null===c.boundingSphere&&c.computeBoundingSphere();Ae.copy(c.boundingSphere);Ae.applyMatrix4(d);Ae.radius+=e;if(!1!==a.ray.intersectsSphere(Ae)){Li.getInverse(d);Mf.copy(a.ray).applyMatrix4(Li);d=e/((this.scale.x+this.scale.y+this.scale.z)/3);d*=d;var f=new p,g=new p;e=new p;var h=new p,l=this&&this.isLineSegments?2:1;if(c.isBufferGeometry){var m=c.index,k=c.attributes.position.array;
24825 if(null!==m){m=m.array;c=0;for(var n=m.length-1;c<n;c+=l){var t=m[c+1];f.fromArray(k,3*m[c]);g.fromArray(k,3*t);t=Mf.distanceSqToSegment(f,g,h,e);t>d||(h.applyMatrix4(this.matrixWorld),t=a.ray.origin.distanceTo(h),t<a.near||t>a.far||b.push({distance:t,point:e.clone().applyMatrix4(this.matrixWorld),index:c,face:null,faceIndex:null,object:this}))}}else for(c=0,n=k.length/3-1;c<n;c+=l)f.fromArray(k,3*c),g.fromArray(k,3*c+3),t=Mf.distanceSqToSegment(f,g,h,e),t>d||(h.applyMatrix4(this.matrixWorld),t=a.ray.origin.distanceTo(h),
24826 t<a.near||t>a.far||b.push({distance:t,point:e.clone().applyMatrix4(this.matrixWorld),index:c,face:null,faceIndex:null,object:this}))}else if(c.isGeometry)for(f=c.vertices,g=f.length,c=0;c<g-1;c+=l)t=Mf.distanceSqToSegment(f[c],f[c+1],h,e),t>d||(h.applyMatrix4(this.matrixWorld),t=a.ray.origin.distanceTo(h),t<a.near||t>a.far||b.push({distance:t,point:e.clone().applyMatrix4(this.matrixWorld),index:c,face:null,faceIndex:null,object:this}))}},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=
24827 a.morphAttributes;var b=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 a=a.morphTargets,void 0!==a&&0<a.length&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});
24828 var Nf=new p,Of=new p;ma.prototype=Object.assign(Object.create(La.prototype),{constructor:ma,isLineSegments:!0,computeLineDistances:function(){var a=this.geometry;if(a.isBufferGeometry)if(null===a.index){for(var b=a.attributes.position,c=[],d=0,e=b.count;d<e;d+=2)Nf.fromBufferAttribute(b,d),Of.fromBufferAttribute(b,d+1),c[d]=0===d?0:c[d-1],c[d+1]=c[d]+Nf.distanceTo(Of);a.setAttribute("lineDistance",new B(c,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
24829 else if(a.isGeometry)for(b=a.vertices,c=a.lineDistances,d=0,e=b.length;d<e;d+=2)Nf.copy(b[d]),Of.copy(b[d+1]),c[d]=0===d?0:c[d-1],c[d+1]=c[d]+Nf.distanceTo(Of);return this}});Te.prototype=Object.assign(Object.create(La.prototype),{constructor:Te,isLineLoop:!0});Xa.prototype=Object.create(K.prototype);Xa.prototype.constructor=Xa;Xa.prototype.isPointsMaterial=!0;Xa.prototype.copy=function(a){K.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.alphaMap=a.alphaMap;this.size=a.size;
24830 this.sizeAttenuation=a.sizeAttenuation;this.morphTargets=a.morphTargets;return this};var Mi=new N,mg=new Wb,Be=new eb,Pf=new p;Nc.prototype=Object.assign(Object.create(y.prototype),{constructor:Nc,isPoints:!0,raycast:function(a,b){var c=this.geometry,d=this.matrixWorld,e=a.params.Points.threshold;null===c.boundingSphere&&c.computeBoundingSphere();Be.copy(c.boundingSphere);Be.applyMatrix4(d);Be.radius+=e;if(!1!==a.ray.intersectsSphere(Be))if(Mi.getInverse(d),mg.copy(a.ray).applyMatrix4(Mi),e/=(this.scale.x+
24831 this.scale.y+this.scale.z)/3,e*=e,c.isBufferGeometry){var f=c.index;c=c.attributes.position.array;if(null!==f){var g=f.array;f=0;for(var h=g.length;f<h;f++){var l=g[f];Pf.fromArray(c,3*l);lg(Pf,l,e,d,a,b,this)}}else for(f=0,g=c.length/3;f<g;f++)Pf.fromArray(c,3*f),lg(Pf,f,e,d,a,b,this)}else for(c=c.vertices,f=0,g=c.length;f<g;f++)lg(c[f],f,e,d,a,b,this)},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=a.morphAttributes;var b=Object.keys(a);if(0<b.length){var c=a[b[0]];if(void 0!==
24832 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 a=a.morphTargets,void 0!==a&&0<a.length&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});ng.prototype=Object.assign(Object.create(W.prototype),{constructor:ng,
24833 isVideoTexture:!0,update:function(){var a=this.image;a.readyState>=a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Oc.prototype=Object.create(W.prototype);Oc.prototype.constructor=Oc;Oc.prototype.isCompressedTexture=!0;Od.prototype=Object.create(W.prototype);Od.prototype.constructor=Od;Od.prototype.isCanvasTexture=!0;Pd.prototype=Object.create(W.prototype);Pd.prototype.constructor=Pd;Pd.prototype.isDepthTexture=!0;Pc.prototype=Object.create(F.prototype);Pc.prototype.constructor=Pc;Qd.prototype=Object.create(L.prototype);
24834 Qd.prototype.constructor=Qd;Qc.prototype=Object.create(F.prototype);Qc.prototype.constructor=Qc;Rd.prototype=Object.create(L.prototype);Rd.prototype.constructor=Rd;Ga.prototype=Object.create(F.prototype);Ga.prototype.constructor=Ga;Sd.prototype=Object.create(L.prototype);Sd.prototype.constructor=Sd;Rc.prototype=Object.create(Ga.prototype);Rc.prototype.constructor=Rc;Td.prototype=Object.create(L.prototype);Td.prototype.constructor=Td;bc.prototype=Object.create(Ga.prototype);bc.prototype.constructor=
24835 bc;Ud.prototype=Object.create(L.prototype);Ud.prototype.constructor=Ud;Sc.prototype=Object.create(Ga.prototype);Sc.prototype.constructor=Sc;Vd.prototype=Object.create(L.prototype);Vd.prototype.constructor=Vd;Tc.prototype=Object.create(Ga.prototype);Tc.prototype.constructor=Tc;Wd.prototype=Object.create(L.prototype);Wd.prototype.constructor=Wd;cc.prototype=Object.create(F.prototype);cc.prototype.constructor=cc;cc.prototype.toJSON=function(){var a=F.prototype.toJSON.call(this);a.path=this.parameters.path.toJSON();
24836 return a};Xd.prototype=Object.create(L.prototype);Xd.prototype.constructor=Xd;Uc.prototype=Object.create(F.prototype);Uc.prototype.constructor=Uc;Yd.prototype=Object.create(L.prototype);Yd.prototype.constructor=Yd;Vc.prototype=Object.create(F.prototype);Vc.prototype.constructor=Vc;var Rk={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=Xh(a,0,e,c,!0),g=[];if(!f||f.next===f.prev)return g;var h;if(d){var l=c;d=[];var m;var k=0;for(m=b.length;k<m;k++){var n=b[k]*l;var p=k<
24837 m-1?b[k+1]*l:a.length;n=Xh(a,n,p,l,!1);n===n.next&&(n.steiner=!0);d.push(Dk(n))}d.sort(Bk);for(k=0;k<d.length;k++){l=d[k];b=f;if(b=Ck(l,b))l=$h(b,l),Lb(b,b.next),Lb(l,l.next);f=Lb(f,f.next)}}if(a.length>80*c){var r=h=a[0];var q=d=a[1];for(l=c;l<e;l+=c)k=a[l],b=a[l+1],k<r&&(r=k),b<q&&(q=b),k>h&&(h=k),b>d&&(d=b);h=Math.max(h-r,d-q);h=0!==h?1/h:0}$d(f,g,c,r,q,h);return g}},sb={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-a[e].x*a[d].y;return.5*c},isClockWise:function(a){return 0>
24838 sb.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];ai(a);bi(c,a);var f=a.length;b.forEach(ai);for(a=0;a<b.length;a++)d.push(f),f+=b[a].length,bi(c,b[a]);b=Rk.triangulate(c,d);for(a=0;a<b.length;a+=3)e.push(b.slice(a,a+3));return e}};dc.prototype=Object.create(L.prototype);dc.prototype.constructor=dc;dc.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);return ci(this.parameters.shapes,this.parameters.options,a)};hb.prototype=Object.create(F.prototype);hb.prototype.constructor=
24839 hb;hb.prototype.toJSON=function(){var a=F.prototype.toJSON.call(this);return ci(this.parameters.shapes,this.parameters.options,a)};var Ek={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 v(b[3*c],b[3*c+1]),new v(a,d),new v(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],l=b[3*d+1];d=b[3*d+2];var k=b[3*e],p=b[3*e+1];e=b[3*e+2];var n=b[3*f],t=b[3*f+1];b=b[3*f+2];return.01>Math.abs(g-l)?[new v(a,1-c),new v(h,1-d),
24840 new v(k,1-e),new v(n,1-b)]:[new v(g,1-c),new v(l,1-d),new v(p,1-e),new v(t,1-b)]}};be.prototype=Object.create(L.prototype);be.prototype.constructor=be;Xc.prototype=Object.create(hb.prototype);Xc.prototype.constructor=Xc;ce.prototype=Object.create(L.prototype);ce.prototype.constructor=ce;ec.prototype=Object.create(F.prototype);ec.prototype.constructor=ec;de.prototype=Object.create(L.prototype);de.prototype.constructor=de;Yc.prototype=Object.create(F.prototype);Yc.prototype.constructor=Yc;ee.prototype=
24841 Object.create(L.prototype);ee.prototype.constructor=ee;Zc.prototype=Object.create(F.prototype);Zc.prototype.constructor=Zc;fc.prototype=Object.create(L.prototype);fc.prototype.constructor=fc;fc.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);return di(this.parameters.shapes,a)};gc.prototype=Object.create(F.prototype);gc.prototype.constructor=gc;gc.prototype.toJSON=function(){var a=F.prototype.toJSON.call(this);return di(this.parameters.shapes,a)};$c.prototype=Object.create(F.prototype);
24842 $c.prototype.constructor=$c;hc.prototype=Object.create(L.prototype);hc.prototype.constructor=hc;tb.prototype=Object.create(F.prototype);tb.prototype.constructor=tb;fe.prototype=Object.create(hc.prototype);fe.prototype.constructor=fe;ge.prototype=Object.create(tb.prototype);ge.prototype.constructor=ge;he.prototype=Object.create(L.prototype);he.prototype.constructor=he;ad.prototype=Object.create(F.prototype);ad.prototype.constructor=ad;var ra=Object.freeze({__proto__:null,WireframeGeometry:Pc,ParametricGeometry:Qd,
24843 ParametricBufferGeometry:Qc,TetrahedronGeometry:Sd,TetrahedronBufferGeometry:Rc,OctahedronGeometry:Td,OctahedronBufferGeometry:bc,IcosahedronGeometry:Ud,IcosahedronBufferGeometry:Sc,DodecahedronGeometry:Vd,DodecahedronBufferGeometry:Tc,PolyhedronGeometry:Rd,PolyhedronBufferGeometry:Ga,TubeGeometry:Wd,TubeBufferGeometry:cc,TorusKnotGeometry:Xd,TorusKnotBufferGeometry:Uc,TorusGeometry:Yd,TorusBufferGeometry:Vc,TextGeometry:be,TextBufferGeometry:Xc,SphereGeometry:ce,SphereBufferGeometry:ec,RingGeometry:de,
24844 RingBufferGeometry:Yc,PlaneGeometry:Fd,PlaneBufferGeometry:ac,LatheGeometry:ee,LatheBufferGeometry:Zc,ShapeGeometry:fc,ShapeBufferGeometry:gc,ExtrudeGeometry:dc,ExtrudeBufferGeometry:hb,EdgesGeometry:$c,ConeGeometry:fe,ConeBufferGeometry:ge,CylinderGeometry:hc,CylinderBufferGeometry:tb,CircleGeometry:he,CircleBufferGeometry:ad,BoxGeometry:fh,BoxBufferGeometry:Gd});ic.prototype=Object.create(K.prototype);ic.prototype.constructor=ic;ic.prototype.isShadowMaterial=!0;ic.prototype.copy=function(a){K.prototype.copy.call(this,
24845 a);this.color.copy(a.color);return this};ub.prototype=Object.create(Ca.prototype);ub.prototype.constructor=ub;ub.prototype.isRawShaderMaterial=!0;ib.prototype=Object.create(K.prototype);ib.prototype.constructor=ib;ib.prototype.isMeshStandardMaterial=!0;ib.prototype.copy=function(a){K.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=a.lightMapIntensity;
24846 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=a.metalnessMap;this.alphaMap=
24847 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;this.vertexTangents=a.vertexTangents;return this};jc.prototype=Object.create(ib.prototype);jc.prototype.constructor=jc;jc.prototype.isMeshPhysicalMaterial=
24848 !0;jc.prototype.copy=function(a){ib.prototype.copy.call(this,a);this.defines={STANDARD:"",PHYSICAL:""};this.clearcoat=a.clearcoat;this.clearcoatMap=a.clearcoatMap;this.clearcoatRoughness=a.clearcoatRoughness;this.clearcoatRoughnessMap=a.clearcoatRoughnessMap;this.clearcoatNormalMap=a.clearcoatNormalMap;this.clearcoatNormalScale.copy(a.clearcoatNormalScale);this.reflectivity=a.reflectivity;this.sheen=a.sheen?(this.sheen||new D).copy(a.sheen):null;this.transparency=a.transparency;return this};Mb.prototype=
24849 Object.create(K.prototype);Mb.prototype.constructor=Mb;Mb.prototype.isMeshPhongMaterial=!0;Mb.prototype.copy=function(a){K.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=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;
24850 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;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=
24851 a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};kc.prototype=Object.create(K.prototype);kc.prototype.constructor=kc;kc.prototype.isMeshToonMaterial=!0;kc.prototype.copy=function(a){K.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.gradientMap=a.gradientMap;this.lightMap=a.lightMap;this.lightMapIntensity=
24852 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;
24853 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};lc.prototype=Object.create(K.prototype);lc.prototype.constructor=lc;lc.prototype.isMeshNormalMaterial=!0;lc.prototype.copy=function(a){K.prototype.copy.call(this,a);this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;
24854 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;this.wireframeLinewidth=a.wireframeLinewidth;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};mc.prototype=Object.create(K.prototype);mc.prototype.constructor=mc;mc.prototype.isMeshLambertMaterial=!0;mc.prototype.copy=function(a){K.prototype.copy.call(this,
24855 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);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;
24856 this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};nc.prototype=Object.create(K.prototype);nc.prototype.constructor=nc;nc.prototype.isMeshMatcapMaterial=!0;nc.prototype.copy=function(a){K.prototype.copy.call(this,a);this.defines={MATCAP:""};this.color.copy(a.color);this.matcap=a.matcap;this.map=a.map;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=
24857 a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.alphaMap=a.alphaMap;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};oc.prototype=Object.create(da.prototype);oc.prototype.constructor=oc;oc.prototype.isLineDashedMaterial=!0;oc.prototype.copy=function(a){da.prototype.copy.call(this,a);
24858 this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var Sk=Object.freeze({__proto__:null,ShadowMaterial:ic,SpriteMaterial:Kb,RawShaderMaterial:ub,ShaderMaterial:Ca,PointsMaterial:Xa,MeshPhysicalMaterial:jc,MeshStandardMaterial:ib,MeshPhongMaterial:Mb,MeshToonMaterial:kc,MeshNormalMaterial:lc,MeshLambertMaterial:mc,MeshDepthMaterial:Hb,MeshDistanceMaterial:Ib,MeshBasicMaterial:Pa,MeshMatcapMaterial:nc,LineDashedMaterial:oc,LineBasicMaterial:da,Material:K}),ka={arraySlice:function(a,
24859 b,c){return ka.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=
24860 new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,l=0;l!==b;++l)e[g++]=a[h+l];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++];
24861 while(void 0!==f)}}},subclip:function(a,b,c,d,e){e=e||30;a=a.clone();a.name=b;var f=[];for(b=0;b<a.tracks.length;++b){for(var g=a.tracks[b],h=g.getValueSize(),l=[],k=[],p=0;p<g.times.length;++p){var n=g.times[p]*e;if(!(n<c||n>=d))for(l.push(g.times[p]),n=0;n<h;++n)k.push(g.values[p*h+n])}0!==l.length&&(g.times=ka.convertArray(l,g.times.constructor),g.values=ka.convertArray(k,g.values.constructor),f.push(g))}a.tracks=f;c=Infinity;for(b=0;b<a.tracks.length;++b)c>a.tracks[b].times[0]&&(c=a.tracks[b].times[0]);
24862 for(b=0;b<a.tracks.length;++b)a.tracks[b].shift(-1*c);a.resetDuration();return a},makeClipAdditive:function(a,b,c,d){void 0===b&&(b=0);void 0===c&&(c=a);if(void 0===d||0>=d)d=30;var e=a.tracks.length;b/=d;for(d=0;d<e;++d){var f=c.tracks[d],g=f.ValueTypeName;if("bool"!==g&&"string"!==g){var h=a.tracks.find(function(a){return a.name===f.name&&a.ValueTypeName===g});if(void 0!==h){var l=f.getValueSize(),k=f.times.length-1;b<=f.times[0]?k=ka.arraySlice(f.values,0,f.valueSize):b>=f.times[k]?k=ka.arraySlice(f.values,
24863 k*l):(k=f.createInterpolant(),k.evaluate(b),k=k.resultBuffer);"quaternion"===g&&(new va(k[0],k[1],k[2],k[3])).normalize().conjugate().toArray(k);for(var p=h.times.length,n=0;n<p;++n){var t=n*l;if("quaternion"===g)va.multiplyQuaternionsFlat(h.values,t,k,0,h.values,t);else for(var r=0;r<l;++r)h.values[t+r]-=k[r]}}}}a.blendMode=2501;return a}};Object.assign(Ma.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===
24864 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=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-
24865 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]=c[a+e];return b},interpolate_:function(){throw Error("call to abstract method");},intervalChanged_:function(){}});Object.assign(Ma.prototype,{beforeStart_:Ma.prototype.copySampleValue_,
24866 afterEnd_:Ma.prototype.copySampleValue_});Xe.prototype=Object.assign(Object.create(Ma.prototype),{constructor:Xe,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=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];
24867 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,l=this._offsetPrev,k=this._offsetNext,p=this._weightPrev,n=this._weightNext,t=(c-b)/(d-b);c=t*t;d=c*t;b=-p*d+2*p*c-p*t;p=(1+p)*d+(-1.5-2*p)*c+(-.5+p)*t+1;t=(-1-n)*d+(1.5+n)*c+.5*t;n=n*d-n*c;for(c=0;c!==g;++c)e[c]=b*f[l+c]+p*f[h+c]+t*f[a+c]+n*f[k+c];
24868 return e}});ie.prototype=Object.assign(Object.create(Ma.prototype),{constructor:ie,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}});Ye.prototype=Object.assign(Object.create(Ma.prototype),{constructor:Ye,interpolate_:function(a){return this.copySampleValue_(a-1)}});Object.assign(ta,{toJSON:function(a){var b=a.constructor;if(void 0!==b.toJSON)b=b.toJSON(a);else{b={name:a.name,
24869 times:ka.convertArray(a.times,Array),values:ka.convertArray(a.values,Array)};var c=a.getInterpolation();c!==a.DefaultInterpolation&&(b.interpolation=c)}b.type=a.ValueTypeName;return b}});Object.assign(ta.prototype,{constructor:ta,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:2301,InterpolantFactoryMethodDiscrete:function(a){return new Ye(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodLinear:function(a){return new ie(this.times,this.values,this.getValueSize(),
24870 a)},InterpolantFactoryMethodSmooth:function(a){return new Xe(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+" keyframe track named "+this.name;if(void 0===this.createInterpolant)if(a!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);
24871 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/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!==
24872 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=ka.arraySlice(c,e,f),this.values=ka.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=!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;
24873 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=g}if(void 0!==b&&ka.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.",
24874 this,f,d);a=!1;break}return a},optimize:function(){for(var a=ka.arraySlice(this.times),b=ka.arraySlice(this.values),c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;g<f;++g){var h=!1,l=a[g];if(l!==a[g+1]&&(1!==g||l!==l[0]))if(d)h=!0;else{var k=g*c,p=k-c,n=k+c;for(l=0;l!==c;++l){var t=b[k+l];if(t!==b[p+l]||t!==b[n+l]){h=!0;break}}}if(h){if(g!==e)for(a[e]=a[g],h=g*c,k=e*c,l=0;l!==c;++l)b[k+l]=b[h+l];++e}}if(0<f){a[e]=a[f];h=f*c;k=e*c;for(l=0;l!==c;++l)b[k+l]=b[h+l];++e}e!==
24875 a.length?(this.times=ka.arraySlice(a,0,e),this.values=ka.arraySlice(b,0,e*c)):(this.times=a,this.values=b);return this},clone:function(){var a=ka.arraySlice(this.times,0),b=ka.arraySlice(this.values,0);a=new this.constructor(this.name,a,b);a.createInterpolant=this.createInterpolant;return a}});Ze.prototype=Object.assign(Object.create(ta.prototype),{constructor:Ze,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});
24876 $e.prototype=Object.assign(Object.create(ta.prototype),{constructor:$e,ValueTypeName:"color"});bd.prototype=Object.assign(Object.create(ta.prototype),{constructor:bd,ValueTypeName:"number"});af.prototype=Object.assign(Object.create(Ma.prototype),{constructor:af,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)va.slerpFlat(e,0,f,a-g,f,a,b);return e}});je.prototype=Object.assign(Object.create(ta.prototype),{constructor:je,
24877 ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(a){return new af(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:void 0});bf.prototype=Object.assign(Object.create(ta.prototype),{constructor:bf,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});cd.prototype=Object.assign(Object.create(ta.prototype),{constructor:cd,ValueTypeName:"vector"});
24878 Object.assign(Sa,{parse:function(a){for(var b=[],c=a.tracks,d=1/(a.fps||1),e=0,f=c.length;e!==f;++e)b.push(Gk(c[e]).scale(d));return new Sa(a.name,a.duration,b,a.blendMode)},toJSON:function(a){var b=[],c=a.tracks;a={name:a.name,duration:a.duration,tracks:b,uuid:a.uuid,blendMode:a.blendMode};for(var d=0,e=c.length;d!==e;++d)b.push(ta.toJSON(c[d]));return a},CreateFromMorphTargetSequence:function(a,b,c,d){for(var e=b.length,f=[],g=0;g<e;g++){var h=[],l=[];h.push((g+e-1)%e,g,(g+1)%e);l.push(0,1,0);var k=
24879 ka.getKeyframeOrder(h);h=ka.sortedArray(h,1,k);l=ka.sortedArray(l,1,k);d||0!==h[0]||(h.push(e),l.push(l[0]));f.push((new bd(".morphTargetInfluences["+b[g].name+"]",h,l)).scale(1/c))}return new Sa(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],l=h.name.match(e);
24880 if(l&&1<l.length){var k=l[1];(l=d[k])||(d[k]=l=[]);l.push(h)}}a=[];for(k in d)a.push(Sa.CreateFromMorphTargetSequence(k,d[k],b,c));return a},parseAnimation:function(a,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=[];ka.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,h=a.blendMode;a=a.hierarchy||[];for(var l=0;l<a.length;l++){var k=a[l].keys;
24881 if(k&&0!==k.length)if(k[0].morphTargets){f={};for(var p=0;p<k.length;p++)if(k[p].morphTargets)for(var n=0;n<k[p].morphTargets.length;n++)f[k[p].morphTargets[n]]=-1;for(var t in f){var r=[],q=[];for(n=0;n!==k[p].morphTargets.length;++n){var u=k[p];r.push(u.time);q.push(u.morphTarget===t?1:0)}d.push(new bd(".morphTargetInfluence["+t+"]",r,q))}f=f.length*(g||1)}else p=".bones["+b[l].name+"]",c(cd,p+".position",k,"pos",d),c(je,p+".quaternion",k,"rot",d),c(cd,p+".scale",k,"scl",d)}return 0===d.length?
24882 null:new Sa(e,f,d,h)}});Object.assign(Sa.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=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();
24883 return this},clone:function(){for(var a=[],b=0;b<this.tracks.length;b++)a.push(this.tracks[b].clone());return new Sa(this.name,this.duration,a,this.blendMode)}});var tc={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={}}},ei=new qg;Object.assign(V.prototype,{load:function(){},loadAsync:function(a,b){var c=this;return new Promise(function(d,e){c.load(a,
24884 d,b,e)})},parse:function(){},setCrossOrigin:function(a){this.crossOrigin=a;return this},setPath:function(a){this.path=a;return this},setResourcePath:function(a){this.resourcePath=a;return this},setRequestHeader:function(a){this.requestHeader=a;return this}});var db={};Ta.prototype=Object.assign(Object.create(V.prototype),{constructor:Ta,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=tc.get(a);if(void 0!==f)return e.manager.itemStart(a),
24885 setTimeout(function(){b&&b(f);e.manager.itemEnd(a)},0),f;if(void 0!==db[a])db[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=decodeURIComponent(g);h&&(g=atob(g));try{var l=(this.responseType||"").toLowerCase();switch(l){case "arraybuffer":case "blob":var k=new Uint8Array(g.length);for(h=0;h<g.length;h++)k[h]=g.charCodeAt(h);var p="blob"===l?new Blob([k.buffer],{type:c}):k.buffer;break;case "document":p=(new DOMParser).parseFromString(g,
24886 c);break;case "json":p=JSON.parse(g);break;default:p=g}setTimeout(function(){b&&b(p);e.manager.itemEnd(a)},0)}catch(t){setTimeout(function(){d&&d(t);e.manager.itemError(a);e.manager.itemEnd(a)},0)}}else{db[a]=[];db[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,d=db[a];delete db[a];if(200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received.");tc.add(a,
24887 c);for(var f=0,g=d.length;f<g;f++){var h=d[f];if(h.onLoad)h.onLoad(c)}}else{f=0;for(g=d.length;f<g;f++)if(h=d[f],h.onError)h.onError(b);e.manager.itemError(a)}e.manager.itemEnd(a)},!1);n.addEventListener("progress",function(b){for(var c=db[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=db[a];delete db[a];for(var d=0,f=c.length;d<f;d++){var g=c[d];if(g.onError)g.onError(b)}e.manager.itemError(a);e.manager.itemEnd(a)},!1);n.addEventListener("abort",
24888 function(b){var c=db[a];delete db[a];for(var d=0,f=c.length;d<f;d++){var g=c[d];if(g.onError)g.onError(b)}e.manager.itemError(a);e.manager.itemEnd(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}},setResponseType:function(a){this.responseType=
24889 a;return this},setWithCredentials:function(a){this.withCredentials=a;return this},setMimeType:function(a){this.mimeType=a;return this}});rg.prototype=Object.assign(Object.create(V.prototype),{constructor:rg,load:function(a,b,c,d){var e=this,f=new Ta(e.manager);f.setPath(e.path);f.load(a,function(c){try{b(e.parse(JSON.parse(c)))}catch(h){d?d(h):console.error(h),e.manager.itemError(a)}},c,d)},parse:function(a){for(var b=[],c=0;c<a.length;c++){var d=Sa.parse(a[c]);b.push(d)}return b}});sg.prototype=
24890 Object.assign(Object.create(V.prototype),{constructor:sg,load:function(a,b,c,d){function e(e){l.load(a[e],function(a){a=f.parse(a,!0);g[e]={width:a.width,height:a.height,format:a.format,mipmaps:a.mipmaps};k+=1;6===k&&(1===a.mipmapCount&&(h.minFilter=1006),h.format=a.format,h.needsUpdate=!0,b&&b(h))},c,d)}var f=this,g=[],h=new Oc;h.image=g;var l=new Ta(this.manager);l.setPath(this.path);l.setResponseType("arraybuffer");if(Array.isArray(a))for(var k=0,p=0,n=a.length;p<n;++p)e(p);else l.load(a,function(a){a=
24891 f.parse(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}});cf.prototype=Object.assign(Object.create(V.prototype),{constructor:cf,load:function(a,b,c,
24892 d){var e=this,f=new $b,g=new Ta(this.manager);g.setResponseType("arraybuffer");g.setPath(this.path);g.load(a,function(a){if(a=e.parse(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:1006,f.anisotropy=void 0!==a.anisotropy?a.anisotropy:1,void 0!==a.format&&(f.format=
24893 a.format),void 0!==a.type&&(f.type=a.type),void 0!==a.mipmaps&&(f.mipmaps=a.mipmaps,f.minFilter=1008),1===a.mipmapCount&&(f.minFilter=1006),f.needsUpdate=!0,b&&b(f,a)},c,d);return f}});dd.prototype=Object.assign(Object.create(V.prototype),{constructor:dd,load:function(a,b,c,d){function e(){l.removeEventListener("load",e,!1);l.removeEventListener("error",f,!1);tc.add(a,this);b&&b(this);g.manager.itemEnd(a)}function f(b){l.removeEventListener("load",e,!1);l.removeEventListener("error",f,!1);d&&d(b);
24894 g.manager.itemError(a);g.manager.itemEnd(a)}void 0!==this.path&&(a=this.path+a);a=this.manager.resolveURL(a);var g=this,h=tc.get(a);if(void 0!==h)return g.manager.itemStart(a),setTimeout(function(){b&&b(h);g.manager.itemEnd(a)},0),h;var l=document.createElementNS("http://www.w3.org/1999/xhtml","img");l.addEventListener("load",e,!1);l.addEventListener("error",f,!1);"data:"!==a.substr(0,5)&&void 0!==this.crossOrigin&&(l.crossOrigin=this.crossOrigin);g.manager.itemStart(a);l.src=a;return l}});df.prototype=
24895 Object.assign(Object.create(V.prototype),{constructor:df,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 qb,g=new dd(this.manager);g.setCrossOrigin(this.crossOrigin);g.setPath(this.path);var h=0;for(c=0;c<a.length;++c)e(c);return f}});ef.prototype=Object.assign(Object.create(V.prototype),{constructor:ef,load:function(a,b,c,d){var e=new W,f=new dd(this.manager);f.setCrossOrigin(this.crossOrigin);f.setPath(this.path);
24896 f.load(a,function(c){e.image=c;c=0<a.search(/\.jpe?g($|\?)/i)||0===a.search(/^data:image\/jpeg/);e.format=c?1022:1023;e.needsUpdate=!0;void 0!==b&&b(e)},c,d);return e}});Object.assign(H.prototype,{getPoint:function(){console.warn("THREE.Curve: .getPoint() not implemented.");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===
24897 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;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=
24898 !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,b){var c=a-1E-4;a+=1E-4;0>c&&(c=0);1<a&&(a=1);c=this.getPoint(c);a=this.getPoint(a);b=b||(c.isVector2?new v:new p);b.copy(a).sub(c).normalize();return b},getTangentAt:function(a,b){a=this.getUtoTmapping(a);
24899 return this.getTangent(a,b)},computeFrenetFrames:function(a,b){var c=new p,d=[],e=[],f=[],g=new p,h=new N,l;for(l=0;l<=a;l++){var k=l/a;d[l]=this.getTangentAt(k,new p);d[l].normalize()}e[0]=new p;f[0]=new p;l=Number.MAX_VALUE;k=Math.abs(d[0].x);var v=Math.abs(d[0].y),n=Math.abs(d[0].z);k<=l&&(l=k,c.set(1,0,0));v<=l&&(l=v,c.set(0,1,0));n<=l&&c.set(0,0,1);g.crossVectors(d[0],c).normalize();e[0].crossVectors(d[0],g);f[0].crossVectors(d[0],e[0]);for(l=1;l<=a;l++)e[l]=e[l-1].clone(),f[l]=f[l-1].clone(),
24900 g.crossVectors(d[l-1],d[l]),g.length()>Number.EPSILON&&(g.normalize(),c=Math.acos(O.clamp(d[l-1].dot(d[l]),-1,1)),e[l].applyMatrix4(h.makeRotationAxis(g,c))),f[l].crossVectors(d[l],e[l]);if(!0===b)for(c=Math.acos(O.clamp(e[0].dot(e[a]),-1,1)),c/=a,0<d[0].dot(g.crossVectors(e[0],e[a]))&&(c=-c),l=1;l<=a;l++)e[l].applyMatrix4(h.makeRotationAxis(d[l],c*l)),f[l].crossVectors(d[l],e[l]);return{tangents:d,normals:e,binormals:f}},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.arcLengthDivisions=
24901 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}});Na.prototype=Object.create(H.prototype);Na.prototype.constructor=Na;Na.prototype.isEllipseCurve=!0;Na.prototype.getPoint=function(a,b){b=b||new v;for(var c=2*Math.PI,d=this.aEndAngle-this.aStartAngle,e=Math.abs(d)<Number.EPSILON;0>
24902 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,f)};Na.prototype.copy=function(a){H.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;
24903 this.aEndAngle=a.aEndAngle;this.aClockwise=a.aClockwise;this.aRotation=a.aRotation;return this};Na.prototype.toJSON=function(){var a=H.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=this.aRotation;return a};Na.prototype.fromJSON=function(a){H.prototype.fromJSON.call(this,a);this.aX=a.aX;this.aY=a.aY;this.xRadius=a.xRadius;this.yRadius=a.yRadius;this.aStartAngle=
24904 a.aStartAngle;this.aEndAngle=a.aEndAngle;this.aClockwise=a.aClockwise;this.aRotation=a.aRotation;return this};ed.prototype=Object.create(Na.prototype);ed.prototype.constructor=ed;ed.prototype.isArcCurve=!0;var Qf=new p,hh=new tg,ih=new tg,jh=new tg;qa.prototype=Object.create(H.prototype);qa.prototype.constructor=qa;qa.prototype.isCatmullRomCurve3=!0;qa.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)/
24905 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 Qf.subVectors(c[0],c[1]).add(c[0]),f=Qf;var g=c[e%d];var h=c[(e+1)%d];this.closed||e+2<d?c=c[(e+2)%d]:(Qf.subVectors(c[d-1],c[d-2]).add(c[d-1]),c=Qf);if("centripetal"===this.curveType||"chordal"===this.curveType){var l="chordal"===this.curveType?.5:.25;d=Math.pow(f.distanceToSquared(g),l);e=Math.pow(g.distanceToSquared(h),l);l=Math.pow(h.distanceToSquared(c),l);1E-4>e&&(e=1);1E-4>d&&(d=e);1E-4>l&&(l=e);hh.initNonuniformCatmullRom(f.x,
24906 g.x,h.x,c.x,d,e,l);ih.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,l);jh.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,l)}else"catmullrom"===this.curveType&&(hh.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),ih.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),jh.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(hh.calc(a),ih.calc(a),jh.calc(a));return b};qa.prototype.copy=function(a){H.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());
24907 this.closed=a.closed;this.curveType=a.curveType;this.tension=a.tension;return this};qa.prototype.toJSON=function(){var a=H.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};qa.prototype.fromJSON=function(a){H.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=
24908 a.closed;this.curveType=a.curveType;this.tension=a.tension;return this};Ya.prototype=Object.create(H.prototype);Ya.prototype.constructor=Ya;Ya.prototype.isCubicBezierCurve=!0;Ya.prototype.getPoint=function(a,b){b=b||new v;var c=this.v0,d=this.v1,e=this.v2,f=this.v3;b.set(le(a,c.x,d.x,e.x,f.x),le(a,c.y,d.y,e.y,f.y));return b};Ya.prototype.copy=function(a){H.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};Ya.prototype.toJSON=function(){var a=
24909 H.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};Ya.prototype.fromJSON=function(a){H.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};jb.prototype=Object.create(H.prototype);jb.prototype.constructor=jb;jb.prototype.isCubicBezierCurve3=!0;jb.prototype.getPoint=function(a,b){b=b||new p;var c=this.v0,d=this.v1,e=this.v2,f=this.v3;
24910 b.set(le(a,c.x,d.x,e.x,f.x),le(a,c.y,d.y,e.y,f.y),le(a,c.z,d.z,e.z,f.z));return b};jb.prototype.copy=function(a){H.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};jb.prototype.toJSON=function(){var a=H.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};jb.prototype.fromJSON=function(a){H.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);
24911 this.v2.fromArray(a.v2);this.v3.fromArray(a.v3);return this};Ia.prototype=Object.create(H.prototype);Ia.prototype.constructor=Ia;Ia.prototype.isLineCurve=!0;Ia.prototype.getPoint=function(a,b){b=b||new v;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.getTangent=function(a,b){a=b||new v;return a=a.copy(this.v2).sub(this.v1).normalize()};Ia.prototype.copy=function(a){H.prototype.copy.call(this,
24912 a);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};Ia.prototype.toJSON=function(){var a=H.prototype.toJSON.call(this);a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};Ia.prototype.fromJSON=function(a){H.prototype.fromJSON.call(this,a);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Za.prototype=Object.create(H.prototype);Za.prototype.constructor=Za;Za.prototype.isLineCurve3=!0;Za.prototype.getPoint=function(a,b){b=b||new p;1===a?b.copy(this.v2):(b.copy(this.v2).sub(this.v1),
24913 b.multiplyScalar(a).add(this.v1));return b};Za.prototype.getPointAt=function(a,b){return this.getPoint(a,b)};Za.prototype.copy=function(a){H.prototype.copy.call(this,a);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};Za.prototype.toJSON=function(){var a=H.prototype.toJSON.call(this);a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};Za.prototype.fromJSON=function(a){H.prototype.fromJSON.call(this,a);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};$a.prototype=Object.create(H.prototype);
24914 $a.prototype.constructor=$a;$a.prototype.isQuadraticBezierCurve=!0;$a.prototype.getPoint=function(a,b){b=b||new v;var c=this.v0,d=this.v1,e=this.v2;b.set(ke(a,c.x,d.x,e.x),ke(a,c.y,d.y,e.y));return b};$a.prototype.copy=function(a){H.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};$a.prototype.toJSON=function(){var a=H.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};$a.prototype.fromJSON=function(a){H.prototype.fromJSON.call(this,
24915 a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};kb.prototype=Object.create(H.prototype);kb.prototype.constructor=kb;kb.prototype.isQuadraticBezierCurve3=!0;kb.prototype.getPoint=function(a,b){b=b||new p;var c=this.v0,d=this.v1,e=this.v2;b.set(ke(a,c.x,d.x,e.x),ke(a,c.y,d.y,e.y),ke(a,c.z,d.z,e.z));return b};kb.prototype.copy=function(a){H.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};kb.prototype.toJSON=function(){var a=
24916 H.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};kb.prototype.fromJSON=function(a){H.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};ab.prototype=Object.create(H.prototype);ab.prototype.constructor=ab;ab.prototype.isSplineCurve=!0;ab.prototype.getPoint=function(a,b){b=b||new v;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-
24917 2?c.length-1:a+1];c=c[a>c.length-3?c.length-1:a+2];b.set(fi(d,e.x,f.x,g.x,c.x),fi(d,e.y,f.y,g.y,c.y));return b};ab.prototype.copy=function(a){H.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};ab.prototype.toJSON=function(){var a=H.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};ab.prototype.fromJSON=function(a){H.prototype.fromJSON.call(this,
24918 a);this.points=[];for(var b=0,c=a.points.length;b<c;b++){var d=a.points[b];this.points.push((new v).fromArray(d))}return this};var kh=Object.freeze({__proto__:null,ArcCurve:ed,CatmullRomCurve3:qa,CubicBezierCurve:Ya,CubicBezierCurve3:jb,EllipseCurve:Na,LineCurve:Ia,LineCurve3:Za,QuadraticBezierCurve:$a,QuadraticBezierCurve3:kb,SplineCurve:ab});vb.prototype=Object.assign(Object.create(H.prototype),{constructor:vb,add:function(a){this.curves.push(a)},closePath:function(){var a=this.curves[0].getPoint(0),
24919 b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new Ia(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();return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&
24920 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=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?
24921 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){H.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},toJSON:function(){var a=H.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());
24922 return a},fromJSON:function(a){H.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 kh[d.type]).fromJSON(d))}return this}});bb.prototype=Object.assign(Object.create(vb.prototype),{constructor:bb,setFromPoints:function(a){this.moveTo(a[0].x,a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y);return this},moveTo:function(a,b){this.currentPoint.set(a,b);return this},lineTo:function(a,b){var c=
24923 new Ia(this.currentPoint.clone(),new v(a,b));this.curves.push(c);this.currentPoint.set(a,b);return this},quadraticCurveTo:function(a,b,c,d){a=new $a(this.currentPoint.clone(),new v(a,b),new v(c,d));this.curves.push(a);this.currentPoint.set(c,d);return this},bezierCurveTo:function(a,b,c,d,e,f){a=new Ya(this.currentPoint.clone(),new v(a,b),new v(c,d),new v(e,f));this.curves.push(a);this.currentPoint.set(e,f);return this},splineThru:function(a){var b=[this.currentPoint.clone()].concat(a);b=new ab(b);
24924 this.curves.push(b);this.currentPoint.copy(a[a.length-1]);return this},arc:function(a,b,c,d,e,f){this.absarc(a+this.currentPoint.x,b+this.currentPoint.y,c,d,e,f);return this},absarc:function(a,b,c,d,e,f){this.absellipse(a,b,c,c,d,e,f);return this},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);return this},absellipse:function(a,b,c,d,e,f,g,h){a=new Na(a,b,c,d,e,f,g,h);0<this.curves.length&&(b=a.getPoint(0),b.equals(this.currentPoint)||this.lineTo(b.x,
24925 b.y));this.curves.push(a);a=a.getPoint(1);this.currentPoint.copy(a);return this},copy:function(a){vb.prototype.copy.call(this,a);this.currentPoint.copy(a.currentPoint);return this},toJSON:function(){var a=vb.prototype.toJSON.call(this);a.currentPoint=this.currentPoint.toArray();return a},fromJSON:function(a){vb.prototype.fromJSON.call(this,a);this.currentPoint.fromArray(a.currentPoint);return this}});Nb.prototype=Object.assign(Object.create(bb.prototype),{constructor:Nb,getPointsHoles:function(a){for(var b=
24926 [],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){bb.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=bb.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());return a},fromJSON:function(a){bb.prototype.fromJSON.call(this,
24927 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 bb).fromJSON(d))}return this}});S.prototype=Object.assign(Object.create(y.prototype),{constructor:S,isLight:!0,copy:function(a){y.prototype.copy.call(this,a);this.color.copy(a.color);this.intensity=a.intensity;return this},toJSON:function(a){a=y.prototype.toJSON.call(this,a);a.object.color=this.color.getHex();a.object.intensity=this.intensity;void 0!==this.groundColor&&(a.object.groundColor=
24928 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}});ff.prototype=Object.assign(Object.create(S.prototype),{constructor:ff,isHemisphereLight:!0,copy:function(a){S.prototype.copy.call(this,a);this.groundColor.copy(a.groundColor);return this}});
24929 Object.assign(lb.prototype,{_projScreenMatrix:new N,_lightPositionWorld:new p,_lookTarget:new p,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(a){var b=this.camera,c=this.matrix,d=this._projScreenMatrix,e=this._lookTarget,f=this._lightPositionWorld;f.setFromMatrixPosition(a.matrixWorld);b.position.copy(f);e.setFromMatrixPosition(a.target.matrixWorld);b.lookAt(e);b.updateMatrixWorld();d.multiplyMatrices(b.projectionMatrix,
24930 b.matrixWorldInverse);this._frustum.setFromProjectionMatrix(d);c.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);c.multiply(b.projectionMatrix);c.multiply(b.matrixWorldInverse)},getViewport:function(a){return this._viewports[a]},getFrameExtents:function(){return this._frameExtents},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&&
24931 (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;return a}});gf.prototype=Object.assign(Object.create(lb.prototype),{constructor:gf,isSpotLightShadow:!0,updateMatrices:function(a){var b=this.camera,c=2*O.RAD2DEG*a.angle,d=this.mapSize.width/this.mapSize.height,e=a.distance||b.far;if(c!==b.fov||d!==b.aspect||e!==b.far)b.fov=c,b.aspect=d,b.far=e,b.updateProjectionMatrix();
24932 lb.prototype.updateMatrices.call(this,a)}});hf.prototype=Object.assign(Object.create(S.prototype),{constructor:hf,isSpotLight:!0,copy:function(a){S.prototype.copy.call(this,a);this.distance=a.distance;this.angle=a.angle;this.penumbra=a.penumbra;this.decay=a.decay;this.target=a.target.clone();this.shadow=a.shadow.clone();return this}});ug.prototype=Object.assign(Object.create(lb.prototype),{constructor:ug,isPointLightShadow:!0,updateMatrices:function(a,b){void 0===b&&(b=0);var c=this.camera,d=this.matrix,
24933 e=this._lightPositionWorld,f=this._lookTarget,g=this._projScreenMatrix;e.setFromMatrixPosition(a.matrixWorld);c.position.copy(e);f.copy(c.position);f.add(this._cubeDirections[b]);c.up.copy(this._cubeUps[b]);c.lookAt(f);c.updateMatrixWorld();d.makeTranslation(-e.x,-e.y,-e.z);g.multiplyMatrices(c.projectionMatrix,c.matrixWorldInverse);this._frustum.setFromProjectionMatrix(g)}});jf.prototype=Object.assign(Object.create(S.prototype),{constructor:jf,isPointLight:!0,copy:function(a){S.prototype.copy.call(this,
24934 a);this.distance=a.distance;this.decay=a.decay;this.shadow=a.shadow.clone();return this}});fd.prototype=Object.assign(Object.create(fb.prototype),{constructor:fd,isOrthographicCamera:!0,copy:function(a,b){fb.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,
24935 fullWidth:1,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.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)/
24936 2,e=c-a;c+=a;a=d+b;b=d-b;null!==this.view&&this.view.enabled&&(d=(this.right-this.left)/this.view.fullWidth/this.zoom,b=(this.top-this.bottom)/this.view.fullHeight/this.zoom,e+=d*this.view.offsetX,c=e+d*this.view.width,a-=b*this.view.offsetY,b=a-b*this.view.height);this.projectionMatrix.makeOrthographic(e,c,a,b,this.near,this.far);this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(a){a=y.prototype.toJSON.call(this,a);a.object.zoom=this.zoom;a.object.left=this.left;a.object.right=
24937 this.right;a.object.top=this.top;a.object.bottom=this.bottom;a.object.near=this.near;a.object.far=this.far;null!==this.view&&(a.object.view=Object.assign({},this.view));return a}});kf.prototype=Object.assign(Object.create(lb.prototype),{constructor:kf,isDirectionalLightShadow:!0,updateMatrices:function(a){lb.prototype.updateMatrices.call(this,a)}});lf.prototype=Object.assign(Object.create(S.prototype),{constructor:lf,isDirectionalLight:!0,copy:function(a){S.prototype.copy.call(this,a);this.target=
24938 a.target.clone();this.shadow=a.shadow.clone();return this}});mf.prototype=Object.assign(Object.create(S.prototype),{constructor:mf,isAmbientLight:!0});nf.prototype=Object.assign(Object.create(S.prototype),{constructor:nf,isRectAreaLight:!0,copy:function(a){S.prototype.copy.call(this,a);this.width=a.width;this.height=a.height;return this},toJSON:function(a){a=S.prototype.toJSON.call(this,a);a.object.width=this.width;a.object.height=this.height;return a}});Object.assign(of.prototype,{isSphericalHarmonics3:!0,
24939 set:function(a){for(var b=0;9>b;b++)this.coefficients[b].copy(a[b]);return this},zero:function(){for(var a=0;9>a;a++)this.coefficients[a].set(0,0,0);return this},getAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.282095);b.addScaledVector(e[1],.488603*d);b.addScaledVector(e[2],.488603*a);b.addScaledVector(e[3],.488603*c);b.addScaledVector(e[4],1.092548*c*d);b.addScaledVector(e[5],1.092548*d*a);b.addScaledVector(e[6],.315392*(3*a*a-1));b.addScaledVector(e[7],
24940 1.092548*c*a);b.addScaledVector(e[8],.546274*(c*c-d*d));return b},getIrradianceAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.886227);b.addScaledVector(e[1],1.023328*d);b.addScaledVector(e[2],1.023328*a);b.addScaledVector(e[3],1.023328*c);b.addScaledVector(e[4],.858086*c*d);b.addScaledVector(e[5],.858086*d*a);b.addScaledVector(e[6],.743125*a*a-.247708);b.addScaledVector(e[7],.858086*c*a);b.addScaledVector(e[8],.429043*(c*c-d*d));return b},add:function(a){for(var b=
24941 0;9>b;b++)this.coefficients[b].add(a.coefficients[b]);return this},addScaledSH:function(a,b){for(var c=0;9>c;c++)this.coefficients[c].addScaledVector(a.coefficients[c],b);return this},scale:function(a){for(var b=0;9>b;b++)this.coefficients[b].multiplyScalar(a);return this},lerp:function(a,b){for(var c=0;9>c;c++)this.coefficients[c].lerp(a.coefficients[c],b);return this},equals:function(a){for(var b=0;9>b;b++)if(!this.coefficients[b].equals(a.coefficients[b]))return!1;return!0},copy:function(a){return this.set(a.coefficients)},
24942 clone:function(){return(new this.constructor).copy(this)},fromArray:function(a,b){void 0===b&&(b=0);for(var c=this.coefficients,d=0;9>d;d++)c[d].fromArray(a,b+3*d);return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);for(var c=this.coefficients,d=0;9>d;d++)c[d].toArray(a,b+3*d);return a}});Object.assign(of,{getBasisAt:function(a,b){var c=a.x,d=a.y;a=a.z;b[0]=.282095;b[1]=.488603*d;b[2]=.488603*a;b[3]=.488603*c;b[4]=1.092548*c*d;b[5]=1.092548*d*a;b[6]=.315392*(3*a*a-1);b[7]=1.092548*
24943 c*a;b[8]=.546274*(c*c-d*d)}});Ua.prototype=Object.assign(Object.create(S.prototype),{constructor:Ua,isLightProbe:!0,copy:function(a){S.prototype.copy.call(this,a);this.sh.copy(a.sh);return this},fromJSON:function(a){this.intensity=a.intensity;this.sh.fromArray(a.sh);return this},toJSON:function(a){a=S.prototype.toJSON.call(this,a);a.object.sh=this.sh.toArray();return a}});pf.prototype=Object.assign(Object.create(V.prototype),{constructor:pf,load:function(a,b,c,d){var e=this,f=new Ta(e.manager);f.setPath(e.path);
24944 f.load(a,function(c){try{b(e.parse(JSON.parse(c)))}catch(h){d?d(h):console.error(h),e.manager.itemError(a)}},c,d)},parse:function(a){function b(a){void 0===c[a]&&console.warn("THREE.MaterialLoader: Undefined texture",a);return c[a]}var c=this.textures,d=new Sk[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.sheen&&(d.sheen=(new D).setHex(a.sheen));
24945 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=a.clearcoat);void 0!==a.clearcoatRoughness&&(d.clearcoatRoughness=a.clearcoatRoughness);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.combine&&(d.combine=a.combine);void 0!==a.side&&(d.side=a.side);void 0!==a.opacity&&(d.opacity=
24946 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.stencilWrite&&(d.stencilWrite=a.stencilWrite);void 0!==a.stencilWriteMask&&(d.stencilWriteMask=a.stencilWriteMask);void 0!==a.stencilFunc&&(d.stencilFunc=a.stencilFunc);void 0!==a.stencilRef&&(d.stencilRef=a.stencilRef);void 0!==
24947 a.stencilFuncMask&&(d.stencilFuncMask=a.stencilFuncMask);void 0!==a.stencilFail&&(d.stencilFail=a.stencilFail);void 0!==a.stencilZFail&&(d.stencilZFail=a.stencilZFail);void 0!==a.stencilZPass&&(d.stencilZPass=a.stencilZPass);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=a.wireframeLinejoin);void 0!==a.rotation&&
24948 (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&&(d.morphTargets=a.morphTargets);
24949 void 0!==a.morphNormals&&(d.morphNormals=a.morphNormals);void 0!==a.dithering&&(d.dithering=a.dithering);void 0!==a.vertexTangents&&(d.vertexTangents=a.vertexTangents);void 0!==a.visible&&(d.visible=a.visible);void 0!==a.toneMapped&&(d.toneMapped=a.toneMapped);void 0!==a.userData&&(d.userData=a.userData);void 0!==a.vertexColors&&(d.vertexColors="number"===typeof a.vertexColors?0<a.vertexColors?!0:!1:a.vertexColors);if(void 0!==a.uniforms)for(var e in a.uniforms){var f=a.uniforms[e];d.uniforms[e]=
24950 {};switch(f.type){case "t":d.uniforms[e].value=b(f.value);break;case "c":d.uniforms[e].value=(new D).setHex(f.value);break;case "v2":d.uniforms[e].value=(new v).fromArray(f.value);break;case "v3":d.uniforms[e].value=(new p).fromArray(f.value);break;case "v4":d.uniforms[e].value=(new R).fromArray(f.value);break;case "m3":d.uniforms[e].value=(new ya).fromArray(f.value);case "m4":d.uniforms[e].value=(new N).fromArray(f.value);break;default:d.uniforms[e].value=f.value}}void 0!==a.defines&&(d.defines=
24951 a.defines);void 0!==a.vertexShader&&(d.vertexShader=a.vertexShader);void 0!==a.fragmentShader&&(d.fragmentShader=a.fragmentShader);if(void 0!==a.extensions)for(var g in a.extensions)d.extensions[g]=a.extensions[g];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.matcap&&(d.matcap=b(a.matcap));void 0!==a.alphaMap&&(d.alphaMap=b(a.alphaMap));void 0!==a.bumpMap&&
24952 (d.bumpMap=b(a.bumpMap));void 0!==a.bumpScale&&(d.bumpScale=a.bumpScale);void 0!==a.normalMap&&(d.normalMap=b(a.normalMap));void 0!==a.normalMapType&&(d.normalMapType=a.normalMapType);void 0!==a.normalScale&&(e=a.normalScale,!1===Array.isArray(e)&&(e=[e,e]),d.normalScale=(new v).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);
24953 void 0!==a.roughnessMap&&(d.roughnessMap=b(a.roughnessMap));void 0!==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.envMapIntensity&&(d.envMapIntensity=a.envMapIntensity);void 0!==a.reflectivity&&(d.reflectivity=a.reflectivity);void 0!==a.refractionRatio&&(d.refractionRatio=
24954 a.refractionRatio);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!==a.aoMapIntensity&&(d.aoMapIntensity=a.aoMapIntensity);void 0!==a.gradientMap&&(d.gradientMap=b(a.gradientMap));void 0!==a.clearcoatMap&&(d.clearcoatMap=b(a.clearcoatMap));void 0!==a.clearcoatRoughnessMap&&(d.clearcoatRoughnessMap=b(a.clearcoatRoughnessMap));void 0!==a.clearcoatNormalMap&&(d.clearcoatNormalMap=b(a.clearcoatNormalMap));
24955 void 0!==a.clearcoatNormalScale&&(d.clearcoatNormalScale=(new v).fromArray(a.clearcoatNormalScale));return d},setTextures:function(a){this.textures=a;return this}});var lh={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]);try{return decodeURIComponent(escape(b))}catch(e){return b}},extractUrlBase:function(a){var b=a.lastIndexOf("/");return-1===b?"./":a.substr(0,b+1)}};me.prototype=Object.assign(Object.create(F.prototype),
24956 {constructor:me,isInstancedBufferGeometry:!0,copy:function(a){F.prototype.copy.call(this,a);this.instanceCount=a.instanceCount;return this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var a=F.prototype.toJSON.call(this);a.instanceCount=this.instanceCount;a.isInstancedBufferGeometry=!0;return a}});qf.prototype=Object.assign(Object.create(G.prototype),{constructor:qf,isInstancedBufferAttribute:!0,copy:function(a){G.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;
24957 return this},toJSON:function(){var a=G.prototype.toJSON.call(this);a.meshPerAttribute=this.meshPerAttribute;a.isInstancedBufferAttribute=!0;return a}});rf.prototype=Object.assign(Object.create(V.prototype),{constructor:rf,load:function(a,b,c,d){var e=this,f=new Ta(e.manager);f.setPath(e.path);f.load(a,function(c){try{b(e.parse(JSON.parse(c)))}catch(h){d?d(h):console.error(h),e.manager.itemError(a)}},c,d)},parse:function(a){var b=a.isInstancedBufferGeometry?new me:new F,c=a.data.index;if(void 0!==
24958 c){var d=new mh[c.type](c.array);b.setIndex(new G(d,1))}c=a.data.attributes;for(var e in c){var f=c[e];d=new mh[f.type](f.array);d=new (f.isInstancedBufferAttribute?qf:G)(d,f.itemSize,f.normalized);void 0!==f.name&&(d.name=f.name);b.setAttribute(e,d)}var g=a.data.morphAttributes;if(g)for(e in g){var h=g[e],l=[];c=0;for(var k=h.length;c<k;c++)f=h[c],d=new mh[f.type](f.array),d=new G(d,f.itemSize,f.normalized),void 0!==f.name&&(d.name=f.name),l.push(d);b.morphAttributes[e]=l}a.data.morphTargetsRelative&&
24959 (b.morphTargetsRelative=!0);e=a.data.groups||a.data.drawcalls||a.data.offsets;if(void 0!==e)for(c=0,f=e.length;c!==f;++c)d=e[c],b.addGroup(d.start,d.count,d.materialIndex);c=a.data.boundingSphere;void 0!==c&&(e=new p,void 0!==c.center&&e.fromArray(c.center),b.boundingSphere=new eb(e,c.radius));a.name&&(b.name=a.name);a.userData&&(b.userData=a.userData);return b}});var mh={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!==typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,
24960 Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};sf.prototype=Object.assign(Object.create(V.prototype),{constructor:sf,load:function(a,b,c,d){var e=this,f=""===this.path?lh.extractUrlBase(a):this.path;this.resourcePath=this.resourcePath||f;f=new Ta(e.manager);f.setPath(this.path);f.load(a,function(c){var f=null;try{f=JSON.parse(c)}catch(l){void 0!==d&&d(l);console.error("THREE:ObjectLoader: Can't parse "+
24961 a+".",l.message);return}c=f.metadata;void 0===c||void 0===c.type||"geometry"===c.type.toLowerCase()?console.error("THREE.ObjectLoader: Can't load "+a):e.parse(f,b)},c,d)},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));void 0!==
24962 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 Nb).fromJSON(a[c]);b[e.uuid]=e}return b},parseGeometries:function(a,b){var c={};if(void 0!==a)for(var d=new rf,e=0,f=a.length;e<f;e++){var g=a[e];switch(g.type){case "PlaneGeometry":case "PlaneBufferGeometry":var h=new ra[g.type](g.width,g.height,g.widthSegments,g.heightSegments);break;case "BoxGeometry":case "BoxBufferGeometry":case "CubeGeometry":h=new ra[g.type](g.width,
24963 g.height,g.depth,g.widthSegments,g.heightSegments,g.depthSegments);break;case "CircleGeometry":case "CircleBufferGeometry":h=new ra[g.type](g.radius,g.segments,g.thetaStart,g.thetaLength);break;case "CylinderGeometry":case "CylinderBufferGeometry":h=new ra[g.type](g.radiusTop,g.radiusBottom,g.height,g.radialSegments,g.heightSegments,g.openEnded,g.thetaStart,g.thetaLength);break;case "ConeGeometry":case "ConeBufferGeometry":h=new ra[g.type](g.radius,g.height,g.radialSegments,g.heightSegments,g.openEnded,
24964 g.thetaStart,g.thetaLength);break;case "SphereGeometry":case "SphereBufferGeometry":h=new ra[g.type](g.radius,g.widthSegments,g.heightSegments,g.phiStart,g.phiLength,g.thetaStart,g.thetaLength);break;case "DodecahedronGeometry":case "DodecahedronBufferGeometry":case "IcosahedronGeometry":case "IcosahedronBufferGeometry":case "OctahedronGeometry":case "OctahedronBufferGeometry":case "TetrahedronGeometry":case "TetrahedronBufferGeometry":h=new ra[g.type](g.radius,g.detail);break;case "RingGeometry":case "RingBufferGeometry":h=
24965 new ra[g.type](g.innerRadius,g.outerRadius,g.thetaSegments,g.phiSegments,g.thetaStart,g.thetaLength);break;case "TorusGeometry":case "TorusBufferGeometry":h=new ra[g.type](g.radius,g.tube,g.radialSegments,g.tubularSegments,g.arc);break;case "TorusKnotGeometry":case "TorusKnotBufferGeometry":h=new ra[g.type](g.radius,g.tube,g.tubularSegments,g.radialSegments,g.p,g.q);break;case "TubeGeometry":case "TubeBufferGeometry":h=new ra[g.type]((new kh[g.path.type]).fromJSON(g.path),g.tubularSegments,g.radius,
24966 g.radialSegments,g.closed);break;case "LatheGeometry":case "LatheBufferGeometry":h=new ra[g.type](g.points,g.segments,g.phiStart,g.phiLength);break;case "PolyhedronGeometry":case "PolyhedronBufferGeometry":h=new ra[g.type](g.vertices,g.indices,g.radius,g.details);break;case "ShapeGeometry":case "ShapeBufferGeometry":h=[];for(var l=0,k=g.shapes.length;l<k;l++){var p=b[g.shapes[l]];h.push(p)}h=new ra[g.type](h,g.curveSegments);break;case "ExtrudeGeometry":case "ExtrudeBufferGeometry":h=[];l=0;for(k=
24967 g.shapes.length;l<k;l++)p=b[g.shapes[l]],h.push(p);l=g.options.extrudePath;void 0!==l&&(g.options.extrudePath=(new kh[l.type]).fromJSON(l));h=new ra[g.type](h,g.options);break;case "BufferGeometry":case "InstancedBufferGeometry":h=d.parse(g);break;case "Geometry":console.error('THREE.ObjectLoader: Loading "Geometry" is not supported anymore.');break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+g.type+'"');continue}h.uuid=g.uuid;void 0!==g.name&&(h.name=g.name);!0===h.isBufferGeometry&&
24968 void 0!==g.userData&&(h.userData=g.userData);c[g.uuid]=h}return c},parseMaterials:function(a,b){var c={},d={};if(void 0!==a){var e=new pf;e.setTextures(b);b=0;for(var f=a.length;b<f;b++){var g=a[b];if("MultiMaterial"===g.type){for(var h=[],l=0;l<g.materials.length;l++){var k=g.materials[l];void 0===c[k.uuid]&&(c[k.uuid]=e.parse(k));h.push(c[k.uuid])}d[g.uuid]=h}else void 0===c[g.uuid]&&(c[g.uuid]=e.parse(g)),d[g.uuid]=c[g.uuid]}}return d},parseAnimations:function(a){for(var b=[],c=0;c<a.length;c++){var d=
24969 a[c],e=Sa.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.itemError(a);d.manager.itemEnd(a)})}var d=this,e={};if(void 0!==a&&0<a.length){b=new qg(b);var f=new dd(b);f.setCrossOrigin(this.crossOrigin);b=0;for(var g=a.length;b<g;b++){var h=a[b],l=h.url;if(Array.isArray(l)){e[h.uuid]=[];for(var k=0,p=l.length;k<p;k++){var n=l[k];n=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?
24970 n:d.resourcePath+n;e[h.uuid].push(c(n))}}else n=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h.url)?h.url:d.resourcePath+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.",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",
24971 g.image);var h=Array.isArray(b[g.image])?new qb(b[g.image]):new W(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,Tk));void 0!==g.offset&&h.offset.fromArray(g.offset);void 0!==g.repeat&&h.repeat.fromArray(g.repeat);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],Ni),h.wrapT=c(g.wrap[1],Ni));void 0!==g.format&&(h.format=g.format);void 0!==g.type&&
24972 (h.type=g.type);void 0!==g.encoding&&(h.encoding=g.encoding);void 0!==g.minFilter&&(h.minFilter=c(g.minFilter,Oi));void 0!==g.magFilter&&(h.magFilter=c(g.magFilter,Oi));void 0!==g.anisotropy&&(h.anisotropy=g.anisotropy);void 0!==g.flipY&&(h.flipY=g.flipY);void 0!==g.premultiplyAlpha&&(h.premultiplyAlpha=g.premultiplyAlpha);void 0!==g.unpackAlignment&&(h.unpackAlignment=g.unpackAlignment);d[g.uuid]=h}return d},parseObject:function(a,b,c){function d(a){void 0===b[a]&&console.warn("THREE.ObjectLoader: Undefined geometry",
24973 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 zc;void 0!==a.background&&Number.isInteger(a.background)&&(f.background=new D(a.background));void 0!==a.fog&&("Fog"===a.fog.type?f.fog=new Oe(a.fog.color,a.fog.near,a.fog.far):
24974 "FogExp2"===a.fog.type&&(f.fog=new Ne(a.fog.color,a.fog.density)));break;case "PerspectiveCamera":f=new P(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 fd(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({},
24975 a.view));break;case "AmbientLight":f=new mf(a.color,a.intensity);break;case "DirectionalLight":f=new lf(a.color,a.intensity);break;case "PointLight":f=new jf(a.color,a.intensity,a.distance,a.decay);break;case "RectAreaLight":f=new nf(a.color,a.intensity,a.width,a.height);break;case "SpotLight":f=new hf(a.color,a.intensity,a.distance,a.angle,a.penumbra,a.decay);break;case "HemisphereLight":f=new ff(a.color,a.groundColor,a.intensity);break;case "LightProbe":f=(new Ua).fromJSON(a);break;case "SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");
24976 case "Mesh":f=d(a.geometry);var g=e(a.material);f=new ea(f,g);break;case "InstancedMesh":f=d(a.geometry);g=e(a.material);var h=a.instanceMatrix;f=new Se(f,g,a.count);f.instanceMatrix=new G(new Float32Array(h.array),16);break;case "LOD":f=new Nd;break;case "Line":f=new La(d(a.geometry),e(a.material),a.mode);break;case "LineLoop":f=new Te(d(a.geometry),e(a.material));break;case "LineSegments":f=new ma(d(a.geometry),e(a.material));break;case "PointCloud":case "Points":f=new Nc(d(a.geometry),e(a.material));
24977 break;case "Sprite":f=new Ld(e(a.material));break;case "Group":f=new Kc;break;default:f=new y}f.uuid=a.uuid;void 0!==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!==
24978 a.scale&&f.scale.fromArray(a.scale));void 0!==a.castShadow&&(f.castShadow=a.castShadow);void 0!==a.receiveShadow&&(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=
24979 a.frustumCulled);void 0!==a.renderOrder&&(f.renderOrder=a.renderOrder);void 0!==a.userData&&(f.userData=a.userData);void 0!==a.layers&&(f.layers.mask=a.layers);if(void 0!==a.children)for(h=a.children,g=0;g<h.length;g++)f.add(this.parseObject(h[g],b,c));if("LOD"===a.type)for(void 0!==a.autoUpdate&&(f.autoUpdate=a.autoUpdate),a=a.levels,h=0;h<a.length;h++){g=a[h];var l=f.getObjectByProperty("uuid",g.object);void 0!==l&&f.addLevel(l,g.distance)}return f}});var Tk={UVMapping:300,CubeReflectionMapping:301,
24980 CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,SphericalReflectionMapping:305,CubeUVReflectionMapping:306,CubeUVRefractionMapping:307},Ni={RepeatWrapping:1E3,ClampToEdgeWrapping:1001,MirroredRepeatWrapping:1002},Oi={NearestFilter:1003,NearestMipmapNearestFilter:1004,NearestMipmapLinearFilter:1005,LinearFilter:1006,LinearMipmapNearestFilter:1007,LinearMipmapLinearFilter:1008};vg.prototype=Object.assign(Object.create(V.prototype),{constructor:vg,
24981 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=tc.get(a);if(void 0!==f)return e.manager.itemStart(a),setTimeout(function(){b&&b(f);e.manager.itemEnd(a)},0),f;fetch(a).then(function(a){return a.blob()}).then(function(a){return void 0===e.options?createImageBitmap(a):createImageBitmap(a,e.options)}).then(function(c){tc.add(a,c);b&&b(c);e.manager.itemEnd(a)}).catch(function(b){d&&
24982 d(b);e.manager.itemError(a);e.manager.itemEnd(a)});e.manager.itemStart(a)}});Object.assign(wg.prototype,{moveTo:function(a,b){this.currentPath=new bb;this.subPaths.push(this.currentPath);this.currentPath.moveTo(a,b);return this},lineTo:function(a,b){this.currentPath.lineTo(a,b);return this},quadraticCurveTo:function(a,b,c,d){this.currentPath.quadraticCurveTo(a,b,c,d);return this},bezierCurveTo:function(a,b,c,d,e,f){this.currentPath.bezierCurveTo(a,b,c,d,e,f);return this},splineThru:function(a){this.currentPath.splineThru(a);
24983 return this},toShapes:function(a,b){function c(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c],f=new Nb;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],l=h.x-g.x,k=h.y-g.y;if(Math.abs(k)>Number.EPSILON){if(0>k&&(g=b[f],l=-l,h=b[e],k=-k),!(a.y<g.y||a.y>h.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=k*(a.x-g.x)-l*(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}
24984 var e=sb.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 Nb;h.curves=g.curves;b.push(h);return b}var l=!e(f[0].getPoints());l=a?!l:l;h=[];var k=[],p=[],n=0;k[n]=void 0;p[n]=[];for(var t=0,r=f.length;t<r;t++){g=f[t];var q=g.getPoints();var u=e(q);(u=a?!u:u)?(!l&&k[n]&&n++,k[n]={s:new Nb,p:q},k[n].s.curves=g.curves,l&&n++,p[n]=[]):p[n].push({h:g,p:q[0]})}if(!k[0])return c(f);if(1<k.length){t=!1;a=[];e=0;for(f=k.length;e<f;e++)h[e]=
24985 [];e=0;for(f=k.length;e<f;e++)for(g=p[e],u=0;u<g.length;u++){l=g[u];n=!0;for(q=0;q<k.length;q++)d(l.p,k[q].p)&&(e!==q&&a.push({froms:e,tos:q,hole:u}),n?(n=!1,h[q].push(l)):t=!0);n&&h[e].push(l)}0<a.length&&(t||(p=h))}t=0;for(e=k.length;t<e;t++)for(h=k[t].s,b.push(h),a=p[t],f=0,g=a.length;f<g;f++)h.holes.push(a[f].h);return b}});Object.assign(xg.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;
24986 var f=(b.boundingBox.yMax-b.boundingBox.yMin+b.underlineThickness)*d;a=[];for(var g=0,h=0,l=0;l<e.length;l++){var k=e[l];if("\n"===k)g=0,h-=f;else{var p=k;k=d;var n=g,t=h,r=b,q=r.glyphs[p]||r.glyphs["?"];if(q){p=new wg;if(q.o){r=q._cachedOutline||(q._cachedOutline=q.o.split(" "));for(var u=0,v=r.length;u<v;)switch(r[u++]){case "m":var x=r[u++]*k+n;var w=r[u++]*k+t;p.moveTo(x,w);break;case "l":x=r[u++]*k+n;w=r[u++]*k+t;p.lineTo(x,w);break;case "q":var y=r[u++]*k+n;var A=r[u++]*k+t;var B=r[u++]*k+n;
24987 var C=r[u++]*k+t;p.quadraticCurveTo(B,C,y,A);break;case "b":y=r[u++]*k+n,A=r[u++]*k+t,B=r[u++]*k+n,C=r[u++]*k+t,x=r[u++]*k+n,w=r[u++]*k+t,p.bezierCurveTo(B,C,x,w,y,A)}}k={offsetX:q.ha*k,path:p}}else console.error('THREE.Font: character "'+p+'" does not exists in font family '+r.familyName+"."),k=void 0;g+=k.offsetX;a.push(k.path)}}b=0;for(e=a.length;b<e;b++)Array.prototype.push.apply(c,a[b].toShapes());return c}});yg.prototype=Object.assign(Object.create(V.prototype),{constructor:yg,load:function(a,
24988 b,c,d){var e=this,f=new Ta(this.manager);f.setPath(this.path);f.load(a,function(a){try{var c=JSON.parse(a)}catch(l){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 xg(a)}});var Rf,Dg={getContext:function(){void 0===Rf&&(Rf=new (window.AudioContext||window.webkitAudioContext));return Rf},setContext:function(a){Rf=a}};tf.prototype=Object.assign(Object.create(V.prototype),
24989 {constructor:tf,load:function(a,b,c,d){var e=this,f=new Ta(e.manager);f.setResponseType("arraybuffer");f.setPath(e.path);f.load(a,function(c){try{var f=c.slice(0);Dg.getContext().decodeAudioData(f,function(a){b(a)})}catch(l){d?d(l):console.error(l),e.manager.itemError(a)}},c,d)}});zg.prototype=Object.assign(Object.create(Ua.prototype),{constructor:zg,isHemisphereLightProbe:!0,copy:function(a){Ua.prototype.copy.call(this,a);return this},toJSON:function(a){return Ua.prototype.toJSON.call(this,a)}});
24990 Ag.prototype=Object.assign(Object.create(Ua.prototype),{constructor:Ag,isAmbientLightProbe:!0,copy:function(a){Ua.prototype.copy.call(this,a);return this},toJSON:function(a){return Ua.prototype.toJSON.call(this,a)}});var Pi=new N,Qi=new N;Object.assign(gi.prototype,{update:function(a){var b=this._cache;if(b.focus!==a.focus||b.fov!==a.fov||b.aspect!==a.aspect*this.aspect||b.near!==a.near||b.far!==a.far||b.zoom!==a.zoom||b.eyeSep!==this.eyeSep){b.focus=a.focus;b.fov=a.fov;b.aspect=a.aspect*this.aspect;
24991 b.near=a.near;b.far=a.far;b.zoom=a.zoom;b.eyeSep=this.eyeSep;var c=a.projectionMatrix.clone(),d=b.eyeSep/2,e=d*b.near/b.focus,f=b.near*Math.tan(O.DEG2RAD*b.fov*.5)/b.zoom;Qi.elements[12]=-d;Pi.elements[12]=d;d=-f*b.aspect+e;var g=f*b.aspect+e;c.elements[0]=2*b.near/(g-d);c.elements[8]=(g+d)/(g-d);this.cameraL.projectionMatrix.copy(c);d=-f*b.aspect-e;g=f*b.aspect-e;c.elements[0]=2*b.near/(g-d);c.elements[8]=(g+d)/(g-d);this.cameraR.projectionMatrix.copy(c)}this.cameraL.matrixWorld.copy(a.matrixWorld).multiply(Qi);
24992 this.cameraR.matrixWorld.copy(a.matrixWorld).multiply(Pi)}});Object.assign(Bg.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=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var b=("undefined"===typeof performance?
24993 Date:performance).now();a=(b-this.oldTime)/1E3;this.oldTime=b;this.elapsedTime+=a}return a}});var uc=new p,Ri=new va,Uk=new p,vc=new p;Cg.prototype=Object.assign(Object.create(y.prototype),{constructor:Cg,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!==
24994 this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):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(a){y.prototype.updateMatrixWorld.call(this,a);a=this.context.listener;
24995 var b=this.up;this.timeDelta=this._clock.getDelta();this.matrixWorld.decompose(uc,Ri,Uk);vc.set(0,0,-1).applyQuaternion(Ri);if(a.positionX){var c=this.context.currentTime+this.timeDelta;a.positionX.linearRampToValueAtTime(uc.x,c);a.positionY.linearRampToValueAtTime(uc.y,c);a.positionZ.linearRampToValueAtTime(uc.z,c);a.forwardX.linearRampToValueAtTime(vc.x,c);a.forwardY.linearRampToValueAtTime(vc.y,c);a.forwardZ.linearRampToValueAtTime(vc.z,c);a.upX.linearRampToValueAtTime(b.x,c);a.upY.linearRampToValueAtTime(b.y,
24996 c);a.upZ.linearRampToValueAtTime(b.z,c)}else a.setPosition(uc.x,uc.y,uc.z),a.setOrientation(vc.x,vc.y,vc.z,b.x,b.y,b.z)}});gd.prototype=Object.assign(Object.create(y.prototype),{constructor:gd,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();
24997 return this},setMediaStreamSource:function(a){this.hasPlaybackControl=!1;this.sourceType="mediaStreamNode";this.source=this.context.createMediaStreamSource(a);this.connect();return this},setBuffer:function(a){this.buffer=a;this.sourceType="buffer";this.autoplay&&this.play();return this},play:function(a){void 0===a&&(a=0);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.");
24998 else return this._startedAt=this.context.currentTime+a,a=this.context.createBufferSource(),a.buffer=this.buffer,a.loop=this.loop,a.loopStart=this.loopStart,a.loopEnd=this.loopEnd,a.onended=this.onEnded.bind(this),a.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=a,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()},pause:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");
24999 else return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress%=this.duration||this.buffer.duration),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this},stop:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this},connect:function(){if(0<this.filters.length){this.source.connect(this.filters[0]);
25000 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]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},
25001 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},setDetune:function(a){this.detune=a;if(void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this},getDetune:function(){return this.detune},getFilter:function(){return this.getFilters()[0]},setFilter:function(a){return this.setFilters(a?[a]:[])},setPlaybackRate:function(a){if(!1===
25002 this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.playbackRate=a,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),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.");
25003 else return this.loop=a,!0===this.isPlaying&&(this.source.loop=this.loop),this},setLoopStart:function(a){this.loopStart=a;return this},setLoopEnd:function(a){this.loopEnd=a;return this},getVolume:function(){return this.gain.gain.value},setVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this}});var wc=new p,Si=new va,Vk=new p,xc=new p;Eg.prototype=Object.assign(Object.create(gd.prototype),{constructor:Eg,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},
25004 setRefDistance:function(a){this.panner.refDistance=a;return this},getRolloffFactor:function(){return this.panner.rolloffFactor},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=
25005 a;this.panner.coneOuterAngle=b;this.panner.coneOuterGain=c;return this},updateMatrixWorld:function(a){y.prototype.updateMatrixWorld.call(this,a);if(!0!==this.hasPlaybackControl||!1!==this.isPlaying)if(this.matrixWorld.decompose(wc,Si,Vk),xc.set(0,0,1).applyQuaternion(Si),a=this.panner,a.positionX){var b=this.context.currentTime+this.listener.timeDelta;a.positionX.linearRampToValueAtTime(wc.x,b);a.positionY.linearRampToValueAtTime(wc.y,b);a.positionZ.linearRampToValueAtTime(wc.z,b);a.orientationX.linearRampToValueAtTime(xc.x,
25006 b);a.orientationY.linearRampToValueAtTime(xc.y,b);a.orientationZ.linearRampToValueAtTime(xc.z,b)}else a.setPosition(wc.x,wc.y,wc.z),a.setOrientation(xc.x,xc.y,xc.z)}});Object.assign(Fg.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(Gg.prototype,{accumulate:function(a,b){var c=this.buffer,d=this.valueSize;a=a*d+d;
25007 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},accumulateAdditive:function(a){var b=this.buffer,c=this.valueSize,d=c*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity();this._mixBufferRegionAdditive(b,d,0,a,c);this.cumulativeWeightAdditive+=a},apply:function(a){var b=this.valueSize,c=this.buffer;a=a*b+b;var d=this.cumulativeWeight,e=this.cumulativeWeightAdditive,f=this.binding;this.cumulativeWeightAdditive=
25008 this.cumulativeWeight=0;1>d&&this._mixBufferRegion(c,a,b*this._origIndex,1-d,b);0<e&&this._mixBufferRegionAdditive(c,a,this._addIndex*b,1,b);d=b;for(e=b+b;d!==e;++d)if(c[d]!==c[d+b]){f.setValue(c,a);break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=b*this._origIndex;this.binding.getValue(a,c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this._setIdentity();this.cumulativeWeightAdditive=this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},
25009 _setAdditiveIdentityNumeric:function(){for(var a=this._addIndex*this.valueSize,b=a+this.valueSize;a<b;a++)this.buffer[a]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric();this.buffer[4*this._addIndex+3]=1},_setAdditiveIdentityOther:function(){for(var a=this._origIndex*this.valueSize,b=this._addIndex*this.valueSize,c=0;c<this.valueSize;c++)this.buffer[b+c]=this.buffer[a+c]},_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){va.slerpFlat(a,
25010 b,a,b,a,c,d)},_slerpAdditive:function(a,b,c,d,e){e*=this._workIndex;va.multiplyQuaternionsFlat(a,e,a,b,a,c);va.slerpFlat(a,b,a,b,a,e,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}},_lerpAdditive:function(a,b,c,d,e){for(var f=0;f!==e;++f){var g=b+f;a[g]+=a[c+f]*d}}});var Wk=/[\[\]\.:\/]/g,Xk="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Yk=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),Zk=/(WCOD+)?/.source.replace("WCOD",Xk),$k=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",
25011 "[^\\[\\]\\.:\\/]"),al=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),bl=new RegExp("^"+Yk+Zk+$k+al+"$"),cl=["material","materials","bones"];Object.assign(hi.prototype,{getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];void 0!==c&&c.getValue(a,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_,
25012 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(Aa,{Composite:hi,create:function(a,b,c){return a&&a.isAnimationObjectGroup?new Aa.Composite(a,b,c):new Aa(a,b,c)},sanitizeNodeName:function(a){return a.replace(/\s/g,"_").replace(Wk,"")},parseTrackName:function(a){var b=bl.exec(a);if(!b)throw Error("PropertyBinding: Cannot parse trackName: "+a);b={nodeName:b[2],objectName:b[3],objectIndex:b[4],
25013 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!==cl.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||"."===b||-1===b||b===a.name||b===a.uuid)return a;if(a.skeleton){var c=a.skeleton.getBoneByName(b);if(void 0!==
25014 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(Aa.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,b){a[b]=this.node[this.propertyName]},function(a,b){for(var c=
25015 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=!0}],[function(a,b){for(var c=this.resolvedProperty,
25016 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,b){this.resolvedProperty[this.propertyIndex]=a[b];
25017 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,d=b.propertyName,e=b.propertyIndex;a||(this.node=
25018 a=Aa.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.",this);return}a=a.material.materials;
25019 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.",this,a);return}a=
25020 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;this.targetObject=a;void 0!==a.needsUpdate?b=this.Versioning.NeedsUpdate:void 0!==a.matrixWorldNeedsUpdate&&(b=this.Versioning.MatrixWorldNeedsUpdate);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.",
25021 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}void 0!==a.morphTargetDictionary[e]&&(e=a.morphTargetDictionary[e])}else{console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);return}}c=this.BindingType.ArrayElement;this.resolvedProperty=f;this.propertyIndex=
25022 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: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null;this.getValue=this._getValue_unbound;this.setValue=
25023 this._setValue_unbound}});Object.assign(Aa.prototype,{_getValue_unbound:Aa.prototype.getValue,_setValue_unbound:Aa.prototype.setValue});Object.assign(ii.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,m=0,p=arguments.length;m!==p;++m){var n=arguments[m],t=n.uuid,r=d[t];if(void 0===r){r=b++;d[t]=r;a.push(n);t=0;for(var q=h;t!==q;++t)g[t].push(new Aa(n,
25024 e[t],f[t]))}else if(r<c){k=a[r];var u=--c;q=a[u];d[q.uuid]=r;a[r]=q;d[t]=u;a[u]=n;t=0;for(q=h;t!==q;++t){var v=g[t],x=v[r];v[r]=v[u];void 0===x&&(x=new Aa(n,e[t],f[t]));v[u]=x}}else a[r]!==k&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c},remove:function(){for(var a=this._objects,b=this.nCachedObjects_,c=this._indicesByUUID,d=this._bindings,e=d.length,f=0,g=
25025 arguments.length;f!==g;++f){var h=arguments[f],k=h.uuid,m=c[k];if(void 0!==m&&m>=b){var p=b++,n=a[p];c[n.uuid]=m;a[m]=n;c[k]=p;a[p]=h;h=0;for(k=e;h!==k;++h){n=d[h];var t=n[m];n[m]=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=arguments[g].uuid,m=d[k];if(void 0!==m)if(delete d[k],m<c){k=--c;var p=a[k],n=--b,t=a[n];d[p.uuid]=m;a[m]=p;d[t.uuid]=
25026 k;a[k]=t;a.pop();p=0;for(t=f;p!==t;++p){var r=e[p],q=r[n];r[m]=r[k];r[k]=q;r.pop()}}else for(n=--b,t=a[n],d[t.uuid]=m,a[m]=t,a.pop(),p=0,t=f;p!==t;++p)r=e[p],r[m]=r[n],r.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_,m=Array(h.length);d=e.length;c[a]=d;f.push(a);g.push(b);e.push(m);c=k;for(d=h.length;c!==d;++c)m[c]=new Aa(h[c],a,b);
25027 return m},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(ji.prototype,{play:function(){this._mixer._activateAction(this);return this},stop:function(){this._mixer._deactivateAction(this);return this.reset()},reset:function(){this.paused=!1;this.enabled=!0;this.time=0;this._loopCount=-1;this._startTime=null;return this.stopFading().stopWarping()},
25028 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;this._effectiveWeight=this.enabled?a:0;return this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(a){return this._scheduleFading(a,
25029 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;null!==a&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(a));return this},setEffectiveTimeScale:function(a){this.timeScale=a;this._effectiveTimeScale=
25030 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,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());
25031 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||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=
25032 null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0<a)switch(b=this._interpolants,e=this._propertyBindings,this.blendMode){case 2501:for(var f=0,g=b.length;f!==g;++f)b[f].evaluate(c),e[f].accumulateAdditive(a);break;default:for(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];b*=d;a>c.parameterPositions[1]&&
25033 (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===e?b:f&&1===(e&1)?c-b:b;if(2200===
25034 d)a:{if(-1===e&&(this._loopCount=0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else{this.time=b;break a}this.clampWhenFinished?this.paused=!0:this.enabled=!1;this.time=b;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:this.enabled=
25035 !1,this.time=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.time=b,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d}))}else this.time=b;if(f&&1===(e&1))return c-b}return 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?
25036 2401: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}});Hg.prototype=Object.assign(Object.create(ua.prototype),{constructor:Hg,_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===
25037 k&&(k={},h[g]=k);for(h=0;h!==e;++h){var m=d[h],p=m.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 Gg(Aa.create(c,p,b&&b._propertyBindings[h].binding.parsedPath),m.ValueTypeName,m.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,
25038 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=
25039 [];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}}}},
25040 _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;
25041 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,
25042 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,
25043 f=e[d],g=b[b.length-1];a=a._cacheIndex;g._cacheIndex=a;b[a]=g;b.pop();delete f[c];0===Object.keys(f).length&&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++,
25044 c=a[b];void 0===c&&(c=new ie(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,c){var d=b||this._root,e=d.uuid;d="string"===typeof a?Sa.findByName(d,a):a;a=null!==d?d.uuid:a;var f=
25045 this._actionsByClip[a],g=null;void 0===c&&(c=null!==d?d.blendMode:2500);if(void 0!==f){g=f.actionByRoot[e];if(void 0!==g&&g.blendMode===c)return g;g=f.knownActions[0];null===d&&(d=g._clip)}if(null===d)return null;b=new ji(this,d,b,c);this._bindAction(b,g);this._addInactiveAction(b,a,e);return b},existingAction:function(a,b){var c=b||this._root;b=c.uuid;c="string"===typeof a?Sa.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=
25046 this._actions,b=this._nActiveActions-1;0<=b;--b)a[b].stop();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},setTime:function(a){for(var b=this.time=0;b<this._actions.length;b++)this._actions[b].time=0;return this.update(a)},getRoot:function(){return this._root},uncacheClip:function(a){var b=
25047 this._actions;a=a.uuid;var c=this._actionsByClip,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];
25048 if(void 0!==d)for(var e in d)a=d[e],a.restoreOriginalState(),this._removeInactiveBinding(a)},uncacheAction:function(a,b){a=this.existingAction(a,b);null!==a&&(this._deactivateAction(a),this._removeInactiveAction(a))}});uf.prototype.clone=function(){return new uf(void 0===this.value.clone?this.value:this.value.clone())};Ig.prototype=Object.assign(Object.create(rb.prototype),{constructor:Ig,isInstancedInterleavedBuffer:!0,copy:function(a){rb.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;
25049 return this}});Object.assign(Jg.prototype,{set:function(a,b){this.ray.set(a,b)},setFromCamera:function(a,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(),this.camera=b):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),this.camera=b):console.error("THREE.Raycaster: Unsupported camera type.")},
25050 intersectObject:function(a,b,c){c=c||[];Kg(a,this,c,b);c.sort(ki);return c},intersectObjects:function(a,b,c){c=c||[];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++)Kg(a[d],this,c,b);c.sort(ki);return c}});Object.assign(li.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=
25051 a.phi;this.theta=a.theta;return this},makeSafe:function(){this.phi=Math.max(1E-6,Math.min(Math.PI-1E-6,this.phi));return this},setFromVector3:function(a){return this.setFromCartesianCoords(a.x,a.y,a.z)},setFromCartesianCoords:function(a,b,c){this.radius=Math.sqrt(a*a+b*b+c*c);0===this.radius?this.phi=this.theta=0:(this.theta=Math.atan2(a,c),this.phi=Math.acos(O.clamp(b/this.radius,-1,1)));return this}});Object.assign(mi.prototype,{set:function(a,b,c){this.radius=a;this.theta=b;this.y=c;return this},
25052 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){return this.setFromCartesianCoords(a.x,a.y,a.z)},setFromCartesianCoords:function(a,b,c){this.radius=Math.sqrt(a*a+c*c);this.theta=Math.atan2(a,c);this.y=b;return this}});var Ti=new v;Object.assign(Lg.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<
25053 c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(a,b){b=Ti.copy(b).multiplyScalar(.5);this.min.copy(a).sub(b);this.max.copy(a).add(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);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===
25054 a&&(console.warn("THREE.Box2: .getCenter() target is now required"),a=new v);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 v);return this.isEmpty()?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);
25055 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,b){void 0===b&&(console.warn("THREE.Box2: .getParameter() target is now required"),b=new v);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<
25056 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 v);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(a){return Ti.copy(a).clamp(this.min,this.max).sub(a).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);
25057 this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});var Ui=new p,Sf=new p;Object.assign(Mg.prototype,{set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},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)},
25058 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)},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(a,b){Ui.subVectors(a,this.start);Sf.subVectors(this.end,
25059 this.start);a=Sf.dot(Sf);a=Sf.dot(Ui)/a;b&&(a=O.clamp(a,0,1));return a},closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);void 0===c&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),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)}});ne.prototype=Object.create(y.prototype);
25060 ne.prototype.constructor=ne;ne.prototype.isImmediateRenderObject=!0;var Vi=new p;hd.prototype=Object.create(y.prototype);hd.prototype.constructor=hd;hd.prototype.dispose=function(){this.cone.geometry.dispose();this.cone.material.dispose()};hd.prototype.update=function(){this.light.updateMatrixWorld();var a=this.light.distance?this.light.distance:1E3,b=a*Math.tan(this.light.angle);this.cone.scale.set(b,b,a);Vi.setFromMatrixPosition(this.light.target.matrixWorld);this.cone.lookAt(Vi);void 0!==this.color?
25061 this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var Tb=new p,Tf=new N,nh=new N;pc.prototype=Object.create(ma.prototype);pc.prototype.constructor=pc;pc.prototype.isSkeletonHelper=!0;pc.prototype.updateMatrixWorld=function(a){var b=this.bones,c=this.geometry,d=c.getAttribute("position");nh.getInverse(this.root.matrixWorld);for(var e=0,f=0;e<b.length;e++){var g=b[e];g.parent&&g.parent.isBone&&(Tf.multiplyMatrices(nh,g.matrixWorld),Tb.setFromMatrixPosition(Tf),
25062 d.setXYZ(f,Tb.x,Tb.y,Tb.z),Tf.multiplyMatrices(nh,g.parent.matrixWorld),Tb.setFromMatrixPosition(Tf),d.setXYZ(f+1,Tb.x,Tb.y,Tb.z),f+=2)}c.getAttribute("position").needsUpdate=!0;y.prototype.updateMatrixWorld.call(this,a)};id.prototype=Object.create(ea.prototype);id.prototype.constructor=id;id.prototype.dispose=function(){this.geometry.dispose();this.material.dispose()};id.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)};
25063 var dl=new p,Wi=new D,Xi=new D;jd.prototype=Object.create(y.prototype);jd.prototype.constructor=jd;jd.prototype.dispose=function(){this.children[0].geometry.dispose();this.children[0].material.dispose()};jd.prototype.update=function(){var a=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var b=a.geometry.getAttribute("color");Wi.copy(this.light.color);Xi.copy(this.light.groundColor);for(var c=0,d=b.count;c<d;c++){var e=c<d/2?Wi:Xi;b.setXYZ(c,e.r,e.g,e.b)}b.needsUpdate=
25064 !0}a.lookAt(dl.setFromMatrixPosition(this.light.matrixWorld).negate())};vf.prototype=Object.assign(Object.create(ma.prototype),{constructor:vf,copy:function(a){ma.prototype.copy.call(this,a);this.geometry.copy(a.geometry);this.material.copy(a.material);return this},clone:function(){return(new this.constructor).copy(this)}});wf.prototype=Object.create(ma.prototype);wf.prototype.constructor=wf;var Yi=new p,Uf=new p,Zi=new p;kd.prototype=Object.create(y.prototype);kd.prototype.constructor=kd;kd.prototype.dispose=
25065 function(){this.lightPlane.geometry.dispose();this.lightPlane.material.dispose();this.targetLine.geometry.dispose();this.targetLine.material.dispose()};kd.prototype.update=function(){Yi.setFromMatrixPosition(this.light.matrixWorld);Uf.setFromMatrixPosition(this.light.target.matrixWorld);Zi.subVectors(Uf,Yi);this.lightPlane.lookAt(Uf);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),
25066 this.targetLine.material.color.copy(this.light.color));this.targetLine.lookAt(Uf);this.targetLine.scale.z=Zi.length()};var xf=new p,la=new fb;oe.prototype=Object.create(ma.prototype);oe.prototype.constructor=oe;oe.prototype.update=function(){var a=this.geometry,b=this.pointMap;la.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);fa("c",b,a,la,0,0,-1);fa("t",b,a,la,0,0,1);fa("n1",b,a,la,-1,-1,-1);fa("n2",b,a,la,1,-1,-1);fa("n3",b,a,la,-1,1,-1);fa("n4",b,a,la,1,1,-1);fa("f1",b,a,la,
25067 -1,-1,1);fa("f2",b,a,la,1,-1,1);fa("f3",b,a,la,-1,1,1);fa("f4",b,a,la,1,1,1);fa("u1",b,a,la,.7,1.1,-1);fa("u2",b,a,la,-.7,1.1,-1);fa("u3",b,a,la,0,2,-1);fa("cf1",b,a,la,-1,0,1);fa("cf2",b,a,la,1,0,1);fa("cf3",b,a,la,0,-1,1);fa("cf4",b,a,la,0,1,1);fa("cn1",b,a,la,-1,0,-1);fa("cn2",b,a,la,1,0,-1);fa("cn3",b,a,la,0,-1,-1);fa("cn4",b,a,la,0,1,-1);a.getAttribute("position").needsUpdate=!0};var Vf=new Va;wb.prototype=Object.create(ma.prototype);wb.prototype.constructor=wb;wb.prototype.update=function(a){void 0!==
25068 a&&console.warn("THREE.BoxHelper: .update() has no longer arguments.");void 0!==this.object&&Vf.setFromObject(this.object);if(!Vf.isEmpty()){a=Vf.min;var b=Vf.max,c=this.geometry.attributes.position,d=c.array;d[0]=b.x;d[1]=b.y;d[2]=b.z;d[3]=a.x;d[4]=b.y;d[5]=b.z;d[6]=a.x;d[7]=a.y;d[8]=b.z;d[9]=b.x;d[10]=a.y;d[11]=b.z;d[12]=b.x;d[13]=b.y;d[14]=a.z;d[15]=a.x;d[16]=b.y;d[17]=a.z;d[18]=a.x;d[19]=a.y;d[20]=a.z;d[21]=b.x;d[22]=a.y;d[23]=a.z;c.needsUpdate=!0;this.geometry.computeBoundingSphere()}};wb.prototype.setFromObject=
25069 function(a){this.object=a;this.update();return this};wb.prototype.copy=function(a){ma.prototype.copy.call(this,a);this.object=a.object;return this};wb.prototype.clone=function(){return(new this.constructor).copy(this)};pe.prototype=Object.create(ma.prototype);pe.prototype.constructor=pe;pe.prototype.updateMatrixWorld=function(a){var b=this.box;b.isEmpty()||(b.getCenter(this.position),b.getSize(this.scale),this.scale.multiplyScalar(.5),y.prototype.updateMatrixWorld.call(this,a))};qe.prototype=Object.create(La.prototype);
25070 qe.prototype.constructor=qe;qe.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);y.prototype.updateMatrixWorld.call(this,a)};var $i=new p,yf,Ng;xb.prototype=Object.create(y.prototype);xb.prototype.constructor=xb;xb.prototype.setDirection=function(a){.99999<a.y?this.quaternion.set(0,0,0,1):-.99999>a.y?this.quaternion.set(1,0,0,0):($i.set(a.z,
25071 0,-a.x).normalize(),this.quaternion.setFromAxisAngle($i,Math.acos(a.y)))};xb.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(1E-4,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};xb.prototype.setColor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};xb.prototype.copy=function(a){y.prototype.copy.call(this,a,!1);this.line.copy(a.line);this.cone.copy(a.cone);
25072 return this};xb.prototype.clone=function(){return(new this.constructor).copy(this)};re.prototype=Object.create(ma.prototype);re.prototype.constructor=re;var nb=Math.pow(2,8),aj=[.125,.215,.35,.446,.526,.582],bj=5+aj.length,mb={3E3:0,3001:1,3002:2,3004:3,3005:4,3006:5,3007:6},oh=new fd,ph=function(){for(var a=[],b=[],c=[],d=8,e=0;e<bj;e++){var f=Math.pow(2,d);b.push(f);var g=1/f;4<e?g=aj[e-8+4-1]:0==e&&(g=0);c.push(g);g=1/(f-1);f=-g/2;g=1+g/2;var h=[f,f,g,f,g,g,f,f,g,g,f,g];f=new Float32Array(108);
25073 g=new Float32Array(72);for(var k=new Float32Array(36),m=0;6>m;m++){var p=m%3*2/3-1,n=2<m?0:-1;f.set([p,n,0,p+2/3,n,0,p+2/3,n+1,0,p,n,0,p+2/3,n+1,0,p,n+1,0],18*m);g.set(h,12*m);k.set([m,m,m,m,m,m],6*m)}h=new F;h.setAttribute("position",new G(f,3));h.setAttribute("uv",new G(g,2));h.setAttribute("faceIndex",new G(k,1));a.push(h);4<d&&d--}return{_lodPlanes:a,_sizeLods:b,_sigmas:c}}(),Ce=ph._lodPlanes,cj=ph._sizeLods,Wf=ph._sigmas,qh=null,yc=(1+Math.sqrt(5))/2,xd=1/yc,dj=[new p(1,1,1),new p(-1,1,1),new p(1,
25074 1,-1),new p(-1,1,-1),new p(0,yc,xd),new p(0,yc,-xd),new p(xd,0,yc),new p(-xd,0,yc),new p(yc,xd,0),new p(-yc,xd,0)];Og.prototype={constructor:Og,fromScene:function(a,b,c,d){void 0===b&&(b=0);void 0===c&&(c=.1);void 0===d&&(d=100);qh=this._renderer.getRenderTarget();var e=this._allocateTargets();this._sceneToCubeUV(a,c,d,e);0<b&&this._blur(e,0,0,b);this._applyPMREM(e);this._cleanup(e);return e},fromEquirectangular:function(a){a.magFilter=1003;a.minFilter=1003;a.generateMipmaps=!1;return this.fromCubemap(a)},
25075 fromCubemap:function(a){qh=this._renderer.getRenderTarget();var b=this._allocateTargets(a);this._textureToCubeUV(a,b);this._applyPMREM(b);this._cleanup(b);return b},compileCubemapShader:function(){null===this._cubemapShader&&(this._cubemapShader=qi(),this._compileMaterial(this._cubemapShader))},compileEquirectangularShader:function(){null===this._equirectShader&&(this._equirectShader=pi(),this._compileMaterial(this._equirectShader))},dispose:function(){this._blurMaterial.dispose();null!==this._cubemapShader&&
25076 this._cubemapShader.dispose();null!==this._equirectShader&&this._equirectShader.dispose();for(var a=0;a<Ce.length;a++)Ce[a].dispose()},_cleanup:function(a){this._pingPongRenderTarget.dispose();this._renderer.setRenderTarget(qh);a.scissorTest=!1;a.setSize(a.width,a.height)},_allocateTargets:function(a){var b=void 0===a||1009!==a.type?!1:3E3===a.encoding||3001===a.encoding||3007===a.encoding;b={magFilter:1003,minFilter:1003,generateMipmaps:!1,type:1009,format:1023,encoding:b?a.encoding:3002,depthBuffer:!1,
25077 stencilBuffer:!1};var c=oi(b);c.depthBuffer=a?!1:!0;this._pingPongRenderTarget=oi(b);return c},_compileMaterial:function(a){a=new ea(Ce[0],a);this._renderer.compile(a,oh)},_sceneToCubeUV:function(a,b,c,d){b=new P(90,1,b,c);c=[1,-1,1,1,1,1];var e=[1,1,1,-1,-1,-1],f=this._renderer,g=f.outputEncoding,h=f.toneMapping,k=f.toneMappingExposure,m=f.getClearColor(),p=f.getClearAlpha();f.toneMapping=1;f.toneMappingExposure=1;f.outputEncoding=3E3;var n=a.background;if(n&&n.isColor){n.convertSRGBToLinear();var t=
25078 Math.min(Math.max(Math.ceil(Math.log2(Math.max(n.r,n.g,n.b))),-128),127);n=n.multiplyScalar(Math.pow(2,-t));f.setClearColor(n,(t+128)/255);a.background=null}for(n=0;6>n;n++)t=n%3,0==t?(b.up.set(0,c[n],0),b.lookAt(e[n],0,0)):1==t?(b.up.set(0,0,c[n]),b.lookAt(0,e[n],0)):(b.up.set(0,c[n],0),b.lookAt(0,0,e[n])),Rg(d,t*nb,2<n?nb:0,nb,nb),f.setRenderTarget(d),f.render(a,b);f.toneMapping=h;f.toneMappingExposure=k;f.outputEncoding=g;f.setClearColor(m,p)},_textureToCubeUV:function(a,b){var c=this._renderer;
25079 a.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=qi()):null==this._equirectShader&&(this._equirectShader=pi());var d=a.isCubeTexture?this._cubemapShader:this._equirectShader,e=new ea(Ce[0],d);d=d.uniforms;d.envMap.value=a;a.isCubeTexture||d.texelSize.value.set(1/a.image.width,1/a.image.height);d.inputEncoding.value=mb[a.encoding];d.outputEncoding.value=mb[b.texture.encoding];Rg(b,0,0,3*nb,2*nb);c.setRenderTarget(b);c.render(e,oh)},_applyPMREM:function(a){var b=this._renderer,c=b.autoClear;
25080 b.autoClear=!1;for(var d=1;d<bj;d++)this._blur(a,d-1,d,Math.sqrt(Wf[d]*Wf[d]-Wf[d-1]*Wf[d-1]),dj[(d-1)%dj.length]);b.autoClear=c},_blur:function(a,b,c,d,e){var f=this._pingPongRenderTarget;this._halfBlur(a,f,b,c,d,"latitudinal",e);this._halfBlur(f,a,c,c,d,"longitudinal",e)},_halfBlur:function(a,b,c,d,e,f,g){var h=this._renderer,k=this._blurMaterial;"latitudinal"!==f&&"longitudinal"!==f&&console.error("blur direction must be either latitudinal or longitudinal!");var m=new ea(Ce[d],k);k=k.uniforms;
25081 var p=cj[c]-1;p=isFinite(e)?Math.PI/(2*p):2*Math.PI/39;var n=e/p,t=isFinite(e)?1+Math.floor(3*n):20;20<t&&console.warn("sigmaRadians, "+e+", is too large and will clip, as it requested "+t+" samples when the maximum is set to 20");e=[];for(var r=0,q=0;20>q;++q){var u=q/n;u=Math.exp(-u*u/2);e.push(u);0==q?r+=u:q<t&&(r+=2*u)}for(q=0;q<e.length;q++)e[q]/=r;k.envMap.value=a.texture;k.samples.value=t;k.weights.value=e;k.latitudinal.value="latitudinal"===f;g&&(k.poleAxis.value=g);k.dTheta.value=p;k.mipInt.value=
25082 8-c;k.inputEncoding.value=mb[a.texture.encoding];k.outputEncoding.value=mb[a.texture.encoding];a=cj[d];u=3*Math.max(0,nb-2*a);Rg(b,u,(0===d?0:2*nb)+2*a*(4<d?d-8+4:0),3*a,2*a);h.setRenderTarget(b);h.render(m,oh)}};H.create=function(a,b){console.log("THREE.Curve.create() has been deprecated");a.prototype=Object.create(H.prototype);a.prototype.constructor=a;a.prototype.getPoint=b;return a};Object.assign(vb.prototype,{createPointsGeometry:function(a){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
25083 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.");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 L,c=0,d=a.length;c<d;c++){var e=a[c];b.vertices.push(new p(e.x,
25084 e.y,e.z||0))}return b}});Object.assign(bb.prototype,{fromPoints:function(a){console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints().");return this.setFromPoints(a)}});ri.prototype=Object.create(qa.prototype);si.prototype=Object.create(qa.prototype);Sg.prototype=Object.create(qa.prototype);Object.assign(Sg.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},
25085 reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}});vf.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};pc.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")};Object.assign(V.prototype,{extractUrlBase:function(a){console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.");
25086 return lh.extractUrlBase(a)}});V.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}};Object.assign(sf.prototype,{setTexturePath:function(a){console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath().");return this.setResourcePath(a)}});Object.assign(Lg.prototype,{center:function(a){console.warn("THREE.Box2: .center() has been renamed to .getCenter().");
25087 return this.getCenter(a)},empty:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");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(Va.prototype,{center:function(a){console.warn("THREE.Box3: .center() has been renamed to .getCenter().");
25088 return this.getCenter(a)},empty:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");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().");
25089 return this.getSize(a)}});Object.assign(eb.prototype,{empty:function(){console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty().");return this.isEmpty()}});Gc.prototype.setFromMatrix=function(a){console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix().");return this.setFromProjectionMatrix(a)};Mg.prototype.center=function(a){console.warn("THREE.Line3: .center() has been renamed to .getCenter().");return this.getCenter(a)};Object.assign(O,{random16:function(){console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead.");
25090 return Math.random()},nearestPowerOfTwo:function(a){console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().");return O.floorPowerOfTwo(a)},nextPowerOfTwo:function(a){console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().");return O.ceilPowerOfTwo(a)}});Object.assign(ya.prototype,{flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");return this.toArray(a,b)},
25091 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.")},applyToBufferAttribute:function(a){console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}});
25092 Object.assign(N.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(){console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");return(new p).setFromMatrixColumn(this,
25093 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.");return a.applyMatrix4(this)},multiplyVector4:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");
25094 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.");return a.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},
25095 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.")},applyToBufferAttribute:function(a){console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},
25096 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)}});Wa.prototype.isIntersectionLine=function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");return this.intersectsLine(a)};va.prototype.multiplyVector3=
25097 function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return a.applyQuaternion(this)};Object.assign(Wb.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)},isIntersectionSphere:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");
25098 return this.intersectsSphere(a)}});Object.assign(pa.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().");return this.getMidpoint(a)},normal:function(a){console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");
25099 return this.getNormal(a)},plane:function(a){console.warn("THREE.Triangle: .plane() has been renamed to .getPlane().");return this.getPlane(a)}});Object.assign(pa,{barycoordFromPoint:function(a,b,c,d,e){console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");return pa.getBarycoord(a,b,c,d,e)},normal:function(a,b,c,d){console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");return pa.getNormal(a,b,c,d)}});Object.assign(Nb.prototype,{extractAllPoints:function(a){console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.");
25100 return this.extractPoints(a)},extrude:function(a){console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.");return new dc(this,a)},makeGeometry:function(a){console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");return new fc(this,a)}});Object.assign(v.prototype,{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().");
25101 return this.manhattanDistanceTo(a)},lengthManhattan:function(){console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(p.prototype,{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.")},
25102 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().");return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(b,
25103 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,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().");
25104 return this.manhattanLength()}});Object.assign(R.prototype,{fromAttribute:function(a,b,c){console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,b,c)},lengthManhattan:function(){console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(L.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.")},
25105 applyMatrix:function(a){console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().");return this.applyMatrix4(a)}});Object.assign(y.prototype,{getChildByName:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");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.");
25106 return this.translateOnAxis(b,a)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(a){console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4().");return this.applyMatrix4(a)}});Object.defineProperties(y.prototype,{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.");
25107 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.")}}});Object.assign(ea.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}});
25108 Object.defineProperties(ea.prototype,{drawMode:{get:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode.");return 0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}});Object.defineProperties(Nd.prototype,{objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels.");
25109 return this.levels}}});Object.defineProperty(Re.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}});Qe.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")};Object.defineProperty(H.prototype,"__arcLengthDivisions",{get:function(){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");return this.arcLengthDivisions},
25110 set:function(a){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");this.arcLengthDivisions=a}});P.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(S.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.");
25111 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.");
25112 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.");
25113 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(G.prototype,{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead.");
25114 return this.array.length}},dynamic:{get:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.");return 35048===this.usage},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.");this.setUsage(35048)}}});Object.assign(G.prototype,{setDynamic:function(a){console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead.");this.setUsage(!0===a?35048:35044);return this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},
25115 setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}});Object.assign(F.prototype,{addIndex:function(a){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");this.setIndex(a)},addAttribute:function(a,b,c){console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute().");return b&&b.isBufferAttribute||b&&b.isInterleavedBufferAttribute?"index"===
25116 a?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(b),this):this.setAttribute(a,b):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(a,new G(b,c)))},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)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");
25117 this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(a){console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute().");return this.deleteAttribute(a)},applyMatrix:function(a){console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4().");return this.applyMatrix4(a)}});
25118 Object.defineProperties(F.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.");return this.groups}}});Object.defineProperties(me.prototype,{maxInstancedCount:{get:function(){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount.");return this.instanceCount},set:function(a){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount.");
25119 this.instanceCount=a}}});Object.defineProperties(Jg.prototype,{linePrecision:{get:function(){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead.");return this.params.Line.threshold},set:function(a){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead.");this.params.Line.threshold=a}}});Object.defineProperties(rb.prototype,{dynamic:{get:function(){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.");
25120 return 35048===this.usage},set:function(a){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.");this.setUsage(a)}}});Object.assign(rb.prototype,{setDynamic:function(a){console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead.");this.setUsage(!0===a?35048:35044);return this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}});
25121 Object.assign(hb.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(uf.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.");
25122 return this}}});Object.defineProperties(K.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){console.warn("THREE.Material: .wrapRGB has been removed.");return new D}},shading:{get:function(){console.error("THREE."+
25123 this.type+": .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}},stencilMask:{get:function(){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead.");return this.stencilFuncMask},set:function(a){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead.");this.stencilFuncMask=
25124 a}}});Object.defineProperties(Mb.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")}}});Object.defineProperties(Ca.prototype,{derivatives:{get:function(){console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");return this.extensions.derivatives},
25125 set:function(a){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");this.extensions.derivatives=a}}});Object.assign(jg.prototype,{clearTarget:function(a,b,c,d){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead.");this.setRenderTarget(a);this.clear(b,c,d)},animate:function(a){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop().");this.setAnimationLoop(a)},getCurrentRenderTarget:function(){console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().");
25126 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' ).");
25127 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' ).");
25128 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.");
25129 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.")},
25130 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.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},
25131 setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel().");return this.getActiveMipmapLevel()}});Object.defineProperties(jg.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},
25132 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.")}},context:{get:function(){console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead.");return this.getContext()}},
25133 vr:{get:function(){console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr");return this.xr}},gammaInput:{get:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.");return!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.");
25134 return!1},set:function(a){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.");this.outputEncoding=!0===a?3001:3E3}}});Object.defineProperties(Rh.prototype,{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.")},
25135 set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},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(Ba.prototype,{wrapS:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");
25136 return this.texture.wrapS},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");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},
25137 set:function(a){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");this.texture.magFilter=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},
25138 set:function(a){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");this.texture.anisotropy=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.");
25139 this.texture.repeat=a}},format:{get:function(){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");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.");
25140 return this.texture.generateMipmaps},set:function(a){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");this.texture.generateMipmaps=a}}});Object.defineProperties(gd.prototype,{load:{value:function(a){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var b=this;(new tf).load(a,function(a){b.setBuffer(a)});return this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}});Fg.prototype.getData=
25141 function(){console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData().");return this.getFrequencyData()};Fc.prototype.updateCubeMap=function(a,b){console.warn("THREE.CubeCamera: .updateCubeMap() is now .update().");return this.update(a,b)};Ob.crossOrigin=void 0;Ob.loadTexture=function(a,b,c,d){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var e=new ef;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a};
25142 Ob.loadTextureCube=function(a,b,c,d){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var e=new df;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a};Ob.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")};Ob.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};
25143 "undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"117"}}));k.ACESFilmicToneMapping=5;k.AddEquation=100;k.AddOperation=2;k.AdditiveAnimationBlendMode=2501;k.AdditiveBlending=2;k.AlphaFormat=1021;k.AlwaysDepth=1;k.AlwaysStencilFunc=519;k.AmbientLight=mf;k.AmbientLightProbe=Ag;k.AnimationClip=Sa;k.AnimationLoader=rg;k.AnimationMixer=Hg;k.AnimationObjectGroup=ii;k.AnimationUtils=ka;k.ArcCurve=ed;k.ArrayCamera=Le;k.ArrowHelper=xb;k.Audio=
25144 gd;k.AudioAnalyser=Fg;k.AudioContext=Dg;k.AudioListener=Cg;k.AudioLoader=tf;k.AxesHelper=re;k.AxisHelper=function(a){console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper.");return new re(a)};k.BackSide=1;k.BasicDepthPacking=3200;k.BasicShadowMap=0;k.BinaryTextureLoader=function(a){console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader.");return new cf(a)};k.Bone=kg;k.BooleanKeyframeTrack=Ze;k.BoundingBoxHelper=function(a,b){console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.");
25145 return new wb(a,b)};k.Box2=Lg;k.Box3=Va;k.Box3Helper=pe;k.BoxBufferGeometry=Gd;k.BoxGeometry=fh;k.BoxHelper=wb;k.BufferAttribute=G;k.BufferGeometry=F;k.BufferGeometryLoader=rf;k.ByteType=1010;k.Cache=tc;k.Camera=fb;k.CameraHelper=oe;k.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")};k.CanvasTexture=Od;k.CatmullRomCurve3=qa;k.CineonToneMapping=4;k.CircleBufferGeometry=ad;k.CircleGeometry=he;k.ClampToEdgeWrapping=1001;k.Clock=Bg;k.ClosedSplineCurve3=ri;k.Color=D;k.ColorKeyframeTrack=
25146 $e;k.CompressedTexture=Oc;k.CompressedTextureLoader=sg;k.ConeBufferGeometry=ge;k.ConeGeometry=fe;k.CubeCamera=Fc;k.CubeGeometry=fh;k.CubeReflectionMapping=301;k.CubeRefractionMapping=302;k.CubeTexture=qb;k.CubeTextureLoader=df;k.CubeUVReflectionMapping=306;k.CubeUVRefractionMapping=307;k.CubicBezierCurve=Ya;k.CubicBezierCurve3=jb;k.CubicInterpolant=Xe;k.CullFaceBack=1;k.CullFaceFront=2;k.CullFaceFrontBack=3;k.CullFaceNone=0;k.Curve=H;k.CurvePath=vb;k.CustomBlending=5;k.CylinderBufferGeometry=tb;k.CylinderGeometry=
25147 hc;k.Cylindrical=mi;k.DataTexture=$b;k.DataTexture2DArray=Hc;k.DataTexture3D=Ic;k.DataTextureLoader=cf;k.DecrementStencilOp=7683;k.DecrementWrapStencilOp=34056;k.DefaultLoadingManager=ei;k.DepthFormat=1026;k.DepthStencilFormat=1027;k.DepthTexture=Pd;k.DirectionalLight=lf;k.DirectionalLightHelper=kd;k.DirectionalLightShadow=kf;k.DiscreteInterpolant=Ye;k.DodecahedronBufferGeometry=Tc;k.DodecahedronGeometry=Vd;k.DoubleSide=2;k.DstAlphaFactor=206;k.DstColorFactor=208;k.DynamicBufferAttribute=function(a,
25148 b){console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead.");return(new G(a,b)).setUsage(35048)};k.DynamicCopyUsage=35050;k.DynamicDrawUsage=35048;k.DynamicReadUsage=35049;k.EdgesGeometry=$c;k.EdgesHelper=function(a,b){console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.");return new ma(new $c(a.geometry),new da({color:void 0!==b?b:16777215}))};k.EllipseCurve=Na;k.EqualDepth=4;k.EqualStencilFunc=
25149 514;k.EquirectangularReflectionMapping=303;k.EquirectangularRefractionMapping=304;k.Euler=Ub;k.EventDispatcher=ua;k.ExtrudeBufferGeometry=hb;k.ExtrudeGeometry=dc;k.Face3=Ac;k.Face4=function(a,b,c,d,e,f,g){console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead.");return new Ac(a,b,c,e,f,g)};k.FaceColors=1;k.FileLoader=Ta;k.FlatShading=1;k.Float32Attribute=function(a,b){console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.");
25150 return new B(a,b)};k.Float32BufferAttribute=B;k.Float64Attribute=function(a,b){console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.");return new Dd(a,b)};k.Float64BufferAttribute=Dd;k.FloatType=1015;k.Fog=Oe;k.FogExp2=Ne;k.Font=xg;k.FontLoader=yg;k.FrontFaceDirectionCCW=1;k.FrontFaceDirectionCW=0;k.FrontSide=0;k.Frustum=Gc;k.GammaEncoding=3007;k.Geometry=L;k.GeometryUtils={merge:function(a,b,c){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");
25151 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.");return a.center()}};k.GreaterDepth=6;k.GreaterEqualDepth=5;k.GreaterEqualStencilFunc=518;k.GreaterStencilFunc=516;k.GridHelper=vf;k.Group=Kc;k.HalfFloatType=1016;k.HemisphereLight=ff;k.HemisphereLightHelper=jd;k.HemisphereLightProbe=zg;k.IcosahedronBufferGeometry=Sc;k.IcosahedronGeometry=
25152 Ud;k.ImageBitmapLoader=vg;k.ImageLoader=dd;k.ImageUtils=Ob;k.ImmediateRenderObject=ne;k.IncrementStencilOp=7682;k.IncrementWrapStencilOp=34055;k.InstancedBufferAttribute=qf;k.InstancedBufferGeometry=me;k.InstancedInterleavedBuffer=Ig;k.InstancedMesh=Se;k.Int16Attribute=function(a,b){console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.");return new Bd(a,b)};k.Int16BufferAttribute=Bd;k.Int32Attribute=function(a,b){console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.");
25153 return new Cd(a,b)};k.Int32BufferAttribute=Cd;k.Int8Attribute=function(a,b){console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.");return new yd(a,b)};k.Int8BufferAttribute=yd;k.IntType=1013;k.InterleavedBuffer=rb;k.InterleavedBufferAttribute=Kd;k.Interpolant=Ma;k.InterpolateDiscrete=2300;k.InterpolateLinear=2301;k.InterpolateSmooth=2302;k.InvertStencilOp=5386;k.JSONLoader=function(){console.error("THREE.JSONLoader has been removed.")};k.KeepStencilOp=7680;
25154 k.KeyframeTrack=ta;k.LOD=Nd;k.LatheBufferGeometry=Zc;k.LatheGeometry=ee;k.Layers=De;k.LensFlare=function(){console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js")};k.LessDepth=2;k.LessEqualDepth=3;k.LessEqualStencilFunc=515;k.LessStencilFunc=513;k.Light=S;k.LightProbe=Ua;k.LightShadow=lb;k.Line=La;k.Line3=Mg;k.LineBasicMaterial=da;k.LineCurve=Ia;k.LineCurve3=Za;k.LineDashedMaterial=oc;k.LineLoop=Te;k.LinePieces=1;k.LineSegments=ma;k.LineStrip=0;k.LinearEncoding=3E3;k.LinearFilter=
25155 1006;k.LinearInterpolant=ie;k.LinearMipMapLinearFilter=1008;k.LinearMipMapNearestFilter=1007;k.LinearMipmapLinearFilter=1008;k.LinearMipmapNearestFilter=1007;k.LinearToneMapping=1;k.Loader=V;k.LoaderUtils=lh;k.LoadingManager=qg;k.LogLuvEncoding=3003;k.LoopOnce=2200;k.LoopPingPong=2202;k.LoopRepeat=2201;k.LuminanceAlphaFormat=1025;k.LuminanceFormat=1024;k.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2};k.Material=K;k.MaterialLoader=pf;k.Math=O;k.MathUtils=O;k.Matrix3=ya;k.Matrix4=N;k.MaxEquation=
25156 104;k.Mesh=ea;k.MeshBasicMaterial=Pa;k.MeshDepthMaterial=Hb;k.MeshDistanceMaterial=Ib;k.MeshFaceMaterial=function(a){console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead.");return a};k.MeshLambertMaterial=mc;k.MeshMatcapMaterial=nc;k.MeshNormalMaterial=lc;k.MeshPhongMaterial=Mb;k.MeshPhysicalMaterial=jc;k.MeshStandardMaterial=ib;k.MeshToonMaterial=kc;k.MinEquation=103;k.MirroredRepeatWrapping=1002;k.MixOperation=1;k.MultiMaterial=function(a){void 0===a&&(a=[]);console.warn("THREE.MultiMaterial has been removed. Use an Array instead.");
25157 a.isMultiMaterial=!0;a.materials=a;a.clone=function(){return a.slice()};return a};k.MultiplyBlending=4;k.MultiplyOperation=0;k.NearestFilter=1003;k.NearestMipMapLinearFilter=1005;k.NearestMipMapNearestFilter=1004;k.NearestMipmapLinearFilter=1005;k.NearestMipmapNearestFilter=1004;k.NeverDepth=0;k.NeverStencilFunc=512;k.NoBlending=0;k.NoColors=0;k.NoToneMapping=0;k.NormalAnimationBlendMode=2500;k.NormalBlending=1;k.NotEqualDepth=7;k.NotEqualStencilFunc=517;k.NumberKeyframeTrack=bd;k.Object3D=y;k.ObjectLoader=
25158 sf;k.ObjectSpaceNormalMap=1;k.OctahedronBufferGeometry=bc;k.OctahedronGeometry=Td;k.OneFactor=201;k.OneMinusDstAlphaFactor=207;k.OneMinusDstColorFactor=209;k.OneMinusSrcAlphaFactor=205;k.OneMinusSrcColorFactor=203;k.OrthographicCamera=fd;k.PCFShadowMap=1;k.PCFSoftShadowMap=2;k.PMREMGenerator=Og;k.ParametricBufferGeometry=Qc;k.ParametricGeometry=Qd;k.Particle=function(a){console.warn("THREE.Particle has been renamed to THREE.Sprite.");return new Ld(a)};k.ParticleBasicMaterial=function(a){console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.");
25159 return new Xa(a)};k.ParticleSystem=function(a,b){console.warn("THREE.ParticleSystem has been renamed to THREE.Points.");return new Nc(a,b)};k.ParticleSystemMaterial=function(a){console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.");return new Xa(a)};k.Path=bb;k.PerspectiveCamera=P;k.Plane=Wa;k.PlaneBufferGeometry=ac;k.PlaneGeometry=Fd;k.PlaneHelper=qe;k.PointCloud=function(a,b){console.warn("THREE.PointCloud has been renamed to THREE.Points.");return new Nc(a,b)};k.PointCloudMaterial=
25160 function(a){console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.");return new Xa(a)};k.PointLight=jf;k.PointLightHelper=id;k.Points=Nc;k.PointsMaterial=Xa;k.PolarGridHelper=wf;k.PolyhedronBufferGeometry=Ga;k.PolyhedronGeometry=Rd;k.PositionalAudio=Eg;k.PropertyBinding=Aa;k.PropertyMixer=Gg;k.QuadraticBezierCurve=$a;k.QuadraticBezierCurve3=kb;k.Quaternion=va;k.QuaternionKeyframeTrack=je;k.QuaternionLinearInterpolant=af;k.REVISION="117";k.RGBADepthPacking=3201;k.RGBAFormat=
25161 1023;k.RGBAIntegerFormat=1033;k.RGBA_ASTC_10x10_Format=37819;k.RGBA_ASTC_10x5_Format=37816;k.RGBA_ASTC_10x6_Format=37817;k.RGBA_ASTC_10x8_Format=37818;k.RGBA_ASTC_12x10_Format=37820;k.RGBA_ASTC_12x12_Format=37821;k.RGBA_ASTC_4x4_Format=37808;k.RGBA_ASTC_5x4_Format=37809;k.RGBA_ASTC_5x5_Format=37810;k.RGBA_ASTC_6x5_Format=37811;k.RGBA_ASTC_6x6_Format=37812;k.RGBA_ASTC_8x5_Format=37813;k.RGBA_ASTC_8x6_Format=37814;k.RGBA_ASTC_8x8_Format=37815;k.RGBA_BPTC_Format=36492;k.RGBA_ETC2_EAC_Format=37496;k.RGBA_PVRTC_2BPPV1_Format=
25162 35843;k.RGBA_PVRTC_4BPPV1_Format=35842;k.RGBA_S3TC_DXT1_Format=33777;k.RGBA_S3TC_DXT3_Format=33778;k.RGBA_S3TC_DXT5_Format=33779;k.RGBDEncoding=3006;k.RGBEEncoding=3002;k.RGBEFormat=1023;k.RGBFormat=1022;k.RGBIntegerFormat=1032;k.RGBM16Encoding=3005;k.RGBM7Encoding=3004;k.RGB_ETC1_Format=36196;k.RGB_ETC2_Format=37492;k.RGB_PVRTC_2BPPV1_Format=35841;k.RGB_PVRTC_4BPPV1_Format=35840;k.RGB_S3TC_DXT1_Format=33776;k.RGFormat=1030;k.RGIntegerFormat=1031;k.RawShaderMaterial=ub;k.Ray=Wb;k.Raycaster=Jg;k.RectAreaLight=
25163 nf;k.RedFormat=1028;k.RedIntegerFormat=1029;k.ReinhardToneMapping=2;k.RepeatWrapping=1E3;k.ReplaceStencilOp=7681;k.ReverseSubtractEquation=102;k.RingBufferGeometry=Yc;k.RingGeometry=de;k.SRGB8_ALPHA8_ASTC_10x10_Format=37851;k.SRGB8_ALPHA8_ASTC_10x5_Format=37848;k.SRGB8_ALPHA8_ASTC_10x6_Format=37849;k.SRGB8_ALPHA8_ASTC_10x8_Format=37850;k.SRGB8_ALPHA8_ASTC_12x10_Format=37852;k.SRGB8_ALPHA8_ASTC_12x12_Format=37853;k.SRGB8_ALPHA8_ASTC_4x4_Format=37840;k.SRGB8_ALPHA8_ASTC_5x4_Format=37841;k.SRGB8_ALPHA8_ASTC_5x5_Format=
25164 37842;k.SRGB8_ALPHA8_ASTC_6x5_Format=37843;k.SRGB8_ALPHA8_ASTC_6x6_Format=37844;k.SRGB8_ALPHA8_ASTC_8x5_Format=37845;k.SRGB8_ALPHA8_ASTC_8x6_Format=37846;k.SRGB8_ALPHA8_ASTC_8x8_Format=37847;k.Scene=zc;k.SceneUtils={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")}};
25165 k.ShaderChunk=M;k.ShaderLib=gb;k.ShaderMaterial=Ca;k.ShadowMaterial=ic;k.Shape=Nb;k.ShapeBufferGeometry=gc;k.ShapeGeometry=fc;k.ShapePath=wg;k.ShapeUtils=sb;k.ShortType=1011;k.Skeleton=Re;k.SkeletonHelper=pc;k.SkinnedMesh=Qe;k.SmoothShading=2;k.Sphere=eb;k.SphereBufferGeometry=ec;k.SphereGeometry=ce;k.Spherical=li;k.SphericalHarmonics3=of;k.SphericalReflectionMapping=305;k.Spline=Sg;k.SplineCurve=ab;k.SplineCurve3=si;k.SpotLight=hf;k.SpotLightHelper=hd;k.SpotLightShadow=gf;k.Sprite=Ld;k.SpriteMaterial=
25166 Kb;k.SrcAlphaFactor=204;k.SrcAlphaSaturateFactor=210;k.SrcColorFactor=202;k.StaticCopyUsage=35046;k.StaticDrawUsage=35044;k.StaticReadUsage=35045;k.StereoCamera=gi;k.StreamCopyUsage=35042;k.StreamDrawUsage=35040;k.StreamReadUsage=35041;k.StringKeyframeTrack=bf;k.SubtractEquation=101;k.SubtractiveBlending=3;k.TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3};k.TangentSpaceNormalMap=0;k.TetrahedronBufferGeometry=Rc;k.TetrahedronGeometry=Sd;k.TextBufferGeometry=Xc;k.TextGeometry=be;k.Texture=W;k.TextureLoader=
25167 ef;k.TorusBufferGeometry=Vc;k.TorusGeometry=Yd;k.TorusKnotBufferGeometry=Uc;k.TorusKnotGeometry=Xd;k.Triangle=pa;k.TriangleFanDrawMode=2;k.TriangleStripDrawMode=1;k.TrianglesDrawMode=0;k.TubeBufferGeometry=cc;k.TubeGeometry=Wd;k.UVMapping=300;k.Uint16Attribute=function(a,b){console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.");return new Xb(a,b)};k.Uint16BufferAttribute=Xb;k.Uint32Attribute=function(a,b){console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.");
25168 return new Yb(a,b)};k.Uint32BufferAttribute=Yb;k.Uint8Attribute=function(a,b){console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.");return new zd(a,b)};k.Uint8BufferAttribute=zd;k.Uint8ClampedAttribute=function(a,b){console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.");return new Ad(a,b)};k.Uint8ClampedBufferAttribute=Ad;k.Uncharted2ToneMapping=3;k.Uniform=uf;k.UniformsLib=A;k.UniformsUtils=
25169 Oh;k.UnsignedByteType=1009;k.UnsignedInt248Type=1020;k.UnsignedIntType=1014;k.UnsignedShort4444Type=1017;k.UnsignedShort5551Type=1018;k.UnsignedShort565Type=1019;k.UnsignedShortType=1012;k.VSMShadowMap=3;k.Vector2=v;k.Vector3=p;k.Vector4=R;k.VectorKeyframeTrack=cd;k.Vertex=function(a,b,c){console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead.");return new p(a,b,c)};k.VertexColors=2;k.VideoTexture=ng;k.WebGLCubeRenderTarget=Zb;k.WebGLMultisampleRenderTarget=Xf;k.WebGLRenderTarget=
25170 Ba;k.WebGLRenderTargetCube=function(a,b,c){console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options ).");return new Zb(a,c)};k.WebGLRenderer=jg;k.WebGLUtils=Th;k.WireframeGeometry=Pc;k.WireframeHelper=function(a,b){console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.");return new ma(new Pc(a.geometry),new da({color:void 0!==b?b:16777215}))};k.WrapAroundEnding=2402;k.XHRLoader=function(a){console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader.");
25171 return new Ta(a)};k.ZeroCurvatureEnding=2400;k.ZeroFactor=200;k.ZeroSlopeEnding=2401;k.ZeroStencilOp=0;k.sRGBEncoding=3001;Object.defineProperty(k,"__esModule",{value:!0})});
25173 },{}],243:[function(require,module,exports){
25176 module.exports = TinyQueue;
25178 function TinyQueue(data, compare) {
25179 if (!(this instanceof TinyQueue)) return new TinyQueue(data, compare);
25181 this.data = data || [];
25182 this.length = this.data.length;
25183 this.compare = compare || defaultCompare;
25185 if (this.length > 0) {
25186 for (var i = (this.length >> 1); i >= 0; i--) this._down(i);
25190 function defaultCompare(a, b) {
25191 return a < b ? -1 : a > b ? 1 : 0;
25194 TinyQueue.prototype = {
25196 push: function (item) {
25197 this.data.push(item);
25199 this._up(this.length - 1);
25203 if (this.length === 0) return undefined;
25204 var top = this.data[0];
25206 if (this.length > 0) {
25207 this.data[0] = this.data[this.length];
25214 peek: function () {
25215 return this.data[0];
25218 _up: function (pos) {
25219 var data = this.data;
25220 var compare = this.compare;
25221 var item = data[pos];
25224 var parent = (pos - 1) >> 1;
25225 var current = data[parent];
25226 if (compare(item, current) >= 0) break;
25227 data[pos] = current;
25234 _down: function (pos) {
25235 var data = this.data;
25236 var compare = this.compare;
25237 var len = this.length;
25238 var halfLen = len >> 1;
25239 var item = data[pos];
25241 while (pos < halfLen) {
25242 var left = (pos << 1) + 1;
25243 var right = left + 1;
25244 var best = data[left];
25246 if (right < len && compare(data[right], best) < 0) {
25248 best = data[right];
25250 if (compare(best, item) >= 0) break;
25260 },{}],244:[function(require,module,exports){
25261 var createElement = require("./vdom/create-element.js")
25263 module.exports = createElement
25265 },{"./vdom/create-element.js":250}],245:[function(require,module,exports){
25266 var diff = require("./vtree/diff.js")
25268 module.exports = diff
25270 },{"./vtree/diff.js":270}],246:[function(require,module,exports){
25271 var h = require("./virtual-hyperscript/index.js")
25275 },{"./virtual-hyperscript/index.js":257}],247:[function(require,module,exports){
25276 var diff = require("./diff.js")
25277 var patch = require("./patch.js")
25278 var h = require("./h.js")
25279 var create = require("./create-element.js")
25280 var VNode = require('./vnode/vnode.js')
25281 var VText = require('./vnode/vtext.js')
25292 },{"./create-element.js":244,"./diff.js":245,"./h.js":246,"./patch.js":248,"./vnode/vnode.js":266,"./vnode/vtext.js":268}],248:[function(require,module,exports){
25293 var patch = require("./vdom/patch.js")
25295 module.exports = patch
25297 },{"./vdom/patch.js":253}],249:[function(require,module,exports){
25298 var isObject = require("is-object")
25299 var isHook = require("../vnode/is-vhook.js")
25301 module.exports = applyProperties
25303 function applyProperties(node, props, previous) {
25304 for (var propName in props) {
25305 var propValue = props[propName]
25307 if (propValue === undefined) {
25308 removeProperty(node, propName, propValue, previous);
25309 } else if (isHook(propValue)) {
25310 removeProperty(node, propName, propValue, previous)
25311 if (propValue.hook) {
25312 propValue.hook(node,
25314 previous ? previous[propName] : undefined)
25317 if (isObject(propValue)) {
25318 patchObject(node, props, previous, propName, propValue);
25320 node[propName] = propValue
25326 function removeProperty(node, propName, propValue, previous) {
25328 var previousValue = previous[propName]
25330 if (!isHook(previousValue)) {
25331 if (propName === "attributes") {
25332 for (var attrName in previousValue) {
25333 node.removeAttribute(attrName)
25335 } else if (propName === "style") {
25336 for (var i in previousValue) {
25339 } else if (typeof previousValue === "string") {
25340 node[propName] = ""
25342 node[propName] = null
25344 } else if (previousValue.unhook) {
25345 previousValue.unhook(node, propName, propValue)
25350 function patchObject(node, props, previous, propName, propValue) {
25351 var previousValue = previous ? previous[propName] : undefined
25354 if (propName === "attributes") {
25355 for (var attrName in propValue) {
25356 var attrValue = propValue[attrName]
25358 if (attrValue === undefined) {
25359 node.removeAttribute(attrName)
25361 node.setAttribute(attrName, attrValue)
25368 if(previousValue && isObject(previousValue) &&
25369 getPrototype(previousValue) !== getPrototype(propValue)) {
25370 node[propName] = propValue
25374 if (!isObject(node[propName])) {
25375 node[propName] = {}
25378 var replacer = propName === "style" ? "" : undefined
25380 for (var k in propValue) {
25381 var value = propValue[k]
25382 node[propName][k] = (value === undefined) ? replacer : value
25386 function getPrototype(value) {
25387 if (Object.getPrototypeOf) {
25388 return Object.getPrototypeOf(value)
25389 } else if (value.__proto__) {
25390 return value.__proto__
25391 } else if (value.constructor) {
25392 return value.constructor.prototype
25396 },{"../vnode/is-vhook.js":261,"is-object":20}],250:[function(require,module,exports){
25397 var document = require("global/document")
25399 var applyProperties = require("./apply-properties")
25401 var isVNode = require("../vnode/is-vnode.js")
25402 var isVText = require("../vnode/is-vtext.js")
25403 var isWidget = require("../vnode/is-widget.js")
25404 var handleThunk = require("../vnode/handle-thunk.js")
25406 module.exports = createElement
25408 function createElement(vnode, opts) {
25409 var doc = opts ? opts.document || document : document
25410 var warn = opts ? opts.warn : null
25412 vnode = handleThunk(vnode).a
25414 if (isWidget(vnode)) {
25415 return vnode.init()
25416 } else if (isVText(vnode)) {
25417 return doc.createTextNode(vnode.text)
25418 } else if (!isVNode(vnode)) {
25420 warn("Item is not a valid virtual dom node", vnode)
25425 var node = (vnode.namespace === null) ?
25426 doc.createElement(vnode.tagName) :
25427 doc.createElementNS(vnode.namespace, vnode.tagName)
25429 var props = vnode.properties
25430 applyProperties(node, props)
25432 var children = vnode.children
25434 for (var i = 0; i < children.length; i++) {
25435 var childNode = createElement(children[i], opts)
25437 node.appendChild(childNode)
25444 },{"../vnode/handle-thunk.js":259,"../vnode/is-vnode.js":262,"../vnode/is-vtext.js":263,"../vnode/is-widget.js":264,"./apply-properties":249,"global/document":16}],251:[function(require,module,exports){
25445 // Maps a virtual DOM tree onto a real DOM tree in an efficient manner.
25446 // We don't want to read all of the DOM nodes in the tree so we use
25447 // the in-order tree indexing to eliminate recursion down certain branches.
25448 // We only recurse into a DOM node if we know that it contains a child of
25453 module.exports = domIndex
25455 function domIndex(rootNode, tree, indices, nodes) {
25456 if (!indices || indices.length === 0) {
25459 indices.sort(ascending)
25460 return recurse(rootNode, tree, indices, nodes, 0)
25464 function recurse(rootNode, tree, indices, nodes, rootIndex) {
25465 nodes = nodes || {}
25469 if (indexInRange(indices, rootIndex, rootIndex)) {
25470 nodes[rootIndex] = rootNode
25473 var vChildren = tree.children
25477 var childNodes = rootNode.childNodes
25479 for (var i = 0; i < tree.children.length; i++) {
25482 var vChild = vChildren[i] || noChild
25483 var nextIndex = rootIndex + (vChild.count || 0)
25485 // skip recursion down the tree if there are no nodes down here
25486 if (indexInRange(indices, rootIndex, nextIndex)) {
25487 recurse(childNodes[i], vChild, indices, nodes, rootIndex)
25490 rootIndex = nextIndex
25498 // Binary search for an index in the interval [left, right]
25499 function indexInRange(indices, left, right) {
25500 if (indices.length === 0) {
25505 var maxIndex = indices.length - 1
25509 while (minIndex <= maxIndex) {
25510 currentIndex = ((maxIndex + minIndex) / 2) >> 0
25511 currentItem = indices[currentIndex]
25513 if (minIndex === maxIndex) {
25514 return currentItem >= left && currentItem <= right
25515 } else if (currentItem < left) {
25516 minIndex = currentIndex + 1
25517 } else if (currentItem > right) {
25518 maxIndex = currentIndex - 1
25527 function ascending(a, b) {
25528 return a > b ? 1 : -1
25531 },{}],252:[function(require,module,exports){
25532 var applyProperties = require("./apply-properties")
25534 var isWidget = require("../vnode/is-widget.js")
25535 var VPatch = require("../vnode/vpatch.js")
25537 var updateWidget = require("./update-widget")
25539 module.exports = applyPatch
25541 function applyPatch(vpatch, domNode, renderOptions) {
25542 var type = vpatch.type
25543 var vNode = vpatch.vNode
25544 var patch = vpatch.patch
25547 case VPatch.REMOVE:
25548 return removeNode(domNode, vNode)
25549 case VPatch.INSERT:
25550 return insertNode(domNode, patch, renderOptions)
25552 return stringPatch(domNode, vNode, patch, renderOptions)
25553 case VPatch.WIDGET:
25554 return widgetPatch(domNode, vNode, patch, renderOptions)
25556 return vNodePatch(domNode, vNode, patch, renderOptions)
25558 reorderChildren(domNode, patch)
25561 applyProperties(domNode, patch, vNode.properties)
25564 return replaceRoot(domNode,
25565 renderOptions.patch(domNode, patch, renderOptions))
25571 function removeNode(domNode, vNode) {
25572 var parentNode = domNode.parentNode
25575 parentNode.removeChild(domNode)
25578 destroyWidget(domNode, vNode);
25583 function insertNode(parentNode, vNode, renderOptions) {
25584 var newNode = renderOptions.render(vNode, renderOptions)
25587 parentNode.appendChild(newNode)
25593 function stringPatch(domNode, leftVNode, vText, renderOptions) {
25596 if (domNode.nodeType === 3) {
25597 domNode.replaceData(0, domNode.length, vText.text)
25600 var parentNode = domNode.parentNode
25601 newNode = renderOptions.render(vText, renderOptions)
25603 if (parentNode && newNode !== domNode) {
25604 parentNode.replaceChild(newNode, domNode)
25611 function widgetPatch(domNode, leftVNode, widget, renderOptions) {
25612 var updating = updateWidget(leftVNode, widget)
25616 newNode = widget.update(leftVNode, domNode) || domNode
25618 newNode = renderOptions.render(widget, renderOptions)
25621 var parentNode = domNode.parentNode
25623 if (parentNode && newNode !== domNode) {
25624 parentNode.replaceChild(newNode, domNode)
25628 destroyWidget(domNode, leftVNode)
25634 function vNodePatch(domNode, leftVNode, vNode, renderOptions) {
25635 var parentNode = domNode.parentNode
25636 var newNode = renderOptions.render(vNode, renderOptions)
25638 if (parentNode && newNode !== domNode) {
25639 parentNode.replaceChild(newNode, domNode)
25645 function destroyWidget(domNode, w) {
25646 if (typeof w.destroy === "function" && isWidget(w)) {
25651 function reorderChildren(domNode, moves) {
25652 var childNodes = domNode.childNodes
25658 for (var i = 0; i < moves.removes.length; i++) {
25659 remove = moves.removes[i]
25660 node = childNodes[remove.from]
25662 keyMap[remove.key] = node
25664 domNode.removeChild(node)
25667 var length = childNodes.length
25668 for (var j = 0; j < moves.inserts.length; j++) {
25669 insert = moves.inserts[j]
25670 node = keyMap[insert.key]
25671 // this is the weirdest bug i've ever seen in webkit
25672 domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to])
25676 function replaceRoot(oldRoot, newRoot) {
25677 if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {
25678 oldRoot.parentNode.replaceChild(newRoot, oldRoot)
25684 },{"../vnode/is-widget.js":264,"../vnode/vpatch.js":267,"./apply-properties":249,"./update-widget":254}],253:[function(require,module,exports){
25685 var document = require("global/document")
25686 var isArray = require("x-is-array")
25688 var render = require("./create-element")
25689 var domIndex = require("./dom-index")
25690 var patchOp = require("./patch-op")
25691 module.exports = patch
25693 function patch(rootNode, patches, renderOptions) {
25694 renderOptions = renderOptions || {}
25695 renderOptions.patch = renderOptions.patch && renderOptions.patch !== patch
25696 ? renderOptions.patch
25698 renderOptions.render = renderOptions.render || render
25700 return renderOptions.patch(rootNode, patches, renderOptions)
25703 function patchRecursive(rootNode, patches, renderOptions) {
25704 var indices = patchIndices(patches)
25706 if (indices.length === 0) {
25710 var index = domIndex(rootNode, patches.a, indices)
25711 var ownerDocument = rootNode.ownerDocument
25713 if (!renderOptions.document && ownerDocument !== document) {
25714 renderOptions.document = ownerDocument
25717 for (var i = 0; i < indices.length; i++) {
25718 var nodeIndex = indices[i]
25719 rootNode = applyPatch(rootNode,
25721 patches[nodeIndex],
25728 function applyPatch(rootNode, domNode, patchList, renderOptions) {
25735 if (isArray(patchList)) {
25736 for (var i = 0; i < patchList.length; i++) {
25737 newNode = patchOp(patchList[i], domNode, renderOptions)
25739 if (domNode === rootNode) {
25744 newNode = patchOp(patchList, domNode, renderOptions)
25746 if (domNode === rootNode) {
25754 function patchIndices(patches) {
25757 for (var key in patches) {
25759 indices.push(Number(key))
25766 },{"./create-element":250,"./dom-index":251,"./patch-op":252,"global/document":16,"x-is-array":289}],254:[function(require,module,exports){
25767 var isWidget = require("../vnode/is-widget.js")
25769 module.exports = updateWidget
25771 function updateWidget(a, b) {
25772 if (isWidget(a) && isWidget(b)) {
25773 if ("name" in a && "name" in b) {
25774 return a.id === b.id
25776 return a.init === b.init
25783 },{"../vnode/is-widget.js":264}],255:[function(require,module,exports){
25786 var EvStore = require('ev-store');
25788 module.exports = EvHook;
25790 function EvHook(value) {
25791 if (!(this instanceof EvHook)) {
25792 return new EvHook(value);
25795 this.value = value;
25798 EvHook.prototype.hook = function (node, propertyName) {
25799 var es = EvStore(node);
25800 var propName = propertyName.substr(3);
25802 es[propName] = this.value;
25805 EvHook.prototype.unhook = function(node, propertyName) {
25806 var es = EvStore(node);
25807 var propName = propertyName.substr(3);
25809 es[propName] = undefined;
25812 },{"ev-store":9}],256:[function(require,module,exports){
25815 module.exports = SoftSetHook;
25817 function SoftSetHook(value) {
25818 if (!(this instanceof SoftSetHook)) {
25819 return new SoftSetHook(value);
25822 this.value = value;
25825 SoftSetHook.prototype.hook = function (node, propertyName) {
25826 if (node[propertyName] !== this.value) {
25827 node[propertyName] = this.value;
25831 },{}],257:[function(require,module,exports){
25834 var isArray = require('x-is-array');
25836 var VNode = require('../vnode/vnode.js');
25837 var VText = require('../vnode/vtext.js');
25838 var isVNode = require('../vnode/is-vnode');
25839 var isVText = require('../vnode/is-vtext');
25840 var isWidget = require('../vnode/is-widget');
25841 var isHook = require('../vnode/is-vhook');
25842 var isVThunk = require('../vnode/is-thunk');
25844 var parseTag = require('./parse-tag.js');
25845 var softSetHook = require('./hooks/soft-set-hook.js');
25846 var evHook = require('./hooks/ev-hook.js');
25848 module.exports = h;
25850 function h(tagName, properties, children) {
25851 var childNodes = [];
25852 var tag, props, key, namespace;
25854 if (!children && isChildren(properties)) {
25855 children = properties;
25859 props = props || properties || {};
25860 tag = parseTag(tagName, props);
25863 if (props.hasOwnProperty('key')) {
25865 props.key = undefined;
25868 // support namespace
25869 if (props.hasOwnProperty('namespace')) {
25870 namespace = props.namespace;
25871 props.namespace = undefined;
25875 if (tag === 'INPUT' &&
25877 props.hasOwnProperty('value') &&
25878 props.value !== undefined &&
25879 !isHook(props.value)
25881 props.value = softSetHook(props.value);
25884 transformProperties(props);
25886 if (children !== undefined && children !== null) {
25887 addChild(children, childNodes, tag, props);
25891 return new VNode(tag, props, childNodes, key, namespace);
25894 function addChild(c, childNodes, tag, props) {
25895 if (typeof c === 'string') {
25896 childNodes.push(new VText(c));
25897 } else if (typeof c === 'number') {
25898 childNodes.push(new VText(String(c)));
25899 } else if (isChild(c)) {
25900 childNodes.push(c);
25901 } else if (isArray(c)) {
25902 for (var i = 0; i < c.length; i++) {
25903 addChild(c[i], childNodes, tag, props);
25905 } else if (c === null || c === undefined) {
25908 throw UnexpectedVirtualElement({
25918 function transformProperties(props) {
25919 for (var propName in props) {
25920 if (props.hasOwnProperty(propName)) {
25921 var value = props[propName];
25923 if (isHook(value)) {
25927 if (propName.substr(0, 3) === 'ev-') {
25928 // add ev-foo support
25929 props[propName] = evHook(value);
25935 function isChild(x) {
25936 return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x);
25939 function isChildren(x) {
25940 return typeof x === 'string' || isArray(x) || isChild(x);
25943 function UnexpectedVirtualElement(data) {
25944 var err = new Error();
25946 err.type = 'virtual-hyperscript.unexpected.virtual-element';
25947 err.message = 'Unexpected virtual child passed to h().\n' +
25948 'Expected a VNode / Vthunk / VWidget / string but:\n' +
25950 errorString(data.foreignObject) +
25952 'The parent vnode is:\n' +
25953 errorString(data.parentVnode)
25955 'Suggested fix: change your `h(..., [ ... ])` callsite.';
25956 err.foreignObject = data.foreignObject;
25957 err.parentVnode = data.parentVnode;
25962 function errorString(obj) {
25964 return JSON.stringify(obj, null, ' ');
25966 return String(obj);
25970 },{"../vnode/is-thunk":260,"../vnode/is-vhook":261,"../vnode/is-vnode":262,"../vnode/is-vtext":263,"../vnode/is-widget":264,"../vnode/vnode.js":266,"../vnode/vtext.js":268,"./hooks/ev-hook.js":255,"./hooks/soft-set-hook.js":256,"./parse-tag.js":258,"x-is-array":289}],258:[function(require,module,exports){
25973 var split = require('browser-split');
25975 var classIdSplit = /([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/;
25976 var notClassId = /^\.|#/;
25978 module.exports = parseTag;
25980 function parseTag(tag, props) {
25985 var noId = !(props.hasOwnProperty('id'));
25987 var tagParts = split(tag, classIdSplit);
25988 var tagName = null;
25990 if (notClassId.test(tagParts[1])) {
25994 var classes, part, type, i;
25996 for (i = 0; i < tagParts.length; i++) {
25997 part = tagParts[i];
26003 type = part.charAt(0);
26007 } else if (type === '.') {
26008 classes = classes || [];
26009 classes.push(part.substring(1, part.length));
26010 } else if (type === '#' && noId) {
26011 props.id = part.substring(1, part.length);
26016 if (props.className) {
26017 classes.push(props.className);
26020 props.className = classes.join(' ');
26023 return props.namespace ? tagName : tagName.toUpperCase();
26026 },{"browser-split":5}],259:[function(require,module,exports){
26027 var isVNode = require("./is-vnode")
26028 var isVText = require("./is-vtext")
26029 var isWidget = require("./is-widget")
26030 var isThunk = require("./is-thunk")
26032 module.exports = handleThunk
26034 function handleThunk(a, b) {
26039 renderedB = renderThunk(b, a)
26043 renderedA = renderThunk(a, null)
26052 function renderThunk(thunk, previous) {
26053 var renderedThunk = thunk.vnode
26055 if (!renderedThunk) {
26056 renderedThunk = thunk.vnode = thunk.render(previous)
26059 if (!(isVNode(renderedThunk) ||
26060 isVText(renderedThunk) ||
26061 isWidget(renderedThunk))) {
26062 throw new Error("thunk did not return a valid node");
26065 return renderedThunk
26068 },{"./is-thunk":260,"./is-vnode":262,"./is-vtext":263,"./is-widget":264}],260:[function(require,module,exports){
26069 module.exports = isThunk
26071 function isThunk(t) {
26072 return t && t.type === "Thunk"
26075 },{}],261:[function(require,module,exports){
26076 module.exports = isHook
26078 function isHook(hook) {
26080 (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||
26081 typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))
26084 },{}],262:[function(require,module,exports){
26085 var version = require("./version")
26087 module.exports = isVirtualNode
26089 function isVirtualNode(x) {
26090 return x && x.type === "VirtualNode" && x.version === version
26093 },{"./version":265}],263:[function(require,module,exports){
26094 var version = require("./version")
26096 module.exports = isVirtualText
26098 function isVirtualText(x) {
26099 return x && x.type === "VirtualText" && x.version === version
26102 },{"./version":265}],264:[function(require,module,exports){
26103 module.exports = isWidget
26105 function isWidget(w) {
26106 return w && w.type === "Widget"
26109 },{}],265:[function(require,module,exports){
26110 module.exports = "2"
26112 },{}],266:[function(require,module,exports){
26113 var version = require("./version")
26114 var isVNode = require("./is-vnode")
26115 var isWidget = require("./is-widget")
26116 var isThunk = require("./is-thunk")
26117 var isVHook = require("./is-vhook")
26119 module.exports = VirtualNode
26121 var noProperties = {}
26122 var noChildren = []
26124 function VirtualNode(tagName, properties, children, key, namespace) {
26125 this.tagName = tagName
26126 this.properties = properties || noProperties
26127 this.children = children || noChildren
26128 this.key = key != null ? String(key) : undefined
26129 this.namespace = (typeof namespace === "string") ? namespace : null
26131 var count = (children && children.length) || 0
26132 var descendants = 0
26133 var hasWidgets = false
26134 var hasThunks = false
26135 var descendantHooks = false
26138 for (var propName in properties) {
26139 if (properties.hasOwnProperty(propName)) {
26140 var property = properties[propName]
26141 if (isVHook(property) && property.unhook) {
26146 hooks[propName] = property
26151 for (var i = 0; i < count; i++) {
26152 var child = children[i]
26153 if (isVNode(child)) {
26154 descendants += child.count || 0
26156 if (!hasWidgets && child.hasWidgets) {
26160 if (!hasThunks && child.hasThunks) {
26164 if (!descendantHooks && (child.hooks || child.descendantHooks)) {
26165 descendantHooks = true
26167 } else if (!hasWidgets && isWidget(child)) {
26168 if (typeof child.destroy === "function") {
26171 } else if (!hasThunks && isThunk(child)) {
26176 this.count = count + descendants
26177 this.hasWidgets = hasWidgets
26178 this.hasThunks = hasThunks
26180 this.descendantHooks = descendantHooks
26183 VirtualNode.prototype.version = version
26184 VirtualNode.prototype.type = "VirtualNode"
26186 },{"./is-thunk":260,"./is-vhook":261,"./is-vnode":262,"./is-widget":264,"./version":265}],267:[function(require,module,exports){
26187 var version = require("./version")
26189 VirtualPatch.NONE = 0
26190 VirtualPatch.VTEXT = 1
26191 VirtualPatch.VNODE = 2
26192 VirtualPatch.WIDGET = 3
26193 VirtualPatch.PROPS = 4
26194 VirtualPatch.ORDER = 5
26195 VirtualPatch.INSERT = 6
26196 VirtualPatch.REMOVE = 7
26197 VirtualPatch.THUNK = 8
26199 module.exports = VirtualPatch
26201 function VirtualPatch(type, vNode, patch) {
26202 this.type = Number(type)
26207 VirtualPatch.prototype.version = version
26208 VirtualPatch.prototype.type = "VirtualPatch"
26210 },{"./version":265}],268:[function(require,module,exports){
26211 var version = require("./version")
26213 module.exports = VirtualText
26215 function VirtualText(text) {
26216 this.text = String(text)
26219 VirtualText.prototype.version = version
26220 VirtualText.prototype.type = "VirtualText"
26222 },{"./version":265}],269:[function(require,module,exports){
26223 var isObject = require("is-object")
26224 var isHook = require("../vnode/is-vhook")
26226 module.exports = diffProps
26228 function diffProps(a, b) {
26231 for (var aKey in a) {
26232 if (!(aKey in b)) {
26234 diff[aKey] = undefined
26237 var aValue = a[aKey]
26238 var bValue = b[aKey]
26240 if (aValue === bValue) {
26242 } else if (isObject(aValue) && isObject(bValue)) {
26243 if (getPrototype(bValue) !== getPrototype(aValue)) {
26245 diff[aKey] = bValue
26246 } else if (isHook(bValue)) {
26248 diff[aKey] = bValue
26250 var objectDiff = diffProps(aValue, bValue)
26253 diff[aKey] = objectDiff
26258 diff[aKey] = bValue
26262 for (var bKey in b) {
26263 if (!(bKey in a)) {
26265 diff[bKey] = b[bKey]
26272 function getPrototype(value) {
26273 if (Object.getPrototypeOf) {
26274 return Object.getPrototypeOf(value)
26275 } else if (value.__proto__) {
26276 return value.__proto__
26277 } else if (value.constructor) {
26278 return value.constructor.prototype
26282 },{"../vnode/is-vhook":261,"is-object":20}],270:[function(require,module,exports){
26283 var isArray = require("x-is-array")
26285 var VPatch = require("../vnode/vpatch")
26286 var isVNode = require("../vnode/is-vnode")
26287 var isVText = require("../vnode/is-vtext")
26288 var isWidget = require("../vnode/is-widget")
26289 var isThunk = require("../vnode/is-thunk")
26290 var handleThunk = require("../vnode/handle-thunk")
26292 var diffProps = require("./diff-props")
26294 module.exports = diff
26296 function diff(a, b) {
26297 var patch = { a: a }
26298 walk(a, b, patch, 0)
26302 function walk(a, b, patch, index) {
26307 var apply = patch[index]
26308 var applyClear = false
26310 if (isThunk(a) || isThunk(b)) {
26311 thunks(a, b, patch, index)
26312 } else if (b == null) {
26314 // If a is a widget we will add a remove patch for it
26315 // Otherwise any child widgets/hooks must be destroyed.
26316 // This prevents adding two remove patches for a widget.
26317 if (!isWidget(a)) {
26318 clearState(a, patch, index)
26319 apply = patch[index]
26322 apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b))
26323 } else if (isVNode(b)) {
26325 if (a.tagName === b.tagName &&
26326 a.namespace === b.namespace &&
26328 var propsPatch = diffProps(a.properties, b.properties)
26330 apply = appendPatch(apply,
26331 new VPatch(VPatch.PROPS, a, propsPatch))
26333 apply = diffChildren(a, b, patch, apply, index)
26335 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
26339 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
26342 } else if (isVText(b)) {
26344 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
26346 } else if (a.text !== b.text) {
26347 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
26349 } else if (isWidget(b)) {
26350 if (!isWidget(a)) {
26354 apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b))
26358 patch[index] = apply
26362 clearState(a, patch, index)
26366 function diffChildren(a, b, patch, apply, index) {
26367 var aChildren = a.children
26368 var orderedSet = reorder(aChildren, b.children)
26369 var bChildren = orderedSet.children
26371 var aLen = aChildren.length
26372 var bLen = bChildren.length
26373 var len = aLen > bLen ? aLen : bLen
26375 for (var i = 0; i < len; i++) {
26376 var leftNode = aChildren[i]
26377 var rightNode = bChildren[i]
26382 // Excess nodes in b need to be added
26383 apply = appendPatch(apply,
26384 new VPatch(VPatch.INSERT, null, rightNode))
26387 walk(leftNode, rightNode, patch, index)
26390 if (isVNode(leftNode) && leftNode.count) {
26391 index += leftNode.count
26395 if (orderedSet.moves) {
26396 // Reorder nodes last
26397 apply = appendPatch(apply, new VPatch(
26407 function clearState(vNode, patch, index) {
26408 // TODO: Make this a single walk, not two
26409 unhook(vNode, patch, index)
26410 destroyWidgets(vNode, patch, index)
26413 // Patch records for all destroyed widgets must be added because we need
26414 // a DOM node reference for the destroy function
26415 function destroyWidgets(vNode, patch, index) {
26416 if (isWidget(vNode)) {
26417 if (typeof vNode.destroy === "function") {
26418 patch[index] = appendPatch(
26420 new VPatch(VPatch.REMOVE, vNode, null)
26423 } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
26424 var children = vNode.children
26425 var len = children.length
26426 for (var i = 0; i < len; i++) {
26427 var child = children[i]
26430 destroyWidgets(child, patch, index)
26432 if (isVNode(child) && child.count) {
26433 index += child.count
26436 } else if (isThunk(vNode)) {
26437 thunks(vNode, null, patch, index)
26441 // Create a sub-patch for thunks
26442 function thunks(a, b, patch, index) {
26443 var nodes = handleThunk(a, b)
26444 var thunkPatch = diff(nodes.a, nodes.b)
26445 if (hasPatches(thunkPatch)) {
26446 patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)
26450 function hasPatches(patch) {
26451 for (var index in patch) {
26452 if (index !== "a") {
26460 // Execute hooks when two nodes are identical
26461 function unhook(vNode, patch, index) {
26462 if (isVNode(vNode)) {
26464 patch[index] = appendPatch(
26469 undefinedKeys(vNode.hooks)
26474 if (vNode.descendantHooks || vNode.hasThunks) {
26475 var children = vNode.children
26476 var len = children.length
26477 for (var i = 0; i < len; i++) {
26478 var child = children[i]
26481 unhook(child, patch, index)
26483 if (isVNode(child) && child.count) {
26484 index += child.count
26488 } else if (isThunk(vNode)) {
26489 thunks(vNode, null, patch, index)
26493 function undefinedKeys(obj) {
26496 for (var key in obj) {
26497 result[key] = undefined
26503 // List diff, naive left to right reordering
26504 function reorder(aChildren, bChildren) {
26505 // O(M) time, O(M) memory
26506 var bChildIndex = keyIndex(bChildren)
26507 var bKeys = bChildIndex.keys
26508 var bFree = bChildIndex.free
26510 if (bFree.length === bChildren.length) {
26512 children: bChildren,
26517 // O(N) time, O(N) memory
26518 var aChildIndex = keyIndex(aChildren)
26519 var aKeys = aChildIndex.keys
26520 var aFree = aChildIndex.free
26522 if (aFree.length === aChildren.length) {
26524 children: bChildren,
26529 // O(MAX(N, M)) memory
26530 var newChildren = []
26533 var freeCount = bFree.length
26534 var deletedItems = 0
26536 // Iterate through a and match a node in b
26538 for (var i = 0 ; i < aChildren.length; i++) {
26539 var aItem = aChildren[i]
26543 if (bKeys.hasOwnProperty(aItem.key)) {
26544 // Match up the old keys
26545 itemIndex = bKeys[aItem.key]
26546 newChildren.push(bChildren[itemIndex])
26549 // Remove old keyed items
26550 itemIndex = i - deletedItems++
26551 newChildren.push(null)
26554 // Match the item in a with the next free item in b
26555 if (freeIndex < freeCount) {
26556 itemIndex = bFree[freeIndex++]
26557 newChildren.push(bChildren[itemIndex])
26559 // There are no free items in b to match with
26560 // the free items in a, so the extra free nodes
26562 itemIndex = i - deletedItems++
26563 newChildren.push(null)
26568 var lastFreeIndex = freeIndex >= bFree.length ?
26572 // Iterate through b and append any new keys
26574 for (var j = 0; j < bChildren.length; j++) {
26575 var newItem = bChildren[j]
26578 if (!aKeys.hasOwnProperty(newItem.key)) {
26579 // Add any new keyed items
26580 // We are adding new items to the end and then sorting them
26581 // in place. In future we should insert new items in place.
26582 newChildren.push(newItem)
26584 } else if (j >= lastFreeIndex) {
26585 // Add any leftover non-keyed items
26586 newChildren.push(newItem)
26590 var simulate = newChildren.slice()
26591 var simulateIndex = 0
26596 for (var k = 0; k < bChildren.length;) {
26597 var wantedItem = bChildren[k]
26598 simulateItem = simulate[simulateIndex]
26601 while (simulateItem === null && simulate.length) {
26602 removes.push(remove(simulate, simulateIndex, null))
26603 simulateItem = simulate[simulateIndex]
26606 if (!simulateItem || simulateItem.key !== wantedItem.key) {
26607 // if we need a key in this position...
26608 if (wantedItem.key) {
26609 if (simulateItem && simulateItem.key) {
26610 // if an insert doesn't put this key in place, it needs to move
26611 if (bKeys[simulateItem.key] !== k + 1) {
26612 removes.push(remove(simulate, simulateIndex, simulateItem.key))
26613 simulateItem = simulate[simulateIndex]
26614 // if the remove didn't put the wanted item in place, we need to insert it
26615 if (!simulateItem || simulateItem.key !== wantedItem.key) {
26616 inserts.push({key: wantedItem.key, to: k})
26618 // items are matching, so skip ahead
26624 inserts.push({key: wantedItem.key, to: k})
26628 inserts.push({key: wantedItem.key, to: k})
26632 // a key in simulate has no matching wanted key, remove it
26633 else if (simulateItem && simulateItem.key) {
26634 removes.push(remove(simulate, simulateIndex, simulateItem.key))
26643 // remove all the remaining nodes from simulate
26644 while(simulateIndex < simulate.length) {
26645 simulateItem = simulate[simulateIndex]
26646 removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key))
26649 // If the only moves we have are deletes then we can just
26650 // let the delete patch remove these items.
26651 if (removes.length === deletedItems && !inserts.length) {
26653 children: newChildren,
26659 children: newChildren,
26667 function remove(arr, index, key) {
26668 arr.splice(index, 1)
26676 function keyIndex(children) {
26679 var length = children.length
26681 for (var i = 0; i < length; i++) {
26682 var child = children[i]
26685 keys[child.key] = i
26692 keys: keys, // A hash of key name to index
26693 free: free // An array of unkeyed item indices
26697 function appendPatch(apply, patch) {
26699 if (isArray(apply)) {
26702 apply = [apply, patch]
26711 },{"../vnode/handle-thunk":259,"../vnode/is-thunk":260,"../vnode/is-vnode":262,"../vnode/is-vtext":263,"../vnode/is-widget":264,"../vnode/vpatch":267,"./diff-props":269,"x-is-array":289}],271:[function(require,module,exports){
26712 /** @license MIT License (c) copyright 2010-2014 original author or authors */
26713 /** @author Brian Cavalier */
26714 /** @author John Hann */
26716 (function(define) { 'use strict';
26717 define(function (require) {
26719 var makePromise = require('./makePromise');
26720 var Scheduler = require('./Scheduler');
26721 var async = require('./env').asap;
26723 return makePromise({
26724 scheduler: new Scheduler(async)
26728 })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
26730 },{"./Scheduler":272,"./env":284,"./makePromise":286}],272:[function(require,module,exports){
26731 /** @license MIT License (c) copyright 2010-2014 original author or authors */
26732 /** @author Brian Cavalier */
26733 /** @author John Hann */
26735 (function(define) { 'use strict';
26736 define(function() {
26738 // Credit to Twisol (https://github.com/Twisol) for suggesting
26739 // this type of extensible queue + trampoline approach for next-tick conflation.
26742 * Async task scheduler
26743 * @param {function} async function to schedule a single async function
26746 function Scheduler(async) {
26747 this._async = async;
26748 this._running = false;
26750 this._queue = this;
26751 this._queueLen = 0;
26752 this._afterQueue = {};
26753 this._afterQueueLen = 0;
26756 this.drain = function() {
26763 * @param {{ run:function }} task
26765 Scheduler.prototype.enqueue = function(task) {
26766 this._queue[this._queueLen++] = task;
26771 * Enqueue a task to run after the main task queue
26772 * @param {{ run:function }} task
26774 Scheduler.prototype.afterQueue = function(task) {
26775 this._afterQueue[this._afterQueueLen++] = task;
26779 Scheduler.prototype.run = function() {
26780 if (!this._running) {
26781 this._running = true;
26782 this._async(this.drain);
26787 * Drain the handler queue entirely, and then the after queue
26789 Scheduler.prototype._drain = function() {
26791 for (; i < this._queueLen; ++i) {
26792 this._queue[i].run();
26793 this._queue[i] = void 0;
26796 this._queueLen = 0;
26797 this._running = false;
26799 for (i = 0; i < this._afterQueueLen; ++i) {
26800 this._afterQueue[i].run();
26801 this._afterQueue[i] = void 0;
26804 this._afterQueueLen = 0;
26810 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
26812 },{}],273:[function(require,module,exports){
26813 /** @license MIT License (c) copyright 2010-2014 original author or authors */
26814 /** @author Brian Cavalier */
26815 /** @author John Hann */
26817 (function(define) { 'use strict';
26818 define(function() {
26821 * Custom error type for promises rejected by promise.timeout
26822 * @param {string} message
26825 function TimeoutError (message) {
26827 this.message = message;
26828 this.name = TimeoutError.name;
26829 if (typeof Error.captureStackTrace === 'function') {
26830 Error.captureStackTrace(this, TimeoutError);
26834 TimeoutError.prototype = Object.create(Error.prototype);
26835 TimeoutError.prototype.constructor = TimeoutError;
26837 return TimeoutError;
26839 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
26840 },{}],274:[function(require,module,exports){
26841 /** @license MIT License (c) copyright 2010-2014 original author or authors */
26842 /** @author Brian Cavalier */
26843 /** @author John Hann */
26845 (function(define) { 'use strict';
26846 define(function() {
26848 makeApply.tryCatchResolve = tryCatchResolve;
26852 function makeApply(Promise, call) {
26853 if(arguments.length < 2) {
26854 call = tryCatchResolve;
26859 function apply(f, thisArg, args) {
26860 var p = Promise._defer();
26861 var l = args.length;
26862 var params = new Array(l);
26863 callAndResolve({ f:f, thisArg:thisArg, args:args, params:params, i:l-1, call:call }, p._handler);
26868 function callAndResolve(c, h) {
26870 return call(c.f, c.thisArg, c.params, h);
26873 var handler = Promise._handler(c.args[c.i]);
26874 handler.fold(callAndResolveNext, c, void 0, h);
26877 function callAndResolveNext(c, x, h) {
26880 callAndResolve(c, h);
26884 function tryCatchResolve(f, thisArg, args, resolver) {
26886 resolver.resolve(f.apply(thisArg, args));
26888 resolver.reject(e);
26893 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
26897 },{}],275:[function(require,module,exports){
26898 /** @license MIT License (c) copyright 2010-2014 original author or authors */
26899 /** @author Brian Cavalier */
26900 /** @author John Hann */
26902 (function(define) { 'use strict';
26903 define(function(require) {
26905 var state = require('../state');
26906 var applier = require('../apply');
26908 return function array(Promise) {
26910 var applyFold = applier(Promise);
26911 var toPromise = Promise.resolve;
26912 var all = Promise.all;
26914 var ar = Array.prototype.reduce;
26915 var arr = Array.prototype.reduceRight;
26916 var slice = Array.prototype.slice;
26918 // Additional array combinators
26921 Promise.some = some;
26922 Promise.settle = settle;
26925 Promise.filter = filter;
26926 Promise.reduce = reduce;
26927 Promise.reduceRight = reduceRight;
26930 * When this promise fulfills with an array, do
26931 * onFulfilled.apply(void 0, array)
26932 * @param {function} onFulfilled function to apply
26933 * @returns {Promise} promise for the result of applying onFulfilled
26935 Promise.prototype.spread = function(onFulfilled) {
26936 return this.then(all).then(function(array) {
26937 return onFulfilled.apply(this, array);
26944 * One-winner competitive race.
26945 * Return a promise that will fulfill when one of the promises
26946 * in the input array fulfills, or will reject when all promises
26948 * @param {array} promises
26949 * @returns {Promise} promise for the first fulfilled value
26951 function any(promises) {
26952 var p = Promise._defer();
26953 var resolver = p._handler;
26954 var l = promises.length>>>0;
26959 for (var h, x, i = 0; i < l; ++i) {
26961 if(x === void 0 && !(i in promises)) {
26966 h = Promise._handler(x);
26967 if(h.state() > 0) {
26968 resolver.become(h);
26969 Promise._visitRemaining(promises, i, h);
26972 h.visit(resolver, handleFulfill, handleReject);
26976 if(pending === 0) {
26977 resolver.reject(new RangeError('any(): array must not be empty'));
26982 function handleFulfill(x) {
26983 /*jshint validthis:true*/
26985 this.resolve(x); // this === resolver
26988 function handleReject(e) {
26989 /*jshint validthis:true*/
26990 if(this.resolved) { // this === resolver
26995 if(--pending === 0) {
26996 this.reject(errors);
27002 * N-winner competitive race
27003 * Return a promise that will fulfill when n input promises have
27004 * fulfilled, or will reject when it becomes impossible for n
27005 * input promises to fulfill (ie when promises.length - n + 1
27007 * @param {array} promises
27008 * @param {number} n
27009 * @returns {Promise} promise for the earliest n fulfillment values
27013 function some(promises, n) {
27014 /*jshint maxcomplexity:7*/
27015 var p = Promise._defer();
27016 var resolver = p._handler;
27021 var l = promises.length>>>0;
27024 var x, i; // reused in both for() loops
27026 // First pass: count actual array items
27027 for(i=0; i<l; ++i) {
27029 if(x === void 0 && !(i in promises)) {
27035 // Compute actual goals
27036 n = Math.max(n, 0);
27037 nReject = (nFulfill - n + 1);
27038 nFulfill = Math.min(n, nFulfill);
27041 resolver.reject(new RangeError('some(): array must contain at least '
27042 + n + ' item(s), but had ' + nFulfill));
27043 } else if(nFulfill === 0) {
27044 resolver.resolve(results);
27047 // Second pass: observe each array item, make progress toward goals
27048 for(i=0; i<l; ++i) {
27050 if(x === void 0 && !(i in promises)) {
27054 Promise._handler(x).visit(resolver, fulfill, reject, resolver.notify);
27059 function fulfill(x) {
27060 /*jshint validthis:true*/
27061 if(this.resolved) { // this === resolver
27066 if(--nFulfill === 0) {
27068 this.resolve(results);
27072 function reject(e) {
27073 /*jshint validthis:true*/
27074 if(this.resolved) { // this === resolver
27079 if(--nReject === 0) {
27081 this.reject(errors);
27087 * Apply f to the value of each promise in a list of promises
27088 * and return a new list containing the results.
27089 * @param {array} promises
27090 * @param {function(x:*, index:Number):*} f mapping function
27091 * @returns {Promise}
27093 function map(promises, f) {
27094 return Promise._traverse(f, promises);
27098 * Filter the provided array of promises using the provided predicate. Input may
27099 * contain promises and values
27100 * @param {Array} promises array of promises and values
27101 * @param {function(x:*, index:Number):boolean} predicate filtering predicate.
27102 * Must return truthy (or promise for truthy) for items to retain.
27103 * @returns {Promise} promise that will fulfill with an array containing all items
27104 * for which predicate returned truthy.
27106 function filter(promises, predicate) {
27107 var a = slice.call(promises);
27108 return Promise._traverse(predicate, a).then(function(keep) {
27109 return filterSync(a, keep);
27113 function filterSync(promises, keep) {
27114 // Safe because we know all promises have fulfilled if we've made it this far
27115 var l = keep.length;
27116 var filtered = new Array(l);
27117 for(var i=0, j=0; i<l; ++i) {
27119 filtered[j++] = Promise._handler(promises[i]).value;
27122 filtered.length = j;
27128 * Return a promise that will always fulfill with an array containing
27129 * the outcome states of all input promises. The returned promise
27130 * will never reject.
27131 * @param {Array} promises
27132 * @returns {Promise} promise for array of settled state descriptors
27134 function settle(promises) {
27135 return all(promises.map(settleOne));
27138 function settleOne(p) {
27139 // Optimize the case where we get an already-resolved when.js promise
27140 // by extracting its state:
27142 if (p instanceof Promise) {
27143 // This is our own Promise type and we can reach its handler internals:
27144 handler = p._handler.join();
27146 if((handler && handler.state() === 0) || !handler) {
27147 // Either still pending, or not a Promise at all:
27148 return toPromise(p).then(state.fulfilled, state.rejected);
27151 // The promise is our own, but it is already resolved. Take a shortcut.
27152 // Since we're not actually handling the resolution, we need to disable
27153 // rejection reporting.
27154 handler._unreport();
27155 return state.inspect(handler);
27159 * Traditional reduce function, similar to `Array.prototype.reduce()`, but
27160 * input may contain promises and/or values, and reduceFunc
27161 * may return either a value or a promise, *and* initialValue may
27162 * be a promise for the starting value.
27163 * @param {Array|Promise} promises array or promise for an array of anything,
27164 * may contain a mix of promises and values.
27165 * @param {function(accumulated:*, x:*, index:Number):*} f reduce function
27166 * @returns {Promise} that will resolve to the final reduced value
27168 function reduce(promises, f /*, initialValue */) {
27169 return arguments.length > 2 ? ar.call(promises, liftCombine(f), arguments[2])
27170 : ar.call(promises, liftCombine(f));
27174 * Traditional reduce function, similar to `Array.prototype.reduceRight()`, but
27175 * input may contain promises and/or values, and reduceFunc
27176 * may return either a value or a promise, *and* initialValue may
27177 * be a promise for the starting value.
27178 * @param {Array|Promise} promises array or promise for an array of anything,
27179 * may contain a mix of promises and values.
27180 * @param {function(accumulated:*, x:*, index:Number):*} f reduce function
27181 * @returns {Promise} that will resolve to the final reduced value
27183 function reduceRight(promises, f /*, initialValue */) {
27184 return arguments.length > 2 ? arr.call(promises, liftCombine(f), arguments[2])
27185 : arr.call(promises, liftCombine(f));
27188 function liftCombine(f) {
27189 return function(z, x, i) {
27190 return applyFold(f, void 0, [z,x,i]);
27196 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
27198 },{"../apply":274,"../state":287}],276:[function(require,module,exports){
27199 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27200 /** @author Brian Cavalier */
27201 /** @author John Hann */
27203 (function(define) { 'use strict';
27204 define(function() {
27206 return function flow(Promise) {
27208 var resolve = Promise.resolve;
27209 var reject = Promise.reject;
27210 var origCatch = Promise.prototype['catch'];
27213 * Handle the ultimate fulfillment value or rejection reason, and assume
27214 * responsibility for all errors. If an error propagates out of result
27215 * or handleFatalError, it will be rethrown to the host, resulting in a
27216 * loud stack track on most platforms and a crash on some.
27217 * @param {function?} onResult
27218 * @param {function?} onError
27219 * @returns {undefined}
27221 Promise.prototype.done = function(onResult, onError) {
27222 this._handler.visit(this._handler.receiver, onResult, onError);
27226 * Add Error-type and predicate matching to catch. Examples:
27227 * promise.catch(TypeError, handleTypeError)
27228 * .catch(predicate, handleMatchedErrors)
27229 * .catch(handleRemainingErrors)
27230 * @param onRejected
27233 Promise.prototype['catch'] = Promise.prototype.otherwise = function(onRejected) {
27234 if (arguments.length < 2) {
27235 return origCatch.call(this, onRejected);
27238 if(typeof onRejected !== 'function') {
27239 return this.ensure(rejectInvalidPredicate);
27242 return origCatch.call(this, createCatchFilter(arguments[1], onRejected));
27246 * Wraps the provided catch handler, so that it will only be called
27247 * if the predicate evaluates truthy
27248 * @param {?function} handler
27249 * @param {function} predicate
27250 * @returns {function} conditional catch handler
27252 function createCatchFilter(handler, predicate) {
27253 return function(e) {
27254 return evaluatePredicate(e, predicate)
27255 ? handler.call(this, e)
27261 * Ensures that onFulfilledOrRejected will be called regardless of whether
27262 * this promise is fulfilled or rejected. onFulfilledOrRejected WILL NOT
27263 * receive the promises' value or reason. Any returned value will be disregarded.
27264 * onFulfilledOrRejected may throw or return a rejected promise to signal
27265 * an additional error.
27266 * @param {function} handler handler to be called regardless of
27267 * fulfillment or rejection
27268 * @returns {Promise}
27270 Promise.prototype['finally'] = Promise.prototype.ensure = function(handler) {
27271 if(typeof handler !== 'function') {
27275 return this.then(function(x) {
27276 return runSideEffect(handler, this, identity, x);
27278 return runSideEffect(handler, this, reject, e);
27282 function runSideEffect (handler, thisArg, propagate, value) {
27283 var result = handler.call(thisArg);
27284 return maybeThenable(result)
27285 ? propagateValue(result, propagate, value)
27286 : propagate(value);
27289 function propagateValue (result, propagate, x) {
27290 return resolve(result).then(function () {
27291 return propagate(x);
27296 * Recover from a failure by returning a defaultValue. If defaultValue
27297 * is a promise, it's fulfillment value will be used. If defaultValue is
27298 * a promise that rejects, the returned promise will reject with the
27300 * @param {*} defaultValue
27301 * @returns {Promise} new promise
27303 Promise.prototype['else'] = Promise.prototype.orElse = function(defaultValue) {
27304 return this.then(void 0, function() {
27305 return defaultValue;
27310 * Shortcut for .then(function() { return value; })
27312 * @return {Promise} a promise that:
27313 * - is fulfilled if value is not a promise, or
27314 * - if value is a promise, will fulfill with its value, or reject
27317 Promise.prototype['yield'] = function(value) {
27318 return this.then(function() {
27324 * Runs a side effect when this promise fulfills, without changing the
27325 * fulfillment value.
27326 * @param {function} onFulfilledSideEffect
27327 * @returns {Promise}
27329 Promise.prototype.tap = function(onFulfilledSideEffect) {
27330 return this.then(onFulfilledSideEffect)['yield'](this);
27336 function rejectInvalidPredicate() {
27337 throw new TypeError('catch predicate must be a function');
27340 function evaluatePredicate(e, predicate) {
27341 return isError(predicate) ? e instanceof predicate : predicate(e);
27344 function isError(predicate) {
27345 return predicate === Error
27346 || (predicate != null && predicate.prototype instanceof Error);
27349 function maybeThenable(x) {
27350 return (typeof x === 'object' || typeof x === 'function') && x !== null;
27353 function identity(x) {
27358 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
27360 },{}],277:[function(require,module,exports){
27361 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27362 /** @author Brian Cavalier */
27363 /** @author John Hann */
27364 /** @author Jeff Escalante */
27366 (function(define) { 'use strict';
27367 define(function() {
27369 return function fold(Promise) {
27371 Promise.prototype.fold = function(f, z) {
27372 var promise = this._beget();
27374 this._handler.fold(function(z, x, to) {
27375 Promise._handler(z).fold(function(x, z, to) {
27376 to.resolve(f.call(this, z, x));
27378 }, z, promise._handler.receiver, promise._handler);
27387 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
27389 },{}],278:[function(require,module,exports){
27390 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27391 /** @author Brian Cavalier */
27392 /** @author John Hann */
27394 (function(define) { 'use strict';
27395 define(function(require) {
27397 var inspect = require('../state').inspect;
27399 return function inspection(Promise) {
27401 Promise.prototype.inspect = function() {
27402 return inspect(Promise._handler(this));
27409 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
27411 },{"../state":287}],279:[function(require,module,exports){
27412 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27413 /** @author Brian Cavalier */
27414 /** @author John Hann */
27416 (function(define) { 'use strict';
27417 define(function() {
27419 return function generate(Promise) {
27421 var resolve = Promise.resolve;
27423 Promise.iterate = iterate;
27424 Promise.unfold = unfold;
27429 * @deprecated Use github.com/cujojs/most streams and most.iterate
27430 * Generate a (potentially infinite) stream of promised values:
27431 * x, f(x), f(f(x)), etc. until condition(x) returns true
27432 * @param {function} f function to generate a new x from the previous x
27433 * @param {function} condition function that, given the current x, returns
27434 * truthy when the iterate should stop
27435 * @param {function} handler function to handle the value produced by f
27436 * @param {*|Promise} x starting value, may be a promise
27437 * @return {Promise} the result of the last call to f before
27438 * condition returns true
27440 function iterate(f, condition, handler, x) {
27441 return unfold(function(x) {
27443 }, condition, handler, x);
27447 * @deprecated Use github.com/cujojs/most streams and most.unfold
27448 * Generate a (potentially infinite) stream of promised values
27449 * by applying handler(generator(seed)) iteratively until
27450 * condition(seed) returns true.
27451 * @param {function} unspool function that generates a [value, newSeed]
27453 * @param {function} condition function that, given the current seed, returns
27454 * truthy when the unfold should stop
27455 * @param {function} handler function to handle the value produced by unspool
27456 * @param x {*|Promise} starting value, may be a promise
27457 * @return {Promise} the result of the last value produced by unspool before
27458 * condition returns true
27460 function unfold(unspool, condition, handler, x) {
27461 return resolve(x).then(function(seed) {
27462 return resolve(condition(seed)).then(function(done) {
27463 return done ? seed : resolve(unspool(seed)).spread(next);
27467 function next(item, newSeed) {
27468 return resolve(handler(item)).then(function() {
27469 return unfold(unspool, condition, handler, newSeed);
27476 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
27478 },{}],280:[function(require,module,exports){
27479 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27480 /** @author Brian Cavalier */
27481 /** @author John Hann */
27483 (function(define) { 'use strict';
27484 define(function() {
27486 return function progress(Promise) {
27490 * Register a progress handler for this promise
27491 * @param {function} onProgress
27492 * @returns {Promise}
27494 Promise.prototype.progress = function(onProgress) {
27495 return this.then(void 0, void 0, onProgress);
27502 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
27504 },{}],281:[function(require,module,exports){
27505 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27506 /** @author Brian Cavalier */
27507 /** @author John Hann */
27509 (function(define) { 'use strict';
27510 define(function(require) {
27512 var env = require('../env');
27513 var TimeoutError = require('../TimeoutError');
27515 function setTimeout(f, ms, x, y) {
27516 return env.setTimer(function() {
27521 return function timed(Promise) {
27523 * Return a new promise whose fulfillment value is revealed only
27524 * after ms milliseconds
27525 * @param {number} ms milliseconds
27526 * @returns {Promise}
27528 Promise.prototype.delay = function(ms) {
27529 var p = this._beget();
27530 this._handler.fold(handleDelay, ms, void 0, p._handler);
27534 function handleDelay(ms, x, h) {
27535 setTimeout(resolveDelay, ms, x, h);
27538 function resolveDelay(x, h) {
27543 * Return a new promise that rejects after ms milliseconds unless
27544 * this promise fulfills earlier, in which case the returned promise
27545 * fulfills with the same value.
27546 * @param {number} ms milliseconds
27547 * @param {Error|*=} reason optional rejection reason to use, defaults
27548 * to a TimeoutError if not provided
27549 * @returns {Promise}
27551 Promise.prototype.timeout = function(ms, reason) {
27552 var p = this._beget();
27553 var h = p._handler;
27555 var t = setTimeout(onTimeout, ms, reason, p._handler);
27557 this._handler.visit(h,
27558 function onFulfill(x) {
27560 this.resolve(x); // this = h
27562 function onReject(x) {
27564 this.reject(x); // this = h
27571 function onTimeout(reason, h, ms) {
27572 var e = typeof reason === 'undefined'
27573 ? new TimeoutError('timed out after ' + ms + 'ms')
27582 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
27584 },{"../TimeoutError":273,"../env":284}],282:[function(require,module,exports){
27585 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27586 /** @author Brian Cavalier */
27587 /** @author John Hann */
27589 (function(define) { 'use strict';
27590 define(function(require) {
27592 var setTimer = require('../env').setTimer;
27593 var format = require('../format');
27595 return function unhandledRejection(Promise) {
27597 var logError = noop;
27598 var logInfo = noop;
27601 if(typeof console !== 'undefined') {
27602 // Alias console to prevent things like uglify's drop_console option from
27603 // removing console.log/error. Unhandled rejections fall into the same
27604 // category as uncaught exceptions, and build tools shouldn't silence them.
27605 localConsole = console;
27606 logError = typeof localConsole.error !== 'undefined'
27607 ? function (e) { localConsole.error(e); }
27608 : function (e) { localConsole.log(e); };
27610 logInfo = typeof localConsole.info !== 'undefined'
27611 ? function (e) { localConsole.info(e); }
27612 : function (e) { localConsole.log(e); };
27615 Promise.onPotentiallyUnhandledRejection = function(rejection) {
27616 enqueue(report, rejection);
27619 Promise.onPotentiallyUnhandledRejectionHandled = function(rejection) {
27620 enqueue(unreport, rejection);
27623 Promise.onFatalRejection = function(rejection) {
27624 enqueue(throwit, rejection.value);
27629 var running = null;
27631 function report(r) {
27634 logError('Potentially unhandled rejection [' + r.id + '] ' + format.formatError(r.value));
27638 function unreport(r) {
27639 var i = reported.indexOf(r);
27641 reported.splice(i, 1);
27642 logInfo('Handled previous rejection [' + r.id + '] ' + format.formatObject(r.value));
27646 function enqueue(f, x) {
27648 if(running === null) {
27649 running = setTimer(flush, 0);
27655 while(tasks.length > 0) {
27656 tasks.shift()(tasks.shift());
27663 function throwit(e) {
27670 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
27672 },{"../env":284,"../format":285}],283:[function(require,module,exports){
27673 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27674 /** @author Brian Cavalier */
27675 /** @author John Hann */
27677 (function(define) { 'use strict';
27678 define(function() {
27680 return function addWith(Promise) {
27682 * Returns a promise whose handlers will be called with `this` set to
27683 * the supplied receiver. Subsequent promises derived from the
27684 * returned promise will also have their handlers called with receiver
27685 * as `this`. Calling `with` with undefined or no arguments will return
27686 * a promise whose handlers will again be called in the usual Promises/A+
27687 * way (no `this`) thus safely undoing any previous `with` in the
27690 * WARNING: Promises returned from `with`/`withThis` are NOT Promises/A+
27691 * compliant, specifically violating 2.2.5 (http://promisesaplus.com/#point-41)
27693 * @param {object} receiver `this` value for all handlers attached to
27694 * the returned promise.
27695 * @returns {Promise}
27697 Promise.prototype['with'] = Promise.prototype.withThis = function(receiver) {
27698 var p = this._beget();
27699 var child = p._handler;
27700 child.receiver = receiver;
27701 this._handler.chain(child, receiver);
27709 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
27712 },{}],284:[function(require,module,exports){
27713 (function (process){
27714 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27715 /** @author Brian Cavalier */
27716 /** @author John Hann */
27718 /*global process,document,setTimeout,clearTimeout,MutationObserver,WebKitMutationObserver*/
27719 (function(define) { 'use strict';
27720 define(function(require) {
27721 /*jshint maxcomplexity:6*/
27723 // Sniff "best" async scheduling option
27724 // Prefer process.nextTick or MutationObserver, then check for
27725 // setTimeout, and finally vertx, since its the only env that doesn't
27729 var capturedSetTimeout = typeof setTimeout !== 'undefined' && setTimeout;
27732 var setTimer = function(f, ms) { return setTimeout(f, ms); };
27733 var clearTimer = function(t) { return clearTimeout(t); };
27734 var asap = function (f) { return capturedSetTimeout(f, 0); };
27736 // Detect specific env
27737 if (isNode()) { // Node
27738 asap = function (f) { return process.nextTick(f); };
27740 } else if (MutationObs = hasMutationObserver()) { // Modern browser
27741 asap = initMutationObserver(MutationObs);
27743 } else if (!capturedSetTimeout) { // vert.x
27744 var vertxRequire = require;
27745 var vertx = vertxRequire('vertx');
27746 setTimer = function (f, ms) { return vertx.setTimer(ms, f); };
27747 clearTimer = vertx.cancelTimer;
27748 asap = vertx.runOnLoop || vertx.runOnContext;
27752 setTimer: setTimer,
27753 clearTimer: clearTimer,
27757 function isNode () {
27758 return typeof process !== 'undefined' &&
27759 Object.prototype.toString.call(process) === '[object process]';
27762 function hasMutationObserver () {
27763 return (typeof MutationObserver !== 'undefined' && MutationObserver) ||
27764 (typeof WebKitMutationObserver !== 'undefined' && WebKitMutationObserver);
27767 function initMutationObserver(MutationObserver) {
27769 var node = document.createTextNode('');
27770 var o = new MutationObserver(run);
27771 o.observe(node, { characterData: true });
27775 scheduled = void 0;
27780 return function (f) {
27782 node.data = (i ^= 1);
27786 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
27788 }).call(this,require('_process'))
27790 },{"_process":7}],285:[function(require,module,exports){
27791 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27792 /** @author Brian Cavalier */
27793 /** @author John Hann */
27795 (function(define) { 'use strict';
27796 define(function() {
27799 formatError: formatError,
27800 formatObject: formatObject,
27801 tryStringify: tryStringify
27805 * Format an error into a string. If e is an Error and has a stack property,
27806 * it's returned. Otherwise, e is formatted using formatObject, with a
27807 * warning added about e not being a proper Error.
27809 * @returns {String} formatted string, suitable for output to developers
27811 function formatError(e) {
27812 var s = typeof e === 'object' && e !== null && (e.stack || e.message) ? e.stack || e.message : formatObject(e);
27813 return e instanceof Error ? s : s + ' (WARNING: non-Error used)';
27817 * Format an object, detecting "plain" objects and running them through
27818 * JSON.stringify if possible.
27819 * @param {Object} o
27820 * @returns {string}
27822 function formatObject(o) {
27824 if(s === '[object Object]' && typeof JSON !== 'undefined') {
27825 s = tryStringify(o, s);
27831 * Try to return the result of JSON.stringify(x). If that fails, return
27834 * @param {*} defaultValue
27835 * @returns {String|*} JSON.stringify(x) or defaultValue
27837 function tryStringify(x, defaultValue) {
27839 return JSON.stringify(x);
27841 return defaultValue;
27846 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
27848 },{}],286:[function(require,module,exports){
27849 (function (process){
27850 /** @license MIT License (c) copyright 2010-2014 original author or authors */
27851 /** @author Brian Cavalier */
27852 /** @author John Hann */
27854 (function(define) { 'use strict';
27855 define(function() {
27857 return function makePromise(environment) {
27859 var tasks = environment.scheduler;
27860 var emitRejection = initEmitRejection();
27862 var objectCreate = Object.create ||
27864 function Child() {}
27865 Child.prototype = proto;
27866 return new Child();
27870 * Create a promise whose fate is determined by resolver
27872 * @returns {Promise} promise
27875 function Promise(resolver, handler) {
27876 this._handler = resolver === Handler ? handler : init(resolver);
27880 * Run the supplied resolver
27882 * @returns {Pending}
27884 function init(resolver) {
27885 var handler = new Pending();
27888 resolver(promiseResolve, promiseReject, promiseNotify);
27896 * Transition from pre-resolution state to post-resolution state, notifying
27897 * all listeners of the ultimate fulfillment or rejection
27898 * @param {*} x resolution value
27900 function promiseResolve (x) {
27901 handler.resolve(x);
27904 * Reject this promise with reason, which will be used verbatim
27905 * @param {Error|*} reason rejection reason, strongly suggested
27906 * to be an Error type
27908 function promiseReject (reason) {
27909 handler.reject(reason);
27914 * Issue a progress event, notifying all progress listeners
27915 * @param {*} x progress event payload to pass to all listeners
27917 function promiseNotify (x) {
27924 Promise.resolve = resolve;
27925 Promise.reject = reject;
27926 Promise.never = never;
27928 Promise._defer = defer;
27929 Promise._handler = getHandler;
27932 * Returns a trusted promise. If x is already a trusted promise, it is
27933 * returned, otherwise returns a new trusted Promise which follows x.
27935 * @return {Promise} promise
27937 function resolve(x) {
27938 return isPromise(x) ? x
27939 : new Promise(Handler, new Async(getHandler(x)));
27943 * Return a reject promise with x as its reason (x is used verbatim)
27945 * @returns {Promise} rejected promise
27947 function reject(x) {
27948 return new Promise(Handler, new Async(new Rejected(x)));
27952 * Return a promise that remains pending forever
27953 * @returns {Promise} forever-pending promise.
27956 return foreverPendingPromise; // Should be frozen
27960 * Creates an internal {promise, resolver} pair
27962 * @returns {Promise}
27965 return new Promise(Handler, new Pending());
27968 // Transformation and flow control
27971 * Transform this promise's fulfillment value, returning a new Promise
27972 * for the transformed result. If the promise cannot be fulfilled, onRejected
27973 * is called with the reason. onProgress *may* be called with updates toward
27974 * this promise's fulfillment.
27975 * @param {function=} onFulfilled fulfillment handler
27976 * @param {function=} onRejected rejection handler
27977 * @param {function=} onProgress @deprecated progress handler
27978 * @return {Promise} new promise
27980 Promise.prototype.then = function(onFulfilled, onRejected, onProgress) {
27981 var parent = this._handler;
27982 var state = parent.join().state();
27984 if ((typeof onFulfilled !== 'function' && state > 0) ||
27985 (typeof onRejected !== 'function' && state < 0)) {
27986 // Short circuit: value will not change, simply share handler
27987 return new this.constructor(Handler, parent);
27990 var p = this._beget();
27991 var child = p._handler;
27993 parent.chain(child, parent.receiver, onFulfilled, onRejected, onProgress);
27999 * If this promise cannot be fulfilled due to an error, call onRejected to
28000 * handle the error. Shortcut for .then(undefined, onRejected)
28001 * @param {function?} onRejected
28002 * @return {Promise}
28004 Promise.prototype['catch'] = function(onRejected) {
28005 return this.then(void 0, onRejected);
28009 * Creates a new, pending promise of the same type as this promise
28011 * @returns {Promise}
28013 Promise.prototype._beget = function() {
28014 return begetFrom(this._handler, this.constructor);
28017 function begetFrom(parent, Promise) {
28018 var child = new Pending(parent.receiver, parent.join().context);
28019 return new Promise(Handler, child);
28022 // Array combinators
28025 Promise.race = race;
28026 Promise._traverse = traverse;
28029 * Return a promise that will fulfill when all promises in the
28030 * input array have fulfilled, or will reject when one of the
28031 * promises rejects.
28032 * @param {array} promises array of promises
28033 * @returns {Promise} promise for array of fulfillment values
28035 function all(promises) {
28036 return traverseWith(snd, null, promises);
28040 * Array<Promise<X>> -> Promise<Array<f(X)>>
28042 * @param {function} f function to apply to each promise's value
28043 * @param {Array} promises array of promises
28044 * @returns {Promise} promise for transformed values
28046 function traverse(f, promises) {
28047 return traverseWith(tryCatch2, f, promises);
28050 function traverseWith(tryMap, f, promises) {
28051 var handler = typeof f === 'function' ? mapAt : settleAt;
28053 var resolver = new Pending();
28054 var pending = promises.length >>> 0;
28055 var results = new Array(pending);
28057 for (var i = 0, x; i < promises.length && !resolver.resolved; ++i) {
28060 if (x === void 0 && !(i in promises)) {
28065 traverseAt(promises, handler, i, x, resolver);
28068 if(pending === 0) {
28069 resolver.become(new Fulfilled(results));
28072 return new Promise(Handler, resolver);
28074 function mapAt(i, x, resolver) {
28075 if(!resolver.resolved) {
28076 traverseAt(promises, settleAt, i, tryMap(f, x, i), resolver);
28080 function settleAt(i, x, resolver) {
28082 if(--pending === 0) {
28083 resolver.become(new Fulfilled(results));
28088 function traverseAt(promises, handler, i, x, resolver) {
28089 if (maybeThenable(x)) {
28090 var h = getHandlerMaybeThenable(x);
28094 h.fold(handler, i, void 0, resolver);
28095 } else if (s > 0) {
28096 handler(i, h.value, resolver);
28098 resolver.become(h);
28099 visitRemaining(promises, i+1, h);
28102 handler(i, x, resolver);
28106 Promise._visitRemaining = visitRemaining;
28107 function visitRemaining(promises, start, handler) {
28108 for(var i=start; i<promises.length; ++i) {
28109 markAsHandled(getHandler(promises[i]), handler);
28113 function markAsHandled(h, handler) {
28114 if(h === handler) {
28120 h.visit(h, void 0, h._unreport);
28127 * Fulfill-reject competitive race. Return a promise that will settle
28128 * to the same state as the earliest input promise to settle.
28130 * WARNING: The ES6 Promise spec requires that race()ing an empty array
28131 * must return a promise that is pending forever. This implementation
28132 * returns a singleton forever-pending promise, the same singleton that is
28133 * returned by Promise.never(), thus can be checked with ===
28135 * @param {array} promises array of promises to race
28136 * @returns {Promise} if input is non-empty, a promise that will settle
28137 * to the same outcome as the earliest input promise to settle. if empty
28138 * is empty, returns a promise that will never settle.
28140 function race(promises) {
28141 if(typeof promises !== 'object' || promises === null) {
28142 return reject(new TypeError('non-iterable passed to race()'));
28145 // Sigh, race([]) is untestable unless we return *something*
28146 // that is recognizable without calling .then() on it.
28147 return promises.length === 0 ? never()
28148 : promises.length === 1 ? resolve(promises[0])
28149 : runRace(promises);
28152 function runRace(promises) {
28153 var resolver = new Pending();
28155 for(i=0; i<promises.length; ++i) {
28157 if (x === void 0 && !(i in promises)) {
28162 if(h.state() !== 0) {
28163 resolver.become(h);
28164 visitRemaining(promises, i+1, h);
28167 h.visit(resolver, resolver.resolve, resolver.reject);
28170 return new Promise(Handler, resolver);
28173 // Promise internals
28174 // Below this, everything is @private
28177 * Get an appropriate handler for x, without checking for cycles
28179 * @returns {object} handler
28181 function getHandler(x) {
28183 return x._handler.join();
28185 return maybeThenable(x) ? getHandlerUntrusted(x) : new Fulfilled(x);
28189 * Get a handler for thenable x.
28190 * NOTE: You must only call this if maybeThenable(x) == true
28191 * @param {object|function|Promise} x
28192 * @returns {object} handler
28194 function getHandlerMaybeThenable(x) {
28195 return isPromise(x) ? x._handler.join() : getHandlerUntrusted(x);
28199 * Get a handler for potentially untrusted thenable x
28201 * @returns {object} handler
28203 function getHandlerUntrusted(x) {
28205 var untrustedThen = x.then;
28206 return typeof untrustedThen === 'function'
28207 ? new Thenable(untrustedThen, x)
28208 : new Fulfilled(x);
28210 return new Rejected(e);
28215 * Handler for a promise that is pending forever
28218 function Handler() {}
28220 Handler.prototype.when
28221 = Handler.prototype.become
28222 = Handler.prototype.notify // deprecated
28223 = Handler.prototype.fail
28224 = Handler.prototype._unreport
28225 = Handler.prototype._report
28228 Handler.prototype._state = 0;
28230 Handler.prototype.state = function() {
28231 return this._state;
28235 * Recursively collapse handler chain to find the handler
28236 * nearest to the fully resolved value.
28237 * @returns {object} handler nearest the fully resolved value
28239 Handler.prototype.join = function() {
28241 while(h.handler !== void 0) {
28247 Handler.prototype.chain = function(to, receiver, fulfilled, rejected, progress) {
28250 receiver: receiver,
28251 fulfilled: fulfilled,
28252 rejected: rejected,
28257 Handler.prototype.visit = function(receiver, fulfilled, rejected, progress) {
28258 this.chain(failIfRejected, receiver, fulfilled, rejected, progress);
28261 Handler.prototype.fold = function(f, z, c, to) {
28262 this.when(new Fold(f, z, c, to));
28266 * Handler that invokes fail() on any handler it becomes
28269 function FailIfRejected() {}
28271 inherit(Handler, FailIfRejected);
28273 FailIfRejected.prototype.become = function(h) {
28277 var failIfRejected = new FailIfRejected();
28280 * Handler that manages a queue of consumers waiting on a pending promise
28283 function Pending(receiver, inheritedContext) {
28284 Promise.createContext(this, inheritedContext);
28286 this.consumers = void 0;
28287 this.receiver = receiver;
28288 this.handler = void 0;
28289 this.resolved = false;
28292 inherit(Handler, Pending);
28294 Pending.prototype._state = 0;
28296 Pending.prototype.resolve = function(x) {
28297 this.become(getHandler(x));
28300 Pending.prototype.reject = function(x) {
28301 if(this.resolved) {
28305 this.become(new Rejected(x));
28308 Pending.prototype.join = function() {
28309 if (!this.resolved) {
28315 while (h.handler !== void 0) {
28318 return this.handler = cycle();
28325 Pending.prototype.run = function() {
28326 var q = this.consumers;
28327 var handler = this.handler;
28328 this.handler = this.handler.join();
28329 this.consumers = void 0;
28331 for (var i = 0; i < q.length; ++i) {
28332 handler.when(q[i]);
28336 Pending.prototype.become = function(handler) {
28337 if(this.resolved) {
28341 this.resolved = true;
28342 this.handler = handler;
28343 if(this.consumers !== void 0) {
28344 tasks.enqueue(this);
28347 if(this.context !== void 0) {
28348 handler._report(this.context);
28352 Pending.prototype.when = function(continuation) {
28353 if(this.resolved) {
28354 tasks.enqueue(new ContinuationTask(continuation, this.handler));
28356 if(this.consumers === void 0) {
28357 this.consumers = [continuation];
28359 this.consumers.push(continuation);
28367 Pending.prototype.notify = function(x) {
28368 if(!this.resolved) {
28369 tasks.enqueue(new ProgressTask(x, this));
28373 Pending.prototype.fail = function(context) {
28374 var c = typeof context === 'undefined' ? this.context : context;
28375 this.resolved && this.handler.join().fail(c);
28378 Pending.prototype._report = function(context) {
28379 this.resolved && this.handler.join()._report(context);
28382 Pending.prototype._unreport = function() {
28383 this.resolved && this.handler.join()._unreport();
28387 * Wrap another handler and force it into a future stack
28388 * @param {object} handler
28391 function Async(handler) {
28392 this.handler = handler;
28395 inherit(Handler, Async);
28397 Async.prototype.when = function(continuation) {
28398 tasks.enqueue(new ContinuationTask(continuation, this));
28401 Async.prototype._report = function(context) {
28402 this.join()._report(context);
28405 Async.prototype._unreport = function() {
28406 this.join()._unreport();
28410 * Handler that wraps an untrusted thenable and assimilates it in a future stack
28411 * @param {function} then
28412 * @param {{then: function}} thenable
28415 function Thenable(then, thenable) {
28416 Pending.call(this);
28417 tasks.enqueue(new AssimilateTask(then, thenable, this));
28420 inherit(Pending, Thenable);
28423 * Handler for a fulfilled promise
28424 * @param {*} x fulfillment value
28427 function Fulfilled(x) {
28428 Promise.createContext(this);
28432 inherit(Handler, Fulfilled);
28434 Fulfilled.prototype._state = 1;
28436 Fulfilled.prototype.fold = function(f, z, c, to) {
28437 runContinuation3(f, z, this, c, to);
28440 Fulfilled.prototype.when = function(cont) {
28441 runContinuation1(cont.fulfilled, this, cont.receiver, cont.resolver);
28447 * Handler for a rejected promise
28448 * @param {*} x rejection reason
28451 function Rejected(x) {
28452 Promise.createContext(this);
28454 this.id = ++errorId;
28456 this.handled = false;
28457 this.reported = false;
28462 inherit(Handler, Rejected);
28464 Rejected.prototype._state = -1;
28466 Rejected.prototype.fold = function(f, z, c, to) {
28470 Rejected.prototype.when = function(cont) {
28471 if(typeof cont.rejected === 'function') {
28474 runContinuation1(cont.rejected, this, cont.receiver, cont.resolver);
28477 Rejected.prototype._report = function(context) {
28478 tasks.afterQueue(new ReportTask(this, context));
28481 Rejected.prototype._unreport = function() {
28485 this.handled = true;
28486 tasks.afterQueue(new UnreportTask(this));
28489 Rejected.prototype.fail = function(context) {
28490 this.reported = true;
28491 emitRejection('unhandledRejection', this);
28492 Promise.onFatalRejection(this, context === void 0 ? this.context : context);
28495 function ReportTask(rejection, context) {
28496 this.rejection = rejection;
28497 this.context = context;
28500 ReportTask.prototype.run = function() {
28501 if(!this.rejection.handled && !this.rejection.reported) {
28502 this.rejection.reported = true;
28503 emitRejection('unhandledRejection', this.rejection) ||
28504 Promise.onPotentiallyUnhandledRejection(this.rejection, this.context);
28508 function UnreportTask(rejection) {
28509 this.rejection = rejection;
28512 UnreportTask.prototype.run = function() {
28513 if(this.rejection.reported) {
28514 emitRejection('rejectionHandled', this.rejection) ||
28515 Promise.onPotentiallyUnhandledRejectionHandled(this.rejection);
28519 // Unhandled rejection hooks
28520 // By default, everything is a noop
28522 Promise.createContext
28523 = Promise.enterContext
28524 = Promise.exitContext
28525 = Promise.onPotentiallyUnhandledRejection
28526 = Promise.onPotentiallyUnhandledRejectionHandled
28527 = Promise.onFatalRejection
28530 // Errors and singletons
28532 var foreverPendingHandler = new Handler();
28533 var foreverPendingPromise = new Promise(Handler, foreverPendingHandler);
28536 return new Rejected(new TypeError('Promise cycle'));
28542 * Run a single consumer
28545 function ContinuationTask(continuation, handler) {
28546 this.continuation = continuation;
28547 this.handler = handler;
28550 ContinuationTask.prototype.run = function() {
28551 this.handler.join().when(this.continuation);
28555 * Run a queue of progress handlers
28558 function ProgressTask(value, handler) {
28559 this.handler = handler;
28560 this.value = value;
28563 ProgressTask.prototype.run = function() {
28564 var q = this.handler.consumers;
28569 for (var c, i = 0; i < q.length; ++i) {
28571 runNotify(c.progress, this.value, this.handler, c.receiver, c.resolver);
28576 * Assimilate a thenable, sending it's value to resolver
28577 * @param {function} then
28578 * @param {object|function} thenable
28579 * @param {object} resolver
28582 function AssimilateTask(then, thenable, resolver) {
28584 this.thenable = thenable;
28585 this.resolver = resolver;
28588 AssimilateTask.prototype.run = function() {
28589 var h = this.resolver;
28590 tryAssimilate(this._then, this.thenable, _resolve, _reject, _notify);
28592 function _resolve(x) { h.resolve(x); }
28593 function _reject(x) { h.reject(x); }
28594 function _notify(x) { h.notify(x); }
28597 function tryAssimilate(then, thenable, resolve, reject, notify) {
28599 then.call(thenable, resolve, reject, notify);
28606 * Fold a handler value with z
28609 function Fold(f, z, c, to) {
28610 this.f = f; this.z = z; this.c = c; this.to = to;
28611 this.resolver = failIfRejected;
28612 this.receiver = this;
28615 Fold.prototype.fulfilled = function(x) {
28616 this.f.call(this.c, this.z, x, this.to);
28619 Fold.prototype.rejected = function(x) {
28623 Fold.prototype.progress = function(x) {
28631 * @returns {boolean} true iff x is a trusted Promise
28633 function isPromise(x) {
28634 return x instanceof Promise;
28638 * Test just enough to rule out primitives, in order to take faster
28639 * paths in some code
28641 * @returns {boolean} false iff x is guaranteed *not* to be a thenable
28643 function maybeThenable(x) {
28644 return (typeof x === 'object' || typeof x === 'function') && x !== null;
28647 function runContinuation1(f, h, receiver, next) {
28648 if(typeof f !== 'function') {
28649 return next.become(h);
28652 Promise.enterContext(h);
28653 tryCatchReject(f, h.value, receiver, next);
28654 Promise.exitContext();
28657 function runContinuation3(f, x, h, receiver, next) {
28658 if(typeof f !== 'function') {
28659 return next.become(h);
28662 Promise.enterContext(h);
28663 tryCatchReject3(f, x, h.value, receiver, next);
28664 Promise.exitContext();
28670 function runNotify(f, x, h, receiver, next) {
28671 if(typeof f !== 'function') {
28672 return next.notify(x);
28675 Promise.enterContext(h);
28676 tryCatchReturn(f, x, receiver, next);
28677 Promise.exitContext();
28680 function tryCatch2(f, a, b) {
28689 * Return f.call(thisArg, x), or if it throws return a rejected promise for
28690 * the thrown exception
28692 function tryCatchReject(f, x, thisArg, next) {
28694 next.become(getHandler(f.call(thisArg, x)));
28696 next.become(new Rejected(e));
28701 * Same as above, but includes the extra argument parameter.
28703 function tryCatchReject3(f, x, y, thisArg, next) {
28705 f.call(thisArg, x, y, next);
28707 next.become(new Rejected(e));
28713 * Return f.call(thisArg, x), or if it throws, *return* the exception
28715 function tryCatchReturn(f, x, thisArg, next) {
28717 next.notify(f.call(thisArg, x));
28723 function inherit(Parent, Child) {
28724 Child.prototype = objectCreate(Parent.prototype);
28725 Child.prototype.constructor = Child;
28728 function snd(x, y) {
28734 function hasCustomEvent() {
28735 if(typeof CustomEvent === 'function') {
28737 var ev = new CustomEvent('unhandledRejection');
28738 return ev instanceof CustomEvent;
28739 } catch (ignoredException) {}
28744 function hasInternetExplorerCustomEvent() {
28745 if(typeof document !== 'undefined' && typeof document.createEvent === 'function') {
28747 // Try to create one event to make sure it's supported
28748 var ev = document.createEvent('CustomEvent');
28749 ev.initCustomEvent('eventType', false, true, {});
28751 } catch (ignoredException) {}
28756 function initEmitRejection() {
28757 /*global process, self, CustomEvent*/
28758 if(typeof process !== 'undefined' && process !== null
28759 && typeof process.emit === 'function') {
28760 // Returning falsy here means to call the default
28761 // onPotentiallyUnhandledRejection API. This is safe even in
28762 // browserify since process.emit always returns falsy in browserify:
28763 // https://github.com/defunctzombie/node-process/blob/master/browser.js#L40-L46
28764 return function(type, rejection) {
28765 return type === 'unhandledRejection'
28766 ? process.emit(type, rejection.value, rejection)
28767 : process.emit(type, rejection);
28769 } else if(typeof self !== 'undefined' && hasCustomEvent()) {
28770 return (function (self, CustomEvent) {
28771 return function (type, rejection) {
28772 var ev = new CustomEvent(type, {
28774 reason: rejection.value,
28781 return !self.dispatchEvent(ev);
28783 }(self, CustomEvent));
28784 } else if(typeof self !== 'undefined' && hasInternetExplorerCustomEvent()) {
28785 return (function(self, document) {
28786 return function(type, rejection) {
28787 var ev = document.createEvent('CustomEvent');
28788 ev.initCustomEvent(type, false, true, {
28789 reason: rejection.value,
28793 return !self.dispatchEvent(ev);
28795 }(self, document));
28804 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
28806 }).call(this,require('_process'))
28808 },{"_process":7}],287:[function(require,module,exports){
28809 /** @license MIT License (c) copyright 2010-2014 original author or authors */
28810 /** @author Brian Cavalier */
28811 /** @author John Hann */
28813 (function(define) { 'use strict';
28814 define(function() {
28817 pending: toPendingState,
28818 fulfilled: toFulfilledState,
28819 rejected: toRejectedState,
28823 function toPendingState() {
28824 return { state: 'pending' };
28827 function toRejectedState(e) {
28828 return { state: 'rejected', reason: e };
28831 function toFulfilledState(x) {
28832 return { state: 'fulfilled', value: x };
28835 function inspect(handler) {
28836 var state = handler.state();
28837 return state === 0 ? toPendingState()
28838 : state > 0 ? toFulfilledState(handler.value)
28839 : toRejectedState(handler.value);
28843 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
28845 },{}],288:[function(require,module,exports){
28846 /** @license MIT License (c) copyright 2010-2014 original author or authors */
28849 * Promises/A+ and when() implementation
28850 * when is part of the cujoJS family of libraries (http://cujojs.com/)
28851 * @author Brian Cavalier
28852 * @author John Hann
28854 (function(define) { 'use strict';
28855 define(function (require) {
28857 var timed = require('./lib/decorators/timed');
28858 var array = require('./lib/decorators/array');
28859 var flow = require('./lib/decorators/flow');
28860 var fold = require('./lib/decorators/fold');
28861 var inspect = require('./lib/decorators/inspect');
28862 var generate = require('./lib/decorators/iterate');
28863 var progress = require('./lib/decorators/progress');
28864 var withThis = require('./lib/decorators/with');
28865 var unhandledRejection = require('./lib/decorators/unhandledRejection');
28866 var TimeoutError = require('./lib/TimeoutError');
28868 var Promise = [array, flow, fold, generate, progress,
28869 inspect, withThis, timed, unhandledRejection]
28870 .reduce(function(Promise, feature) {
28871 return feature(Promise);
28872 }, require('./lib/Promise'));
28874 var apply = require('./lib/apply')(Promise);
28878 when.promise = promise; // Create a pending promise
28879 when.resolve = Promise.resolve; // Create a resolved promise
28880 when.reject = Promise.reject; // Create a rejected promise
28882 when.lift = lift; // lift a function to return promises
28883 when['try'] = attempt; // call a function and return a promise
28884 when.attempt = attempt; // alias for when.try
28886 when.iterate = Promise.iterate; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
28887 when.unfold = Promise.unfold; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
28889 when.join = join; // Join 2 or more promises
28891 when.all = all; // Resolve a list of promises
28892 when.settle = settle; // Settle a list of promises
28894 when.any = lift(Promise.any); // One-winner race
28895 when.some = lift(Promise.some); // Multi-winner race
28896 when.race = lift(Promise.race); // First-to-settle race
28898 when.map = map; // Array.map() for promises
28899 when.filter = filter; // Array.filter() for promises
28900 when.reduce = lift(Promise.reduce); // Array.reduce() for promises
28901 when.reduceRight = lift(Promise.reduceRight); // Array.reduceRight() for promises
28903 when.isPromiseLike = isPromiseLike; // Is something promise-like, aka thenable
28905 when.Promise = Promise; // Promise constructor
28906 when.defer = defer; // Create a {promise, resolve, reject} tuple
28910 when.TimeoutError = TimeoutError;
28913 * Get a trusted promise for x, or by transforming x with onFulfilled
28916 * @param {function?} onFulfilled callback to be called when x is
28917 * successfully fulfilled. If promiseOrValue is an immediate value, callback
28918 * will be invoked immediately.
28919 * @param {function?} onRejected callback to be called when x is
28921 * @param {function?} onProgress callback to be called when progress updates
28922 * are issued for x. @deprecated
28923 * @returns {Promise} a new promise that will fulfill with the return
28924 * value of callback or errback or the completion value of promiseOrValue if
28925 * callback and/or errback is not supplied.
28927 function when(x, onFulfilled, onRejected, onProgress) {
28928 var p = Promise.resolve(x);
28929 if (arguments.length < 2) {
28933 return p.then(onFulfilled, onRejected, onProgress);
28937 * Creates a new promise whose fate is determined by resolver.
28938 * @param {function} resolver function(resolve, reject, notify)
28939 * @returns {Promise} promise whose fate is determine by resolver
28941 function promise(resolver) {
28942 return new Promise(resolver);
28946 * Lift the supplied function, creating a version of f that returns
28947 * promises, and accepts promises as arguments.
28948 * @param {function} f
28949 * @returns {Function} version of f that returns promises
28952 return function() {
28953 for(var i=0, l=arguments.length, a=new Array(l); i<l; ++i) {
28954 a[i] = arguments[i];
28956 return apply(f, this, a);
28961 * Call f in a future turn, with the supplied args, and return a promise
28963 * @param {function} f
28964 * @returns {Promise}
28966 function attempt(f /*, args... */) {
28967 /*jshint validthis:true */
28968 for(var i=0, l=arguments.length-1, a=new Array(l); i<l; ++i) {
28969 a[i] = arguments[i+1];
28971 return apply(f, this, a);
28975 * Creates a {promise, resolver} pair, either or both of which
28976 * may be given out safely to consumers.
28977 * @return {{promise: Promise, resolve: function, reject: function, notify: function}}
28980 return new Deferred();
28983 function Deferred() {
28984 var p = Promise._defer();
28986 function resolve(x) { p._handler.resolve(x); }
28987 function reject(x) { p._handler.reject(x); }
28988 function notify(x) { p._handler.notify(x); }
28991 this.resolve = resolve;
28992 this.reject = reject;
28993 this.notify = notify;
28994 this.resolver = { resolve: resolve, reject: reject, notify: notify };
28998 * Determines if x is promise-like, i.e. a thenable object
28999 * NOTE: Will return true for *any thenable object*, and isn't truly
29000 * safe, since it may attempt to access the `then` property of x (i.e.
29001 * clever/malicious getters may do weird things)
29002 * @param {*} x anything
29003 * @returns {boolean} true if x is promise-like
29005 function isPromiseLike(x) {
29006 return x && typeof x.then === 'function';
29010 * Return a promise that will resolve only once all the supplied arguments
29011 * have resolved. The resolution value of the returned promise will be an array
29012 * containing the resolution values of each of the arguments.
29013 * @param {...*} arguments may be a mix of promises and values
29014 * @returns {Promise}
29016 function join(/* ...promises */) {
29017 return Promise.all(arguments);
29021 * Return a promise that will fulfill once all input promises have
29022 * fulfilled, or reject when any one input promise rejects.
29023 * @param {array|Promise} promises array (or promise for an array) of promises
29024 * @returns {Promise}
29026 function all(promises) {
29027 return when(promises, Promise.all);
29031 * Return a promise that will always fulfill with an array containing
29032 * the outcome states of all input promises. The returned promise
29033 * will only reject if `promises` itself is a rejected promise.
29034 * @param {array|Promise} promises array (or promise for an array) of promises
29035 * @returns {Promise} promise for array of settled state descriptors
29037 function settle(promises) {
29038 return when(promises, Promise.settle);
29042 * Promise-aware array map function, similar to `Array.prototype.map()`,
29043 * but input array may contain promises or values.
29044 * @param {Array|Promise} promises array of anything, may contain promises and values
29045 * @param {function(x:*, index:Number):*} mapFunc map function which may
29046 * return a promise or value
29047 * @returns {Promise} promise that will fulfill with an array of mapped values
29048 * or reject if any input promise rejects.
29050 function map(promises, mapFunc) {
29051 return when(promises, function(promises) {
29052 return Promise.map(promises, mapFunc);
29057 * Filter the provided array of promises using the provided predicate. Input may
29058 * contain promises and values
29059 * @param {Array|Promise} promises array of promises and values
29060 * @param {function(x:*, index:Number):boolean} predicate filtering predicate.
29061 * Must return truthy (or promise for truthy) for items to retain.
29062 * @returns {Promise} promise that will fulfill with an array containing all items
29063 * for which predicate returned truthy.
29065 function filter(promises, predicate) {
29066 return when(promises, function(promises) {
29067 return Promise.filter(promises, predicate);
29073 })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
29075 },{"./lib/Promise":271,"./lib/TimeoutError":273,"./lib/apply":274,"./lib/decorators/array":275,"./lib/decorators/flow":276,"./lib/decorators/fold":277,"./lib/decorators/inspect":278,"./lib/decorators/iterate":279,"./lib/decorators/progress":280,"./lib/decorators/timed":281,"./lib/decorators/unhandledRejection":282,"./lib/decorators/with":283}],289:[function(require,module,exports){
29076 var nativeIsArray = Array.isArray
29077 var toString = Object.prototype.toString
29079 module.exports = nativeIsArray || isArray
29081 function isArray(obj) {
29082 return toString.call(obj) === "[object Array]"
29085 },{}],290:[function(require,module,exports){
29087 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29088 if (k2 === undefined) k2 = k;
29089 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29090 }) : (function(o, m, k, k2) {
29091 if (k2 === undefined) k2 = k;
29094 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29095 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29097 Object.defineProperty(exports, "__esModule", { value: true });
29098 var APIv3_1 = require("./api/APIv3");
29099 Object.defineProperty(exports, "APIv3", { enumerable: true, get: function () { return APIv3_1.APIv3; } });
29100 var ModelCreator_1 = require("./api/ModelCreator");
29101 Object.defineProperty(exports, "ModelCreator", { enumerable: true, get: function () { return ModelCreator_1.ModelCreator; } });
29102 __exportStar(require("./api/interfaces/interfaces"), exports);
29104 },{"./api/APIv3":303,"./api/ModelCreator":304,"./api/interfaces/interfaces":305}],291:[function(require,module,exports){
29106 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29107 if (k2 === undefined) k2 = k;
29108 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29109 }) : (function(o, m, k, k2) {
29110 if (k2 === undefined) k2 = k;
29113 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29114 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29116 Object.defineProperty(exports, "__esModule", { value: true });
29117 exports.ImageBoundary = void 0;
29118 var Component_1 = require("./component/Component");
29119 Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return Component_1.Component; } });
29120 var ComponentService_1 = require("./component/ComponentService");
29121 Object.defineProperty(exports, "ComponentService", { enumerable: true, get: function () { return ComponentService_1.ComponentService; } });
29122 var HandlerBase_1 = require("./component/utils/HandlerBase");
29123 Object.defineProperty(exports, "HandlerBase", { enumerable: true, get: function () { return HandlerBase_1.HandlerBase; } });
29124 var MeshFactory_1 = require("./component/utils/MeshFactory");
29125 Object.defineProperty(exports, "MeshFactory", { enumerable: true, get: function () { return MeshFactory_1.MeshFactory; } });
29126 var MeshScene_1 = require("./component/utils/MeshScene");
29127 Object.defineProperty(exports, "MeshScene", { enumerable: true, get: function () { return MeshScene_1.MeshScene; } });
29128 var MouseOperator_1 = require("./component/utils/MouseOperator");
29129 Object.defineProperty(exports, "MouseOperator", { enumerable: true, get: function () { return MouseOperator_1.MouseOperator; } });
29130 var ComponentSize_1 = require("./component/utils/ComponentSize");
29131 Object.defineProperty(exports, "ComponentSize", { enumerable: true, get: function () { return ComponentSize_1.ComponentSize; } });
29132 var AttributionComponent_1 = require("./component/AttributionComponent");
29133 Object.defineProperty(exports, "AttributionComponent", { enumerable: true, get: function () { return AttributionComponent_1.AttributionComponent; } });
29134 var BackgroundComponent_1 = require("./component/BackgroundComponent");
29135 Object.defineProperty(exports, "BackgroundComponent", { enumerable: true, get: function () { return BackgroundComponent_1.BackgroundComponent; } });
29136 var BearingComponent_1 = require("./component/BearingComponent");
29137 Object.defineProperty(exports, "BearingComponent", { enumerable: true, get: function () { return BearingComponent_1.BearingComponent; } });
29138 var CacheComponent_1 = require("./component/CacheComponent");
29139 Object.defineProperty(exports, "CacheComponent", { enumerable: true, get: function () { return CacheComponent_1.CacheComponent; } });
29140 var CoverComponent_1 = require("./component/CoverComponent");
29141 Object.defineProperty(exports, "CoverComponent", { enumerable: true, get: function () { return CoverComponent_1.CoverComponent; } });
29142 var DebugComponent_1 = require("./component/DebugComponent");
29143 Object.defineProperty(exports, "DebugComponent", { enumerable: true, get: function () { return DebugComponent_1.DebugComponent; } });
29144 var DirectionComponent_1 = require("./component/direction/DirectionComponent");
29145 Object.defineProperty(exports, "DirectionComponent", { enumerable: true, get: function () { return DirectionComponent_1.DirectionComponent; } });
29146 var DirectionDOMCalculator_1 = require("./component/direction/DirectionDOMCalculator");
29147 Object.defineProperty(exports, "DirectionDOMCalculator", { enumerable: true, get: function () { return DirectionDOMCalculator_1.DirectionDOMCalculator; } });
29148 var DirectionDOMRenderer_1 = require("./component/direction/DirectionDOMRenderer");
29149 Object.defineProperty(exports, "DirectionDOMRenderer", { enumerable: true, get: function () { return DirectionDOMRenderer_1.DirectionDOMRenderer; } });
29150 var ImageComponent_1 = require("./component/ImageComponent");
29151 Object.defineProperty(exports, "ImageComponent", { enumerable: true, get: function () { return ImageComponent_1.ImageComponent; } });
29152 var KeyboardComponent_1 = require("./component/keyboard/KeyboardComponent");
29153 Object.defineProperty(exports, "KeyboardComponent", { enumerable: true, get: function () { return KeyboardComponent_1.KeyboardComponent; } });
29154 var KeyPlayHandler_1 = require("./component/keyboard/KeyPlayHandler");
29155 Object.defineProperty(exports, "KeyPlayHandler", { enumerable: true, get: function () { return KeyPlayHandler_1.KeyPlayHandler; } });
29156 var KeyZoomHandler_1 = require("./component/keyboard/KeyZoomHandler");
29157 Object.defineProperty(exports, "KeyZoomHandler", { enumerable: true, get: function () { return KeyZoomHandler_1.KeyZoomHandler; } });
29158 var KeySequenceNavigationHandler_1 = require("./component/keyboard/KeySequenceNavigationHandler");
29159 Object.defineProperty(exports, "KeySequenceNavigationHandler", { enumerable: true, get: function () { return KeySequenceNavigationHandler_1.KeySequenceNavigationHandler; } });
29160 var KeySpatialNavigationHandler_1 = require("./component/keyboard/KeySpatialNavigationHandler");
29161 Object.defineProperty(exports, "KeySpatialNavigationHandler", { enumerable: true, get: function () { return KeySpatialNavigationHandler_1.KeySpatialNavigationHandler; } });
29162 var LoadingComponent_1 = require("./component/LoadingComponent");
29163 Object.defineProperty(exports, "LoadingComponent", { enumerable: true, get: function () { return LoadingComponent_1.LoadingComponent; } });
29164 var Marker_1 = require("./component/marker/marker/Marker");
29165 Object.defineProperty(exports, "Marker", { enumerable: true, get: function () { return Marker_1.Marker; } });
29166 var MarkerComponent_1 = require("./component/marker/MarkerComponent");
29167 Object.defineProperty(exports, "MarkerComponent", { enumerable: true, get: function () { return MarkerComponent_1.MarkerComponent; } });
29168 var MarkerScene_1 = require("./component/marker/MarkerScene");
29169 Object.defineProperty(exports, "MarkerScene", { enumerable: true, get: function () { return MarkerScene_1.MarkerScene; } });
29170 var MarkerSet_1 = require("./component/marker/MarkerSet");
29171 Object.defineProperty(exports, "MarkerSet", { enumerable: true, get: function () { return MarkerSet_1.MarkerSet; } });
29172 var MouseComponent_1 = require("./component/mouse/MouseComponent");
29173 Object.defineProperty(exports, "MouseComponent", { enumerable: true, get: function () { return MouseComponent_1.MouseComponent; } });
29174 __exportStar(require("./component/mouse/HandlerTypes"), exports);
29175 var BounceHandler_1 = require("./component/mouse/BounceHandler");
29176 Object.defineProperty(exports, "BounceHandler", { enumerable: true, get: function () { return BounceHandler_1.BounceHandler; } });
29177 var DragPanHandler_1 = require("./component/mouse/DragPanHandler");
29178 Object.defineProperty(exports, "DragPanHandler", { enumerable: true, get: function () { return DragPanHandler_1.DragPanHandler; } });
29179 var DoubleClickZoomHandler_1 = require("./component/mouse/DoubleClickZoomHandler");
29180 Object.defineProperty(exports, "DoubleClickZoomHandler", { enumerable: true, get: function () { return DoubleClickZoomHandler_1.DoubleClickZoomHandler; } });
29181 var EarthControlHandler_1 = require("./component/mouse/EarthControlHandler");
29182 Object.defineProperty(exports, "EarthControlHandler", { enumerable: true, get: function () { return EarthControlHandler_1.EarthControlHandler; } });
29183 var ScrollZoomHandler_1 = require("./component/mouse/ScrollZoomHandler");
29184 Object.defineProperty(exports, "ScrollZoomHandler", { enumerable: true, get: function () { return ScrollZoomHandler_1.ScrollZoomHandler; } });
29185 var TouchZoomHandler_1 = require("./component/mouse/TouchZoomHandler");
29186 Object.defineProperty(exports, "TouchZoomHandler", { enumerable: true, get: function () { return TouchZoomHandler_1.TouchZoomHandler; } });
29187 var ImageBoundary = require("./component/mouse/ImageBoundary");
29188 exports.ImageBoundary = ImageBoundary;
29189 var Popup_1 = require("./component/popup/popup/Popup");
29190 Object.defineProperty(exports, "Popup", { enumerable: true, get: function () { return Popup_1.Popup; } });
29191 var PopupComponent_1 = require("./component/popup/PopupComponent");
29192 Object.defineProperty(exports, "PopupComponent", { enumerable: true, get: function () { return PopupComponent_1.PopupComponent; } });
29193 var NavigationComponent_1 = require("./component/NavigationComponent");
29194 Object.defineProperty(exports, "NavigationComponent", { enumerable: true, get: function () { return NavigationComponent_1.NavigationComponent; } });
29195 var RouteComponent_1 = require("./component/RouteComponent");
29196 Object.defineProperty(exports, "RouteComponent", { enumerable: true, get: function () { return RouteComponent_1.RouteComponent; } });
29197 var SequenceComponent_1 = require("./component/sequence/SequenceComponent");
29198 Object.defineProperty(exports, "SequenceComponent", { enumerable: true, get: function () { return SequenceComponent_1.SequenceComponent; } });
29199 var SequenceDOMRenderer_1 = require("./component/sequence/SequenceDOMRenderer");
29200 Object.defineProperty(exports, "SequenceDOMRenderer", { enumerable: true, get: function () { return SequenceDOMRenderer_1.SequenceDOMRenderer; } });
29201 var SequenceMode_1 = require("./component/sequence/SequenceMode");
29202 Object.defineProperty(exports, "SequenceMode", { enumerable: true, get: function () { return SequenceMode_1.SequenceMode; } });
29203 var SpatialDataCache_1 = require("./component/spatialdata/SpatialDataCache");
29204 Object.defineProperty(exports, "SpatialDataCache", { enumerable: true, get: function () { return SpatialDataCache_1.SpatialDataCache; } });
29205 var SpatialDataComponent_1 = require("./component/spatialdata/SpatialDataComponent");
29206 Object.defineProperty(exports, "SpatialDataComponent", { enumerable: true, get: function () { return SpatialDataComponent_1.SpatialDataComponent; } });
29207 var SpatialDataScene_1 = require("./component/spatialdata/SpatialDataScene");
29208 Object.defineProperty(exports, "SpatialDataScene", { enumerable: true, get: function () { return SpatialDataScene_1.SpatialDataScene; } });
29209 var ImagePlaneComponent_1 = require("./component/imageplane/ImagePlaneComponent");
29210 Object.defineProperty(exports, "ImagePlaneComponent", { enumerable: true, get: function () { return ImagePlaneComponent_1.ImagePlaneComponent; } });
29211 var ImagePlaneGLRenderer_1 = require("./component/imageplane/ImagePlaneGLRenderer");
29212 Object.defineProperty(exports, "ImagePlaneGLRenderer", { enumerable: true, get: function () { return ImagePlaneGLRenderer_1.ImagePlaneGLRenderer; } });
29213 var Shaders_1 = require("./component/shaders/Shaders");
29214 Object.defineProperty(exports, "Shaders", { enumerable: true, get: function () { return Shaders_1.Shaders; } });
29215 var SimpleMarker_1 = require("./component/marker/marker/SimpleMarker");
29216 Object.defineProperty(exports, "SimpleMarker", { enumerable: true, get: function () { return SimpleMarker_1.SimpleMarker; } });
29217 var CircleMarker_1 = require("./component/marker/marker/CircleMarker");
29218 Object.defineProperty(exports, "CircleMarker", { enumerable: true, get: function () { return CircleMarker_1.CircleMarker; } });
29219 var SliderComponent_1 = require("./component/slider/SliderComponent");
29220 Object.defineProperty(exports, "SliderComponent", { enumerable: true, get: function () { return SliderComponent_1.SliderComponent; } });
29221 var SliderDOMRenderer_1 = require("./component/slider/SliderDOMRenderer");
29222 Object.defineProperty(exports, "SliderDOMRenderer", { enumerable: true, get: function () { return SliderDOMRenderer_1.SliderDOMRenderer; } });
29223 var SliderGLRenderer_1 = require("./component/slider/SliderGLRenderer");
29224 Object.defineProperty(exports, "SliderGLRenderer", { enumerable: true, get: function () { return SliderGLRenderer_1.SliderGLRenderer; } });
29225 var StatsComponent_1 = require("./component/StatsComponent");
29226 Object.defineProperty(exports, "StatsComponent", { enumerable: true, get: function () { return StatsComponent_1.StatsComponent; } });
29227 var TagHandlerBase_1 = require("./component/tag/handlers/TagHandlerBase");
29228 Object.defineProperty(exports, "TagHandlerBase", { enumerable: true, get: function () { return TagHandlerBase_1.TagHandlerBase; } });
29229 var CreateHandlerBase_1 = require("./component/tag/handlers/CreateHandlerBase");
29230 Object.defineProperty(exports, "CreateHandlerBase", { enumerable: true, get: function () { return CreateHandlerBase_1.CreateHandlerBase; } });
29231 var CreatePointHandler_1 = require("./component/tag/handlers/CreatePointHandler");
29232 Object.defineProperty(exports, "CreatePointHandler", { enumerable: true, get: function () { return CreatePointHandler_1.CreatePointHandler; } });
29233 var CreateVertexHandler_1 = require("./component/tag/handlers/CreateVertexHandler");
29234 Object.defineProperty(exports, "CreateVertexHandler", { enumerable: true, get: function () { return CreateVertexHandler_1.CreateVertexHandler; } });
29235 var CreatePointsHandler_1 = require("./component/tag/handlers/CreatePointsHandler");
29236 Object.defineProperty(exports, "CreatePointsHandler", { enumerable: true, get: function () { return CreatePointsHandler_1.CreatePointsHandler; } });
29237 var CreatePolygonHandler_1 = require("./component/tag/handlers/CreatePolygonHandler");
29238 Object.defineProperty(exports, "CreatePolygonHandler", { enumerable: true, get: function () { return CreatePolygonHandler_1.CreatePolygonHandler; } });
29239 var CreateRectHandler_1 = require("./component/tag/handlers/CreateRectHandler");
29240 Object.defineProperty(exports, "CreateRectHandler", { enumerable: true, get: function () { return CreateRectHandler_1.CreateRectHandler; } });
29241 var CreateRectDragHandler_1 = require("./component/tag/handlers/CreateRectDragHandler");
29242 Object.defineProperty(exports, "CreateRectDragHandler", { enumerable: true, get: function () { return CreateRectDragHandler_1.CreateRectDragHandler; } });
29243 var EditVertexHandler_1 = require("./component/tag/handlers/EditVertexHandler");
29244 Object.defineProperty(exports, "EditVertexHandler", { enumerable: true, get: function () { return EditVertexHandler_1.EditVertexHandler; } });
29245 var Tag_1 = require("./component/tag/tag/Tag");
29246 Object.defineProperty(exports, "Tag", { enumerable: true, get: function () { return Tag_1.Tag; } });
29247 var OutlineTag_1 = require("./component/tag/tag/OutlineTag");
29248 Object.defineProperty(exports, "OutlineTag", { enumerable: true, get: function () { return OutlineTag_1.OutlineTag; } });
29249 var ExtremePointTag_1 = require("./component/tag/tag/ExtremePointTag");
29250 Object.defineProperty(exports, "ExtremePointTag", { enumerable: true, get: function () { return ExtremePointTag_1.ExtremePointTag; } });
29251 var RenderTag_1 = require("./component/tag/tag/RenderTag");
29252 Object.defineProperty(exports, "RenderTag", { enumerable: true, get: function () { return RenderTag_1.RenderTag; } });
29253 var OutlineRenderTagBase_1 = require("./component/tag/tag/OutlineRenderTagBase");
29254 Object.defineProperty(exports, "OutlineRenderTagBase", { enumerable: true, get: function () { return OutlineRenderTagBase_1.OutlineRenderTagBase; } });
29255 var OutlineRenderTag_1 = require("./component/tag/tag/OutlineRenderTag");
29256 Object.defineProperty(exports, "OutlineRenderTag", { enumerable: true, get: function () { return OutlineRenderTag_1.OutlineRenderTag; } });
29257 var ExtremePointRenderTag_1 = require("./component/tag/tag/ExtremePointRenderTag");
29258 Object.defineProperty(exports, "ExtremePointRenderTag", { enumerable: true, get: function () { return ExtremePointRenderTag_1.ExtremePointRenderTag; } });
29259 var SpotTag_1 = require("./component/tag/tag/SpotTag");
29260 Object.defineProperty(exports, "SpotTag", { enumerable: true, get: function () { return SpotTag_1.SpotTag; } });
29261 var SpotRenderTag_1 = require("./component/tag/tag/SpotRenderTag");
29262 Object.defineProperty(exports, "SpotRenderTag", { enumerable: true, get: function () { return SpotRenderTag_1.SpotRenderTag; } });
29263 var TagDomain_1 = require("./component/tag/tag/TagDomain");
29264 Object.defineProperty(exports, "TagDomain", { enumerable: true, get: function () { return TagDomain_1.TagDomain; } });
29265 var TagComponent_1 = require("./component/tag/TagComponent");
29266 Object.defineProperty(exports, "TagComponent", { enumerable: true, get: function () { return TagComponent_1.TagComponent; } });
29267 var TagCreator_1 = require("./component/tag/TagCreator");
29268 Object.defineProperty(exports, "TagCreator", { enumerable: true, get: function () { return TagCreator_1.TagCreator; } });
29269 var TagDOMRenderer_1 = require("./component/tag/TagDOMRenderer");
29270 Object.defineProperty(exports, "TagDOMRenderer", { enumerable: true, get: function () { return TagDOMRenderer_1.TagDOMRenderer; } });
29271 var TagMode_1 = require("./component/tag/TagMode");
29272 Object.defineProperty(exports, "TagMode", { enumerable: true, get: function () { return TagMode_1.TagMode; } });
29273 var TagOperation_1 = require("./component/tag/TagOperation");
29274 Object.defineProperty(exports, "TagOperation", { enumerable: true, get: function () { return TagOperation_1.TagOperation; } });
29275 var TagScene_1 = require("./component/tag/TagScene");
29276 Object.defineProperty(exports, "TagScene", { enumerable: true, get: function () { return TagScene_1.TagScene; } });
29277 var TagSet_1 = require("./component/tag/TagSet");
29278 Object.defineProperty(exports, "TagSet", { enumerable: true, get: function () { return TagSet_1.TagSet; } });
29279 var Geometry_1 = require("./component/tag/geometry/Geometry");
29280 Object.defineProperty(exports, "Geometry", { enumerable: true, get: function () { return Geometry_1.Geometry; } });
29281 var VertexGeometry_1 = require("./component/tag/geometry/VertexGeometry");
29282 Object.defineProperty(exports, "VertexGeometry", { enumerable: true, get: function () { return VertexGeometry_1.VertexGeometry; } });
29283 var RectGeometry_1 = require("./component/tag/geometry/RectGeometry");
29284 Object.defineProperty(exports, "RectGeometry", { enumerable: true, get: function () { return RectGeometry_1.RectGeometry; } });
29285 var PointGeometry_1 = require("./component/tag/geometry/PointGeometry");
29286 Object.defineProperty(exports, "PointGeometry", { enumerable: true, get: function () { return PointGeometry_1.PointGeometry; } });
29287 var PointsGeometry_1 = require("./component/tag/geometry/PointsGeometry");
29288 Object.defineProperty(exports, "PointsGeometry", { enumerable: true, get: function () { return PointsGeometry_1.PointsGeometry; } });
29289 var PolygonGeometry_1 = require("./component/tag/geometry/PolygonGeometry");
29290 Object.defineProperty(exports, "PolygonGeometry", { enumerable: true, get: function () { return PolygonGeometry_1.PolygonGeometry; } });
29291 var GeometryTagError_1 = require("./component/tag/error/GeometryTagError");
29292 Object.defineProperty(exports, "GeometryTagError", { enumerable: true, get: function () { return GeometryTagError_1.GeometryTagError; } });
29293 var ZoomComponent_1 = require("./component/zoom/ZoomComponent");
29294 Object.defineProperty(exports, "ZoomComponent", { enumerable: true, get: function () { return ZoomComponent_1.ZoomComponent; } });
29295 var CreateTag_1 = require("./component/tag/tag/CreateTag");
29296 Object.defineProperty(exports, "CreateTag", { enumerable: true, get: function () { return CreateTag_1.CreateTag; } });
29297 var OutlineCreateTag_1 = require("./component/tag/tag/OutlineCreateTag");
29298 Object.defineProperty(exports, "OutlineCreateTag", { enumerable: true, get: function () { return OutlineCreateTag_1.OutlineCreateTag; } });
29299 var ExtremePointCreateTag_1 = require("./component/tag/tag/ExtremePointCreateTag");
29300 Object.defineProperty(exports, "ExtremePointCreateTag", { enumerable: true, get: function () { return ExtremePointCreateTag_1.ExtremePointCreateTag; } });
29301 __exportStar(require("./component/interfaces/interfaces"), exports);
29303 },{"./component/AttributionComponent":306,"./component/BackgroundComponent":307,"./component/BearingComponent":308,"./component/CacheComponent":309,"./component/Component":310,"./component/ComponentService":311,"./component/CoverComponent":312,"./component/DebugComponent":313,"./component/ImageComponent":314,"./component/LoadingComponent":315,"./component/NavigationComponent":316,"./component/RouteComponent":317,"./component/StatsComponent":318,"./component/direction/DirectionComponent":319,"./component/direction/DirectionDOMCalculator":320,"./component/direction/DirectionDOMRenderer":321,"./component/imageplane/ImagePlaneComponent":322,"./component/imageplane/ImagePlaneGLRenderer":323,"./component/interfaces/interfaces":327,"./component/keyboard/KeyPlayHandler":328,"./component/keyboard/KeySequenceNavigationHandler":329,"./component/keyboard/KeySpatialNavigationHandler":330,"./component/keyboard/KeyZoomHandler":331,"./component/keyboard/KeyboardComponent":332,"./component/marker/MarkerComponent":334,"./component/marker/MarkerScene":335,"./component/marker/MarkerSet":336,"./component/marker/marker/CircleMarker":338,"./component/marker/marker/Marker":339,"./component/marker/marker/SimpleMarker":340,"./component/mouse/BounceHandler":341,"./component/mouse/DoubleClickZoomHandler":342,"./component/mouse/DragPanHandler":343,"./component/mouse/EarthControlHandler":344,"./component/mouse/HandlerTypes":345,"./component/mouse/ImageBoundary":346,"./component/mouse/MouseComponent":347,"./component/mouse/ScrollZoomHandler":348,"./component/mouse/TouchZoomHandler":349,"./component/popup/PopupComponent":351,"./component/popup/popup/Popup":352,"./component/sequence/SequenceComponent":353,"./component/sequence/SequenceDOMRenderer":354,"./component/sequence/SequenceMode":355,"./component/shaders/Shaders":356,"./component/slider/SliderComponent":357,"./component/slider/SliderDOMRenderer":358,"./component/slider/SliderGLRenderer":359,"./component/spatialdata/SpatialDataCache":362,"./component/spatialdata/SpatialDataComponent":363,"./component/spatialdata/SpatialDataScene":364,"./component/tag/TagComponent":367,"./component/tag/TagCreator":368,"./component/tag/TagDOMRenderer":369,"./component/tag/TagMode":370,"./component/tag/TagOperation":371,"./component/tag/TagScene":372,"./component/tag/TagSet":373,"./component/tag/error/GeometryTagError":374,"./component/tag/geometry/Geometry":375,"./component/tag/geometry/PointGeometry":376,"./component/tag/geometry/PointsGeometry":377,"./component/tag/geometry/PolygonGeometry":378,"./component/tag/geometry/RectGeometry":379,"./component/tag/geometry/VertexGeometry":380,"./component/tag/handlers/CreateHandlerBase":381,"./component/tag/handlers/CreatePointHandler":382,"./component/tag/handlers/CreatePointsHandler":383,"./component/tag/handlers/CreatePolygonHandler":384,"./component/tag/handlers/CreateRectDragHandler":385,"./component/tag/handlers/CreateRectHandler":386,"./component/tag/handlers/CreateVertexHandler":387,"./component/tag/handlers/EditVertexHandler":388,"./component/tag/handlers/TagHandlerBase":389,"./component/tag/tag/CreateTag":391,"./component/tag/tag/ExtremePointCreateTag":392,"./component/tag/tag/ExtremePointRenderTag":393,"./component/tag/tag/ExtremePointTag":394,"./component/tag/tag/OutlineCreateTag":395,"./component/tag/tag/OutlineRenderTag":396,"./component/tag/tag/OutlineRenderTagBase":397,"./component/tag/tag/OutlineTag":398,"./component/tag/tag/RenderTag":399,"./component/tag/tag/SpotRenderTag":400,"./component/tag/tag/SpotTag":401,"./component/tag/tag/Tag":402,"./component/tag/tag/TagDomain":403,"./component/utils/ComponentSize":404,"./component/utils/HandlerBase":405,"./component/utils/MeshFactory":406,"./component/utils/MeshScene":407,"./component/utils/MouseOperator":408,"./component/zoom/ZoomComponent":409}],292:[function(require,module,exports){
29305 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29306 if (k2 === undefined) k2 = k;
29307 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29308 }) : (function(o, m, k, k2) {
29309 if (k2 === undefined) k2 = k;
29312 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29313 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29315 Object.defineProperty(exports, "__esModule", { value: true });
29316 var EdgeDirection_1 = require("./graph/edge/EdgeDirection");
29317 Object.defineProperty(exports, "EdgeDirection", { enumerable: true, get: function () { return EdgeDirection_1.EdgeDirection; } });
29318 var EdgeCalculatorSettings_1 = require("./graph/edge/EdgeCalculatorSettings");
29319 Object.defineProperty(exports, "EdgeCalculatorSettings", { enumerable: true, get: function () { return EdgeCalculatorSettings_1.EdgeCalculatorSettings; } });
29320 var EdgeCalculatorDirections_1 = require("./graph/edge/EdgeCalculatorDirections");
29321 Object.defineProperty(exports, "EdgeCalculatorDirections", { enumerable: true, get: function () { return EdgeCalculatorDirections_1.EdgeCalculatorDirections; } });
29322 var EdgeCalculatorCoefficients_1 = require("./graph/edge/EdgeCalculatorCoefficients");
29323 Object.defineProperty(exports, "EdgeCalculatorCoefficients", { enumerable: true, get: function () { return EdgeCalculatorCoefficients_1.EdgeCalculatorCoefficients; } });
29324 var EdgeCalculator_1 = require("./graph/edge/EdgeCalculator");
29325 Object.defineProperty(exports, "EdgeCalculator", { enumerable: true, get: function () { return EdgeCalculator_1.EdgeCalculator; } });
29326 __exportStar(require("./graph/edge/interfaces/interfaces"), exports);
29328 },{"./graph/edge/EdgeCalculator":433,"./graph/edge/EdgeCalculatorCoefficients":434,"./graph/edge/EdgeCalculatorDirections":435,"./graph/edge/EdgeCalculatorSettings":436,"./graph/edge/EdgeDirection":437,"./graph/edge/interfaces/interfaces":438}],293:[function(require,module,exports){
29330 Object.defineProperty(exports, "__esModule", { value: true });
29331 var AbortMapillaryError_1 = require("./error/AbortMapillaryError");
29332 Object.defineProperty(exports, "AbortMapillaryError", { enumerable: true, get: function () { return AbortMapillaryError_1.AbortMapillaryError; } });
29333 var ArgumentMapillaryError_1 = require("./error/ArgumentMapillaryError");
29334 Object.defineProperty(exports, "ArgumentMapillaryError", { enumerable: true, get: function () { return ArgumentMapillaryError_1.ArgumentMapillaryError; } });
29335 var GraphMapillaryError_1 = require("./error/GraphMapillaryError");
29336 Object.defineProperty(exports, "GraphMapillaryError", { enumerable: true, get: function () { return GraphMapillaryError_1.GraphMapillaryError; } });
29337 var MapillaryError_1 = require("./error/MapillaryError");
29338 Object.defineProperty(exports, "MapillaryError", { enumerable: true, get: function () { return MapillaryError_1.MapillaryError; } });
29340 },{"./error/AbortMapillaryError":410,"./error/ArgumentMapillaryError":411,"./error/GraphMapillaryError":412,"./error/MapillaryError":413}],294:[function(require,module,exports){
29342 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29343 if (k2 === undefined) k2 = k;
29344 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29345 }) : (function(o, m, k, k2) {
29346 if (k2 === undefined) k2 = k;
29349 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29350 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29352 Object.defineProperty(exports, "__esModule", { value: true });
29353 exports.Lines = exports.Geo = void 0;
29354 var Camera_1 = require("./geo/Camera");
29355 Object.defineProperty(exports, "Camera", { enumerable: true, get: function () { return Camera_1.Camera; } });
29356 var GeoCoords_1 = require("./geo/GeoCoords");
29357 Object.defineProperty(exports, "GeoCoords", { enumerable: true, get: function () { return GeoCoords_1.GeoCoords; } });
29358 var GeoRBush_1 = require("./geo/GeoRBush");
29359 Object.defineProperty(exports, "GeoRBush", { enumerable: true, get: function () { return GeoRBush_1.GeoRBush; } });
29360 var ViewportCoords_1 = require("./geo/ViewportCoords");
29361 Object.defineProperty(exports, "ViewportCoords", { enumerable: true, get: function () { return ViewportCoords_1.ViewportCoords; } });
29362 var Spatial_1 = require("./geo/Spatial");
29363 Object.defineProperty(exports, "Spatial", { enumerable: true, get: function () { return Spatial_1.Spatial; } });
29364 var Transform_1 = require("./geo/Transform");
29365 Object.defineProperty(exports, "Transform", { enumerable: true, get: function () { return Transform_1.Transform; } });
29366 __exportStar(require("./geo/interfaces/interfaces"), exports);
29367 var Geo = require("./geo/Geo");
29369 var Lines = require("./geo/Lines");
29370 exports.Lines = Lines;
29372 },{"./geo/Camera":414,"./geo/Geo":415,"./geo/GeoCoords":416,"./geo/GeoRBush":417,"./geo/Lines":418,"./geo/Spatial":419,"./geo/Transform":420,"./geo/ViewportCoords":421,"./geo/interfaces/interfaces":422}],295:[function(require,module,exports){
29374 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29375 if (k2 === undefined) k2 = k;
29376 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29377 }) : (function(o, m, k, k2) {
29378 if (k2 === undefined) k2 = k;
29381 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29382 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29384 Object.defineProperty(exports, "__esModule", { value: true });
29385 var FilterCreator_1 = require("./graph/FilterCreator");
29386 Object.defineProperty(exports, "FilterCreator", { enumerable: true, get: function () { return FilterCreator_1.FilterCreator; } });
29387 var Graph_1 = require("./graph/Graph");
29388 Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return Graph_1.Graph; } });
29389 var GraphCalculator_1 = require("./graph/GraphCalculator");
29390 Object.defineProperty(exports, "GraphCalculator", { enumerable: true, get: function () { return GraphCalculator_1.GraphCalculator; } });
29391 var GraphMode_1 = require("./graph/GraphMode");
29392 Object.defineProperty(exports, "GraphMode", { enumerable: true, get: function () { return GraphMode_1.GraphMode; } });
29393 var GraphService_1 = require("./graph/GraphService");
29394 Object.defineProperty(exports, "GraphService", { enumerable: true, get: function () { return GraphService_1.GraphService; } });
29395 var ImageLoadingService_1 = require("./graph/ImageLoadingService");
29396 Object.defineProperty(exports, "ImageLoadingService", { enumerable: true, get: function () { return ImageLoadingService_1.ImageLoadingService; } });
29397 var MeshReader_1 = require("./graph/MeshReader");
29398 Object.defineProperty(exports, "MeshReader", { enumerable: true, get: function () { return MeshReader_1.MeshReader; } });
29399 var Node_1 = require("./graph/Node");
29400 Object.defineProperty(exports, "Node", { enumerable: true, get: function () { return Node_1.Node; } });
29401 var NodeCache_1 = require("./graph/NodeCache");
29402 Object.defineProperty(exports, "NodeCache", { enumerable: true, get: function () { return NodeCache_1.NodeCache; } });
29403 var Sequence_1 = require("./graph/Sequence");
29404 Object.defineProperty(exports, "Sequence", { enumerable: true, get: function () { return Sequence_1.Sequence; } });
29405 __exportStar(require("./graph/interfaces/interfaces"), exports);
29407 },{"./graph/FilterCreator":423,"./graph/Graph":424,"./graph/GraphCalculator":425,"./graph/GraphMode":426,"./graph/GraphService":427,"./graph/ImageLoadingService":428,"./graph/MeshReader":429,"./graph/Node":430,"./graph/NodeCache":431,"./graph/Sequence":432,"./graph/interfaces/interfaces":439}],296:[function(require,module,exports){
29410 * MapillaryJS is a WebGL JavaScript library for exploring street level imagery
29413 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29414 if (k2 === undefined) k2 = k;
29415 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29416 }) : (function(o, m, k, k2) {
29417 if (k2 === undefined) k2 = k;
29420 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29421 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29423 Object.defineProperty(exports, "__esModule", { value: true });
29424 exports.SpatialDataComponent = exports.PopupComponent = exports.MarkerComponent = exports.TagComponent = void 0;
29425 __exportStar(require("./Support"), exports);
29426 var Edge_1 = require("./Edge");
29427 Object.defineProperty(exports, "EdgeDirection", { enumerable: true, get: function () { return Edge_1.EdgeDirection; } });
29428 var Error_1 = require("./Error");
29429 Object.defineProperty(exports, "AbortMapillaryError", { enumerable: true, get: function () { return Error_1.AbortMapillaryError; } });
29430 var Render_1 = require("./Render");
29431 Object.defineProperty(exports, "RenderMode", { enumerable: true, get: function () { return Render_1.RenderMode; } });
29432 var State_1 = require("./State");
29433 Object.defineProperty(exports, "TransitionMode", { enumerable: true, get: function () { return State_1.TransitionMode; } });
29434 var Viewer_1 = require("./Viewer");
29435 Object.defineProperty(exports, "Alignment", { enumerable: true, get: function () { return Viewer_1.Alignment; } });
29436 Object.defineProperty(exports, "ImageSize", { enumerable: true, get: function () { return Viewer_1.ImageSize; } });
29437 Object.defineProperty(exports, "Viewer", { enumerable: true, get: function () { return Viewer_1.Viewer; } });
29438 var Component_1 = require("./Component");
29439 Object.defineProperty(exports, "SliderMode", { enumerable: true, get: function () { return Component_1.SliderMode; } });
29440 Object.defineProperty(exports, "ComponentSize", { enumerable: true, get: function () { return Component_1.ComponentSize; } });
29441 var TagComponent = require("./component/tag/Tag");
29442 exports.TagComponent = TagComponent;
29443 var MarkerComponent = require("./component/marker/Marker");
29444 exports.MarkerComponent = MarkerComponent;
29445 var PopupComponent = require("./component/popup/Popup");
29446 exports.PopupComponent = PopupComponent;
29447 var SpatialDataComponent = require("./component/spatialdata/SpatialData");
29448 exports.SpatialDataComponent = SpatialDataComponent;
29450 },{"./Component":291,"./Edge":292,"./Error":293,"./Render":297,"./State":298,"./Support":299,"./Viewer":302,"./component/marker/Marker":333,"./component/popup/Popup":350,"./component/spatialdata/SpatialData":361,"./component/tag/Tag":366}],297:[function(require,module,exports){
29452 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29453 if (k2 === undefined) k2 = k;
29454 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29455 }) : (function(o, m, k, k2) {
29456 if (k2 === undefined) k2 = k;
29459 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29460 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29462 Object.defineProperty(exports, "__esModule", { value: true });
29463 var DOMRenderer_1 = require("./render/DOMRenderer");
29464 Object.defineProperty(exports, "DOMRenderer", { enumerable: true, get: function () { return DOMRenderer_1.DOMRenderer; } });
29465 var GLRenderer_1 = require("./render/GLRenderer");
29466 Object.defineProperty(exports, "GLRenderer", { enumerable: true, get: function () { return GLRenderer_1.GLRenderer; } });
29467 var GLRenderStage_1 = require("./render/GLRenderStage");
29468 Object.defineProperty(exports, "GLRenderStage", { enumerable: true, get: function () { return GLRenderStage_1.GLRenderStage; } });
29469 var RenderCamera_1 = require("./render/RenderCamera");
29470 Object.defineProperty(exports, "RenderCamera", { enumerable: true, get: function () { return RenderCamera_1.RenderCamera; } });
29471 var RenderMode_1 = require("./render/RenderMode");
29472 Object.defineProperty(exports, "RenderMode", { enumerable: true, get: function () { return RenderMode_1.RenderMode; } });
29473 var RenderService_1 = require("./render/RenderService");
29474 Object.defineProperty(exports, "RenderService", { enumerable: true, get: function () { return RenderService_1.RenderService; } });
29475 __exportStar(require("./render/interfaces/interfaces"), exports);
29477 },{"./render/DOMRenderer":440,"./render/GLRenderStage":441,"./render/GLRenderer":442,"./render/RenderCamera":443,"./render/RenderMode":444,"./render/RenderService":445,"./render/interfaces/interfaces":446}],298:[function(require,module,exports){
29479 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29480 if (k2 === undefined) k2 = k;
29481 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29482 }) : (function(o, m, k, k2) {
29483 if (k2 === undefined) k2 = k;
29486 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29487 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29489 Object.defineProperty(exports, "__esModule", { value: true });
29490 var FrameGenerator_1 = require("./state/FrameGenerator");
29491 Object.defineProperty(exports, "FrameGenerator", { enumerable: true, get: function () { return FrameGenerator_1.FrameGenerator; } });
29492 var RotationDelta_1 = require("./state/RotationDelta");
29493 Object.defineProperty(exports, "RotationDelta", { enumerable: true, get: function () { return RotationDelta_1.RotationDelta; } });
29494 var State_1 = require("./state/State");
29495 Object.defineProperty(exports, "State", { enumerable: true, get: function () { return State_1.State; } });
29496 var StateBase_1 = require("./state/states/StateBase");
29497 Object.defineProperty(exports, "StateBase", { enumerable: true, get: function () { return StateBase_1.StateBase; } });
29498 var StateContext_1 = require("./state/StateContext");
29499 Object.defineProperty(exports, "StateContext", { enumerable: true, get: function () { return StateContext_1.StateContext; } });
29500 var StateService_1 = require("./state/StateService");
29501 Object.defineProperty(exports, "StateService", { enumerable: true, get: function () { return StateService_1.StateService; } });
29502 var TransitionMode_1 = require("./state/TransitionMode");
29503 Object.defineProperty(exports, "TransitionMode", { enumerable: true, get: function () { return TransitionMode_1.TransitionMode; } });
29504 var EarthState_1 = require("./state/states/EarthState");
29505 Object.defineProperty(exports, "EarthState", { enumerable: true, get: function () { return EarthState_1.EarthState; } });
29506 var InteractiveStateBase_1 = require("./state/states/InteractiveStateBase");
29507 Object.defineProperty(exports, "InteractiveStateBase", { enumerable: true, get: function () { return InteractiveStateBase_1.InteractiveStateBase; } });
29508 var InteractiveWaitingState_1 = require("./state/states/InteractiveWaitingState");
29509 Object.defineProperty(exports, "InteractiveWaitingState", { enumerable: true, get: function () { return InteractiveWaitingState_1.InteractiveWaitingState; } });
29510 var TraversingState_1 = require("./state/states/TraversingState");
29511 Object.defineProperty(exports, "TraversingState", { enumerable: true, get: function () { return TraversingState_1.TraversingState; } });
29512 var WaitingState_1 = require("./state/states/WaitingState");
29513 Object.defineProperty(exports, "WaitingState", { enumerable: true, get: function () { return WaitingState_1.WaitingState; } });
29514 __exportStar(require("./state/interfaces/interfaces"), exports);
29516 },{"./state/FrameGenerator":447,"./state/RotationDelta":448,"./state/State":449,"./state/StateContext":450,"./state/StateService":451,"./state/TransitionMode":452,"./state/interfaces/interfaces":453,"./state/states/EarthState":454,"./state/states/InteractiveStateBase":455,"./state/states/InteractiveWaitingState":456,"./state/states/StateBase":457,"./state/states/TraversingState":458,"./state/states/WaitingState":459}],299:[function(require,module,exports){
29518 Object.defineProperty(exports, "__esModule", { value: true });
29519 exports.isFallbackSupported = exports.isSupported = void 0;
29520 var support = require("./utils/Support");
29522 * Test whether the current browser supports the full
29523 * functionality of MapillaryJS.
29525 * @description The full functionality includes WebGL rendering.
29527 * @return {boolean}
29529 * @example `var supported = Mapillary.isSupported();`
29531 function isSupported() {
29532 return isFallbackSupported() &&
29533 support.isWebGLSupportedCached();
29535 exports.isSupported = isSupported;
29537 * Test whether the current browser supports the fallback
29538 * functionality of MapillaryJS.
29540 * @description The fallback functionality does not include WebGL
29541 * rendering, only 2D canvas rendering.
29543 * @return {boolean}
29545 * @example `var fallbackSupported = Mapillary.isFallbackSupported();`
29547 function isFallbackSupported() {
29548 return support.isBrowser() &&
29549 support.isBlobSupported() &&
29550 support.isArraySupported() &&
29551 support.isFunctionSupported() &&
29552 support.isJSONSupported() &&
29553 support.isObjectSupported();
29555 exports.isFallbackSupported = isFallbackSupported;
29557 },{"./utils/Support":468}],300:[function(require,module,exports){
29559 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29560 if (k2 === undefined) k2 = k;
29561 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29562 }) : (function(o, m, k, k2) {
29563 if (k2 === undefined) k2 = k;
29566 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29567 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29569 Object.defineProperty(exports, "__esModule", { value: true });
29570 var ImageTileLoader_1 = require("./tiles/ImageTileLoader");
29571 Object.defineProperty(exports, "ImageTileLoader", { enumerable: true, get: function () { return ImageTileLoader_1.ImageTileLoader; } });
29572 var ImageTileStore_1 = require("./tiles/ImageTileStore");
29573 Object.defineProperty(exports, "ImageTileStore", { enumerable: true, get: function () { return ImageTileStore_1.ImageTileStore; } });
29574 var TextureProvider_1 = require("./tiles/TextureProvider");
29575 Object.defineProperty(exports, "TextureProvider", { enumerable: true, get: function () { return TextureProvider_1.TextureProvider; } });
29576 var RegionOfInterestCalculator_1 = require("./tiles/RegionOfInterestCalculator");
29577 Object.defineProperty(exports, "RegionOfInterestCalculator", { enumerable: true, get: function () { return RegionOfInterestCalculator_1.RegionOfInterestCalculator; } });
29578 __exportStar(require("./tiles/interfaces/interfaces"), exports);
29580 },{"./tiles/ImageTileLoader":460,"./tiles/ImageTileStore":461,"./tiles/RegionOfInterestCalculator":462,"./tiles/TextureProvider":463,"./tiles/interfaces/interfaces":464}],301:[function(require,module,exports){
29582 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29583 if (k2 === undefined) k2 = k;
29584 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29585 }) : (function(o, m, k, k2) {
29586 if (k2 === undefined) k2 = k;
29589 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29590 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29592 Object.defineProperty(exports, "__esModule", { value: true });
29593 var DOM_1 = require("./utils/DOM");
29594 Object.defineProperty(exports, "DOM", { enumerable: true, get: function () { return DOM_1.DOM; } });
29595 var EventEmitter_1 = require("./utils/EventEmitter");
29596 Object.defineProperty(exports, "EventEmitter", { enumerable: true, get: function () { return EventEmitter_1.EventEmitter; } });
29597 var Settings_1 = require("./utils/Settings");
29598 Object.defineProperty(exports, "Settings", { enumerable: true, get: function () { return Settings_1.Settings; } });
29599 __exportStar(require("./utils/Support"), exports);
29600 var Urls_1 = require("./utils/Urls");
29601 Object.defineProperty(exports, "Urls", { enumerable: true, get: function () { return Urls_1.Urls; } });
29603 },{"./utils/DOM":465,"./utils/EventEmitter":466,"./utils/Settings":467,"./utils/Support":468,"./utils/Urls":469}],302:[function(require,module,exports){
29605 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29606 if (k2 === undefined) k2 = k;
29607 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29608 }) : (function(o, m, k, k2) {
29609 if (k2 === undefined) k2 = k;
29612 var __exportStar = (this && this.__exportStar) || function(m, exports) {
29613 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
29615 Object.defineProperty(exports, "__esModule", { value: true });
29616 var Alignment_1 = require("./viewer/Alignment");
29617 Object.defineProperty(exports, "Alignment", { enumerable: true, get: function () { return Alignment_1.Alignment; } });
29618 var CacheService_1 = require("./viewer/CacheService");
29619 Object.defineProperty(exports, "CacheService", { enumerable: true, get: function () { return CacheService_1.CacheService; } });
29620 var ComponentController_1 = require("./viewer/ComponentController");
29621 Object.defineProperty(exports, "ComponentController", { enumerable: true, get: function () { return ComponentController_1.ComponentController; } });
29622 var Container_1 = require("./viewer/Container");
29623 Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return Container_1.Container; } });
29624 var Observer_1 = require("./viewer/Observer");
29625 Object.defineProperty(exports, "Observer", { enumerable: true, get: function () { return Observer_1.Observer; } });
29626 var ImageSize_1 = require("./viewer/ImageSize");
29627 Object.defineProperty(exports, "ImageSize", { enumerable: true, get: function () { return ImageSize_1.ImageSize; } });
29628 var KeyboardService_1 = require("./viewer/KeyboardService");
29629 Object.defineProperty(exports, "KeyboardService", { enumerable: true, get: function () { return KeyboardService_1.KeyboardService; } });
29630 var LoadingService_1 = require("./viewer/LoadingService");
29631 Object.defineProperty(exports, "LoadingService", { enumerable: true, get: function () { return LoadingService_1.LoadingService; } });
29632 var MouseService_1 = require("./viewer/MouseService");
29633 Object.defineProperty(exports, "MouseService", { enumerable: true, get: function () { return MouseService_1.MouseService; } });
29634 var Navigator_1 = require("./viewer/Navigator");
29635 Object.defineProperty(exports, "Navigator", { enumerable: true, get: function () { return Navigator_1.Navigator; } });
29636 var PlayService_1 = require("./viewer/PlayService");
29637 Object.defineProperty(exports, "PlayService", { enumerable: true, get: function () { return PlayService_1.PlayService; } });
29638 var Projection_1 = require("./viewer/Projection");
29639 Object.defineProperty(exports, "Projection", { enumerable: true, get: function () { return Projection_1.Projection; } });
29640 var SpriteService_1 = require("./viewer/SpriteService");
29641 Object.defineProperty(exports, "SpriteService", { enumerable: true, get: function () { return SpriteService_1.SpriteService; } });
29642 var TouchService_1 = require("./viewer/TouchService");
29643 Object.defineProperty(exports, "TouchService", { enumerable: true, get: function () { return TouchService_1.TouchService; } });
29644 var Viewer_1 = require("./viewer/Viewer");
29645 Object.defineProperty(exports, "Viewer", { enumerable: true, get: function () { return Viewer_1.Viewer; } });
29646 __exportStar(require("./viewer/interfaces/interfaces"), exports);
29648 },{"./viewer/Alignment":470,"./viewer/CacheService":471,"./viewer/ComponentController":472,"./viewer/Container":473,"./viewer/ImageSize":474,"./viewer/KeyboardService":475,"./viewer/LoadingService":476,"./viewer/MouseService":477,"./viewer/Navigator":478,"./viewer/Observer":479,"./viewer/PlayService":481,"./viewer/Projection":482,"./viewer/SpriteService":483,"./viewer/TouchService":484,"./viewer/Viewer":485,"./viewer/interfaces/interfaces":486}],303:[function(require,module,exports){
29650 Object.defineProperty(exports, "__esModule", { value: true });
29651 exports.APIv3 = void 0;
29652 var operators_1 = require("rxjs/operators");
29653 var rxjs_1 = require("rxjs");
29654 var API_1 = require("../API");
29658 * @classdesc Provides methods for access of API v3.
29660 var APIv3 = /** @class */ (function () {
29662 * Create a new api v3 instance.
29664 * @param {number} clientId - Client id for API requests.
29665 * @param {number} [token] - Optional bearer token for API requests of
29666 * protected resources.
29667 * @param {ModelCreator} [creator] - Optional model creator instance.
29669 function APIv3(clientId, token, creator) {
29670 this._clientId = clientId;
29671 this._modelCreator = creator != null ? creator : new API_1.ModelCreator();
29672 this._model = this._modelCreator.createModel(clientId, token);
29673 this._pageCount = 999;
29674 this._pathImageByKey = "imageByKey";
29675 this._pathImageCloseTo = "imageCloseTo";
29676 this._pathImagesByH = "imagesByH";
29677 this._pathImageViewAdd = "imageViewAdd";
29678 this._pathSequenceByKey = "sequenceByKey";
29679 this._pathSequenceViewAdd = "sequenceViewAdd";
29680 this._propertiesCore = [
29685 this._propertiesFill = [
29687 "captured_with_camera_uuid",
29689 "organization_key",
29693 this._propertiesKey = [
29696 this._propertiesSequence = [
29699 this._propertiesSpatial = [
29705 "camera_projection_type",
29717 this._propertiesUser = [
29721 Object.defineProperty(APIv3.prototype, "clientId", {
29723 return this._clientId;
29728 APIv3.prototype.imageByKeyFill$ = function (keys) {
29729 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
29730 this._pathImageByKey,
29732 this._propertiesKey
29733 .concat(this._propertiesFill)
29734 .concat(this._propertiesSpatial),
29735 this._propertiesKey
29736 .concat(this._propertiesUser)
29737 ])).pipe(operators_1.map(function (value) {
29739 throw new Error("Images (" + keys.join(", ") + ") could not be found.");
29741 return value.json.imageByKey;
29742 })), this._pathImageByKey, keys);
29744 APIv3.prototype.imageByKeyFull$ = function (keys) {
29745 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
29746 this._pathImageByKey,
29748 this._propertiesKey
29749 .concat(this._propertiesCore)
29750 .concat(this._propertiesFill)
29751 .concat(this._propertiesSpatial),
29752 this._propertiesKey
29753 .concat(this._propertiesUser)
29754 ])).pipe(operators_1.map(function (value) {
29756 throw new Error("Images (" + keys.join(", ") + ") could not be found.");
29758 return value.json.imageByKey;
29759 })), this._pathImageByKey, keys);
29761 APIv3.prototype.imageCloseTo$ = function (lat, lon) {
29762 var lonLat = lon + ":" + lat;
29763 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
29764 this._pathImageCloseTo,
29766 this._propertiesKey
29767 .concat(this._propertiesCore)
29768 .concat(this._propertiesFill)
29769 .concat(this._propertiesSpatial),
29770 this._propertiesKey
29771 .concat(this._propertiesUser)
29772 ])).pipe(operators_1.map(function (value) {
29773 return value != null ? value.json.imageCloseTo[lonLat] : null;
29774 })), this._pathImageCloseTo, [lonLat]);
29776 APIv3.prototype.imagesByH$ = function (hs) {
29778 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
29779 this._pathImagesByH,
29781 { from: 0, to: this._pageCount },
29782 this._propertiesKey
29783 .concat(this._propertiesCore)
29784 ])).pipe(operators_1.map(function (value) {
29786 value = { json: { imagesByH: {} } };
29787 for (var _i = 0, hs_1 = hs; _i < hs_1.length; _i++) {
29789 value.json.imagesByH[h] = {};
29790 for (var i = 0; i <= _this._pageCount; i++) {
29791 value.json.imagesByH[h][i] = null;
29795 return value.json.imagesByH;
29796 })), this._pathImagesByH, hs);
29798 APIv3.prototype.imageViewAdd$ = function (keys) {
29799 return this._catchInvalidateCall$(this._wrapCallModelResponse$(this._model.call([this._pathImageViewAdd], [keys])), this._pathImageViewAdd, keys);
29801 APIv3.prototype.invalidateImageByKey = function (keys) {
29802 this._invalidateGet(this._pathImageByKey, keys);
29804 APIv3.prototype.invalidateImagesByH = function (hs) {
29805 this._invalidateGet(this._pathImagesByH, hs);
29807 APIv3.prototype.invalidateSequenceByKey = function (sKeys) {
29808 this._invalidateGet(this._pathSequenceByKey, sKeys);
29810 APIv3.prototype.setToken = function (token) {
29811 this._model.invalidate([]);
29812 this._model = null;
29813 this._model = this._modelCreator.createModel(this._clientId, token);
29815 APIv3.prototype.sequenceByKey$ = function (sequenceKeys) {
29816 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
29817 this._pathSequenceByKey,
29819 this._propertiesKey
29820 .concat(this._propertiesSequence)
29821 ])).pipe(operators_1.map(function (value) {
29823 value = { json: { sequenceByKey: {} } };
29825 for (var _i = 0, sequenceKeys_1 = sequenceKeys; _i < sequenceKeys_1.length; _i++) {
29826 var sequenceKey = sequenceKeys_1[_i];
29827 if (!(sequenceKey in value.json.sequenceByKey)) {
29828 console.warn("Sequence data missing (" + sequenceKey + ")");
29829 value.json.sequenceByKey[sequenceKey] = { key: sequenceKey, keys: [] };
29832 return value.json.sequenceByKey;
29833 })), this._pathSequenceByKey, sequenceKeys);
29835 APIv3.prototype.sequenceViewAdd$ = function (sequenceKeys) {
29836 return this._catchInvalidateCall$(this._wrapCallModelResponse$(this._model.call([this._pathSequenceViewAdd], [sequenceKeys])), this._pathSequenceViewAdd, sequenceKeys);
29838 APIv3.prototype._catchInvalidateGet$ = function (observable, path, paths) {
29840 return observable.pipe(operators_1.catchError(function (error) {
29841 _this._invalidateGet(path, paths);
29845 APIv3.prototype._catchInvalidateCall$ = function (observable, path, paths) {
29847 return observable.pipe(operators_1.catchError(function (error) {
29848 _this._invalidateCall(path, paths);
29852 APIv3.prototype._invalidateGet = function (path, paths) {
29853 this._model.invalidate([path, paths]);
29855 APIv3.prototype._invalidateCall = function (path, paths) {
29856 this._model.invalidate([path], [paths]);
29858 APIv3.prototype._wrapModelResponse$ = function (modelResponse) {
29859 return rxjs_1.Observable
29860 .create(function (subscriber) {
29862 .then(function (value) {
29863 subscriber.next(value);
29864 subscriber.complete();
29865 }, function (error) {
29866 subscriber.error(error);
29870 APIv3.prototype._wrapCallModelResponse$ = function (modelResponse) {
29871 return this._wrapModelResponse$(modelResponse).pipe(operators_1.map(function (value) {
29877 exports.APIv3 = APIv3;
29878 exports.default = APIv3;
29880 },{"../API":290,"rxjs":43,"rxjs/operators":241}],304:[function(require,module,exports){
29882 Object.defineProperty(exports, "__esModule", { value: true });
29883 exports.ModelCreator = void 0;
29884 var falcor = require("falcor");
29885 var falcor_http_datasource_1 = require("falcor-http-datasource");
29886 var Utils_1 = require("../Utils");
29888 * @class ModelCreator
29890 * @classdesc Creates API models.
29892 var ModelCreator = /** @class */ (function () {
29893 function ModelCreator() {
29896 * Creates a Falcor model.
29898 * @description Max cache size will be set to 16 MB. Authorization
29899 * header will be added if bearer token is supplied.
29901 * @param {number} clientId - Client id for API requests.
29902 * @param {number} [token] - Optional bearer token for API requests of
29903 * protected resources.
29904 * @returns {falcor.Model} Falcor model for HTTP requests.
29906 ModelCreator.prototype.createModel = function (clientId, token) {
29907 var configuration = {
29909 withCredentials: false,
29911 if (token != null) {
29912 configuration.headers = { "Authorization": "Bearer " + token };
29914 return new falcor.Model({
29915 maxSize: 16 * 1024 * 1024,
29916 source: new falcor_http_datasource_1.default(Utils_1.Urls.falcorModel(clientId), configuration),
29919 return ModelCreator;
29921 exports.ModelCreator = ModelCreator;
29922 exports.default = ModelCreator;
29924 },{"../Utils":301,"falcor":15,"falcor-http-datasource":10}],305:[function(require,module,exports){
29926 Object.defineProperty(exports, "__esModule", { value: true });
29928 },{}],306:[function(require,module,exports){
29930 var __extends = (this && this.__extends) || (function () {
29931 var extendStatics = function (d, b) {
29932 extendStatics = Object.setPrototypeOf ||
29933 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29934 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
29935 return extendStatics(d, b);
29937 return function (d, b) {
29938 extendStatics(d, b);
29939 function __() { this.constructor = d; }
29940 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29943 Object.defineProperty(exports, "__esModule", { value: true });
29944 exports.AttributionComponent = void 0;
29945 var rxjs_1 = require("rxjs");
29946 var operators_1 = require("rxjs/operators");
29947 var vd = require("virtual-dom");
29948 var Component_1 = require("../Component");
29949 var Utils_1 = require("../Utils");
29950 var AttributionComponent = /** @class */ (function (_super) {
29951 __extends(AttributionComponent, _super);
29952 function AttributionComponent(name, container, navigator) {
29953 return _super.call(this, name, container, navigator) || this;
29955 AttributionComponent.prototype._activate = function () {
29957 this._disposable = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
29958 var node = _a[0], size = _a[1];
29961 vnode: _this._getAttributionNode(node.username, node.key, node.capturedAt, size.width),
29964 .subscribe(this._container.domRenderer.render$);
29966 AttributionComponent.prototype._deactivate = function () {
29967 this._disposable.unsubscribe();
29969 AttributionComponent.prototype._getDefaultConfiguration = function () {
29972 AttributionComponent.prototype._getAttributionNode = function (username, key, capturedAt, width) {
29973 var compact = width <= 640;
29974 var mapillaryIcon = vd.h("div.AttributionMapillaryLogo", []);
29975 var mapillaryLink = vd.h("a.AttributionIconContainer", { href: Utils_1.Urls.explore, target: "_blank" }, [mapillaryIcon]);
29976 var imageBy = compact ? "" + username : "image by " + username;
29977 var imageByContent = vd.h("div.AttributionUsername", { textContent: imageBy }, []);
29978 var date = new Date(capturedAt).toDateString().split(" ");
29979 var formatted = (date.length > 3 ?
29982 [date[1], date[2] + ",", date[3]] :
29984 var dateContent = vd.h("div.AttributionDate", { textContent: formatted }, []);
29985 var imageLink = vd.h("a.AttributionImageContainer", { href: Utils_1.Urls.exporeImage(key), target: "_blank" }, [imageByContent, dateContent]);
29986 var compactClass = compact ? ".AttributionCompact" : "";
29987 return vd.h("div.AttributionContainer" + compactClass, {}, [mapillaryLink, imageLink]);
29989 AttributionComponent.componentName = "attribution";
29990 return AttributionComponent;
29991 }(Component_1.Component));
29992 exports.AttributionComponent = AttributionComponent;
29993 Component_1.ComponentService.register(AttributionComponent);
29994 exports.default = AttributionComponent;
29996 },{"../Component":291,"../Utils":301,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],307:[function(require,module,exports){
29998 var __extends = (this && this.__extends) || (function () {
29999 var extendStatics = function (d, b) {
30000 extendStatics = Object.setPrototypeOf ||
30001 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30002 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30003 return extendStatics(d, b);
30005 return function (d, b) {
30006 extendStatics(d, b);
30007 function __() { this.constructor = d; }
30008 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30011 Object.defineProperty(exports, "__esModule", { value: true });
30012 exports.BackgroundComponent = void 0;
30013 var vd = require("virtual-dom");
30014 var Component_1 = require("../Component");
30015 var BackgroundComponent = /** @class */ (function (_super) {
30016 __extends(BackgroundComponent, _super);
30017 function BackgroundComponent(name, container, navigator) {
30018 return _super.call(this, name, container, navigator) || this;
30020 BackgroundComponent.prototype._activate = function () {
30021 this._container.domRenderer.render$
30022 .next({ name: this._name, vnode: this._getBackgroundNode("The viewer can't display the given image.") });
30024 BackgroundComponent.prototype._deactivate = function () {
30027 BackgroundComponent.prototype._getDefaultConfiguration = function () {
30030 BackgroundComponent.prototype._getBackgroundNode = function (notice) {
30031 // todo: add condition for when to display the DOM node
30032 return vd.h("div.BackgroundWrapper", {}, [
30033 vd.h("p", { textContent: notice }, []),
30036 BackgroundComponent.componentName = "background";
30037 return BackgroundComponent;
30038 }(Component_1.Component));
30039 exports.BackgroundComponent = BackgroundComponent;
30040 Component_1.ComponentService.register(BackgroundComponent);
30041 exports.default = BackgroundComponent;
30043 },{"../Component":291,"virtual-dom":247}],308:[function(require,module,exports){
30045 var __extends = (this && this.__extends) || (function () {
30046 var extendStatics = function (d, b) {
30047 extendStatics = Object.setPrototypeOf ||
30048 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30049 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30050 return extendStatics(d, b);
30052 return function (d, b) {
30053 extendStatics(d, b);
30054 function __() { this.constructor = d; }
30055 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30058 Object.defineProperty(exports, "__esModule", { value: true });
30059 exports.BearingComponent = void 0;
30060 var operators_1 = require("rxjs/operators");
30061 var vd = require("virtual-dom");
30062 var UnitBezier = require("@mapbox/unitbezier");
30063 var rxjs_1 = require("rxjs");
30064 var Component_1 = require("../Component");
30065 var Geo_1 = require("../Geo");
30066 var ViewportCoords_1 = require("../geo/ViewportCoords");
30067 var ComponentSize_1 = require("./utils/ComponentSize");
30069 * @class BearingComponent
30071 * @classdesc Component for indicating bearing and field of view.
30075 * var viewer = new Mapillary.Viewer(
30080 * var bearingComponent = viewer.getComponent("bearing");
30081 * bearingComponent.configure({ size: Mapillary.ComponentSize.Small });
30084 var BearingComponent = /** @class */ (function (_super) {
30085 __extends(BearingComponent, _super);
30086 function BearingComponent(name, container, navigator) {
30087 var _this = _super.call(this, name, container, navigator) || this;
30088 _this._spatial = new Geo_1.Spatial();
30089 _this._viewportCoords = new ViewportCoords_1.default();
30090 _this._svgNamespace = "http://www.w3.org/2000/svg";
30091 _this._distinctThreshold = Math.PI / 360;
30092 _this._animationSpeed = 0.075;
30093 _this._unitBezier = new UnitBezier(0.74, 0.67, 0.38, 0.96);
30096 BearingComponent.prototype._activate = function () {
30098 var cameraBearingFov$ = this._container.renderService.renderCamera$.pipe(operators_1.map(function (rc) {
30099 var vFov = _this._spatial.degToRad(rc.perspective.fov);
30100 var hFov = rc.perspective.aspect === Number.POSITIVE_INFINITY ?
30102 Math.atan(rc.perspective.aspect * Math.tan(0.5 * vFov)) * 2;
30103 return [_this._spatial.azimuthalToBearing(rc.rotation.phi), hFov];
30104 }), operators_1.distinctUntilChanged(function (a1, a2) {
30105 return Math.abs(a2[0] - a1[0]) < _this._distinctThreshold &&
30106 Math.abs(a2[1] - a1[1]) < _this._distinctThreshold;
30108 var nodeFov$ = rxjs_1.combineLatest(this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
30109 return frame.state.currentNode.key;
30110 })), this._navigator.panService.panNodes$).pipe(operators_1.map(function (_a) {
30111 var frame = _a[0], panNodes = _a[1];
30112 var node = frame.state.currentNode;
30113 var transform = frame.state.currentTransform;
30115 var panoHFov = 2 * Math.PI * node.gpano.CroppedAreaImageWidthPixels / node.gpano.FullPanoWidthPixels;
30116 return [panoHFov / 2, panoHFov / 2];
30118 var currentProjectedPoints = _this._computeProjectedPoints(transform);
30119 var hFov = _this._spatial.degToRad(_this._computeHorizontalFov(currentProjectedPoints));
30120 var hFovLeft = hFov / 2;
30121 var hFovRight = hFov / 2;
30122 for (var _i = 0, panNodes_1 = panNodes; _i < panNodes_1.length; _i++) {
30123 var _b = panNodes_1[_i], n = _b[0], f = _b[2];
30124 var diff = _this._spatial.wrap(n.ca - node.ca, -180, 180);
30126 hFovLeft = _this._spatial.degToRad(Math.abs(diff)) + f / 2;
30129 hFovRight = _this._spatial.degToRad(Math.abs(diff)) + f / 2;
30132 return [hFovLeft, hFovRight];
30133 }), operators_1.distinctUntilChanged(function (_a, _b) {
30134 var hFovLeft1 = _a[0], hFovRight1 = _a[1];
30135 var hFovLeft2 = _b[0], hFovRight2 = _b[1];
30136 return Math.abs(hFovLeft2 - hFovLeft1) < _this._distinctThreshold &&
30137 Math.abs(hFovRight2 - hFovRight1) < _this._distinctThreshold;
30139 var offset$ = rxjs_1.combineLatest(this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
30140 return frame.state.currentNode.key;
30141 })), this._container.renderService.bearing$).pipe(operators_1.map(function (_a) {
30142 var frame = _a[0], bearing = _a[1];
30143 var offset = _this._spatial.degToRad(frame.state.currentNode.ca - bearing);
30146 var nodeFovOperation$ = new rxjs_1.Subject();
30147 var smoothNodeFov$ = nodeFovOperation$.pipe(operators_1.scan(function (state, operation) {
30148 return operation(state);
30149 }, { alpha: 0, curr: [0, 0, 0], prev: [0, 0, 0] }), operators_1.map(function (state) {
30150 var alpha = _this._unitBezier.solve(state.alpha);
30151 var curr = state.curr;
30152 var prev = state.prev;
30154 _this._interpolate(prev[0], curr[0], alpha),
30155 _this._interpolate(prev[1], curr[1], alpha),
30158 this._fovSubscription = nodeFov$.pipe(operators_1.map(function (nbf) {
30159 return function (state) {
30160 var a = _this._unitBezier.solve(state.alpha);
30161 var c = state.curr;
30162 var p = state.prev;
30164 _this._interpolate(p[0], c[0], a),
30165 _this._interpolate(p[1], c[1], a),
30167 var curr = nbf.slice();
30175 .subscribe(nodeFovOperation$);
30176 this._fovAnimationSubscription = nodeFov$.pipe(operators_1.switchMap(function () {
30177 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.skip(1), operators_1.scan(function (alpha) {
30178 return alpha + _this._animationSpeed;
30179 }, 0), operators_1.takeWhile(function (alpha) {
30180 return alpha <= 1 + _this._animationSpeed;
30181 }), operators_1.map(function (alpha) {
30182 return Math.min(alpha, 1);
30184 }), operators_1.map(function (alpha) {
30185 return function (nbfState) {
30188 curr: nbfState.curr.slice(),
30189 prev: nbfState.prev.slice(),
30193 .subscribe(nodeFovOperation$);
30194 var nodeBearingFov$ = rxjs_1.combineLatest(offset$, smoothNodeFov$).pipe(operators_1.map(function (_a) {
30195 var offset = _a[0], fov = _a[1];
30196 return [offset, fov[0], fov[1]];
30198 this._renderSubscription = rxjs_1.combineLatest(cameraBearingFov$, nodeBearingFov$, this._configuration$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
30199 var _b = _a[0], cb = _b[0], cf = _b[1], _c = _a[1], no = _c[0], nfl = _c[1], nfr = _c[2], configuration = _a[2], size = _a[3];
30200 var background = _this._createBackground(cb);
30201 var fovIndicator = _this._createFovIndicator(nfl, nfr, no);
30202 var north = _this._createNorth(cb);
30203 var cameraSector = _this._createCircleSectorCompass(_this._createCircleSector(Math.max(Math.PI / 20, cf), "#FFF"));
30204 var compact = configuration.size === ComponentSize_1.default.Small ||
30205 configuration.size === ComponentSize_1.default.Automatic && size.width < 640 ?
30206 ".BearingCompact" : "";
30209 vnode: vd.h("div.BearingIndicatorContainer" + compact, { oncontextmenu: function (event) { event.preventDefault(); } }, [
30217 .subscribe(this._container.domRenderer.render$);
30219 BearingComponent.prototype._deactivate = function () {
30220 this._renderSubscription.unsubscribe();
30221 this._fovSubscription.unsubscribe();
30222 this._fovAnimationSubscription.unsubscribe();
30224 BearingComponent.prototype._getDefaultConfiguration = function () {
30225 return { size: ComponentSize_1.default.Automatic };
30227 BearingComponent.prototype._createFovIndicator = function (fovLeft, fovRigth, offset) {
30228 var arc = this._createFovArc(fovLeft, fovRigth);
30229 var group = vd.h("g", {
30230 attributes: { transform: "translate(18,18)" },
30231 namespace: this._svgNamespace,
30233 var svg = vd.h("svg", {
30234 attributes: { viewBox: "0 0 36 36" },
30235 namespace: this._svgNamespace,
30239 position: "absolute",
30241 transform: "rotateZ(" + this._spatial.radToDeg(offset) + "deg)",
30247 BearingComponent.prototype._createFovArc = function (fovLeft, fovRigth) {
30248 var radius = 16.75;
30249 var strokeWidth = 2.5;
30250 var fov = fovLeft + fovRigth;
30251 if (fov > 2 * Math.PI - Math.PI / 90) {
30252 return vd.h("circle", {
30256 "fill-opacity": "0",
30259 "stroke-width": "" + strokeWidth,
30261 namespace: this._svgNamespace,
30264 var arcStart = -Math.PI / 2 - fovLeft;
30265 var arcEnd = arcStart + fov;
30266 var startX = radius * Math.cos(arcStart);
30267 var startY = radius * Math.sin(arcStart);
30268 var endX = radius * Math.cos(arcEnd);
30269 var endY = radius * Math.sin(arcEnd);
30270 var largeArc = fov >= Math.PI ? 1 : 0;
30271 var description = "M " + startX + " " + startY + " A " + radius + " " + radius + " 0 " + largeArc + " 1 " + endX + " " + endY;
30272 return vd.h("path", {
30275 "fill-opacity": "0",
30277 "stroke-width": "" + strokeWidth,
30279 namespace: this._svgNamespace,
30282 BearingComponent.prototype._createCircleSectorCompass = function (cameraSector) {
30283 var group = vd.h("g", {
30284 attributes: { transform: "translate(1,1)" },
30285 namespace: this._svgNamespace,
30286 }, [cameraSector]);
30287 var svg = vd.h("svg", {
30288 attributes: { viewBox: "0 0 2 2" },
30289 namespace: this._svgNamespace,
30293 position: "absolute",
30300 BearingComponent.prototype._createCircleSector = function (fov, fill) {
30301 if (fov > 2 * Math.PI - Math.PI / 90) {
30302 return vd.h("circle", {
30303 attributes: { cx: "0", cy: "0", fill: fill, r: "1" },
30304 namespace: this._svgNamespace,
30307 var arcStart = -Math.PI / 2 - fov / 2;
30308 var arcEnd = arcStart + fov;
30309 var startX = Math.cos(arcStart);
30310 var startY = Math.sin(arcStart);
30311 var endX = Math.cos(arcEnd);
30312 var endY = Math.sin(arcEnd);
30313 var largeArc = fov >= Math.PI ? 1 : 0;
30314 var description = "M 0 0 " + startX + " " + startY + " A 1 1 0 " + largeArc + " 1 " + endX + " " + endY;
30315 return vd.h("path", {
30316 attributes: { d: description, fill: fill },
30317 namespace: this._svgNamespace,
30320 BearingComponent.prototype._createNorth = function (bearing) {
30321 var north = vd.h("div.BearingNorth", []);
30322 var container = vd.h("div.BearingNorthContainer", { style: { transform: "rotateZ(" + this._spatial.radToDeg(-bearing) + "deg)" } }, [north]);
30325 BearingComponent.prototype._createBackground = function (bearing) {
30326 return vd.h("div.BearingIndicatorBackground", { style: { transform: "rotateZ(" + this._spatial.radToDeg(-bearing) + "deg)" } }, [
30327 vd.h("div.BearingIndicatorBackgroundCircle", []),
30328 vd.h("div.BearingIndicatorBackgroundArrowContainer", [
30329 vd.h("div.BearingIndicatorBackgroundArrow", []),
30333 BearingComponent.prototype._computeProjectedPoints = function (transform) {
30334 var vertices = [[1, 0]];
30335 var directions = [[0, 0.5]];
30336 var pointsPerLine = 12;
30337 return Geo_1.Geo.computeProjectedPoints(transform, vertices, directions, pointsPerLine, this._viewportCoords);
30339 BearingComponent.prototype._computeHorizontalFov = function (projectedPoints) {
30341 var fovs = projectedPoints
30342 .map(function (projectedPoint) {
30343 return _this._coordToFov(projectedPoint[0]);
30345 var fov = Math.min.apply(Math, fovs);
30348 BearingComponent.prototype._coordToFov = function (x) {
30349 return this._spatial.radToDeg(2 * Math.atan(x));
30351 BearingComponent.prototype._interpolate = function (x1, x2, alpha) {
30352 return (1 - alpha) * x1 + alpha * x2;
30354 BearingComponent.componentName = "bearing";
30355 return BearingComponent;
30356 }(Component_1.Component));
30357 exports.BearingComponent = BearingComponent;
30358 Component_1.ComponentService.register(BearingComponent);
30359 exports.default = BearingComponent;
30362 },{"../Component":291,"../Geo":294,"../geo/ViewportCoords":421,"./utils/ComponentSize":404,"@mapbox/unitbezier":2,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],309:[function(require,module,exports){
30364 var __extends = (this && this.__extends) || (function () {
30365 var extendStatics = function (d, b) {
30366 extendStatics = Object.setPrototypeOf ||
30367 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30368 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30369 return extendStatics(d, b);
30371 return function (d, b) {
30372 extendStatics(d, b);
30373 function __() { this.constructor = d; }
30374 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30377 Object.defineProperty(exports, "__esModule", { value: true });
30378 exports.CacheComponent = void 0;
30379 var rxjs_1 = require("rxjs");
30380 var operators_1 = require("rxjs/operators");
30381 var Edge_1 = require("../Edge");
30382 var Component_1 = require("../Component");
30383 var CacheComponent = /** @class */ (function (_super) {
30384 __extends(CacheComponent, _super);
30385 function CacheComponent(name, container, navigator) {
30386 return _super.call(this, name, container, navigator) || this;
30389 * Set the cache depth.
30391 * Configures the cache depth. The cache depth can be different for
30392 * different edge direction types.
30394 * @param {ICacheDepth} depth - Cache depth structure.
30396 CacheComponent.prototype.setDepth = function (depth) {
30397 this.configure({ depth: depth });
30399 CacheComponent.prototype._activate = function () {
30401 this._sequenceSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
30402 return node.sequenceEdges$;
30403 }), operators_1.filter(function (status) {
30404 return status.cached;
30405 })), this._configuration$).pipe(operators_1.switchMap(function (nc) {
30406 var status = nc[0];
30407 var configuration = nc[1];
30408 var sequenceDepth = Math.max(0, Math.min(4, configuration.depth.sequence));
30409 var next$ = _this._cache$(status.edges, Edge_1.EdgeDirection.Next, sequenceDepth);
30410 var prev$ = _this._cache$(status.edges, Edge_1.EdgeDirection.Prev, sequenceDepth);
30411 return rxjs_1.merge(next$, prev$).pipe(operators_1.catchError(function (error, caught) {
30412 console.error("Failed to cache sequence edges.", error);
30413 return rxjs_1.empty();
30416 .subscribe(function () { });
30417 this._spatialSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
30418 return rxjs_1.combineLatest(rxjs_1.of(node), node.spatialEdges$.pipe(operators_1.filter(function (status) {
30419 return status.cached;
30421 })), this._configuration$).pipe(operators_1.switchMap(function (_a) {
30422 var _b = _a[0], node = _b[0], edgeStatus = _b[1], configuration = _a[1];
30423 var edges = edgeStatus.edges;
30424 var depth = configuration.depth;
30425 var panoDepth = Math.max(0, Math.min(2, depth.pano));
30426 var stepDepth = node.pano ? 0 : Math.max(0, Math.min(3, depth.step));
30427 var turnDepth = node.pano ? 0 : Math.max(0, Math.min(1, depth.turn));
30428 var pano$ = _this._cache$(edges, Edge_1.EdgeDirection.Pano, panoDepth);
30429 var forward$ = _this._cache$(edges, Edge_1.EdgeDirection.StepForward, stepDepth);
30430 var backward$ = _this._cache$(edges, Edge_1.EdgeDirection.StepBackward, stepDepth);
30431 var left$ = _this._cache$(edges, Edge_1.EdgeDirection.StepLeft, stepDepth);
30432 var right$ = _this._cache$(edges, Edge_1.EdgeDirection.StepRight, stepDepth);
30433 var turnLeft$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnLeft, turnDepth);
30434 var turnRight$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnRight, turnDepth);
30435 var turnU$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnU, turnDepth);
30436 return rxjs_1.merge(forward$, backward$, left$, right$, pano$, turnLeft$, turnRight$, turnU$).pipe(operators_1.catchError(function (error, caught) {
30437 console.error("Failed to cache spatial edges.", error);
30438 return rxjs_1.empty();
30441 .subscribe(function () { });
30443 CacheComponent.prototype._deactivate = function () {
30444 this._sequenceSubscription.unsubscribe();
30445 this._spatialSubscription.unsubscribe();
30447 CacheComponent.prototype._getDefaultConfiguration = function () {
30448 return { depth: { pano: 1, sequence: 2, step: 1, turn: 0 } };
30450 CacheComponent.prototype._cache$ = function (edges, direction, depth) {
30452 return rxjs_1.zip(rxjs_1.of(edges), rxjs_1.of(depth)).pipe(operators_1.expand(function (ed) {
30455 var edgesDepths$ = [];
30457 for (var _i = 0, es_1 = es; _i < es_1.length; _i++) {
30458 var edge = es_1[_i];
30459 if (edge.data.direction === direction) {
30460 edgesDepths$.push(rxjs_1.zip(_this._navigator.graphService.cacheNode$(edge.to).pipe(operators_1.mergeMap(function (n) {
30461 return _this._nodeToEdges$(n, direction);
30462 })), rxjs_1.of(d - 1)));
30466 return rxjs_1.from(edgesDepths$).pipe(operators_1.mergeAll());
30467 }), operators_1.skip(1));
30469 CacheComponent.prototype._nodeToEdges$ = function (node, direction) {
30470 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
30471 node.sequenceEdges$ :
30472 node.spatialEdges$).pipe(operators_1.first(function (status) {
30473 return status.cached;
30474 }), operators_1.map(function (status) {
30475 return status.edges;
30478 CacheComponent.componentName = "cache";
30479 return CacheComponent;
30480 }(Component_1.Component));
30481 exports.CacheComponent = CacheComponent;
30482 Component_1.ComponentService.register(CacheComponent);
30483 exports.default = CacheComponent;
30485 },{"../Component":291,"../Edge":292,"rxjs":43,"rxjs/operators":241}],310:[function(require,module,exports){
30487 var __extends = (this && this.__extends) || (function () {
30488 var extendStatics = function (d, b) {
30489 extendStatics = Object.setPrototypeOf ||
30490 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30491 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30492 return extendStatics(d, b);
30494 return function (d, b) {
30495 extendStatics(d, b);
30496 function __() { this.constructor = d; }
30497 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30500 Object.defineProperty(exports, "__esModule", { value: true });
30501 exports.Component = void 0;
30502 var operators_1 = require("rxjs/operators");
30503 var rxjs_1 = require("rxjs");
30504 var Utils_1 = require("../Utils");
30505 var Component = /** @class */ (function (_super) {
30506 __extends(Component, _super);
30507 function Component(name, container, navigator) {
30508 var _this = _super.call(this) || this;
30509 _this._activated$ = new rxjs_1.BehaviorSubject(false);
30510 _this._configurationSubject$ = new rxjs_1.Subject();
30511 _this._activated = false;
30512 _this._container = container;
30513 _this._name = name;
30514 _this._navigator = navigator;
30515 _this._configuration$ =
30516 _this._configurationSubject$.pipe(operators_1.startWith(_this.defaultConfiguration), operators_1.scan(function (conf, newConf) {
30517 for (var key in newConf) {
30518 if (newConf.hasOwnProperty(key)) {
30519 conf[key] = newConf[key];
30523 }), operators_1.publishReplay(1), operators_1.refCount());
30524 _this._configuration$.subscribe(function () { });
30527 Object.defineProperty(Component.prototype, "activated", {
30529 return this._activated;
30534 Object.defineProperty(Component.prototype, "activated$", {
30537 return this._activated$;
30542 Object.defineProperty(Component.prototype, "defaultConfiguration", {
30544 * Get default configuration.
30546 * @returns {TConfiguration} Default configuration for component.
30549 return this._getDefaultConfiguration();
30554 Object.defineProperty(Component.prototype, "configuration$", {
30557 return this._configuration$;
30562 Object.defineProperty(Component.prototype, "name", {
30566 * @description The name of the component. Used when interacting with the
30567 * component through the Viewer's API.
30575 Component.prototype.activate = function (conf) {
30576 if (this._activated) {
30579 if (conf !== undefined) {
30580 this._configurationSubject$.next(conf);
30582 this._activated = true;
30584 this._activated$.next(true);
30586 Component.prototype.configure = function (conf) {
30587 this._configurationSubject$.next(conf);
30589 Component.prototype.deactivate = function () {
30590 if (!this._activated) {
30593 this._activated = false;
30594 this._deactivate();
30595 this._container.domRenderer.clear(this._name);
30596 this._container.glRenderer.clear(this._name);
30597 this._activated$.next(false);
30600 * Detect the viewer's new width and height and resize the component's
30601 * rendered elements accordingly if applicable.
30605 Component.prototype.resize = function () { return; };
30606 Component.componentName = "not_worthy";
30608 }(Utils_1.EventEmitter));
30609 exports.Component = Component;
30610 exports.default = Component;
30612 },{"../Utils":301,"rxjs":43,"rxjs/operators":241}],311:[function(require,module,exports){
30614 Object.defineProperty(exports, "__esModule", { value: true });
30615 exports.ComponentService = void 0;
30616 var Error_1 = require("../Error");
30617 var ComponentService = /** @class */ (function () {
30618 function ComponentService(container, navigator) {
30619 this._components = {};
30620 for (var componentName in ComponentService.registeredComponents) {
30621 if (!ComponentService.registeredComponents.hasOwnProperty(componentName)) {
30624 var component = ComponentService.registeredComponents[componentName];
30625 this._components[componentName] = {
30627 component: new component(componentName, container, navigator),
30630 this._coverComponent = new ComponentService.registeredCoverComponent("cover", container, navigator);
30631 this._coverComponent.activate();
30632 this._coverActivated = true;
30634 ComponentService.register = function (component) {
30635 if (ComponentService.registeredComponents[component.componentName] === undefined) {
30636 ComponentService.registeredComponents[component.componentName] = component;
30639 ComponentService.registerCover = function (coverComponent) {
30640 ComponentService.registeredCoverComponent = coverComponent;
30642 Object.defineProperty(ComponentService.prototype, "coverActivated", {
30644 return this._coverActivated;
30649 ComponentService.prototype.activateCover = function () {
30650 if (this._coverActivated) {
30653 this._coverActivated = true;
30654 for (var componentName in this._components) {
30655 if (!this._components.hasOwnProperty(componentName)) {
30658 var component = this._components[componentName];
30659 if (component.active) {
30660 component.component.deactivate();
30664 ComponentService.prototype.deactivateCover = function () {
30665 if (!this._coverActivated) {
30668 this._coverActivated = false;
30669 for (var componentName in this._components) {
30670 if (!this._components.hasOwnProperty(componentName)) {
30673 var component = this._components[componentName];
30674 if (component.active) {
30675 component.component.activate();
30679 ComponentService.prototype.activate = function (name) {
30680 this._checkName(name);
30681 this._components[name].active = true;
30682 if (!this._coverActivated) {
30683 this.get(name).activate();
30686 ComponentService.prototype.configure = function (name, conf) {
30687 this._checkName(name);
30688 this.get(name).configure(conf);
30690 ComponentService.prototype.deactivate = function (name) {
30691 this._checkName(name);
30692 this._components[name].active = false;
30693 if (!this._coverActivated) {
30694 this.get(name).deactivate();
30697 ComponentService.prototype.get = function (name) {
30698 return this._components[name].component;
30700 ComponentService.prototype.getCover = function () {
30701 return this._coverComponent;
30703 ComponentService.prototype._checkName = function (name) {
30704 if (!(name in this._components)) {
30705 throw new Error_1.ArgumentMapillaryError("Component does not exist: " + name);
30708 ComponentService.registeredComponents = {};
30709 return ComponentService;
30711 exports.ComponentService = ComponentService;
30712 exports.default = ComponentService;
30714 },{"../Error":293}],312:[function(require,module,exports){
30716 var __extends = (this && this.__extends) || (function () {
30717 var extendStatics = function (d, b) {
30718 extendStatics = Object.setPrototypeOf ||
30719 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30720 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30721 return extendStatics(d, b);
30723 return function (d, b) {
30724 extendStatics(d, b);
30725 function __() { this.constructor = d; }
30726 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30729 Object.defineProperty(exports, "__esModule", { value: true });
30730 exports.CoverComponent = void 0;
30731 var rxjs_1 = require("rxjs");
30732 var operators_1 = require("rxjs/operators");
30733 var vd = require("virtual-dom");
30734 var Component_1 = require("../Component");
30735 var Utils_1 = require("../Utils");
30736 var Viewer_1 = require("../Viewer");
30737 var CoverComponent = /** @class */ (function (_super) {
30738 __extends(CoverComponent, _super);
30739 function CoverComponent(name, container, navigator) {
30740 return _super.call(this, name, container, navigator) || this;
30742 CoverComponent.prototype._activate = function () {
30744 this._configuration$.pipe(operators_1.distinctUntilChanged(undefined, function (configuration) {
30745 return configuration.state;
30746 }), operators_1.switchMap(function (configuration) {
30747 return rxjs_1.combineLatest(rxjs_1.of(configuration.state), _this._navigator.stateService.currentNode$);
30748 }), operators_1.switchMap(function (_a) {
30749 var state = _a[0], node = _a[1];
30750 var keySrc$ = rxjs_1.combineLatest(rxjs_1.of(node.key), node.image$.pipe(operators_1.filter(function (image) {
30752 }), operators_1.map(function (image) {
30755 return state === Component_1.CoverState.Visible ? keySrc$.pipe(operators_1.first()) : keySrc$;
30756 }), operators_1.distinctUntilChanged(function (_a, _b) {
30757 var k1 = _a[0], s1 = _a[1];
30758 var k2 = _b[0], s2 = _b[1];
30759 return k1 === k2 && s1 === s2;
30760 }), operators_1.map(function (_a) {
30761 var key = _a[0], src = _a[1];
30762 return { key: key, src: src };
30764 .subscribe(this._configurationSubject$);
30765 this._renderSubscription = rxjs_1.combineLatest(this._configuration$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
30766 var configuration = _a[0], size = _a[1];
30767 if (!configuration.key) {
30768 return { name: _this._name, vnode: vd.h("div", []) };
30770 var compactClass = size.width <= 640 || size.height <= 480 ? ".CoverCompact" : "";
30771 if (configuration.state === Component_1.CoverState.Hidden) {
30772 var doneContainer = vd.h("div.CoverContainer.CoverDone" + compactClass, [_this._getCoverBackgroundVNode(configuration)]);
30773 return { name: _this._name, vnode: doneContainer };
30775 var container = vd.h("div.CoverContainer" + compactClass, [_this._getCoverButtonVNode(configuration)]);
30776 return { name: _this._name, vnode: container };
30778 .subscribe(this._container.domRenderer.render$);
30780 CoverComponent.prototype._deactivate = function () {
30781 this._renderSubscription.unsubscribe();
30782 this._keySubscription.unsubscribe();
30784 CoverComponent.prototype._getDefaultConfiguration = function () {
30785 return { state: Component_1.CoverState.Visible };
30787 CoverComponent.prototype._getCoverButtonVNode = function (configuration) {
30789 var cover = configuration.state === Component_1.CoverState.Loading ? "div.Cover.CoverLoading" : "div.Cover";
30790 var coverButton = vd.h("div.CoverButton", [vd.h("div.CoverButtonIcon", [])]);
30791 var coverLogo = vd.h("a.CoverLogo", { href: Utils_1.Urls.explore, target: "_blank" }, []);
30792 var coverIndicator = vd.h("div.CoverIndicator", { onclick: function () { _this.configure({ state: Component_1.CoverState.Loading }); } }, []);
30793 return vd.h(cover, [
30794 this._getCoverBackgroundVNode(configuration),
30800 CoverComponent.prototype._getCoverBackgroundVNode = function (conf) {
30801 var url = conf.src != null ?
30802 conf.src : Utils_1.Urls.thumbnail(conf.key, Viewer_1.ImageSize.Size640);
30803 var properties = { style: { backgroundImage: "url(" + url + ")" } };
30805 if (conf.state === Component_1.CoverState.Loading) {
30806 children.push(vd.h("div.Spinner", {}, []));
30808 return vd.h("div.CoverBackground", properties, children);
30810 CoverComponent.componentName = "cover";
30811 return CoverComponent;
30812 }(Component_1.Component));
30813 exports.CoverComponent = CoverComponent;
30814 Component_1.ComponentService.registerCover(CoverComponent);
30815 exports.default = CoverComponent;
30817 },{"../Component":291,"../Utils":301,"../Viewer":302,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],313:[function(require,module,exports){
30819 var __extends = (this && this.__extends) || (function () {
30820 var extendStatics = function (d, b) {
30821 extendStatics = Object.setPrototypeOf ||
30822 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30823 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30824 return extendStatics(d, b);
30826 return function (d, b) {
30827 extendStatics(d, b);
30828 function __() { this.constructor = d; }
30829 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30832 Object.defineProperty(exports, "__esModule", { value: true });
30833 exports.DebugComponent = void 0;
30834 var rxjs_1 = require("rxjs");
30835 var operators_1 = require("rxjs/operators");
30836 var vd = require("virtual-dom");
30837 var Component_1 = require("../Component");
30838 var DebugComponent = /** @class */ (function (_super) {
30839 __extends(DebugComponent, _super);
30840 function DebugComponent() {
30841 var _this = _super !== null && _super.apply(this, arguments) || this;
30842 _this._open$ = new rxjs_1.BehaviorSubject(false);
30845 DebugComponent.prototype._activate = function () {
30847 this._disposable = rxjs_1.combineLatest(this._navigator.stateService.currentState$, this._open$, this._navigator.imageLoadingService.loadstatus$).pipe(operators_1.map(function (_a) {
30848 var frame = _a[0], open = _a[1], loadStatus = _a[2];
30849 return { name: _this._name, vnode: _this._getDebugVNode(open, _this._getDebugInfo(frame, loadStatus)) };
30851 .subscribe(this._container.domRenderer.render$);
30853 DebugComponent.prototype._deactivate = function () {
30854 this._disposable.unsubscribe();
30856 DebugComponent.prototype._getDefaultConfiguration = function () {
30859 DebugComponent.prototype._getDebugInfo = function (frame, loadStatus) {
30861 ret.push(vd.h("h2", "Node"));
30862 if (frame.state.currentNode) {
30863 ret.push(vd.h("p", "currentNode: " + frame.state.currentNode.key));
30865 if (frame.state.previousNode) {
30866 ret.push(vd.h("p", "previousNode: " + frame.state.previousNode.key));
30868 ret.push(vd.h("h2", "Loading"));
30872 for (var key in loadStatus) {
30873 if (!loadStatus.hasOwnProperty(key)) {
30876 var status_1 = loadStatus[key];
30877 total += status_1.loaded;
30878 if (status_1.loaded !== status_1.total) {
30885 ret.push(vd.h("p", "Loaded Images: " + loaded));
30886 ret.push(vd.h("p", "Loading Images: " + loading));
30887 ret.push(vd.h("p", "Total bytes loaded: " + total));
30888 ret.push(vd.h("h2", "Camera"));
30889 ret.push(vd.h("p", "camera.position.x: " + frame.state.camera.position.x));
30890 ret.push(vd.h("p", "camera.position.y: " + frame.state.camera.position.y));
30891 ret.push(vd.h("p", "camera.position.z: " + frame.state.camera.position.z));
30892 ret.push(vd.h("p", "camera.lookat.x: " + frame.state.camera.lookat.x));
30893 ret.push(vd.h("p", "camera.lookat.y: " + frame.state.camera.lookat.y));
30894 ret.push(vd.h("p", "camera.lookat.z: " + frame.state.camera.lookat.z));
30895 ret.push(vd.h("p", "camera.up.x: " + frame.state.camera.up.x));
30896 ret.push(vd.h("p", "camera.up.y: " + frame.state.camera.up.y));
30897 ret.push(vd.h("p", "camera.up.z: " + frame.state.camera.up.z));
30900 DebugComponent.prototype._getDebugVNode = function (open, info) {
30902 return vd.h("div.Debug", {}, [
30903 vd.h("h2", {}, ["Debug"]),
30904 this._getDebugVNodeButton(open),
30905 vd.h("pre", {}, info),
30909 return this._getDebugVNodeButton(open);
30912 DebugComponent.prototype._getDebugVNodeButton = function (open) {
30913 var buttonText = open ? "Disable Debug" : "D";
30914 var buttonCssClass = open ? "" : ".DebugButtonFixed";
30916 return vd.h("button.DebugButton" + buttonCssClass, { onclick: this._closeDebugElement.bind(this) }, [buttonText]);
30919 return vd.h("button.DebugButton" + buttonCssClass, { onclick: this._openDebugElement.bind(this) }, [buttonText]);
30922 DebugComponent.prototype._closeDebugElement = function (open) {
30923 this._open$.next(false);
30925 DebugComponent.prototype._openDebugElement = function () {
30926 this._open$.next(true);
30928 DebugComponent.componentName = "debug";
30929 return DebugComponent;
30930 }(Component_1.Component));
30931 exports.DebugComponent = DebugComponent;
30932 Component_1.ComponentService.register(DebugComponent);
30933 exports.default = DebugComponent;
30935 },{"../Component":291,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],314:[function(require,module,exports){
30937 var __extends = (this && this.__extends) || (function () {
30938 var extendStatics = function (d, b) {
30939 extendStatics = Object.setPrototypeOf ||
30940 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30941 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30942 return extendStatics(d, b);
30944 return function (d, b) {
30945 extendStatics(d, b);
30946 function __() { this.constructor = d; }
30947 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30950 Object.defineProperty(exports, "__esModule", { value: true });
30951 exports.ImageComponent = void 0;
30952 var rxjs_1 = require("rxjs");
30953 var operators_1 = require("rxjs/operators");
30954 var vd = require("virtual-dom");
30955 var Component_1 = require("../Component");
30956 var Utils_1 = require("../Utils");
30957 var ImageComponent = /** @class */ (function (_super) {
30958 __extends(ImageComponent, _super);
30959 function ImageComponent(name, container, navigator, dom) {
30960 var _this = _super.call(this, name, container, navigator) || this;
30961 _this._canvasId = container.id + "-" + _this._name;
30962 _this._dom = !!dom ? dom : new Utils_1.DOM();
30965 ImageComponent.prototype._activate = function () {
30967 var canvasSize$ = this._container.domRenderer.element$.pipe(operators_1.map(function (element) {
30968 return _this._dom.document.getElementById(_this._canvasId);
30969 }), operators_1.filter(function (canvas) {
30971 }), operators_1.map(function (canvas) {
30972 var adaptableDomRenderer = canvas.parentElement;
30973 var width = adaptableDomRenderer.offsetWidth;
30974 var height = adaptableDomRenderer.offsetHeight;
30975 return [canvas, { height: height, width: width }];
30976 }), operators_1.distinctUntilChanged(function (s1, s2) {
30977 return s1.height === s2.height && s1.width === s2.width;
30979 var canvas = _a[0], size = _a[1];
30982 this.drawSubscription = rxjs_1.combineLatest(canvasSize$, this._navigator.stateService.currentNode$)
30983 .subscribe(function (_a) {
30984 var _b = _a[0], canvas = _b[0], size = _b[1], node = _a[1];
30985 canvas.width = size.width;
30986 canvas.height = size.height;
30989 .drawImage(node.image, 0, 0, size.width, size.height);
30991 this._container.domRenderer.renderAdaptive$.next({ name: this._name, vnode: vd.h("canvas#" + this._canvasId, []) });
30993 ImageComponent.prototype._deactivate = function () {
30994 this.drawSubscription.unsubscribe();
30996 ImageComponent.prototype._getDefaultConfiguration = function () {
30999 ImageComponent.componentName = "image";
31000 return ImageComponent;
31001 }(Component_1.Component));
31002 exports.ImageComponent = ImageComponent;
31003 Component_1.ComponentService.register(ImageComponent);
31004 exports.default = ImageComponent;
31007 },{"../Component":291,"../Utils":301,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],315:[function(require,module,exports){
31009 var __extends = (this && this.__extends) || (function () {
31010 var extendStatics = function (d, b) {
31011 extendStatics = Object.setPrototypeOf ||
31012 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31013 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
31014 return extendStatics(d, b);
31016 return function (d, b) {
31017 extendStatics(d, b);
31018 function __() { this.constructor = d; }
31019 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31022 Object.defineProperty(exports, "__esModule", { value: true });
31023 exports.LoadingComponent = void 0;
31024 var rxjs_1 = require("rxjs");
31025 var operators_1 = require("rxjs/operators");
31026 var vd = require("virtual-dom");
31027 var Component_1 = require("../Component");
31028 var LoadingComponent = /** @class */ (function (_super) {
31029 __extends(LoadingComponent, _super);
31030 function LoadingComponent(name, container, navigator) {
31031 return _super.call(this, name, container, navigator) || this;
31033 LoadingComponent.prototype._activate = function () {
31035 this._loadingSubscription = this._navigator.loadingService.loading$.pipe(operators_1.switchMap(function (loading) {
31037 _this._navigator.imageLoadingService.loadstatus$ :
31039 }), operators_1.map(function (loadStatus) {
31042 for (var key in loadStatus) {
31043 if (!loadStatus.hasOwnProperty(key)) {
31046 var status_1 = loadStatus[key];
31047 if (status_1.loaded !== status_1.total) {
31048 loaded += status_1.loaded;
31049 total += status_1.total;
31052 var percentage = 100;
31054 percentage = (loaded / total) * 100;
31056 return { name: _this._name, vnode: _this._getBarVNode(percentage) };
31058 .subscribe(this._container.domRenderer.render$);
31060 LoadingComponent.prototype._deactivate = function () {
31061 this._loadingSubscription.unsubscribe();
31063 LoadingComponent.prototype._getDefaultConfiguration = function () {
31066 LoadingComponent.prototype._getBarVNode = function (percentage) {
31067 var loadingBarStyle = {};
31068 var loadingContainerStyle = {};
31069 if (percentage !== 100) {
31070 loadingBarStyle.width = percentage.toFixed(0) + "%";
31071 loadingBarStyle.opacity = "1";
31074 loadingBarStyle.width = "100%";
31075 loadingBarStyle.opacity = "0";
31077 return vd.h("div.Loading", { style: loadingContainerStyle }, [vd.h("div.LoadingBar", { style: loadingBarStyle }, [])]);
31079 LoadingComponent.componentName = "loading";
31080 return LoadingComponent;
31081 }(Component_1.Component));
31082 exports.LoadingComponent = LoadingComponent;
31083 Component_1.ComponentService.register(LoadingComponent);
31084 exports.default = LoadingComponent;
31086 },{"../Component":291,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],316:[function(require,module,exports){
31088 var __extends = (this && this.__extends) || (function () {
31089 var extendStatics = function (d, b) {
31090 extendStatics = Object.setPrototypeOf ||
31091 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31092 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
31093 return extendStatics(d, b);
31095 return function (d, b) {
31096 extendStatics(d, b);
31097 function __() { this.constructor = d; }
31098 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31101 Object.defineProperty(exports, "__esModule", { value: true });
31102 exports.NavigationComponent = void 0;
31103 var rxjs_1 = require("rxjs");
31104 var operators_1 = require("rxjs/operators");
31105 var vd = require("virtual-dom");
31106 var Edge_1 = require("../Edge");
31107 var Error_1 = require("../Error");
31108 var Component_1 = require("../Component");
31110 * @class NavigationComponent
31112 * @classdesc Fallback navigation component for environments without WebGL support.
31114 * Replaces the functionality in the Direction and Sequence components.
31116 var NavigationComponent = /** @class */ (function (_super) {
31117 __extends(NavigationComponent, _super);
31119 function NavigationComponent(name, container, navigator) {
31120 var _this = _super.call(this, name, container, navigator) || this;
31121 _this._seqNames = {};
31122 _this._seqNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.Prev]] = "Prev";
31123 _this._seqNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.Next]] = "Next";
31124 _this._spaTopNames = {};
31125 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnLeft]] = "Turnleft";
31126 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepLeft]] = "Left";
31127 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepForward]] = "Forward";
31128 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepRight]] = "Right";
31129 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnRight]] = "Turnright";
31130 _this._spaBottomNames = {};
31131 _this._spaBottomNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnU]] = "Turnaround";
31132 _this._spaBottomNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepBackward]] = "Backward";
31135 NavigationComponent.prototype._activate = function () {
31137 this._renderSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, this._configuration$).pipe(operators_1.switchMap(function (_a) {
31138 var node = _a[0], configuration = _a[1];
31139 var sequenceEdges$ = configuration.sequence ?
31140 node.sequenceEdges$.pipe(operators_1.map(function (status) {
31141 return status.edges
31142 .map(function (edge) {
31143 return edge.data.direction;
31147 var spatialEdges$ = !node.pano && configuration.spatial ?
31148 node.spatialEdges$.pipe(operators_1.map(function (status) {
31149 return status.edges
31150 .map(function (edge) {
31151 return edge.data.direction;
31155 return rxjs_1.combineLatest(sequenceEdges$, spatialEdges$).pipe(operators_1.map(function (_a) {
31156 var seq = _a[0], spa = _a[1];
31157 return seq.concat(spa);
31159 }), operators_1.map(function (edgeDirections) {
31160 var seqs = _this._createArrowRow(_this._seqNames, edgeDirections);
31161 var spaTops = _this._createArrowRow(_this._spaTopNames, edgeDirections);
31162 var spaBottoms = _this._createArrowRow(_this._spaBottomNames, edgeDirections);
31163 var seqContainer = vd.h("div.NavigationSequence", seqs);
31164 var spaTopContainer = vd.h("div.NavigationSpatialTop", spaTops);
31165 var spaBottomContainer = vd.h("div.NavigationSpatialBottom", spaBottoms);
31166 var spaContainer = vd.h("div.NavigationSpatial", [spaTopContainer, spaBottomContainer]);
31167 return { name: _this._name, vnode: vd.h("div.NavigationContainer", [seqContainer, spaContainer]) };
31169 .subscribe(this._container.domRenderer.render$);
31171 NavigationComponent.prototype._deactivate = function () {
31172 this._renderSubscription.unsubscribe();
31174 NavigationComponent.prototype._getDefaultConfiguration = function () {
31175 return { sequence: true, spatial: true };
31177 NavigationComponent.prototype._createArrowRow = function (arrowNames, edgeDirections) {
31179 for (var arrowName in arrowNames) {
31180 if (!(arrowNames.hasOwnProperty(arrowName))) {
31183 var direction = Edge_1.EdgeDirection[arrowName];
31184 if (edgeDirections.indexOf(direction) !== -1) {
31185 arrows.push(this._createVNode(direction, arrowNames[arrowName], "visible"));
31188 arrows.push(this._createVNode(direction, arrowNames[arrowName], "hidden"));
31193 NavigationComponent.prototype._createVNode = function (direction, name, visibility) {
31195 return vd.h("span.Direction.Direction" + name, {
31196 onclick: function (ev) {
31197 _this._navigator.moveDir$(direction)
31198 .subscribe(undefined, function (error) {
31199 if (!(error instanceof Error_1.AbortMapillaryError)) {
31200 console.error(error);
31205 visibility: visibility,
31209 NavigationComponent.componentName = "navigation";
31210 return NavigationComponent;
31211 }(Component_1.Component));
31212 exports.NavigationComponent = NavigationComponent;
31213 Component_1.ComponentService.register(NavigationComponent);
31214 exports.default = NavigationComponent;
31216 },{"../Component":291,"../Edge":292,"../Error":293,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],317:[function(require,module,exports){
31218 var __extends = (this && this.__extends) || (function () {
31219 var extendStatics = function (d, b) {
31220 extendStatics = Object.setPrototypeOf ||
31221 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31222 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
31223 return extendStatics(d, b);
31225 return function (d, b) {
31226 extendStatics(d, b);
31227 function __() { this.constructor = d; }
31228 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31231 Object.defineProperty(exports, "__esModule", { value: true });
31232 exports.RouteComponent = void 0;
31233 var rxjs_1 = require("rxjs");
31234 var operators_1 = require("rxjs/operators");
31235 var vd = require("virtual-dom");
31236 var Component_1 = require("../Component");
31237 var DescriptionState = /** @class */ (function () {
31238 function DescriptionState() {
31240 return DescriptionState;
31242 var RouteState = /** @class */ (function () {
31243 function RouteState() {
31247 var RouteTrack = /** @class */ (function () {
31248 function RouteTrack() {
31249 this.nodeInstructions = [];
31250 this.nodeInstructionsOrdered = [];
31254 var RouteComponent = /** @class */ (function (_super) {
31255 __extends(RouteComponent, _super);
31256 function RouteComponent(name, container, navigator) {
31257 return _super.call(this, name, container, navigator) || this;
31259 RouteComponent.prototype.play = function () {
31260 this.configure({ playing: true });
31262 RouteComponent.prototype.stop = function () {
31263 this.configure({ playing: false });
31265 RouteComponent.prototype._activate = function () {
31267 var slowedStream$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
31268 return (frame.id % 2) === 0;
31269 }), operators_1.filter(function (frame) {
31270 return frame.state.nodesAhead < 15;
31271 }), operators_1.distinctUntilChanged(undefined, function (frame) {
31272 return frame.state.lastNode.key;
31274 var routeTrack$ = rxjs_1.combineLatest(this.configuration$.pipe(operators_1.mergeMap(function (conf) {
31275 return rxjs_1.from(conf.paths);
31276 }), operators_1.distinct(function (p) {
31277 return p.sequenceKey;
31278 }), operators_1.mergeMap(function (path) {
31279 return _this._navigator.apiV3.sequenceByKey$([path.sequenceKey]).pipe(operators_1.map(function (sequenceByKey) {
31280 return sequenceByKey[path.sequenceKey];
31282 })), this.configuration$).pipe(operators_1.map(function (_a) {
31283 var sequence = _a[0], conf = _a[1];
31285 var instructionPlaces = [];
31286 for (var _i = 0, _b = conf.paths; _i < _b.length; _i++) {
31288 if (path.sequenceKey === sequence.key) {
31289 var nodeInstructions = [];
31290 var saveKey = false;
31291 for (var _c = 0, _d = sequence.keys; _c < _d.length; _c++) {
31293 if (path.startKey === key) {
31297 var description = null;
31298 for (var _e = 0, _f = path.infoKeys; _e < _f.length; _e++) {
31299 var infoKey = _f[_e];
31300 if (infoKey.key === key) {
31301 description = infoKey.description;
31304 nodeInstructions.push({ description: description, key: key });
31306 if (path.stopKey === key) {
31310 instructionPlaces.push({ nodeInstructions: nodeInstructions, place: i });
31314 return instructionPlaces;
31315 }), operators_1.scan(function (routeTrack, instructionPlaces) {
31316 for (var _i = 0, instructionPlaces_1 = instructionPlaces; _i < instructionPlaces_1.length; _i++) {
31317 var instructionPlace = instructionPlaces_1[_i];
31318 routeTrack.nodeInstructionsOrdered[instructionPlace.place] = instructionPlace.nodeInstructions;
31320 for (var place in routeTrack.nodeInstructionsOrdered) {
31321 if (!routeTrack.nodeInstructionsOrdered.hasOwnProperty(place)) {
31324 var instructionGroup = routeTrack.nodeInstructionsOrdered[place];
31325 for (var _a = 0, instructionGroup_1 = instructionGroup; _a < instructionGroup_1.length; _a++) {
31326 var instruction = instructionGroup_1[_a];
31327 routeTrack.nodeInstructions.push(instruction);
31331 }, new RouteTrack()));
31332 var cacheNode$ = rxjs_1.combineLatest(slowedStream$, routeTrack$, this.configuration$).pipe(operators_1.map(function (_a) {
31333 var frame = _a[0], routeTrack = _a[1], conf = _a[2];
31334 return { conf: conf, frame: frame, routeTrack: routeTrack };
31335 }), operators_1.scan(function (routeState, rtAndFrame) {
31336 if (rtAndFrame.conf.playing === undefined || rtAndFrame.conf.playing) {
31337 routeState.routeTrack = rtAndFrame.routeTrack;
31338 routeState.currentNode = rtAndFrame.frame.state.currentNode;
31339 routeState.lastNode = rtAndFrame.frame.state.lastNode;
31340 routeState.playing = true;
31343 _this._navigator.stateService.cutNodes();
31344 routeState.playing = false;
31347 }, new RouteState()), operators_1.filter(function (routeState) {
31348 return routeState.playing;
31349 }), operators_1.filter(function (routeState) {
31350 for (var _i = 0, _a = routeState.routeTrack.nodeInstructions; _i < _a.length; _i++) {
31351 var nodeInstruction = _a[_i];
31352 if (!nodeInstruction) {
31355 if (nodeInstruction.key === routeState.lastNode.key) {
31360 }), operators_1.distinctUntilChanged(undefined, function (routeState) {
31361 return routeState.lastNode.key;
31362 }), operators_1.mergeMap(function (routeState) {
31364 for (var _i = 0, _a = routeState.routeTrack.nodeInstructions; _i < _a.length; _i++) {
31365 var nodeInstruction = _a[_i];
31366 if (nodeInstruction.key === routeState.lastNode.key) {
31371 var nextInstruction = routeState.routeTrack.nodeInstructions[i + 1];
31372 if (!nextInstruction) {
31373 return rxjs_1.of(null);
31375 return _this._navigator.graphService.cacheNode$(nextInstruction.key);
31377 this._disposable = rxjs_1.combineLatest(cacheNode$, this.configuration$).pipe(operators_1.map(function (_a) {
31378 var node = _a[0], conf = _a[1];
31379 return { conf: conf, node: node };
31380 }), operators_1.filter(function (cAN) {
31381 return cAN.node !== null && cAN.conf.playing;
31382 }), operators_1.pluck("node"))
31383 .subscribe(this._navigator.stateService.appendNode$);
31384 this._disposableDescription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, routeTrack$, this.configuration$).pipe(operators_1.map(function (_a) {
31385 var node = _a[0], routeTrack = _a[1], conf = _a[2];
31386 if (conf.playing !== undefined && !conf.playing) {
31389 var description = null;
31390 for (var _i = 0, _b = routeTrack.nodeInstructions; _i < _b.length; _i++) {
31391 var nodeInstruction = _b[_i];
31392 if (nodeInstruction.key === node.key) {
31393 description = nodeInstruction.description;
31397 return description;
31398 }), operators_1.scan(function (descriptionState, description) {
31399 if (description !== descriptionState.description && description !== null) {
31400 descriptionState.description = description;
31401 descriptionState.showsLeft = 6;
31404 descriptionState.showsLeft--;
31406 if (description === "quit") {
31407 descriptionState.description = null;
31409 return descriptionState;
31410 }, new DescriptionState()), operators_1.map(function (descriptionState) {
31411 if (descriptionState.showsLeft > 0 && descriptionState.description) {
31412 return { name: _this._name, vnode: _this._getRouteAnnotationNode(descriptionState.description) };
31415 return { name: _this._name, vnode: vd.h("div", []) };
31418 .subscribe(this._container.domRenderer.render$);
31420 RouteComponent.prototype._deactivate = function () {
31421 this._disposable.unsubscribe();
31422 this._disposableDescription.unsubscribe();
31424 RouteComponent.prototype._getDefaultConfiguration = function () {
31427 RouteComponent.prototype._getRouteAnnotationNode = function (description) {
31428 return vd.h("div.RouteFrame", {}, [
31429 vd.h("p", { textContent: description }, []),
31432 RouteComponent.componentName = "route";
31433 return RouteComponent;
31434 }(Component_1.Component));
31435 exports.RouteComponent = RouteComponent;
31436 Component_1.ComponentService.register(RouteComponent);
31437 exports.default = RouteComponent;
31439 },{"../Component":291,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],318:[function(require,module,exports){
31441 var __extends = (this && this.__extends) || (function () {
31442 var extendStatics = function (d, b) {
31443 extendStatics = Object.setPrototypeOf ||
31444 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31445 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
31446 return extendStatics(d, b);
31448 return function (d, b) {
31449 extendStatics(d, b);
31450 function __() { this.constructor = d; }
31451 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31454 Object.defineProperty(exports, "__esModule", { value: true });
31455 exports.StatsComponent = void 0;
31456 var rxjs_1 = require("rxjs");
31457 var operators_1 = require("rxjs/operators");
31458 var Component_1 = require("../Component");
31459 var StatsComponent = /** @class */ (function (_super) {
31460 __extends(StatsComponent, _super);
31461 function StatsComponent(name, container, navigator, scheduler) {
31462 var _this = _super.call(this, name, container, navigator) || this;
31463 _this._scheduler = scheduler;
31466 StatsComponent.prototype._activate = function () {
31468 this._sequenceSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.scan(function (keys, node) {
31469 var sKey = node.sequenceKey;
31471 if (!(sKey in keys.reported)) {
31472 keys.report = [sKey];
31473 keys.reported[sKey] = true;
31476 }, { report: [], reported: {} }), operators_1.filter(function (keys) {
31477 return keys.report.length > 0;
31478 }), operators_1.mergeMap(function (keys) {
31479 return _this._navigator.apiV3.sequenceViewAdd$(keys.report).pipe(operators_1.catchError(function (error, caught) {
31480 console.error("Failed to report sequence stats (" + keys.report + ")", error);
31481 return rxjs_1.empty();
31484 .subscribe(function () { });
31485 this._imageSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
31487 })).pipe(operators_1.buffer(this._navigator.stateService.currentNode$.pipe(operators_1.debounceTime(5000, this._scheduler))), operators_1.scan(function (keys, newKeys) {
31489 for (var _i = 0, newKeys_1 = newKeys; _i < newKeys_1.length; _i++) {
31490 var key = newKeys_1[_i];
31491 if (!(key in keys.reported)) {
31492 keys.report.push(key);
31493 keys.reported[key] = true;
31497 }, { report: [], reported: {} }), operators_1.filter(function (keys) {
31498 return keys.report.length > 0;
31499 }), operators_1.mergeMap(function (keys) {
31500 return _this._navigator.apiV3.imageViewAdd$(keys.report).pipe(operators_1.catchError(function (error, caught) {
31501 console.error("Failed to report image stats (" + keys.report + ")", error);
31502 return rxjs_1.empty();
31505 .subscribe(function () { });
31507 StatsComponent.prototype._deactivate = function () {
31508 this._sequenceSubscription.unsubscribe();
31509 this._imageSubscription.unsubscribe();
31511 StatsComponent.prototype._getDefaultConfiguration = function () {
31514 StatsComponent.componentName = "stats";
31515 return StatsComponent;
31516 }(Component_1.Component));
31517 exports.StatsComponent = StatsComponent;
31518 Component_1.ComponentService.register(StatsComponent);
31519 exports.default = StatsComponent;
31521 },{"../Component":291,"rxjs":43,"rxjs/operators":241}],319:[function(require,module,exports){
31523 var __extends = (this && this.__extends) || (function () {
31524 var extendStatics = function (d, b) {
31525 extendStatics = Object.setPrototypeOf ||
31526 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31527 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
31528 return extendStatics(d, b);
31530 return function (d, b) {
31531 extendStatics(d, b);
31532 function __() { this.constructor = d; }
31533 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31536 Object.defineProperty(exports, "__esModule", { value: true });
31537 exports.DirectionComponent = void 0;
31538 var vd = require("virtual-dom");
31539 var rxjs_1 = require("rxjs");
31540 var operators_1 = require("rxjs/operators");
31541 var Component_1 = require("../../Component");
31543 * @class DirectionComponent
31544 * @classdesc Component showing navigation arrows for steps and turns.
31546 var DirectionComponent = /** @class */ (function (_super) {
31547 __extends(DirectionComponent, _super);
31548 function DirectionComponent(name, container, navigator, directionDOMRenderer) {
31549 var _this = _super.call(this, name, container, navigator) || this;
31550 _this._renderer = !!directionDOMRenderer ?
31551 directionDOMRenderer :
31552 new Component_1.DirectionDOMRenderer(_this.defaultConfiguration, { height: container.element.offsetHeight, width: container.element.offsetWidth });
31553 _this._hoveredKeySubject$ = new rxjs_1.Subject();
31554 _this._hoveredKey$ = _this._hoveredKeySubject$.pipe(operators_1.share());
31557 Object.defineProperty(DirectionComponent.prototype, "hoveredKey$", {
31559 * Get hovered key observable.
31561 * @description An observable emitting the key of the node for the direction
31562 * arrow that is being hovered. When the mouse leaves a direction arrow null
31565 * @returns {Observable<string>}
31568 return this._hoveredKey$;
31574 * Set highlight key.
31576 * @description The arrow pointing towards the node corresponding to the
31577 * highlight key will be highlighted.
31579 * @param {string} highlightKey Key of node to be highlighted if existing
31582 DirectionComponent.prototype.setHighlightKey = function (highlightKey) {
31583 this.configure({ highlightKey: highlightKey });
31586 * Set min width of container element.
31588 * @description Set min width of the non transformed container element holding
31589 * the navigation arrows. If the min width is larger than the max width the
31590 * min width value will be used.
31592 * The container element is automatically resized when the resize
31593 * method on the Viewer class is called.
31595 * @param {number} minWidth
31597 DirectionComponent.prototype.setMinWidth = function (minWidth) {
31598 this.configure({ minWidth: minWidth });
31601 * Set max width of container element.
31603 * @description Set max width of the non transformed container element holding
31604 * the navigation arrows. If the min width is larger than the max width the
31605 * min width value will be used.
31607 * The container element is automatically resized when the resize
31608 * method on the Viewer class is called.
31610 * @param {number} minWidth
31612 DirectionComponent.prototype.setMaxWidth = function (maxWidth) {
31613 this.configure({ maxWidth: maxWidth });
31615 DirectionComponent.prototype._activate = function () {
31617 this._configurationSubscription = this._configuration$
31618 .subscribe(function (configuration) {
31619 _this._renderer.setConfiguration(configuration);
31621 this._resizeSubscription = this._container.renderService.size$
31622 .subscribe(function (size) {
31623 _this._renderer.resize(size);
31625 this._nodeSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.tap(function (node) {
31626 _this._container.domRenderer.render$.next({ name: _this._name, vnode: vd.h("div", {}, []) });
31627 _this._renderer.setNode(node);
31628 }), operators_1.withLatestFrom(this._configuration$), operators_1.switchMap(function (_a) {
31629 var node = _a[0], configuration = _a[1];
31630 return rxjs_1.combineLatest(node.spatialEdges$, configuration.distinguishSequence ?
31631 _this._navigator.graphService
31632 .cacheSequence$(node.sequenceKey).pipe(operators_1.catchError(function (error, caught) {
31633 console.error("Failed to cache sequence (" + node.sequenceKey + ")", error);
31634 return rxjs_1.of(null);
31638 .subscribe(function (_a) {
31639 var edgeStatus = _a[0], sequence = _a[1];
31640 _this._renderer.setEdges(edgeStatus, sequence);
31642 this._renderCameraSubscription = this._container.renderService.renderCameraFrame$.pipe(operators_1.tap(function (renderCamera) {
31643 _this._renderer.setRenderCamera(renderCamera);
31644 }), operators_1.map(function () {
31645 return _this._renderer;
31646 }), operators_1.filter(function (renderer) {
31647 return renderer.needsRender;
31648 }), operators_1.map(function (renderer) {
31649 return { name: _this._name, vnode: renderer.render(_this._navigator) };
31651 .subscribe(this._container.domRenderer.render$);
31652 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) {
31653 var element = _a[0];
31654 var elements = element.getElementsByClassName("DirectionsPerspective");
31655 for (var i = 0; i < elements.length; i++) {
31656 var hovered = elements.item(i).querySelector(":hover");
31657 if (hovered != null && hovered.hasAttribute("data-key")) {
31658 return hovered.getAttribute("data-key");
31662 }), operators_1.distinctUntilChanged())
31663 .subscribe(this._hoveredKeySubject$);
31664 this._emitHoveredKeySubscription = this._hoveredKey$
31665 .subscribe(function (key) {
31666 _this.fire(DirectionComponent.hoveredkeychanged, key);
31669 DirectionComponent.prototype._deactivate = function () {
31670 this._configurationSubscription.unsubscribe();
31671 this._emitHoveredKeySubscription.unsubscribe();
31672 this._hoveredKeySubscription.unsubscribe();
31673 this._nodeSubscription.unsubscribe();
31674 this._renderCameraSubscription.unsubscribe();
31676 DirectionComponent.prototype._getDefaultConfiguration = function () {
31678 distinguishSequence: false,
31684 DirectionComponent.componentName = "direction";
31686 * Event fired when the hovered key changes.
31688 * @description Emits the key of the node for the direction
31689 * arrow that is being hovered. When the mouse leaves a
31690 * direction arrow null is emitted.
31692 * @event DirectionComponent#hoveredkeychanged
31693 * @type {string} The hovered key, null if no key is hovered.
31695 DirectionComponent.hoveredkeychanged = "hoveredkeychanged";
31696 return DirectionComponent;
31697 }(Component_1.Component));
31698 exports.DirectionComponent = DirectionComponent;
31699 Component_1.ComponentService.register(DirectionComponent);
31700 exports.default = DirectionComponent;
31703 },{"../../Component":291,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],320:[function(require,module,exports){
31705 Object.defineProperty(exports, "__esModule", { value: true });
31706 exports.DirectionDOMCalculator = void 0;
31707 var Geo_1 = require("../../Geo");
31709 * @class DirectionDOMCalculator
31710 * @classdesc Helper class for calculating DOM CSS properties.
31712 var DirectionDOMCalculator = /** @class */ (function () {
31713 function DirectionDOMCalculator(configuration, size) {
31714 this._spatial = new Geo_1.Spatial();
31715 this._minThresholdWidth = 320;
31716 this._maxThresholdWidth = 1480;
31717 this._minThresholdHeight = 240;
31718 this._maxThresholdHeight = 820;
31719 this._configure(configuration);
31720 this._resize(size);
31723 Object.defineProperty(DirectionDOMCalculator.prototype, "minWidth", {
31725 return this._minWidth;
31730 Object.defineProperty(DirectionDOMCalculator.prototype, "maxWidth", {
31732 return this._maxWidth;
31737 Object.defineProperty(DirectionDOMCalculator.prototype, "containerWidth", {
31739 return this._containerWidth;
31744 Object.defineProperty(DirectionDOMCalculator.prototype, "containerWidthCss", {
31746 return this._containerWidthCss;
31751 Object.defineProperty(DirectionDOMCalculator.prototype, "containerMarginCss", {
31753 return this._containerMarginCss;
31758 Object.defineProperty(DirectionDOMCalculator.prototype, "containerLeftCss", {
31760 return this._containerLeftCss;
31765 Object.defineProperty(DirectionDOMCalculator.prototype, "containerHeight", {
31767 return this._containerHeight;
31772 Object.defineProperty(DirectionDOMCalculator.prototype, "containerHeightCss", {
31774 return this._containerHeightCss;
31779 Object.defineProperty(DirectionDOMCalculator.prototype, "containerBottomCss", {
31781 return this._containerBottomCss;
31786 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleSize", {
31788 return this._stepCircleSize;
31793 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleSizeCss", {
31795 return this._stepCircleSizeCss;
31800 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleMarginCss", {
31802 return this._stepCircleMarginCss;
31807 Object.defineProperty(DirectionDOMCalculator.prototype, "turnCircleSize", {
31809 return this._turnCircleSize;
31814 Object.defineProperty(DirectionDOMCalculator.prototype, "turnCircleSizeCss", {
31816 return this._turnCircleSizeCss;
31821 Object.defineProperty(DirectionDOMCalculator.prototype, "outerRadius", {
31823 return this._outerRadius;
31828 Object.defineProperty(DirectionDOMCalculator.prototype, "innerRadius", {
31830 return this._innerRadius;
31835 Object.defineProperty(DirectionDOMCalculator.prototype, "shadowOffset", {
31837 return this._shadowOffset;
31843 * Configures the min and max width values.
31845 * @param {IDirectionConfiguration} configuration Configuration
31846 * with min and max width values.
31848 DirectionDOMCalculator.prototype.configure = function (configuration) {
31849 this._configure(configuration);
31853 * Resizes all properties according to the width and height
31854 * of the size object.
31856 * @param {ISize} size The size of the container element.
31858 DirectionDOMCalculator.prototype.resize = function (size) {
31859 this._resize(size);
31863 * Calculates the coordinates on the unit circle for an angle.
31865 * @param {number} angle Angle in radians.
31866 * @returns {Array<number>} The x and y coordinates on the unit circle.
31868 DirectionDOMCalculator.prototype.angleToCoordinates = function (angle) {
31869 return [Math.cos(angle), Math.sin(angle)];
31872 * Calculates the coordinates on the unit circle for the
31873 * relative angle between the first and second angle.
31875 * @param {number} first Angle in radians.
31876 * @param {number} second Angle in radians.
31877 * @returns {Array<number>} The x and y coordinates on the unit circle
31878 * for the relative angle between the first and second angle.
31880 DirectionDOMCalculator.prototype.relativeAngleToCoordiantes = function (first, second) {
31881 var relativeAngle = this._spatial.wrapAngle(first - second);
31882 return this.angleToCoordinates(relativeAngle);
31884 DirectionDOMCalculator.prototype._configure = function (configuration) {
31885 this._minWidth = configuration.minWidth;
31886 this._maxWidth = this._getMaxWidth(configuration.minWidth, configuration.maxWidth);
31888 DirectionDOMCalculator.prototype._resize = function (size) {
31889 this._elementWidth = size.width;
31890 this._elementHeight = size.height;
31892 DirectionDOMCalculator.prototype._reset = function () {
31893 this._containerWidth = this._getContainerWidth(this._elementWidth, this._elementHeight);
31894 this._containerHeight = this._getContainerHeight(this.containerWidth);
31895 this._stepCircleSize = this._getStepCircleDiameter(this._containerHeight);
31896 this._turnCircleSize = this._getTurnCircleDiameter(this.containerHeight);
31897 this._outerRadius = this._getOuterRadius(this._containerHeight);
31898 this._innerRadius = this._getInnerRadius(this._containerHeight);
31899 this._shadowOffset = 3;
31900 this._containerWidthCss = this._numberToCssPixels(this._containerWidth);
31901 this._containerMarginCss = this._numberToCssPixels(-0.5 * this._containerWidth);
31902 this._containerLeftCss = this._numberToCssPixels(Math.floor(0.5 * this._elementWidth));
31903 this._containerHeightCss = this._numberToCssPixels(this._containerHeight);
31904 this._containerBottomCss = this._numberToCssPixels(Math.floor(-0.08 * this._containerHeight));
31905 this._stepCircleSizeCss = this._numberToCssPixels(this._stepCircleSize);
31906 this._stepCircleMarginCss = this._numberToCssPixels(-0.5 * this._stepCircleSize);
31907 this._turnCircleSizeCss = this._numberToCssPixels(this._turnCircleSize);
31909 DirectionDOMCalculator.prototype._getContainerWidth = function (elementWidth, elementHeight) {
31910 var relativeWidth = (elementWidth - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth);
31911 var relativeHeight = (elementHeight - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight);
31912 var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight)));
31913 coeff = 0.04 * Math.round(25 * coeff);
31914 return this._minWidth + coeff * (this._maxWidth - this._minWidth);
31916 DirectionDOMCalculator.prototype._getContainerHeight = function (containerWidth) {
31917 return 0.77 * containerWidth;
31919 DirectionDOMCalculator.prototype._getStepCircleDiameter = function (containerHeight) {
31920 return 0.34 * containerHeight;
31922 DirectionDOMCalculator.prototype._getTurnCircleDiameter = function (containerHeight) {
31923 return 0.3 * containerHeight;
31925 DirectionDOMCalculator.prototype._getOuterRadius = function (containerHeight) {
31926 return 0.31 * containerHeight;
31928 DirectionDOMCalculator.prototype._getInnerRadius = function (containerHeight) {
31929 return 0.125 * containerHeight;
31931 DirectionDOMCalculator.prototype._numberToCssPixels = function (value) {
31932 return value + "px";
31934 DirectionDOMCalculator.prototype._getMaxWidth = function (value, minWidth) {
31935 return value > minWidth ? value : minWidth;
31937 return DirectionDOMCalculator;
31939 exports.DirectionDOMCalculator = DirectionDOMCalculator;
31940 exports.default = DirectionDOMCalculator;
31943 },{"../../Geo":294}],321:[function(require,module,exports){
31945 Object.defineProperty(exports, "__esModule", { value: true });
31946 exports.DirectionDOMRenderer = void 0;
31947 var vd = require("virtual-dom");
31948 var Component_1 = require("../../Component");
31949 var Edge_1 = require("../../Edge");
31950 var Error_1 = require("../../Error");
31951 var Geo_1 = require("../../Geo");
31953 * @class DirectionDOMRenderer
31954 * @classdesc DOM renderer for direction arrows.
31956 var DirectionDOMRenderer = /** @class */ (function () {
31957 function DirectionDOMRenderer(configuration, size) {
31958 this._isEdge = false;
31959 this._spatial = new Geo_1.Spatial();
31960 this._calculator = new Component_1.DirectionDOMCalculator(configuration, size);
31962 this._rotation = { phi: 0, theta: 0 };
31963 this._epsilon = 0.5 * Math.PI / 180;
31964 this._highlightKey = null;
31965 this._distinguishSequence = false;
31966 this._needsRender = false;
31967 this._stepEdges = [];
31968 this._turnEdges = [];
31969 this._panoEdges = [];
31970 this._sequenceEdgeKeys = [];
31971 this._stepDirections = [
31972 Edge_1.EdgeDirection.StepForward,
31973 Edge_1.EdgeDirection.StepBackward,
31974 Edge_1.EdgeDirection.StepLeft,
31975 Edge_1.EdgeDirection.StepRight,
31977 this._turnDirections = [
31978 Edge_1.EdgeDirection.TurnLeft,
31979 Edge_1.EdgeDirection.TurnRight,
31980 Edge_1.EdgeDirection.TurnU,
31982 this._turnNames = {};
31983 this._turnNames[Edge_1.EdgeDirection.TurnLeft] = "TurnLeft";
31984 this._turnNames[Edge_1.EdgeDirection.TurnRight] = "TurnRight";
31985 this._turnNames[Edge_1.EdgeDirection.TurnU] = "TurnAround";
31986 // detects IE 8-11, then Edge 20+.
31987 var isIE = !!document.documentMode;
31988 this._isEdge = !isIE && !!window.StyleMedia;
31990 Object.defineProperty(DirectionDOMRenderer.prototype, "needsRender", {
31992 * Get needs render.
31994 * @returns {boolean} Value indicating whether render should be called.
31997 return this._needsRender;
32003 * Renders virtual DOM elements.
32005 * @description Calling render resets the needs render property.
32007 DirectionDOMRenderer.prototype.render = function (navigator) {
32008 this._needsRender = false;
32009 var rotation = this._rotation;
32012 if (this._node.pano) {
32013 steps = steps.concat(this._createPanoArrows(navigator, rotation));
32016 steps = steps.concat(this._createPerspectiveToPanoArrows(navigator, rotation));
32017 steps = steps.concat(this._createStepArrows(navigator, rotation));
32018 turns = turns.concat(this._createTurnArrows(navigator));
32020 return this._getContainer(steps, turns, rotation);
32022 DirectionDOMRenderer.prototype.setEdges = function (edgeStatus, sequence) {
32023 this._setEdges(edgeStatus, sequence);
32024 this._setNeedsRender();
32027 * Set node for which to show edges.
32029 * @param {Node} node
32031 DirectionDOMRenderer.prototype.setNode = function (node) {
32033 this._clearEdges();
32034 this._setNeedsRender();
32037 * Set the render camera to use for calculating rotations.
32039 * @param {RenderCamera} renderCamera
32041 DirectionDOMRenderer.prototype.setRenderCamera = function (renderCamera) {
32042 var rotation = renderCamera.rotation;
32043 if (Math.abs(rotation.phi - this._rotation.phi) < this._epsilon) {
32046 this._rotation = rotation;
32047 this._setNeedsRender();
32050 * Set configuration values.
32052 * @param {IDirectionConfiguration} configuration
32054 DirectionDOMRenderer.prototype.setConfiguration = function (configuration) {
32055 var needsRender = false;
32056 if (this._highlightKey !== configuration.highlightKey ||
32057 this._distinguishSequence !== configuration.distinguishSequence) {
32058 this._highlightKey = configuration.highlightKey;
32059 this._distinguishSequence = configuration.distinguishSequence;
32060 needsRender = true;
32062 if (this._calculator.minWidth !== configuration.minWidth ||
32063 this._calculator.maxWidth !== configuration.maxWidth) {
32064 this._calculator.configure(configuration);
32065 needsRender = true;
32068 this._setNeedsRender();
32072 * Detect the element's width and height and resize
32073 * elements accordingly.
32075 * @param {ISize} size Size of vßiewer container element.
32077 DirectionDOMRenderer.prototype.resize = function (size) {
32078 this._calculator.resize(size);
32079 this._setNeedsRender();
32081 DirectionDOMRenderer.prototype._setNeedsRender = function () {
32082 if (this._node != null) {
32083 this._needsRender = true;
32086 DirectionDOMRenderer.prototype._clearEdges = function () {
32087 this._stepEdges = [];
32088 this._turnEdges = [];
32089 this._panoEdges = [];
32090 this._sequenceEdgeKeys = [];
32092 DirectionDOMRenderer.prototype._setEdges = function (edgeStatus, sequence) {
32093 this._stepEdges = [];
32094 this._turnEdges = [];
32095 this._panoEdges = [];
32096 this._sequenceEdgeKeys = [];
32097 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
32099 var direction = edge.data.direction;
32100 if (this._stepDirections.indexOf(direction) > -1) {
32101 this._stepEdges.push(edge);
32104 if (this._turnDirections.indexOf(direction) > -1) {
32105 this._turnEdges.push(edge);
32108 if (edge.data.direction === Edge_1.EdgeDirection.Pano) {
32109 this._panoEdges.push(edge);
32112 if (this._distinguishSequence && sequence != null) {
32113 var edges = this._panoEdges
32114 .concat(this._stepEdges)
32115 .concat(this._turnEdges);
32116 for (var _b = 0, edges_1 = edges; _b < edges_1.length; _b++) {
32117 var edge = edges_1[_b];
32118 var edgeKey = edge.to;
32119 for (var _c = 0, _d = sequence.keys; _c < _d.length; _c++) {
32120 var sequenceKey = _d[_c];
32121 if (sequenceKey === edgeKey) {
32122 this._sequenceEdgeKeys.push(edgeKey);
32129 DirectionDOMRenderer.prototype._createPanoArrows = function (navigator, rotation) {
32131 for (var _i = 0, _a = this._panoEdges; _i < _a.length; _i++) {
32132 var panoEdge = _a[_i];
32133 arrows.push(this._createVNodeByKey(navigator, panoEdge.to, panoEdge.data.worldMotionAzimuth, rotation, this._calculator.outerRadius, "DirectionsArrowPano"));
32135 for (var _b = 0, _c = this._stepEdges; _b < _c.length; _b++) {
32136 var stepEdge = _c[_b];
32137 arrows.push(this._createPanoToPerspectiveArrow(navigator, stepEdge.to, stepEdge.data.worldMotionAzimuth, rotation, stepEdge.data.direction));
32141 DirectionDOMRenderer.prototype._createPanoToPerspectiveArrow = function (navigator, key, azimuth, rotation, direction) {
32142 var threshold = Math.PI / 8;
32143 var relativePhi = rotation.phi;
32144 switch (direction) {
32145 case Edge_1.EdgeDirection.StepBackward:
32146 relativePhi = rotation.phi - Math.PI;
32148 case Edge_1.EdgeDirection.StepLeft:
32149 relativePhi = rotation.phi + Math.PI / 2;
32151 case Edge_1.EdgeDirection.StepRight:
32152 relativePhi = rotation.phi - Math.PI / 2;
32157 if (Math.abs(this._spatial.wrapAngle(azimuth - relativePhi)) < threshold) {
32158 return this._createVNodeByKey(navigator, key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowStep");
32160 return this._createVNodeDisabled(key, azimuth, rotation);
32162 DirectionDOMRenderer.prototype._createPerspectiveToPanoArrows = function (navigator, rotation) {
32164 for (var _i = 0, _a = this._panoEdges; _i < _a.length; _i++) {
32165 var panoEdge = _a[_i];
32166 arrows.push(this._createVNodeByKey(navigator, panoEdge.to, panoEdge.data.worldMotionAzimuth, rotation, this._calculator.innerRadius, "DirectionsArrowPano", true));
32170 DirectionDOMRenderer.prototype._createStepArrows = function (navigator, rotation) {
32172 for (var _i = 0, _a = this._stepEdges; _i < _a.length; _i++) {
32173 var stepEdge = _a[_i];
32174 arrows.push(this._createVNodeByDirection(navigator, stepEdge.to, stepEdge.data.worldMotionAzimuth, rotation, stepEdge.data.direction));
32178 DirectionDOMRenderer.prototype._createTurnArrows = function (navigator) {
32180 for (var _i = 0, _a = this._turnEdges; _i < _a.length; _i++) {
32181 var turnEdge = _a[_i];
32182 var direction = turnEdge.data.direction;
32183 var name_1 = this._turnNames[direction];
32184 turns.push(this._createVNodeByTurn(navigator, turnEdge.to, name_1, direction));
32188 DirectionDOMRenderer.prototype._createVNodeByKey = function (navigator, key, azimuth, rotation, offset, className, shiftVertically) {
32189 var onClick = function (e) {
32190 navigator.moveToKey$(key)
32191 .subscribe(undefined, function (error) {
32192 if (!(error instanceof Error_1.AbortMapillaryError)) {
32193 console.error(error);
32197 return this._createVNode(key, azimuth, rotation, offset, className, "DirectionsCircle", onClick, shiftVertically);
32199 DirectionDOMRenderer.prototype._createVNodeByDirection = function (navigator, key, azimuth, rotation, direction) {
32200 var onClick = function (e) {
32201 navigator.moveDir$(direction)
32202 .subscribe(undefined, function (error) {
32203 if (!(error instanceof Error_1.AbortMapillaryError)) {
32204 console.error(error);
32208 return this._createVNode(key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowStep", "DirectionsCircle", onClick);
32210 DirectionDOMRenderer.prototype._createVNodeByTurn = function (navigator, key, className, direction) {
32211 var onClick = function (e) {
32212 navigator.moveDir$(direction)
32213 .subscribe(undefined, function (error) {
32214 if (!(error instanceof Error_1.AbortMapillaryError)) {
32215 console.error(error);
32220 height: this._calculator.turnCircleSizeCss,
32221 transform: "rotate(0)",
32222 width: this._calculator.turnCircleSizeCss,
32224 switch (direction) {
32225 case Edge_1.EdgeDirection.TurnLeft:
32226 style.left = "5px";
32229 case Edge_1.EdgeDirection.TurnRight:
32230 style.right = "5px";
32233 case Edge_1.EdgeDirection.TurnU:
32234 style.left = "5px";
32235 style.bottom = "5px";
32240 var circleProperties = {
32247 var circleClassName = "TurnCircle";
32248 if (this._sequenceEdgeKeys.indexOf(key) > -1) {
32249 circleClassName += "Sequence";
32251 if (this._highlightKey === key) {
32252 circleClassName += "Highlight";
32254 var turn = vd.h("div." + className, {}, []);
32255 return vd.h("div." + circleClassName, circleProperties, [turn]);
32257 DirectionDOMRenderer.prototype._createVNodeDisabled = function (key, azimuth, rotation) {
32258 return this._createVNode(key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowDisabled", "DirectionsCircleDisabled");
32260 DirectionDOMRenderer.prototype._createVNode = function (key, azimuth, rotation, radius, className, circleClassName, onClick, shiftVertically) {
32261 var translation = this._calculator.angleToCoordinates(azimuth - rotation.phi);
32262 // rotate 90 degrees clockwise and flip over X-axis
32263 var translationX = Math.round(-radius * translation[1] + 0.5 * this._calculator.containerWidth);
32264 var translationY = Math.round(-radius * translation[0] + 0.5 * this._calculator.containerHeight);
32265 var shadowTranslation = this._calculator.relativeAngleToCoordiantes(azimuth, rotation.phi);
32266 var shadowOffset = this._calculator.shadowOffset;
32267 var shadowTranslationX = -shadowOffset * shadowTranslation[1];
32268 var shadowTranslationY = shadowOffset * shadowTranslation[0];
32269 var filter = "drop-shadow(" + shadowTranslationX + "px " + shadowTranslationY + "px 1px rgba(0,0,0,0.8))";
32272 "-webkit-filter": filter,
32276 var chevron = vd.h("div." + className, properties, []);
32277 var azimuthDeg = -this._spatial.radToDeg(azimuth - rotation.phi);
32278 var circleTransform = shiftVertically ?
32279 "translate(" + translationX + "px, " + translationY + "px) rotate(" + azimuthDeg + "deg) translateZ(-0.01px)" :
32280 "translate(" + translationX + "px, " + translationY + "px) rotate(" + azimuthDeg + "deg)";
32281 var circleProperties = {
32282 attributes: { "data-key": key },
32285 height: this._calculator.stepCircleSizeCss,
32286 marginLeft: this._calculator.stepCircleMarginCss,
32287 marginTop: this._calculator.stepCircleMarginCss,
32288 transform: circleTransform,
32289 width: this._calculator.stepCircleSizeCss,
32292 if (this._sequenceEdgeKeys.indexOf(key) > -1) {
32293 circleClassName += "Sequence";
32295 if (this._highlightKey === key) {
32296 circleClassName += "Highlight";
32298 return vd.h("div." + circleClassName, circleProperties, [chevron]);
32300 DirectionDOMRenderer.prototype._getContainer = function (steps, turns, rotation) {
32301 // edge does not handle hover on perspective transforms.
32302 var transform = this._isEdge ?
32304 "perspective(" + this._calculator.containerWidthCss + ") rotateX(60deg)";
32306 oncontextmenu: function (event) { event.preventDefault(); },
32308 bottom: this._calculator.containerBottomCss,
32309 height: this._calculator.containerHeightCss,
32310 left: this._calculator.containerLeftCss,
32311 marginLeft: this._calculator.containerMarginCss,
32312 transform: transform,
32313 width: this._calculator.containerWidthCss,
32316 return vd.h("div.DirectionsPerspective", properties, turns.concat(steps));
32318 return DirectionDOMRenderer;
32320 exports.DirectionDOMRenderer = DirectionDOMRenderer;
32321 exports.default = DirectionDOMRenderer;
32324 },{"../../Component":291,"../../Edge":292,"../../Error":293,"../../Geo":294,"virtual-dom":247}],322:[function(require,module,exports){
32326 var __extends = (this && this.__extends) || (function () {
32327 var extendStatics = function (d, b) {
32328 extendStatics = Object.setPrototypeOf ||
32329 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32330 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32331 return extendStatics(d, b);
32333 return function (d, b) {
32334 extendStatics(d, b);
32335 function __() { this.constructor = d; }
32336 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32339 Object.defineProperty(exports, "__esModule", { value: true });
32340 exports.ImagePlaneComponent = void 0;
32341 var rxjs_1 = require("rxjs");
32342 var operators_1 = require("rxjs/operators");
32343 var Component_1 = require("../../Component");
32344 var Viewer_1 = require("../../Viewer");
32345 var Render_1 = require("../../Render");
32346 var Tiles_1 = require("../../Tiles");
32347 var Utils_1 = require("../../Utils");
32348 var ViewportCoords_1 = require("../../geo/ViewportCoords");
32349 var Spatial_1 = require("../../geo/Spatial");
32350 var ImagePlaneComponent = /** @class */ (function (_super) {
32351 __extends(ImagePlaneComponent, _super);
32352 function ImagePlaneComponent(name, container, navigator) {
32353 var _this = _super.call(this, name, container, navigator) || this;
32354 _this._imageTileLoader = new Tiles_1.ImageTileLoader(Utils_1.Urls.tileScheme, Utils_1.Urls.tileDomain, Utils_1.Urls.origin);
32355 _this._roiCalculator = new Tiles_1.RegionOfInterestCalculator();
32356 _this._rendererOperation$ = new rxjs_1.Subject();
32357 _this._rendererCreator$ = new rxjs_1.Subject();
32358 _this._rendererDisposer$ = new rxjs_1.Subject();
32359 _this._renderer$ = _this._rendererOperation$.pipe(operators_1.scan(function (renderer, operation) {
32360 return operation(renderer);
32361 }, null), operators_1.filter(function (renderer) {
32362 return renderer != null;
32363 }), operators_1.distinctUntilChanged(undefined, function (renderer) {
32364 return renderer.frameId;
32366 _this._rendererCreator$.pipe(operators_1.map(function () {
32367 return function (renderer) {
32368 if (renderer != null) {
32369 throw new Error("Multiple image plane states can not be created at the same time");
32371 return new Component_1.ImagePlaneGLRenderer();
32374 .subscribe(_this._rendererOperation$);
32375 _this._rendererDisposer$.pipe(operators_1.map(function () {
32376 return function (renderer) {
32377 renderer.dispose();
32381 .subscribe(_this._rendererOperation$);
32384 ImagePlaneComponent.prototype._activate = function () {
32386 this._rendererSubscription = this._renderer$.pipe(operators_1.map(function (renderer) {
32390 frameId: renderer.frameId,
32391 needsRender: renderer.needsRender,
32392 render: renderer.render.bind(renderer),
32393 stage: Render_1.GLRenderStage.Background,
32396 renderer.clearNeedsRender();
32399 .subscribe(this._container.glRenderer.render$);
32400 this._rendererCreator$.next(null);
32401 this._stateSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
32402 return function (renderer) {
32403 renderer.updateFrame(frame);
32407 .subscribe(this._rendererOperation$);
32408 var textureProvider$ = this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
32409 return frame.state.currentNode.key;
32410 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
32411 var frame = _a[0], renderer = _a[1], size = _a[2];
32412 var state = frame.state;
32413 var viewportSize = Math.max(size.width, size.height);
32414 var currentNode = state.currentNode;
32415 var currentTransform = state.currentTransform;
32416 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
32417 return new Tiles_1.TextureProvider(currentNode.key, currentTransform.basicWidth, currentTransform.basicHeight, tileSize, currentNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
32418 }), operators_1.publishReplay(1), operators_1.refCount());
32419 this._textureProviderSubscription = textureProvider$.subscribe(function () { });
32420 this._setTextureProviderSubscription = textureProvider$.pipe(operators_1.map(function (provider) {
32421 return function (renderer) {
32422 renderer.setTextureProvider(provider.key, provider);
32426 .subscribe(this._rendererOperation$);
32427 this._setTileSizeSubscription = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
32428 return rxjs_1.combineLatest(textureProvider$, rxjs_1.of(size)).pipe(operators_1.first());
32430 .subscribe(function (_a) {
32431 var provider = _a[0], size = _a[1];
32432 var viewportSize = Math.max(size.width, size.height);
32433 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
32434 provider.setTileSize(tileSize);
32436 this._abortTextureProviderSubscription = textureProvider$.pipe(operators_1.pairwise())
32437 .subscribe(function (pair) {
32438 var previous = pair[0];
32441 var roiTrigger$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
32442 var camera = _a[0], size = _a[1];
32444 camera.camera.position.clone(),
32445 camera.camera.lookat.clone(),
32446 camera.zoom.valueOf(),
32447 size.height.valueOf(),
32448 size.width.valueOf()
32450 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
32451 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
32452 }), operators_1.map(function (pls) {
32453 var samePosition = pls[0][0].equals(pls[1][0]);
32454 var sameLookat = pls[0][1].equals(pls[1][1]);
32455 var sameZoom = pls[0][2] === pls[1][2];
32456 var sameHeight = pls[0][3] === pls[1][3];
32457 var sameWidth = pls[0][4] === pls[1][4];
32458 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
32459 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
32461 }), operators_1.switchMap(function (stalled) {
32462 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
32463 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
32464 this._setRegionOfInterestSubscription = textureProvider$.pipe(operators_1.switchMap(function (provider) {
32465 return roiTrigger$.pipe(operators_1.map(function (_a) {
32466 var camera = _a[0], size = _a[1], transform = _a[2];
32467 var basic = new ViewportCoords_1.default().viewportToBasic(0, 0, transform, camera.perspective);
32468 if (basic[0] < 0 || basic[1] < 0 || basic[0] > 1 || basic[1] > 1) {
32472 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
32475 }), operators_1.filter(function (args) {
32478 }), operators_1.filter(function (args) {
32479 return !args[1].disposed;
32481 .subscribe(function (args) {
32483 var provider = args[1];
32484 provider.setRegionOfInterest(roi);
32486 var hasTexture$ = textureProvider$.pipe(operators_1.switchMap(function (provider) {
32487 return provider.hasTexture$;
32488 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
32489 this._hasTextureSubscription = hasTexture$.subscribe(function () { });
32490 var nodeImage$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
32491 return frame.state.nodesAhead === 0;
32492 }), operators_1.map(function (frame) {
32493 return frame.state.currentNode;
32494 }), operators_1.distinctUntilChanged(undefined, function (node) {
32496 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexture$), operators_1.filter(function (args) {
32498 }), operators_1.map(function (args) {
32500 }), operators_1.filter(function (node) {
32502 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
32503 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
32504 }), operators_1.switchMap(function (node) {
32505 var baseImageSize = node.pano ?
32506 Utils_1.Settings.basePanoramaSize :
32507 Utils_1.Settings.baseImageSize;
32508 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
32509 return rxjs_1.empty();
32512 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
32513 return [n.image, n];
32515 return image$.pipe(operators_1.takeUntil(hasTexture$.pipe(operators_1.filter(function (hasTexture) {
32517 }))), operators_1.catchError(function (error, caught) {
32518 console.error("Failed to fetch high res image (" + node.key + ")", error);
32519 return rxjs_1.empty();
32521 })).pipe(operators_1.publish(), operators_1.refCount());
32522 this._updateBackgroundSubscription = nodeImage$.pipe(operators_1.withLatestFrom(textureProvider$))
32523 .subscribe(function (args) {
32524 if (args[0][1].key !== args[1].key ||
32525 args[1].disposed) {
32528 args[1].updateBackground(args[0][0]);
32530 this._updateTextureImageSubscription = nodeImage$.pipe(operators_1.map(function (imn) {
32531 return function (renderer) {
32532 renderer.updateTextureImage(imn[0], imn[1]);
32536 .subscribe(this._rendererOperation$);
32537 this._clearPeripheryPlaneSubscription = this._navigator.panService.panNodes$.pipe(operators_1.filter(function (panNodes) {
32538 return panNodes.length === 0;
32539 }), operators_1.map(function () {
32540 return function (renderer) {
32541 renderer.clearPeripheryPlanes();
32545 .subscribe(this._rendererOperation$);
32546 var cachedPanNodes$ = this._navigator.panService.panNodes$.pipe(operators_1.switchMap(function (nts) {
32547 return rxjs_1.from(nts).pipe(operators_1.mergeMap(function (_a) {
32548 var n = _a[0], t = _a[1];
32549 return rxjs_1.combineLatest(_this._navigator.graphService.cacheNode$(n.key).pipe(operators_1.catchError(function (error) {
32550 console.error("Failed to cache periphery node (" + n.key + ")", error);
32551 return rxjs_1.empty();
32552 })), rxjs_1.of(t));
32554 }), operators_1.share());
32555 this._addPeripheryPlaneSubscription = cachedPanNodes$.pipe(operators_1.map(function (_a) {
32556 var n = _a[0], t = _a[1];
32557 return function (renderer) {
32558 renderer.addPeripheryPlane(n, t);
32562 .subscribe(this._rendererOperation$);
32563 this._updatePeripheryPlaneTextureSubscription = cachedPanNodes$.pipe(operators_1.mergeMap(function (_a) {
32565 return Viewer_1.ImageSize.Size2048 > Math.max(n.image.width, n.image.height) ?
32566 n.cacheImage$(Viewer_1.ImageSize.Size2048).pipe(operators_1.catchError(function () {
32567 return rxjs_1.empty();
32570 }), operators_1.map(function (n) {
32571 return function (renderer) {
32572 renderer.updateTextureImage(n.image, n);
32576 .subscribe(this._rendererOperation$);
32577 var inTransition$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
32578 return frame.state.alpha < 1;
32579 }), operators_1.distinctUntilChanged());
32580 var panTrigger$ = rxjs_1.combineLatest(this._container.mouseService.active$, this._container.touchService.active$, this._navigator.stateService.inMotion$, inTransition$).pipe(operators_1.map(function (_a) {
32581 var mouseActive = _a[0], touchActive = _a[1], inMotion = _a[2], inTransition = _a[3];
32582 return !(mouseActive || touchActive || inMotion || inTransition);
32583 }), operators_1.filter(function (trigger) {
32586 this._moveToPeripheryNodeSubscription = this._navigator.panService.panNodes$.pipe(operators_1.switchMap(function (nts) {
32587 return panTrigger$.pipe(operators_1.withLatestFrom(_this._container.renderService.renderCamera$, _this._navigator.stateService.currentNode$, _this._navigator.stateService.currentTransform$), operators_1.mergeMap(function (_a) {
32588 var renderCamera = _a[1], currentNode = _a[2], currentTransform = _a[3];
32596 }), operators_1.switchMap(function (_a) {
32597 var camera = _a[0], cn = _a[1], ct = _a[2], nts = _a[3];
32598 var direction = camera.camera.lookat.clone().sub(camera.camera.position);
32599 var cd = new Spatial_1.default().viewingDirection(cn.rotation);
32600 var ca = cd.angleTo(direction);
32601 var closest = [ca, undefined];
32602 var basic = new ViewportCoords_1.default().viewportToBasic(0, 0, ct, camera.perspective);
32603 if (basic[0] >= 0 && basic[0] <= 1 && basic[1] >= 0 && basic[1] <= 1) {
32604 closest[0] = Number.NEGATIVE_INFINITY;
32606 for (var _i = 0, nts_1 = nts; _i < nts_1.length; _i++) {
32607 var n = nts_1[_i][0];
32608 var d = new Spatial_1.default().viewingDirection(n.rotation);
32609 var a = d.angleTo(direction);
32610 if (a < closest[0]) {
32612 closest[1] = n.key;
32616 return rxjs_1.empty();
32618 return _this._navigator.moveToKey$(closest[1]).pipe(operators_1.catchError(function () {
32619 return rxjs_1.empty();
32624 ImagePlaneComponent.prototype._deactivate = function () {
32625 this._rendererDisposer$.next(null);
32626 this._abortTextureProviderSubscription.unsubscribe();
32627 this._hasTextureSubscription.unsubscribe();
32628 this._rendererSubscription.unsubscribe();
32629 this._setRegionOfInterestSubscription.unsubscribe();
32630 this._setTextureProviderSubscription.unsubscribe();
32631 this._setTileSizeSubscription.unsubscribe();
32632 this._stateSubscription.unsubscribe();
32633 this._textureProviderSubscription.unsubscribe();
32634 this._updateBackgroundSubscription.unsubscribe();
32635 this._updateTextureImageSubscription.unsubscribe();
32636 this._clearPeripheryPlaneSubscription.unsubscribe();
32637 this._addPeripheryPlaneSubscription.unsubscribe();
32638 this._updatePeripheryPlaneTextureSubscription.unsubscribe();
32639 this._moveToPeripheryNodeSubscription.unsubscribe();
32641 ImagePlaneComponent.prototype._getDefaultConfiguration = function () {
32644 ImagePlaneComponent.componentName = "imagePlane";
32645 return ImagePlaneComponent;
32646 }(Component_1.Component));
32647 exports.ImagePlaneComponent = ImagePlaneComponent;
32648 Component_1.ComponentService.register(ImagePlaneComponent);
32649 exports.default = ImagePlaneComponent;
32651 },{"../../Component":291,"../../Render":297,"../../Tiles":300,"../../Utils":301,"../../Viewer":302,"../../geo/Spatial":419,"../../geo/ViewportCoords":421,"rxjs":43,"rxjs/operators":241}],323:[function(require,module,exports){
32653 Object.defineProperty(exports, "__esModule", { value: true });
32654 exports.ImagePlaneGLRenderer = void 0;
32655 var Component_1 = require("../../Component");
32656 var ImagePlaneGLRenderer = /** @class */ (function () {
32657 function ImagePlaneGLRenderer() {
32658 this._factory = new Component_1.MeshFactory();
32659 this._scene = new Component_1.MeshScene();
32661 this._alphaOld = 0;
32662 this._fadeOutSpeed = 0.05;
32663 this._currentKey = null;
32664 this._previousKey = null;
32665 this._providerDisposers = {};
32667 this._needsRender = false;
32669 Object.defineProperty(ImagePlaneGLRenderer.prototype, "frameId", {
32671 return this._frameId;
32676 Object.defineProperty(ImagePlaneGLRenderer.prototype, "needsRender", {
32678 return this._needsRender;
32683 ImagePlaneGLRenderer.prototype.indicateNeedsRender = function () {
32684 this._needsRender = true;
32686 ImagePlaneGLRenderer.prototype.addPeripheryPlane = function (node, transform) {
32687 var mesh = this._factory.createMesh(node, transform);
32689 planes[node.key] = mesh;
32690 this._scene.addPeripheryPlanes(planes);
32691 this._needsRender = true;
32693 ImagePlaneGLRenderer.prototype.clearPeripheryPlanes = function () {
32694 this._scene.setPeripheryPlanes({});
32695 this._needsRender = true;
32697 ImagePlaneGLRenderer.prototype.updateFrame = function (frame) {
32698 this._updateFrameId(frame.id);
32699 this._needsRender = this._updateAlpha(frame.state.alpha) || this._needsRender;
32700 this._needsRender = this._updateAlphaOld(frame.state.alpha) || this._needsRender;
32701 this._needsRender = this._updateImagePlanes(frame.state) || this._needsRender;
32703 ImagePlaneGLRenderer.prototype.setTextureProvider = function (key, provider) {
32705 if (key !== this._currentKey) {
32708 var createdSubscription = provider.textureCreated$
32709 .subscribe(function (texture) {
32710 _this._updateTexture(texture);
32712 var updatedSubscription = provider.textureUpdated$
32713 .subscribe(function (updated) {
32714 _this._needsRender = true;
32716 var dispose = function () {
32717 createdSubscription.unsubscribe();
32718 updatedSubscription.unsubscribe();
32719 provider.dispose();
32721 if (key in this._providerDisposers) {
32722 var disposeProvider = this._providerDisposers[key];
32724 delete this._providerDisposers[key];
32726 this._providerDisposers[key] = dispose;
32728 ImagePlaneGLRenderer.prototype.updateTextureImage = function (image, node) {
32729 this._needsRender = true;
32730 var planes = this._extend({}, this._scene.planes, this._scene.planesOld, this._scene.planesPeriphery);
32731 for (var key in planes) {
32732 if (!planes.hasOwnProperty(key)) {
32735 if (key !== node.key) {
32738 var plane = planes[key];
32739 var material = plane.material;
32740 var texture = material.uniforms.projectorTex.value;
32741 texture.image = image;
32742 texture.needsUpdate = true;
32745 ImagePlaneGLRenderer.prototype.render = function (perspectiveCamera, renderer) {
32746 var planes = this._scene.planes;
32747 var planesOld = this._scene.planesOld;
32748 var planesPeriphery = this._scene.planesPeriphery;
32749 var planeAlpha = Object.keys(planesOld).length ? 1 : this._alpha;
32750 var peripheryAlpha = Object.keys(planesOld).length ? 1 : Math.floor(this._alpha);
32751 for (var key in planes) {
32752 if (!planes.hasOwnProperty(key)) {
32755 var plane = planes[key];
32756 plane.material.uniforms.opacity.value = planeAlpha;
32758 for (var key in planesOld) {
32759 if (!planesOld.hasOwnProperty(key)) {
32762 var plane = planesOld[key];
32763 plane.material.uniforms.opacity.value = this._alphaOld;
32765 for (var key in planesPeriphery) {
32766 if (!planesPeriphery.hasOwnProperty(key)) {
32769 var plane = planesPeriphery[key];
32770 plane.material.uniforms.opacity.value = peripheryAlpha;
32772 renderer.render(this._scene.scenePeriphery, perspectiveCamera);
32773 renderer.render(this._scene.scene, perspectiveCamera);
32774 renderer.render(this._scene.sceneOld, perspectiveCamera);
32775 for (var key in planes) {
32776 if (!planes.hasOwnProperty(key)) {
32779 var plane = planes[key];
32780 plane.material.uniforms.opacity.value = this._alpha;
32782 renderer.render(this._scene.scene, perspectiveCamera);
32784 ImagePlaneGLRenderer.prototype.clearNeedsRender = function () {
32785 this._needsRender = false;
32787 ImagePlaneGLRenderer.prototype.dispose = function () {
32788 this._scene.clear();
32790 ImagePlaneGLRenderer.prototype._updateFrameId = function (frameId) {
32791 this._frameId = frameId;
32793 ImagePlaneGLRenderer.prototype._updateAlpha = function (alpha) {
32794 if (alpha === this._alpha) {
32797 this._alpha = alpha;
32800 ImagePlaneGLRenderer.prototype._updateAlphaOld = function (alpha) {
32801 if (alpha < 1 || this._alphaOld === 0) {
32804 this._alphaOld = Math.max(0, this._alphaOld - this._fadeOutSpeed);
32807 ImagePlaneGLRenderer.prototype._updateImagePlanes = function (state) {
32808 if (state.currentNode == null || state.currentNode.key === this._currentKey) {
32811 var previousKey = state.previousNode != null ? state.previousNode.key : null;
32812 var currentKey = state.currentNode.key;
32813 if (this._previousKey !== previousKey &&
32814 this._previousKey !== currentKey &&
32815 this._previousKey in this._providerDisposers) {
32816 var disposeProvider = this._providerDisposers[this._previousKey];
32818 delete this._providerDisposers[this._previousKey];
32820 if (previousKey != null) {
32821 if (previousKey !== this._currentKey && previousKey !== this._previousKey) {
32822 var previousMesh = this._factory.createMesh(state.previousNode, state.previousTransform);
32823 var previousPlanes = {};
32824 previousPlanes[previousKey] = previousMesh;
32825 this._scene.updateImagePlanes(previousPlanes);
32827 this._previousKey = previousKey;
32829 this._currentKey = currentKey;
32830 var currentMesh = this._factory.createMesh(state.currentNode, state.currentTransform);
32832 planes[currentKey] = currentMesh;
32833 this._scene.updateImagePlanes(planes);
32834 this._alphaOld = 1;
32837 ImagePlaneGLRenderer.prototype._updateTexture = function (texture) {
32838 this._needsRender = true;
32839 var planes = this._scene.planes;
32840 for (var key in planes) {
32841 if (!planes.hasOwnProperty(key)) {
32844 var plane = planes[key];
32845 var material = plane.material;
32846 var oldTexture = material.uniforms.projectorTex.value;
32847 material.uniforms.projectorTex.value = null;
32848 oldTexture.dispose();
32849 material.uniforms.projectorTex.value = texture;
32852 ImagePlaneGLRenderer.prototype._extend = function (dest) {
32854 for (var _i = 1; _i < arguments.length; _i++) {
32855 sources[_i - 1] = arguments[_i];
32857 for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
32858 var src = sources_1[_a];
32859 for (var k in src) {
32860 if (!src.hasOwnProperty(k)) {
32868 return ImagePlaneGLRenderer;
32870 exports.ImagePlaneGLRenderer = ImagePlaneGLRenderer;
32871 exports.default = ImagePlaneGLRenderer;
32873 },{"../../Component":291}],324:[function(require,module,exports){
32875 Object.defineProperty(exports, "__esModule", { value: true });
32877 },{}],325:[function(require,module,exports){
32879 Object.defineProperty(exports, "__esModule", { value: true });
32880 exports.CoverState = void 0;
32882 (function (CoverState) {
32883 CoverState[CoverState["Hidden"] = 0] = "Hidden";
32884 CoverState[CoverState["Loading"] = 1] = "Loading";
32885 CoverState[CoverState["Visible"] = 2] = "Visible";
32886 })(CoverState = exports.CoverState || (exports.CoverState = {}));
32888 },{}],326:[function(require,module,exports){
32890 Object.defineProperty(exports, "__esModule", { value: true });
32891 exports.SliderMode = void 0;
32893 * Enumeration for slider mode.
32898 * @description Modes for specifying how transitions
32899 * between nodes are performed in slider mode. Only
32900 * applicable when the slider component determines
32901 * that transitions with motion is possilble. When it
32902 * is not, the stationary mode will be applied.
32905 (function (SliderMode) {
32907 * Transitions with motion.
32909 * @description The slider component moves the
32910 * camera between the node origins.
32912 * In this mode it is not possible to zoom or pan.
32914 * The slider component falls back to stationary
32915 * mode when it determines that the pair of nodes
32916 * does not have a strong enough relation.
32918 SliderMode[SliderMode["Motion"] = 0] = "Motion";
32920 * Stationary transitions.
32922 * @description The camera is stationary.
32924 * In this mode it is possible to zoom and pan.
32926 SliderMode[SliderMode["Stationary"] = 1] = "Stationary";
32927 })(SliderMode = exports.SliderMode || (exports.SliderMode = {}));
32929 },{}],327:[function(require,module,exports){
32931 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
32932 if (k2 === undefined) k2 = k;
32933 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
32934 }) : (function(o, m, k, k2) {
32935 if (k2 === undefined) k2 = k;
32938 var __exportStar = (this && this.__exportStar) || function(m, exports) {
32939 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
32941 Object.defineProperty(exports, "__esModule", { value: true });
32942 var ICoverConfiguration_1 = require("./ICoverConfiguration");
32943 Object.defineProperty(exports, "CoverState", { enumerable: true, get: function () { return ICoverConfiguration_1.CoverState; } });
32944 var ISliderConfiguration_1 = require("./ISliderConfiguration");
32945 Object.defineProperty(exports, "SliderMode", { enumerable: true, get: function () { return ISliderConfiguration_1.SliderMode; } });
32946 __exportStar(require("../imageplane/interfaces/interfaces"), exports);
32947 __exportStar(require("../marker/interfaces/interfaces"), exports);
32948 __exportStar(require("../spatialdata/interfaces/interfaces"), exports);
32949 __exportStar(require("../tag/interfaces/interfaces"), exports);
32951 },{"../imageplane/interfaces/interfaces":324,"../marker/interfaces/interfaces":337,"../spatialdata/interfaces/interfaces":365,"../tag/interfaces/interfaces":390,"./ICoverConfiguration":325,"./ISliderConfiguration":326}],328:[function(require,module,exports){
32953 var __extends = (this && this.__extends) || (function () {
32954 var extendStatics = function (d, b) {
32955 extendStatics = Object.setPrototypeOf ||
32956 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32957 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32958 return extendStatics(d, b);
32960 return function (d, b) {
32961 extendStatics(d, b);
32962 function __() { this.constructor = d; }
32963 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32966 Object.defineProperty(exports, "__esModule", { value: true });
32967 exports.KeyPlayHandler = void 0;
32968 var operators_1 = require("rxjs/operators");
32969 var Component_1 = require("../../Component");
32970 var Edge_1 = require("../../Edge");
32972 * The `KeyPlayHandler` allows the user to control the play behavior
32973 * using the following key commands:
32975 * `Spacebar`: Start or stop playing.
32976 * `SHIFT` + `D`: Switch direction.
32977 * `<`: Decrease speed.
32978 * `>`: Increase speed.
32982 * var keyboardComponent = viewer.getComponent("keyboard");
32984 * keyboardComponent.keyPlay.disable();
32985 * keyboardComponent.keyPlay.enable();
32987 * var isEnabled = keyboardComponent.keyPlay.isEnabled;
32990 var KeyPlayHandler = /** @class */ (function (_super) {
32991 __extends(KeyPlayHandler, _super);
32992 function KeyPlayHandler() {
32993 return _super !== null && _super.apply(this, arguments) || this;
32995 KeyPlayHandler.prototype._enable = function () {
32997 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) {
32998 return node.sequenceEdges$;
33000 .subscribe(function (_a) {
33001 var event = _a[0], playing = _a[1], direction = _a[2], speed = _a[3], status = _a[4];
33002 if (event.altKey || event.ctrlKey || event.metaKey) {
33005 switch (event.key) {
33007 if (!event.shiftKey) {
33010 var newDirection = playing ?
33011 null : direction === Edge_1.EdgeDirection.Next ?
33012 Edge_1.EdgeDirection.Prev : direction === Edge_1.EdgeDirection.Prev ?
33013 Edge_1.EdgeDirection.Next : null;
33014 if (newDirection != null) {
33015 _this._navigator.playService.setDirection(newDirection);
33019 if (event.shiftKey) {
33023 _this._navigator.playService.stop();
33026 for (var _i = 0, _b = status.edges; _i < _b.length; _i++) {
33028 if (edge.data.direction === direction) {
33029 _this._navigator.playService.play();
33035 _this._navigator.playService.setSpeed(speed - 0.05);
33038 _this._navigator.playService.setSpeed(speed + 0.05);
33043 event.preventDefault();
33046 KeyPlayHandler.prototype._disable = function () {
33047 this._keyDownSubscription.unsubscribe();
33049 KeyPlayHandler.prototype._getConfiguration = function (enable) {
33050 return { keyZoom: enable };
33052 return KeyPlayHandler;
33053 }(Component_1.HandlerBase));
33054 exports.KeyPlayHandler = KeyPlayHandler;
33055 exports.default = KeyPlayHandler;
33057 },{"../../Component":291,"../../Edge":292,"rxjs/operators":241}],329:[function(require,module,exports){
33059 var __extends = (this && this.__extends) || (function () {
33060 var extendStatics = function (d, b) {
33061 extendStatics = Object.setPrototypeOf ||
33062 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33063 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33064 return extendStatics(d, b);
33066 return function (d, b) {
33067 extendStatics(d, b);
33068 function __() { this.constructor = d; }
33069 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33072 Object.defineProperty(exports, "__esModule", { value: true });
33073 exports.KeySequenceNavigationHandler = void 0;
33074 var operators_1 = require("rxjs/operators");
33075 var Component_1 = require("../../Component");
33076 var Edge_1 = require("../../Edge");
33077 var Error_1 = require("../../Error");
33079 * The `KeySequenceNavigationHandler` allows the user to navigate through a sequence using the
33080 * following key commands:
33082 * `ALT` + `Up Arrow`: Navigate to next image in the sequence.
33083 * `ALT` + `Down Arrow`: Navigate to previous image in sequence.
33087 * var keyboardComponent = viewer.getComponent("keyboard");
33089 * keyboardComponent.keySequenceNavigation.disable();
33090 * keyboardComponent.keySequenceNavigation.enable();
33092 * var isEnabled = keyboardComponent.keySequenceNavigation.isEnabled;
33095 var KeySequenceNavigationHandler = /** @class */ (function (_super) {
33096 __extends(KeySequenceNavigationHandler, _super);
33097 function KeySequenceNavigationHandler() {
33098 return _super !== null && _super.apply(this, arguments) || this;
33100 KeySequenceNavigationHandler.prototype._enable = function () {
33102 var sequenceEdges$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
33103 return node.sequenceEdges$;
33105 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(sequenceEdges$))
33106 .subscribe(function (_a) {
33107 var event = _a[0], edgeStatus = _a[1];
33108 var direction = null;
33109 switch (event.keyCode) {
33111 direction = Edge_1.EdgeDirection.Next;
33114 direction = Edge_1.EdgeDirection.Prev;
33119 event.preventDefault();
33120 if (!event.altKey || event.shiftKey || !edgeStatus.cached) {
33123 for (var _i = 0, _b = edgeStatus.edges; _i < _b.length; _i++) {
33125 if (edge.data.direction === direction) {
33126 _this._navigator.moveToKey$(edge.to)
33127 .subscribe(undefined, function (error) {
33128 if (!(error instanceof Error_1.AbortMapillaryError)) {
33129 console.error(error);
33137 KeySequenceNavigationHandler.prototype._disable = function () {
33138 this._keyDownSubscription.unsubscribe();
33140 KeySequenceNavigationHandler.prototype._getConfiguration = function (enable) {
33141 return { keySequenceNavigation: enable };
33143 return KeySequenceNavigationHandler;
33144 }(Component_1.HandlerBase));
33145 exports.KeySequenceNavigationHandler = KeySequenceNavigationHandler;
33146 exports.default = KeySequenceNavigationHandler;
33148 },{"../../Component":291,"../../Edge":292,"../../Error":293,"rxjs/operators":241}],330:[function(require,module,exports){
33150 var __extends = (this && this.__extends) || (function () {
33151 var extendStatics = function (d, b) {
33152 extendStatics = Object.setPrototypeOf ||
33153 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33154 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33155 return extendStatics(d, b);
33157 return function (d, b) {
33158 extendStatics(d, b);
33159 function __() { this.constructor = d; }
33160 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33163 Object.defineProperty(exports, "__esModule", { value: true });
33164 exports.KeySpatialNavigationHandler = void 0;
33165 var operators_1 = require("rxjs/operators");
33166 var Component_1 = require("../../Component");
33167 var Edge_1 = require("../../Edge");
33168 var Error_1 = require("../../Error");
33170 * The `KeySpatialNavigationHandler` allows the user to navigate through a sequence using the
33171 * following key commands:
33173 * `Up Arrow`: Step forward.
33174 * `Down Arrow`: Step backward.
33175 * `Left Arrow`: Step to the left.
33176 * `Rigth Arrow`: Step to the right.
33177 * `SHIFT` + `Down Arrow`: Turn around.
33178 * `SHIFT` + `Left Arrow`: Turn to the left.
33179 * `SHIFT` + `Rigth Arrow`: Turn to the right.
33183 * var keyboardComponent = viewer.getComponent("keyboard");
33185 * keyboardComponent.keySpatialNavigation.disable();
33186 * keyboardComponent.keySpatialNavigation.enable();
33188 * var isEnabled = keyboardComponent.keySpatialNavigation.isEnabled;
33191 var KeySpatialNavigationHandler = /** @class */ (function (_super) {
33192 __extends(KeySpatialNavigationHandler, _super);
33194 function KeySpatialNavigationHandler(component, container, navigator, spatial) {
33195 var _this = _super.call(this, component, container, navigator) || this;
33196 _this._spatial = spatial;
33199 KeySpatialNavigationHandler.prototype._enable = function () {
33201 var spatialEdges$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
33202 return node.spatialEdges$;
33204 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(spatialEdges$, this._navigator.stateService.currentState$))
33205 .subscribe(function (_a) {
33206 var event = _a[0], edgeStatus = _a[1], frame = _a[2];
33207 var pano = frame.state.currentNode.pano;
33208 var direction = null;
33209 switch (event.keyCode) {
33211 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnLeft : Edge_1.EdgeDirection.StepLeft;
33214 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.Pano : Edge_1.EdgeDirection.StepForward;
33217 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnRight : Edge_1.EdgeDirection.StepRight;
33220 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnU : Edge_1.EdgeDirection.StepBackward;
33225 event.preventDefault();
33226 if (event.altKey || !edgeStatus.cached ||
33227 (event.shiftKey && pano)) {
33231 _this._moveDir(direction, edgeStatus);
33235 shifts[Edge_1.EdgeDirection.StepBackward] = Math.PI;
33236 shifts[Edge_1.EdgeDirection.StepForward] = 0;
33237 shifts[Edge_1.EdgeDirection.StepLeft] = Math.PI / 2;
33238 shifts[Edge_1.EdgeDirection.StepRight] = -Math.PI / 2;
33239 var phi = _this._rotationFromCamera(frame.state.camera).phi;
33240 var navigationAngle = _this._spatial.wrapAngle(phi + shifts[direction]);
33241 var threshold = Math.PI / 4;
33242 var edges = edgeStatus.edges.filter(function (e) {
33243 return e.data.direction === Edge_1.EdgeDirection.Pano || e.data.direction === direction;
33245 var smallestAngle = Number.MAX_VALUE;
33247 for (var _i = 0, edges_1 = edges; _i < edges_1.length; _i++) {
33248 var edge = edges_1[_i];
33249 var angle = Math.abs(_this._spatial.wrapAngle(edge.data.worldMotionAzimuth - navigationAngle));
33250 if (angle < Math.min(smallestAngle, threshold)) {
33251 smallestAngle = angle;
33255 if (toKey == null) {
33258 _this._moveToKey(toKey);
33262 KeySpatialNavigationHandler.prototype._disable = function () {
33263 this._keyDownSubscription.unsubscribe();
33265 KeySpatialNavigationHandler.prototype._getConfiguration = function (enable) {
33266 return { keySpatialNavigation: enable };
33268 KeySpatialNavigationHandler.prototype._moveDir = function (direction, edgeStatus) {
33269 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
33271 if (edge.data.direction === direction) {
33272 this._moveToKey(edge.to);
33277 KeySpatialNavigationHandler.prototype._moveToKey = function (key) {
33278 this._navigator.moveToKey$(key)
33279 .subscribe(undefined, function (error) {
33280 if (!(error instanceof Error_1.AbortMapillaryError)) {
33281 console.error(error);
33285 KeySpatialNavigationHandler.prototype._rotationFromCamera = function (camera) {
33286 var direction = camera.lookat.clone().sub(camera.position);
33287 var upProjection = direction.clone().dot(camera.up);
33288 var planeProjection = direction.clone().sub(camera.up.clone().multiplyScalar(upProjection));
33289 var phi = Math.atan2(planeProjection.y, planeProjection.x);
33290 var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
33291 return { phi: phi, theta: theta };
33293 return KeySpatialNavigationHandler;
33294 }(Component_1.HandlerBase));
33295 exports.KeySpatialNavigationHandler = KeySpatialNavigationHandler;
33296 exports.default = KeySpatialNavigationHandler;
33298 },{"../../Component":291,"../../Edge":292,"../../Error":293,"rxjs/operators":241}],331:[function(require,module,exports){
33300 var __extends = (this && this.__extends) || (function () {
33301 var extendStatics = function (d, b) {
33302 extendStatics = Object.setPrototypeOf ||
33303 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33304 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33305 return extendStatics(d, b);
33307 return function (d, b) {
33308 extendStatics(d, b);
33309 function __() { this.constructor = d; }
33310 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33313 Object.defineProperty(exports, "__esModule", { value: true });
33314 exports.KeyZoomHandler = void 0;
33315 var operators_1 = require("rxjs/operators");
33316 var Component_1 = require("../../Component");
33318 * The `KeyZoomHandler` allows the user to zoom in and out using the
33319 * following key commands:
33326 * var keyboardComponent = viewer.getComponent("keyboard");
33328 * keyboardComponent.keyZoom.disable();
33329 * keyboardComponent.keyZoom.enable();
33331 * var isEnabled = keyboardComponent.keyZoom.isEnabled;
33334 var KeyZoomHandler = /** @class */ (function (_super) {
33335 __extends(KeyZoomHandler, _super);
33337 function KeyZoomHandler(component, container, navigator, viewportCoords) {
33338 var _this = _super.call(this, component, container, navigator) || this;
33339 _this._viewportCoords = viewportCoords;
33342 KeyZoomHandler.prototype._enable = function () {
33344 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
33345 .subscribe(function (_a) {
33346 var event = _a[0], render = _a[1], transform = _a[2];
33347 if (event.altKey || event.shiftKey || event.ctrlKey || event.metaKey) {
33351 switch (event.key) {
33361 event.preventDefault();
33362 var unprojected = _this._viewportCoords.unprojectFromViewport(0, 0, render.perspective);
33363 var reference = transform.projectBasic(unprojected.toArray());
33364 _this._navigator.stateService.zoomIn(delta, reference);
33367 KeyZoomHandler.prototype._disable = function () {
33368 this._keyDownSubscription.unsubscribe();
33370 KeyZoomHandler.prototype._getConfiguration = function (enable) {
33371 return { keyZoom: enable };
33373 return KeyZoomHandler;
33374 }(Component_1.HandlerBase));
33375 exports.KeyZoomHandler = KeyZoomHandler;
33376 exports.default = KeyZoomHandler;
33378 },{"../../Component":291,"rxjs/operators":241}],332:[function(require,module,exports){
33380 var __extends = (this && this.__extends) || (function () {
33381 var extendStatics = function (d, b) {
33382 extendStatics = Object.setPrototypeOf ||
33383 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33384 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33385 return extendStatics(d, b);
33387 return function (d, b) {
33388 extendStatics(d, b);
33389 function __() { this.constructor = d; }
33390 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33393 Object.defineProperty(exports, "__esModule", { value: true });
33394 exports.KeyboardComponent = void 0;
33395 var Component_1 = require("../../Component");
33396 var Geo_1 = require("../../Geo");
33398 * @class KeyboardComponent
33400 * @classdesc Component for keyboard event handling.
33402 * To retrive and use the keyboard component
33406 * var viewer = new Mapillary.Viewer(
33411 * var keyboardComponent = viewer.getComponent("keyboard");
33414 var KeyboardComponent = /** @class */ (function (_super) {
33415 __extends(KeyboardComponent, _super);
33417 function KeyboardComponent(name, container, navigator) {
33418 var _this = _super.call(this, name, container, navigator) || this;
33419 _this._keyPlayHandler = new Component_1.KeyPlayHandler(_this, container, navigator);
33420 _this._keySequenceNavigationHandler = new Component_1.KeySequenceNavigationHandler(_this, container, navigator);
33421 _this._keySpatialNavigationHandler = new Component_1.KeySpatialNavigationHandler(_this, container, navigator, new Geo_1.Spatial());
33422 _this._keyZoomHandler = new Component_1.KeyZoomHandler(_this, container, navigator, new Geo_1.ViewportCoords());
33425 Object.defineProperty(KeyboardComponent.prototype, "keyPlay", {
33429 * @returns {KeyPlayHandler} The key play handler.
33432 return this._keyPlayHandler;
33437 Object.defineProperty(KeyboardComponent.prototype, "keySequenceNavigation", {
33439 * Get key sequence navigation.
33441 * @returns {KeySequenceNavigationHandler} The key sequence navigation handler.
33444 return this._keySequenceNavigationHandler;
33449 Object.defineProperty(KeyboardComponent.prototype, "keySpatialNavigation", {
33453 * @returns {KeySpatialNavigationHandler} The spatial handler.
33456 return this._keySpatialNavigationHandler;
33461 Object.defineProperty(KeyboardComponent.prototype, "keyZoom", {
33465 * @returns {KeyZoomHandler} The key zoom handler.
33468 return this._keyZoomHandler;
33473 KeyboardComponent.prototype._activate = function () {
33475 this._configurationSubscription = this._configuration$
33476 .subscribe(function (configuration) {
33477 if (configuration.keyPlay) {
33478 _this._keyPlayHandler.enable();
33481 _this._keyPlayHandler.disable();
33483 if (configuration.keySequenceNavigation) {
33484 _this._keySequenceNavigationHandler.enable();
33487 _this._keySequenceNavigationHandler.disable();
33489 if (configuration.keySpatialNavigation) {
33490 _this._keySpatialNavigationHandler.enable();
33493 _this._keySpatialNavigationHandler.disable();
33495 if (configuration.keyZoom) {
33496 _this._keyZoomHandler.enable();
33499 _this._keyZoomHandler.disable();
33503 KeyboardComponent.prototype._deactivate = function () {
33504 this._configurationSubscription.unsubscribe();
33505 this._keyPlayHandler.disable();
33506 this._keySequenceNavigationHandler.disable();
33507 this._keySpatialNavigationHandler.disable();
33508 this._keyZoomHandler.disable();
33510 KeyboardComponent.prototype._getDefaultConfiguration = function () {
33511 return { keyPlay: true, keySequenceNavigation: true, keySpatialNavigation: true, keyZoom: true };
33513 KeyboardComponent.componentName = "keyboard";
33514 return KeyboardComponent;
33515 }(Component_1.Component));
33516 exports.KeyboardComponent = KeyboardComponent;
33517 Component_1.ComponentService.register(KeyboardComponent);
33518 exports.default = KeyboardComponent;
33520 },{"../../Component":291,"../../Geo":294}],333:[function(require,module,exports){
33522 Object.defineProperty(exports, "__esModule", { value: true });
33523 var MarkerComponent_1 = require("./MarkerComponent");
33524 Object.defineProperty(exports, "MarkerComponent", { enumerable: true, get: function () { return MarkerComponent_1.MarkerComponent; } });
33525 var SimpleMarker_1 = require("./marker/SimpleMarker");
33526 Object.defineProperty(exports, "SimpleMarker", { enumerable: true, get: function () { return SimpleMarker_1.SimpleMarker; } });
33527 var CircleMarker_1 = require("./marker/CircleMarker");
33528 Object.defineProperty(exports, "CircleMarker", { enumerable: true, get: function () { return CircleMarker_1.CircleMarker; } });
33530 },{"./MarkerComponent":334,"./marker/CircleMarker":338,"./marker/SimpleMarker":340}],334:[function(require,module,exports){
33532 var __extends = (this && this.__extends) || (function () {
33533 var extendStatics = function (d, b) {
33534 extendStatics = Object.setPrototypeOf ||
33535 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33536 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33537 return extendStatics(d, b);
33539 return function (d, b) {
33540 extendStatics(d, b);
33541 function __() { this.constructor = d; }
33542 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33545 Object.defineProperty(exports, "__esModule", { value: true });
33546 exports.MarkerComponent = void 0;
33547 var rxjs_1 = require("rxjs");
33548 var operators_1 = require("rxjs/operators");
33549 var THREE = require("three");
33550 var when = require("when");
33551 var Component_1 = require("../../Component");
33552 var Render_1 = require("../../Render");
33553 var Graph_1 = require("../../Graph");
33554 var Geo_1 = require("../../Geo");
33556 * @class MarkerComponent
33558 * @classdesc Component for showing and editing 3D marker objects.
33560 * The `add` method is used for adding new markers or replacing
33561 * markers already in the set.
33563 * If a marker already in the set has the same
33564 * id as one of the markers added, the old marker will be removed and
33565 * the added marker will take its place.
33567 * It is not possible to update markers in the set by updating any properties
33568 * directly on the marker object. Markers need to be replaced by
33569 * re-adding them for updates to geographic position or configuration
33572 * Markers added to the marker component can be either interactive
33573 * or non-interactive. Different marker types define their behavior.
33574 * Markers with interaction support can be configured with options
33575 * to respond to dragging inside the viewer and be detected when
33576 * retrieving markers from pixel points with the `getMarkerIdAt` method.
33578 * To retrive and use the marker component
33582 * var viewer = new Mapillary.Viewer(
33586 * { component: { marker: true } });
33588 * var markerComponent = viewer.getComponent("marker");
33591 var MarkerComponent = /** @class */ (function (_super) {
33592 __extends(MarkerComponent, _super);
33594 function MarkerComponent(name, container, navigator) {
33595 var _this = _super.call(this, name, container, navigator) || this;
33596 _this._relativeGroundAltitude = -2;
33597 _this._geoCoords = new Geo_1.GeoCoords();
33598 _this._graphCalculator = new Graph_1.GraphCalculator();
33599 _this._markerScene = new Component_1.MarkerScene();
33600 _this._markerSet = new Component_1.MarkerSet();
33601 _this._viewportCoords = new Geo_1.ViewportCoords();
33605 * Add markers to the marker set or replace markers in the marker set.
33607 * @description If a marker already in the set has the same
33608 * id as one of the markers added, the old marker will be removed
33609 * the added marker will take its place.
33611 * Any marker inside the visible bounding bbox
33612 * will be initialized and placed in the viewer.
33614 * @param {Array<Marker>} markers - Markers to add.
33616 * @example ```markerComponent.add([marker1, marker2]);```
33618 MarkerComponent.prototype.add = function (markers) {
33619 this._markerSet.add(markers);
33622 * Returns the marker in the marker set with the specified id, or
33623 * undefined if the id matches no marker.
33625 * @param {string} markerId - Id of the marker.
33627 * @example ```var marker = markerComponent.get("markerId");```
33630 MarkerComponent.prototype.get = function (markerId) {
33631 return this._markerSet.get(markerId);
33634 * Returns an array of all markers.
33636 * @example ```var markers = markerComponent.getAll();```
33638 MarkerComponent.prototype.getAll = function () {
33639 return this._markerSet.getAll();
33642 * Returns the id of the interactive marker closest to the current camera
33643 * position at the specified point.
33645 * @description Notice that the pixelPoint argument requires x, y
33646 * coordinates from pixel space.
33648 * With this function, you can use the coordinates provided by mouse
33649 * events to get information out of the marker component.
33651 * If no interactive geometry of an interactive marker exist at the pixel
33652 * point, `null` will be returned.
33654 * @param {Array<number>} pixelPoint - Pixel coordinates on the viewer element.
33655 * @returns {string} Id of the interactive marker closest to the camera. If no
33656 * interactive marker exist at the pixel point, `null` will be returned.
33660 * markerComponent.getMarkerIdAt([100, 100])
33661 * .then((markerId) => { console.log(markerId); });
33664 MarkerComponent.prototype.getMarkerIdAt = function (pixelPoint) {
33666 return when.promise(function (resolve, reject) {
33667 _this._container.renderService.renderCamera$.pipe(operators_1.first(), operators_1.map(function (render) {
33668 var viewport = _this._viewportCoords
33669 .canvasToViewport(pixelPoint[0], pixelPoint[1], _this._container.element);
33670 var id = _this._markerScene.intersectObjects(viewport, render.perspective);
33673 .subscribe(function (id) {
33675 }, function (error) {
33681 * Check if a marker exist in the marker set.
33683 * @param {string} markerId - Id of the marker.
33685 * @example ```var markerExists = markerComponent.has("markerId");```
33687 MarkerComponent.prototype.has = function (markerId) {
33688 return this._markerSet.has(markerId);
33691 * Remove markers with the specified ids from the marker set.
33693 * @param {Array<string>} markerIds - Ids for markers to remove.
33695 * @example ```markerComponent.remove(["id-1", "id-2"]);```
33697 MarkerComponent.prototype.remove = function (markerIds) {
33698 this._markerSet.remove(markerIds);
33701 * Remove all markers from the marker set.
33703 * @example ```markerComponent.removeAll();```
33705 MarkerComponent.prototype.removeAll = function () {
33706 this._markerSet.removeAll();
33708 MarkerComponent.prototype._activate = function () {
33710 var groundAltitude$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
33711 return frame.state.camera.position.z + _this._relativeGroundAltitude;
33712 }), operators_1.distinctUntilChanged(function (a1, a2) {
33713 return Math.abs(a1 - a2) < 0.01;
33714 }), operators_1.publishReplay(1), operators_1.refCount());
33715 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());
33716 var clampedConfiguration$ = this._configuration$.pipe(operators_1.map(function (configuration) {
33717 return { visibleBBoxSize: Math.max(1, Math.min(200, configuration.visibleBBoxSize)) };
33719 var currentlatLon$ = this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) { return node.latLon; }), operators_1.publishReplay(1), operators_1.refCount());
33720 var visibleBBox$ = rxjs_1.combineLatest(clampedConfiguration$, currentlatLon$).pipe(operators_1.map(function (_a) {
33721 var configuration = _a[0], latLon = _a[1];
33722 return _this._graphCalculator
33723 .boundingBoxCorners(latLon, configuration.visibleBBoxSize / 2);
33724 }), operators_1.publishReplay(1), operators_1.refCount());
33725 var visibleMarkers$ = rxjs_1.combineLatest(rxjs_1.concat(rxjs_1.of(this._markerSet), this._markerSet.changed$), visibleBBox$).pipe(operators_1.map(function (_a) {
33726 var set = _a[0], bbox = _a[1];
33727 return set.search(bbox);
33729 this._setChangedSubscription = geoInitiated$.pipe(operators_1.switchMap(function () {
33730 return visibleMarkers$.pipe(operators_1.withLatestFrom(_this._navigator.stateService.reference$, groundAltitude$));
33732 .subscribe(function (_a) {
33733 var markers = _a[0], reference = _a[1], alt = _a[2];
33734 var geoCoords = _this._geoCoords;
33735 var markerScene = _this._markerScene;
33736 var sceneMarkers = markerScene.markers;
33737 var markersToRemove = Object.assign({}, sceneMarkers);
33738 for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
33739 var marker = markers_1[_i];
33740 if (marker.id in sceneMarkers) {
33741 delete markersToRemove[marker.id];
33744 var point3d = geoCoords
33745 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
33746 markerScene.add(marker, point3d);
33749 for (var id in markersToRemove) {
33750 if (!markersToRemove.hasOwnProperty(id)) {
33753 markerScene.remove(id);
33756 this._markersUpdatedSubscription = geoInitiated$.pipe(operators_1.switchMap(function () {
33757 return _this._markerSet.updated$.pipe(operators_1.withLatestFrom(visibleBBox$, _this._navigator.stateService.reference$, groundAltitude$));
33759 .subscribe(function (_a) {
33760 var markers = _a[0], _b = _a[1], sw = _b[0], ne = _b[1], reference = _a[2], alt = _a[3];
33761 var geoCoords = _this._geoCoords;
33762 var markerScene = _this._markerScene;
33763 for (var _i = 0, markers_2 = markers; _i < markers_2.length; _i++) {
33764 var marker = markers_2[_i];
33765 var exists = markerScene.has(marker.id);
33766 var visible = marker.latLon.lat > sw.lat &&
33767 marker.latLon.lat < ne.lat &&
33768 marker.latLon.lon > sw.lon &&
33769 marker.latLon.lon < ne.lon;
33771 var point3d = geoCoords
33772 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
33773 markerScene.add(marker, point3d);
33775 else if (!visible && exists) {
33776 markerScene.remove(marker.id);
33780 this._referenceSubscription = this._navigator.stateService.reference$.pipe(operators_1.skip(1), operators_1.withLatestFrom(groundAltitude$))
33781 .subscribe(function (_a) {
33782 var reference = _a[0], alt = _a[1];
33783 var geoCoords = _this._geoCoords;
33784 var markerScene = _this._markerScene;
33785 for (var _i = 0, _b = markerScene.getAll(); _i < _b.length; _i++) {
33786 var marker = _b[_i];
33787 var point3d = geoCoords
33788 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
33789 markerScene.update(marker.id, point3d);
33792 this._adjustHeightSubscription = groundAltitude$.pipe(operators_1.skip(1), operators_1.withLatestFrom(this._navigator.stateService.reference$, currentlatLon$))
33793 .subscribe(function (_a) {
33794 var alt = _a[0], reference = _a[1], latLon = _a[2];
33795 var geoCoords = _this._geoCoords;
33796 var markerScene = _this._markerScene;
33797 var position = geoCoords
33798 .geodeticToEnu(latLon.lat, latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
33799 for (var _i = 0, _b = markerScene.getAll(); _i < _b.length; _i++) {
33800 var marker = _b[_i];
33801 var point3d = geoCoords
33802 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
33803 var distanceX = point3d[0] - position[0];
33804 var distanceY = point3d[1] - position[1];
33805 var groundDistance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
33806 if (groundDistance > 50) {
33809 markerScene.lerpAltitude(marker.id, alt, Math.min(1, Math.max(0, 1.2 - 1.2 * groundDistance / 50)));
33812 this._renderSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
33813 var scene = _this._markerScene;
33818 needsRender: scene.needsRender,
33819 render: scene.render.bind(scene),
33820 stage: Render_1.GLRenderStage.Foreground,
33824 .subscribe(this._container.glRenderer.render$);
33825 var hoveredMarkerId$ = rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._container.mouseService.mouseMove$).pipe(operators_1.map(function (_a) {
33826 var render = _a[0], event = _a[1];
33827 var element = _this._container.element;
33828 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
33829 var viewport = _this._viewportCoords.canvasToViewport(canvasX, canvasY, element);
33830 var markerId = _this._markerScene.intersectObjects(viewport, render.perspective);
33832 }), operators_1.publishReplay(1), operators_1.refCount());
33833 var draggingStarted$ = this._container.mouseService
33834 .filtered$(this._name, this._container.mouseService.mouseDragStart$).pipe(operators_1.map(function (event) {
33837 var draggingStopped$ = this._container.mouseService
33838 .filtered$(this._name, this._container.mouseService.mouseDragEnd$).pipe(operators_1.map(function (event) {
33841 var filteredDragging$ = rxjs_1.merge(draggingStarted$, draggingStopped$).pipe(operators_1.startWith(false));
33842 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())
33843 .subscribe(function (_a) {
33844 var previous = _a[0], current = _a[1];
33845 var dragging = current[0];
33846 var eventType = dragging ? MarkerComponent.dragstart : MarkerComponent.dragend;
33847 var id = dragging ? current[1] : previous[1];
33848 var marker = _this._markerScene.get(id);
33849 var markerEvent = { marker: marker, target: _this, type: eventType };
33850 _this.fire(eventType, markerEvent);
33852 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));
33853 this._mouseClaimSubscription = rxjs_1.combineLatest(this._container.mouseService.active$, hoveredMarkerId$.pipe(operators_1.distinctUntilChanged()), mouseDown$, filteredDragging$).pipe(operators_1.map(function (_a) {
33854 var active = _a[0], markerId = _a[1], mouseDown = _a[2], filteredDragging = _a[3];
33855 return (!active && markerId != null && mouseDown) || filteredDragging;
33856 }), operators_1.distinctUntilChanged())
33857 .subscribe(function (claim) {
33859 _this._container.mouseService.claimMouse(_this._name, 1);
33860 _this._container.mouseService.claimWheel(_this._name, 1);
33863 _this._container.mouseService.unclaimMouse(_this._name);
33864 _this._container.mouseService.unclaimWheel(_this._name);
33867 var offset$ = this._container.mouseService
33868 .filtered$(this._name, this._container.mouseService.mouseDragStart$).pipe(operators_1.withLatestFrom(hoveredMarkerId$, this._container.renderService.renderCamera$), operators_1.map(function (_a) {
33869 var e = _a[0], id = _a[1], r = _a[2];
33870 var marker = _this._markerScene.get(id);
33871 var element = _this._container.element;
33872 var _b = _this._viewportCoords.projectToCanvas(marker.geometry.position.toArray(), element, r.perspective), groundCanvasX = _b[0], groundCanvasY = _b[1];
33873 var _c = _this._viewportCoords.canvasPosition(e, element), canvasX = _c[0], canvasY = _c[1];
33874 var offset = [canvasX - groundCanvasX, canvasY - groundCanvasY];
33875 return [marker, offset, r];
33876 }), operators_1.publishReplay(1), operators_1.refCount());
33877 this._updateMarkerSubscription = this._container.mouseService
33878 .filtered$(this._name, this._container.mouseService.mouseDrag$).pipe(operators_1.withLatestFrom(offset$, this._navigator.stateService.reference$, clampedConfiguration$))
33879 .subscribe(function (_a) {
33880 var event = _a[0], _b = _a[1], marker = _b[0], offset = _b[1], render = _b[2], reference = _a[2], configuration = _a[3];
33881 if (!_this._markerScene.has(marker.id)) {
33884 var element = _this._container.element;
33885 var _c = _this._viewportCoords.canvasPosition(event, element), canvasX = _c[0], canvasY = _c[1];
33886 var groundX = canvasX - offset[0];
33887 var groundY = canvasY - offset[1];
33888 var _d = _this._viewportCoords
33889 .canvasToViewport(groundX, groundY, element), viewportX = _d[0], viewportY = _d[1];
33890 var direction = new THREE.Vector3(viewportX, viewportY, 1)
33891 .unproject(render.perspective)
33892 .sub(render.perspective.position)
33894 var distance = Math.min(_this._relativeGroundAltitude / direction.z, configuration.visibleBBoxSize / 2 - 0.1);
33895 if (distance < 0) {
33898 var intersection = direction
33900 .multiplyScalar(distance)
33901 .add(render.perspective.position);
33902 intersection.z = render.perspective.position.z + _this._relativeGroundAltitude;
33903 var _e = _this._geoCoords
33904 .enuToGeodetic(intersection.x, intersection.y, intersection.z, reference.lat, reference.lon, reference.alt), lat = _e[0], lon = _e[1];
33905 _this._markerScene.update(marker.id, intersection.toArray(), { lat: lat, lon: lon });
33906 _this._markerSet.update(marker);
33907 var markerEvent = { marker: marker, target: _this, type: MarkerComponent.changed };
33908 _this.fire(MarkerComponent.changed, markerEvent);
33911 MarkerComponent.prototype._deactivate = function () {
33912 this._adjustHeightSubscription.unsubscribe();
33913 this._dragEventSubscription.unsubscribe();
33914 this._markersUpdatedSubscription.unsubscribe();
33915 this._mouseClaimSubscription.unsubscribe();
33916 this._referenceSubscription.unsubscribe();
33917 this._renderSubscription.unsubscribe();
33918 this._setChangedSubscription.unsubscribe();
33919 this._updateMarkerSubscription.unsubscribe();
33920 this._markerScene.clear();
33922 MarkerComponent.prototype._getDefaultConfiguration = function () {
33923 return { visibleBBoxSize: 100 };
33925 MarkerComponent.componentName = "marker";
33927 * Fired when the position of a marker is changed.
33929 * @type {IMarkerEvent} markerEvent - Marker event data.
33932 * markerComponent.on("changed", function(e) {
33933 * console.log(e.marker.id, e.marker.latLon);
33937 MarkerComponent.changed = "changed";
33939 * Fired when a marker drag interaction starts.
33941 * @type {IMarkerEvent} markerEvent - Marker event data.
33944 * markerComponent.on("dragstart", function(e) {
33945 * console.log(e.marker.id, e.marker.latLon);
33949 MarkerComponent.dragstart = "dragstart";
33951 * Fired when a marker drag interaction ends.
33953 * @type {IMarkerEvent} markerEvent - Marker event data.
33956 * markerComponent.on("dragend", function(e) {
33957 * console.log(e.marker.id, e.marker.latLon);
33961 MarkerComponent.dragend = "dragend";
33962 return MarkerComponent;
33963 }(Component_1.Component));
33964 exports.MarkerComponent = MarkerComponent;
33965 Component_1.ComponentService.register(MarkerComponent);
33966 exports.default = MarkerComponent;
33969 },{"../../Component":291,"../../Geo":294,"../../Graph":295,"../../Render":297,"rxjs":43,"rxjs/operators":241,"three":242,"when":288}],335:[function(require,module,exports){
33971 Object.defineProperty(exports, "__esModule", { value: true });
33972 exports.MarkerScene = void 0;
33973 var THREE = require("three");
33974 var MarkerScene = /** @class */ (function () {
33975 function MarkerScene(scene, raycaster) {
33976 this._needsRender = false;
33977 this._interactiveObjects = [];
33978 this._markers = {};
33979 this._objectMarkers = {};
33980 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster();
33981 this._scene = !!scene ? scene : new THREE.Scene();
33983 Object.defineProperty(MarkerScene.prototype, "markers", {
33985 return this._markers;
33990 Object.defineProperty(MarkerScene.prototype, "needsRender", {
33992 return this._needsRender;
33997 MarkerScene.prototype.add = function (marker, position) {
33998 if (marker.id in this._markers) {
33999 this._dispose(marker.id);
34001 marker.createGeometry(position);
34002 this._scene.add(marker.geometry);
34003 this._markers[marker.id] = marker;
34004 for (var _i = 0, _a = marker.getInteractiveObjects(); _i < _a.length; _i++) {
34005 var interactiveObject = _a[_i];
34006 this._interactiveObjects.push(interactiveObject);
34007 this._objectMarkers[interactiveObject.uuid] = marker.id;
34009 this._needsRender = true;
34011 MarkerScene.prototype.clear = function () {
34012 for (var id in this._markers) {
34013 if (!this._markers.hasOwnProperty) {
34018 this._needsRender = true;
34020 MarkerScene.prototype.get = function (id) {
34021 return this._markers[id];
34023 MarkerScene.prototype.getAll = function () {
34026 .keys(this._markers)
34027 .map(function (id) { return _this._markers[id]; });
34029 MarkerScene.prototype.has = function (id) {
34030 return id in this._markers;
34032 MarkerScene.prototype.intersectObjects = function (_a, camera) {
34033 var viewportX = _a[0], viewportY = _a[1];
34034 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
34035 var intersects = this._raycaster.intersectObjects(this._interactiveObjects);
34036 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
34037 var intersect = intersects_1[_i];
34038 if (intersect.object.uuid in this._objectMarkers) {
34039 return this._objectMarkers[intersect.object.uuid];
34044 MarkerScene.prototype.lerpAltitude = function (id, alt, alpha) {
34045 if (!(id in this._markers)) {
34048 this._markers[id].lerpAltitude(alt, alpha);
34049 this._needsRender = true;
34051 MarkerScene.prototype.remove = function (id) {
34052 if (!(id in this._markers)) {
34056 this._needsRender = true;
34058 MarkerScene.prototype.render = function (perspectiveCamera, renderer) {
34059 renderer.render(this._scene, perspectiveCamera);
34060 this._needsRender = false;
34062 MarkerScene.prototype.update = function (id, position, latLon) {
34063 if (!(id in this._markers)) {
34066 var marker = this._markers[id];
34067 marker.updatePosition(position, latLon);
34068 this._needsRender = true;
34070 MarkerScene.prototype._dispose = function (id) {
34071 var marker = this._markers[id];
34072 this._scene.remove(marker.geometry);
34073 for (var _i = 0, _a = marker.getInteractiveObjects(); _i < _a.length; _i++) {
34074 var interactiveObject = _a[_i];
34075 var index = this._interactiveObjects.indexOf(interactiveObject);
34076 if (index !== -1) {
34077 this._interactiveObjects.splice(index, 1);
34080 console.warn("Object does not exist (" + interactiveObject.id + ") for " + id);
34082 delete this._objectMarkers[interactiveObject.uuid];
34084 marker.disposeGeometry();
34085 delete this._markers[id];
34087 return MarkerScene;
34089 exports.MarkerScene = MarkerScene;
34090 exports.default = MarkerScene;
34092 },{"three":242}],336:[function(require,module,exports){
34094 Object.defineProperty(exports, "__esModule", { value: true });
34095 exports.MarkerSet = void 0;
34096 var rxjs_1 = require("rxjs");
34097 var Geo_1 = require("../../Geo");
34098 var MarkerSet = /** @class */ (function () {
34099 function MarkerSet() {
34101 this._index = new Geo_1.GeoRBush(16);
34102 this._indexChanged$ = new rxjs_1.Subject();
34103 this._updated$ = new rxjs_1.Subject();
34105 Object.defineProperty(MarkerSet.prototype, "changed$", {
34107 return this._indexChanged$;
34112 Object.defineProperty(MarkerSet.prototype, "updated$", {
34114 return this._updated$;
34119 MarkerSet.prototype.add = function (markers) {
34121 var hash = this._hash;
34122 var index = this._index;
34123 for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
34124 var marker = markers_1[_i];
34125 var id = marker.id;
34127 index.remove(hash[id]);
34128 updated.push(marker);
34131 lat: marker.latLon.lat,
34132 lon: marker.latLon.lon,
34136 index.insert(item);
34138 if (updated.length > 0) {
34139 this._updated$.next(updated);
34141 if (markers.length > updated.length) {
34142 this._indexChanged$.next(this);
34145 MarkerSet.prototype.has = function (id) {
34146 return id in this._hash;
34148 MarkerSet.prototype.get = function (id) {
34149 return this.has(id) ? this._hash[id].marker : undefined;
34151 MarkerSet.prototype.getAll = function () {
34154 .map(function (indexItem) {
34155 return indexItem.marker;
34158 MarkerSet.prototype.remove = function (ids) {
34159 var hash = this._hash;
34160 var index = this._index;
34161 var changed = false;
34162 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
34163 var id = ids_1[_i];
34164 if (!(id in hash)) {
34167 var item = hash[id];
34168 index.remove(item);
34173 this._indexChanged$.next(this);
34176 MarkerSet.prototype.removeAll = function () {
34178 this._index.clear();
34179 this._indexChanged$.next(this);
34181 MarkerSet.prototype.search = function (_a) {
34182 var sw = _a[0], ne = _a[1];
34190 .map(function (indexItem) {
34191 return indexItem.marker;
34194 MarkerSet.prototype.update = function (marker) {
34195 var hash = this._hash;
34196 var index = this._index;
34197 var id = marker.id;
34198 if (!(id in hash)) {
34201 index.remove(hash[id]);
34203 lat: marker.latLon.lat,
34204 lon: marker.latLon.lon,
34208 index.insert(item);
34212 exports.MarkerSet = MarkerSet;
34213 exports.default = MarkerSet;
34215 },{"../../Geo":294,"rxjs":43}],337:[function(require,module,exports){
34217 Object.defineProperty(exports, "__esModule", { value: true });
34219 },{}],338:[function(require,module,exports){
34221 var __extends = (this && this.__extends) || (function () {
34222 var extendStatics = function (d, b) {
34223 extendStatics = Object.setPrototypeOf ||
34224 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34225 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34226 return extendStatics(d, b);
34228 return function (d, b) {
34229 extendStatics(d, b);
34230 function __() { this.constructor = d; }
34231 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34234 Object.defineProperty(exports, "__esModule", { value: true });
34235 exports.CircleMarker = void 0;
34236 var THREE = require("three");
34237 var Component_1 = require("../../../Component");
34239 * @class CircleMarker
34241 * @classdesc Non-interactive marker with a flat circle shape. The circle
34242 * marker can not be configured to be interactive.
34244 * Circle marker properties can not be updated after creation.
34246 * To create and add one `CircleMarker` with default configuration
34247 * and one with configuration use
34251 * var defaultMarker = new Mapillary.MarkerComponent.CircleMarker(
34253 * { lat: 0, lon: 0, });
34255 * var configuredMarker = new Mapillary.MarkerComponent.CircleMarker(
34257 * { lat: 0, lon: 0, },
34264 * markerComponent.add([defaultMarker, configuredMarker]);
34267 var CircleMarker = /** @class */ (function (_super) {
34268 __extends(CircleMarker, _super);
34269 function CircleMarker(id, latLon, options) {
34270 var _this = _super.call(this, id, latLon) || this;
34271 options = !!options ? options : {};
34272 _this._color = options.color != null ? options.color : 0xffffff;
34273 _this._opacity = options.opacity != null ? options.opacity : 0.4;
34274 _this._radius = options.radius != null ? options.radius : 1;
34277 CircleMarker.prototype._createGeometry = function (position) {
34278 var circle = new THREE.Mesh(new THREE.CircleGeometry(this._radius, 16), new THREE.MeshBasicMaterial({
34279 color: this._color,
34280 opacity: this._opacity,
34283 circle.up.fromArray([0, 0, 1]);
34284 circle.renderOrder = -1;
34285 var group = new THREE.Object3D();
34287 group.position.fromArray(position);
34288 this._geometry = group;
34290 CircleMarker.prototype._disposeGeometry = function () {
34291 for (var _i = 0, _a = this._geometry.children; _i < _a.length; _i++) {
34293 mesh.geometry.dispose();
34294 mesh.material.dispose();
34297 CircleMarker.prototype._getInteractiveObjects = function () {
34300 return CircleMarker;
34301 }(Component_1.Marker));
34302 exports.CircleMarker = CircleMarker;
34303 exports.default = CircleMarker;
34305 },{"../../../Component":291,"three":242}],339:[function(require,module,exports){
34307 Object.defineProperty(exports, "__esModule", { value: true });
34308 exports.Marker = void 0;
34312 * @classdesc Represents an abstract marker class that should be extended
34313 * by marker implementations used in the marker component.
34315 var Marker = /** @class */ (function () {
34316 function Marker(id, latLon) {
34318 this._latLon = latLon;
34320 Object.defineProperty(Marker.prototype, "id", {
34323 * @returns {string} The id of the marker.
34331 Object.defineProperty(Marker.prototype, "geometry", {
34338 return this._geometry;
34343 Object.defineProperty(Marker.prototype, "latLon", {
34346 * @returns {ILatLon} The geographic coordinates of the marker.
34349 return this._latLon;
34355 Marker.prototype.createGeometry = function (position) {
34356 if (!!this._geometry) {
34359 this._createGeometry(position);
34360 // update matrix world if raycasting occurs before first render
34361 this._geometry.updateMatrixWorld(true);
34364 Marker.prototype.disposeGeometry = function () {
34365 if (!this._geometry) {
34368 this._disposeGeometry();
34369 this._geometry = undefined;
34372 Marker.prototype.getInteractiveObjects = function () {
34373 if (!this._geometry) {
34376 return this._getInteractiveObjects();
34379 Marker.prototype.lerpAltitude = function (alt, alpha) {
34380 if (!this._geometry) {
34383 this._geometry.position.z = (1 - alpha) * this._geometry.position.z + alpha * alt;
34386 Marker.prototype.updatePosition = function (position, latLon) {
34388 this._latLon.lat = latLon.lat;
34389 this._latLon.lon = latLon.lon;
34391 if (!this._geometry) {
34394 this._geometry.position.fromArray(position);
34395 this._geometry.updateMatrixWorld(true);
34399 exports.Marker = Marker;
34400 exports.default = Marker;
34402 },{}],340:[function(require,module,exports){
34404 var __extends = (this && this.__extends) || (function () {
34405 var extendStatics = function (d, b) {
34406 extendStatics = Object.setPrototypeOf ||
34407 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34408 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34409 return extendStatics(d, b);
34411 return function (d, b) {
34412 extendStatics(d, b);
34413 function __() { this.constructor = d; }
34414 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34417 Object.defineProperty(exports, "__esModule", { value: true });
34418 exports.SimpleMarker = void 0;
34419 var THREE = require("three");
34420 var Component_1 = require("../../../Component");
34422 * @class SimpleMarker
34424 * @classdesc Interactive marker with ice cream shape. The sphere
34425 * inside the ice cream can be configured to be interactive.
34427 * Simple marker properties can not be updated after creation.
34429 * To create and add one `SimpleMarker` with default configuration
34430 * (non-interactive) and one interactive with configuration use
34434 * var defaultMarker = new Mapillary.MarkerComponent.SimpleMarker(
34436 * { lat: 0, lon: 0, });
34438 * var interactiveMarker = new Mapillary.MarkerComponent.SimpleMarker(
34440 * { lat: 0, lon: 0, },
34442 * ballColor: "#00f",
34443 * ballOpacity: 0.5,
34445 * interactive: true,
34450 * markerComponent.add([defaultMarker, interactiveMarker]);
34453 var SimpleMarker = /** @class */ (function (_super) {
34454 __extends(SimpleMarker, _super);
34455 function SimpleMarker(id, latLon, options) {
34456 var _this = _super.call(this, id, latLon) || this;
34457 options = !!options ? options : {};
34458 _this._ballColor = options.ballColor != null ? options.ballColor : 0xff0000;
34459 _this._ballOpacity = options.ballOpacity != null ? options.ballOpacity : 0.8;
34460 _this._circleToRayAngle = 2;
34461 _this._color = options.color != null ? options.color : 0xff0000;
34462 _this._interactive = !!options.interactive;
34463 _this._opacity = options.opacity != null ? options.opacity : 0.4;
34464 _this._radius = options.radius != null ? options.radius : 1;
34467 SimpleMarker.prototype._createGeometry = function (position) {
34468 var radius = this._radius;
34469 var cone = new THREE.Mesh(this._markerGeometry(radius, 8, 8), new THREE.MeshBasicMaterial({
34470 color: this._color,
34471 opacity: this._opacity,
34474 cone.renderOrder = 1;
34475 var ball = new THREE.Mesh(new THREE.SphereGeometry(radius / 2, 8, 8), new THREE.MeshBasicMaterial({
34476 color: this._ballColor,
34477 opacity: this._ballOpacity,
34480 ball.position.z = this._markerHeight(radius);
34481 var group = new THREE.Object3D();
34484 group.position.fromArray(position);
34485 this._geometry = group;
34487 SimpleMarker.prototype._disposeGeometry = function () {
34488 for (var _i = 0, _a = this._geometry.children; _i < _a.length; _i++) {
34490 mesh.geometry.dispose();
34491 mesh.material.dispose();
34494 SimpleMarker.prototype._getInteractiveObjects = function () {
34495 return this._interactive ? [this._geometry.children[0]] : [];
34497 SimpleMarker.prototype._markerHeight = function (radius) {
34498 var t = Math.tan(Math.PI - this._circleToRayAngle);
34499 return radius * Math.sqrt(1 + t * t);
34501 SimpleMarker.prototype._markerGeometry = function (radius, widthSegments, heightSegments) {
34502 var geometry = new THREE.Geometry();
34503 widthSegments = Math.max(3, Math.floor(widthSegments) || 8);
34504 heightSegments = Math.max(2, Math.floor(heightSegments) || 6);
34505 var height = this._markerHeight(radius);
34507 for (var y = 0; y <= heightSegments; ++y) {
34508 var verticesRow = [];
34509 for (var x = 0; x <= widthSegments; ++x) {
34510 var u = x / widthSegments * Math.PI * 2;
34511 var v = y / heightSegments * Math.PI;
34513 if (v < this._circleToRayAngle) {
34517 var t = Math.tan(v - this._circleToRayAngle);
34518 r = radius * Math.sqrt(1 + t * t);
34520 var vertex = new THREE.Vector3();
34521 vertex.x = r * Math.cos(u) * Math.sin(v);
34522 vertex.y = r * Math.sin(u) * Math.sin(v);
34523 vertex.z = r * Math.cos(v) + height;
34524 geometry.vertices.push(vertex);
34525 verticesRow.push(geometry.vertices.length - 1);
34527 vertices.push(verticesRow);
34529 for (var y = 0; y < heightSegments; ++y) {
34530 for (var x = 0; x < widthSegments; ++x) {
34531 var v1 = vertices[y][x + 1];
34532 var v2 = vertices[y][x];
34533 var v3 = vertices[y + 1][x];
34534 var v4 = vertices[y + 1][x + 1];
34535 var n1 = geometry.vertices[v1].clone().normalize();
34536 var n2 = geometry.vertices[v2].clone().normalize();
34537 var n3 = geometry.vertices[v3].clone().normalize();
34538 var n4 = geometry.vertices[v4].clone().normalize();
34539 geometry.faces.push(new THREE.Face3(v1, v2, v4, [n1, n2, n4]));
34540 geometry.faces.push(new THREE.Face3(v2, v3, v4, [n2.clone(), n3, n4.clone()]));
34543 geometry.computeFaceNormals();
34544 geometry.boundingSphere = new THREE.Sphere(new THREE.Vector3(), radius + height);
34547 return SimpleMarker;
34548 }(Component_1.Marker));
34549 exports.SimpleMarker = SimpleMarker;
34550 exports.default = SimpleMarker;
34552 },{"../../../Component":291,"three":242}],341:[function(require,module,exports){
34554 var __extends = (this && this.__extends) || (function () {
34555 var extendStatics = function (d, b) {
34556 extendStatics = Object.setPrototypeOf ||
34557 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34558 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34559 return extendStatics(d, b);
34561 return function (d, b) {
34562 extendStatics(d, b);
34563 function __() { this.constructor = d; }
34564 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34567 Object.defineProperty(exports, "__esModule", { value: true });
34568 exports.BounceHandler = void 0;
34569 var rxjs_1 = require("rxjs");
34570 var operators_1 = require("rxjs/operators");
34571 var Component_1 = require("../../Component");
34573 * The `BounceHandler` ensures that the viewer bounces back to the image
34574 * when drag panning outside of the image edge.
34576 var BounceHandler = /** @class */ (function (_super) {
34577 __extends(BounceHandler, _super);
34578 function BounceHandler(component, container, navigator, viewportCoords, spatial) {
34579 var _this = _super.call(this, component, container, navigator) || this;
34580 _this._spatial = spatial;
34581 _this._viewportCoords = viewportCoords;
34584 BounceHandler.prototype._enable = function () {
34586 var inTransition$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
34587 return frame.state.alpha < 1;
34588 }), operators_1.distinctUntilChanged());
34589 this._bounceSubscription = rxjs_1.combineLatest(inTransition$, this._navigator.stateService.inTranslation$, this._container.mouseService.active$, this._container.touchService.active$).pipe(operators_1.map(function (noForce) {
34590 return noForce[0] || noForce[1] || noForce[2] || noForce[3];
34591 }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (noForce) {
34594 rxjs_1.combineLatest(_this._container.renderService.renderCamera$, _this._navigator.stateService.currentTransform$.pipe(operators_1.first()));
34595 }), operators_1.withLatestFrom(this._navigator.panService.panNodes$))
34596 .subscribe(function (_a) {
34597 var _b = _a[0], render = _b[0], transform = _b[1], nts = _a[1];
34598 if (!transform.hasValidScale && render.camera.focal < 0.1) {
34601 if (render.perspective.aspect === 0 || render.perspective.aspect === Number.POSITIVE_INFINITY) {
34604 var distances = Component_1.ImageBoundary.viewportDistances(transform, render.perspective, _this._viewportCoords);
34605 var basic = _this._viewportCoords.viewportToBasic(0, 0, transform, render.perspective);
34606 if ((basic[0] < 0 || basic[0] > 1) && nts.length > 0) {
34607 distances[0] = distances[2] = 0;
34609 for (var _i = 0, nts_1 = nts; _i < nts_1.length; _i++) {
34610 var _c = nts_1[_i], t = _c[1];
34611 var d = Component_1.ImageBoundary.viewportDistances(t, render.perspective, _this._viewportCoords);
34612 for (var i = 1; i < distances.length; i += 2) {
34613 if (d[i] < distances[i]) {
34614 distances[i] = d[i];
34618 if (Math.max.apply(Math, distances) < 0.01) {
34621 var horizontalDistance = distances[1] - distances[3];
34622 var verticalDistance = distances[0] - distances[2];
34623 var currentDirection = _this._viewportCoords
34624 .unprojectFromViewport(0, 0, render.perspective)
34625 .sub(render.perspective.position);
34626 var directionPhi = _this._viewportCoords
34627 .unprojectFromViewport(horizontalDistance, 0, render.perspective)
34628 .sub(render.perspective.position);
34629 var directionTheta = _this._viewportCoords
34630 .unprojectFromViewport(0, verticalDistance, render.perspective)
34631 .sub(render.perspective.position);
34632 var phi = (horizontalDistance > 0 ? 1 : -1) * directionPhi.angleTo(currentDirection);
34633 var theta = (verticalDistance > 0 ? 1 : -1) * directionTheta.angleTo(currentDirection);
34634 var threshold = Math.PI / 60;
34636 phi = _this._spatial.clamp(coeff * phi, -threshold, threshold);
34637 theta = _this._spatial.clamp(coeff * theta, -threshold, threshold);
34638 _this._navigator.stateService.rotateUnbounded({ phi: phi, theta: theta });
34641 BounceHandler.prototype._disable = function () {
34642 this._bounceSubscription.unsubscribe();
34644 BounceHandler.prototype._getConfiguration = function () {
34647 return BounceHandler;
34648 }(Component_1.HandlerBase));
34649 exports.BounceHandler = BounceHandler;
34650 exports.default = BounceHandler;
34652 },{"../../Component":291,"rxjs":43,"rxjs/operators":241}],342:[function(require,module,exports){
34654 var __extends = (this && this.__extends) || (function () {
34655 var extendStatics = function (d, b) {
34656 extendStatics = Object.setPrototypeOf ||
34657 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34658 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34659 return extendStatics(d, b);
34661 return function (d, b) {
34662 extendStatics(d, b);
34663 function __() { this.constructor = d; }
34664 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34667 Object.defineProperty(exports, "__esModule", { value: true });
34668 exports.DoubleClickZoomHandler = void 0;
34669 var rxjs_1 = require("rxjs");
34670 var operators_1 = require("rxjs/operators");
34671 var Component_1 = require("../../Component");
34673 * The `DoubleClickZoomHandler` allows the user to zoom the viewer image at a point by double clicking.
34677 * var mouseComponent = viewer.getComponent("mouse");
34679 * mouseComponent.doubleClickZoom.disable();
34680 * mouseComponent.doubleClickZoom.enable();
34682 * var isEnabled = mouseComponent.doubleClickZoom.isEnabled;
34685 var DoubleClickZoomHandler = /** @class */ (function (_super) {
34686 __extends(DoubleClickZoomHandler, _super);
34688 function DoubleClickZoomHandler(component, container, navigator, viewportCoords) {
34689 var _this = _super.call(this, component, container, navigator) || this;
34690 _this._viewportCoords = viewportCoords;
34693 DoubleClickZoomHandler.prototype._enable = function () {
34695 this._zoomSubscription = rxjs_1.merge(this._container.mouseService
34696 .filtered$(this._component.name, this._container.mouseService.dblClick$), this._container.touchService.doubleTap$.pipe(operators_1.map(function (e) {
34697 var touch = e.touches[0];
34698 return { clientX: touch.clientX, clientY: touch.clientY, shiftKey: e.shiftKey };
34699 }))).pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
34700 .subscribe(function (_a) {
34701 var event = _a[0], render = _a[1], transform = _a[2];
34702 var element = _this._container.element;
34703 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
34704 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
34705 var reference = transform.projectBasic(unprojected.toArray());
34706 var delta = !!event.shiftKey ? -1 : 1;
34707 _this._navigator.stateService.zoomIn(delta, reference);
34710 DoubleClickZoomHandler.prototype._disable = function () {
34711 this._zoomSubscription.unsubscribe();
34713 DoubleClickZoomHandler.prototype._getConfiguration = function (enable) {
34714 return { doubleClickZoom: enable };
34716 return DoubleClickZoomHandler;
34717 }(Component_1.HandlerBase));
34718 exports.DoubleClickZoomHandler = DoubleClickZoomHandler;
34719 exports.default = DoubleClickZoomHandler;
34721 },{"../../Component":291,"rxjs":43,"rxjs/operators":241}],343:[function(require,module,exports){
34723 var __extends = (this && this.__extends) || (function () {
34724 var extendStatics = function (d, b) {
34725 extendStatics = Object.setPrototypeOf ||
34726 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34727 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34728 return extendStatics(d, b);
34730 return function (d, b) {
34731 extendStatics(d, b);
34732 function __() { this.constructor = d; }
34733 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34736 Object.defineProperty(exports, "__esModule", { value: true });
34737 exports.DragPanHandler = void 0;
34738 var rxjs_1 = require("rxjs");
34739 var operators_1 = require("rxjs/operators");
34740 var Component_1 = require("../../Component");
34742 * The `DragPanHandler` allows the user to pan the viewer image by clicking and dragging the cursor.
34746 * var mouseComponent = viewer.getComponent("mouse");
34748 * mouseComponent.dragPan.disable();
34749 * mouseComponent.dragPan.enable();
34751 * var isEnabled = mouseComponent.dragPan.isEnabled;
34754 var DragPanHandler = /** @class */ (function (_super) {
34755 __extends(DragPanHandler, _super);
34757 function DragPanHandler(component, container, navigator, viewportCoords, spatial) {
34758 var _this = _super.call(this, component, container, navigator) || this;
34759 _this._spatial = spatial;
34760 _this._viewportCoords = viewportCoords;
34763 DragPanHandler.prototype._enable = function () {
34765 var draggingStarted$ = this._container.mouseService
34766 .filtered$(this._component.name, this._container.mouseService.mouseDragStart$).pipe(operators_1.map(function () {
34768 }), operators_1.share());
34769 var draggingStopped$ = this._container.mouseService
34770 .filtered$(this._component.name, this._container.mouseService.mouseDragEnd$).pipe(operators_1.map(function () {
34772 }), operators_1.share());
34773 this._activeMouseSubscription = rxjs_1.merge(draggingStarted$, draggingStopped$)
34774 .subscribe(this._container.mouseService.activate$);
34775 var documentMouseMove$ = rxjs_1.merge(draggingStarted$, draggingStopped$).pipe(operators_1.switchMap(function (dragging) {
34777 _this._container.mouseService.documentMouseMove$ :
34780 this._preventDefaultSubscription = rxjs_1.merge(documentMouseMove$, this._container.touchService.touchMove$)
34781 .subscribe(function (event) {
34782 event.preventDefault(); // prevent selection of content outside the viewer
34784 var touchMovingStarted$ = this._container.touchService.singleTouchDragStart$.pipe(operators_1.map(function () {
34787 var touchMovingStopped$ = this._container.touchService.singleTouchDragEnd$.pipe(operators_1.map(function () {
34790 this._activeTouchSubscription = rxjs_1.merge(touchMovingStarted$, touchMovingStopped$)
34791 .subscribe(this._container.touchService.activate$);
34792 var rotation$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
34793 return frame.state.currentNode.fullPano || frame.state.nodesAhead < 1;
34794 }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (enable) {
34796 return rxjs_1.empty();
34798 var mouseDrag$ = Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService);
34799 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) {
34800 return event != null && event.touches.length > 0 ?
34801 event.touches[0] : null;
34802 }), operators_1.pairwise(), operators_1.filter(function (pair) {
34803 return pair[0] != null && pair[1] != null;
34805 return rxjs_1.merge(mouseDrag$, singleTouchDrag$);
34806 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, this._navigator.panService.panNodes$), operators_1.map(function (_a) {
34807 var events = _a[0], render = _a[1], transform = _a[2], nts = _a[3];
34808 var previousEvent = events[0];
34809 var event = events[1];
34810 var movementX = event.clientX - previousEvent.clientX;
34811 var movementY = event.clientY - previousEvent.clientY;
34812 var element = _this._container.element;
34813 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
34814 var currentDirection = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective)
34815 .sub(render.perspective.position);
34816 var directionX = _this._viewportCoords.unprojectFromCanvas(canvasX - movementX, canvasY, element, render.perspective)
34817 .sub(render.perspective.position);
34818 var directionY = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY - movementY, element, render.perspective)
34819 .sub(render.perspective.position);
34820 var phi = (movementX > 0 ? 1 : -1) * directionX.angleTo(currentDirection);
34821 var theta = (movementY > 0 ? -1 : 1) * directionY.angleTo(currentDirection);
34822 var distances = Component_1.ImageBoundary.viewportDistances(transform, render.perspective, _this._viewportCoords);
34823 for (var _i = 0, nts_1 = nts; _i < nts_1.length; _i++) {
34824 var _c = nts_1[_i], t = _c[1];
34825 var d = Component_1.ImageBoundary.viewportDistances(t, render.perspective, _this._viewportCoords);
34826 for (var i = 0; i < distances.length; i++) {
34827 if (d[i] < distances[i]) {
34828 distances[i] = d[i];
34832 if (distances[0] > 0 && theta < 0) {
34833 theta /= Math.max(1, 2e2 * distances[0]);
34835 if (distances[2] > 0 && theta > 0) {
34836 theta /= Math.max(1, 2e2 * distances[2]);
34838 if (distances[1] > 0 && phi < 0) {
34839 phi /= Math.max(1, 2e2 * distances[1]);
34841 if (distances[3] > 0 && phi > 0) {
34842 phi /= Math.max(1, 2e2 * distances[3]);
34844 return { phi: phi, theta: theta };
34845 }), operators_1.share());
34846 this._rotateWithoutInertiaSubscription = rotation$
34847 .subscribe(function (rotation) {
34848 _this._navigator.stateService.rotateWithoutInertia(rotation);
34850 this._rotateSubscription = rotation$.pipe(operators_1.scan(function (rotationBuffer, rotation) {
34851 _this._drainBuffer(rotationBuffer);
34852 rotationBuffer.push([Date.now(), rotation]);
34853 return rotationBuffer;
34854 }, []), 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) {
34855 var drainedBuffer = _this._drainBuffer(rotationBuffer.slice());
34856 var rotation = { phi: 0, theta: 0 };
34857 for (var _i = 0, drainedBuffer_1 = drainedBuffer; _i < drainedBuffer_1.length; _i++) {
34858 var bufferedRotation = drainedBuffer_1[_i];
34859 rotation.phi += bufferedRotation[1].phi;
34860 rotation.theta += bufferedRotation[1].theta;
34862 var count = drainedBuffer.length;
34864 rotation.phi /= count;
34865 rotation.theta /= count;
34867 var threshold = Math.PI / 18;
34868 rotation.phi = _this._spatial.clamp(rotation.phi, -threshold, threshold);
34869 rotation.theta = _this._spatial.clamp(rotation.theta, -threshold, threshold);
34872 .subscribe(function (rotation) {
34873 _this._navigator.stateService.rotate(rotation);
34876 DragPanHandler.prototype._disable = function () {
34877 this._activeMouseSubscription.unsubscribe();
34878 this._activeTouchSubscription.unsubscribe();
34879 this._preventDefaultSubscription.unsubscribe();
34880 this._rotateSubscription.unsubscribe();
34881 this._rotateWithoutInertiaSubscription.unsubscribe();
34882 this._activeMouseSubscription = null;
34883 this._activeTouchSubscription = null;
34884 this._preventDefaultSubscription = null;
34885 this._rotateSubscription = null;
34887 DragPanHandler.prototype._getConfiguration = function (enable) {
34888 return { dragPan: enable };
34890 DragPanHandler.prototype._drainBuffer = function (buffer) {
34892 var now = Date.now();
34893 while (buffer.length > 0 && now - buffer[0][0] > cutoff) {
34898 return DragPanHandler;
34899 }(Component_1.HandlerBase));
34900 exports.DragPanHandler = DragPanHandler;
34901 exports.default = DragPanHandler;
34903 },{"../../Component":291,"rxjs":43,"rxjs/operators":241}],344:[function(require,module,exports){
34905 var __extends = (this && this.__extends) || (function () {
34906 var extendStatics = function (d, b) {
34907 extendStatics = Object.setPrototypeOf ||
34908 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34909 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34910 return extendStatics(d, b);
34912 return function (d, b) {
34913 extendStatics(d, b);
34914 function __() { this.constructor = d; }
34915 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34918 Object.defineProperty(exports, "__esModule", { value: true });
34919 exports.EarthControlHandler = void 0;
34920 var THREE = require("three");
34921 var rxjs_1 = require("rxjs");
34922 var operators_1 = require("rxjs/operators");
34923 var Component_1 = require("../../Component");
34924 var State_1 = require("../../State");
34925 var EarthControlHandler = /** @class */ (function (_super) {
34926 __extends(EarthControlHandler, _super);
34927 function EarthControlHandler(component, container, navigator, viewportCoords, spatial) {
34928 var _this = _super.call(this, component, container, navigator) || this;
34929 _this._spatial = spatial;
34930 _this._viewportCoords = viewportCoords;
34933 EarthControlHandler.prototype._enable = function () {
34935 var earth$ = this._navigator.stateService.state$.pipe(operators_1.map(function (state) {
34936 return state === State_1.State.Earth;
34937 }), operators_1.share());
34938 this._preventDefaultSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
34940 _this._container.mouseService.mouseWheel$ :
34943 .subscribe(function (event) {
34944 event.preventDefault();
34946 this._truckSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
34948 return rxjs_1.empty();
34950 return Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService).pipe(operators_1.filter(function (_a) {
34951 var e1 = _a[0], e2 = _a[1];
34952 return !(e1.ctrlKey && e2.ctrlKey);
34954 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
34955 var _b = _a[0], previous = _b[0], current = _b[1], render = _a[1], transform = _a[2];
34956 var planeNormal = [0, 0, 1];
34957 var planePoint = transform.unprojectBasic([0.5, 0.5], 0);
34958 planePoint[2] -= 2;
34959 var currentIntersection = _this._planeIntersection(current, planeNormal, planePoint, render.perspective, _this._container.element);
34960 var previousIntersection = _this._planeIntersection(previous, planeNormal, planePoint, render.perspective, _this._container.element);
34961 if (!currentIntersection || !previousIntersection) {
34964 var direction = new THREE.Vector3()
34965 .subVectors(currentIntersection, previousIntersection)
34966 .multiplyScalar(-1)
34969 }), operators_1.filter(function (direction) {
34970 return !!direction;
34972 .subscribe(function (direction) {
34973 _this._navigator.stateService.truck(direction);
34975 this._orbitSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
34977 return rxjs_1.empty();
34979 return Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService).pipe(operators_1.filter(function (_a) {
34980 var e1 = _a[0], e2 = _a[1];
34981 return e1.ctrlKey && e2.ctrlKey;
34983 }), operators_1.map(function (_a) {
34984 var previous = _a[0], current = _a[1];
34985 var _b = _this._eventToViewport(current, _this._container.element), currentX = _b[0], currentY = _b[1];
34986 var _c = _this._eventToViewport(previous, _this._container.element), previousX = _c[0], previousY = _c[1];
34987 var phi = (previousX - currentX) * Math.PI;
34988 var theta = (currentY - previousY) * Math.PI / 2;
34989 return { phi: phi, theta: theta };
34991 .subscribe(function (rotation) {
34992 _this._navigator.stateService.orbit(rotation);
34994 this._dollySubscription = earth$.pipe(operators_1.switchMap(function (earth) {
34996 return rxjs_1.empty();
34998 return _this._container.mouseService
34999 .filteredWheel$(_this._component.name, _this._container.mouseService.mouseWheel$);
35000 }), operators_1.map(function (event) {
35001 var delta = event.deltaY;
35002 if (event.deltaMode === 1) {
35003 delta = 40 * delta;
35005 else if (event.deltaMode === 2) {
35006 delta = 800 * delta;
35008 var canvasSize = _this._viewportCoords.containerToCanvas(_this._container.element);
35009 return -delta / canvasSize[1];
35011 .subscribe(function (delta) {
35012 _this._navigator.stateService.dolly(delta);
35015 EarthControlHandler.prototype._disable = function () {
35016 this._dollySubscription.unsubscribe();
35017 this._orbitSubscription.unsubscribe();
35018 this._preventDefaultSubscription.unsubscribe();
35019 this._truckSubscription.unsubscribe();
35021 EarthControlHandler.prototype._getConfiguration = function () {
35024 EarthControlHandler.prototype._eventToViewport = function (event, element) {
35025 var previousCanvas = this._viewportCoords.canvasPosition(event, element);
35026 return this._viewportCoords.canvasToViewport(previousCanvas[0], previousCanvas[1], element);
35028 EarthControlHandler.prototype._planeIntersection = function (event, planeNormal, planePoint, camera, element) {
35029 var _a = this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
35030 var direction = this._viewportCoords
35031 .unprojectFromCanvas(canvasX, canvasY, element, camera)
35032 .sub(camera.position)
35034 if (Math.abs(this._spatial.angleToPlane(direction.toArray(), planeNormal)) < Math.PI / 90) {
35037 var l0 = camera.position.clone();
35038 var n = new THREE.Vector3().fromArray(planeNormal);
35039 var p0 = new THREE.Vector3().fromArray(planePoint);
35040 var d = new THREE.Vector3().subVectors(p0, l0).dot(n) / direction.clone().dot(n);
35041 var intersection = new THREE.Vector3().addVectors(l0, direction.multiplyScalar(d));
35042 if (this._viewportCoords.worldToCamera(intersection.toArray(), camera)[2] > 0) {
35045 return intersection;
35047 return EarthControlHandler;
35048 }(Component_1.HandlerBase));
35049 exports.EarthControlHandler = EarthControlHandler;
35050 exports.default = EarthControlHandler;
35052 },{"../../Component":291,"../../State":298,"rxjs":43,"rxjs/operators":241,"three":242}],345:[function(require,module,exports){
35054 Object.defineProperty(exports, "__esModule", { value: true });
35056 },{}],346:[function(require,module,exports){
35058 Object.defineProperty(exports, "__esModule", { value: true });
35059 exports.viewportDistances = void 0;
35060 var Geo_1 = require("../../../src/Geo");
35061 function basicBoundaryPoints(pointsPerSide) {
35063 var os = [[0, 0], [1, 0], [1, 1], [0, 1]];
35064 var ds = [[1, 0], [0, 1], [-1, 0], [0, -1]];
35065 for (var side = 0; side < 4; ++side) {
35068 for (var i = 0; i < pointsPerSide; ++i) {
35069 points.push([o[0] + d[0] * i / pointsPerSide,
35070 o[1] + d[1] * i / pointsPerSide]);
35075 function insideViewport(x, y) {
35076 return x >= -1 && x <= 1 && y >= -1 && y <= 1;
35078 function insideBasic(x, y) {
35079 return x >= 0 && x <= 1 && y >= 0 && y <= 1;
35081 function viewportDistances(transform, perspective, viewportCoords) {
35082 var boundaryPointsBasic = basicBoundaryPoints(100);
35083 var boundaryPointsViewport = boundaryPointsBasic
35084 .map(function (basic) {
35085 return viewportCoords.basicToViewportSafe(basic[0], basic[1], transform, perspective);
35087 var visibleBoundaryPoints = [];
35088 var viewportSides = [
35094 var intersections = [false, false, false, false];
35095 for (var i = 0; i < boundaryPointsViewport.length; i++) {
35096 var p1 = boundaryPointsViewport[i];
35097 var p2 = boundaryPointsViewport[(i + 1) % boundaryPointsViewport.length];
35102 if (insideViewport(p1[0], p1[1])) {
35103 visibleBoundaryPoints.push(p1);
35107 var x1 = p1[0], y1 = p1[1];
35108 var x2 = p2[0], y2 = p2[1];
35109 if (insideViewport(x1, y1)) {
35110 if (insideViewport(x2, y2)) {
35111 visibleBoundaryPoints.push(p1);
35114 for (var side = 0; side < 4; side++) {
35115 var s1 = { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } };
35116 var s2 = { p1: viewportSides[side], p2: viewportSides[(side + 1) % 4] };
35117 var intersecting = Geo_1.Lines.segmentsIntersect(s1, s2);
35118 if (intersecting) {
35119 var intersection = Geo_1.Lines.segmentIntersection(s1, s2);
35120 visibleBoundaryPoints.push(p1, [intersection.x, intersection.y]);
35121 intersections[side] = true;
35127 var _a = viewportCoords.viewportToBasic(-1, 1, transform, perspective), topLeftBasicX = _a[0], topLeftBasicY = _a[1];
35128 var _b = viewportCoords.viewportToBasic(1, 1, transform, perspective), topRightBasicX = _b[0], topRightBasicY = _b[1];
35129 var _c = viewportCoords.viewportToBasic(1, -1, transform, perspective), bottomRightBasicX = _c[0], bottomRightBasicY = _c[1];
35130 var _d = viewportCoords.viewportToBasic(-1, -1, transform, perspective), bottomLeftBasicX = _d[0], bottomLeftBasicY = _d[1];
35131 if (insideBasic(topLeftBasicX, topLeftBasicY)) {
35132 intersections[3] = intersections[0] = true;
35134 if (insideBasic(topRightBasicX, topRightBasicY)) {
35135 intersections[0] = intersections[1] = true;
35137 if (insideBasic(bottomRightBasicX, bottomRightBasicY)) {
35138 intersections[1] = intersections[2] = true;
35140 if (insideBasic(bottomLeftBasicX, bottomLeftBasicY)) {
35141 intersections[2] = intersections[3] = true;
35143 var maximums = [-1, -1, 1, 1];
35144 for (var _i = 0, visibleBoundaryPoints_1 = visibleBoundaryPoints; _i < visibleBoundaryPoints_1.length; _i++) {
35145 var visibleBoundaryPoint = visibleBoundaryPoints_1[_i];
35146 var x = visibleBoundaryPoint[0];
35147 var y = visibleBoundaryPoint[1];
35148 if (x > maximums[1]) {
35151 if (x < maximums[3]) {
35154 if (y > maximums[0]) {
35157 if (y < maximums[2]) {
35161 var boundary = [1, 1, -1, -1];
35162 var distances = [];
35163 for (var side = 0; side < 4; side++) {
35164 if (intersections[side]) {
35168 distances.push(Math.abs(boundary[side] - maximums[side]));
35172 exports.viewportDistances = viewportDistances;
35174 },{"../../../src/Geo":294}],347:[function(require,module,exports){
35176 var __extends = (this && this.__extends) || (function () {
35177 var extendStatics = function (d, b) {
35178 extendStatics = Object.setPrototypeOf ||
35179 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35180 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35181 return extendStatics(d, b);
35183 return function (d, b) {
35184 extendStatics(d, b);
35185 function __() { this.constructor = d; }
35186 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35189 Object.defineProperty(exports, "__esModule", { value: true });
35190 exports.MouseComponent = void 0;
35191 var Component_1 = require("../../Component");
35192 var Geo_1 = require("../../Geo");
35194 * @class MouseComponent
35196 * @classdesc Component handling mouse and touch events for camera movement.
35198 * To retrive and use the mouse component
35202 * var viewer = new Mapillary.Viewer(
35207 * var mouseComponent = viewer.getComponent("mouse");
35210 var MouseComponent = /** @class */ (function (_super) {
35211 __extends(MouseComponent, _super);
35213 function MouseComponent(name, container, navigator) {
35214 var _this = _super.call(this, name, container, navigator) || this;
35215 var spatial = new Geo_1.Spatial();
35216 var viewportCoords = new Geo_1.ViewportCoords();
35217 _this._bounceHandler = new Component_1.BounceHandler(_this, container, navigator, viewportCoords, spatial);
35218 _this._doubleClickZoomHandler = new Component_1.DoubleClickZoomHandler(_this, container, navigator, viewportCoords);
35219 _this._dragPanHandler = new Component_1.DragPanHandler(_this, container, navigator, viewportCoords, spatial);
35220 _this._earthControlHandler = new Component_1.EarthControlHandler(_this, container, navigator, viewportCoords, spatial);
35221 _this._scrollZoomHandler = new Component_1.ScrollZoomHandler(_this, container, navigator, viewportCoords);
35222 _this._touchZoomHandler = new Component_1.TouchZoomHandler(_this, container, navigator, viewportCoords);
35225 Object.defineProperty(MouseComponent.prototype, "doubleClickZoom", {
35227 * Get double click zoom.
35229 * @returns {DoubleClickZoomHandler} The double click zoom handler.
35232 return this._doubleClickZoomHandler;
35237 Object.defineProperty(MouseComponent.prototype, "dragPan", {
35241 * @returns {DragPanHandler} The drag pan handler.
35244 return this._dragPanHandler;
35249 Object.defineProperty(MouseComponent.prototype, "scrollZoom", {
35253 * @returns {ScrollZoomHandler} The scroll zoom handler.
35256 return this._scrollZoomHandler;
35261 Object.defineProperty(MouseComponent.prototype, "touchZoom", {
35265 * @returns {TouchZoomHandler} The touch zoom handler.
35268 return this._touchZoomHandler;
35273 MouseComponent.prototype._activate = function () {
35275 this._bounceHandler.enable();
35276 this._earthControlHandler.enable();
35277 this._configurationSubscription = this._configuration$
35278 .subscribe(function (configuration) {
35279 if (configuration.doubleClickZoom) {
35280 _this._doubleClickZoomHandler.enable();
35283 _this._doubleClickZoomHandler.disable();
35285 if (configuration.dragPan) {
35286 _this._dragPanHandler.enable();
35289 _this._dragPanHandler.disable();
35291 if (configuration.scrollZoom) {
35292 _this._scrollZoomHandler.enable();
35295 _this._scrollZoomHandler.disable();
35297 if (configuration.touchZoom) {
35298 _this._touchZoomHandler.enable();
35301 _this._touchZoomHandler.disable();
35304 this._container.mouseService.claimMouse(this._name, 0);
35306 MouseComponent.prototype._deactivate = function () {
35307 this._container.mouseService.unclaimMouse(this._name);
35308 this._configurationSubscription.unsubscribe();
35309 this._bounceHandler.disable();
35310 this._doubleClickZoomHandler.disable();
35311 this._dragPanHandler.disable();
35312 this._earthControlHandler.disable();
35313 this._scrollZoomHandler.disable();
35314 this._touchZoomHandler.disable();
35316 MouseComponent.prototype._getDefaultConfiguration = function () {
35317 return { doubleClickZoom: false, dragPan: true, scrollZoom: true, touchZoom: true };
35320 MouseComponent.componentName = "mouse";
35321 return MouseComponent;
35322 }(Component_1.Component));
35323 exports.MouseComponent = MouseComponent;
35324 Component_1.ComponentService.register(MouseComponent);
35325 exports.default = MouseComponent;
35327 },{"../../Component":291,"../../Geo":294}],348:[function(require,module,exports){
35329 var __extends = (this && this.__extends) || (function () {
35330 var extendStatics = function (d, b) {
35331 extendStatics = Object.setPrototypeOf ||
35332 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35333 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35334 return extendStatics(d, b);
35336 return function (d, b) {
35337 extendStatics(d, b);
35338 function __() { this.constructor = d; }
35339 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35342 Object.defineProperty(exports, "__esModule", { value: true });
35343 exports.ScrollZoomHandler = void 0;
35344 var operators_1 = require("rxjs/operators");
35345 var Component_1 = require("../../Component");
35347 * The `ScrollZoomHandler` allows the user to zoom the viewer image by scrolling.
35351 * var mouseComponent = viewer.getComponent("mouse");
35353 * mouseComponent.scrollZoom.disable();
35354 * mouseComponent.scrollZoom.enable();
35356 * var isEnabled = mouseComponent.scrollZoom.isEnabled;
35359 var ScrollZoomHandler = /** @class */ (function (_super) {
35360 __extends(ScrollZoomHandler, _super);
35362 function ScrollZoomHandler(component, container, navigator, viewportCoords) {
35363 var _this = _super.call(this, component, container, navigator) || this;
35364 _this._viewportCoords = viewportCoords;
35367 ScrollZoomHandler.prototype._enable = function () {
35369 this._container.mouseService.claimWheel(this._component.name, 0);
35370 this._preventDefaultSubscription = this._container.mouseService.mouseWheel$
35371 .subscribe(function (event) {
35372 event.preventDefault();
35374 this._zoomSubscription = this._container.mouseService
35375 .filteredWheel$(this._component.name, this._container.mouseService.mouseWheel$).pipe(operators_1.withLatestFrom(this._navigator.stateService.currentState$, function (w, f) {
35377 }), operators_1.filter(function (args) {
35378 var state = args[1].state;
35379 return state.currentNode.fullPano || state.nodesAhead < 1;
35380 }), operators_1.map(function (args) {
35382 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, function (w, r, t) {
35385 .subscribe(function (args) {
35386 var event = args[0];
35387 var render = args[1];
35388 var transform = args[2];
35389 var element = _this._container.element;
35390 var _a = _this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
35391 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
35392 var reference = transform.projectBasic(unprojected.toArray());
35393 var deltaY = event.deltaY;
35394 if (event.deltaMode === 1) {
35395 deltaY = 40 * deltaY;
35397 else if (event.deltaMode === 2) {
35398 deltaY = 800 * deltaY;
35400 var canvasSize = _this._viewportCoords.containerToCanvas(element);
35401 var zoom = -3 * deltaY / canvasSize[1];
35402 _this._navigator.stateService.zoomIn(zoom, reference);
35405 ScrollZoomHandler.prototype._disable = function () {
35406 this._container.mouseService.unclaimWheel(this._component.name);
35407 this._preventDefaultSubscription.unsubscribe();
35408 this._zoomSubscription.unsubscribe();
35409 this._preventDefaultSubscription = null;
35410 this._zoomSubscription = null;
35412 ScrollZoomHandler.prototype._getConfiguration = function (enable) {
35413 return { scrollZoom: enable };
35415 return ScrollZoomHandler;
35416 }(Component_1.HandlerBase));
35417 exports.ScrollZoomHandler = ScrollZoomHandler;
35418 exports.default = ScrollZoomHandler;
35420 },{"../../Component":291,"rxjs/operators":241}],349:[function(require,module,exports){
35422 var __extends = (this && this.__extends) || (function () {
35423 var extendStatics = function (d, b) {
35424 extendStatics = Object.setPrototypeOf ||
35425 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35426 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35427 return extendStatics(d, b);
35429 return function (d, b) {
35430 extendStatics(d, b);
35431 function __() { this.constructor = d; }
35432 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35435 Object.defineProperty(exports, "__esModule", { value: true });
35436 exports.TouchZoomHandler = void 0;
35437 var rxjs_1 = require("rxjs");
35438 var operators_1 = require("rxjs/operators");
35439 var Component_1 = require("../../Component");
35441 * The `TouchZoomHandler` allows the user to zoom the viewer image by pinching on a touchscreen.
35445 * var mouseComponent = viewer.getComponent("mouse");
35447 * mouseComponent.touchZoom.disable();
35448 * mouseComponent.touchZoom.enable();
35450 * var isEnabled = mouseComponent.touchZoom.isEnabled;
35453 var TouchZoomHandler = /** @class */ (function (_super) {
35454 __extends(TouchZoomHandler, _super);
35456 function TouchZoomHandler(component, container, navigator, viewportCoords) {
35457 var _this = _super.call(this, component, container, navigator) || this;
35458 _this._viewportCoords = viewportCoords;
35461 TouchZoomHandler.prototype._enable = function () {
35463 this._preventDefaultSubscription = this._container.touchService.pinch$
35464 .subscribe(function (pinch) {
35465 pinch.originalEvent.preventDefault();
35467 var pinchStarted$ = this._container.touchService.pinchStart$.pipe(operators_1.map(function (event) {
35470 var pinchStopped$ = this._container.touchService.pinchEnd$.pipe(operators_1.map(function (event) {
35473 this._activeSubscription = rxjs_1.merge(pinchStarted$, pinchStopped$)
35474 .subscribe(this._container.touchService.activate$);
35475 this._zoomSubscription = this._container.touchService.pinch$.pipe(operators_1.withLatestFrom(this._navigator.stateService.currentState$), operators_1.filter(function (args) {
35476 var state = args[1].state;
35477 return state.currentNode.fullPano || state.nodesAhead < 1;
35478 }), operators_1.map(function (args) {
35480 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
35481 .subscribe(function (_a) {
35482 var pinch = _a[0], render = _a[1], transform = _a[2];
35483 var element = _this._container.element;
35484 var _b = _this._viewportCoords.canvasPosition(pinch, element), canvasX = _b[0], canvasY = _b[1];
35485 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
35486 var reference = transform.projectBasic(unprojected.toArray());
35487 var _c = _this._viewportCoords.containerToCanvas(element), canvasWidth = _c[0], canvasHeight = _c[1];
35488 var zoom = 3 * pinch.distanceChange / Math.min(canvasWidth, canvasHeight);
35489 _this._navigator.stateService.zoomIn(zoom, reference);
35492 TouchZoomHandler.prototype._disable = function () {
35493 this._activeSubscription.unsubscribe();
35494 this._preventDefaultSubscription.unsubscribe();
35495 this._zoomSubscription.unsubscribe();
35496 this._preventDefaultSubscription = null;
35497 this._zoomSubscription = null;
35499 TouchZoomHandler.prototype._getConfiguration = function (enable) {
35500 return { touchZoom: enable };
35502 return TouchZoomHandler;
35503 }(Component_1.HandlerBase));
35504 exports.TouchZoomHandler = TouchZoomHandler;
35505 exports.default = TouchZoomHandler;
35507 },{"../../Component":291,"rxjs":43,"rxjs/operators":241}],350:[function(require,module,exports){
35509 Object.defineProperty(exports, "__esModule", { value: true });
35510 var Popup_1 = require("./popup/Popup");
35511 Object.defineProperty(exports, "Popup", { enumerable: true, get: function () { return Popup_1.Popup; } });
35512 var PopupComponent_1 = require("./PopupComponent");
35513 Object.defineProperty(exports, "PopupComponent", { enumerable: true, get: function () { return PopupComponent_1.PopupComponent; } });
35515 },{"./PopupComponent":351,"./popup/Popup":352}],351:[function(require,module,exports){
35517 var __extends = (this && this.__extends) || (function () {
35518 var extendStatics = function (d, b) {
35519 extendStatics = Object.setPrototypeOf ||
35520 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35521 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35522 return extendStatics(d, b);
35524 return function (d, b) {
35525 extendStatics(d, b);
35526 function __() { this.constructor = d; }
35527 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35530 Object.defineProperty(exports, "__esModule", { value: true });
35531 exports.PopupComponent = void 0;
35532 var rxjs_1 = require("rxjs");
35533 var operators_1 = require("rxjs/operators");
35534 var Component_1 = require("../../Component");
35535 var Utils_1 = require("../../Utils");
35537 * @class PopupComponent
35539 * @classdesc Component for showing HTML popup objects.
35541 * The `add` method is used for adding new popups. Popups are removed by reference.
35543 * It is not possible to update popups in the set by updating any properties
35544 * directly on the popup object. Popups need to be replaced by
35545 * removing them and creating new ones with relevant changed properties and
35546 * adding those instead.
35548 * Popups are only relevant to a single image because they are based on
35549 * 2D basic image coordinates. Popups related to a certain image should
35550 * be removed when the viewer is moved to another node.
35552 * To retrive and use the popup component
35556 * var viewer = new Mapillary.Viewer(
35560 * { component: { popup: true } });
35562 * var popupComponent = viewer.getComponent("popup");
35565 var PopupComponent = /** @class */ (function (_super) {
35566 __extends(PopupComponent, _super);
35568 function PopupComponent(name, container, navigator, dom) {
35569 var _this = _super.call(this, name, container, navigator) || this;
35570 _this._dom = !!dom ? dom : new Utils_1.DOM();
35571 _this._popups = [];
35572 _this._added$ = new rxjs_1.Subject();
35573 _this._popups$ = new rxjs_1.Subject();
35577 * Add popups to the popups set.
35579 * @description Adding a new popup never replaces an old one
35580 * because they are stored by reference. Adding an already
35581 * existing popup has no effect.
35583 * @param {Array<Popup>} popups - Popups to add.
35585 * @example ```popupComponent.add([popup1, popup2]);```
35587 PopupComponent.prototype.add = function (popups) {
35588 for (var _i = 0, popups_1 = popups; _i < popups_1.length; _i++) {
35589 var popup = popups_1[_i];
35590 if (this._popups.indexOf(popup) !== -1) {
35593 this._popups.push(popup);
35594 if (this._activated) {
35595 popup.setParentContainer(this._popupContainer);
35598 this._added$.next(popups);
35599 this._popups$.next(this._popups);
35602 * Returns an array of all popups.
35604 * @example ```var popups = popupComponent.getAll();```
35606 PopupComponent.prototype.getAll = function () {
35607 return this._popups.slice();
35610 * Remove popups based on reference from the popup set.
35612 * @param {Array<Popup>} popups - Popups to remove.
35614 * @example ```popupComponent.remove([popup1, popup2]);```
35616 PopupComponent.prototype.remove = function (popups) {
35617 for (var _i = 0, popups_2 = popups; _i < popups_2.length; _i++) {
35618 var popup = popups_2[_i];
35619 this._remove(popup);
35621 this._popups$.next(this._popups);
35624 * Remove all popups from the popup set.
35626 * @example ```popupComponent.removeAll();```
35628 PopupComponent.prototype.removeAll = function () {
35629 for (var _i = 0, _a = this._popups.slice(); _i < _a.length; _i++) {
35630 var popup = _a[_i];
35631 this._remove(popup);
35633 this._popups$.next(this._popups);
35635 PopupComponent.prototype._activate = function () {
35637 this._popupContainer = this._dom.createElement("div", "mapillary-js-popup-container", this._container.element);
35638 for (var _i = 0, _a = this._popups; _i < _a.length; _i++) {
35639 var popup = _a[_i];
35640 popup.setParentContainer(this._popupContainer);
35642 this._updateAllSubscription = rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._container.renderService.size$, this._navigator.stateService.currentTransform$)
35643 .subscribe(function (_a) {
35644 var renderCamera = _a[0], size = _a[1], transform = _a[2];
35645 for (var _i = 0, _b = _this._popups; _i < _b.length; _i++) {
35646 var popup = _b[_i];
35647 popup.update(renderCamera, size, transform);
35650 var changed$ = this._popups$.pipe(operators_1.startWith(this._popups), operators_1.switchMap(function (popups) {
35651 return rxjs_1.from(popups).pipe(operators_1.mergeMap(function (popup) {
35652 return popup.changed$;
35654 }), operators_1.map(function (popup) {
35657 this._updateAddedChangedSubscription = rxjs_1.merge(this._added$, changed$).pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._container.renderService.size$, this._navigator.stateService.currentTransform$))
35658 .subscribe(function (_a) {
35659 var popups = _a[0], renderCamera = _a[1], size = _a[2], transform = _a[3];
35660 for (var _i = 0, popups_3 = popups; _i < popups_3.length; _i++) {
35661 var popup = popups_3[_i];
35662 popup.update(renderCamera, size, transform);
35666 PopupComponent.prototype._deactivate = function () {
35667 this._updateAllSubscription.unsubscribe();
35668 this._updateAddedChangedSubscription.unsubscribe();
35669 for (var _i = 0, _a = this._popups; _i < _a.length; _i++) {
35670 var popup = _a[_i];
35673 this._container.element.removeChild(this._popupContainer);
35674 delete this._popupContainer;
35676 PopupComponent.prototype._getDefaultConfiguration = function () {
35679 PopupComponent.prototype._remove = function (popup) {
35680 var index = this._popups.indexOf(popup);
35681 if (index === -1) {
35684 var removed = this._popups.splice(index, 1)[0];
35685 if (this._activated) {
35689 PopupComponent.componentName = "popup";
35690 return PopupComponent;
35691 }(Component_1.Component));
35692 exports.PopupComponent = PopupComponent;
35693 Component_1.ComponentService.register(PopupComponent);
35694 exports.default = PopupComponent;
35696 },{"../../Component":291,"../../Utils":301,"rxjs":43,"rxjs/operators":241}],352:[function(require,module,exports){
35698 Object.defineProperty(exports, "__esModule", { value: true });
35699 exports.Popup = void 0;
35700 var rxjs_1 = require("rxjs");
35701 var Geo_1 = require("../../../Geo");
35702 var Utils_1 = require("../../../Utils");
35703 var Viewer_1 = require("../../../Viewer");
35707 * @classdesc Popup instance for rendering custom HTML content
35708 * on top of images. Popups are based on 2D basic image coordinates
35709 * (see the {@link Viewer} class documentation for more information about coordinate
35710 * systems) and a certain popup is therefore only relevant to a single image.
35711 * Popups related to a certain image should be removed when moving
35712 * to another image.
35714 * A popup must have both its content and its point or rect set to be
35715 * rendered. Popup options can not be updated after creation but the
35716 * basic point or rect as well as its content can be changed by calling
35717 * the appropriate methods.
35719 * To create and add one `Popup` with default configuration
35720 * (tooltip visuals and automatic float) and one with specific options
35725 * var defaultSpan = document.createElement('span');
35726 * defaultSpan.innerHTML = 'hello default';
35728 * var defaultPopup = new Mapillary.PopupComponent.Popup();
35729 * defaultPopup.setDOMContent(defaultSpan);
35730 * defaultPopup.setBasicPoint([0.3, 0.3]);
35732 * var cleanSpan = document.createElement('span');
35733 * cleanSpan.innerHTML = 'hello clean';
35735 * var cleanPopup = new Mapillary.PopupComponent.Popup({
35737 * float: Mapillary.Alignment.Top,
35742 * cleanPopup.setDOMContent(cleanSpan);
35743 * cleanPopup.setBasicPoint([0.6, 0.6]);
35745 * popupComponent.add([defaultPopup, cleanPopup]);
35748 * @description Implementation of API methods and API documentation inspired
35749 * by/used from https://github.com/mapbox/mapbox-gl-js/blob/v0.38.0/src/ui/popup.js
35751 var Popup = /** @class */ (function () {
35752 function Popup(options, viewportCoords, dom) {
35753 this._options = {};
35754 options = !!options ? options : {};
35755 this._options.capturePointer = options.capturePointer === false ?
35756 options.capturePointer : true;
35757 this._options.clean = options.clean;
35758 this._options.float = options.float;
35759 this._options.offset = options.offset;
35760 this._options.opacity = options.opacity;
35761 this._options.position = options.position;
35762 this._dom = !!dom ? dom : new Utils_1.DOM();
35763 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
35764 this._notifyChanged$ = new rxjs_1.Subject();
35766 Object.defineProperty(Popup.prototype, "changed$", {
35768 * @description Internal observable used by the component to
35769 * render the popup when its position or content has changed.
35773 return this._notifyChanged$;
35779 * @description Internal method used by the component to
35780 * remove all references to the popup.
35783 Popup.prototype.remove = function () {
35784 if (this._content && this._content.parentNode) {
35785 this._content.parentNode.removeChild(this._content);
35787 if (this._container) {
35788 this._container.parentNode.removeChild(this._container);
35789 delete this._container;
35791 if (this._parentContainer) {
35792 delete this._parentContainer;
35796 * Sets a 2D basic image coordinates point to the popup's anchor, and
35797 * moves the popup to it.
35799 * @description Overwrites any previously set point or rect.
35801 * @param {Array<number>} basicPoint - Point in 2D basic image coordinates.
35805 * var popup = new Mapillary.PopupComponent.Popup();
35806 * popup.setText('hello image');
35807 * popup.setBasicPoint([0.3, 0.3]);
35809 * popupComponent.add([popup]);
35812 Popup.prototype.setBasicPoint = function (basicPoint) {
35813 this._point = basicPoint.slice();
35815 this._notifyChanged$.next(this);
35818 * Sets a 2D basic image coordinates rect to the popup's anchor, and
35819 * moves the popup to it.
35821 * @description Overwrites any previously set point or rect.
35823 * @param {Array<number>} basicRect - Rect in 2D basic image
35824 * coordinates ([topLeftX, topLeftY, bottomRightX, bottomRightY]) .
35828 * var popup = new Mapillary.PopupComponent.Popup();
35829 * popup.setText('hello image');
35830 * popup.setBasicRect([0.3, 0.3, 0.5, 0.6]);
35832 * popupComponent.add([popup]);
35835 Popup.prototype.setBasicRect = function (basicRect) {
35836 this._rect = basicRect.slice();
35837 this._point = null;
35838 this._notifyChanged$.next(this);
35841 * Sets the popup's content to the element provided as a DOM node.
35843 * @param {Node} htmlNode - A DOM node to be used as content for the popup.
35847 * var div = document.createElement('div');
35848 * div.innerHTML = 'hello image';
35850 * var popup = new Mapillary.PopupComponent.Popup();
35851 * popup.setDOMContent(div);
35852 * popup.setBasicPoint([0.3, 0.3]);
35854 * popupComponent.add([popup]);
35857 Popup.prototype.setDOMContent = function (htmlNode) {
35858 if (this._content && this._content.parentNode) {
35859 this._content.parentNode.removeChild(this._content);
35861 var className = "mapillaryjs-popup-content" +
35862 (this._options.clean === true ? "-clean" : "") +
35863 (this._options.capturePointer === true ? " mapillaryjs-popup-capture-pointer" : "");
35864 this._content = this._dom.createElement("div", className, this._container);
35865 this._content.appendChild(htmlNode);
35866 this._notifyChanged$.next(this);
35869 * Sets the popup's content to the HTML provided as a string.
35871 * @description This method does not perform HTML filtering or sanitization,
35872 * and must be used only with trusted content. Consider Popup#setText if the
35873 * content is an untrusted text string.
35875 * @param {string} html - A string representing HTML content for the popup.
35879 * var popup = new Mapillary.PopupComponent.Popup();
35880 * popup.setHTML('<div>hello image</div>');
35881 * popup.setBasicPoint([0.3, 0.3]);
35883 * popupComponent.add([popup]);
35886 Popup.prototype.setHTML = function (html) {
35887 var frag = this._dom.document.createDocumentFragment();
35888 var temp = this._dom.createElement("body");
35890 temp.innerHTML = html;
35892 child = temp.firstChild;
35896 frag.appendChild(child);
35898 this.setDOMContent(frag);
35901 * Sets the popup's content to a string of text.
35903 * @description This function creates a Text node in the DOM, so it cannot insert raw HTML.
35904 * Use this method for security against XSS if the popup content is user-provided.
35906 * @param {string} text - Textual content for the popup.
35910 * var popup = new Mapillary.PopupComponent.Popup();
35911 * popup.setText('hello image');
35912 * popup.setBasicPoint([0.3, 0.3]);
35914 * popupComponent.add([popup]);
35917 Popup.prototype.setText = function (text) {
35918 this.setDOMContent(this._dom.document.createTextNode(text));
35921 * @description Internal method for attaching the popup to
35922 * its parent container so that it is rendered in the DOM tree.
35925 Popup.prototype.setParentContainer = function (parentContainer) {
35926 this._parentContainer = parentContainer;
35929 * @description Internal method for updating the rendered
35930 * position of the popup called by the popup component.
35933 Popup.prototype.update = function (renderCamera, size, transform) {
35935 if (!this._parentContainer || !this._content) {
35938 if (!this._point && !this._rect) {
35941 if (!this._container) {
35942 this._container = this._dom.createElement("div", "mapillaryjs-popup", this._parentContainer);
35943 var showTip = this._options.clean !== true &&
35944 this._options.float !== Viewer_1.Alignment.Center;
35946 var tipClassName = "mapillaryjs-popup-tip" +
35947 (this._options.capturePointer === true ? " mapillaryjs-popup-capture-pointer" : "");
35948 this._tip = this._dom.createElement("div", tipClassName, this._container);
35949 this._dom.createElement("div", "mapillaryjs-popup-tip-inner", this._tip);
35951 this._container.appendChild(this._content);
35952 this._parentContainer.appendChild(this._container);
35953 if (this._options.opacity != null) {
35954 this._container.style.opacity = this._options.opacity.toString();
35957 var pointPixel = null;
35958 var position = this._alignmentToPopupAligment(this._options.position);
35959 var float = this._alignmentToPopupAligment(this._options.float);
35960 var classList = this._container.classList;
35961 if (this._point != null) {
35963 this._viewportCoords.basicToCanvasSafe(this._point[0], this._point[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
35966 var alignments = ["center", "top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"];
35967 var appliedPosition = null;
35968 for (var _i = 0, alignments_1 = alignments; _i < alignments_1.length; _i++) {
35969 var alignment = alignments_1[_i];
35970 if (classList.contains("mapillaryjs-popup-float-" + alignment)) {
35971 appliedPosition = alignment;
35975 _a = this._rectToPixel(this._rect, position, appliedPosition, renderCamera, size, transform), pointPixel = _a[0], position = _a[1];
35980 if (pointPixel == null) {
35981 this._container.style.display = "none";
35984 this._container.style.display = "";
35986 var width = this._container.offsetWidth;
35987 var height = this._container.offsetHeight;
35988 var floats = this._pixelToFloats(pointPixel, size, width, height);
35989 float = floats.length === 0 ? "top" : floats.join("-");
35991 var offset = this._normalizeOffset(this._options.offset);
35992 pointPixel = [pointPixel[0] + offset[float][0], pointPixel[1] + offset[float][1]];
35993 pointPixel = [Math.round(pointPixel[0]), Math.round(pointPixel[1])];
35994 var floatTranslate = {
35995 "bottom": "translate(-50%,0)",
35996 "bottom-left": "translate(-100%,0)",
35997 "bottom-right": "translate(0,0)",
35998 "center": "translate(-50%,-50%)",
35999 "left": "translate(-100%,-50%)",
36000 "right": "translate(0,-50%)",
36001 "top": "translate(-50%,-100%)",
36002 "top-left": "translate(-100%,-100%)",
36003 "top-right": "translate(0,-100%)",
36005 for (var key in floatTranslate) {
36006 if (!floatTranslate.hasOwnProperty(key)) {
36009 classList.remove("mapillaryjs-popup-float-" + key);
36011 classList.add("mapillaryjs-popup-float-" + float);
36012 this._container.style.transform = floatTranslate[float] + " translate(" + pointPixel[0] + "px," + pointPixel[1] + "px)";
36014 Popup.prototype._rectToPixel = function (rect, position, appliedPosition, renderCamera, size, transform) {
36016 var width = this._container.offsetWidth;
36017 var height = this._container.offsetHeight;
36018 var floatOffsets = {
36019 "bottom": [0, height / 2],
36020 "bottom-left": [-width / 2, height / 2],
36021 "bottom-right": [width / 2, height / 2],
36022 "left": [-width / 2, 0],
36023 "right": [width / 2, 0],
36024 "top": [0, -height / 2],
36025 "top-left": [-width / 2, -height / 2],
36026 "top-right": [width / 2, -height / 2],
36028 var automaticPositions = ["top", "bottom", "left", "right"];
36029 var largestVisibleArea = [0, null, null];
36030 for (var _i = 0, automaticPositions_1 = automaticPositions; _i < automaticPositions_1.length; _i++) {
36031 var automaticPosition = automaticPositions_1[_i];
36032 var autoPointBasic = this._pointFromRectPosition(rect, automaticPosition);
36033 var autoPointPixel = this._viewportCoords.basicToCanvasSafe(autoPointBasic[0], autoPointBasic[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
36034 if (autoPointPixel == null) {
36037 var floatOffset = floatOffsets[automaticPosition];
36038 var offsetedPosition = [autoPointPixel[0] + floatOffset[0], autoPointPixel[1] + floatOffset[1]];
36039 var staticCoeff = appliedPosition != null && appliedPosition === automaticPosition ? 1 : 0.7;
36040 var floats = this._pixelToFloats(offsetedPosition, size, width / staticCoeff, height / (2 * staticCoeff));
36041 if (floats.length === 0 &&
36042 autoPointPixel[0] > 0 &&
36043 autoPointPixel[0] < size.width &&
36044 autoPointPixel[1] > 0 &&
36045 autoPointPixel[1] < size.height) {
36046 return [autoPointPixel, automaticPosition];
36048 var minX = Math.max(offsetedPosition[0] - width / 2, 0);
36049 var maxX = Math.min(offsetedPosition[0] + width / 2, size.width);
36050 var minY = Math.max(offsetedPosition[1] - height / 2, 0);
36051 var maxY = Math.min(offsetedPosition[1] + height / 2, size.height);
36052 var visibleX = Math.max(0, maxX - minX);
36053 var visibleY = Math.max(0, maxY - minY);
36054 var visibleArea = staticCoeff * visibleX * visibleY;
36055 if (visibleArea > largestVisibleArea[0]) {
36056 largestVisibleArea[0] = visibleArea;
36057 largestVisibleArea[1] = autoPointPixel;
36058 largestVisibleArea[2] = automaticPosition;
36061 if (largestVisibleArea[0] > 0) {
36062 return [largestVisibleArea[1], largestVisibleArea[2]];
36065 var pointBasic = this._pointFromRectPosition(rect, position);
36066 var pointPixel = this._viewportCoords.basicToCanvasSafe(pointBasic[0], pointBasic[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
36067 return [pointPixel, position != null ? position : "top"];
36069 Popup.prototype._alignmentToPopupAligment = function (float) {
36071 case Viewer_1.Alignment.Bottom:
36073 case Viewer_1.Alignment.BottomLeft:
36074 return "bottom-left";
36075 case Viewer_1.Alignment.BottomRight:
36076 return "bottom-right";
36077 case Viewer_1.Alignment.Center:
36079 case Viewer_1.Alignment.Left:
36081 case Viewer_1.Alignment.Right:
36083 case Viewer_1.Alignment.Top:
36085 case Viewer_1.Alignment.TopLeft:
36087 case Viewer_1.Alignment.TopRight:
36088 return "top-right";
36093 Popup.prototype._normalizeOffset = function (offset) {
36094 if (offset == null) {
36095 return this._normalizeOffset(0);
36097 if (typeof offset === "number") {
36098 // input specifies a radius
36099 var sideOffset = offset;
36100 var sign = sideOffset >= 0 ? 1 : -1;
36101 var cornerOffset = sign * Math.round(Math.sqrt(0.5 * Math.pow(sideOffset, 2)));
36103 "bottom": [0, sideOffset],
36104 "bottom-left": [-cornerOffset, cornerOffset],
36105 "bottom-right": [cornerOffset, cornerOffset],
36107 "left": [-sideOffset, 0],
36108 "right": [sideOffset, 0],
36109 "top": [0, -sideOffset],
36110 "top-left": [-cornerOffset, -cornerOffset],
36111 "top-right": [cornerOffset, -cornerOffset],
36115 // input specifes a value for each position
36117 "bottom": offset.bottom || [0, 0],
36118 "bottom-left": offset.bottomLeft || [0, 0],
36119 "bottom-right": offset.bottomRight || [0, 0],
36120 "center": offset.center || [0, 0],
36121 "left": offset.left || [0, 0],
36122 "right": offset.right || [0, 0],
36123 "top": offset.top || [0, 0],
36124 "top-left": offset.topLeft || [0, 0],
36125 "top-right": offset.topRight || [0, 0],
36129 Popup.prototype._pixelToFloats = function (pointPixel, size, width, height) {
36131 if (pointPixel[1] < height) {
36132 floats.push("bottom");
36134 else if (pointPixel[1] > size.height - height) {
36135 floats.push("top");
36137 if (pointPixel[0] < width / 2) {
36138 floats.push("right");
36140 else if (pointPixel[0] > size.width - width / 2) {
36141 floats.push("left");
36145 Popup.prototype._pointFromRectPosition = function (rect, position) {
36147 var x1 = rect[0] < rect[2] ? rect[2] : rect[2] + 1;
36150 switch (position) {
36152 return [(x0 + x1) / 2, y1];
36153 case "bottom-left":
36155 case "bottom-right":
36158 return [(x0 + x1) / 2, (y0 + y1) / 2];
36160 return [x0, (y0 + y1) / 2];
36162 return [x1, (y0 + y1) / 2];
36164 return [(x0 + x1) / 2, y0];
36170 return [(x0 + x1) / 2, y1];
36175 exports.Popup = Popup;
36176 exports.default = Popup;
36179 },{"../../../Geo":294,"../../../Utils":301,"../../../Viewer":302,"rxjs":43}],353:[function(require,module,exports){
36181 var __extends = (this && this.__extends) || (function () {
36182 var extendStatics = function (d, b) {
36183 extendStatics = Object.setPrototypeOf ||
36184 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36185 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36186 return extendStatics(d, b);
36188 return function (d, b) {
36189 extendStatics(d, b);
36190 function __() { this.constructor = d; }
36191 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36194 Object.defineProperty(exports, "__esModule", { value: true });
36195 exports.SequenceComponent = void 0;
36196 var rxjs_1 = require("rxjs");
36197 var operators_1 = require("rxjs/operators");
36198 var Component_1 = require("../../Component");
36199 var Edge_1 = require("../../Edge");
36200 var Graph_1 = require("../../Graph");
36202 * @class SequenceComponent
36203 * @classdesc Component showing navigation arrows for sequence directions
36204 * as well as playing button. Exposes an API to start and stop play.
36206 var SequenceComponent = /** @class */ (function (_super) {
36207 __extends(SequenceComponent, _super);
36208 function SequenceComponent(name, container, navigator, renderer, scheduler) {
36209 var _this = _super.call(this, name, container, navigator) || this;
36210 _this._sequenceDOMRenderer = !!renderer ? renderer : new Component_1.SequenceDOMRenderer(container);
36211 _this._scheduler = scheduler;
36212 _this._containerWidth$ = new rxjs_1.Subject();
36213 _this._hoveredKeySubject$ = new rxjs_1.Subject();
36214 _this._hoveredKey$ = _this._hoveredKeySubject$.pipe(operators_1.share());
36215 _this._navigator.playService.playing$.pipe(operators_1.skip(1), operators_1.withLatestFrom(_this._configuration$))
36216 .subscribe(function (_a) {
36217 var playing = _a[0], configuration = _a[1];
36218 _this.fire(SequenceComponent.playingchanged, playing);
36219 if (playing === configuration.playing) {
36229 _this._navigator.playService.direction$.pipe(operators_1.skip(1), operators_1.withLatestFrom(_this._configuration$))
36230 .subscribe(function (_a) {
36231 var direction = _a[0], configuration = _a[1];
36232 if (direction !== configuration.direction) {
36233 _this.setDirection(direction);
36238 Object.defineProperty(SequenceComponent.prototype, "hoveredKey$", {
36240 * Get hovered key observable.
36242 * @description An observable emitting the key of the node for the direction
36243 * arrow that is being hovered. When the mouse leaves a direction arrow null
36246 * @returns {Observable<string>}
36249 return this._hoveredKey$;
36257 * @fires PlayerComponent#playingchanged
36259 SequenceComponent.prototype.play = function () {
36260 this.configure({ playing: true });
36265 * @fires PlayerComponent#playingchanged
36267 SequenceComponent.prototype.stop = function () {
36268 this.configure({ playing: false });
36271 * Set the direction to follow when playing.
36273 * @param {EdgeDirection} direction - The direction that will be followed when playing.
36275 SequenceComponent.prototype.setDirection = function (direction) {
36276 this.configure({ direction: direction });
36279 * Set highlight key.
36281 * @description The arrow pointing towards the node corresponding to the
36282 * highlight key will be highlighted.
36284 * @param {string} highlightKey Key of node to be highlighted if existing.
36286 SequenceComponent.prototype.setHighlightKey = function (highlightKey) {
36287 this.configure({ highlightKey: highlightKey });
36290 * Set max width of container element.
36292 * @description Set max width of the container element holding
36293 * the sequence navigation elements. If the min width is larger than the
36294 * max width the min width value will be used.
36296 * The container element is automatically resized when the resize
36297 * method on the Viewer class is called.
36299 * @param {number} minWidth
36301 SequenceComponent.prototype.setMaxWidth = function (maxWidth) {
36302 this.configure({ maxWidth: maxWidth });
36305 * Set min width of container element.
36307 * @description Set min width of the container element holding
36308 * the sequence navigation elements. If the min width is larger than the
36309 * max width the min width value will be used.
36311 * The container element is automatically resized when the resize
36312 * method on the Viewer class is called.
36314 * @param {number} minWidth
36316 SequenceComponent.prototype.setMinWidth = function (minWidth) {
36317 this.configure({ minWidth: minWidth });
36320 * Set the value indicating whether the sequence UI elements should be visible.
36322 * @param {boolean} visible
36324 SequenceComponent.prototype.setVisible = function (visible) {
36325 this.configure({ visible: visible });
36327 SequenceComponent.prototype._activate = function () {
36329 this._sequenceDOMRenderer.activate();
36330 var edgeStatus$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
36331 return node.sequenceEdges$;
36332 }), operators_1.publishReplay(1), operators_1.refCount());
36333 var sequence$ = this._navigator.stateService.currentNode$.pipe(operators_1.distinctUntilChanged(undefined, function (node) {
36334 return node.sequenceKey;
36335 }), operators_1.switchMap(function (node) {
36336 return rxjs_1.concat(rxjs_1.of(null), _this._navigator.graphService.cacheSequence$(node.sequenceKey).pipe(operators_1.retry(3), operators_1.catchError(function (e) {
36337 console.error("Failed to cache sequence", e);
36338 return rxjs_1.of(null);
36340 }), operators_1.startWith(null), operators_1.publishReplay(1), operators_1.refCount());
36341 this._sequenceSubscription = sequence$.subscribe();
36342 var rendererKey$ = this._sequenceDOMRenderer.index$.pipe(operators_1.withLatestFrom(sequence$), operators_1.map(function (_a) {
36343 var index = _a[0], sequence = _a[1];
36344 return sequence != null ? sequence.keys[index] : null;
36345 }), operators_1.filter(function (key) {
36347 }), operators_1.distinctUntilChanged(), operators_1.publish(), operators_1.refCount());
36348 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) {
36349 return _this._navigator.moveToKey$(key).pipe(operators_1.catchError(function (e) {
36350 return rxjs_1.empty();
36354 this._setSequenceGraphModeSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
36357 .subscribe(function () {
36358 _this._navigator.graphService.setGraphMode(Graph_1.GraphMode.Sequence);
36360 this._setSpatialGraphModeSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
36363 .subscribe(function () {
36364 _this._navigator.graphService.setGraphMode(Graph_1.GraphMode.Spatial);
36366 this._navigator.graphService.graphMode$.pipe(operators_1.switchMap(function (mode) {
36367 return mode === Graph_1.GraphMode.Spatial ?
36368 _this._navigator.stateService.currentNode$.pipe(operators_1.take(2)) :
36370 }), operators_1.filter(function (node) {
36371 return !node.spatialEdges.cached;
36372 }), operators_1.switchMap(function (node) {
36373 return _this._navigator.graphService.cacheNode$(node.key).pipe(operators_1.catchError(function (e) {
36374 return rxjs_1.empty();
36378 this._stopSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
36381 .subscribe(function () {
36382 _this._navigator.playService.stop();
36384 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) {
36385 var _b = _a[0], mode = _b[0], changing = _b[1], node = _a[1];
36386 return changing && mode === Graph_1.GraphMode.Sequence ?
36387 _this._navigator.graphService.cacheSequenceNodes$(node.sequenceKey, node.key).pipe(operators_1.retry(3), operators_1.catchError(function (error) {
36388 console.error("Failed to cache sequence nodes.", error);
36389 return rxjs_1.empty();
36394 var position$ = sequence$.pipe(operators_1.switchMap(function (sequence) {
36396 return rxjs_1.of({ index: null, max: null });
36398 var firstCurrentKey = true;
36399 return _this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.startWith(false), operators_1.distinctUntilChanged(), operators_1.switchMap(function (changingPosition) {
36400 var skipCount = !changingPosition && firstCurrentKey ? 0 : 1;
36401 firstCurrentKey = false;
36402 return changingPosition ?
36404 _this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
36406 }), operators_1.distinctUntilChanged(), operators_1.skip(skipCount));
36407 }), operators_1.map(function (key) {
36408 var index = sequence.keys.indexOf(key);
36409 if (index === -1) {
36410 return { index: null, max: null };
36412 return { index: index, max: sequence.keys.length - 1 };
36415 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) {
36416 var edgeStatus = _a[0], configuration = _a[1], containerWidth = _a[2], renderer = _a[3], speed = _a[4], position = _a[5];
36417 var vNode = _this._sequenceDOMRenderer
36418 .render(edgeStatus, configuration, containerWidth, speed, position.index, position.max, _this, _this._navigator);
36419 return { name: _this._name, vnode: vNode };
36421 .subscribe(this._container.domRenderer.render$);
36422 this._setSpeedSubscription = this._sequenceDOMRenderer.speed$
36423 .subscribe(function (speed) {
36424 _this._navigator.playService.setSpeed(speed);
36426 this._setDirectionSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
36427 return configuration.direction;
36428 }), operators_1.distinctUntilChanged())
36429 .subscribe(function (direction) {
36430 _this._navigator.playService.setDirection(direction);
36432 this._containerWidthSubscription = rxjs_1.combineLatest(this._container.renderService.size$, this._configuration$.pipe(operators_1.distinctUntilChanged(function (value1, value2) {
36433 return value1[0] === value2[0] && value1[1] === value2[1];
36434 }, function (configuration) {
36435 return [configuration.minWidth, configuration.maxWidth];
36436 }))).pipe(operators_1.map(function (_a) {
36437 var size = _a[0], configuration = _a[1];
36438 return _this._sequenceDOMRenderer.getContainerWidth(size, configuration);
36440 .subscribe(this._containerWidth$);
36441 this._playingSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
36442 return configuration.playing;
36443 }), operators_1.distinctUntilChanged())
36444 .subscribe(function (playing) {
36446 _this._navigator.playService.play();
36449 _this._navigator.playService.stop();
36452 this._hoveredKeySubscription = this._sequenceDOMRenderer.mouseEnterDirection$.pipe(operators_1.switchMap(function (direction) {
36453 var edgeTo$ = edgeStatus$.pipe(operators_1.map(function (edgeStatus) {
36454 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
36456 if (edge.data.direction === direction) {
36461 }), operators_1.takeUntil(_this._sequenceDOMRenderer.mouseLeaveDirection$));
36462 return rxjs_1.concat(edgeTo$, rxjs_1.of(null));
36463 }), operators_1.distinctUntilChanged())
36464 .subscribe(this._hoveredKeySubject$);
36465 this._emitHoveredKeySubscription = this._hoveredKey$
36466 .subscribe(function (key) {
36467 _this.fire(SequenceComponent.hoveredkeychanged, key);
36470 SequenceComponent.prototype._deactivate = function () {
36471 this._emitHoveredKeySubscription.unsubscribe();
36472 this._renderSubscription.unsubscribe();
36473 this._playingSubscription.unsubscribe();
36474 this._containerWidthSubscription.unsubscribe();
36475 this._hoveredKeySubscription.unsubscribe();
36476 this._setSpeedSubscription.unsubscribe();
36477 this._setDirectionSubscription.unsubscribe();
36478 this._setSequenceGraphModeSubscription.unsubscribe();
36479 this._setSpatialGraphModeSubscription.unsubscribe();
36480 this._sequenceSubscription.unsubscribe();
36481 this._moveSubscription.unsubscribe();
36482 this._cacheSequenceNodesSubscription.unsubscribe();
36483 this._stopSubscription.unsubscribe();
36484 this._sequenceDOMRenderer.deactivate();
36486 SequenceComponent.prototype._getDefaultConfiguration = function () {
36488 direction: Edge_1.EdgeDirection.Next,
36496 SequenceComponent.componentName = "sequence";
36498 * Event fired when playing starts or stops.
36500 * @event SequenceComponent#playingchanged
36501 * @type {boolean} Indicates whether the player is playing.
36503 SequenceComponent.playingchanged = "playingchanged";
36505 * Event fired when the hovered key changes.
36507 * @description Emits the key of the node for the direction
36508 * arrow that is being hovered. When the mouse leaves a
36509 * direction arrow null is emitted.
36511 * @event SequenceComponent#hoveredkeychanged
36512 * @type {string} The hovered key, null if no key is hovered.
36514 SequenceComponent.hoveredkeychanged = "hoveredkeychanged";
36515 return SequenceComponent;
36516 }(Component_1.Component));
36517 exports.SequenceComponent = SequenceComponent;
36518 Component_1.ComponentService.register(SequenceComponent);
36519 exports.default = SequenceComponent;
36521 },{"../../Component":291,"../../Edge":292,"../../Graph":295,"rxjs":43,"rxjs/operators":241}],354:[function(require,module,exports){
36523 Object.defineProperty(exports, "__esModule", { value: true });
36524 exports.SequenceDOMRenderer = void 0;
36525 var rxjs_1 = require("rxjs");
36526 var operators_1 = require("rxjs/operators");
36527 var vd = require("virtual-dom");
36528 var Component_1 = require("../../Component");
36529 var Edge_1 = require("../../Edge");
36530 var Error_1 = require("../../Error");
36531 var SequenceDOMRenderer = /** @class */ (function () {
36532 function SequenceDOMRenderer(container) {
36533 this._container = container;
36534 this._minThresholdWidth = 320;
36535 this._maxThresholdWidth = 1480;
36536 this._minThresholdHeight = 240;
36537 this._maxThresholdHeight = 820;
36538 this._stepperDefaultWidth = 108;
36539 this._controlsDefaultWidth = 88;
36540 this._defaultHeight = 30;
36541 this._expandControls = false;
36542 this._mode = Component_1.SequenceMode.Default;
36544 this._changingSpeed = false;
36545 this._index = null;
36546 this._changingPosition = false;
36547 this._mouseEnterDirection$ = new rxjs_1.Subject();
36548 this._mouseLeaveDirection$ = new rxjs_1.Subject();
36549 this._notifyChanged$ = new rxjs_1.Subject();
36550 this._notifyChangingPositionChanged$ = new rxjs_1.Subject();
36551 this._notifySpeedChanged$ = new rxjs_1.Subject();
36552 this._notifyIndexChanged$ = new rxjs_1.Subject();
36554 Object.defineProperty(SequenceDOMRenderer.prototype, "changed$", {
36556 return this._notifyChanged$;
36561 Object.defineProperty(SequenceDOMRenderer.prototype, "changingPositionChanged$", {
36563 return this._notifyChangingPositionChanged$;
36568 Object.defineProperty(SequenceDOMRenderer.prototype, "speed$", {
36570 return this._notifySpeedChanged$;
36575 Object.defineProperty(SequenceDOMRenderer.prototype, "index$", {
36577 return this._notifyIndexChanged$;
36582 Object.defineProperty(SequenceDOMRenderer.prototype, "mouseEnterDirection$", {
36584 return this._mouseEnterDirection$;
36589 Object.defineProperty(SequenceDOMRenderer.prototype, "mouseLeaveDirection$", {
36591 return this._mouseLeaveDirection$;
36596 SequenceDOMRenderer.prototype.activate = function () {
36598 if (!!this._changingSubscription) {
36601 this._changingSubscription = rxjs_1.merge(this._container.mouseService.documentMouseUp$, this._container.touchService.touchEnd$.pipe(operators_1.filter(function (touchEvent) {
36602 return touchEvent.touches.length === 0;
36604 .subscribe(function (event) {
36605 if (_this._changingSpeed) {
36606 _this._changingSpeed = false;
36608 if (_this._changingPosition) {
36609 _this._setChangingPosition(false);
36613 SequenceDOMRenderer.prototype.deactivate = function () {
36614 if (!this._changingSubscription) {
36617 this._changingSpeed = false;
36618 this._changingPosition = false;
36619 this._expandControls = false;
36620 this._mode = Component_1.SequenceMode.Default;
36621 this._changingSubscription.unsubscribe();
36622 this._changingSubscription = null;
36624 SequenceDOMRenderer.prototype.render = function (edgeStatus, configuration, containerWidth, speed, index, max, component, navigator) {
36625 if (configuration.visible === false) {
36626 return vd.h("div.SequenceContainer", {}, []);
36628 var stepper = this._createStepper(edgeStatus, configuration, containerWidth, component, navigator);
36629 var controls = this._createSequenceControls(containerWidth);
36630 var playback = this._createPlaybackControls(containerWidth, speed, component, configuration);
36631 var timeline = this._createTimelineControls(containerWidth, index, max);
36632 return vd.h("div.SequenceContainer", [stepper, controls, playback, timeline]);
36634 SequenceDOMRenderer.prototype.getContainerWidth = function (size, configuration) {
36635 var minWidth = configuration.minWidth;
36636 var maxWidth = configuration.maxWidth;
36637 if (maxWidth < minWidth) {
36638 maxWidth = minWidth;
36640 var relativeWidth = (size.width - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth);
36641 var relativeHeight = (size.height - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight);
36642 var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight)));
36643 return minWidth + coeff * (maxWidth - minWidth);
36645 SequenceDOMRenderer.prototype._createPositionInput = function (index, max) {
36647 this._index = index;
36648 var onPosition = function (e) {
36649 _this._index = Number(e.target.value);
36650 _this._notifyIndexChanged$.next(_this._index);
36652 var boundingRect = this._container.domContainer.getBoundingClientRect();
36653 var width = Math.max(276, Math.min(410, 5 + 0.8 * boundingRect.width)) - 65;
36654 var onStart = function (e) {
36655 e.stopPropagation();
36656 _this._setChangingPosition(true);
36658 var onMove = function (e) {
36659 if (_this._changingPosition === true) {
36660 e.stopPropagation();
36663 var onKeyDown = function (e) {
36664 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
36665 e.key === "ArrowRight" || e.key === "ArrowUp") {
36666 e.preventDefault();
36669 var positionInputProperties = {
36670 max: max != null ? max : 1,
36672 onchange: onPosition,
36673 oninput: onPosition,
36674 onkeydown: onKeyDown,
36675 onmousedown: onStart,
36676 onmousemove: onMove,
36677 ontouchmove: onMove,
36678 ontouchstart: onStart,
36680 width: width + "px",
36683 value: index != null ? index : 0,
36685 var disabled = index == null || max == null || max <= 1;
36687 positionInputProperties.disabled = "true";
36689 var positionInput = vd.h("input.SequencePosition", positionInputProperties, []);
36690 var positionContainerClass = disabled ? ".SequencePositionContainerDisabled" : ".SequencePositionContainer";
36691 return vd.h("div" + positionContainerClass, [positionInput]);
36693 SequenceDOMRenderer.prototype._createSpeedInput = function (speed) {
36695 this._speed = speed;
36696 var onSpeed = function (e) {
36697 _this._speed = Number(e.target.value) / 1000;
36698 _this._notifySpeedChanged$.next(_this._speed);
36700 var boundingRect = this._container.domContainer.getBoundingClientRect();
36701 var width = Math.max(276, Math.min(410, 5 + 0.8 * boundingRect.width)) - 160;
36702 var onStart = function (e) {
36703 _this._changingSpeed = true;
36704 e.stopPropagation();
36706 var onMove = function (e) {
36707 if (_this._changingSpeed === true) {
36708 e.stopPropagation();
36711 var onKeyDown = function (e) {
36712 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
36713 e.key === "ArrowRight" || e.key === "ArrowUp") {
36714 e.preventDefault();
36717 var speedInput = vd.h("input.SequenceSpeed", {
36722 onkeydown: onKeyDown,
36723 onmousedown: onStart,
36724 onmousemove: onMove,
36725 ontouchmove: onMove,
36726 ontouchstart: onStart,
36728 width: width + "px",
36731 value: 1000 * speed,
36733 return vd.h("div.SequenceSpeedContainer", [speedInput]);
36735 SequenceDOMRenderer.prototype._createPlaybackControls = function (containerWidth, speed, component, configuration) {
36737 if (this._mode !== Component_1.SequenceMode.Playback) {
36738 return vd.h("div.SequencePlayback", []);
36740 var switchIcon = vd.h("div.SequenceSwitchIcon.SequenceIconVisible", []);
36741 var direction = configuration.direction === Edge_1.EdgeDirection.Next ?
36742 Edge_1.EdgeDirection.Prev : Edge_1.EdgeDirection.Next;
36743 var playing = configuration.playing;
36744 var switchButtonProperties = {
36745 onclick: function () {
36747 component.setDirection(direction);
36751 var switchButtonClassName = configuration.playing ? ".SequenceSwitchButtonDisabled" : ".SequenceSwitchButton";
36752 var switchButton = vd.h("div" + switchButtonClassName, switchButtonProperties, [switchIcon]);
36753 var slowIcon = vd.h("div.SequenceSlowIcon.SequenceIconVisible", []);
36754 var slowContainer = vd.h("div.SequenceSlowContainer", [slowIcon]);
36755 var fastIcon = vd.h("div.SequenceFastIcon.SequenceIconVisible", []);
36756 var fastContainer = vd.h("div.SequenceFastContainer", [fastIcon]);
36757 var closeIcon = vd.h("div.SequenceCloseIcon.SequenceIconVisible", []);
36758 var closeButtonProperties = {
36759 onclick: function () {
36760 _this._mode = Component_1.SequenceMode.Default;
36761 _this._notifyChanged$.next(_this);
36764 var closeButton = vd.h("div.SequenceCloseButton", closeButtonProperties, [closeIcon]);
36765 var speedInput = this._createSpeedInput(speed);
36766 var playbackChildren = [switchButton, slowContainer, speedInput, fastContainer, closeButton];
36767 var top = Math.round(containerWidth / this._stepperDefaultWidth * this._defaultHeight + 10);
36768 var playbackProperties = { style: { top: top + "px" } };
36769 return vd.h("div.SequencePlayback", playbackProperties, playbackChildren);
36771 SequenceDOMRenderer.prototype._createPlayingButton = function (nextKey, prevKey, configuration, component) {
36772 var canPlay = configuration.direction === Edge_1.EdgeDirection.Next && nextKey != null ||
36773 configuration.direction === Edge_1.EdgeDirection.Prev && prevKey != null;
36774 var onclick = configuration.playing ?
36775 function (e) { component.stop(); } :
36776 canPlay ? function (e) { component.play(); } : null;
36777 var buttonProperties = { onclick: onclick };
36778 var iconClass = configuration.playing ?
36780 canPlay ? "Play" : "PlayDisabled";
36781 var iconProperties = { className: iconClass };
36782 if (configuration.direction === Edge_1.EdgeDirection.Prev) {
36783 iconProperties.style = {
36784 transform: "rotate(180deg) translate(50%, 50%)",
36787 var icon = vd.h("div.SequenceComponentIcon", iconProperties, []);
36788 var buttonClass = canPlay ? "SequencePlay" : "SequencePlayDisabled";
36789 return vd.h("div." + buttonClass, buttonProperties, [icon]);
36791 SequenceDOMRenderer.prototype._createSequenceControls = function (containerWidth) {
36793 var borderRadius = Math.round(8 / this._stepperDefaultWidth * containerWidth);
36794 var expanderProperties = {
36795 onclick: function () {
36796 _this._expandControls = !_this._expandControls;
36797 _this._mode = Component_1.SequenceMode.Default;
36798 _this._notifyChanged$.next(_this);
36801 "border-bottom-right-radius": borderRadius + "px",
36802 "border-top-right-radius": borderRadius + "px",
36805 var expanderBar = vd.h("div.SequenceExpanderBar", []);
36806 var expander = vd.h("div.SequenceExpanderButton", expanderProperties, [expanderBar]);
36807 var fastIconClassName = this._mode === Component_1.SequenceMode.Playback ?
36808 ".SequenceFastIconGrey.SequenceIconVisible" : ".SequenceFastIcon";
36809 var fastIcon = vd.h("div" + fastIconClassName, []);
36810 var playbackProperties = {
36811 onclick: function () {
36812 _this._mode = _this._mode === Component_1.SequenceMode.Playback ?
36813 Component_1.SequenceMode.Default :
36814 Component_1.SequenceMode.Playback;
36815 _this._notifyChanged$.next(_this);
36818 var playback = vd.h("div.SequencePlaybackButton", playbackProperties, [fastIcon]);
36819 var timelineIconClassName = this._mode === Component_1.SequenceMode.Timeline ?
36820 ".SequenceTimelineIconGrey.SequenceIconVisible" : ".SequenceTimelineIcon";
36821 var timelineIcon = vd.h("div" + timelineIconClassName, []);
36822 var timelineProperties = {
36823 onclick: function () {
36824 _this._mode = _this._mode === Component_1.SequenceMode.Timeline ?
36825 Component_1.SequenceMode.Default :
36826 Component_1.SequenceMode.Timeline;
36827 _this._notifyChanged$.next(_this);
36830 var timeline = vd.h("div.SequenceTimelineButton", timelineProperties, [timelineIcon]);
36833 height: (this._defaultHeight / this._stepperDefaultWidth * containerWidth) + "px",
36834 transform: "translate(" + (containerWidth / 2 + 2) + "px, 0)",
36835 width: (this._controlsDefaultWidth / this._stepperDefaultWidth * containerWidth) + "px",
36838 var className = ".SequenceControls" +
36839 (this._expandControls ? ".SequenceControlsExpanded" : "");
36840 return vd.h("div" + className, properties, [playback, timeline, expander]);
36842 SequenceDOMRenderer.prototype._createSequenceArrows = function (nextKey, prevKey, containerWidth, configuration, navigator) {
36844 var nextProperties = {
36845 onclick: nextKey != null ?
36847 navigator.moveDir$(Edge_1.EdgeDirection.Next)
36848 .subscribe(undefined, function (error) {
36849 if (!(error instanceof Error_1.AbortMapillaryError)) {
36850 console.error(error);
36855 onmouseenter: function (e) { _this._mouseEnterDirection$.next(Edge_1.EdgeDirection.Next); },
36856 onmouseleave: function (e) { _this._mouseLeaveDirection$.next(Edge_1.EdgeDirection.Next); },
36858 var borderRadius = Math.round(8 / this._stepperDefaultWidth * containerWidth);
36859 var prevProperties = {
36860 onclick: prevKey != null ?
36862 navigator.moveDir$(Edge_1.EdgeDirection.Prev)
36863 .subscribe(undefined, function (error) {
36864 if (!(error instanceof Error_1.AbortMapillaryError)) {
36865 console.error(error);
36870 onmouseenter: function (e) { _this._mouseEnterDirection$.next(Edge_1.EdgeDirection.Prev); },
36871 onmouseleave: function (e) { _this._mouseLeaveDirection$.next(Edge_1.EdgeDirection.Prev); },
36873 "border-bottom-left-radius": borderRadius + "px",
36874 "border-top-left-radius": borderRadius + "px",
36877 var nextClass = this._getStepClassName(Edge_1.EdgeDirection.Next, nextKey, configuration.highlightKey);
36878 var prevClass = this._getStepClassName(Edge_1.EdgeDirection.Prev, prevKey, configuration.highlightKey);
36879 var nextIcon = vd.h("div.SequenceComponentIcon", []);
36880 var prevIcon = vd.h("div.SequenceComponentIcon", []);
36882 vd.h("div." + prevClass, prevProperties, [prevIcon]),
36883 vd.h("div." + nextClass, nextProperties, [nextIcon]),
36886 SequenceDOMRenderer.prototype._createStepper = function (edgeStatus, configuration, containerWidth, component, navigator) {
36887 var nextKey = null;
36888 var prevKey = null;
36889 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
36891 if (edge.data.direction === Edge_1.EdgeDirection.Next) {
36894 if (edge.data.direction === Edge_1.EdgeDirection.Prev) {
36898 var playingButton = this._createPlayingButton(nextKey, prevKey, configuration, component);
36899 var buttons = this._createSequenceArrows(nextKey, prevKey, containerWidth, configuration, navigator);
36900 buttons.splice(1, 0, playingButton);
36901 var containerProperties = {
36902 oncontextmenu: function (event) { event.preventDefault(); },
36904 height: (this._defaultHeight / this._stepperDefaultWidth * containerWidth) + "px",
36905 width: containerWidth + "px",
36908 return vd.h("div.SequenceStepper", containerProperties, buttons);
36910 SequenceDOMRenderer.prototype._createTimelineControls = function (containerWidth, index, max) {
36912 if (this._mode !== Component_1.SequenceMode.Timeline) {
36913 return vd.h("div.SequenceTimeline", []);
36915 var positionInput = this._createPositionInput(index, max);
36916 var closeIcon = vd.h("div.SequenceCloseIcon.SequenceIconVisible", []);
36917 var closeButtonProperties = {
36918 onclick: function () {
36919 _this._mode = Component_1.SequenceMode.Default;
36920 _this._notifyChanged$.next(_this);
36923 var closeButton = vd.h("div.SequenceCloseButton", closeButtonProperties, [closeIcon]);
36924 var top = Math.round(containerWidth / this._stepperDefaultWidth * this._defaultHeight + 10);
36925 var playbackProperties = { style: { top: top + "px" } };
36926 return vd.h("div.SequenceTimeline", playbackProperties, [positionInput, closeButton]);
36928 SequenceDOMRenderer.prototype._getStepClassName = function (direction, key, highlightKey) {
36929 var className = direction === Edge_1.EdgeDirection.Next ?
36930 "SequenceStepNext" :
36931 "SequenceStepPrev";
36933 className += "Disabled";
36936 if (highlightKey === key) {
36937 className += "Highlight";
36942 SequenceDOMRenderer.prototype._setChangingPosition = function (value) {
36943 this._changingPosition = value;
36944 this._notifyChangingPositionChanged$.next(value);
36946 return SequenceDOMRenderer;
36948 exports.SequenceDOMRenderer = SequenceDOMRenderer;
36949 exports.default = SequenceDOMRenderer;
36951 },{"../../Component":291,"../../Edge":292,"../../Error":293,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],355:[function(require,module,exports){
36953 Object.defineProperty(exports, "__esModule", { value: true });
36954 exports.SequenceMode = void 0;
36956 (function (SequenceMode) {
36957 SequenceMode[SequenceMode["Default"] = 0] = "Default";
36958 SequenceMode[SequenceMode["Playback"] = 1] = "Playback";
36959 SequenceMode[SequenceMode["Timeline"] = 2] = "Timeline";
36960 })(SequenceMode = exports.SequenceMode || (exports.SequenceMode = {}));
36961 exports.default = SequenceMode;
36963 },{}],356:[function(require,module,exports){
36965 Object.defineProperty(exports, "__esModule", { value: true });
36966 exports.Shaders = void 0;
36968 var path = require("path");
36969 var Shaders = /** @class */ (function () {
36970 function Shaders() {
36972 Shaders.equirectangular = {
36973 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}",
36974 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}",
36976 Shaders.equirectangularCurtain = {
36977 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}",
36978 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}",
36980 Shaders.perspective = {
36981 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}",
36982 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}",
36984 Shaders.perspectiveCurtain = {
36985 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",
36986 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}",
36988 Shaders.fisheye = {
36989 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;\n float y = vRstq.y;\n float z = vRstq.z;\n\n float r = sqrt(x * x + y * y);\n float theta = atan(r, z);\n\n if (radial_peak > 0. && theta > radial_peak) {\n theta = radial_peak;\n }\n\n float theta2 = theta * theta;\n float theta_d = theta * (1.0 + theta2 * (k1 + theta2 * k2));\n float s = focal * theta_d / r;\n\n float u = scale_x * s * x + 0.5;\n float v = -scale_y * s * 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}\n",
36990 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}",
36992 Shaders.fisheyeCurtain = {
36993 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;\n float y = vRstq.y;\n float z = vRstq.z;\n\n float r2 = sqrt(x * x + y * y);\n float theta = atan(r2, z);\n\n if (radial_peak > 0. && theta > radial_peak) {\n theta = radial_peak;\n }\n\n float theta2 = theta * theta;\n float theta_d = theta * (1.0 + theta2 * (k1 + theta2 * k2));\n float s = focal * theta_d / r2;\n\n float u = scale_x * s * x + 0.5;\n float v = -scale_y * s * 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",
36994 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}",
36996 Shaders.perspectiveDistorted = {
36997 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",
36998 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",
37000 Shaders.perspectiveDistortedCurtain = {
37001 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",
37002 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",
37006 exports.Shaders = Shaders;
37009 },{"path":39}],357:[function(require,module,exports){
37011 var __extends = (this && this.__extends) || (function () {
37012 var extendStatics = function (d, b) {
37013 extendStatics = Object.setPrototypeOf ||
37014 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
37015 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
37016 return extendStatics(d, b);
37018 return function (d, b) {
37019 extendStatics(d, b);
37020 function __() { this.constructor = d; }
37021 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
37024 Object.defineProperty(exports, "__esModule", { value: true });
37025 exports.SliderComponent = void 0;
37026 var rxjs_1 = require("rxjs");
37027 var operators_1 = require("rxjs/operators");
37028 var Component_1 = require("../../Component");
37029 var Geo_1 = require("../../Geo");
37030 var State_1 = require("../../State");
37031 var Render_1 = require("../../Render");
37032 var Tiles_1 = require("../../Tiles");
37033 var Utils_1 = require("../../Utils");
37035 * @class SliderComponent
37037 * @classdesc Component for comparing pairs of images. Renders
37038 * a slider for adjusting the curtain of the first image.
37040 * Deactivate the sequence, direction and image plane
37041 * components when activating the slider component to avoid
37042 * interfering UI elements.
37044 * To retrive and use the slider component
37048 * var viewer = new Mapillary.Viewer(
37053 * viewer.deactivateComponent("imagePlane");
37054 * viewer.deactivateComponent("direction");
37055 * viewer.deactivateComponent("sequence");
37057 * viewer.activateComponent("slider");
37059 * var sliderComponent = viewer.getComponent("slider");
37062 var SliderComponent = /** @class */ (function (_super) {
37063 __extends(SliderComponent, _super);
37065 function SliderComponent(name, container, navigator, viewportCoords) {
37066 var _this = _super.call(this, name, container, navigator) || this;
37067 _this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
37068 _this._domRenderer = new Component_1.SliderDOMRenderer(container);
37069 _this._imageTileLoader = new Tiles_1.ImageTileLoader(Utils_1.Urls.tileScheme, Utils_1.Urls.tileDomain, Utils_1.Urls.origin);
37070 _this._roiCalculator = new Tiles_1.RegionOfInterestCalculator();
37071 _this._spatial = new Geo_1.Spatial();
37072 _this._glRendererOperation$ = new rxjs_1.Subject();
37073 _this._glRendererCreator$ = new rxjs_1.Subject();
37074 _this._glRendererDisposer$ = new rxjs_1.Subject();
37075 _this._glRenderer$ = _this._glRendererOperation$.pipe(operators_1.scan(function (glRenderer, operation) {
37076 return operation(glRenderer);
37077 }, null), operators_1.filter(function (glRenderer) {
37078 return glRenderer != null;
37079 }), operators_1.distinctUntilChanged(undefined, function (glRenderer) {
37080 return glRenderer.frameId;
37082 _this._glRendererCreator$.pipe(operators_1.map(function () {
37083 return function (glRenderer) {
37084 if (glRenderer != null) {
37085 throw new Error("Multiple slider states can not be created at the same time");
37087 return new Component_1.SliderGLRenderer();
37090 .subscribe(_this._glRendererOperation$);
37091 _this._glRendererDisposer$.pipe(operators_1.map(function () {
37092 return function (glRenderer) {
37093 glRenderer.dispose();
37097 .subscribe(_this._glRendererOperation$);
37101 * Set the initial position.
37103 * @description Configures the intial position of the slider.
37104 * The inital position value will be used when the component
37107 * @param {number} initialPosition - Initial slider position.
37109 SliderComponent.prototype.setInitialPosition = function (initialPosition) {
37110 this.configure({ initialPosition: initialPosition });
37113 * Set the image keys.
37115 * @description Configures the component to show the image
37116 * planes for the supplied image keys.
37118 * @param {ISliderKeys} keys - Slider keys object specifying
37119 * the images to be shown in the foreground and the background.
37121 SliderComponent.prototype.setKeys = function (keys) {
37122 this.configure({ keys: keys });
37125 * Set the slider mode.
37127 * @description Configures the mode for transitions between
37130 * @param {SliderMode} mode - Slider mode to be set.
37132 SliderComponent.prototype.setSliderMode = function (mode) {
37133 this.configure({ mode: mode });
37136 * Set the value controlling if the slider is visible.
37138 * @param {boolean} sliderVisible - Value indicating if
37139 * the slider should be visible or not.
37141 SliderComponent.prototype.setSliderVisible = function (sliderVisible) {
37142 this.configure({ sliderVisible: sliderVisible });
37144 SliderComponent.prototype._activate = function () {
37146 this._modeSubcription = this._domRenderer.mode$
37147 .subscribe(function (mode) {
37148 _this.setSliderMode(mode);
37150 this._glRenderSubscription = this._glRenderer$.pipe(operators_1.map(function (glRenderer) {
37154 frameId: glRenderer.frameId,
37155 needsRender: glRenderer.needsRender,
37156 render: glRenderer.render.bind(glRenderer),
37157 stage: Render_1.GLRenderStage.Background,
37162 .subscribe(this._container.glRenderer.render$);
37163 var position$ = rxjs_1.concat(this.configuration$.pipe(operators_1.map(function (configuration) {
37164 return configuration.initialPosition != null ?
37165 configuration.initialPosition : 1;
37166 }), operators_1.first()), this._domRenderer.position$);
37167 var mode$ = this.configuration$.pipe(operators_1.map(function (configuration) {
37168 return configuration.mode;
37169 }), operators_1.distinctUntilChanged());
37170 var motionless$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
37171 return frame.state.motionless;
37172 }), operators_1.distinctUntilChanged());
37173 var fullPano$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
37174 return frame.state.currentNode.fullPano;
37175 }), operators_1.distinctUntilChanged());
37176 var sliderVisible$ = rxjs_1.combineLatest(this._configuration$.pipe(operators_1.map(function (configuration) {
37177 return configuration.sliderVisible;
37178 })), this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
37179 return !(frame.state.currentNode == null ||
37180 frame.state.previousNode == null ||
37181 (frame.state.currentNode.pano && !frame.state.currentNode.fullPano) ||
37182 (frame.state.previousNode.pano && !frame.state.previousNode.fullPano) ||
37183 (frame.state.currentNode.fullPano && !frame.state.previousNode.fullPano));
37184 }), operators_1.distinctUntilChanged())).pipe(operators_1.map(function (_a) {
37185 var sliderVisible = _a[0], enabledState = _a[1];
37186 return sliderVisible && enabledState;
37187 }), operators_1.distinctUntilChanged());
37188 this._waitSubscription = rxjs_1.combineLatest(mode$, motionless$, fullPano$, sliderVisible$).pipe(operators_1.withLatestFrom(this._navigator.stateService.state$))
37189 .subscribe(function (_a) {
37190 var _b = _a[0], mode = _b[0], motionless = _b[1], fullPano = _b[2], sliderVisible = _b[3], state = _a[1];
37191 var interactive = sliderVisible &&
37192 (motionless || mode === Component_1.SliderMode.Stationary || fullPano);
37193 if (interactive && state !== State_1.State.WaitingInteractively) {
37194 _this._navigator.stateService.waitInteractively();
37196 else if (!interactive && state !== State_1.State.Waiting) {
37197 _this._navigator.stateService.wait();
37200 this._moveSubscription = rxjs_1.combineLatest(position$, mode$, motionless$, fullPano$, sliderVisible$)
37201 .subscribe(function (_a) {
37202 var position = _a[0], mode = _a[1], motionless = _a[2], fullPano = _a[3], sliderVisible = _a[4];
37203 if (motionless || mode === Component_1.SliderMode.Stationary || fullPano) {
37204 _this._navigator.stateService.moveTo(1);
37207 _this._navigator.stateService.moveTo(position);
37210 this._domRenderSubscription = rxjs_1.combineLatest(position$, mode$, motionless$, fullPano$, sliderVisible$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
37211 var position = _a[0], mode = _a[1], motionless = _a[2], fullPano = _a[3], sliderVisible = _a[4], size = _a[5];
37214 vnode: _this._domRenderer.render(position, mode, motionless, fullPano, sliderVisible),
37217 .subscribe(this._container.domRenderer.render$);
37218 this._glRendererCreator$.next(null);
37219 this._updateCurtainSubscription = rxjs_1.combineLatest(position$, fullPano$, sliderVisible$, this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.map(function (_a) {
37220 var position = _a[0], fullPano = _a[1], visible = _a[2], render = _a[3], transform = _a[4];
37222 return visible ? position : 1;
37224 var basicMin = _this._viewportCoords.viewportToBasic(-1.15, 0, transform, render.perspective);
37225 var basicMax = _this._viewportCoords.viewportToBasic(1.15, 0, transform, render.perspective);
37226 var shiftedMax = basicMax[0] < basicMin[0] ? basicMax[0] + 1 : basicMax[0];
37227 var basicPosition = basicMin[0] + position * (shiftedMax - basicMin[0]);
37228 return basicPosition > 1 ? basicPosition - 1 : basicPosition;
37229 }), operators_1.map(function (position) {
37230 return function (glRenderer) {
37231 glRenderer.updateCurtain(position);
37235 .subscribe(this._glRendererOperation$);
37236 this._stateSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentState$, mode$).pipe(operators_1.map(function (_a) {
37237 var frame = _a[0], mode = _a[1];
37238 return function (glRenderer) {
37239 glRenderer.update(frame, mode);
37243 .subscribe(this._glRendererOperation$);
37244 this._setKeysSubscription = this._configuration$.pipe(operators_1.filter(function (configuration) {
37245 return configuration.keys != null;
37246 }), operators_1.switchMap(function (configuration) {
37247 return rxjs_1.zip(rxjs_1.zip(_this._catchCacheNode$(configuration.keys.background), _this._catchCacheNode$(configuration.keys.foreground)).pipe(operators_1.map(function (nodes) {
37248 return { background: nodes[0], foreground: nodes[1] };
37249 })), _this._navigator.stateService.currentState$.pipe(operators_1.first())).pipe(operators_1.map(function (nf) {
37250 return { nodes: nf[0], state: nf[1].state };
37253 .subscribe(function (co) {
37254 if (co.state.currentNode != null &&
37255 co.state.previousNode != null &&
37256 co.state.currentNode.key === co.nodes.foreground.key &&
37257 co.state.previousNode.key === co.nodes.background.key) {
37260 if (co.state.currentNode.key === co.nodes.background.key) {
37261 _this._navigator.stateService.setNodes([co.nodes.foreground]);
37264 if (co.state.currentNode.key === co.nodes.foreground.key &&
37265 co.state.trajectory.length === 1) {
37266 _this._navigator.stateService.prependNodes([co.nodes.background]);
37269 _this._navigator.stateService.setNodes([co.nodes.background]);
37270 _this._navigator.stateService.setNodes([co.nodes.foreground]);
37274 var previousNode$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
37275 return frame.state.previousNode;
37276 }), operators_1.filter(function (node) {
37277 return node != null;
37278 }), operators_1.distinctUntilChanged(undefined, function (node) {
37281 var textureProvider$ = this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
37282 return frame.state.currentNode.key;
37283 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
37284 var frame = _a[0], renderer = _a[1], size = _a[2];
37285 var state = frame.state;
37286 var viewportSize = Math.max(size.width, size.height);
37287 var currentNode = state.currentNode;
37288 var currentTransform = state.currentTransform;
37289 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
37290 return new Tiles_1.TextureProvider(currentNode.key, currentTransform.basicWidth, currentTransform.basicHeight, tileSize, currentNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
37291 }), operators_1.publishReplay(1), operators_1.refCount());
37292 this._textureProviderSubscription = textureProvider$.subscribe(function () { });
37293 this._setTextureProviderSubscription = textureProvider$.pipe(operators_1.map(function (provider) {
37294 return function (renderer) {
37295 renderer.setTextureProvider(provider.key, provider);
37299 .subscribe(this._glRendererOperation$);
37300 this._setTileSizeSubscription = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
37301 return rxjs_1.combineLatest(textureProvider$, rxjs_1.of(size)).pipe(operators_1.first());
37303 .subscribe(function (_a) {
37304 var provider = _a[0], size = _a[1];
37305 var viewportSize = Math.max(size.width, size.height);
37306 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
37307 provider.setTileSize(tileSize);
37309 this._abortTextureProviderSubscription = textureProvider$.pipe(operators_1.pairwise())
37310 .subscribe(function (pair) {
37311 var previous = pair[0];
37314 var roiTrigger$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
37315 var camera = _a[0], size = _a[1];
37317 camera.camera.position.clone(),
37318 camera.camera.lookat.clone(),
37319 camera.zoom.valueOf(),
37320 size.height.valueOf(),
37321 size.width.valueOf()
37323 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
37324 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
37325 }), operators_1.map(function (pls) {
37326 var samePosition = pls[0][0].equals(pls[1][0]);
37327 var sameLookat = pls[0][1].equals(pls[1][1]);
37328 var sameZoom = pls[0][2] === pls[1][2];
37329 var sameHeight = pls[0][3] === pls[1][3];
37330 var sameWidth = pls[0][4] === pls[1][4];
37331 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
37332 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
37334 }), operators_1.switchMap(function (stalled) {
37335 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
37336 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
37337 this._setRegionOfInterestSubscription = textureProvider$.pipe(operators_1.switchMap(function (provider) {
37338 return roiTrigger$.pipe(operators_1.map(function (_a) {
37339 var camera = _a[0], size = _a[1], transform = _a[2];
37341 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
37345 }), operators_1.filter(function (args) {
37346 return !args[1].disposed;
37348 .subscribe(function (args) {
37350 var provider = args[1];
37351 provider.setRegionOfInterest(roi);
37353 var hasTexture$ = textureProvider$.pipe(operators_1.switchMap(function (provider) {
37354 return provider.hasTexture$;
37355 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
37356 this._hasTextureSubscription = hasTexture$.subscribe(function () { });
37357 var nodeImage$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
37358 return frame.state.nodesAhead === 0;
37359 }), operators_1.map(function (frame) {
37360 return frame.state.currentNode;
37361 }), operators_1.distinctUntilChanged(undefined, function (node) {
37363 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexture$), operators_1.filter(function (args) {
37365 }), operators_1.map(function (args) {
37367 }), operators_1.filter(function (node) {
37369 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
37370 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
37371 }), operators_1.switchMap(function (node) {
37372 var baseImageSize = node.pano ?
37373 Utils_1.Settings.basePanoramaSize :
37374 Utils_1.Settings.baseImageSize;
37375 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
37376 return rxjs_1.empty();
37379 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
37380 return [n.image, n];
37382 return image$.pipe(operators_1.takeUntil(hasTexture$.pipe(operators_1.filter(function (hasTexture) {
37384 }))), operators_1.catchError(function (error, caught) {
37385 console.error("Failed to fetch high res image (" + node.key + ")", error);
37386 return rxjs_1.empty();
37388 })).pipe(operators_1.publish(), operators_1.refCount());
37389 this._updateBackgroundSubscription = nodeImage$.pipe(operators_1.withLatestFrom(textureProvider$))
37390 .subscribe(function (args) {
37391 if (args[0][1].key !== args[1].key ||
37392 args[1].disposed) {
37395 args[1].updateBackground(args[0][0]);
37397 this._updateTextureImageSubscription = nodeImage$.pipe(operators_1.map(function (imn) {
37398 return function (renderer) {
37399 renderer.updateTextureImage(imn[0], imn[1]);
37403 .subscribe(this._glRendererOperation$);
37404 var textureProviderPrev$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
37405 return !!frame.state.previousNode;
37406 }), operators_1.distinctUntilChanged(undefined, function (frame) {
37407 return frame.state.previousNode.key;
37408 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
37409 var frame = _a[0], renderer = _a[1], size = _a[2];
37410 var state = frame.state;
37411 var viewportSize = Math.max(size.width, size.height);
37412 var previousNode = state.previousNode;
37413 var previousTransform = state.previousTransform;
37414 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
37415 return new Tiles_1.TextureProvider(previousNode.key, previousTransform.basicWidth, previousTransform.basicHeight, tileSize, previousNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
37416 }), operators_1.publishReplay(1), operators_1.refCount());
37417 this._textureProviderSubscriptionPrev = textureProviderPrev$.subscribe(function () { });
37418 this._setTextureProviderSubscriptionPrev = textureProviderPrev$.pipe(operators_1.map(function (provider) {
37419 return function (renderer) {
37420 renderer.setTextureProviderPrev(provider.key, provider);
37424 .subscribe(this._glRendererOperation$);
37425 this._setTileSizeSubscriptionPrev = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
37426 return rxjs_1.combineLatest(textureProviderPrev$, rxjs_1.of(size)).pipe(operators_1.first());
37428 .subscribe(function (_a) {
37429 var provider = _a[0], size = _a[1];
37430 var viewportSize = Math.max(size.width, size.height);
37431 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
37432 provider.setTileSize(tileSize);
37434 this._abortTextureProviderSubscriptionPrev = textureProviderPrev$.pipe(operators_1.pairwise())
37435 .subscribe(function (pair) {
37436 var previous = pair[0];
37439 var roiTriggerPrev$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
37440 var camera = _a[0], size = _a[1];
37442 camera.camera.position.clone(),
37443 camera.camera.lookat.clone(),
37444 camera.zoom.valueOf(),
37445 size.height.valueOf(),
37446 size.width.valueOf()
37448 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
37449 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
37450 }), operators_1.map(function (pls) {
37451 var samePosition = pls[0][0].equals(pls[1][0]);
37452 var sameLookat = pls[0][1].equals(pls[1][1]);
37453 var sameZoom = pls[0][2] === pls[1][2];
37454 var sameHeight = pls[0][3] === pls[1][3];
37455 var sameWidth = pls[0][4] === pls[1][4];
37456 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
37457 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
37459 }), operators_1.switchMap(function (stalled) {
37460 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
37461 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
37462 this._setRegionOfInterestSubscriptionPrev = textureProviderPrev$.pipe(operators_1.switchMap(function (provider) {
37463 return roiTriggerPrev$.pipe(operators_1.map(function (_a) {
37464 var camera = _a[0], size = _a[1], transform = _a[2];
37466 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
37470 }), operators_1.filter(function (args) {
37471 return !args[1].disposed;
37472 }), operators_1.withLatestFrom(this._navigator.stateService.currentState$))
37473 .subscribe(function (_a) {
37474 var _b = _a[0], roi = _b[0], provider = _b[1], frame = _a[1];
37475 var shiftedRoi = null;
37476 if (frame.state.previousNode.fullPano) {
37477 if (frame.state.currentNode.fullPano) {
37478 var currentViewingDirection = _this._spatial.viewingDirection(frame.state.currentNode.rotation);
37479 var previousViewingDirection = _this._spatial.viewingDirection(frame.state.previousNode.rotation);
37480 var directionDiff = _this._spatial.angleBetweenVector2(currentViewingDirection.x, currentViewingDirection.y, previousViewingDirection.x, previousViewingDirection.y);
37481 var shift = directionDiff / (2 * Math.PI);
37483 maxX: _this._spatial.wrap(roi.bbox.maxX + shift, 0, 1),
37484 maxY: roi.bbox.maxY,
37485 minX: _this._spatial.wrap(roi.bbox.minX + shift, 0, 1),
37486 minY: roi.bbox.minY,
37490 pixelHeight: roi.pixelHeight,
37491 pixelWidth: roi.pixelWidth,
37495 var currentViewingDirection = _this._spatial.viewingDirection(frame.state.currentNode.rotation);
37496 var previousViewingDirection = _this._spatial.viewingDirection(frame.state.previousNode.rotation);
37497 var directionDiff = _this._spatial.angleBetweenVector2(currentViewingDirection.x, currentViewingDirection.y, previousViewingDirection.x, previousViewingDirection.y);
37498 var shiftX = directionDiff / (2 * Math.PI);
37499 var a1 = _this._spatial.angleToPlane(currentViewingDirection.toArray(), [0, 0, 1]);
37500 var a2 = _this._spatial.angleToPlane(previousViewingDirection.toArray(), [0, 0, 1]);
37501 var shiftY = (a2 - a1) / (2 * Math.PI);
37502 var currentTransform = frame.state.currentTransform;
37503 var size = Math.max(currentTransform.basicWidth, currentTransform.basicHeight);
37504 var hFov = size > 0 ?
37505 2 * Math.atan(0.5 * currentTransform.basicWidth / (size * currentTransform.focal)) :
37507 var vFov = size > 0 ?
37508 2 * Math.atan(0.5 * currentTransform.basicHeight / (size * currentTransform.focal)) :
37510 var spanningWidth = hFov / (2 * Math.PI);
37511 var spanningHeight = vFov / Math.PI;
37512 var basicWidth = (roi.bbox.maxX - roi.bbox.minX) * spanningWidth;
37513 var basicHeight = (roi.bbox.maxY - roi.bbox.minY) * spanningHeight;
37514 var pixelWidth = roi.pixelWidth * spanningWidth;
37515 var pixelHeight = roi.pixelHeight * spanningHeight;
37516 var zoomShiftX = (roi.bbox.minX + roi.bbox.maxX) / 2 - 0.5;
37517 var zoomShiftY = (roi.bbox.minY + roi.bbox.maxY) / 2 - 0.5;
37518 var minX = 0.5 + shiftX + spanningWidth * zoomShiftX - basicWidth / 2;
37519 var maxX = 0.5 + shiftX + spanningWidth * zoomShiftX + basicWidth / 2;
37520 var minY = 0.5 + shiftY + spanningHeight * zoomShiftY - basicHeight / 2;
37521 var maxY = 0.5 + shiftY + spanningHeight * zoomShiftY + basicHeight / 2;
37523 maxX: _this._spatial.wrap(maxX, 0, 1),
37525 minX: _this._spatial.wrap(minX, 0, 1),
37530 pixelHeight: pixelHeight,
37531 pixelWidth: pixelWidth,
37536 var currentBasicAspect = frame.state.currentTransform.basicAspect;
37537 var previousBasicAspect = frame.state.previousTransform.basicAspect;
37538 var _c = _this._getBasicCorners(currentBasicAspect, previousBasicAspect), _d = _c[0], cornerMinX = _d[0], cornerMinY = _d[1], _e = _c[1], cornerMaxX = _e[0], cornerMaxY = _e[1];
37539 var basicWidth = cornerMaxX - cornerMinX;
37540 var basicHeight = cornerMaxY - cornerMinY;
37541 var pixelWidth = roi.pixelWidth / basicWidth;
37542 var pixelHeight = roi.pixelHeight / basicHeight;
37543 var minX = (basicWidth - 1) / (2 * basicWidth) + roi.bbox.minX / basicWidth;
37544 var maxX = (basicWidth - 1) / (2 * basicWidth) + roi.bbox.maxX / basicWidth;
37545 var minY = (basicHeight - 1) / (2 * basicHeight) + roi.bbox.minY / basicHeight;
37546 var maxY = (basicHeight - 1) / (2 * basicHeight) + roi.bbox.maxY / basicHeight;
37553 _this._clipBoundingBox(bbox);
37556 pixelHeight: pixelHeight,
37557 pixelWidth: pixelWidth,
37560 provider.setRegionOfInterest(shiftedRoi);
37562 var hasTexturePrev$ = textureProviderPrev$.pipe(operators_1.switchMap(function (provider) {
37563 return provider.hasTexture$;
37564 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
37565 this._hasTextureSubscriptionPrev = hasTexturePrev$.subscribe(function () { });
37566 var nodeImagePrev$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
37567 return frame.state.nodesAhead === 0 && !!frame.state.previousNode;
37568 }), operators_1.map(function (frame) {
37569 return frame.state.previousNode;
37570 }), operators_1.distinctUntilChanged(undefined, function (node) {
37572 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexturePrev$), operators_1.filter(function (args) {
37574 }), operators_1.map(function (args) {
37576 }), operators_1.filter(function (node) {
37578 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
37579 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
37580 }), operators_1.switchMap(function (node) {
37581 var baseImageSize = node.pano ?
37582 Utils_1.Settings.basePanoramaSize :
37583 Utils_1.Settings.baseImageSize;
37584 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
37585 return rxjs_1.empty();
37588 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
37589 return [n.image, n];
37591 return image$.pipe(operators_1.takeUntil(hasTexturePrev$.pipe(operators_1.filter(function (hasTexture) {
37593 }))), operators_1.catchError(function (error, caught) {
37594 console.error("Failed to fetch high res image (" + node.key + ")", error);
37595 return rxjs_1.empty();
37597 })).pipe(operators_1.publish(), operators_1.refCount());
37598 this._updateBackgroundSubscriptionPrev = nodeImagePrev$.pipe(operators_1.withLatestFrom(textureProviderPrev$))
37599 .subscribe(function (args) {
37600 if (args[0][1].key !== args[1].key ||
37601 args[1].disposed) {
37604 args[1].updateBackground(args[0][0]);
37606 this._updateTextureImageSubscriptionPrev = nodeImagePrev$.pipe(operators_1.map(function (imn) {
37607 return function (renderer) {
37608 renderer.updateTextureImage(imn[0], imn[1]);
37612 .subscribe(this._glRendererOperation$);
37614 SliderComponent.prototype._deactivate = function () {
37616 this._waitSubscription.unsubscribe();
37617 this._navigator.stateService.state$.pipe(operators_1.first())
37618 .subscribe(function (state) {
37619 if (state !== State_1.State.Traversing) {
37620 _this._navigator.stateService.traverse();
37623 this._glRendererDisposer$.next(null);
37624 this._domRenderer.deactivate();
37625 this._modeSubcription.unsubscribe();
37626 this._setKeysSubscription.unsubscribe();
37627 this._stateSubscription.unsubscribe();
37628 this._glRenderSubscription.unsubscribe();
37629 this._domRenderSubscription.unsubscribe();
37630 this._moveSubscription.unsubscribe();
37631 this._updateCurtainSubscription.unsubscribe();
37632 this._textureProviderSubscription.unsubscribe();
37633 this._setTextureProviderSubscription.unsubscribe();
37634 this._setTileSizeSubscription.unsubscribe();
37635 this._abortTextureProviderSubscription.unsubscribe();
37636 this._setRegionOfInterestSubscription.unsubscribe();
37637 this._hasTextureSubscription.unsubscribe();
37638 this._updateBackgroundSubscription.unsubscribe();
37639 this._updateTextureImageSubscription.unsubscribe();
37640 this._textureProviderSubscriptionPrev.unsubscribe();
37641 this._setTextureProviderSubscriptionPrev.unsubscribe();
37642 this._setTileSizeSubscriptionPrev.unsubscribe();
37643 this._abortTextureProviderSubscriptionPrev.unsubscribe();
37644 this._setRegionOfInterestSubscriptionPrev.unsubscribe();
37645 this._hasTextureSubscriptionPrev.unsubscribe();
37646 this._updateBackgroundSubscriptionPrev.unsubscribe();
37647 this._updateTextureImageSubscriptionPrev.unsubscribe();
37648 this.configure({ keys: null });
37650 SliderComponent.prototype._getDefaultConfiguration = function () {
37652 initialPosition: 1,
37653 mode: Component_1.SliderMode.Motion,
37654 sliderVisible: true,
37657 SliderComponent.prototype._catchCacheNode$ = function (key) {
37658 return this._navigator.graphService.cacheNode$(key).pipe(operators_1.catchError(function (error, caught) {
37659 console.error("Failed to cache slider node (" + key + ")", error);
37660 return rxjs_1.empty();
37663 SliderComponent.prototype._getBasicCorners = function (currentAspect, previousAspect) {
37666 if (currentAspect > previousAspect) {
37668 offsetY = 0.5 * currentAspect / previousAspect;
37671 offsetX = 0.5 * previousAspect / currentAspect;
37674 return [[0.5 - offsetX, 0.5 - offsetY], [0.5 + offsetX, 0.5 + offsetY]];
37676 SliderComponent.prototype._clipBoundingBox = function (bbox) {
37677 bbox.minX = Math.max(0, Math.min(1, bbox.minX));
37678 bbox.maxX = Math.max(0, Math.min(1, bbox.maxX));
37679 bbox.minY = Math.max(0, Math.min(1, bbox.minY));
37680 bbox.maxY = Math.max(0, Math.min(1, bbox.maxY));
37682 SliderComponent.componentName = "slider";
37683 return SliderComponent;
37684 }(Component_1.Component));
37685 exports.SliderComponent = SliderComponent;
37686 Component_1.ComponentService.register(SliderComponent);
37687 exports.default = SliderComponent;
37690 },{"../../Component":291,"../../Geo":294,"../../Render":297,"../../State":298,"../../Tiles":300,"../../Utils":301,"rxjs":43,"rxjs/operators":241}],358:[function(require,module,exports){
37692 Object.defineProperty(exports, "__esModule", { value: true });
37693 exports.SliderDOMRenderer = void 0;
37694 var rxjs_1 = require("rxjs");
37695 var operators_1 = require("rxjs/operators");
37696 var vd = require("virtual-dom");
37697 var Component_1 = require("../../Component");
37698 var SliderDOMRenderer = /** @class */ (function () {
37699 function SliderDOMRenderer(container) {
37700 this._container = container;
37701 this._interacting = false;
37702 this._notifyModeChanged$ = new rxjs_1.Subject();
37703 this._notifyPositionChanged$ = new rxjs_1.Subject();
37704 this._stopInteractionSubscription = null;
37706 Object.defineProperty(SliderDOMRenderer.prototype, "mode$", {
37708 return this._notifyModeChanged$;
37713 Object.defineProperty(SliderDOMRenderer.prototype, "position$", {
37715 return this._notifyPositionChanged$;
37720 SliderDOMRenderer.prototype.activate = function () {
37722 if (!!this._stopInteractionSubscription) {
37725 this._stopInteractionSubscription = rxjs_1.merge(this._container.mouseService.documentMouseUp$, this._container.touchService.touchEnd$.pipe(operators_1.filter(function (touchEvent) {
37726 return touchEvent.touches.length === 0;
37728 .subscribe(function (event) {
37729 if (_this._interacting) {
37730 _this._interacting = false;
37734 SliderDOMRenderer.prototype.deactivate = function () {
37735 if (!this._stopInteractionSubscription) {
37738 this._interacting = false;
37739 this._stopInteractionSubscription.unsubscribe();
37740 this._stopInteractionSubscription = null;
37742 SliderDOMRenderer.prototype.render = function (position, mode, motionless, pano, visible) {
37745 children.push(vd.h("div.SliderBorder", []));
37746 var modeVisible = !(motionless || pano);
37748 children.push(this._createModeButton(mode));
37749 children.push(this._createModeButton2d(mode));
37751 children.push(this._createPositionInput(position, modeVisible));
37753 var boundingRect = this._container.domContainer.getBoundingClientRect();
37754 var width = Math.max(215, Math.min(400, boundingRect.width - 100));
37755 return vd.h("div.SliderContainer", { style: { width: width + "px" } }, children);
37757 SliderDOMRenderer.prototype._createModeButton = function (mode) {
37760 onclick: function () {
37761 if (mode === Component_1.SliderMode.Motion) {
37764 _this._notifyModeChanged$.next(Component_1.SliderMode.Motion);
37767 var className = mode === Component_1.SliderMode.Stationary ?
37768 "SliderModeButtonDisabled" :
37769 "SliderModeButton";
37770 return vd.h("div." + className, properties, [vd.h("div.SliderModeIcon", [])]);
37772 SliderDOMRenderer.prototype._createModeButton2d = function (mode) {
37775 onclick: function () {
37776 if (mode === Component_1.SliderMode.Stationary) {
37779 _this._notifyModeChanged$.next(Component_1.SliderMode.Stationary);
37782 var className = mode === Component_1.SliderMode.Motion ?
37783 "SliderModeButton2dDisabled" :
37784 "SliderModeButton2d";
37785 return vd.h("div." + className, properties, [vd.h("div.SliderModeIcon2d", [])]);
37787 SliderDOMRenderer.prototype._createPositionInput = function (position, modeVisible) {
37789 var onChange = function (e) {
37790 _this._notifyPositionChanged$.next(Number(e.target.value) / 1000);
37792 var onStart = function (e) {
37793 _this._interacting = true;
37794 e.stopPropagation();
37796 var onMove = function (e) {
37797 if (_this._interacting) {
37798 e.stopPropagation();
37801 var onKeyDown = function (e) {
37802 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
37803 e.key === "ArrowRight" || e.key === "ArrowUp") {
37804 e.preventDefault();
37807 var boundingRect = this._container.domContainer.getBoundingClientRect();
37808 var width = Math.max(215, Math.min(400, boundingRect.width - 105)) - 84 + (modeVisible ? 0 : 52);
37809 var positionInput = vd.h("input.SliderPosition", {
37812 onchange: onChange,
37814 onkeydown: onKeyDown,
37815 onmousedown: onStart,
37816 onmousemove: onMove,
37817 ontouchmove: onMove,
37818 ontouchstart: onStart,
37820 width: width + "px",
37823 value: 1000 * position,
37825 return vd.h("div.SliderPositionContainer", [positionInput]);
37827 return SliderDOMRenderer;
37829 exports.SliderDOMRenderer = SliderDOMRenderer;
37830 exports.default = SliderDOMRenderer;
37832 },{"../../Component":291,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],359:[function(require,module,exports){
37834 Object.defineProperty(exports, "__esModule", { value: true });
37835 exports.SliderGLRenderer = void 0;
37836 var Component_1 = require("../../Component");
37837 var Geo_1 = require("../../Geo");
37838 var SliderGLRenderer = /** @class */ (function () {
37839 function SliderGLRenderer() {
37840 this._factory = new Component_1.MeshFactory();
37841 this._scene = new Component_1.MeshScene();
37842 this._spatial = new Geo_1.Spatial();
37843 this._currentKey = null;
37844 this._previousKey = null;
37845 this._disabled = false;
37848 this._needsRender = false;
37850 this._currentProviderDisposers = {};
37851 this._previousProviderDisposers = {};
37853 Object.defineProperty(SliderGLRenderer.prototype, "disabled", {
37855 return this._disabled;
37860 Object.defineProperty(SliderGLRenderer.prototype, "frameId", {
37862 return this._frameId;
37867 Object.defineProperty(SliderGLRenderer.prototype, "needsRender", {
37869 return this._needsRender;
37874 SliderGLRenderer.prototype.setTextureProvider = function (key, provider) {
37875 this._setTextureProvider(key, this._currentKey, provider, this._currentProviderDisposers, this._updateTexture.bind(this));
37877 SliderGLRenderer.prototype.setTextureProviderPrev = function (key, provider) {
37878 this._setTextureProvider(key, this._previousKey, provider, this._previousProviderDisposers, this._updateTexturePrev.bind(this));
37880 SliderGLRenderer.prototype.update = function (frame, mode) {
37881 this._updateFrameId(frame.id);
37882 this._updateImagePlanes(frame.state, mode);
37884 SliderGLRenderer.prototype.updateCurtain = function (curtain) {
37885 if (this._curtain === curtain) {
37888 this._curtain = curtain;
37889 this._updateCurtain();
37890 this._needsRender = true;
37892 SliderGLRenderer.prototype.updateTexture = function (image, node) {
37893 var planes = node.key === this._currentKey ?
37894 this._scene.planes :
37895 node.key === this._previousKey ?
37896 this._scene.planesOld :
37898 if (Object.keys(planes).length === 0) {
37901 this._needsRender = true;
37902 for (var key in planes) {
37903 if (!planes.hasOwnProperty(key)) {
37906 var plane = planes[key];
37907 var material = plane.material;
37908 var texture = material.uniforms.projectorTex.value;
37909 texture.image = image;
37910 texture.needsUpdate = true;
37913 SliderGLRenderer.prototype.updateTextureImage = function (image, node) {
37914 if (this._currentKey !== node.key) {
37917 this._needsRender = true;
37918 var planes = this._scene.planes;
37919 for (var key in planes) {
37920 if (!planes.hasOwnProperty(key)) {
37923 var plane = planes[key];
37924 var material = plane.material;
37925 var texture = material.uniforms.projectorTex.value;
37926 texture.image = image;
37927 texture.needsUpdate = true;
37930 SliderGLRenderer.prototype.render = function (perspectiveCamera, renderer) {
37931 if (!this.disabled) {
37932 renderer.render(this._scene.sceneOld, perspectiveCamera);
37934 renderer.render(this._scene.scene, perspectiveCamera);
37935 this._needsRender = false;
37937 SliderGLRenderer.prototype.dispose = function () {
37938 this._scene.clear();
37939 for (var key in this._currentProviderDisposers) {
37940 if (!this._currentProviderDisposers.hasOwnProperty(key)) {
37943 this._currentProviderDisposers[key]();
37945 for (var key in this._previousProviderDisposers) {
37946 if (!this._previousProviderDisposers.hasOwnProperty(key)) {
37949 this._previousProviderDisposers[key]();
37951 this._currentProviderDisposers = {};
37952 this._previousProviderDisposers = {};
37954 SliderGLRenderer.prototype._getBasicCorners = function (currentAspect, previousAspect) {
37957 if (currentAspect > previousAspect) {
37959 offsetY = 0.5 * currentAspect / previousAspect;
37962 offsetX = 0.5 * previousAspect / currentAspect;
37965 return [[0.5 - offsetX, 0.5 - offsetY], [0.5 + offsetX, 0.5 + offsetY]];
37967 SliderGLRenderer.prototype._setDisabled = function (state) {
37968 this._disabled = state.currentNode == null ||
37969 state.previousNode == null ||
37970 (state.currentNode.pano && !state.currentNode.fullPano) ||
37971 (state.previousNode.pano && !state.previousNode.fullPano) ||
37972 (state.currentNode.fullPano && !state.previousNode.fullPano);
37974 SliderGLRenderer.prototype._setTextureProvider = function (key, originalKey, provider, providerDisposers, updateTexture) {
37976 if (key !== originalKey) {
37979 var createdSubscription = provider.textureCreated$
37980 .subscribe(updateTexture);
37981 var updatedSubscription = provider.textureUpdated$
37982 .subscribe(function (updated) {
37983 _this._needsRender = true;
37985 var dispose = function () {
37986 createdSubscription.unsubscribe();
37987 updatedSubscription.unsubscribe();
37988 provider.dispose();
37990 if (key in providerDisposers) {
37991 var disposeProvider = providerDisposers[key];
37993 delete providerDisposers[key];
37995 providerDisposers[key] = dispose;
37997 SliderGLRenderer.prototype._updateCurtain = function () {
37998 var planes = this._scene.planes;
37999 for (var key in planes) {
38000 if (!planes.hasOwnProperty(key)) {
38003 var plane = planes[key];
38004 var shaderMaterial = plane.material;
38005 if (!!shaderMaterial.uniforms.curtain) {
38006 shaderMaterial.uniforms.curtain.value = this._curtain;
38010 SliderGLRenderer.prototype._updateFrameId = function (frameId) {
38011 this._frameId = frameId;
38013 SliderGLRenderer.prototype._updateImagePlanes = function (state, mode) {
38014 var currentChanged = state.currentNode != null && this._currentKey !== state.currentNode.key;
38015 var previousChanged = state.previousNode != null && this._previousKey !== state.previousNode.key;
38016 var modeChanged = this._mode !== mode;
38017 if (!(currentChanged || previousChanged || modeChanged)) {
38020 this._setDisabled(state);
38021 this._needsRender = true;
38023 var motionless = state.motionless || mode === Component_1.SliderMode.Stationary || state.currentNode.pano;
38024 if (this.disabled || previousChanged) {
38025 if (this._previousKey in this._previousProviderDisposers) {
38026 this._previousProviderDisposers[this._previousKey]();
38027 delete this._previousProviderDisposers[this._previousKey];
38030 if (this.disabled) {
38031 this._scene.setImagePlanesOld({});
38034 if (previousChanged || modeChanged) {
38035 var previousNode = state.previousNode;
38036 this._previousKey = previousNode.key;
38037 var elements = state.currentTransform.rt.elements;
38038 var translation = [elements[12], elements[13], elements[14]];
38039 var currentAspect = state.currentTransform.basicAspect;
38040 var previousAspect = state.previousTransform.basicAspect;
38041 var textureScale = currentAspect > previousAspect ?
38042 [1, previousAspect / currentAspect] :
38043 [currentAspect / previousAspect, 1];
38044 var rotation = state.currentNode.rotation;
38045 var width = state.currentNode.width;
38046 var height = state.currentNode.height;
38047 if (previousNode.fullPano) {
38048 rotation = state.previousNode.rotation;
38049 translation = this._spatial
38050 .rotate(this._spatial
38051 .opticalCenter(state.currentNode.rotation, translation)
38052 .toArray(), rotation)
38053 .multiplyScalar(-1)
38055 width = state.previousNode.width;
38056 height = state.previousNode.height;
38058 var transform = new Geo_1.Transform(state.currentNode.orientation, width, height, state.currentNode.focal, state.currentNode.scale, previousNode.gpano, rotation, translation, previousNode.image, textureScale);
38059 var mesh = undefined;
38060 if (previousNode.fullPano) {
38061 mesh = this._factory.createMesh(previousNode, motionless || state.currentNode.fullPano ? transform : state.previousTransform);
38065 var _a = this._getBasicCorners(currentAspect, previousAspect), _b = _a[0], basicX0 = _b[0], basicY0 = _b[1], _c = _a[1], basicX1 = _c[0], basicY1 = _c[1];
38066 mesh = this._factory.createFlatMesh(state.previousNode, transform, basicX0, basicX1, basicY0, basicY1);
38069 mesh = this._factory.createMesh(state.previousNode, state.previousTransform);
38072 var previousPlanes = {};
38073 previousPlanes[previousNode.key] = mesh;
38074 this._scene.setImagePlanesOld(previousPlanes);
38077 if (currentChanged || modeChanged) {
38078 if (this._currentKey in this._currentProviderDisposers) {
38079 this._currentProviderDisposers[this._currentKey]();
38080 delete this._currentProviderDisposers[this._currentKey];
38082 this._currentKey = state.currentNode.key;
38084 if (state.currentNode.fullPano) {
38085 planes[state.currentNode.key] = this._factory.createCurtainMesh(state.currentNode, state.currentTransform);
38087 else if (state.currentNode.pano && !state.currentNode.fullPano) {
38088 planes[state.currentNode.key] = this._factory.createMesh(state.currentNode, state.currentTransform);
38092 planes[state.currentNode.key] = this._factory.createDistortedCurtainMesh(state.currentNode, state.currentTransform);
38095 planes[state.currentNode.key] = this._factory.createCurtainMesh(state.currentNode, state.currentTransform);
38098 this._scene.setImagePlanes(planes);
38099 this._updateCurtain();
38102 SliderGLRenderer.prototype._updateTexture = function (texture) {
38103 this._needsRender = true;
38104 var planes = this._scene.planes;
38105 for (var key in planes) {
38106 if (!planes.hasOwnProperty(key)) {
38109 var plane = planes[key];
38110 var material = plane.material;
38111 var oldTexture = material.uniforms.projectorTex.value;
38112 material.uniforms.projectorTex.value = null;
38113 oldTexture.dispose();
38114 material.uniforms.projectorTex.value = texture;
38117 SliderGLRenderer.prototype._updateTexturePrev = function (texture) {
38118 this._needsRender = true;
38119 var planes = this._scene.planesOld;
38120 for (var key in planes) {
38121 if (!planes.hasOwnProperty(key)) {
38124 var plane = planes[key];
38125 var material = plane.material;
38126 var oldTexture = material.uniforms.projectorTex.value;
38127 material.uniforms.projectorTex.value = null;
38128 oldTexture.dispose();
38129 material.uniforms.projectorTex.value = texture;
38132 return SliderGLRenderer;
38134 exports.SliderGLRenderer = SliderGLRenderer;
38135 exports.default = SliderGLRenderer;
38138 },{"../../Component":291,"../../Geo":294}],360:[function(require,module,exports){
38140 Object.defineProperty(exports, "__esModule", { value: true });
38141 exports.CameraVisualizationMode = void 0;
38142 var CameraVisualizationMode;
38143 (function (CameraVisualizationMode) {
38144 CameraVisualizationMode[CameraVisualizationMode["Default"] = 0] = "Default";
38145 CameraVisualizationMode[CameraVisualizationMode["Cluster"] = 1] = "Cluster";
38146 CameraVisualizationMode[CameraVisualizationMode["ConnectedComponent"] = 2] = "ConnectedComponent";
38147 CameraVisualizationMode[CameraVisualizationMode["Sequence"] = 3] = "Sequence";
38148 })(CameraVisualizationMode = exports.CameraVisualizationMode || (exports.CameraVisualizationMode = {}));
38149 exports.default = CameraVisualizationMode;
38151 },{}],361:[function(require,module,exports){
38153 Object.defineProperty(exports, "__esModule", { value: true });
38154 var CameraVisualizationMode_1 = require("./CameraVisualizationMode");
38155 Object.defineProperty(exports, "CameraVisualizationMode", { enumerable: true, get: function () { return CameraVisualizationMode_1.CameraVisualizationMode; } });
38157 },{"./CameraVisualizationMode":360}],362:[function(require,module,exports){
38159 Object.defineProperty(exports, "__esModule", { value: true });
38160 exports.SpatialDataCache = void 0;
38161 var geohash = require("latlon-geohash");
38162 var pako = require("pako");
38163 var rxjs_1 = require("rxjs");
38164 var operators_1 = require("rxjs/operators");
38165 var Error_1 = require("../../Error");
38166 var Utils_1 = require("../../Utils");
38167 var SpatialDataCache = /** @class */ (function () {
38168 function SpatialDataCache(graphService) {
38169 this._graphService = graphService;
38171 this._cacheRequests = {};
38172 this._clusterReconstructions = {};
38173 this._clusterReconstructionTiles = {};
38174 this._tileClusters = {};
38175 this._cachingTiles$ = {};
38176 this._cachingClusterReconstructions$ = {};
38178 SpatialDataCache.prototype.cacheClusterReconstructions$ = function (hash) {
38180 if (!this.hasTile(hash)) {
38181 throw new Error("Cannot cache reconstructions of a non-existing tile.");
38183 if (this.hasClusterReconstructions(hash)) {
38184 throw new Error("Cannot cache reconstructions that already exists.");
38186 if (this.isCachingClusterReconstructions(hash)) {
38187 return this._cachingClusterReconstructions$[hash];
38189 var clusterKeys = this.getTile(hash)
38190 .filter(function (nd) {
38191 return !!nd.clusterKey;
38193 .map(function (nd) {
38194 return nd.clusterKey;
38196 .filter(function (v, i, a) {
38197 return a.indexOf(v) === i;
38199 this._tileClusters[hash] = clusterKeys;
38200 this._cacheRequests[hash] = [];
38201 this._cachingClusterReconstructions$[hash] = rxjs_1.from(clusterKeys).pipe(operators_1.mergeMap(function (key) {
38202 if (_this._hasClusterReconstruction(key)) {
38203 return rxjs_1.of(_this._getClusterReconstruction(key));
38205 return _this._getClusterReconstruction$(key, _this._cacheRequests[hash])
38206 .pipe(operators_1.catchError(function (error) {
38207 if (error instanceof Error_1.AbortMapillaryError) {
38208 return rxjs_1.empty();
38210 console.error(error);
38211 return rxjs_1.empty();
38213 }, 6), operators_1.filter(function () {
38214 return hash in _this._tileClusters;
38215 }), operators_1.tap(function (reconstruction) {
38216 if (!_this._hasClusterReconstruction(reconstruction.key)) {
38217 _this._clusterReconstructions[reconstruction.key] = reconstruction;
38219 if (!(reconstruction.key in _this._clusterReconstructionTiles)) {
38220 _this._clusterReconstructionTiles[reconstruction.key] = [];
38222 if (_this._clusterReconstructionTiles[reconstruction.key].indexOf(hash) === -1) {
38223 _this._clusterReconstructionTiles[reconstruction.key].push(hash);
38225 }), operators_1.finalize(function () {
38226 if (hash in _this._cachingClusterReconstructions$) {
38227 delete _this._cachingClusterReconstructions$[hash];
38229 if (hash in _this._cacheRequests) {
38230 delete _this._cacheRequests[hash];
38232 }), operators_1.publish(), operators_1.refCount());
38233 return this._cachingClusterReconstructions$[hash];
38235 SpatialDataCache.prototype.cacheTile$ = function (hash) {
38237 if (hash.length !== 8) {
38238 throw new Error("Hash needs to be level 8.");
38240 if (this.hasTile(hash)) {
38241 throw new Error("Cannot cache tile that already exists.");
38243 if (this.isCachingTile(hash)) {
38244 return this._cachingTiles$[hash];
38246 var bounds = geohash.bounds(hash);
38247 var sw = { lat: bounds.sw.lat, lon: bounds.sw.lon };
38248 var ne = { lat: bounds.ne.lat, lon: bounds.ne.lon };
38249 this._cachingTiles$[hash] = this._graphService.cacheBoundingBox$(sw, ne).pipe(operators_1.catchError(function (error) {
38250 console.error(error);
38251 return rxjs_1.empty();
38252 }), operators_1.map(function (nodes) {
38254 .map(function (n) {
38255 return _this._createNodeData(n);
38257 }), operators_1.filter(function () {
38258 return !(hash in _this._tiles);
38259 }), operators_1.tap(function (nodeData) {
38261 _this._tiles[hash] = [];
38262 (_a = _this._tiles[hash]).push.apply(_a, nodeData);
38263 delete _this._cachingTiles$[hash];
38264 }), operators_1.finalize(function () {
38265 if (hash in _this._cachingTiles$) {
38266 delete _this._cachingTiles$[hash];
38268 }), operators_1.publish(), operators_1.refCount());
38269 return this._cachingTiles$[hash];
38271 SpatialDataCache.prototype.isCachingClusterReconstructions = function (hash) {
38272 return hash in this._cachingClusterReconstructions$;
38274 SpatialDataCache.prototype.isCachingTile = function (hash) {
38275 return hash in this._cachingTiles$;
38277 SpatialDataCache.prototype.hasClusterReconstructions = function (hash) {
38278 if (hash in this._cachingClusterReconstructions$ ||
38279 !(hash in this._tileClusters)) {
38282 for (var _i = 0, _a = this._tileClusters[hash]; _i < _a.length; _i++) {
38284 if (!(key in this._clusterReconstructions)) {
38290 SpatialDataCache.prototype.hasTile = function (hash) {
38291 return !(hash in this._cachingTiles$) && hash in this._tiles;
38293 SpatialDataCache.prototype.getClusterReconstructions = function (hash) {
38295 return hash in this._tileClusters ?
38296 this._tileClusters[hash]
38297 .map(function (key) {
38298 return _this._clusterReconstructions[key];
38300 .filter(function (reconstruction) {
38301 return !!reconstruction;
38305 SpatialDataCache.prototype.getTile = function (hash) {
38306 return hash in this._tiles ? this._tiles[hash] : [];
38308 SpatialDataCache.prototype.uncache = function (keepHashes) {
38309 for (var _i = 0, _a = Object.keys(this._cacheRequests); _i < _a.length; _i++) {
38311 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
38314 for (var _b = 0, _c = this._cacheRequests[hash]; _b < _c.length; _b++) {
38315 var request = _c[_b];
38318 delete this._cacheRequests[hash];
38320 for (var _d = 0, _e = Object.keys(this._tileClusters); _d < _e.length; _d++) {
38322 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
38325 for (var _f = 0, _g = this._tileClusters[hash]; _f < _g.length; _f++) {
38327 if (!(key in this._clusterReconstructionTiles)) {
38330 var index = this._clusterReconstructionTiles[key].indexOf(hash);
38331 if (index === -1) {
38334 this._clusterReconstructionTiles[key].splice(index, 1);
38335 if (this._clusterReconstructionTiles[key].length > 0) {
38338 delete this._clusterReconstructionTiles[key];
38339 delete this._clusterReconstructions[key];
38341 delete this._tileClusters[hash];
38343 for (var _h = 0, _j = Object.keys(this._tiles); _h < _j.length; _h++) {
38345 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
38348 delete this._tiles[hash];
38351 SpatialDataCache.prototype._createNodeData = function (node) {
38354 cameraProjection: node.cameraProjection,
38355 clusterKey: node.clusterKey,
38358 height: node.height,
38362 lat: node.latLon.lat,
38363 lon: node.latLon.lon,
38364 mergeCC: node.mergeCC,
38365 orientation: node.orientation,
38366 originalLat: node.originalLatLon.lat,
38367 originalLon: node.originalLatLon.lon,
38368 rotation: [node.rotation[0], node.rotation[1], node.rotation[2]],
38370 sequenceKey: node.sequenceKey,
38374 SpatialDataCache.prototype._getClusterReconstruction = function (key) {
38375 return this._clusterReconstructions[key];
38377 SpatialDataCache.prototype._getClusterReconstruction$ = function (key, requests) {
38378 return rxjs_1.Observable.create(function (subscriber) {
38379 var xhr = new XMLHttpRequest();
38380 xhr.open("GET", Utils_1.Urls.clusterReconstruction(key), true);
38381 xhr.responseType = "arraybuffer";
38382 xhr.timeout = 15000;
38383 xhr.onload = function () {
38384 if (!xhr.response) {
38385 subscriber.error(new Error("Cluster reconstruction retreival failed (" + key + ")"));
38388 var inflated = pako.inflate(xhr.response, { to: "string" });
38389 var reconstructions = JSON.parse(inflated);
38390 if (reconstructions.length < 1) {
38391 subscriber.error(new Error("No cluster reconstruction exists (" + key + ")"));
38393 var reconstruction = reconstructions[0];
38394 reconstruction.key = key;
38395 subscriber.next(reconstruction);
38396 subscriber.complete();
38399 xhr.onerror = function () {
38400 subscriber.error(new Error("Failed to get cluster reconstruction (" + key + ")"));
38402 xhr.ontimeout = function () {
38403 subscriber.error(new Error("Cluster reconstruction request timed out (" + key + ")"));
38405 xhr.onabort = function () {
38406 subscriber.error(new Error_1.AbortMapillaryError("Cluster reconstruction request was aborted (" + key + ")"));
38408 requests.push(xhr);
38412 SpatialDataCache.prototype._hasClusterReconstruction = function (key) {
38413 return key in this._clusterReconstructions;
38415 return SpatialDataCache;
38417 exports.SpatialDataCache = SpatialDataCache;
38418 exports.default = SpatialDataCache;
38420 },{"../../Error":293,"../../Utils":301,"latlon-geohash":21,"pako":23,"rxjs":43,"rxjs/operators":241}],363:[function(require,module,exports){
38422 var __extends = (this && this.__extends) || (function () {
38423 var extendStatics = function (d, b) {
38424 extendStatics = Object.setPrototypeOf ||
38425 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
38426 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
38427 return extendStatics(d, b);
38429 return function (d, b) {
38430 extendStatics(d, b);
38431 function __() { this.constructor = d; }
38432 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
38435 Object.defineProperty(exports, "__esModule", { value: true });
38436 exports.SpatialDataComponent = void 0;
38437 var geohash = require("latlon-geohash");
38438 var rxjs_1 = require("rxjs");
38439 var operators_1 = require("rxjs/operators");
38440 var Component_1 = require("../../Component");
38441 var Geo_1 = require("../../Geo");
38442 var Render_1 = require("../../Render");
38443 var PlayService_1 = require("../../viewer/PlayService");
38444 var State_1 = require("../../state/State");
38445 var CameraVisualizationMode_1 = require("./CameraVisualizationMode");
38446 var SpatialDataComponent = /** @class */ (function (_super) {
38447 __extends(SpatialDataComponent, _super);
38448 function SpatialDataComponent(name, container, navigator) {
38449 var _this = _super.call(this, name, container, navigator) || this;
38450 _this._cache = new Component_1.SpatialDataCache(navigator.graphService);
38451 _this._scene = new Component_1.SpatialDataScene(_this._getDefaultConfiguration());
38452 _this._viewportCoords = new Geo_1.ViewportCoords();
38453 _this._geoCoords = new Geo_1.GeoCoords();
38456 SpatialDataComponent.prototype._activate = function () {
38458 this._earthControlsSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
38459 return configuration.earthControls;
38460 }), operators_1.distinctUntilChanged(), operators_1.withLatestFrom(this._navigator.stateService.state$))
38461 .subscribe(function (_a) {
38462 var earth = _a[0], state = _a[1];
38463 if (earth && state !== State_1.default.Earth) {
38464 _this._navigator.stateService.earth();
38466 else if (!earth && state === State_1.default.Earth) {
38467 _this._navigator.stateService.traverse();
38470 var direction$ = this._container.renderService.bearing$.pipe(operators_1.map(function (bearing) {
38471 var direction = "";
38472 if (bearing > 292.5 || bearing <= 67.5) {
38475 if (bearing > 112.5 && bearing <= 247.5) {
38478 if (bearing > 22.5 && bearing <= 157.5) {
38481 if (bearing > 202.5 && bearing <= 337.5) {
38485 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
38486 var hash$ = this._navigator.stateService.reference$.pipe(operators_1.tap(function () {
38487 _this._scene.uncache();
38488 }), operators_1.switchMap(function () {
38489 return _this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
38490 return geohash.encode(node.latLon.lat, node.latLon.lon, 8);
38491 }), operators_1.distinctUntilChanged());
38492 }), operators_1.publishReplay(1), operators_1.refCount());
38493 var sequencePlay$ = rxjs_1.combineLatest(this._navigator.playService.playing$, this._navigator.playService.speed$).pipe(operators_1.map(function (_a) {
38494 var playing = _a[0], speed = _a[1];
38495 return playing && speed > PlayService_1.default.sequenceSpeed;
38496 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
38497 var hashes$ = rxjs_1.combineLatest(this._navigator.stateService.state$.pipe(operators_1.map(function (state) {
38498 return state === State_1.default.Earth;
38499 }), operators_1.distinctUntilChanged()), hash$, sequencePlay$, direction$).pipe(operators_1.distinctUntilChanged(function (_a, _b) {
38500 var e1 = _a[0], h1 = _a[1], s1 = _a[2], d1 = _a[3];
38501 var e2 = _b[0], h2 = _b[1], s2 = _b[2], d2 = _b[3];
38506 return h1 === h2 && s1 === s2;
38508 return h1 === h2 && s1 === s2 && d1 === d2;
38509 }), operators_1.concatMap(function (_a) {
38510 var earth = _a[0], hash = _a[1], sequencePlay = _a[2], direction = _a[3];
38512 return sequencePlay ?
38513 rxjs_1.of([hash]) :
38514 rxjs_1.of(_this._adjacentComponent(hash, 4));
38516 return sequencePlay ?
38517 rxjs_1.of([hash, geohash.neighbours(hash)[direction]]) :
38518 rxjs_1.of(_this._computeTiles(hash, direction));
38519 }), operators_1.publish(), operators_1.refCount());
38520 var tile$ = hashes$.pipe(operators_1.switchMap(function (hashes) {
38521 return rxjs_1.from(hashes).pipe(operators_1.mergeMap(function (h) {
38522 var t$ = _this._cache.hasTile(h) ?
38523 rxjs_1.of(_this._cache.getTile(h)) :
38524 _this._cache.cacheTile$(h);
38525 return rxjs_1.combineLatest(rxjs_1.of(h), t$);
38527 }), operators_1.publish(), operators_1.refCount());
38528 this._addTileSubscription = tile$.pipe(operators_1.withLatestFrom(this._navigator.stateService.reference$))
38529 .subscribe(function (_a) {
38530 var hash = _a[0][0], reference = _a[1];
38531 if (_this._scene.hasTile(hash)) {
38534 _this._scene.addTile(_this._computeTileBBox(hash, reference), hash);
38536 this._addNodeSubscription = tile$.pipe(operators_1.withLatestFrom(this._navigator.stateService.reference$))
38537 .subscribe(function (_a) {
38538 var _b = _a[0], hash = _b[0], datas = _b[1], reference = _a[1];
38539 for (var _i = 0, datas_1 = datas; _i < datas_1.length; _i++) {
38540 var data = datas_1[_i];
38541 if (_this._scene.hasNode(data.key, hash)) {
38544 _this._scene.addNode(data, _this._createTransform(data, reference), _this._computeOriginalPosition(data, reference), hash);
38547 this._addReconstructionSubscription = tile$.pipe(operators_1.concatMap(function (_a) {
38549 var reconstructions$;
38550 if (_this._cache.hasClusterReconstructions(hash)) {
38551 reconstructions$ = rxjs_1.from(_this._cache.getClusterReconstructions(hash));
38553 else if (_this._cache.isCachingClusterReconstructions(hash)) {
38554 reconstructions$ = _this._cache.cacheClusterReconstructions$(hash).pipe(operators_1.last(null, {}), operators_1.switchMap(function () {
38555 return rxjs_1.from(_this._cache.getClusterReconstructions(hash));
38558 else if (_this._cache.hasTile(hash)) {
38559 reconstructions$ = _this._cache.cacheClusterReconstructions$(hash);
38562 reconstructions$ = rxjs_1.empty();
38564 return rxjs_1.combineLatest(rxjs_1.of(hash), reconstructions$);
38565 }), operators_1.withLatestFrom(this._navigator.stateService.reference$))
38566 .subscribe(function (_a) {
38567 var _b = _a[0], hash = _b[0], reconstruction = _b[1], reference = _a[1];
38568 if (_this._scene.hasClusterReconstruction(reconstruction.key, hash)) {
38571 _this._scene.addClusterReconstruction(reconstruction, _this._computeTranslation(reconstruction, reference), hash);
38573 this._cameraVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
38574 return configuration.camerasVisible;
38575 }), operators_1.distinctUntilChanged())
38576 .subscribe(function (visible) {
38577 _this._scene.setCameraVisibility(visible);
38579 this._pointVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
38580 return configuration.pointsVisible;
38581 }), operators_1.distinctUntilChanged())
38582 .subscribe(function (visible) {
38583 _this._scene.setPointVisibility(visible);
38585 this._positionVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
38586 return configuration.positionsVisible;
38587 }), operators_1.distinctUntilChanged())
38588 .subscribe(function (visible) {
38589 _this._scene.setPositionVisibility(visible);
38591 this._tileVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
38592 return configuration.tilesVisible;
38593 }), operators_1.distinctUntilChanged())
38594 .subscribe(function (visible) {
38595 _this._scene.setTileVisibility(visible);
38597 this._ccToModeSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
38598 return configuration.connectedComponents === true ?
38599 CameraVisualizationMode_1.default.ConnectedComponent :
38600 CameraVisualizationMode_1.default.Default;
38601 }), operators_1.distinctUntilChanged())
38602 .subscribe(function (mode) {
38603 _this.configure({ cameraVisualizationMode: mode });
38605 this._cameraVisualizationModeSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
38606 return configuration.cameraVisualizationMode;
38607 }), operators_1.distinctUntilChanged())
38608 .subscribe(function (mode) {
38609 _this._scene.setCameraVisualizationMode(mode);
38611 this._uncacheSubscription = hash$
38612 .subscribe(function (hash) {
38613 var keepHashes = _this._adjacentComponent(hash, 4);
38614 _this._scene.uncache(keepHashes);
38615 _this._cache.uncache(keepHashes);
38617 this._moveSubscription = this._navigator.playService.playing$.pipe(operators_1.switchMap(function (playing) {
38620 _this._container.mouseService.dblClick$;
38621 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$), operators_1.switchMap(function (_a) {
38622 var event = _a[0], render = _a[1];
38623 var element = _this._container.element;
38624 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
38625 var viewport = _this._viewportCoords.canvasToViewport(canvasX, canvasY, element);
38626 var key = _this._scene.intersectObjects(viewport, render.perspective);
38628 _this._navigator.moveToKey$(key).pipe(operators_1.catchError(function () {
38629 return rxjs_1.empty();
38634 this._renderSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
38635 var scene = _this._scene;
38640 needsRender: scene.needsRender,
38641 render: scene.render.bind(scene),
38642 stage: Render_1.GLRenderStage.Foreground,
38646 .subscribe(this._container.glRenderer.render$);
38648 SpatialDataComponent.prototype._deactivate = function () {
38650 this._cache.uncache();
38651 this._scene.uncache();
38652 this._addNodeSubscription.unsubscribe();
38653 this._addReconstructionSubscription.unsubscribe();
38654 this._addTileSubscription.unsubscribe();
38655 this._cameraVisibilitySubscription.unsubscribe();
38656 this._earthControlsSubscription.unsubscribe();
38657 this._moveSubscription.unsubscribe();
38658 this._pointVisibilitySubscription.unsubscribe();
38659 this._positionVisibilitySubscription.unsubscribe();
38660 this._renderSubscription.unsubscribe();
38661 this._tileVisibilitySubscription.unsubscribe();
38662 this._uncacheSubscription.unsubscribe();
38663 this._cameraVisualizationModeSubscription.unsubscribe();
38664 this._ccToModeSubscription.unsubscribe();
38665 this._navigator.stateService.state$.pipe(operators_1.first())
38666 .subscribe(function (state) {
38667 if (state === State_1.default.Earth) {
38668 _this._navigator.stateService.traverse();
38672 SpatialDataComponent.prototype._getDefaultConfiguration = function () {
38674 cameraVisualizationMode: CameraVisualizationMode_1.default.Default,
38675 camerasVisible: false,
38676 connectedComponents: false,
38677 pointsVisible: true,
38678 positionsVisible: false,
38679 tilesVisible: false,
38682 SpatialDataComponent.prototype._adjacentComponent = function (hash, depth) {
38683 var hashSet = new Set();
38685 this._adjacentComponentRecursive(hashSet, [hash], 0, depth);
38686 return this._setToArray(hashSet);
38688 SpatialDataComponent.prototype._adjacentComponentRecursive = function (hashSet, currentHashes, currentDepth, maxDepth) {
38689 if (currentDepth === maxDepth) {
38692 var neighbours = [];
38693 for (var _i = 0, currentHashes_1 = currentHashes; _i < currentHashes_1.length; _i++) {
38694 var hash = currentHashes_1[_i];
38695 var hashNeighbours = geohash.neighbours(hash);
38696 for (var direction in hashNeighbours) {
38697 if (!hashNeighbours.hasOwnProperty(direction)) {
38700 neighbours.push(hashNeighbours[direction]);
38703 var newHashes = [];
38704 for (var _a = 0, neighbours_1 = neighbours; _a < neighbours_1.length; _a++) {
38705 var neighbour = neighbours_1[_a];
38706 if (!hashSet.has(neighbour)) {
38707 hashSet.add(neighbour);
38708 newHashes.push(neighbour);
38711 this._adjacentComponentRecursive(hashSet, newHashes, currentDepth + 1, maxDepth);
38713 SpatialDataComponent.prototype._computeOriginalPosition = function (data, reference) {
38714 return this._geoCoords.geodeticToEnu(data.originalLat, data.originalLon, data.alt, reference.lat, reference.lon, reference.alt);
38716 SpatialDataComponent.prototype._computeTileBBox = function (hash, reference) {
38717 var bounds = geohash.bounds(hash);
38718 var sw = this._geoCoords.geodeticToEnu(bounds.sw.lat, bounds.sw.lon, 0, reference.lat, reference.lon, reference.alt);
38719 var ne = this._geoCoords.geodeticToEnu(bounds.ne.lat, bounds.ne.lon, 0, reference.lat, reference.lon, reference.alt);
38722 SpatialDataComponent.prototype._createTransform = function (data, reference) {
38723 var translation = Geo_1.Geo.computeTranslation({ alt: data.alt, lat: data.lat, lon: data.lon }, data.rotation, reference);
38724 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, data.cameraProjection);
38727 SpatialDataComponent.prototype._computeTiles = function (hash, direction) {
38728 var hashSet = new Set();
38729 var directions = ["n", "ne", "e", "se", "s", "sw", "w", "nw"];
38730 this._computeTilesRecursive(hashSet, hash, direction, directions, 0, 2);
38731 return this._setToArray(hashSet);
38733 SpatialDataComponent.prototype._computeTilesRecursive = function (hashSet, currentHash, direction, directions, currentDepth, maxDepth) {
38734 hashSet.add(currentHash);
38735 if (currentDepth === maxDepth) {
38738 var neighbours = geohash.neighbours(currentHash);
38739 var directionIndex = directions.indexOf(direction);
38740 var length = directions.length;
38741 var directionNeighbours = [
38742 neighbours[directions[this._modulo((directionIndex - 1), length)]],
38743 neighbours[direction],
38744 neighbours[directions[this._modulo((directionIndex + 1), length)]],
38746 for (var _i = 0, directionNeighbours_1 = directionNeighbours; _i < directionNeighbours_1.length; _i++) {
38747 var directionNeighbour = directionNeighbours_1[_i];
38748 this._computeTilesRecursive(hashSet, directionNeighbour, direction, directions, currentDepth + 1, maxDepth);
38751 SpatialDataComponent.prototype._computeTranslation = function (reconstruction, reference) {
38752 return this._geoCoords.geodeticToEnu(reconstruction.reference_lla.latitude, reconstruction.reference_lla.longitude, reconstruction.reference_lla.altitude, reference.lat, reference.lon, reference.alt);
38754 SpatialDataComponent.prototype._modulo = function (a, n) {
38755 return ((a % n) + n) % n;
38757 SpatialDataComponent.prototype._setToArray = function (s) {
38759 s.forEach(function (value) {
38764 SpatialDataComponent.componentName = "spatialData";
38765 return SpatialDataComponent;
38766 }(Component_1.Component));
38767 exports.SpatialDataComponent = SpatialDataComponent;
38768 Component_1.ComponentService.register(SpatialDataComponent);
38769 exports.default = SpatialDataComponent;
38771 },{"../../Component":291,"../../Geo":294,"../../Render":297,"../../state/State":449,"../../viewer/PlayService":481,"./CameraVisualizationMode":360,"latlon-geohash":21,"rxjs":43,"rxjs/operators":241}],364:[function(require,module,exports){
38773 Object.defineProperty(exports, "__esModule", { value: true });
38774 exports.SpatialDataScene = void 0;
38775 var THREE = require("three");
38776 var CameraVisualizationMode_1 = require("./CameraVisualizationMode");
38777 var SpatialDataScene = /** @class */ (function () {
38778 function SpatialDataScene(configuration, scene, raycaster) {
38779 this._scene = !!scene ? scene : new THREE.Scene();
38780 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster(undefined, undefined, 0.8);
38781 this._cameraColors = {};
38782 this._needsRender = false;
38783 this._interactiveObjects = [];
38786 this._tileClusterReconstructions = {};
38787 this._clusterReconstructions = {};
38788 this._cameraVisualizationMode = !!configuration.cameraVisualizationMode ?
38789 configuration.cameraVisualizationMode :
38790 CameraVisualizationMode_1.default.Default;
38791 if (this._cameraVisualizationMode === CameraVisualizationMode_1.default.Default &&
38792 configuration.connectedComponents === true) {
38793 this._cameraVisualizationMode = CameraVisualizationMode_1.default.ConnectedComponent;
38795 this._camerasVisible = configuration.camerasVisible;
38796 this._pointsVisible = configuration.pointsVisible;
38797 this._positionsVisible = configuration.positionsVisible;
38798 this._tilesVisible = configuration.tilesVisible;
38800 Object.defineProperty(SpatialDataScene.prototype, "needsRender", {
38802 return this._needsRender;
38807 SpatialDataScene.prototype.addClusterReconstruction = function (reconstruction, translation, hash) {
38808 if (this.hasClusterReconstruction(reconstruction.key, hash)) {
38811 var key = reconstruction.key;
38812 if (!(key in this._clusterReconstructions)) {
38813 this._clusterReconstructions[key] = {
38814 points: new THREE.Object3D(),
38817 this._clusterReconstructions[key].points.visible = this._pointsVisible;
38818 this._clusterReconstructions[key].points.add(this._createClusterPoints(reconstruction, translation));
38819 this._scene.add(this._clusterReconstructions[key].points);
38821 if (this._clusterReconstructions[key].tiles.indexOf(hash) === -1) {
38822 this._clusterReconstructions[key].tiles.push(hash);
38824 if (!(hash in this._tileClusterReconstructions)) {
38825 this._tileClusterReconstructions[hash] = {
38829 if (this._tileClusterReconstructions[hash].keys.indexOf(key) === -1) {
38830 this._tileClusterReconstructions[hash].keys.push(key);
38832 this._needsRender = true;
38834 SpatialDataScene.prototype.addNode = function (data, transform, originalPosition, hash) {
38835 var key = data.key;
38836 var clusterKey = data.clusterKey;
38837 var sequenceKey = data.sequenceKey;
38838 var connectedComponent = !!data.mergeCC ? data.mergeCC.toString() : "";
38839 if (this.hasNode(key, hash)) {
38842 if (!(hash in this._nodes)) {
38843 this._nodes[hash] = {
38845 cameras: new THREE.Object3D(),
38847 connectedComponents: {},
38849 positions: new THREE.Object3D(),
38852 this._nodes[hash].cameras.visible = this._camerasVisible;
38853 this._nodes[hash].positions.visible = this._positionsVisible;
38854 this._scene.add(this._nodes[hash].cameras, this._nodes[hash].positions);
38856 if (!(connectedComponent in this._nodes[hash].connectedComponents)) {
38857 this._nodes[hash].connectedComponents[connectedComponent] = [];
38859 if (!(clusterKey in this._nodes[hash].clusters)) {
38860 this._nodes[hash].clusters[clusterKey] = [];
38862 if (!(sequenceKey in this._nodes[hash].sequences)) {
38863 this._nodes[hash].sequences[sequenceKey] = [];
38865 var camera = this._createCamera(transform);
38866 this._nodes[hash].cameras.add(camera);
38867 for (var _i = 0, _a = camera.children; _i < _a.length; _i++) {
38868 var child = _a[_i];
38869 this._nodes[hash].cameraKeys[child.uuid] = key;
38870 this._interactiveObjects.push(child);
38872 this._nodes[hash].connectedComponents[connectedComponent].push(camera);
38873 this._nodes[hash].clusters[clusterKey].push(camera);
38874 this._nodes[hash].sequences[sequenceKey].push(camera);
38875 var id = this._getId(clusterKey, connectedComponent, sequenceKey, this._cameraVisualizationMode);
38876 var color = this._getColor(id, this._cameraVisualizationMode);
38877 this._setCameraColor(color, camera);
38878 this._nodes[hash].positions.add(this._createPosition(transform, originalPosition));
38879 this._nodes[hash].keys.push(key);
38880 this._needsRender = true;
38882 SpatialDataScene.prototype.addTile = function (tileBBox, hash) {
38883 if (this.hasTile(hash)) {
38886 var sw = tileBBox[0];
38887 var ne = tileBBox[1];
38888 var geometry = new THREE.Geometry();
38889 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));
38890 var tile = new THREE.Line(geometry, new THREE.LineBasicMaterial());
38891 this._tiles[hash] = new THREE.Object3D();
38892 this._tiles[hash].visible = this._tilesVisible;
38893 this._tiles[hash].add(tile);
38894 this._scene.add(this._tiles[hash]);
38895 this._needsRender = true;
38897 SpatialDataScene.prototype.uncache = function (keepHashes) {
38898 for (var _i = 0, _a = Object.keys(this._tileClusterReconstructions); _i < _a.length; _i++) {
38900 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
38903 this._disposeReconstruction(hash);
38905 for (var _b = 0, _c = Object.keys(this._nodes); _b < _c.length; _b++) {
38907 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
38910 this._disposeNodes(hash);
38912 for (var _d = 0, _e = Object.keys(this._tiles); _d < _e.length; _d++) {
38914 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
38917 this._disposeTile(hash);
38919 this._needsRender = true;
38921 SpatialDataScene.prototype.hasClusterReconstruction = function (key, hash) {
38922 return key in this._clusterReconstructions &&
38923 this._clusterReconstructions[key].tiles.indexOf(hash) !== -1;
38925 SpatialDataScene.prototype.hasTile = function (hash) {
38926 return hash in this._tiles;
38928 SpatialDataScene.prototype.hasNode = function (key, hash) {
38929 return hash in this._nodes && this._nodes[hash].keys.indexOf(key) !== -1;
38931 SpatialDataScene.prototype.intersectObjects = function (_a, camera) {
38932 var viewportX = _a[0], viewportY = _a[1];
38933 if (!this._camerasVisible) {
38936 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
38937 var intersects = this._raycaster.intersectObjects(this._interactiveObjects);
38938 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
38939 var intersect = intersects_1[_i];
38940 for (var hash in this._nodes) {
38941 if (!this._nodes.hasOwnProperty(hash)) {
38944 if (intersect.object.uuid in this._nodes[hash].cameraKeys) {
38945 return this._nodes[hash].cameraKeys[intersect.object.uuid];
38951 SpatialDataScene.prototype.setCameraVisibility = function (visible) {
38952 if (visible === this._camerasVisible) {
38955 for (var hash in this._nodes) {
38956 if (!this._nodes.hasOwnProperty(hash)) {
38959 this._nodes[hash].cameras.visible = visible;
38961 this._camerasVisible = visible;
38962 this._needsRender = true;
38964 SpatialDataScene.prototype.setPointVisibility = function (visible) {
38965 if (visible === this._pointsVisible) {
38968 for (var key in this._clusterReconstructions) {
38969 if (!this._clusterReconstructions.hasOwnProperty(key)) {
38972 this._clusterReconstructions[key].points.visible = visible;
38974 this._pointsVisible = visible;
38975 this._needsRender = true;
38977 SpatialDataScene.prototype.setPositionVisibility = function (visible) {
38978 if (visible === this._positionsVisible) {
38981 for (var hash in this._nodes) {
38982 if (!this._nodes.hasOwnProperty(hash)) {
38985 this._nodes[hash].positions.visible = visible;
38987 this._positionsVisible = visible;
38988 this._needsRender = true;
38990 SpatialDataScene.prototype.setTileVisibility = function (visible) {
38991 if (visible === this._tilesVisible) {
38994 for (var hash in this._tiles) {
38995 if (!this._tiles.hasOwnProperty(hash)) {
38998 this._tiles[hash].visible = visible;
39000 this._tilesVisible = visible;
39001 this._needsRender = true;
39003 SpatialDataScene.prototype.setCameraVisualizationMode = function (mode) {
39004 if (mode === this._cameraVisualizationMode) {
39007 for (var hash in this._nodes) {
39008 if (!this._nodes.hasOwnProperty(hash)) {
39011 var cameras = undefined;
39012 if (mode === CameraVisualizationMode_1.default.Cluster) {
39013 cameras = this._nodes[hash].clusters;
39015 else if (mode === CameraVisualizationMode_1.default.ConnectedComponent) {
39016 cameras = this._nodes[hash].connectedComponents;
39018 else if (mode === CameraVisualizationMode_1.default.Sequence) {
39019 cameras = this._nodes[hash].sequences;
39022 for (var _i = 0, _a = this._nodes[hash].cameras.children; _i < _a.length; _i++) {
39023 var child = _a[_i];
39024 var color = this._getColor("", mode);
39025 this._setCameraColor(color, child);
39029 for (var id in cameras) {
39030 if (!cameras.hasOwnProperty(id)) {
39033 var color = this._getColor(id, mode);
39034 for (var _b = 0, _c = cameras[id]; _b < _c.length; _b++) {
39035 var camera = _c[_b];
39036 this._setCameraColor(color, camera);
39040 this._cameraVisualizationMode = mode;
39041 this._needsRender = true;
39043 SpatialDataScene.prototype.render = function (perspectiveCamera, renderer) {
39044 renderer.render(this._scene, perspectiveCamera);
39045 this._needsRender = false;
39047 SpatialDataScene.prototype._arrayToFloatArray = function (a, columns) {
39049 var f = new Float32Array(n * columns);
39050 for (var i = 0; i < n; i++) {
39053 f[index + 0] = item[0];
39054 f[index + 1] = item[1];
39055 f[index + 2] = item[2];
39059 SpatialDataScene.prototype._createAxis = function (transform) {
39060 var north = transform.unprojectBasic([0.5, 0], 0.22);
39061 var south = transform.unprojectBasic([0.5, 1], 0.16);
39062 var axis = new THREE.BufferGeometry();
39063 axis.setAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray([north, south], 3), 3));
39064 return new THREE.Line(axis, new THREE.LineBasicMaterial());
39066 SpatialDataScene.prototype._createCamera = function (transform) {
39067 return !!transform.gpano ?
39068 this._createPanoCamera(transform) :
39069 this._createPrespectiveCamera(transform);
39071 SpatialDataScene.prototype._createDiagonals = function (transform, depth) {
39072 var origin = transform.unprojectBasic([0, 0], 0, true);
39073 var topLeft = transform.unprojectBasic([0, 0], depth, true);
39074 var topRight = transform.unprojectBasic([1, 0], depth, true);
39075 var bottomRight = transform.unprojectBasic([1, 1], depth, true);
39076 var bottomLeft = transform.unprojectBasic([0, 1], depth, true);
39080 origin, bottomRight,
39081 origin, bottomLeft,
39083 var diagonals = new THREE.BufferGeometry();
39084 diagonals.setAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices, 3), 3));
39085 return new THREE.LineSegments(diagonals, new THREE.LineBasicMaterial());
39087 SpatialDataScene.prototype._createFrame = function (transform, depth) {
39088 var vertices2d = [];
39089 vertices2d.push.apply(vertices2d, this._subsample([0, 1], [0, 0], 20));
39090 vertices2d.push.apply(vertices2d, this._subsample([0, 0], [1, 0], 20));
39091 vertices2d.push.apply(vertices2d, this._subsample([1, 0], [1, 1], 20));
39092 var vertices3d = vertices2d
39093 .map(function (basic) {
39094 return transform.unprojectBasic(basic, depth, true);
39096 var frame = new THREE.BufferGeometry();
39097 frame.setAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices3d, 3), 3));
39098 return new THREE.Line(frame, new THREE.LineBasicMaterial());
39100 SpatialDataScene.prototype._createLatitude = function (basicY, numVertices, transform) {
39101 var positions = new Float32Array((numVertices + 1) * 3);
39102 for (var i = 0; i <= numVertices; i++) {
39103 var position = transform.unprojectBasic([i / numVertices, basicY], 0.16);
39105 positions[index + 0] = position[0];
39106 positions[index + 1] = position[1];
39107 positions[index + 2] = position[2];
39109 var latitude = new THREE.BufferGeometry();
39110 latitude.setAttribute("position", new THREE.BufferAttribute(positions, 3));
39111 return new THREE.Line(latitude, new THREE.LineBasicMaterial());
39113 SpatialDataScene.prototype._createLongitude = function (basicX, numVertices, transform) {
39114 var positions = new Float32Array((numVertices + 1) * 3);
39115 for (var i = 0; i <= numVertices; i++) {
39116 var position = transform.unprojectBasic([basicX, i / numVertices], 0.16);
39118 positions[index + 0] = position[0];
39119 positions[index + 1] = position[1];
39120 positions[index + 2] = position[2];
39122 var latitude = new THREE.BufferGeometry();
39123 latitude.setAttribute("position", new THREE.BufferAttribute(positions, 3));
39124 return new THREE.Line(latitude, new THREE.LineBasicMaterial());
39126 SpatialDataScene.prototype._createPanoCamera = function (transform) {
39127 var camera = new THREE.Object3D();
39128 camera.children.push(this._createAxis(transform));
39129 camera.children.push(this._createLatitude(0.5, 10, transform));
39130 camera.children.push(this._createLongitude(0, 6, transform));
39131 camera.children.push(this._createLongitude(0.25, 6, transform));
39132 camera.children.push(this._createLongitude(0.5, 6, transform));
39133 camera.children.push(this._createLongitude(0.75, 6, transform));
39136 SpatialDataScene.prototype._createClusterPoints = function (reconstruction, translation) {
39137 var points = Object
39138 .keys(reconstruction.points)
39139 .map(function (key) {
39140 return reconstruction.points[key];
39142 var numPoints = points.length;
39143 var positions = new Float32Array(numPoints * 3);
39144 var colors = new Float32Array(numPoints * 3);
39145 for (var i = 0; i < numPoints; i++) {
39147 var coords = points[i].coordinates;
39148 var point = new THREE.Vector3(coords[0], coords[1], coords[2])
39149 .add(new THREE.Vector3().fromArray(translation));
39150 positions[index + 0] = point.x;
39151 positions[index + 1] = point.y;
39152 positions[index + 2] = point.z;
39153 var color = points[i].color;
39154 colors[index + 0] = color[0] / 255.0;
39155 colors[index + 1] = color[1] / 255.0;
39156 colors[index + 2] = color[2] / 255.0;
39158 var geometry = new THREE.BufferGeometry();
39159 geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
39160 geometry.setAttribute("color", new THREE.BufferAttribute(colors, 3));
39161 var material = new THREE.PointsMaterial({
39163 vertexColors: true,
39165 return new THREE.Points(geometry, material);
39167 SpatialDataScene.prototype._createPosition = function (transform, originalPosition) {
39168 var computedPosition = transform.unprojectBasic([0, 0], 0);
39169 var vertices = [originalPosition, computedPosition];
39170 var geometry = new THREE.BufferGeometry();
39171 geometry.setAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices, 3), 3));
39172 return new THREE.Line(geometry, new THREE.LineBasicMaterial({ color: new THREE.Color(1, 0, 0) }));
39174 SpatialDataScene.prototype._createPrespectiveCamera = function (transform) {
39176 var camera = new THREE.Object3D();
39177 camera.children.push(this._createDiagonals(transform, depth));
39178 camera.children.push(this._createFrame(transform, depth));
39181 SpatialDataScene.prototype._disposeCameras = function (hash) {
39182 var tileCameras = this._nodes[hash].cameras;
39183 for (var _i = 0, _a = tileCameras.children.slice(); _i < _a.length; _i++) {
39184 var camera = _a[_i];
39185 for (var _b = 0, _c = camera.children; _b < _c.length; _b++) {
39186 var child = _c[_b];
39187 child.geometry.dispose();
39188 child.material.dispose();
39189 var index = this._interactiveObjects.indexOf(child);
39190 if (index !== -1) {
39191 this._interactiveObjects.splice(index, 1);
39194 console.warn("Object does not exist (" + child.id + ") for " + hash);
39197 tileCameras.remove(camera);
39199 this._scene.remove(tileCameras);
39201 SpatialDataScene.prototype._disposePoints = function (hash) {
39202 for (var _i = 0, _a = this._tileClusterReconstructions[hash].keys; _i < _a.length; _i++) {
39204 if (!(key in this._clusterReconstructions)) {
39207 var index = this._clusterReconstructions[key].tiles.indexOf(hash);
39208 if (index === -1) {
39211 this._clusterReconstructions[key].tiles.splice(index, 1);
39212 if (this._clusterReconstructions[key].tiles.length > 0) {
39215 for (var _b = 0, _c = this._clusterReconstructions[key].points.children.slice(); _b < _c.length; _b++) {
39216 var points = _c[_b];
39217 points.geometry.dispose();
39218 points.material.dispose();
39220 this._scene.remove(this._clusterReconstructions[key].points);
39221 delete this._clusterReconstructions[key];
39224 SpatialDataScene.prototype._disposePositions = function (hash) {
39225 var tilePositions = this._nodes[hash].positions;
39226 for (var _i = 0, _a = tilePositions.children.slice(); _i < _a.length; _i++) {
39227 var position = _a[_i];
39228 position.geometry.dispose();
39229 position.material.dispose();
39230 tilePositions.remove(position);
39232 this._scene.remove(tilePositions);
39234 SpatialDataScene.prototype._disposeNodes = function (hash) {
39235 this._disposeCameras(hash);
39236 this._disposePositions(hash);
39237 delete this._nodes[hash];
39239 SpatialDataScene.prototype._disposeReconstruction = function (hash) {
39240 this._disposePoints(hash);
39241 delete this._tileClusterReconstructions[hash];
39243 SpatialDataScene.prototype._disposeTile = function (hash) {
39244 var tile = this._tiles[hash];
39245 for (var _i = 0, _a = tile.children.slice(); _i < _a.length; _i++) {
39247 line.geometry.dispose();
39248 line.material.dispose();
39251 this._scene.remove(tile);
39252 delete this._tiles[hash];
39254 SpatialDataScene.prototype._getColor = function (id, mode) {
39255 return mode !== CameraVisualizationMode_1.default.Default && id.length > 0 ?
39256 this._getCameraColor(id) :
39259 SpatialDataScene.prototype._getCameraColor = function (id) {
39260 if (!(id in this._cameraColors)) {
39261 this._cameraColors[id] = this._randomColor();
39263 return this._cameraColors[id];
39265 SpatialDataScene.prototype._getId = function (clusterKey, connectedComponent, sequenceKey, mode) {
39267 case CameraVisualizationMode_1.default.Cluster:
39269 case CameraVisualizationMode_1.default.ConnectedComponent:
39270 return connectedComponent;
39271 case CameraVisualizationMode_1.default.Sequence:
39272 return sequenceKey;
39277 SpatialDataScene.prototype._interpolate = function (a, b, alpha) {
39278 return a + alpha * (b - a);
39280 SpatialDataScene.prototype._randomColor = function () {
39281 return "hsl(" + Math.floor(360 * Math.random()) + ", 100%, 65%)";
39283 SpatialDataScene.prototype._setCameraColor = function (color, camera) {
39284 for (var _i = 0, _a = camera.children; _i < _a.length; _i++) {
39285 var child = _a[_i];
39286 child.material.color = new THREE.Color(color);
39289 SpatialDataScene.prototype._subsample = function (p1, p2, subsamples) {
39290 if (subsamples < 1) {
39294 for (var i = 0; i <= subsamples + 1; i++) {
39296 for (var j = 0; j < 3; j++) {
39297 p.push(this._interpolate(p1[j], p2[j], i / (subsamples + 1)));
39303 return SpatialDataScene;
39305 exports.SpatialDataScene = SpatialDataScene;
39306 exports.default = SpatialDataScene;
39308 },{"./CameraVisualizationMode":360,"three":242}],365:[function(require,module,exports){
39310 Object.defineProperty(exports, "__esModule", { value: true });
39312 },{}],366:[function(require,module,exports){
39314 Object.defineProperty(exports, "__esModule", { value: true });
39315 var GeometryTagError_1 = require("./error/GeometryTagError");
39316 Object.defineProperty(exports, "GeometryTagError", { enumerable: true, get: function () { return GeometryTagError_1.GeometryTagError; } });
39317 var PointGeometry_1 = require("./geometry/PointGeometry");
39318 Object.defineProperty(exports, "PointGeometry", { enumerable: true, get: function () { return PointGeometry_1.PointGeometry; } });
39319 var PointsGeometry_1 = require("./geometry/PointsGeometry");
39320 Object.defineProperty(exports, "PointsGeometry", { enumerable: true, get: function () { return PointsGeometry_1.PointsGeometry; } });
39321 var RectGeometry_1 = require("./geometry/RectGeometry");
39322 Object.defineProperty(exports, "RectGeometry", { enumerable: true, get: function () { return RectGeometry_1.RectGeometry; } });
39323 var PolygonGeometry_1 = require("./geometry/PolygonGeometry");
39324 Object.defineProperty(exports, "PolygonGeometry", { enumerable: true, get: function () { return PolygonGeometry_1.PolygonGeometry; } });
39325 var OutlineTag_1 = require("./tag/OutlineTag");
39326 Object.defineProperty(exports, "OutlineTag", { enumerable: true, get: function () { return OutlineTag_1.OutlineTag; } });
39327 var ExtremePointTag_1 = require("./tag/ExtremePointTag");
39328 Object.defineProperty(exports, "ExtremePointTag", { enumerable: true, get: function () { return ExtremePointTag_1.ExtremePointTag; } });
39329 var SpotTag_1 = require("./tag/SpotTag");
39330 Object.defineProperty(exports, "SpotTag", { enumerable: true, get: function () { return SpotTag_1.SpotTag; } });
39331 var TagDomain_1 = require("./tag/TagDomain");
39332 Object.defineProperty(exports, "TagDomain", { enumerable: true, get: function () { return TagDomain_1.TagDomain; } });
39333 var TagComponent_1 = require("./TagComponent");
39334 Object.defineProperty(exports, "TagComponent", { enumerable: true, get: function () { return TagComponent_1.TagComponent; } });
39335 var TagMode_1 = require("./TagMode");
39336 Object.defineProperty(exports, "TagMode", { enumerable: true, get: function () { return TagMode_1.TagMode; } });
39338 },{"./TagComponent":367,"./TagMode":370,"./error/GeometryTagError":374,"./geometry/PointGeometry":376,"./geometry/PointsGeometry":377,"./geometry/PolygonGeometry":378,"./geometry/RectGeometry":379,"./tag/ExtremePointTag":394,"./tag/OutlineTag":398,"./tag/SpotTag":401,"./tag/TagDomain":403}],367:[function(require,module,exports){
39340 var __extends = (this && this.__extends) || (function () {
39341 var extendStatics = function (d, b) {
39342 extendStatics = Object.setPrototypeOf ||
39343 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
39344 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
39345 return extendStatics(d, b);
39347 return function (d, b) {
39348 extendStatics(d, b);
39349 function __() { this.constructor = d; }
39350 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
39353 Object.defineProperty(exports, "__esModule", { value: true });
39354 exports.TagComponent = void 0;
39355 var rxjs_1 = require("rxjs");
39356 var operators_1 = require("rxjs/operators");
39357 var when = require("when");
39358 var Component_1 = require("../../Component");
39359 var Geo_1 = require("../../Geo");
39360 var Render_1 = require("../../Render");
39362 * @class TagComponent
39364 * @classdesc Component for showing and editing tags with different
39365 * geometries composed from 2D basic image coordinates (see the
39366 * {@link Viewer} class documentation for more information about coordinate
39369 * The `add` method is used for adding new tags or replacing
39370 * tags already in the set. Tags are removed by id.
39372 * If a tag already in the set has the same
39373 * id as one of the tags added, the old tag will be removed and
39374 * the added tag will take its place.
39376 * The tag component mode can be set to either be non interactive or
39377 * to be in creating mode of a certain geometry type.
39379 * The tag properties can be updated at any time and the change will
39380 * be visibile immediately.
39382 * Tags are only relevant to a single image because they are based on
39383 * 2D basic image coordinates. Tags related to a certain image should
39384 * be removed when the viewer is moved to another node.
39386 * To retrive and use the tag component
39390 * var viewer = new Mapillary.Viewer(
39394 * { component: { tag: true } });
39396 * var tagComponent = viewer.getComponent("tag");
39399 var TagComponent = /** @class */ (function (_super) {
39400 __extends(TagComponent, _super);
39402 function TagComponent(name, container, navigator) {
39403 var _this = _super.call(this, name, container, navigator) || this;
39404 _this._tagDomRenderer = new Component_1.TagDOMRenderer();
39405 _this._tagScene = new Component_1.TagScene();
39406 _this._tagSet = new Component_1.TagSet();
39407 _this._tagCreator = new Component_1.TagCreator(_this, navigator);
39408 _this._viewportCoords = new Geo_1.ViewportCoords();
39409 _this._createHandlers = {
39410 "CreatePoint": new Component_1.CreatePointHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
39411 "CreatePoints": new Component_1.CreatePointsHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
39412 "CreatePolygon": new Component_1.CreatePolygonHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
39413 "CreateRect": new Component_1.CreateRectHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
39414 "CreateRectDrag": new Component_1.CreateRectDragHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
39415 "Default": undefined,
39417 _this._editVertexHandler = new Component_1.EditVertexHandler(_this, container, navigator, _this._viewportCoords, _this._tagSet);
39418 _this._renderTags$ = _this._tagSet.changed$.pipe(operators_1.map(function (tagSet) {
39419 var tags = tagSet.getAll();
39420 // ensure that tags are always rendered in the same order
39421 // to avoid hover tracking problems on first resize.
39422 tags.sort(function (t1, t2) {
39423 var id1 = t1.tag.id;
39424 var id2 = t2.tag.id;
39434 }), operators_1.share());
39435 _this._tagChanged$ = _this._renderTags$.pipe(operators_1.switchMap(function (tags) {
39436 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
39437 return rxjs_1.merge(tag.tag.changed$, tag.tag.geometryChanged$);
39439 }), operators_1.share());
39440 _this._renderTagGLChanged$ = _this._renderTags$.pipe(operators_1.switchMap(function (tags) {
39441 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
39442 return tag.glObjectsChanged$;
39444 }), operators_1.share());
39445 _this._createGeometryChanged$ = _this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
39446 return tag != null ?
39447 tag.geometryChanged$ :
39449 }), operators_1.share());
39450 _this._createGLObjectsChanged$ = _this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
39451 return tag != null ?
39452 tag.glObjectsChanged$ :
39454 }), operators_1.share());
39455 _this._creatingConfiguration$ = _this._configuration$.pipe(operators_1.distinctUntilChanged(function (c1, c2) {
39456 return c1.mode === c2.mode;
39457 }, function (configuration) {
39459 createColor: configuration.createColor,
39460 mode: configuration.mode,
39462 }), operators_1.publishReplay(1), operators_1.refCount());
39463 _this._creatingConfiguration$
39464 .subscribe(function (configuration) {
39465 _this.fire(TagComponent.modechanged, configuration.mode);
39470 * Add tags to the tag set or replace tags in the tag set.
39472 * @description If a tag already in the set has the same
39473 * id as one of the tags added, the old tag will be removed
39474 * the added tag will take its place.
39476 * @param {Array<Tag>} tags - Tags to add.
39478 * @example ```tagComponent.add([tag1, tag2]);```
39480 TagComponent.prototype.add = function (tags) {
39482 if (this._activated) {
39483 this._navigator.stateService.currentTransform$.pipe(operators_1.first())
39484 .subscribe(function (transform) {
39485 _this._tagSet.add(tags, transform);
39486 var renderTags = tags
39487 .map(function (tag) {
39488 return _this._tagSet.get(tag.id);
39490 _this._tagScene.add(renderTags);
39494 this._tagSet.addDeactivated(tags);
39498 * Calculate the smallest rectangle containing all the points
39499 * in the points geometry.
39501 * @description The result may be different depending on if the
39502 * current node is an equirectangular panorama or not. If the
39503 * current node is an equirectangular panorama the rectangle may
39504 * wrap the horizontal border of the image.
39506 * @returns {Promise<Array<number>>} Promise to the rectangle
39507 * on the format specified for the {@link RectGeometry} in basic
39510 TagComponent.prototype.calculateRect = function (geometry) {
39512 return when.promise(function (resolve, reject) {
39513 _this._navigator.stateService.currentTransform$.pipe(operators_1.first(), operators_1.map(function (transform) {
39514 return geometry.getRect2d(transform);
39516 .subscribe(function (rect) {
39518 }, function (error) {
39524 * Force the creation of a geometry programatically using its
39525 * current vertices.
39527 * @description The method only has an effect when the tag
39528 * mode is either of the following modes:
39530 * TagMode.CreatePoints
39531 * TagMode.CreatePolygon
39532 * TagMode.CreateRect
39533 * TagMode.CreateRectDrag
39535 * In the case of points or polygon creation, only the created
39536 * vertices are used, i.e. the mouse position is disregarded.
39538 * In the case of rectangle creation the position of the mouse
39539 * at the time of the method call is used as one of the vertices
39540 * defining the rectangle.
39542 * @fires TagComponent.geometrycreated
39546 * tagComponent.on("geometrycreated", function(geometry) {
39547 * console.log(geometry);
39550 * tagComponent.create();
39553 TagComponent.prototype.create = function () {
39554 this._tagCreator.replayedTag$.pipe(operators_1.first(), operators_1.filter(function (tag) {
39557 .subscribe(function (tag) {
39562 * Change the current tag mode.
39564 * @description Change the tag mode to one of the create modes for creating new geometries.
39566 * @param {TagMode} mode - New tag mode.
39568 * @fires TagComponent#modechanged
39570 * @example ```tagComponent.changeMode(Mapillary.TagComponent.TagMode.CreateRect);```
39572 TagComponent.prototype.changeMode = function (mode) {
39573 this.configure({ mode: mode });
39576 * Returns the tag in the tag set with the specified id, or
39577 * undefined if the id matches no tag.
39579 * @param {string} tagId - Id of the tag.
39581 * @example ```var tag = tagComponent.get("tagId");```
39583 TagComponent.prototype.get = function (tagId) {
39584 if (this._activated) {
39585 var renderTag = this._tagSet.get(tagId);
39586 return renderTag !== undefined ? renderTag.tag : undefined;
39589 return this._tagSet.getDeactivated(tagId);
39593 * Returns an array of all tags.
39595 * @example ```var tags = tagComponent.getAll();```
39597 TagComponent.prototype.getAll = function () {
39598 if (this.activated) {
39599 return this._tagSet
39601 .map(function (renderTag) {
39602 return renderTag.tag;
39606 return this._tagSet.getAllDeactivated();
39610 * Returns an array of tag ids for tags that contain the specified point.
39612 * @description The pixel point must lie inside the polygon or rectangle
39613 * of an added tag for the tag id to be returned. Tag ids for
39614 * tags that do not have a fill will also be returned if the point is inside
39615 * the geometry of the tag. Tags with point geometries can not be retrieved.
39617 * No tag ids will be returned for polygons rendered in cropped panoramas or
39618 * rectangles rendered in panoramas.
39620 * Notice that the pixelPoint argument requires x, y coordinates from pixel space.
39622 * With this function, you can use the coordinates provided by mouse
39623 * events to get information out of the tag component.
39625 * If no tag at exist the pixel point, an empty array will be returned.
39627 * @param {Array<number>} pixelPoint - Pixel coordinates on the viewer element.
39628 * @returns {Promise<Array<string>>} Promise to the ids of the tags that
39629 * contain the specified pixel point.
39633 * tagComponent.getTagIdsAt([100, 100])
39634 * .then((tagIds) => { console.log(tagIds); });
39637 TagComponent.prototype.getTagIdsAt = function (pixelPoint) {
39639 return when.promise(function (resolve, reject) {
39640 _this._container.renderService.renderCamera$.pipe(operators_1.first(), operators_1.map(function (render) {
39641 var viewport = _this._viewportCoords
39642 .canvasToViewport(pixelPoint[0], pixelPoint[1], _this._container.element);
39643 var ids = _this._tagScene.intersectObjects(viewport, render.perspective);
39646 .subscribe(function (ids) {
39648 }, function (error) {
39654 * Check if a tag exist in the tag set.
39656 * @param {string} tagId - Id of the tag.
39658 * @example ```var tagExists = tagComponent.has("tagId");```
39660 TagComponent.prototype.has = function (tagId) {
39661 return this._activated ? this._tagSet.has(tagId) : this._tagSet.hasDeactivated(tagId);
39664 * Remove tags with the specified ids from the tag set.
39666 * @param {Array<string>} tagIds - Ids for tags to remove.
39668 * @example ```tagComponent.remove(["id-1", "id-2"]);```
39670 TagComponent.prototype.remove = function (tagIds) {
39671 if (this._activated) {
39672 this._tagSet.remove(tagIds);
39673 this._tagScene.remove(tagIds);
39676 this._tagSet.removeDeactivated(tagIds);
39680 * Remove all tags from the tag set.
39682 * @example ```tagComponent.removeAll();```
39684 TagComponent.prototype.removeAll = function () {
39685 if (this._activated) {
39686 this._tagSet.removeAll();
39687 this._tagScene.removeAll();
39690 this._tagSet.removeAllDeactivated();
39693 TagComponent.prototype._activate = function () {
39695 this._editVertexHandler.enable();
39696 var handlerGeometryCreated$ = rxjs_1.from(Object.keys(this._createHandlers)).pipe(operators_1.map(function (key) {
39697 return _this._createHandlers[key];
39698 }), operators_1.filter(function (handler) {
39700 }), operators_1.mergeMap(function (handler) {
39701 return handler.geometryCreated$;
39702 }), operators_1.share());
39703 this._fireGeometryCreatedSubscription = handlerGeometryCreated$
39704 .subscribe(function (geometry) {
39705 _this.fire(TagComponent.geometrycreated, geometry);
39707 this._fireCreateGeometryEventSubscription = this._tagCreator.tag$.pipe(operators_1.skipWhile(function (tag) {
39708 return tag == null;
39709 }), operators_1.distinctUntilChanged())
39710 .subscribe(function (tag) {
39711 var eventType = tag != null ?
39712 TagComponent.creategeometrystart :
39713 TagComponent.creategeometryend;
39714 _this.fire(eventType, _this);
39716 this._handlerStopCreateSubscription = handlerGeometryCreated$
39717 .subscribe(function () {
39718 _this.changeMode(Component_1.TagMode.Default);
39720 this._handlerEnablerSubscription = this._creatingConfiguration$
39721 .subscribe(function (configuration) {
39722 _this._disableCreateHandlers();
39723 var mode = Component_1.TagMode[configuration.mode];
39724 var handler = _this._createHandlers[mode];
39729 this._fireTagsChangedSubscription = this._renderTags$
39730 .subscribe(function () {
39731 _this.fire(TagComponent.tagschanged, _this);
39733 this._stopCreateSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
39734 return tag != null ?
39735 tag.aborted$.pipe(operators_1.map(function () { return null; })) :
39738 .subscribe(function () { _this.changeMode(Component_1.TagMode.Default); });
39739 this._setGLCreateTagSubscription = this._tagCreator.tag$
39740 .subscribe(function (tag) {
39741 if (_this._tagScene.hasCreateTag()) {
39742 _this._tagScene.removeCreateTag();
39745 _this._tagScene.addCreateTag(tag);
39748 this._createGLObjectsChangedSubscription = this._createGLObjectsChanged$
39749 .subscribe(function (tag) {
39750 _this._tagScene.updateCreateTagObjects(tag);
39752 this._updateGLObjectsSubscription = this._renderTagGLChanged$
39753 .subscribe(function (tag) {
39754 _this._tagScene.updateObjects(tag);
39756 this._updateTagSceneSubscription = this._tagChanged$
39757 .subscribe(function () {
39758 _this._tagScene.update();
39760 this._domSubscription = rxjs_1.combineLatest(this._renderTags$.pipe(operators_1.startWith([]), operators_1.tap(function () {
39761 _this._container.domRenderer.render$.next({
39763 vnode: _this._tagDomRenderer.clear(),
39765 })), 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) {
39766 var renderTags = _a[0], rc = _a[1], atlas = _a[2], size = _a[3], ct = _a[5];
39769 vnode: _this._tagDomRenderer.render(renderTags, ct, atlas, rc.perspective, size),
39772 .subscribe(this._container.domRenderer.render$);
39773 this._glSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
39774 var tagScene = _this._tagScene;
39779 needsRender: tagScene.needsRender,
39780 render: tagScene.render.bind(tagScene),
39781 stage: Render_1.GLRenderStage.Foreground,
39785 .subscribe(this._container.glRenderer.render$);
39786 this._navigator.stateService.currentTransform$.pipe(operators_1.first())
39787 .subscribe(function (transform) {
39788 _this._tagSet.activate(transform);
39789 _this._tagScene.add(_this._tagSet.getAll());
39792 TagComponent.prototype._deactivate = function () {
39793 this._editVertexHandler.disable();
39794 this._disableCreateHandlers();
39795 this._tagScene.clear();
39796 this._tagSet.deactivate();
39797 this._tagCreator.delete$.next(null);
39798 this._updateGLObjectsSubscription.unsubscribe();
39799 this._updateTagSceneSubscription.unsubscribe();
39800 this._stopCreateSubscription.unsubscribe();
39801 this._setGLCreateTagSubscription.unsubscribe();
39802 this._createGLObjectsChangedSubscription.unsubscribe();
39803 this._domSubscription.unsubscribe();
39804 this._glSubscription.unsubscribe();
39805 this._fireCreateGeometryEventSubscription.unsubscribe();
39806 this._fireGeometryCreatedSubscription.unsubscribe();
39807 this._fireTagsChangedSubscription.unsubscribe();
39808 this._handlerStopCreateSubscription.unsubscribe();
39809 this._handlerEnablerSubscription.unsubscribe();
39810 this._container.element.classList.remove("component-tag-create");
39812 TagComponent.prototype._getDefaultConfiguration = function () {
39814 createColor: 0xFFFFFF,
39815 indicatePointsCompleter: true,
39816 mode: Component_1.TagMode.Default,
39819 TagComponent.prototype._disableCreateHandlers = function () {
39820 var createHandlers = this._createHandlers;
39821 for (var key in createHandlers) {
39822 if (!createHandlers.hasOwnProperty(key)) {
39825 var handler = createHandlers[key];
39832 TagComponent.componentName = "tag";
39834 * Event fired when an interaction to create a geometry ends.
39836 * @description A create interaction can by a geometry being created
39837 * or by the creation being aborted.
39839 * @event TagComponent#creategeometryend
39840 * @type {TagComponent} Tag component.
39843 * tagComponent.on("creategeometryend", function(component) {
39844 * console.log(component);
39848 TagComponent.creategeometryend = "creategeometryend";
39850 * Event fired when an interaction to create a geometry starts.
39852 * @description A create interaction starts when the first vertex
39853 * is created in the geometry.
39855 * @event TagComponent#creategeometrystart
39856 * @type {TagComponent} Tag component.
39859 * tagComponent.on("creategeometrystart", function(component) {
39860 * console.log(component);
39864 TagComponent.creategeometrystart = "creategeometrystart";
39866 * Event fired when the create mode is changed.
39868 * @event TagComponent#modechanged
39869 * @type {TagMode} Tag mode
39872 * tagComponent.on("modechanged", function(mode) {
39873 * console.log(mode);
39877 TagComponent.modechanged = "modechanged";
39879 * Event fired when a geometry has been created.
39881 * @event TagComponent#geometrycreated
39882 * @type {Geometry} Created geometry.
39885 * tagComponent.on("geometrycreated", function(geometry) {
39886 * console.log(geometry);
39890 TagComponent.geometrycreated = "geometrycreated";
39892 * Event fired when the tags collection has changed.
39894 * @event TagComponent#tagschanged
39895 * @type {TagComponent} Tag component.
39898 * tagComponent.on("tagschanged", function(component) {
39899 * console.log(component.getAll());
39903 TagComponent.tagschanged = "tagschanged";
39904 return TagComponent;
39905 }(Component_1.Component));
39906 exports.TagComponent = TagComponent;
39907 Component_1.ComponentService.register(TagComponent);
39908 exports.default = TagComponent;
39910 },{"../../Component":291,"../../Geo":294,"../../Render":297,"rxjs":43,"rxjs/operators":241,"when":288}],368:[function(require,module,exports){
39912 Object.defineProperty(exports, "__esModule", { value: true });
39913 exports.TagCreator = void 0;
39914 var operators_1 = require("rxjs/operators");
39915 var rxjs_1 = require("rxjs");
39916 var Component_1 = require("../../Component");
39917 var TagCreator = /** @class */ (function () {
39918 function TagCreator(component, navigator) {
39919 this._component = component;
39920 this._navigator = navigator;
39921 this._tagOperation$ = new rxjs_1.Subject();
39922 this._createPoints$ = new rxjs_1.Subject();
39923 this._createPolygon$ = new rxjs_1.Subject();
39924 this._createRect$ = new rxjs_1.Subject();
39925 this._delete$ = new rxjs_1.Subject();
39926 this._tag$ = this._tagOperation$.pipe(operators_1.scan(function (tag, operation) {
39927 return operation(tag);
39928 }, null), operators_1.share());
39929 this._replayedTag$ = this._tag$.pipe(operators_1.publishReplay(1), operators_1.refCount());
39930 this._replayedTag$.subscribe();
39931 this._createPoints$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
39932 var coord = _a[0], conf = _a[1], transform = _a[2];
39933 return function () {
39934 var geometry = new Component_1.PointsGeometry([
39935 [coord[0], coord[1]],
39936 [coord[0], coord[1]],
39938 return new Component_1.ExtremePointCreateTag(geometry, {
39939 color: conf.createColor,
39940 indicateCompleter: conf.indicatePointsCompleter,
39944 .subscribe(this._tagOperation$);
39945 this._createRect$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
39946 var coord = _a[0], conf = _a[1], transform = _a[2];
39947 return function () {
39948 var geometry = new Component_1.RectGeometry([
39954 return new Component_1.OutlineCreateTag(geometry, { color: conf.createColor }, transform);
39957 .subscribe(this._tagOperation$);
39958 this._createPolygon$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
39959 var coord = _a[0], conf = _a[1], transform = _a[2];
39960 return function () {
39961 var geometry = new Component_1.PolygonGeometry([
39962 [coord[0], coord[1]],
39963 [coord[0], coord[1]],
39964 [coord[0], coord[1]],
39966 return new Component_1.OutlineCreateTag(geometry, { color: conf.createColor }, transform);
39969 .subscribe(this._tagOperation$);
39970 this._delete$.pipe(operators_1.map(function () {
39971 return function () {
39975 .subscribe(this._tagOperation$);
39977 Object.defineProperty(TagCreator.prototype, "createRect$", {
39979 return this._createRect$;
39984 Object.defineProperty(TagCreator.prototype, "createPolygon$", {
39986 return this._createPolygon$;
39991 Object.defineProperty(TagCreator.prototype, "createPoints$", {
39993 return this._createPoints$;
39998 Object.defineProperty(TagCreator.prototype, "delete$", {
40000 return this._delete$;
40005 Object.defineProperty(TagCreator.prototype, "tag$", {
40012 Object.defineProperty(TagCreator.prototype, "replayedTag$", {
40014 return this._replayedTag$;
40021 exports.TagCreator = TagCreator;
40022 exports.default = TagCreator;
40024 },{"../../Component":291,"rxjs":43,"rxjs/operators":241}],369:[function(require,module,exports){
40026 Object.defineProperty(exports, "__esModule", { value: true });
40027 exports.TagDOMRenderer = void 0;
40028 var vd = require("virtual-dom");
40029 var TagDOMRenderer = /** @class */ (function () {
40030 function TagDOMRenderer() {
40032 TagDOMRenderer.prototype.render = function (tags, createTag, atlas, camera, size) {
40034 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
40035 var tag = tags_1[_i];
40036 vNodes = vNodes.concat(tag.getDOMObjects(atlas, camera, size));
40038 if (createTag != null) {
40039 vNodes = vNodes.concat(createTag.getDOMObjects(camera, size));
40041 return vd.h("div.TagContainer", {}, vNodes);
40043 TagDOMRenderer.prototype.clear = function () {
40044 return vd.h("div", {}, []);
40046 return TagDOMRenderer;
40048 exports.TagDOMRenderer = TagDOMRenderer;
40050 },{"virtual-dom":247}],370:[function(require,module,exports){
40052 Object.defineProperty(exports, "__esModule", { value: true });
40053 exports.TagMode = void 0;
40055 * Enumeration for tag modes
40058 * @description Modes for the interaction in the tag component.
40061 (function (TagMode) {
40063 * Disables creating tags.
40065 TagMode[TagMode["Default"] = 0] = "Default";
40067 * Create a point geometry through a click.
40069 TagMode[TagMode["CreatePoint"] = 1] = "CreatePoint";
40071 * Create a points geometry through clicks.
40073 TagMode[TagMode["CreatePoints"] = 2] = "CreatePoints";
40075 * Create a polygon geometry through clicks.
40077 TagMode[TagMode["CreatePolygon"] = 3] = "CreatePolygon";
40079 * Create a rect geometry through clicks.
40081 TagMode[TagMode["CreateRect"] = 4] = "CreateRect";
40083 * Create a rect geometry through drag.
40085 * @description Claims the mouse which results in mouse handlers like
40086 * drag pan and scroll zoom becoming inactive.
40088 TagMode[TagMode["CreateRectDrag"] = 5] = "CreateRectDrag";
40089 })(TagMode = exports.TagMode || (exports.TagMode = {}));
40090 exports.default = TagMode;
40092 },{}],371:[function(require,module,exports){
40094 Object.defineProperty(exports, "__esModule", { value: true });
40095 exports.TagOperation = void 0;
40097 (function (TagOperation) {
40098 TagOperation[TagOperation["None"] = 0] = "None";
40099 TagOperation[TagOperation["Centroid"] = 1] = "Centroid";
40100 TagOperation[TagOperation["Vertex"] = 2] = "Vertex";
40101 })(TagOperation = exports.TagOperation || (exports.TagOperation = {}));
40102 exports.default = TagOperation;
40104 },{}],372:[function(require,module,exports){
40106 Object.defineProperty(exports, "__esModule", { value: true });
40107 exports.TagScene = void 0;
40108 var THREE = require("three");
40109 var TagScene = /** @class */ (function () {
40110 function TagScene(scene, raycaster) {
40111 this._createTag = null;
40112 this._needsRender = false;
40113 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster();
40114 this._scene = !!scene ? scene : new THREE.Scene();
40115 this._objectTags = {};
40116 this._retrievableObjects = [];
40119 Object.defineProperty(TagScene.prototype, "needsRender", {
40121 return this._needsRender;
40126 TagScene.prototype.add = function (tags) {
40127 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
40128 var tag = tags_1[_i];
40129 if (tag.tag.id in this._tags) {
40130 this._remove(tag.tag.id);
40134 this._needsRender = true;
40136 TagScene.prototype.addCreateTag = function (tag) {
40137 for (var _i = 0, _a = tag.glObjects; _i < _a.length; _i++) {
40138 var object = _a[_i];
40139 this._scene.add(object);
40141 this._createTag = { tag: tag, objects: tag.glObjects };
40142 this._needsRender = true;
40144 TagScene.prototype.clear = function () {
40145 for (var _i = 0, _a = Object.keys(this._tags); _i < _a.length; _i++) {
40149 this._needsRender = false;
40151 TagScene.prototype.get = function (id) {
40152 return this.has(id) ? this._tags[id].tag : undefined;
40154 TagScene.prototype.has = function (id) {
40155 return id in this._tags;
40157 TagScene.prototype.hasCreateTag = function () {
40158 return this._createTag != null;
40160 TagScene.prototype.intersectObjects = function (_a, camera) {
40161 var viewportX = _a[0], viewportY = _a[1];
40162 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
40163 var intersects = this._raycaster.intersectObjects(this._retrievableObjects);
40164 var intersectedIds = [];
40165 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
40166 var intersect = intersects_1[_i];
40167 if (intersect.object.uuid in this._objectTags) {
40168 intersectedIds.push(this._objectTags[intersect.object.uuid]);
40171 return intersectedIds;
40173 TagScene.prototype.remove = function (ids) {
40174 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
40175 var id = ids_1[_i];
40178 this._needsRender = true;
40180 TagScene.prototype.removeAll = function () {
40181 for (var _i = 0, _a = Object.keys(this._tags); _i < _a.length; _i++) {
40185 this._needsRender = true;
40187 TagScene.prototype.removeCreateTag = function () {
40188 if (this._createTag == null) {
40191 for (var _i = 0, _a = this._createTag.objects; _i < _a.length; _i++) {
40192 var object = _a[_i];
40193 this._scene.remove(object);
40195 this._createTag.tag.dispose();
40196 this._createTag = null;
40197 this._needsRender = true;
40199 TagScene.prototype.render = function (perspectiveCamera, renderer) {
40200 renderer.render(this._scene, perspectiveCamera);
40201 this._needsRender = false;
40203 TagScene.prototype.update = function () {
40204 this._needsRender = true;
40206 TagScene.prototype.updateCreateTagObjects = function (tag) {
40207 if (this._createTag.tag !== tag) {
40208 throw new Error("Create tags do not have the same reference.");
40210 for (var _i = 0, _a = this._createTag.objects; _i < _a.length; _i++) {
40211 var object = _a[_i];
40212 this._scene.remove(object);
40214 for (var _b = 0, _c = tag.glObjects; _b < _c.length; _b++) {
40215 var object = _c[_b];
40216 this._scene.add(object);
40218 this._createTag.objects = tag.glObjects;
40219 this._needsRender = true;
40221 TagScene.prototype.updateObjects = function (tag) {
40222 var id = tag.tag.id;
40223 if (this._tags[id].tag !== tag) {
40224 throw new Error("Tags do not have the same reference.");
40226 var tagObjects = this._tags[id];
40227 this._removeObjects(tagObjects);
40228 delete this._tags[id];
40230 this._needsRender = true;
40232 TagScene.prototype._add = function (tag) {
40233 var id = tag.tag.id;
40234 var tagObjects = { tag: tag, objects: [], retrievableObjects: [] };
40235 this._tags[id] = tagObjects;
40236 for (var _i = 0, _a = tag.getGLObjects(); _i < _a.length; _i++) {
40237 var object = _a[_i];
40238 tagObjects.objects.push(object);
40239 this._scene.add(object);
40241 for (var _b = 0, _c = tag.getRetrievableObjects(); _b < _c.length; _b++) {
40242 var retrievableObject = _c[_b];
40243 tagObjects.retrievableObjects.push(retrievableObject);
40244 this._retrievableObjects.push(retrievableObject);
40245 this._objectTags[retrievableObject.uuid] = tag.tag.id;
40248 TagScene.prototype._remove = function (id) {
40249 var tagObjects = this._tags[id];
40250 this._removeObjects(tagObjects);
40251 tagObjects.tag.dispose();
40252 delete this._tags[id];
40254 TagScene.prototype._removeObjects = function (tagObjects) {
40255 for (var _i = 0, _a = tagObjects.objects; _i < _a.length; _i++) {
40256 var object = _a[_i];
40257 this._scene.remove(object);
40259 for (var _b = 0, _c = tagObjects.retrievableObjects; _b < _c.length; _b++) {
40260 var retrievableObject = _c[_b];
40261 var index = this._retrievableObjects.indexOf(retrievableObject);
40262 if (index !== -1) {
40263 this._retrievableObjects.splice(index, 1);
40269 exports.TagScene = TagScene;
40270 exports.default = TagScene;
40272 },{"three":242}],373:[function(require,module,exports){
40274 Object.defineProperty(exports, "__esModule", { value: true });
40275 exports.TagSet = void 0;
40276 var rxjs_1 = require("rxjs");
40277 var Component_1 = require("../../Component");
40278 var ExtremePointTag_1 = require("./tag/ExtremePointTag");
40279 var ExtremePointRenderTag_1 = require("./tag/ExtremePointRenderTag");
40280 var TagSet = /** @class */ (function () {
40281 function TagSet() {
40282 this._active = false;
40284 this._hashDeactivated = {};
40285 this._notifyChanged$ = new rxjs_1.Subject();
40287 Object.defineProperty(TagSet.prototype, "active", {
40289 return this._active;
40294 Object.defineProperty(TagSet.prototype, "changed$", {
40296 return this._notifyChanged$;
40301 TagSet.prototype.activate = function (transform) {
40302 if (this._active) {
40305 for (var id in this._hashDeactivated) {
40306 if (!this._hashDeactivated.hasOwnProperty(id)) {
40309 var tag = this._hashDeactivated[id];
40310 this._add(tag, transform);
40312 this._hashDeactivated = {};
40313 this._active = true;
40314 this._notifyChanged$.next(this);
40316 TagSet.prototype.deactivate = function () {
40317 if (!this._active) {
40320 for (var id in this._hash) {
40321 if (!this._hash.hasOwnProperty(id)) {
40324 this._hashDeactivated[id] = this._hash[id].tag;
40327 this._active = false;
40329 TagSet.prototype.add = function (tags, transform) {
40330 this._assertActivationState(true);
40331 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
40332 var tag = tags_1[_i];
40333 this._add(tag, transform);
40335 this._notifyChanged$.next(this);
40337 TagSet.prototype.addDeactivated = function (tags) {
40338 this._assertActivationState(false);
40339 for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
40340 var tag = tags_2[_i];
40341 if (!(tag instanceof Component_1.OutlineTag ||
40342 tag instanceof Component_1.SpotTag ||
40343 tag instanceof ExtremePointTag_1.default)) {
40344 throw new Error("Tag type not supported");
40346 this._hashDeactivated[tag.id] = tag;
40349 TagSet.prototype.get = function (id) {
40350 return this.has(id) ? this._hash[id] : undefined;
40352 TagSet.prototype.getAll = function () {
40353 var hash = this._hash;
40354 return Object.keys(hash)
40355 .map(function (id) {
40359 TagSet.prototype.getAllDeactivated = function () {
40360 var hashDeactivated = this._hashDeactivated;
40361 return Object.keys(hashDeactivated)
40362 .map(function (id) {
40363 return hashDeactivated[id];
40366 TagSet.prototype.getDeactivated = function (id) {
40367 return this.hasDeactivated(id) ? this._hashDeactivated[id] : undefined;
40369 TagSet.prototype.has = function (id) {
40370 return id in this._hash;
40372 TagSet.prototype.hasDeactivated = function (id) {
40373 return id in this._hashDeactivated;
40375 TagSet.prototype.remove = function (ids) {
40376 this._assertActivationState(true);
40377 var hash = this._hash;
40378 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
40379 var id = ids_1[_i];
40380 if (!(id in hash)) {
40385 this._notifyChanged$.next(this);
40387 TagSet.prototype.removeAll = function () {
40388 this._assertActivationState(true);
40390 this._notifyChanged$.next(this);
40392 TagSet.prototype.removeAllDeactivated = function () {
40393 this._assertActivationState(false);
40394 this._hashDeactivated = {};
40396 TagSet.prototype.removeDeactivated = function (ids) {
40397 this._assertActivationState(false);
40398 var hashDeactivated = this._hashDeactivated;
40399 for (var _i = 0, ids_2 = ids; _i < ids_2.length; _i++) {
40400 var id = ids_2[_i];
40401 if (!(id in hashDeactivated)) {
40404 delete hashDeactivated[id];
40407 TagSet.prototype._add = function (tag, transform) {
40408 if (tag instanceof Component_1.OutlineTag) {
40409 this._hash[tag.id] = new Component_1.OutlineRenderTag(tag, transform);
40411 else if (tag instanceof Component_1.SpotTag) {
40412 this._hash[tag.id] = new Component_1.SpotRenderTag(tag, transform);
40414 else if (tag instanceof ExtremePointTag_1.default) {
40415 this._hash[tag.id] = new ExtremePointRenderTag_1.default(tag, transform);
40418 throw new Error("Tag type not supported");
40421 TagSet.prototype._assertActivationState = function (should) {
40422 if (should !== this._active) {
40423 throw new Error("Tag set not in correct state for operation.");
40428 exports.TagSet = TagSet;
40429 exports.default = TagSet;
40431 },{"../../Component":291,"./tag/ExtremePointRenderTag":393,"./tag/ExtremePointTag":394,"rxjs":43}],374:[function(require,module,exports){
40433 var __extends = (this && this.__extends) || (function () {
40434 var extendStatics = function (d, b) {
40435 extendStatics = Object.setPrototypeOf ||
40436 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
40437 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
40438 return extendStatics(d, b);
40440 return function (d, b) {
40441 extendStatics(d, b);
40442 function __() { this.constructor = d; }
40443 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40446 Object.defineProperty(exports, "__esModule", { value: true });
40447 exports.GeometryTagError = void 0;
40448 var Error_1 = require("../../../Error");
40449 var GeometryTagError = /** @class */ (function (_super) {
40450 __extends(GeometryTagError, _super);
40451 function GeometryTagError(message) {
40452 var _this = _super.call(this, message != null ? message : "The provided geometry value is incorrect") || this;
40453 Object.setPrototypeOf(_this, GeometryTagError.prototype);
40454 _this.name = "GeometryTagError";
40457 return GeometryTagError;
40458 }(Error_1.MapillaryError));
40459 exports.GeometryTagError = GeometryTagError;
40460 exports.default = Error_1.MapillaryError;
40462 },{"../../../Error":293}],375:[function(require,module,exports){
40464 Object.defineProperty(exports, "__esModule", { value: true });
40465 exports.Geometry = void 0;
40466 var rxjs_1 = require("rxjs");
40470 * @classdesc Represents a geometry.
40472 var Geometry = /** @class */ (function () {
40474 * Create a geometry.
40479 function Geometry() {
40480 this._notifyChanged$ = new rxjs_1.Subject();
40482 Object.defineProperty(Geometry.prototype, "changed$", {
40484 * Get changed observable.
40486 * @description Emits the geometry itself every time the geometry
40489 * @returns {Observable<Geometry>} Observable emitting the geometry instance.
40493 return this._notifyChanged$;
40500 exports.Geometry = Geometry;
40501 exports.default = Geometry;
40503 },{"rxjs":43}],376:[function(require,module,exports){
40505 var __extends = (this && this.__extends) || (function () {
40506 var extendStatics = function (d, b) {
40507 extendStatics = Object.setPrototypeOf ||
40508 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
40509 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
40510 return extendStatics(d, b);
40512 return function (d, b) {
40513 extendStatics(d, b);
40514 function __() { this.constructor = d; }
40515 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40518 Object.defineProperty(exports, "__esModule", { value: true });
40519 exports.PointGeometry = void 0;
40520 var Component_1 = require("../../../Component");
40522 * @class PointGeometry
40524 * @classdesc Represents a point geometry in the 2D basic image coordinate system.
40528 * var basicPoint = [0.5, 0.7];
40529 * var pointGeometry = new Mapillary.TagComponent.PointGeometry(basicPoint);
40532 var PointGeometry = /** @class */ (function (_super) {
40533 __extends(PointGeometry, _super);
40535 * Create a point geometry.
40538 * @param {Array<number>} point - An array representing the basic coordinates of
40541 * @throws {GeometryTagError} Point coordinates must be valid basic coordinates.
40543 function PointGeometry(point) {
40544 var _this = _super.call(this) || this;
40547 if (x < 0 || x > 1 || y < 0 || y > 1) {
40548 throw new Component_1.GeometryTagError("Basic coordinates must be on the interval [0, 1].");
40550 _this._point = point.slice();
40553 Object.defineProperty(PointGeometry.prototype, "point", {
40555 * Get point property.
40556 * @returns {Array<number>} Array representing the basic coordinates of the point.
40559 return this._point;
40565 * Get the 2D basic coordinates for the centroid of the point, i.e. the 2D
40566 * basic coordinates of the point itself.
40568 * @returns {Array<number>} 2D basic coordinates representing the centroid.
40571 PointGeometry.prototype.getCentroid2d = function () {
40572 return this._point.slice();
40575 * Get the 3D world coordinates for the centroid of the point, i.e. the 3D
40576 * world coordinates of the point itself.
40578 * @param {Transform} transform - The transform of the node related to the point.
40579 * @returns {Array<number>} 3D world coordinates representing the centroid.
40582 PointGeometry.prototype.getCentroid3d = function (transform) {
40583 return transform.unprojectBasic(this._point, 200);
40586 * Set the centroid of the point, i.e. the point coordinates.
40588 * @param {Array<number>} value - The new value of the centroid.
40589 * @param {Transform} transform - The transform of the node related to the point.
40592 PointGeometry.prototype.setCentroid2d = function (value, transform) {
40594 Math.max(0, Math.min(1, value[0])),
40595 Math.max(0, Math.min(1, value[1])),
40597 this._point[0] = changed[0];
40598 this._point[1] = changed[1];
40599 this._notifyChanged$.next(this);
40601 return PointGeometry;
40602 }(Component_1.Geometry));
40603 exports.PointGeometry = PointGeometry;
40604 exports.default = PointGeometry;
40606 },{"../../../Component":291}],377:[function(require,module,exports){
40608 var __extends = (this && this.__extends) || (function () {
40609 var extendStatics = function (d, b) {
40610 extendStatics = Object.setPrototypeOf ||
40611 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
40612 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
40613 return extendStatics(d, b);
40615 return function (d, b) {
40616 extendStatics(d, b);
40617 function __() { this.constructor = d; }
40618 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40621 Object.defineProperty(exports, "__esModule", { value: true });
40622 exports.PointsGeometry = void 0;
40623 var Component_1 = require("../../../Component");
40625 * @class PointsGeometry
40627 * @classdesc Represents a point set in the 2D basic image coordinate system.
40631 * var points = [[0.5, 0.3], [0.7, 0.3], [0.6, 0.5]];
40632 * var pointsGeometry = new Mapillary.TagComponent.PointsGeometry(points);
40635 var PointsGeometry = /** @class */ (function (_super) {
40636 __extends(PointsGeometry, _super);
40638 * Create a points geometry.
40641 * @param {Array<Array<number>>} points - Array of 2D points on the basic coordinate
40642 * system. The number of points must be greater than or equal to two.
40644 * @throws {GeometryTagError} Point coordinates must be valid basic coordinates.
40646 function PointsGeometry(points) {
40647 var _this = _super.call(this) || this;
40648 var pointsLength = points.length;
40649 if (pointsLength < 2) {
40650 throw new Component_1.GeometryTagError("A points geometry must have two or more positions.");
40652 _this._points = [];
40653 for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
40654 var point = points_1[_i];
40655 if (point[0] < 0 || point[0] > 1 ||
40656 point[1] < 0 || point[1] > 1) {
40657 throw new Component_1.GeometryTagError("Basic coordinates of points must be on the interval [0, 1].");
40659 _this._points.push(point.slice());
40663 Object.defineProperty(PointsGeometry.prototype, "points", {
40665 * Get points property.
40666 * @returns {Array<Array<number>>} Array of 2d points.
40669 return this._points;
40675 * Add a point to the point set.
40677 * @param {Array<number>} point - Point to add.
40680 PointsGeometry.prototype.addPoint2d = function (point) {
40682 Math.max(0, Math.min(1, point[0])),
40683 Math.max(0, Math.min(1, point[1])),
40685 this._points.push(clamped);
40686 this._notifyChanged$.next(this);
40689 * Get the coordinates of a point from the point set representation of the geometry.
40691 * @param {number} index - Point index.
40692 * @returns {Array<number>} Array representing the 2D basic coordinates of the point.
40695 PointsGeometry.prototype.getPoint2d = function (index) {
40696 return this._points[index].slice();
40699 * Remove a point from the point set.
40701 * @param {number} index - The index of the point to remove.
40704 PointsGeometry.prototype.removePoint2d = function (index) {
40706 index >= this._points.length ||
40707 this._points.length < 3) {
40708 throw new Component_1.GeometryTagError("Index for removed point must be valid.");
40710 this._points.splice(index, 1);
40711 this._notifyChanged$.next(this);
40714 PointsGeometry.prototype.setVertex2d = function (index, value, transform) {
40715 this.setPoint2d(index, value, transform);
40718 PointsGeometry.prototype.setPoint2d = function (index, value, transform) {
40720 Math.max(0, Math.min(1, value[0])),
40721 Math.max(0, Math.min(1, value[1])),
40723 this._points[index] = changed;
40724 this._notifyChanged$.next(this);
40727 PointsGeometry.prototype.getPoints3d = function (transform) {
40728 return this._getPoints3d(this._points, transform);
40731 PointsGeometry.prototype.getPoint3d = function (index, transform) {
40732 return transform.unprojectBasic(this._points[index], 200);
40735 PointsGeometry.prototype.getPoints2d = function () {
40736 return this._points.slice();
40739 PointsGeometry.prototype.getCentroid2d = function (transform) {
40741 throw new Component_1.GeometryTagError("Get centroid must be called with a transform for points geometries.");
40743 var _a = this.getRect2d(transform), minX = _a[0], minY = _a[1], maxX = _a[2], maxY = _a[3];
40744 var centroidX = minX < maxX ?
40745 (minX + maxX) / 2 :
40746 ((minX + maxX + 1) / 2) % 1;
40747 var centroidY = (minY + maxY) / 2;
40748 return [centroidX, centroidY];
40751 PointsGeometry.prototype.getCentroid3d = function (transform) {
40752 var centroid2d = this.getCentroid2d();
40753 return transform.unprojectBasic(centroid2d, 200);
40756 PointsGeometry.prototype.getRect2d = function (transform) {
40761 var points = this._points;
40762 for (var _i = 0, points_2 = points; _i < points_2.length; _i++) {
40763 var point = points_2[_i];
40764 if (point[0] < minX) {
40767 if (point[0] > maxX) {
40770 if (point[1] < minY) {
40773 if (point[1] > maxY) {
40777 if (transform.fullPano) {
40779 for (var i = 0; i < points.length; i++) {
40782 indices.sort(function (a, b) {
40783 return points[a][0] < points[b][0] ?
40785 points[a][0] > points[b][0] ?
40789 var maxDistanceX = points[indices[0]][0] + 1 - points[indices[indices.length - 1]][0];
40790 var leftMostIndex = 0;
40791 for (var i = 0; i < indices.length - 1; i++) {
40792 var index1 = indices[i];
40793 var index2 = indices[i + 1];
40794 var distanceX = points[index2][0] - points[index1][0];
40795 if (distanceX > maxDistanceX) {
40796 maxDistanceX = distanceX;
40797 leftMostIndex = i + 1;
40800 if (leftMostIndex > 0) {
40801 minX = points[indices[leftMostIndex]][0];
40802 maxX = points[indices[leftMostIndex - 1]][0];
40805 return [minX, minY, maxX, maxY];
40808 PointsGeometry.prototype.setCentroid2d = function (value, transform) {
40809 throw new Error("Not implemented");
40811 PointsGeometry.prototype._getPoints3d = function (points2d, transform) {
40813 .map(function (point) {
40814 return transform.unprojectBasic(point, 200);
40817 return PointsGeometry;
40818 }(Component_1.Geometry));
40819 exports.PointsGeometry = PointsGeometry;
40820 exports.default = PointsGeometry;
40822 },{"../../../Component":291}],378:[function(require,module,exports){
40824 var __extends = (this && this.__extends) || (function () {
40825 var extendStatics = function (d, b) {
40826 extendStatics = Object.setPrototypeOf ||
40827 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
40828 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
40829 return extendStatics(d, b);
40831 return function (d, b) {
40832 extendStatics(d, b);
40833 function __() { this.constructor = d; }
40834 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40837 Object.defineProperty(exports, "__esModule", { value: true });
40838 exports.PolygonGeometry = void 0;
40839 var Component_1 = require("../../../Component");
40841 * @class PolygonGeometry
40843 * @classdesc Represents a polygon geometry in the 2D basic image coordinate system.
40844 * All polygons and holes provided to the constructor needs to be closed.
40848 * var basicPolygon = [[0.5, 0.3], [0.7, 0.3], [0.6, 0.5], [0.5, 0.3]];
40849 * var polygonGeometry = new Mapillary.TagComponent.PolygonGeometry(basicPolygon);
40852 var PolygonGeometry = /** @class */ (function (_super) {
40853 __extends(PolygonGeometry, _super);
40855 * Create a polygon geometry.
40858 * @param {Array<Array<number>>} polygon - Array of polygon vertices. Must be closed.
40859 * @param {Array<Array<Array<number>>>} [holes] - Array of arrays of hole vertices.
40860 * Each array of holes vertices must be closed.
40862 * @throws {GeometryTagError} Polygon coordinates must be valid basic coordinates.
40864 function PolygonGeometry(polygon, holes) {
40865 var _this = _super.call(this) || this;
40866 var polygonLength = polygon.length;
40867 if (polygonLength < 3) {
40868 throw new Component_1.GeometryTagError("A polygon must have three or more positions.");
40870 if (polygon[0][0] !== polygon[polygonLength - 1][0] ||
40871 polygon[0][1] !== polygon[polygonLength - 1][1]) {
40872 throw new Component_1.GeometryTagError("First and last positions must be equivalent.");
40874 _this._polygon = [];
40875 for (var _i = 0, polygon_1 = polygon; _i < polygon_1.length; _i++) {
40876 var vertex = polygon_1[_i];
40877 if (vertex[0] < 0 || vertex[0] > 1 ||
40878 vertex[1] < 0 || vertex[1] > 1) {
40879 throw new Component_1.GeometryTagError("Basic coordinates of polygon must be on the interval [0, 1].");
40881 _this._polygon.push(vertex.slice());
40884 if (holes == null) {
40887 for (var i = 0; i < holes.length; i++) {
40888 var hole = holes[i];
40889 var holeLength = hole.length;
40890 if (holeLength < 3) {
40891 throw new Component_1.GeometryTagError("A polygon hole must have three or more positions.");
40893 if (hole[0][0] !== hole[holeLength - 1][0] ||
40894 hole[0][1] !== hole[holeLength - 1][1]) {
40895 throw new Component_1.GeometryTagError("First and last positions of hole must be equivalent.");
40897 _this._holes.push([]);
40898 for (var _a = 0, hole_1 = hole; _a < hole_1.length; _a++) {
40899 var vertex = hole_1[_a];
40900 if (vertex[0] < 0 || vertex[0] > 1 ||
40901 vertex[1] < 0 || vertex[1] > 1) {
40902 throw new Component_1.GeometryTagError("Basic coordinates of hole must be on the interval [0, 1].");
40904 _this._holes[i].push(vertex.slice());
40909 Object.defineProperty(PolygonGeometry.prototype, "polygon", {
40911 * Get polygon property.
40912 * @returns {Array<Array<number>>} Closed 2d polygon.
40915 return this._polygon;
40920 Object.defineProperty(PolygonGeometry.prototype, "holes", {
40922 * Get holes property.
40923 * @returns {Array<Array<Array<number>>>} Holes of 2d polygon.
40926 return this._holes;
40932 * Add a vertex to the polygon by appending it after the last vertex.
40934 * @param {Array<number>} vertex - Vertex to add.
40937 PolygonGeometry.prototype.addVertex2d = function (vertex) {
40939 Math.max(0, Math.min(1, vertex[0])),
40940 Math.max(0, Math.min(1, vertex[1])),
40942 this._polygon.splice(this._polygon.length - 1, 0, clamped);
40943 this._notifyChanged$.next(this);
40946 * Get the coordinates of a vertex from the polygon representation of the geometry.
40948 * @param {number} index - Vertex index.
40949 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
40952 PolygonGeometry.prototype.getVertex2d = function (index) {
40953 return this._polygon[index].slice();
40956 * Remove a vertex from the polygon.
40958 * @param {number} index - The index of the vertex to remove.
40961 PolygonGeometry.prototype.removeVertex2d = function (index) {
40963 index >= this._polygon.length ||
40964 this._polygon.length < 4) {
40965 throw new Component_1.GeometryTagError("Index for removed vertex must be valid.");
40967 if (index > 0 && index < this._polygon.length - 1) {
40968 this._polygon.splice(index, 1);
40971 this._polygon.splice(0, 1);
40972 this._polygon.pop();
40973 var closing = this._polygon[0].slice();
40974 this._polygon.push(closing);
40976 this._notifyChanged$.next(this);
40979 PolygonGeometry.prototype.setVertex2d = function (index, value, transform) {
40981 Math.max(0, Math.min(1, value[0])),
40982 Math.max(0, Math.min(1, value[1])),
40984 if (index === 0 || index === this._polygon.length - 1) {
40985 this._polygon[0] = changed.slice();
40986 this._polygon[this._polygon.length - 1] = changed.slice();
40989 this._polygon[index] = changed.slice();
40991 this._notifyChanged$.next(this);
40994 PolygonGeometry.prototype.setCentroid2d = function (value, transform) {
40995 var xs = this._polygon.map(function (point) { return point[0]; });
40996 var ys = this._polygon.map(function (point) { return point[1]; });
40997 var minX = Math.min.apply(Math, xs);
40998 var maxX = Math.max.apply(Math, xs);
40999 var minY = Math.min.apply(Math, ys);
41000 var maxY = Math.max.apply(Math, ys);
41001 var centroid = this.getCentroid2d();
41002 var minTranslationX = -minX;
41003 var maxTranslationX = 1 - maxX;
41004 var minTranslationY = -minY;
41005 var maxTranslationY = 1 - maxY;
41006 var translationX = Math.max(minTranslationX, Math.min(maxTranslationX, value[0] - centroid[0]));
41007 var translationY = Math.max(minTranslationY, Math.min(maxTranslationY, value[1] - centroid[1]));
41008 for (var _i = 0, _a = this._polygon; _i < _a.length; _i++) {
41009 var point = _a[_i];
41010 point[0] += translationX;
41011 point[1] += translationY;
41013 this._notifyChanged$.next(this);
41016 PolygonGeometry.prototype.getPoints3d = function (transform) {
41017 return this._getPoints3d(this._subsample(this._polygon), transform);
41020 PolygonGeometry.prototype.getVertex3d = function (index, transform) {
41021 return transform.unprojectBasic(this._polygon[index], 200);
41024 PolygonGeometry.prototype.getVertices2d = function () {
41025 return this._polygon.slice();
41028 PolygonGeometry.prototype.getVertices3d = function (transform) {
41029 return this._getPoints3d(this._polygon, transform);
41032 * Get a polygon representation of the 3D coordinates for the vertices of each hole
41033 * of the geometry. Line segments between vertices will possibly be subsampled
41034 * resulting in a larger number of points than the total number of vertices.
41036 * @param {Transform} transform - The transform of the node related to the geometry.
41037 * @returns {Array<Array<Array<number>>>} Array of hole polygons in 3D world coordinates
41038 * representing the vertices of each hole of the geometry.
41041 PolygonGeometry.prototype.getHolePoints3d = function (transform) {
41044 .map(function (hole2d) {
41045 return _this._getPoints3d(_this._subsample(hole2d), transform);
41049 * Get a polygon representation of the 3D coordinates for the vertices of each hole
41052 * @param {Transform} transform - The transform of the node related to the geometry.
41053 * @returns {Array<Array<Array<number>>>} Array of hole polygons in 3D world coordinates
41054 * representing the vertices of each hole of the geometry.
41057 PolygonGeometry.prototype.getHoleVertices3d = function (transform) {
41060 .map(function (hole2d) {
41061 return _this._getPoints3d(hole2d, transform);
41065 PolygonGeometry.prototype.getCentroid2d = function () {
41066 var polygon = this._polygon;
41070 for (var i = 0; i < polygon.length - 1; i++) {
41071 var xi = polygon[i][0];
41072 var yi = polygon[i][1];
41073 var xi1 = polygon[i + 1][0];
41074 var yi1 = polygon[i + 1][1];
41075 var a = xi * yi1 - xi1 * yi;
41077 centroidX += (xi + xi1) * a;
41078 centroidY += (yi + yi1) * a;
41081 centroidX /= 6 * area;
41082 centroidY /= 6 * area;
41083 return [centroidX, centroidY];
41086 PolygonGeometry.prototype.getCentroid3d = function (transform) {
41087 var centroid2d = this.getCentroid2d();
41088 return transform.unprojectBasic(centroid2d, 200);
41091 PolygonGeometry.prototype.get3dDomainTriangles3d = function (transform) {
41093 return this._triangulate(this._project(this._polygon, transform), this.getVertices3d(transform), this._holes
41094 .map(function (hole2d) {
41095 return _this._project(hole2d, transform);
41096 }), this.getHoleVertices3d(transform));
41099 PolygonGeometry.prototype.getTriangles3d = function (transform) {
41101 if (transform.fullPano) {
41102 return this._triangulatePano(this._polygon.slice(), this.holes.slice(), transform);
41104 var points2d = this._project(this._subsample(this._polygon), transform);
41105 var points3d = this.getPoints3d(transform);
41106 var holes2d = this._holes
41107 .map(function (hole) {
41108 return _this._project(_this._subsample(hole), transform);
41110 var holes3d = this.getHolePoints3d(transform);
41111 return this._triangulate(points2d, points3d, holes2d, holes3d);
41114 PolygonGeometry.prototype.getPoleOfInaccessibility2d = function () {
41115 return this._getPoleOfInaccessibility2d(this._polygon.slice());
41118 PolygonGeometry.prototype.getPoleOfInaccessibility3d = function (transform) {
41119 var pole2d = this._getPoleOfInaccessibility2d(this._polygon.slice());
41120 return transform.unprojectBasic(pole2d, 200);
41122 PolygonGeometry.prototype._getPoints3d = function (points2d, transform) {
41124 .map(function (point) {
41125 return transform.unprojectBasic(point, 200);
41128 return PolygonGeometry;
41129 }(Component_1.VertexGeometry));
41130 exports.PolygonGeometry = PolygonGeometry;
41131 exports.default = PolygonGeometry;
41133 },{"../../../Component":291}],379:[function(require,module,exports){
41135 var __extends = (this && this.__extends) || (function () {
41136 var extendStatics = function (d, b) {
41137 extendStatics = Object.setPrototypeOf ||
41138 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
41139 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
41140 return extendStatics(d, b);
41142 return function (d, b) {
41143 extendStatics(d, b);
41144 function __() { this.constructor = d; }
41145 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
41148 Object.defineProperty(exports, "__esModule", { value: true });
41149 exports.RectGeometry = void 0;
41150 var Component_1 = require("../../../Component");
41152 * @class RectGeometry
41154 * @classdesc Represents a rectangle geometry in the 2D basic image coordinate system.
41158 * var basicRect = [0.5, 0.3, 0.7, 0.4];
41159 * var rectGeometry = new Mapillary.TagComponent.RectGeometry(basicRect);
41162 var RectGeometry = /** @class */ (function (_super) {
41163 __extends(RectGeometry, _super);
41165 * Create a rectangle geometry.
41168 * @param {Array<number>} rect - An array representing the top-left and bottom-right
41169 * corners of the rectangle in basic coordinates. Ordered according to [x0, y0, x1, y1].
41171 * @throws {GeometryTagError} Rectangle coordinates must be valid basic coordinates.
41173 function RectGeometry(rect) {
41174 var _this = _super.call(this) || this;
41175 if (rect[1] > rect[3]) {
41176 throw new Component_1.GeometryTagError("Basic Y coordinates values can not be inverted.");
41178 for (var _i = 0, rect_1 = rect; _i < rect_1.length; _i++) {
41179 var coord = rect_1[_i];
41180 if (coord < 0 || coord > 1) {
41181 throw new Component_1.GeometryTagError("Basic coordinates must be on the interval [0, 1].");
41184 _this._anchorIndex = undefined;
41185 _this._rect = rect.slice(0, 4);
41186 _this._inverted = _this._rect[0] > _this._rect[2];
41189 Object.defineProperty(RectGeometry.prototype, "anchorIndex", {
41191 * Get anchor index property.
41193 * @returns {number} Index representing the current anchor property if
41194 * achoring indexing has been initialized. If anchor indexing has not been
41195 * initialized or has been terminated undefined will be returned.
41199 return this._anchorIndex;
41204 Object.defineProperty(RectGeometry.prototype, "inverted", {
41206 * Get inverted property.
41208 * @returns {boolean} Boolean determining whether the rect geometry is
41209 * inverted. For panoramas the rect geometrye may be inverted.
41213 return this._inverted;
41218 Object.defineProperty(RectGeometry.prototype, "rect", {
41220 * Get rect property.
41222 * @returns {Array<number>} Array representing the top-left and bottom-right
41223 * corners of the rectangle in basic coordinates.
41232 * Initialize anchor indexing to enable setting opposite vertex.
41234 * @param {number} [index] - The index of the vertex to use as anchor.
41236 * @throws {Error} If anchor indexing has already been initialized.
41237 * @throws {Error} If index is not valid (0 to 3).
41240 RectGeometry.prototype.initializeAnchorIndexing = function (index) {
41241 if (this._anchorIndex !== undefined) {
41242 throw new Error("Anchor indexing is already initialized.");
41244 if (index < 0 || index > 3) {
41245 throw new Error("Invalid anchor index: " + index + ".");
41247 this._anchorIndex = index === undefined ? 0 : index;
41250 * Terminate anchor indexing to disable setting pposite vertex.
41253 RectGeometry.prototype.terminateAnchorIndexing = function () {
41254 this._anchorIndex = undefined;
41257 * Set the value of the vertex opposite to the anchor in the polygon
41258 * representation of the rectangle.
41260 * @description Setting the opposite vertex may change the anchor index.
41262 * @param {Array<number>} opposite - The new value of the vertex opposite to the anchor.
41263 * @param {Transform} transform - The transform of the node related to the rectangle.
41265 * @throws {Error} When anchor indexing has not been initialized.
41268 RectGeometry.prototype.setOppositeVertex2d = function (opposite, transform) {
41269 if (this._anchorIndex === undefined) {
41270 throw new Error("Anchor indexing needs to be initialized.");
41273 Math.max(0, Math.min(1, opposite[0])),
41274 Math.max(0, Math.min(1, opposite[1])),
41276 var original = this._rect.slice();
41277 var anchor = this._anchorIndex === 0 ? [original[0], original[3]] :
41278 this._anchorIndex === 1 ? [original[0], original[1]] :
41279 this._anchorIndex === 2 ? [original[2], original[1]] :
41280 [original[2], original[3]];
41281 if (transform.fullPano) {
41282 var deltaX = this._anchorIndex < 2 ?
41283 changed[0] - original[2] :
41284 changed[0] - original[0];
41285 if (!this._inverted && this._anchorIndex < 2 && changed[0] < 0.25 && original[2] > 0.75 && deltaX < -0.5) {
41286 // right side passes boundary rightward
41287 this._inverted = true;
41288 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
41290 else if (!this._inverted && this._anchorIndex >= 2 && changed[0] < 0.25 && original[2] > 0.75 && deltaX < -0.5) {
41291 // left side passes right side and boundary rightward
41292 this._inverted = true;
41293 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
41295 else if (this._inverted && this._anchorIndex >= 2 && changed[0] < 0.25 && original[0] > 0.75 && deltaX < -0.5) {
41296 this._inverted = false;
41297 if (anchor[0] > changed[0]) {
41298 // left side passes boundary rightward
41299 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
41302 // left side passes right side and boundary rightward
41303 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
41306 else if (!this._inverted && this._anchorIndex >= 2 && changed[0] > 0.75 && original[0] < 0.25 && deltaX > 0.5) {
41307 // left side passes boundary leftward
41308 this._inverted = true;
41309 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
41311 else if (!this._inverted && this._anchorIndex < 2 && changed[0] > 0.75 && original[0] < 0.25 && deltaX > 0.5) {
41312 // right side passes left side and boundary leftward
41313 this._inverted = true;
41314 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
41316 else if (this._inverted && this._anchorIndex < 2 && changed[0] > 0.75 && original[2] < 0.25 && deltaX > 0.5) {
41317 this._inverted = false;
41318 if (anchor[0] > changed[0]) {
41319 // right side passes boundary leftward
41320 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
41323 // right side passes left side and boundary leftward
41324 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
41327 else if (this._inverted && this._anchorIndex < 2 && changed[0] > original[0]) {
41328 // inverted and right side passes left side completing a loop
41329 this._inverted = false;
41330 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
41332 else if (this._inverted && this._anchorIndex >= 2 && changed[0] < original[2]) {
41333 // inverted and left side passes right side completing a loop
41334 this._inverted = false;
41335 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
41337 else if (this._inverted) {
41338 // if still inverted only top and bottom can switch
41339 if (this._anchorIndex < 2) {
41340 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
41343 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
41347 // if still not inverted treat as non full pano
41348 if (anchor[0] <= changed[0] && anchor[1] > changed[1]) {
41349 this._anchorIndex = 0;
41351 else if (anchor[0] <= changed[0] && anchor[1] <= changed[1]) {
41352 this._anchorIndex = 1;
41354 else if (anchor[0] > changed[0] && anchor[1] <= changed[1]) {
41355 this._anchorIndex = 2;
41358 this._anchorIndex = 3;
41362 if (this._anchorIndex === 0) {
41363 rect[0] = anchor[0];
41364 rect[1] = changed[1];
41365 rect[2] = changed[0];
41366 rect[3] = anchor[1];
41368 else if (this._anchorIndex === 1) {
41369 rect[0] = anchor[0];
41370 rect[1] = anchor[1];
41371 rect[2] = changed[0];
41372 rect[3] = changed[1];
41374 else if (this._anchorIndex === 2) {
41375 rect[0] = changed[0];
41376 rect[1] = anchor[1];
41377 rect[2] = anchor[0];
41378 rect[3] = changed[1];
41381 rect[0] = changed[0];
41382 rect[1] = changed[1];
41383 rect[2] = anchor[0];
41384 rect[3] = anchor[1];
41386 if (!this._inverted && rect[0] > rect[2] ||
41387 this._inverted && rect[0] < rect[2]) {
41388 rect[0] = original[0];
41389 rect[2] = original[2];
41391 if (rect[1] > rect[3]) {
41392 rect[1] = original[1];
41393 rect[3] = original[3];
41395 this._rect[0] = rect[0];
41396 this._rect[1] = rect[1];
41397 this._rect[2] = rect[2];
41398 this._rect[3] = rect[3];
41401 if (anchor[0] <= changed[0] && anchor[1] > changed[1]) {
41402 this._anchorIndex = 0;
41404 else if (anchor[0] <= changed[0] && anchor[1] <= changed[1]) {
41405 this._anchorIndex = 1;
41407 else if (anchor[0] > changed[0] && anchor[1] <= changed[1]) {
41408 this._anchorIndex = 2;
41411 this._anchorIndex = 3;
41414 if (this._anchorIndex === 0) {
41415 rect[0] = anchor[0];
41416 rect[1] = changed[1];
41417 rect[2] = changed[0];
41418 rect[3] = anchor[1];
41420 else if (this._anchorIndex === 1) {
41421 rect[0] = anchor[0];
41422 rect[1] = anchor[1];
41423 rect[2] = changed[0];
41424 rect[3] = changed[1];
41426 else if (this._anchorIndex === 2) {
41427 rect[0] = changed[0];
41428 rect[1] = anchor[1];
41429 rect[2] = anchor[0];
41430 rect[3] = changed[1];
41433 rect[0] = changed[0];
41434 rect[1] = changed[1];
41435 rect[2] = anchor[0];
41436 rect[3] = anchor[1];
41438 if (rect[0] > rect[2]) {
41439 rect[0] = original[0];
41440 rect[2] = original[2];
41442 if (rect[1] > rect[3]) {
41443 rect[1] = original[1];
41444 rect[3] = original[3];
41446 this._rect[0] = rect[0];
41447 this._rect[1] = rect[1];
41448 this._rect[2] = rect[2];
41449 this._rect[3] = rect[3];
41451 this._notifyChanged$.next(this);
41454 * Set the value of a vertex in the polygon representation of the rectangle.
41456 * @description The polygon is defined to have the first vertex at the
41457 * bottom-left corner with the rest of the vertices following in clockwise order.
41459 * @param {number} index - The index of the vertex to be set.
41460 * @param {Array<number>} value - The new value of the vertex.
41461 * @param {Transform} transform - The transform of the node related to the rectangle.
41464 RectGeometry.prototype.setVertex2d = function (index, value, transform) {
41465 var original = this._rect.slice();
41467 Math.max(0, Math.min(1, value[0])),
41468 Math.max(0, Math.min(1, value[1])),
41472 rect[0] = changed[0];
41473 rect[1] = original[1];
41474 rect[2] = original[2];
41475 rect[3] = changed[1];
41477 else if (index === 1) {
41478 rect[0] = changed[0];
41479 rect[1] = changed[1];
41480 rect[2] = original[2];
41481 rect[3] = original[3];
41483 else if (index === 2) {
41484 rect[0] = original[0];
41485 rect[1] = changed[1];
41486 rect[2] = changed[0];
41487 rect[3] = original[3];
41489 else if (index === 3) {
41490 rect[0] = original[0];
41491 rect[1] = original[1];
41492 rect[2] = changed[0];
41493 rect[3] = changed[1];
41495 if (transform.fullPano) {
41496 var passingBoundaryLeftward = index < 2 && changed[0] > 0.75 && original[0] < 0.25 ||
41497 index >= 2 && this._inverted && changed[0] > 0.75 && original[2] < 0.25;
41498 var passingBoundaryRightward = index < 2 && this._inverted && changed[0] < 0.25 && original[0] > 0.75 ||
41499 index >= 2 && changed[0] < 0.25 && original[2] > 0.75;
41500 if (passingBoundaryLeftward || passingBoundaryRightward) {
41501 this._inverted = !this._inverted;
41504 if (rect[0] - original[0] < -0.25) {
41505 rect[0] = original[0];
41507 if (rect[2] - original[2] > 0.25) {
41508 rect[2] = original[2];
41511 if (!this._inverted && rect[0] > rect[2] ||
41512 this._inverted && rect[0] < rect[2]) {
41513 rect[0] = original[0];
41514 rect[2] = original[2];
41518 if (rect[0] > rect[2]) {
41519 rect[0] = original[0];
41520 rect[2] = original[2];
41523 if (rect[1] > rect[3]) {
41524 rect[1] = original[1];
41525 rect[3] = original[3];
41527 this._rect[0] = rect[0];
41528 this._rect[1] = rect[1];
41529 this._rect[2] = rect[2];
41530 this._rect[3] = rect[3];
41531 this._notifyChanged$.next(this);
41534 RectGeometry.prototype.setCentroid2d = function (value, transform) {
41535 var original = this._rect.slice();
41536 var x0 = original[0];
41537 var x1 = this._inverted ? original[2] + 1 : original[2];
41538 var y0 = original[1];
41539 var y1 = original[3];
41540 var centerX = x0 + (x1 - x0) / 2;
41541 var centerY = y0 + (y1 - y0) / 2;
41542 var translationX = 0;
41543 if (transform.gpano != null &&
41544 transform.gpano.CroppedAreaImageWidthPixels === transform.gpano.FullPanoWidthPixels) {
41545 translationX = this._inverted ? value[0] + 1 - centerX : value[0] - centerX;
41548 var minTranslationX = -x0;
41549 var maxTranslationX = 1 - x1;
41550 translationX = Math.max(minTranslationX, Math.min(maxTranslationX, value[0] - centerX));
41552 var minTranslationY = -y0;
41553 var maxTranslationY = 1 - y1;
41554 var translationY = Math.max(minTranslationY, Math.min(maxTranslationY, value[1] - centerY));
41555 this._rect[0] = original[0] + translationX;
41556 this._rect[1] = original[1] + translationY;
41557 this._rect[2] = original[2] + translationX;
41558 this._rect[3] = original[3] + translationY;
41559 if (this._rect[0] < 0) {
41560 this._rect[0] += 1;
41561 this._inverted = !this._inverted;
41563 else if (this._rect[0] > 1) {
41564 this._rect[0] -= 1;
41565 this._inverted = !this._inverted;
41567 if (this._rect[2] < 0) {
41568 this._rect[2] += 1;
41569 this._inverted = !this._inverted;
41571 else if (this._rect[2] > 1) {
41572 this._rect[2] -= 1;
41573 this._inverted = !this._inverted;
41575 this._notifyChanged$.next(this);
41578 * Get the 3D coordinates for the vertices of the rectangle with
41579 * interpolated points along the lines.
41581 * @param {Transform} transform - The transform of the node related to
41583 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates
41584 * representing the rectangle.
41587 RectGeometry.prototype.getPoints3d = function (transform) {
41588 return this._getPoints2d()
41589 .map(function (point) {
41590 return transform.unprojectBasic(point, 200);
41594 * Get the coordinates of a vertex from the polygon representation of the geometry.
41596 * @description The first vertex represents the bottom-left corner with the rest of
41597 * the vertices following in clockwise order. The method shifts the right side
41598 * coordinates of the rectangle by one unit to ensure that the vertices are ordered
41601 * @param {number} index - Vertex index.
41602 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
41605 RectGeometry.prototype.getVertex2d = function (index) {
41606 return this._rectToVertices2d(this._rect)[index];
41609 * Get the coordinates of a vertex from the polygon representation of the geometry.
41611 * @description The first vertex represents the bottom-left corner with the rest of
41612 * the vertices following in clockwise order. The coordinates will not be shifted
41613 * so they may not appear in clockwise order when layed out on the plane.
41615 * @param {number} index - Vertex index.
41616 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
41619 RectGeometry.prototype.getNonAdjustedVertex2d = function (index) {
41620 return this._rectToNonAdjustedVertices2d(this._rect)[index];
41623 * Get a vertex from the polygon representation of the 3D coordinates for the
41624 * vertices of the geometry.
41626 * @description The first vertex represents the bottom-left corner with the rest of
41627 * the vertices following in clockwise order.
41629 * @param {number} index - Vertex index.
41630 * @param {Transform} transform - The transform of the node related to the geometry.
41631 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates representing
41632 * the vertices of the geometry.
41635 RectGeometry.prototype.getVertex3d = function (index, transform) {
41636 return transform.unprojectBasic(this._rectToVertices2d(this._rect)[index], 200);
41639 * Get a polygon representation of the 2D basic coordinates for the vertices of the rectangle.
41641 * @description The first vertex represents the bottom-left corner with the rest of
41642 * the vertices following in clockwise order.
41644 * @returns {Array<Array<number>>} Polygon array of 2D basic coordinates representing
41645 * the rectangle vertices.
41648 RectGeometry.prototype.getVertices2d = function () {
41649 return this._rectToVertices2d(this._rect);
41652 * Get a polygon representation of the 3D coordinates for the vertices of the rectangle.
41654 * @description The first vertex represents the bottom-left corner with the rest of
41655 * the vertices following in clockwise order.
41657 * @param {Transform} transform - The transform of the node related to the rectangle.
41658 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates representing
41659 * the rectangle vertices.
41662 RectGeometry.prototype.getVertices3d = function (transform) {
41663 return this._rectToVertices2d(this._rect)
41664 .map(function (vertex) {
41665 return transform.unprojectBasic(vertex, 200);
41669 RectGeometry.prototype.getCentroid2d = function () {
41670 var rect = this._rect;
41672 var x1 = this._inverted ? rect[2] + 1 : rect[2];
41675 var centroidX = (x0 + x1) / 2;
41676 var centroidY = (y0 + y1) / 2;
41677 return [centroidX, centroidY];
41680 RectGeometry.prototype.getCentroid3d = function (transform) {
41681 var centroid2d = this.getCentroid2d();
41682 return transform.unprojectBasic(centroid2d, 200);
41687 RectGeometry.prototype.getPoleOfInaccessibility2d = function () {
41688 return this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));
41691 RectGeometry.prototype.getPoleOfInaccessibility3d = function (transform) {
41692 var pole2d = this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));
41693 return transform.unprojectBasic(pole2d, 200);
41696 RectGeometry.prototype.getTriangles3d = function (transform) {
41697 return transform.fullPano ?
41699 this._triangulate(this._project(this._getPoints2d(), transform), this.getPoints3d(transform));
41702 * Check if a particular bottom-right value is valid according to the current
41703 * rectangle coordinates.
41705 * @param {Array<number>} bottomRight - The bottom-right coordinates to validate
41706 * @returns {boolean} Value indicating whether the provided bottom-right coordinates
41710 RectGeometry.prototype.validate = function (bottomRight) {
41711 var rect = this._rect;
41712 if (!this._inverted && bottomRight[0] < rect[0] ||
41713 bottomRight[0] - rect[2] > 0.25 ||
41714 bottomRight[1] < rect[1]) {
41720 * Get the 2D coordinates for the vertices of the rectangle with
41721 * interpolated points along the lines.
41723 * @returns {Array<Array<number>>} Polygon array of 2D basic coordinates
41724 * representing the rectangle.
41726 RectGeometry.prototype._getPoints2d = function () {
41727 var vertices2d = this._rectToVertices2d(this._rect);
41728 var sides = vertices2d.length - 1;
41731 for (var i = 0; i < sides; ++i) {
41732 var startX = vertices2d[i][0];
41733 var startY = vertices2d[i][1];
41734 var endX = vertices2d[i + 1][0];
41735 var endY = vertices2d[i + 1][1];
41736 var intervalX = (endX - startX) / (sections - 1);
41737 var intervalY = (endY - startY) / (sections - 1);
41738 for (var j = 0; j < sections; ++j) {
41740 startX + j * intervalX,
41741 startY + j * intervalY,
41743 points2d.push(point);
41749 * Convert the top-left, bottom-right representation of a rectangle to a polygon
41750 * representation of the vertices starting at the bottom-left corner going
41753 * @description The method shifts the right side coordinates of the rectangle
41754 * by one unit to ensure that the vertices are ordered clockwise.
41756 * @param {Array<number>} rect - Top-left, bottom-right representation of a
41758 * @returns {Array<Array<number>>} Polygon representation of the vertices of the
41761 RectGeometry.prototype._rectToVertices2d = function (rect) {
41763 [rect[0], rect[3]],
41764 [rect[0], rect[1]],
41765 [this._inverted ? rect[2] + 1 : rect[2], rect[1]],
41766 [this._inverted ? rect[2] + 1 : rect[2], rect[3]],
41767 [rect[0], rect[3]],
41771 * Convert the top-left, bottom-right representation of a rectangle to a polygon
41772 * representation of the vertices starting at the bottom-left corner going
41775 * @description The first vertex represents the bottom-left corner with the rest of
41776 * the vertices following in clockwise order. The coordinates will not be shifted
41777 * to ensure that the vertices are ordered clockwise when layed out on the plane.
41779 * @param {Array<number>} rect - Top-left, bottom-right representation of a
41781 * @returns {Array<Array<number>>} Polygon representation of the vertices of the
41784 RectGeometry.prototype._rectToNonAdjustedVertices2d = function (rect) {
41786 [rect[0], rect[3]],
41787 [rect[0], rect[1]],
41788 [rect[2], rect[1]],
41789 [rect[2], rect[3]],
41790 [rect[0], rect[3]],
41793 return RectGeometry;
41794 }(Component_1.VertexGeometry));
41795 exports.RectGeometry = RectGeometry;
41796 exports.default = RectGeometry;
41798 },{"../../../Component":291}],380:[function(require,module,exports){
41800 var __extends = (this && this.__extends) || (function () {
41801 var extendStatics = function (d, b) {
41802 extendStatics = Object.setPrototypeOf ||
41803 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
41804 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
41805 return extendStatics(d, b);
41807 return function (d, b) {
41808 extendStatics(d, b);
41809 function __() { this.constructor = d; }
41810 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
41813 var __spreadArrays = (this && this.__spreadArrays) || function () {
41814 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
41815 for (var r = Array(s), k = 0, i = 0; i < il; i++)
41816 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
41820 Object.defineProperty(exports, "__esModule", { value: true });
41821 exports.VertexGeometry = void 0;
41822 var earcut_1 = require("earcut");
41823 var martinez = require("martinez-polygon-clipping");
41824 var polylabel = require("@mapbox/polylabel");
41825 var THREE = require("three");
41826 var Component_1 = require("../../../Component");
41828 * @class VertexGeometry
41830 * @classdesc Represents a vertex geometry.
41832 var VertexGeometry = /** @class */ (function (_super) {
41833 __extends(VertexGeometry, _super);
41835 * Create a vertex geometry.
41840 function VertexGeometry() {
41841 var _this = _super.call(this) || this;
41842 _this._subsampleThreshold = 0.005;
41846 * Finds the polygon pole of inaccessibility, the most distant internal
41847 * point from the polygon outline.
41849 * @param {Array<Array<number>>} points2d - 2d points of outline to triangulate.
41850 * @returns {Array<number>} Point of inaccessibility.
41853 VertexGeometry.prototype._getPoleOfInaccessibility2d = function (points2d) {
41854 var pole2d = polylabel([points2d], 3e-2);
41857 VertexGeometry.prototype._project = function (points2d, transform) {
41858 var camera = this._createCamera(transform.upVector().toArray(), transform.unprojectSfM([0, 0], 0), transform.unprojectSfM([0, 0], 10));
41859 return this._deunproject(points2d, transform, camera);
41861 VertexGeometry.prototype._subsample = function (points2d, threshold) {
41862 if (threshold === void 0) { threshold = this._subsampleThreshold; }
41863 var subsampled = [];
41864 var length = points2d.length;
41865 for (var index = 0; index < length; index++) {
41866 var p1 = points2d[index];
41867 var p2 = points2d[(index + 1) % length];
41868 subsampled.push(p1);
41869 var dist = Math.sqrt(Math.pow((p2[0] - p1[0]), 2) + Math.pow((p2[1] - p1[1]), 2));
41870 var subsamples = Math.floor(dist / threshold);
41871 var coeff = 1 / (subsamples + 1);
41872 for (var i = 1; i <= subsamples; i++) {
41873 var alpha = i * coeff;
41875 (1 - alpha) * p1[0] + alpha * p2[0],
41876 (1 - alpha) * p1[1] + alpha * p2[1],
41878 subsampled.push(subsample);
41884 * Triangulates a 2d polygon and returns the triangle
41885 * representation as a flattened array of 3d points.
41887 * @param {Array<Array<number>>} points2d - 2d points of outline to triangulate.
41888 * @param {Array<Array<number>>} points3d - 3d points of outline corresponding to the 2d points.
41889 * @param {Array<Array<Array<number>>>} [holes2d] - 2d points of holes to triangulate.
41890 * @param {Array<Array<Array<number>>>} [holes3d] - 3d points of holes corresponding to the 2d points.
41891 * @returns {Array<number>} Flattened array of 3d points ordered based on the triangles.
41894 VertexGeometry.prototype._triangulate = function (points2d, points3d, holes2d, holes3d) {
41895 var data = [points2d.slice(0, -1)];
41896 for (var _i = 0, _a = holes2d != null ? holes2d : []; _i < _a.length; _i++) {
41897 var hole2d = _a[_i];
41898 data.push(hole2d.slice(0, -1));
41900 var points = points3d.slice(0, -1);
41901 for (var _b = 0, _c = holes3d != null ? holes3d : []; _b < _c.length; _b++) {
41902 var hole3d = _c[_b];
41903 points = points.concat(hole3d.slice(0, -1));
41905 var flattened = earcut_1.default.flatten(data);
41906 var indices = earcut_1.default(flattened.vertices, flattened.holes, flattened.dimensions);
41907 var triangles = [];
41908 for (var i = 0; i < indices.length; ++i) {
41909 var point = points[indices[i]];
41910 triangles.push(point[0]);
41911 triangles.push(point[1]);
41912 triangles.push(point[2]);
41916 VertexGeometry.prototype._triangulatePano = function (points2d, holes2d, transform) {
41917 var triangles = [];
41918 var epsilon = 1e-9;
41921 for (var x = 0; x < subareasX; x++) {
41922 for (var y = 0; y < subareasY; y++) {
41923 var epsilonX0 = x === 0 ? -epsilon : epsilon;
41924 var epsilonY0 = y === 0 ? -epsilon : epsilon;
41925 var x0 = x / subareasX + epsilonX0;
41926 var y0 = y / subareasY + epsilonY0;
41927 var x1 = (x + 1) / subareasX + epsilon;
41928 var y1 = (y + 1) / subareasY + epsilon;
41937 (2 * x + 1) / (2 * subareasX),
41938 (2 * y + 1) / (2 * subareasY),
41940 triangles.push.apply(triangles, this._triangulateSubarea(points2d, holes2d, bbox2d, lookat2d, transform));
41945 VertexGeometry.prototype._unproject = function (points2d, transform, distance) {
41946 if (distance === void 0) { distance = 200; }
41948 .map(function (point) {
41949 return transform.unprojectBasic(point, distance);
41952 VertexGeometry.prototype._createCamera = function (upVector, position, lookAt) {
41953 var camera = new THREE.Camera();
41954 camera.up.copy(new THREE.Vector3().fromArray(upVector));
41955 camera.position.copy(new THREE.Vector3().fromArray(position));
41956 camera.lookAt(new THREE.Vector3().fromArray(lookAt));
41957 camera.updateMatrix();
41958 camera.updateMatrixWorld(true);
41961 VertexGeometry.prototype._deunproject = function (points2d, transform, camera) {
41963 .map(function (point2d) {
41964 var pointWorld = transform.unprojectBasic(point2d, 10000);
41965 var pointCamera = new THREE.Vector3(pointWorld[0], pointWorld[1], pointWorld[2])
41966 .applyMatrix4(camera.matrixWorldInverse);
41967 return [pointCamera.x / pointCamera.z, pointCamera.y / pointCamera.z];
41970 VertexGeometry.prototype._triangulateSubarea = function (points2d, holes2d, bbox2d, lookat2d, transform) {
41971 var intersections = martinez.intersection(__spreadArrays([points2d], holes2d), [bbox2d]);
41972 if (!intersections) {
41975 var triangles = [];
41976 var threshold = this._subsampleThreshold;
41977 var camera = this._createCamera(transform.upVector().toArray(), transform.unprojectSfM([0, 0], 0), transform.unprojectBasic(lookat2d, 10));
41978 for (var _i = 0, intersections_1 = intersections; _i < intersections_1.length; _i++) {
41979 var intersection = intersections_1[_i];
41980 var subsampledPolygon2d = this._subsample(intersection[0], threshold);
41981 var polygon2d = this._deunproject(subsampledPolygon2d, transform, camera);
41982 var polygon3d = this._unproject(subsampledPolygon2d, transform);
41983 var polygonHoles2d = [];
41984 var polygonHoles3d = [];
41985 for (var i = 1; i < intersection.length; i++) {
41986 var subsampledHole2d = this._subsample(intersection[i], threshold);
41987 var hole2d = this._deunproject(subsampledHole2d, transform, camera);
41988 var hole3d = this._unproject(subsampledHole2d, transform);
41989 polygonHoles2d.push(hole2d);
41990 polygonHoles3d.push(hole3d);
41992 triangles.push.apply(triangles, this._triangulate(polygon2d, polygon3d, polygonHoles2d, polygonHoles3d));
41996 return VertexGeometry;
41997 }(Component_1.Geometry));
41998 exports.VertexGeometry = VertexGeometry;
41999 exports.default = VertexGeometry;
42001 },{"../../../Component":291,"@mapbox/polylabel":1,"earcut":8,"martinez-polygon-clipping":22,"three":242}],381:[function(require,module,exports){
42003 var __extends = (this && this.__extends) || (function () {
42004 var extendStatics = function (d, b) {
42005 extendStatics = Object.setPrototypeOf ||
42006 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42007 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42008 return extendStatics(d, b);
42010 return function (d, b) {
42011 extendStatics(d, b);
42012 function __() { this.constructor = d; }
42013 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42016 Object.defineProperty(exports, "__esModule", { value: true });
42017 exports.CreateHandlerBase = void 0;
42018 var operators_1 = require("rxjs/operators");
42019 var rxjs_1 = require("rxjs");
42020 var Component_1 = require("../../../Component");
42021 var CreateHandlerBase = /** @class */ (function (_super) {
42022 __extends(CreateHandlerBase, _super);
42023 function CreateHandlerBase(component, container, navigator, viewportCoords, tagCreator) {
42024 var _this = _super.call(this, component, container, navigator, viewportCoords) || this;
42025 _this._tagCreator = tagCreator;
42026 _this._geometryCreated$ = new rxjs_1.Subject();
42029 Object.defineProperty(CreateHandlerBase.prototype, "geometryCreated$", {
42031 return this._geometryCreated$;
42036 CreateHandlerBase.prototype._enable = function () {
42037 this._enableCreate();
42038 this._container.element.classList.add("component-tag-create");
42040 CreateHandlerBase.prototype._disable = function () {
42041 this._container.element.classList.remove("component-tag-create");
42042 this._disableCreate();
42044 CreateHandlerBase.prototype._validateBasic = function (basic) {
42047 return 0 <= x && x <= 1 && 0 <= y && y <= 1;
42049 CreateHandlerBase.prototype._mouseEventToBasic$ = function (mouseEvent$) {
42051 return mouseEvent$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
42052 var event = _a[0], camera = _a[1], transform = _a[2];
42053 return _this._mouseEventToBasic(event, _this._container.element, camera, transform);
42056 return CreateHandlerBase;
42057 }(Component_1.TagHandlerBase));
42058 exports.CreateHandlerBase = CreateHandlerBase;
42059 exports.default = CreateHandlerBase;
42061 },{"../../../Component":291,"rxjs":43,"rxjs/operators":241}],382:[function(require,module,exports){
42063 var __extends = (this && this.__extends) || (function () {
42064 var extendStatics = function (d, b) {
42065 extendStatics = Object.setPrototypeOf ||
42066 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42067 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42068 return extendStatics(d, b);
42070 return function (d, b) {
42071 extendStatics(d, b);
42072 function __() { this.constructor = d; }
42073 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42076 Object.defineProperty(exports, "__esModule", { value: true });
42077 exports.CreatePointHandler = void 0;
42078 var operators_1 = require("rxjs/operators");
42079 var Component_1 = require("../../../Component");
42080 var CreatePointHandler = /** @class */ (function (_super) {
42081 __extends(CreatePointHandler, _super);
42082 function CreatePointHandler() {
42083 return _super !== null && _super.apply(this, arguments) || this;
42085 CreatePointHandler.prototype._enableCreate = function () {
42086 this._container.mouseService.deferPixels(this._name, 4);
42087 this._geometryCreatedSubscription = this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(operators_1.filter(this._validateBasic), operators_1.map(function (basic) {
42088 return new Component_1.PointGeometry(basic);
42090 .subscribe(this._geometryCreated$);
42092 CreatePointHandler.prototype._disableCreate = function () {
42093 this._container.mouseService.undeferPixels(this._name);
42094 this._geometryCreatedSubscription.unsubscribe();
42096 CreatePointHandler.prototype._getNameExtension = function () {
42097 return "create-point";
42099 return CreatePointHandler;
42100 }(Component_1.CreateHandlerBase));
42101 exports.CreatePointHandler = CreatePointHandler;
42102 exports.default = CreatePointHandler;
42104 },{"../../../Component":291,"rxjs/operators":241}],383:[function(require,module,exports){
42106 var __extends = (this && this.__extends) || (function () {
42107 var extendStatics = function (d, b) {
42108 extendStatics = Object.setPrototypeOf ||
42109 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42110 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42111 return extendStatics(d, b);
42113 return function (d, b) {
42114 extendStatics(d, b);
42115 function __() { this.constructor = d; }
42116 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42119 Object.defineProperty(exports, "__esModule", { value: true });
42120 exports.CreatePointsHandler = void 0;
42121 var Component_1 = require("../../../Component");
42122 var CreatePointsHandler = /** @class */ (function (_super) {
42123 __extends(CreatePointsHandler, _super);
42124 function CreatePointsHandler() {
42125 return _super !== null && _super.apply(this, arguments) || this;
42127 Object.defineProperty(CreatePointsHandler.prototype, "_create$", {
42129 return this._tagCreator.createPoints$;
42134 CreatePointsHandler.prototype._addPoint = function (tag, basicPoint) {
42135 tag.geometry.addPoint2d(basicPoint);
42137 CreatePointsHandler.prototype._getNameExtension = function () {
42138 return "create-points";
42140 CreatePointsHandler.prototype._setVertex2d = function (tag, basicPoint, transform) {
42141 tag.geometry.setPoint2d((tag.geometry).points.length - 1, basicPoint, transform);
42143 return CreatePointsHandler;
42144 }(Component_1.CreateVertexHandler));
42145 exports.CreatePointsHandler = CreatePointsHandler;
42146 exports.default = CreatePointsHandler;
42148 },{"../../../Component":291}],384:[function(require,module,exports){
42150 var __extends = (this && this.__extends) || (function () {
42151 var extendStatics = function (d, b) {
42152 extendStatics = Object.setPrototypeOf ||
42153 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42154 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42155 return extendStatics(d, b);
42157 return function (d, b) {
42158 extendStatics(d, b);
42159 function __() { this.constructor = d; }
42160 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42163 Object.defineProperty(exports, "__esModule", { value: true });
42164 exports.CreatePolygonHandler = void 0;
42165 var Component_1 = require("../../../Component");
42166 var CreatePolygonHandler = /** @class */ (function (_super) {
42167 __extends(CreatePolygonHandler, _super);
42168 function CreatePolygonHandler() {
42169 return _super !== null && _super.apply(this, arguments) || this;
42171 Object.defineProperty(CreatePolygonHandler.prototype, "_create$", {
42173 return this._tagCreator.createPolygon$;
42178 CreatePolygonHandler.prototype._addPoint = function (tag, basicPoint) {
42179 tag.addPoint(basicPoint);
42181 CreatePolygonHandler.prototype._getNameExtension = function () {
42182 return "create-polygon";
42184 CreatePolygonHandler.prototype._setVertex2d = function (tag, basicPoint, transform) {
42185 tag.geometry.setVertex2d(tag.geometry.polygon.length - 2, basicPoint, transform);
42187 return CreatePolygonHandler;
42188 }(Component_1.CreateVertexHandler));
42189 exports.CreatePolygonHandler = CreatePolygonHandler;
42190 exports.default = CreatePolygonHandler;
42192 },{"../../../Component":291}],385:[function(require,module,exports){
42194 var __extends = (this && this.__extends) || (function () {
42195 var extendStatics = function (d, b) {
42196 extendStatics = Object.setPrototypeOf ||
42197 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42198 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42199 return extendStatics(d, b);
42201 return function (d, b) {
42202 extendStatics(d, b);
42203 function __() { this.constructor = d; }
42204 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42207 Object.defineProperty(exports, "__esModule", { value: true });
42208 exports.CreateRectDragHandler = void 0;
42209 var rxjs_1 = require("rxjs");
42210 var operators_1 = require("rxjs/operators");
42211 var Component_1 = require("../../../Component");
42212 var CreateRectDragHandler = /** @class */ (function (_super) {
42213 __extends(CreateRectDragHandler, _super);
42214 function CreateRectDragHandler() {
42215 return _super !== null && _super.apply(this, arguments) || this;
42217 CreateRectDragHandler.prototype._enableCreate = function () {
42219 this._container.mouseService.claimMouse(this._name, 2);
42220 this._deleteSubscription = this._navigator.stateService.currentTransform$.pipe(operators_1.map(function (transform) { return null; }), operators_1.skip(1))
42221 .subscribe(this._tagCreator.delete$);
42222 this._createSubscription = this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name, this._container.mouseService.mouseDragStart$)).pipe(operators_1.filter(this._validateBasic))
42223 .subscribe(this._tagCreator.createRect$);
42224 this._initializeAnchorIndexingSubscription = this._tagCreator.tag$.pipe(operators_1.filter(function (tag) {
42227 .subscribe(function (tag) {
42228 tag.geometry.initializeAnchorIndexing();
42230 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) {
42231 var _b = _a[0], event = _b[0], camera = _b[1], transform = _a[1];
42232 return _this._mouseEventToBasic(event, _this._container.element, camera, transform);
42234 this._setVertexSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
42236 rxjs_1.combineLatest(rxjs_1.of(tag), basicMouse$, _this._navigator.stateService.currentTransform$) :
42239 .subscribe(function (_a) {
42240 var tag = _a[0], basicPoint = _a[1], transform = _a[2];
42241 tag.geometry.setOppositeVertex2d(basicPoint, transform);
42243 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) {
42245 }), operators_1.share());
42246 this._addPointSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
42248 rxjs_1.combineLatest(rxjs_1.of(tag), basicMouseDragEnd$) :
42251 .subscribe(function (_a) {
42252 var tag = _a[0], basicPoint = _a[1];
42253 var rectGeometry = tag.geometry;
42254 if (!rectGeometry.validate(basicPoint)) {
42255 basicPoint = rectGeometry.getNonAdjustedVertex2d(3);
42257 tag.addPoint(basicPoint);
42259 this._geometryCreatedSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
42261 tag.created$.pipe(operators_1.map(function (t) {
42266 .subscribe(this._geometryCreated$);
42268 CreateRectDragHandler.prototype._disableCreate = function () {
42269 this._container.mouseService.unclaimMouse(this._name);
42270 this._tagCreator.delete$.next(null);
42271 this._addPointSubscription.unsubscribe();
42272 this._createSubscription.unsubscribe();
42273 this._deleteSubscription.unsubscribe();
42274 this._geometryCreatedSubscription.unsubscribe();
42275 this._initializeAnchorIndexingSubscription.unsubscribe();
42276 this._setVertexSubscription.unsubscribe();
42278 CreateRectDragHandler.prototype._getNameExtension = function () {
42279 return "create-rect-drag";
42281 return CreateRectDragHandler;
42282 }(Component_1.CreateHandlerBase));
42283 exports.CreateRectDragHandler = CreateRectDragHandler;
42284 exports.default = CreateRectDragHandler;
42286 },{"../../../Component":291,"rxjs":43,"rxjs/operators":241}],386:[function(require,module,exports){
42288 var __extends = (this && this.__extends) || (function () {
42289 var extendStatics = function (d, b) {
42290 extendStatics = Object.setPrototypeOf ||
42291 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42292 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42293 return extendStatics(d, b);
42295 return function (d, b) {
42296 extendStatics(d, b);
42297 function __() { this.constructor = d; }
42298 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42301 Object.defineProperty(exports, "__esModule", { value: true });
42302 exports.CreateRectHandler = void 0;
42303 var operators_1 = require("rxjs/operators");
42304 var Component_1 = require("../../../Component");
42305 var CreateRectHandler = /** @class */ (function (_super) {
42306 __extends(CreateRectHandler, _super);
42307 function CreateRectHandler() {
42308 return _super !== null && _super.apply(this, arguments) || this;
42310 Object.defineProperty(CreateRectHandler.prototype, "_create$", {
42312 return this._tagCreator.createRect$;
42317 CreateRectHandler.prototype._addPoint = function (tag, basicPoint) {
42318 var rectGeometry = tag.geometry;
42319 if (!rectGeometry.validate(basicPoint)) {
42320 basicPoint = rectGeometry.getNonAdjustedVertex2d(3);
42322 tag.addPoint(basicPoint);
42324 CreateRectHandler.prototype._enable = function () {
42325 _super.prototype._enable.call(this);
42326 this._initializeAnchorIndexingSubscription = this._tagCreator.tag$.pipe(operators_1.filter(function (tag) {
42329 .subscribe(function (tag) {
42330 tag.geometry.initializeAnchorIndexing();
42333 CreateRectHandler.prototype._disable = function () {
42334 _super.prototype._disable.call(this);
42335 this._initializeAnchorIndexingSubscription.unsubscribe();
42337 CreateRectHandler.prototype._getNameExtension = function () {
42338 return "create-rect";
42340 CreateRectHandler.prototype._setVertex2d = function (tag, basicPoint, transform) {
42341 tag.geometry.setOppositeVertex2d(basicPoint, transform);
42343 return CreateRectHandler;
42344 }(Component_1.CreateVertexHandler));
42345 exports.CreateRectHandler = CreateRectHandler;
42346 exports.default = CreateRectHandler;
42348 },{"../../../Component":291,"rxjs/operators":241}],387:[function(require,module,exports){
42350 var __extends = (this && this.__extends) || (function () {
42351 var extendStatics = function (d, b) {
42352 extendStatics = Object.setPrototypeOf ||
42353 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42354 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42355 return extendStatics(d, b);
42357 return function (d, b) {
42358 extendStatics(d, b);
42359 function __() { this.constructor = d; }
42360 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42363 Object.defineProperty(exports, "__esModule", { value: true });
42364 exports.CreateVertexHandler = void 0;
42365 var rxjs_1 = require("rxjs");
42366 var operators_1 = require("rxjs/operators");
42367 var Component_1 = require("../../../Component");
42368 var CreateVertexHandler = /** @class */ (function (_super) {
42369 __extends(CreateVertexHandler, _super);
42370 function CreateVertexHandler() {
42371 return _super !== null && _super.apply(this, arguments) || this;
42373 CreateVertexHandler.prototype._enableCreate = function () {
42375 this._container.mouseService.deferPixels(this._name, 4);
42376 var transformChanged$ = this._navigator.stateService.currentTransform$.pipe(operators_1.map(function () { }), operators_1.publishReplay(1), operators_1.refCount());
42377 this._deleteSubscription = transformChanged$.pipe(operators_1.skip(1))
42378 .subscribe(this._tagCreator.delete$);
42379 var basicClick$ = this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(operators_1.share());
42380 this._createSubscription = transformChanged$.pipe(operators_1.switchMap(function () {
42381 return basicClick$.pipe(operators_1.filter(_this._validateBasic), operators_1.take(1));
42383 .subscribe(this._create$);
42384 this._setVertexSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
42386 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$) :
42389 .subscribe(function (_a) {
42390 var tag = _a[0], event = _a[1], camera = _a[2], transform = _a[3];
42391 var basicPoint = _this._mouseEventToBasic(event, _this._container.element, camera, transform);
42392 _this._setVertex2d(tag, basicPoint, transform);
42394 this._addPointSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
42396 rxjs_1.combineLatest(rxjs_1.of(tag), basicClick$) :
42399 .subscribe(function (_a) {
42400 var tag = _a[0], basicPoint = _a[1];
42401 _this._addPoint(tag, basicPoint);
42403 this._geometryCreateSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
42405 tag.created$.pipe(operators_1.map(function (t) {
42410 .subscribe(this._geometryCreated$);
42412 CreateVertexHandler.prototype._disableCreate = function () {
42413 this._container.mouseService.undeferPixels(this._name);
42414 this._tagCreator.delete$.next(null);
42415 this._addPointSubscription.unsubscribe();
42416 this._createSubscription.unsubscribe();
42417 this._deleteSubscription.unsubscribe();
42418 this._geometryCreateSubscription.unsubscribe();
42419 this._setVertexSubscription.unsubscribe();
42421 return CreateVertexHandler;
42422 }(Component_1.CreateHandlerBase));
42423 exports.CreateVertexHandler = CreateVertexHandler;
42424 exports.default = CreateVertexHandler;
42426 },{"../../../Component":291,"rxjs":43,"rxjs/operators":241}],388:[function(require,module,exports){
42428 var __extends = (this && this.__extends) || (function () {
42429 var extendStatics = function (d, b) {
42430 extendStatics = Object.setPrototypeOf ||
42431 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42432 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42433 return extendStatics(d, b);
42435 return function (d, b) {
42436 extendStatics(d, b);
42437 function __() { this.constructor = d; }
42438 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42441 Object.defineProperty(exports, "__esModule", { value: true });
42442 exports.EditVertexHandler = void 0;
42443 var rxjs_1 = require("rxjs");
42444 var operators_1 = require("rxjs/operators");
42445 var Component_1 = require("../../../Component");
42446 var EditVertexHandler = /** @class */ (function (_super) {
42447 __extends(EditVertexHandler, _super);
42448 function EditVertexHandler(component, container, navigator, viewportCoords, tagSet) {
42449 var _this = _super.call(this, component, container, navigator, viewportCoords) || this;
42450 _this._tagSet = tagSet;
42453 EditVertexHandler.prototype._enable = function () {
42455 var interaction$ = this._tagSet.changed$.pipe(operators_1.map(function (tagSet) {
42456 return tagSet.getAll();
42457 }), operators_1.switchMap(function (tags) {
42458 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
42459 return tag.interact$;
42461 }), operators_1.switchMap(function (interaction) {
42462 return rxjs_1.concat(rxjs_1.of(interaction), _this._container.mouseService.documentMouseUp$.pipe(operators_1.map(function () {
42463 return { offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: null };
42464 }), operators_1.first()));
42465 }), operators_1.share());
42466 var mouseMove$ = rxjs_1.merge(this._container.mouseService.mouseMove$, this._container.mouseService.domMouseMove$).pipe(operators_1.share());
42467 this._claimMouseSubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
42468 return !!interaction.tag ? _this._container.mouseService.domMouseDragStart$ : rxjs_1.empty();
42470 .subscribe(function () {
42471 _this._container.mouseService.claimMouse(_this._name, 3);
42473 this._cursorSubscription = interaction$.pipe(operators_1.map(function (interaction) {
42474 return interaction.cursor;
42475 }), operators_1.distinctUntilChanged())
42476 .subscribe(function (cursor) {
42477 var interactionCursors = ["crosshair", "move", "nesw-resize", "nwse-resize"];
42478 for (var _i = 0, interactionCursors_1 = interactionCursors; _i < interactionCursors_1.length; _i++) {
42479 var interactionCursor = interactionCursors_1[_i];
42480 _this._container.element.classList.remove("component-tag-edit-" + interactionCursor);
42483 _this._container.element.classList.add("component-tag-edit-" + cursor);
42486 this._unclaimMouseSubscription = this._container.mouseService
42487 .filtered$(this._name, this._container.mouseService.domMouseDragEnd$)
42488 .subscribe(function (e) {
42489 _this._container.mouseService.unclaimMouse(_this._name);
42491 this._preventDefaultSubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
42492 return !!interaction.tag ?
42493 _this._container.mouseService.documentMouseMove$ :
42496 .subscribe(function (event) {
42497 event.preventDefault(); // prevent selection of content outside the viewer
42499 this._updateGeometrySubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
42500 if (interaction.operation === Component_1.TagOperation.None || !interaction.tag) {
42501 return rxjs_1.empty();
42503 var mouseDrag$ = _this._container.mouseService
42504 .filtered$(_this._name, _this._container.mouseService.domMouseDrag$).pipe(operators_1.filter(function (event) {
42505 return _this._viewportCoords.insideElement(event, _this._container.element);
42507 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) {
42508 var event = _a[0], render = _a[1];
42509 return [event, render, i, transform];
42512 .subscribe(function (_a) {
42513 var mouseEvent = _a[0], renderCamera = _a[1], interaction = _a[2], transform = _a[3];
42514 var basic = _this._mouseEventToBasic(mouseEvent, _this._container.element, renderCamera, transform, interaction.offsetX, interaction.offsetY);
42515 var geometry = interaction.tag.geometry;
42516 if (interaction.operation === Component_1.TagOperation.Centroid) {
42517 geometry.setCentroid2d(basic, transform);
42519 else if (interaction.operation === Component_1.TagOperation.Vertex) {
42520 geometry.setVertex2d(interaction.vertexIndex, basic, transform);
42524 EditVertexHandler.prototype._disable = function () {
42525 this._claimMouseSubscription.unsubscribe();
42526 this._cursorSubscription.unsubscribe();
42527 this._preventDefaultSubscription.unsubscribe();
42528 this._unclaimMouseSubscription.unsubscribe();
42529 this._updateGeometrySubscription.unsubscribe();
42531 EditVertexHandler.prototype._getNameExtension = function () {
42532 return "edit-vertex";
42534 return EditVertexHandler;
42535 }(Component_1.TagHandlerBase));
42536 exports.EditVertexHandler = EditVertexHandler;
42537 exports.default = EditVertexHandler;
42540 },{"../../../Component":291,"rxjs":43,"rxjs/operators":241}],389:[function(require,module,exports){
42542 var __extends = (this && this.__extends) || (function () {
42543 var extendStatics = function (d, b) {
42544 extendStatics = Object.setPrototypeOf ||
42545 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42546 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42547 return extendStatics(d, b);
42549 return function (d, b) {
42550 extendStatics(d, b);
42551 function __() { this.constructor = d; }
42552 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42555 Object.defineProperty(exports, "__esModule", { value: true });
42556 exports.TagHandlerBase = void 0;
42557 var Component_1 = require("../../../Component");
42558 var TagHandlerBase = /** @class */ (function (_super) {
42559 __extends(TagHandlerBase, _super);
42560 function TagHandlerBase(component, container, navigator, viewportCoords) {
42561 var _this = _super.call(this, component, container, navigator) || this;
42562 _this._name = _this._component.name + "-" + _this._getNameExtension();
42563 _this._viewportCoords = viewportCoords;
42566 TagHandlerBase.prototype._getConfiguration = function (enable) {
42569 TagHandlerBase.prototype._mouseEventToBasic = function (event, element, camera, transform, offsetX, offsetY) {
42570 offsetX = offsetX != null ? offsetX : 0;
42571 offsetY = offsetY != null ? offsetY : 0;
42572 var _a = this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
42573 var basic = this._viewportCoords.canvasToBasic(canvasX - offsetX, canvasY - offsetY, element, transform, camera.perspective);
42576 return TagHandlerBase;
42577 }(Component_1.HandlerBase));
42578 exports.TagHandlerBase = TagHandlerBase;
42579 exports.default = TagHandlerBase;
42582 },{"../../../Component":291}],390:[function(require,module,exports){
42584 Object.defineProperty(exports, "__esModule", { value: true });
42586 },{}],391:[function(require,module,exports){
42588 Object.defineProperty(exports, "__esModule", { value: true });
42589 exports.CreateTag = void 0;
42590 var operators_1 = require("rxjs/operators");
42591 var THREE = require("three");
42592 var rxjs_1 = require("rxjs");
42593 var Geo_1 = require("../../../Geo");
42594 var CreateTag = /** @class */ (function () {
42595 function CreateTag(geometry, transform, viewportCoords) {
42597 this._geometry = geometry;
42598 this._transform = transform;
42599 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
42600 this._aborted$ = new rxjs_1.Subject();
42601 this._created$ = new rxjs_1.Subject();
42602 this._glObjectsChanged$ = new rxjs_1.Subject();
42603 this._geometryChangedSubscription = this._geometry.changed$
42604 .subscribe(function () {
42605 _this._onGeometryChanged();
42606 _this._glObjectsChanged$.next(_this);
42609 Object.defineProperty(CreateTag.prototype, "geometry", {
42611 return this._geometry;
42616 Object.defineProperty(CreateTag.prototype, "glObjects", {
42618 return this._glObjects;
42623 Object.defineProperty(CreateTag.prototype, "aborted$", {
42625 return this._aborted$;
42630 Object.defineProperty(CreateTag.prototype, "created$", {
42632 return this._created$;
42637 Object.defineProperty(CreateTag.prototype, "glObjectsChanged$", {
42639 return this._glObjectsChanged$;
42644 Object.defineProperty(CreateTag.prototype, "geometryChanged$", {
42647 return this._geometry.changed$.pipe(operators_1.map(function () {
42654 CreateTag.prototype.dispose = function () {
42655 this._geometryChangedSubscription.unsubscribe();
42657 CreateTag.prototype._canvasToTransform = function (canvas) {
42658 var canvasX = Math.round(canvas[0]);
42659 var canvasY = Math.round(canvas[1]);
42660 var transform = "translate(-50%,-50%) translate(" + canvasX + "px," + canvasY + "px)";
42663 CreateTag.prototype._colorToBackground = function (color) {
42664 return "#" + ("000000" + color.toString(16)).substr(-6);
42666 CreateTag.prototype._createOutine = function (polygon3d, color) {
42667 var positions = this._getLinePositions(polygon3d);
42668 var geometry = new THREE.BufferGeometry();
42669 geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
42670 var material = new THREE.LineBasicMaterial({
42674 return new THREE.Line(geometry, material);
42676 CreateTag.prototype._disposeLine = function (line) {
42677 if (line == null) {
42680 line.geometry.dispose();
42681 line.material.dispose();
42683 CreateTag.prototype._getLinePositions = function (polygon3d) {
42684 var length = polygon3d.length;
42685 var positions = new Float32Array(length * 3);
42686 for (var i = 0; i < length; ++i) {
42688 var position = polygon3d[i];
42689 positions[index] = position[0];
42690 positions[index + 1] = position[1];
42691 positions[index + 2] = position[2];
42697 exports.CreateTag = CreateTag;
42698 exports.default = CreateTag;
42700 },{"../../../Geo":294,"rxjs":43,"rxjs/operators":241,"three":242}],392:[function(require,module,exports){
42702 var __extends = (this && this.__extends) || (function () {
42703 var extendStatics = function (d, b) {
42704 extendStatics = Object.setPrototypeOf ||
42705 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42706 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42707 return extendStatics(d, b);
42709 return function (d, b) {
42710 extendStatics(d, b);
42711 function __() { this.constructor = d; }
42712 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42715 Object.defineProperty(exports, "__esModule", { value: true });
42716 exports.ExtremePointCreateTag = void 0;
42717 var vd = require("virtual-dom");
42718 var Tag_1 = require("../Tag");
42719 var Component_1 = require("../../../Component");
42720 var ExtremePointCreateTag = /** @class */ (function (_super) {
42721 __extends(ExtremePointCreateTag, _super);
42722 function ExtremePointCreateTag(geometry, options, transform, viewportCoords) {
42723 var _this = _super.call(this, geometry, transform, viewportCoords) || this;
42725 color: options.color == null ? 0xFFFFFF : options.color,
42726 indicateCompleter: options.indicateCompleter == null ? true : options.indicateCompleter,
42728 _this._rectGeometry = new Tag_1.RectGeometry(_this._geometry.getRect2d(transform));
42729 _this._createGlObjects();
42732 ExtremePointCreateTag.prototype.create = function () {
42733 if (this._geometry.points.length < 3) {
42736 this._geometry.removePoint2d(this._geometry.points.length - 1);
42737 this._created$.next(this);
42739 ExtremePointCreateTag.prototype.dispose = function () {
42740 _super.prototype.dispose.call(this);
42741 this._disposeObjects();
42743 ExtremePointCreateTag.prototype.getDOMObjects = function (camera, size) {
42746 offsetHeight: size.height, offsetWidth: size.width,
42749 var points2d = this._geometry.getPoints2d();
42750 var length = points2d.length;
42751 var _loop_1 = function (index) {
42752 var nonModifiedIndex = index;
42753 var _a = points2d[index], pointX = _a[0], pointY = _a[1];
42754 var pointCanvas = this_1._viewportCoords.basicToCanvasSafe(pointX, pointY, container, this_1._transform, camera);
42755 if (!pointCanvas) {
42758 var abort = function (e) {
42759 e.stopPropagation();
42760 _this._aborted$.next(_this);
42762 var remove = function (e) {
42763 e.stopPropagation();
42764 _this._geometry.removePoint2d(nonModifiedIndex);
42766 var transform = this_1._canvasToTransform(pointCanvas);
42767 var completerProperties = {
42768 onclick: index === 0 && length < 3 ? abort : remove,
42769 style: { transform: transform },
42771 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
42772 var background = this_1._colorToBackground(this_1._options.color);
42773 var pointProperties = {
42775 background: background,
42776 transform: transform,
42779 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
42782 for (var index = 0; index < length - 1; index++) {
42785 if (length > 2 && this._options.indicateCompleter === true) {
42786 var _a = this._geometry.getCentroid2d(this._transform), centroidX = _a[0], centroidY = _a[1];
42787 var centroidCanvas = this._viewportCoords.basicToCanvasSafe(centroidX, centroidY, container, this._transform, camera);
42788 if (!!centroidCanvas) {
42789 var complete = function (e) {
42790 e.stopPropagation();
42791 _this._geometry.removePoint2d(_this._geometry.points.length - 1);
42792 _this._created$.next(_this);
42794 var transform = this._canvasToTransform(centroidCanvas);
42795 var completerProperties = {
42797 style: { transform: transform },
42799 vNodes.push(vd.h("div.TagCompleter.TagLarger", completerProperties, []));
42800 var pointProperties = {
42802 background: this._colorToBackground(this._options.color),
42803 transform: transform,
42806 vNodes.push(vd.h("div.TagVertex.TagLarger", pointProperties, []));
42807 var dotProperties = {
42809 transform: transform,
42812 vNodes.push(vd.h("div.TagDot", dotProperties, []));
42817 ExtremePointCreateTag.prototype._onGeometryChanged = function () {
42818 this._disposeObjects();
42819 this._rectGeometry = new Tag_1.RectGeometry(this._geometry.getRect2d(this._transform));
42820 this._createGlObjects();
42822 ExtremePointCreateTag.prototype._createGlObjects = function () {
42823 this._glObjects = [];
42824 var polygon3d = this._rectGeometry.getPoints3d(this._transform);
42825 this._outline = this._createOutine(polygon3d, this._options.color);
42826 this._glObjects.push(this._outline);
42828 ExtremePointCreateTag.prototype._disposeObjects = function () {
42829 this._disposeLine(this._outline);
42830 this._outline = null;
42831 this._glObjects = null;
42833 return ExtremePointCreateTag;
42834 }(Component_1.CreateTag));
42835 exports.ExtremePointCreateTag = ExtremePointCreateTag;
42838 },{"../../../Component":291,"../Tag":366,"virtual-dom":247}],393:[function(require,module,exports){
42840 var __extends = (this && this.__extends) || (function () {
42841 var extendStatics = function (d, b) {
42842 extendStatics = Object.setPrototypeOf ||
42843 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42844 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42845 return extendStatics(d, b);
42847 return function (d, b) {
42848 extendStatics(d, b);
42849 function __() { this.constructor = d; }
42850 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42853 Object.defineProperty(exports, "__esModule", { value: true });
42854 exports.ExtremePointRenderTag = void 0;
42855 var THREE = require("three");
42856 var vd = require("virtual-dom");
42857 var Component_1 = require("../../../Component");
42859 * @class OutlineRenderTag
42860 * @classdesc Tag visualizing the properties of an OutlineTag.
42862 var ExtremePointRenderTag = /** @class */ (function (_super) {
42863 __extends(ExtremePointRenderTag, _super);
42864 function ExtremePointRenderTag(tag, transform) {
42865 var _this = _super.call(this, tag, transform) || this;
42866 _this._rectGeometry = new Component_1.RectGeometry(_this._tag.geometry.getRect2d(transform));
42867 _this._fill = !transform.gpano ?
42868 _this._createFill() : null;
42869 _this._outline = _this._tag.lineWidth >= 1 ?
42870 _this._createOutline() :
42874 ExtremePointRenderTag.prototype.dispose = function () {
42875 _super.prototype.dispose.call(this);
42876 this._disposeFill();
42877 this._disposeOutline();
42879 ExtremePointRenderTag.prototype.getDOMObjects = function (atlas, camera, size) {
42882 offsetHeight: size.height, offsetWidth: size.width,
42884 if (!this._tag.editable) {
42887 var lineColor = this._colorToCss(this._tag.lineColor);
42888 var points2d = this._tag.geometry.getPoints2d();
42889 for (var i = 0; i < points2d.length; i++) {
42890 var _a = points2d[i], vertexBasicX = _a[0], vertexBasicY = _a[1];
42891 var vertexCanvas = this._viewportCoords.basicToCanvasSafe(vertexBasicX, vertexBasicY, container, this._transform, camera);
42892 if (vertexCanvas == null) {
42895 var cursor = "crosshair";
42896 var interact = this._interact(Component_1.TagOperation.Vertex, cursor, i);
42897 var vertexCanvasX = Math.round(vertexCanvas[0]);
42898 var vertexCanvasY = Math.round(vertexCanvas[1]);
42899 var transform = "translate(-50%, -50%) translate(" + vertexCanvasX + "px," + vertexCanvasY + "px)";
42901 onmousedown: interact,
42902 style: { background: lineColor, transform: transform, cursor: cursor },
42904 vNodes.push(vd.h("div.TagResizer", properties, []));
42905 if (!this._tag.indicateVertices) {
42908 var pointProperties = {
42909 style: { background: lineColor, transform: transform },
42911 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
42915 ExtremePointRenderTag.prototype.getGLObjects = function () {
42916 var glObjects = [];
42917 if (this._fill != null) {
42918 glObjects.push(this._fill);
42920 if (this._outline != null) {
42921 glObjects.push(this._outline);
42925 ExtremePointRenderTag.prototype.getRetrievableObjects = function () {
42926 return this._fill != null ? [this._fill] : [];
42928 ExtremePointRenderTag.prototype._onGeometryChanged = function () {
42929 this._rectGeometry = new Component_1.RectGeometry(this._tag.geometry.getRect2d(this._transform));
42930 if (this._fill != null) {
42931 this._updateFillGeometry();
42933 if (this._outline != null) {
42934 this._updateOulineGeometry();
42937 ExtremePointRenderTag.prototype._onTagChanged = function () {
42938 var glObjectsChanged = false;
42939 if (this._fill != null) {
42940 this._updateFillMaterial(this._fill.material);
42942 if (this._outline == null) {
42943 if (this._tag.lineWidth >= 1) {
42944 this._outline = this._createOutline();
42945 glObjectsChanged = true;
42949 this._updateOutlineMaterial();
42951 return glObjectsChanged;
42953 ExtremePointRenderTag.prototype._getPoints3d = function () {
42954 return this._rectGeometry.getPoints3d(this._transform);
42956 ExtremePointRenderTag.prototype._getTriangles = function () {
42957 return this._rectGeometry.getTriangles3d(this._transform);
42959 ExtremePointRenderTag.prototype._updateFillMaterial = function (material) {
42960 material.color = new THREE.Color(this._tag.fillColor);
42961 material.opacity = this._tag.fillOpacity;
42962 material.needsUpdate = true;
42964 ExtremePointRenderTag.prototype._updateLineBasicMaterial = function (material) {
42965 material.color = new THREE.Color(this._tag.lineColor);
42966 material.linewidth = Math.max(this._tag.lineWidth, 1);
42967 material.visible = this._tag.lineWidth >= 1 && this._tag.lineOpacity > 0;
42968 material.opacity = this._tag.lineOpacity;
42969 material.transparent = this._tag.lineOpacity < 1;
42970 material.needsUpdate = true;
42972 ExtremePointRenderTag.prototype._updateOutlineMaterial = function () {
42973 var material = this._outline.material;
42974 this._updateLineBasicMaterial(material);
42976 return ExtremePointRenderTag;
42977 }(Component_1.OutlineRenderTagBase));
42978 exports.ExtremePointRenderTag = ExtremePointRenderTag;
42979 exports.default = ExtremePointRenderTag;
42982 },{"../../../Component":291,"three":242,"virtual-dom":247}],394:[function(require,module,exports){
42984 var __extends = (this && this.__extends) || (function () {
42985 var extendStatics = function (d, b) {
42986 extendStatics = Object.setPrototypeOf ||
42987 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42988 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
42989 return extendStatics(d, b);
42991 return function (d, b) {
42992 extendStatics(d, b);
42993 function __() { this.constructor = d; }
42994 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
42997 Object.defineProperty(exports, "__esModule", { value: true });
42998 exports.ExtremePointTag = void 0;
42999 var Component_1 = require("../../../Component");
43001 * @class ExtremePointTag
43003 * @classdesc Tag holding properties for visualizing a extreme points
43004 * and their outline.
43008 * var geometry = new Mapillary.TagComponent.PointsGeometry([[0.3, 0.3], [0.5, 0.4]]);
43009 * var tag = new Mapillary.TagComponent.ExtremePointTag(
43012 * { editable: true, lineColor: 0xff0000 });
43014 * tagComponent.add([tag]);
43017 var ExtremePointTag = /** @class */ (function (_super) {
43018 __extends(ExtremePointTag, _super);
43020 * Create an extreme point tag.
43024 * @param {string} id - Unique identifier of the tag.
43025 * @param {PointsGeometry} geometry - Geometry defining points of tag.
43026 * @param {IExtremePointTagOptions} options - Options defining the visual appearance and
43027 * behavior of the extreme point tag.
43029 function ExtremePointTag(id, geometry, options) {
43030 var _this = _super.call(this, id, geometry) || this;
43031 options = !!options ? options : {};
43032 _this._editable = options.editable == null ? false : options.editable;
43033 _this._fillColor = options.fillColor == null ? 0xFFFFFF : options.fillColor;
43034 _this._fillOpacity = options.fillOpacity == null ? 0.0 : options.fillOpacity;
43035 _this._indicateVertices = options.indicateVertices == null ? true : options.indicateVertices;
43036 _this._lineColor = options.lineColor == null ? 0xFFFFFF : options.lineColor;
43037 _this._lineOpacity = options.lineOpacity == null ? 1 : options.lineOpacity;
43038 _this._lineWidth = options.lineWidth == null ? 1 : options.lineWidth;
43041 Object.defineProperty(ExtremePointTag.prototype, "editable", {
43043 * Get editable property.
43044 * @returns {boolean} Value indicating if tag is editable.
43047 return this._editable;
43050 * Set editable property.
43053 * @fires Tag#changed
43055 set: function (value) {
43056 this._editable = value;
43057 this._notifyChanged$.next(this);
43062 Object.defineProperty(ExtremePointTag.prototype, "fillColor", {
43064 * Get fill color property.
43065 * @returns {number}
43068 return this._fillColor;
43071 * Set fill color property.
43074 * @fires Tag#changed
43076 set: function (value) {
43077 this._fillColor = value;
43078 this._notifyChanged$.next(this);
43083 Object.defineProperty(ExtremePointTag.prototype, "fillOpacity", {
43085 * Get fill opacity property.
43086 * @returns {number}
43089 return this._fillOpacity;
43092 * Set fill opacity property.
43095 * @fires Tag#changed
43097 set: function (value) {
43098 this._fillOpacity = value;
43099 this._notifyChanged$.next(this);
43104 Object.defineProperty(ExtremePointTag.prototype, "geometry", {
43107 return this._geometry;
43112 Object.defineProperty(ExtremePointTag.prototype, "indicateVertices", {
43114 * Get indicate vertices property.
43115 * @returns {boolean} Value indicating if vertices should be indicated
43116 * when tag is editable.
43119 return this._indicateVertices;
43122 * Set indicate vertices property.
43125 * @fires Tag#changed
43127 set: function (value) {
43128 this._indicateVertices = value;
43129 this._notifyChanged$.next(this);
43134 Object.defineProperty(ExtremePointTag.prototype, "lineColor", {
43136 * Get line color property.
43137 * @returns {number}
43140 return this._lineColor;
43143 * Set line color property.
43146 * @fires Tag#changed
43148 set: function (value) {
43149 this._lineColor = value;
43150 this._notifyChanged$.next(this);
43155 Object.defineProperty(ExtremePointTag.prototype, "lineOpacity", {
43157 * Get line opacity property.
43158 * @returns {number}
43161 return this._lineOpacity;
43164 * Set line opacity property.
43167 * @fires Tag#changed
43169 set: function (value) {
43170 this._lineOpacity = value;
43171 this._notifyChanged$.next(this);
43176 Object.defineProperty(ExtremePointTag.prototype, "lineWidth", {
43178 * Get line width property.
43179 * @returns {number}
43182 return this._lineWidth;
43185 * Set line width property.
43188 * @fires Tag#changed
43190 set: function (value) {
43191 this._lineWidth = value;
43192 this._notifyChanged$.next(this);
43198 * Set options for tag.
43200 * @description Sets all the option properties provided and keeps
43201 * the rest of the values as is.
43203 * @param {IExtremePointTagOptions} options - Extreme point tag options
43205 * @fires {Tag#changed}
43207 ExtremePointTag.prototype.setOptions = function (options) {
43208 this._editable = options.editable == null ? this._editable : options.editable;
43209 this._indicateVertices = options.indicateVertices == null ? this._indicateVertices : options.indicateVertices;
43210 this._lineColor = options.lineColor == null ? this._lineColor : options.lineColor;
43211 this._lineWidth = options.lineWidth == null ? this._lineWidth : options.lineWidth;
43212 this._fillColor = options.fillColor == null ? this._fillColor : options.fillColor;
43213 this._fillOpacity = options.fillOpacity == null ? this._fillOpacity : options.fillOpacity;
43214 this._notifyChanged$.next(this);
43216 return ExtremePointTag;
43217 }(Component_1.Tag));
43218 exports.ExtremePointTag = ExtremePointTag;
43219 exports.default = ExtremePointTag;
43221 },{"../../../Component":291}],395:[function(require,module,exports){
43223 var __extends = (this && this.__extends) || (function () {
43224 var extendStatics = function (d, b) {
43225 extendStatics = Object.setPrototypeOf ||
43226 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
43227 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
43228 return extendStatics(d, b);
43230 return function (d, b) {
43231 extendStatics(d, b);
43232 function __() { this.constructor = d; }
43233 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
43236 Object.defineProperty(exports, "__esModule", { value: true });
43237 exports.OutlineCreateTag = void 0;
43238 var vd = require("virtual-dom");
43239 var Component_1 = require("../../../Component");
43240 var OutlineCreateTag = /** @class */ (function (_super) {
43241 __extends(OutlineCreateTag, _super);
43242 function OutlineCreateTag(geometry, options, transform, viewportCoords) {
43243 var _this = _super.call(this, geometry, transform, viewportCoords) || this;
43244 _this._options = { color: options.color == null ? 0xFFFFFF : options.color };
43245 _this._createGlObjects();
43248 OutlineCreateTag.prototype.create = function () {
43249 if (this._geometry instanceof Component_1.RectGeometry) {
43250 this._created$.next(this);
43252 else if (this._geometry instanceof Component_1.PolygonGeometry) {
43253 var polygonGeometry = this._geometry;
43254 polygonGeometry.removeVertex2d(polygonGeometry.polygon.length - 2);
43255 this._created$.next(this);
43258 OutlineCreateTag.prototype.dispose = function () {
43259 _super.prototype.dispose.call(this);
43260 this._disposeLine(this._outline);
43261 this._disposeObjects();
43263 OutlineCreateTag.prototype.getDOMObjects = function (camera, size) {
43267 offsetHeight: size.height, offsetWidth: size.width,
43269 var abort = function (e) {
43270 e.stopPropagation();
43271 _this._aborted$.next(_this);
43273 if (this._geometry instanceof Component_1.RectGeometry) {
43274 var anchorIndex = this._geometry.anchorIndex;
43275 var vertexIndex = anchorIndex === undefined ? 1 : anchorIndex;
43276 var _a = this._geometry.getVertex2d(vertexIndex), basicX = _a[0], basicY = _a[1];
43277 var canvasPoint = this._viewportCoords.basicToCanvasSafe(basicX, basicY, container, this._transform, camera);
43278 if (canvasPoint != null) {
43279 var background = this._colorToBackground(this._options.color);
43280 var transform = this._canvasToTransform(canvasPoint);
43281 var pointProperties = {
43282 style: { background: background, transform: transform },
43284 var completerProperties = {
43286 style: { transform: transform },
43288 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
43289 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
43292 else if (this._geometry instanceof Component_1.PolygonGeometry) {
43293 var polygonGeometry_1 = this._geometry;
43294 var _b = polygonGeometry_1.getVertex2d(0), firstVertexBasicX = _b[0], firstVertexBasicY = _b[1];
43295 var firstVertexCanvas = this._viewportCoords.basicToCanvasSafe(firstVertexBasicX, firstVertexBasicY, container, this._transform, camera);
43296 if (firstVertexCanvas != null) {
43297 var firstOnclick = polygonGeometry_1.polygon.length > 4 ?
43299 e.stopPropagation();
43300 polygonGeometry_1.removeVertex2d(polygonGeometry_1.polygon.length - 2);
43301 _this._created$.next(_this);
43304 var transform = this._canvasToTransform(firstVertexCanvas);
43305 var completerProperties = {
43306 onclick: firstOnclick,
43307 style: { transform: transform },
43309 var firstClass = polygonGeometry_1.polygon.length > 4 ?
43312 vNodes.push(vd.h("div." + firstClass, completerProperties, []));
43314 if (polygonGeometry_1.polygon.length > 3) {
43315 var _c = polygonGeometry_1.getVertex2d(polygonGeometry_1.polygon.length - 3), lastVertexBasicX = _c[0], lastVertexBasicY = _c[1];
43316 var lastVertexCanvas = this._viewportCoords.basicToCanvasSafe(lastVertexBasicX, lastVertexBasicY, container, this._transform, camera);
43317 if (lastVertexCanvas != null) {
43318 var remove = function (e) {
43319 e.stopPropagation();
43320 polygonGeometry_1.removeVertex2d(polygonGeometry_1.polygon.length - 3);
43322 var transform = this._canvasToTransform(lastVertexCanvas);
43323 var completerProperties = {
43325 style: { transform: transform },
43327 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
43330 var verticesBasic = polygonGeometry_1.polygon.slice();
43331 verticesBasic.splice(-2, 2);
43332 for (var _i = 0, verticesBasic_1 = verticesBasic; _i < verticesBasic_1.length; _i++) {
43333 var vertexBasic = verticesBasic_1[_i];
43334 var vertexCanvas = this._viewportCoords.basicToCanvasSafe(vertexBasic[0], vertexBasic[1], container, this._transform, camera);
43335 if (vertexCanvas != null) {
43336 var background = this._colorToBackground(this._options.color);
43337 var transform = this._canvasToTransform(vertexCanvas);
43338 var pointProperties = {
43340 background: background,
43341 transform: transform,
43344 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
43350 OutlineCreateTag.prototype.addPoint = function (point) {
43351 if (this._geometry instanceof Component_1.RectGeometry) {
43352 var rectGeometry = this._geometry;
43353 if (!rectGeometry.validate(point)) {
43356 this._created$.next(this);
43358 else if (this._geometry instanceof Component_1.PolygonGeometry) {
43359 var polygonGeometry = this._geometry;
43360 polygonGeometry.addVertex2d(point);
43363 OutlineCreateTag.prototype._onGeometryChanged = function () {
43364 this._disposeLine(this._outline);
43365 this._disposeObjects();
43366 this._createGlObjects();
43368 OutlineCreateTag.prototype._disposeObjects = function () {
43369 this._outline = null;
43370 this._glObjects = [];
43372 OutlineCreateTag.prototype._createGlObjects = function () {
43373 var polygon3d = this._geometry instanceof Component_1.RectGeometry ?
43374 this._geometry.getPoints3d(this._transform) :
43375 this._geometry.getVertices3d(this._transform);
43376 this._outline = this._createOutine(polygon3d, this._options.color);
43377 this._glObjects = [this._outline];
43379 return OutlineCreateTag;
43380 }(Component_1.CreateTag));
43381 exports.OutlineCreateTag = OutlineCreateTag;
43382 exports.default = OutlineCreateTag;
43385 },{"../../../Component":291,"virtual-dom":247}],396:[function(require,module,exports){
43387 var __extends = (this && this.__extends) || (function () {
43388 var extendStatics = function (d, b) {
43389 extendStatics = Object.setPrototypeOf ||
43390 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
43391 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
43392 return extendStatics(d, b);
43394 return function (d, b) {
43395 extendStatics(d, b);
43396 function __() { this.constructor = d; }
43397 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
43400 Object.defineProperty(exports, "__esModule", { value: true });
43401 exports.OutlineRenderTag = void 0;
43402 var THREE = require("three");
43403 var vd = require("virtual-dom");
43404 var Component_1 = require("../../../Component");
43406 * @class OutlineRenderTag
43407 * @classdesc Tag visualizing the properties of an OutlineTag.
43409 var OutlineRenderTag = /** @class */ (function (_super) {
43410 __extends(OutlineRenderTag, _super);
43411 function OutlineRenderTag(tag, transform) {
43412 var _this = _super.call(this, tag, transform) || this;
43413 _this._fill = !transform.gpano ?
43414 _this._createFill() :
43415 transform.fullPano &&
43416 tag.domain === Component_1.TagDomain.TwoDimensional &&
43417 tag.geometry instanceof Component_1.PolygonGeometry ?
43418 _this._createFill() :
43420 _this._holes = _this._tag.lineWidth >= 1 ?
43421 _this._createHoles() :
43423 _this._outline = _this._tag.lineWidth >= 1 ?
43424 _this._createOutline() :
43428 OutlineRenderTag.prototype.dispose = function () {
43429 _super.prototype.dispose.call(this);
43430 this._disposeFill();
43431 this._disposeHoles();
43432 this._disposeOutline();
43434 OutlineRenderTag.prototype.getDOMObjects = function (atlas, camera, size) {
43437 var isRect = this._tag.geometry instanceof Component_1.RectGeometry;
43438 var isPerspective = !this._transform.gpano;
43440 offsetHeight: size.height, offsetWidth: size.width,
43442 if (this._tag.icon != null && (isRect || isPerspective)) {
43443 var _a = this._tag.geometry instanceof Component_1.RectGeometry ?
43444 this._tag.geometry.getVertex2d(this._tag.iconIndex) :
43445 this._tag.geometry.getPoleOfInaccessibility2d(), iconBasicX = _a[0], iconBasicY = _a[1];
43446 var iconCanvas = this._viewportCoords.basicToCanvasSafe(iconBasicX, iconBasicY, container, this._transform, camera);
43447 if (iconCanvas != null) {
43448 var interact = function () {
43449 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
43451 if (atlas.loaded) {
43452 var sprite = atlas.getDOMSprite(this._tag.icon, this._tag.iconFloat);
43453 var iconCanvasX = Math.round(iconCanvas[0]);
43454 var iconCanvasY = Math.round(iconCanvas[1]);
43455 var transform = "translate(" + iconCanvasX + "px," + iconCanvasY + "px)";
43456 var click = function (e) {
43457 e.stopPropagation();
43458 _this._tag.click$.next(_this._tag);
43462 onmousedown: interact,
43463 style: { transform: transform },
43465 vNodes.push(vd.h("div.TagSymbol", properties, [sprite]));
43469 else if (this._tag.text != null && (isRect || isPerspective)) {
43470 var _b = this._tag.geometry instanceof Component_1.RectGeometry ?
43471 this._tag.geometry.getVertex2d(3) :
43472 this._tag.geometry.getPoleOfInaccessibility2d(), textBasicX = _b[0], textBasicY = _b[1];
43473 var textCanvas = this._viewportCoords.basicToCanvasSafe(textBasicX, textBasicY, container, this._transform, camera);
43474 if (textCanvas != null) {
43475 var textCanvasX = Math.round(textCanvas[0]);
43476 var textCanvasY = Math.round(textCanvas[1]);
43477 var transform = this._tag.geometry instanceof Component_1.RectGeometry ?
43478 "translate(" + textCanvasX + "px," + textCanvasY + "px)" :
43479 "translate(-50%, -50%) translate(" + textCanvasX + "px," + textCanvasY + "px)";
43480 var interact = function () {
43481 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
43484 onmousedown: interact,
43486 color: this._colorToCss(this._tag.textColor),
43487 transform: transform,
43489 textContent: this._tag.text,
43491 vNodes.push(vd.h("span.TagSymbol", properties, []));
43494 if (!this._tag.editable) {
43497 var lineColor = this._colorToCss(this._tag.lineColor);
43498 if (this._tag.geometry instanceof Component_1.RectGeometry) {
43499 var _c = this._tag.geometry.getCentroid2d(), centroidBasicX = _c[0], centroidBasicY = _c[1];
43500 var centroidCanvas = this._viewportCoords.basicToCanvasSafe(centroidBasicX, centroidBasicY, container, this._transform, camera);
43501 if (centroidCanvas != null) {
43502 var interact = this._interact(Component_1.TagOperation.Centroid, "move");
43503 var centroidCanvasX = Math.round(centroidCanvas[0]);
43504 var centroidCanvasY = Math.round(centroidCanvas[1]);
43505 var transform = "translate(-50%, -50%) translate(" + centroidCanvasX + "px," + centroidCanvasY + "px)";
43507 onmousedown: interact,
43508 style: { background: lineColor, transform: transform },
43510 vNodes.push(vd.h("div.TagMover", properties, []));
43513 var vertices2d = this._tag.geometry.getVertices2d();
43514 for (var i = 0; i < vertices2d.length - 1; i++) {
43516 ((this._tag.icon != null && i === this._tag.iconIndex) ||
43517 (this._tag.icon == null && this._tag.text != null && i === 3))) {
43520 var _d = vertices2d[i], vertexBasicX = _d[0], vertexBasicY = _d[1];
43521 var vertexCanvas = this._viewportCoords.basicToCanvasSafe(vertexBasicX, vertexBasicY, container, this._transform, camera);
43522 if (vertexCanvas == null) {
43525 var cursor = isRect ?
43526 i % 2 === 0 ? "nesw-resize" : "nwse-resize" :
43528 var interact = this._interact(Component_1.TagOperation.Vertex, cursor, i);
43529 var vertexCanvasX = Math.round(vertexCanvas[0]);
43530 var vertexCanvasY = Math.round(vertexCanvas[1]);
43531 var transform = "translate(-50%, -50%) translate(" + vertexCanvasX + "px," + vertexCanvasY + "px)";
43533 onmousedown: interact,
43534 style: { background: lineColor, transform: transform, cursor: cursor },
43536 vNodes.push(vd.h("div.TagResizer", properties, []));
43537 if (!this._tag.indicateVertices) {
43540 var pointProperties = {
43541 style: { background: lineColor, transform: transform },
43543 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
43547 OutlineRenderTag.prototype.getGLObjects = function () {
43548 var glObjects = [];
43549 if (this._fill != null) {
43550 glObjects.push(this._fill);
43552 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
43554 glObjects.push(hole);
43556 if (this._outline != null) {
43557 glObjects.push(this._outline);
43561 OutlineRenderTag.prototype.getRetrievableObjects = function () {
43562 return this._fill != null ? [this._fill] : [];
43564 OutlineRenderTag.prototype._onGeometryChanged = function () {
43565 if (this._fill != null) {
43566 this._updateFillGeometry();
43568 if (this._holes.length > 0) {
43569 this._updateHoleGeometries();
43571 if (this._outline != null) {
43572 this._updateOulineGeometry();
43575 OutlineRenderTag.prototype._onTagChanged = function () {
43576 var glObjectsChanged = false;
43577 if (this._fill != null) {
43578 this._updateFillMaterial(this._fill.material);
43580 if (this._outline == null) {
43581 if (this._tag.lineWidth >= 1) {
43582 this._holes = this._createHoles();
43583 this._outline = this._createOutline();
43584 glObjectsChanged = true;
43588 this._updateHoleMaterials();
43589 this._updateOutlineMaterial();
43591 return glObjectsChanged;
43593 OutlineRenderTag.prototype._getPoints3d = function () {
43594 return this._in3dDomain() ?
43595 this._tag.geometry.getVertices3d(this._transform) :
43596 this._tag.geometry.getPoints3d(this._transform);
43598 OutlineRenderTag.prototype._getTriangles = function () {
43599 return this._in3dDomain() ?
43600 this._tag.geometry.get3dDomainTriangles3d(this._transform) :
43601 this._tag.geometry.getTriangles3d(this._transform);
43603 OutlineRenderTag.prototype._updateFillMaterial = function (material) {
43604 material.color = new THREE.Color(this._tag.fillColor);
43605 material.opacity = this._tag.fillOpacity;
43606 material.needsUpdate = true;
43608 OutlineRenderTag.prototype._updateLineBasicMaterial = function (material) {
43609 material.color = new THREE.Color(this._tag.lineColor);
43610 material.linewidth = Math.max(this._tag.lineWidth, 1);
43611 material.visible = this._tag.lineWidth >= 1 && this._tag.lineOpacity > 0;
43612 material.opacity = this._tag.lineOpacity;
43613 material.transparent = this._tag.lineOpacity < 1;
43614 material.needsUpdate = true;
43616 OutlineRenderTag.prototype._createHoles = function () {
43618 if (this._tag.geometry instanceof Component_1.PolygonGeometry) {
43619 var holes3d = this._getHoles3d();
43620 for (var _i = 0, holes3d_1 = holes3d; _i < holes3d_1.length; _i++) {
43621 var holePoints3d = holes3d_1[_i];
43622 var hole = this._createLine(holePoints3d);
43628 OutlineRenderTag.prototype._disposeHoles = function () {
43629 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
43631 hole.geometry.dispose();
43632 hole.material.dispose();
43636 OutlineRenderTag.prototype._getHoles3d = function () {
43637 var polygonGeometry = this._tag.geometry;
43638 return this._in3dDomain() ?
43639 polygonGeometry.getHoleVertices3d(this._transform) :
43640 polygonGeometry.getHolePoints3d(this._transform);
43642 OutlineRenderTag.prototype._in3dDomain = function () {
43643 return this._tag.geometry instanceof Component_1.PolygonGeometry && this._tag.domain === Component_1.TagDomain.ThreeDimensional;
43645 OutlineRenderTag.prototype._updateHoleGeometries = function () {
43646 var holes3d = this._getHoles3d();
43647 if (holes3d.length !== this._holes.length) {
43648 throw new Error("Changing the number of holes is not supported.");
43650 for (var i = 0; i < this._holes.length; i++) {
43651 var holePoints3d = holes3d[i];
43652 var hole = this._holes[i];
43653 this._updateLine(hole, holePoints3d);
43656 OutlineRenderTag.prototype._updateHoleMaterials = function () {
43657 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
43659 this._updateLineBasicMaterial(hole.material);
43662 OutlineRenderTag.prototype._updateOutlineMaterial = function () {
43663 this._updateLineBasicMaterial(this._outline.material);
43665 return OutlineRenderTag;
43666 }(Component_1.OutlineRenderTagBase));
43667 exports.OutlineRenderTag = OutlineRenderTag;
43670 },{"../../../Component":291,"three":242,"virtual-dom":247}],397:[function(require,module,exports){
43672 var __extends = (this && this.__extends) || (function () {
43673 var extendStatics = function (d, b) {
43674 extendStatics = Object.setPrototypeOf ||
43675 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
43676 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
43677 return extendStatics(d, b);
43679 return function (d, b) {
43680 extendStatics(d, b);
43681 function __() { this.constructor = d; }
43682 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
43685 Object.defineProperty(exports, "__esModule", { value: true });
43686 exports.OutlineRenderTagBase = void 0;
43687 var THREE = require("three");
43688 var Component_1 = require("../../../Component");
43689 var OutlineRenderTagBase = /** @class */ (function (_super) {
43690 __extends(OutlineRenderTagBase, _super);
43691 function OutlineRenderTagBase(tag, transform) {
43692 var _this = _super.call(this, tag, transform) || this;
43693 _this._geometryChangedSubscription = _this._tag.geometry.changed$
43694 .subscribe(function () {
43695 _this._onGeometryChanged();
43697 _this._changedSubscription = _this._tag.changed$
43698 .subscribe(function () {
43699 var glObjectsChanged = _this._onTagChanged();
43700 if (glObjectsChanged) {
43701 _this._glObjectsChanged$.next(_this);
43706 OutlineRenderTagBase.prototype.dispose = function () {
43707 this._changedSubscription.unsubscribe();
43708 this._geometryChangedSubscription.unsubscribe();
43710 OutlineRenderTagBase.prototype._colorToCss = function (color) {
43711 return "#" + ("000000" + color.toString(16)).substr(-6);
43713 OutlineRenderTagBase.prototype._createFill = function () {
43714 var triangles = this._getTriangles();
43715 var positions = new Float32Array(triangles);
43716 var geometry = new THREE.BufferGeometry();
43717 geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
43718 geometry.computeBoundingSphere();
43719 var material = new THREE.MeshBasicMaterial({ side: THREE.DoubleSide, transparent: true });
43720 this._updateFillMaterial(material);
43721 return new THREE.Mesh(geometry, material);
43723 OutlineRenderTagBase.prototype._createLine = function (points3d) {
43724 var positions = this._getLinePositions(points3d);
43725 var geometry = new THREE.BufferGeometry();
43726 geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
43727 geometry.computeBoundingSphere();
43728 var material = new THREE.LineBasicMaterial();
43729 this._updateLineBasicMaterial(material);
43730 var line = new THREE.Line(geometry, material);
43731 line.renderOrder = 1;
43734 OutlineRenderTagBase.prototype._createOutline = function () {
43735 return this._createLine(this._getPoints3d());
43737 OutlineRenderTagBase.prototype._disposeFill = function () {
43738 if (this._fill == null) {
43741 this._fill.geometry.dispose();
43742 this._fill.material.dispose();
43745 OutlineRenderTagBase.prototype._disposeOutline = function () {
43746 if (this._outline == null) {
43749 this._outline.geometry.dispose();
43750 this._outline.material.dispose();
43751 this._outline = null;
43753 OutlineRenderTagBase.prototype._getLinePositions = function (points3d) {
43754 var length = points3d.length;
43755 var positions = new Float32Array(length * 3);
43756 for (var i = 0; i < length; ++i) {
43758 var position = points3d[i];
43759 positions[index + 0] = position[0];
43760 positions[index + 1] = position[1];
43761 positions[index + 2] = position[2];
43765 OutlineRenderTagBase.prototype._interact = function (operation, cursor, vertexIndex) {
43767 return function (e) {
43768 var offsetX = e.offsetX - e.target.offsetWidth / 2;
43769 var offsetY = e.offsetY - e.target.offsetHeight / 2;
43770 _this._interact$.next({
43774 operation: operation,
43776 vertexIndex: vertexIndex,
43780 OutlineRenderTagBase.prototype._updateFillGeometry = function () {
43781 var triangles = this._getTriangles();
43782 var positions = new Float32Array(triangles);
43783 var geometry = this._fill.geometry;
43784 var attribute = geometry.getAttribute("position");
43785 if (attribute.array.length === positions.length) {
43786 attribute.set(positions);
43787 attribute.needsUpdate = true;
43790 geometry.removeAttribute("position");
43791 geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
43793 geometry.computeBoundingSphere();
43795 OutlineRenderTagBase.prototype._updateLine = function (line, points3d) {
43796 var positions = this._getLinePositions(points3d);
43797 var geometry = line.geometry;
43798 var attribute = geometry.getAttribute("position");
43799 attribute.set(positions);
43800 attribute.needsUpdate = true;
43801 geometry.computeBoundingSphere();
43803 OutlineRenderTagBase.prototype._updateOulineGeometry = function () {
43804 this._updateLine(this._outline, this._getPoints3d());
43806 return OutlineRenderTagBase;
43807 }(Component_1.RenderTag));
43808 exports.OutlineRenderTagBase = OutlineRenderTagBase;
43809 exports.default = OutlineRenderTagBase;
43812 },{"../../../Component":291,"three":242}],398:[function(require,module,exports){
43814 var __extends = (this && this.__extends) || (function () {
43815 var extendStatics = function (d, b) {
43816 extendStatics = Object.setPrototypeOf ||
43817 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
43818 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
43819 return extendStatics(d, b);
43821 return function (d, b) {
43822 extendStatics(d, b);
43823 function __() { this.constructor = d; }
43824 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
43827 Object.defineProperty(exports, "__esModule", { value: true });
43828 exports.OutlineTag = void 0;
43829 var rxjs_1 = require("rxjs");
43830 var Component_1 = require("../../../Component");
43831 var Viewer_1 = require("../../../Viewer");
43833 * @class OutlineTag
43835 * @classdesc Tag holding properties for visualizing a geometry outline.
43839 * var geometry = new Mapillary.TagComponent.RectGeometry([0.3, 0.3, 0.5, 0.4]);
43840 * var tag = new Mapillary.TagComponent.OutlineTag(
43843 * { editable: true, lineColor: 0xff0000 });
43845 * tagComponent.add([tag]);
43848 var OutlineTag = /** @class */ (function (_super) {
43849 __extends(OutlineTag, _super);
43851 * Create an outline tag.
43855 * @param {string} id - Unique identifier of the tag.
43856 * @param {VertexGeometry} geometry - Geometry defining vertices of tag.
43857 * @param {IOutlineTagOptions} options - Options defining the visual appearance and
43858 * behavior of the outline tag.
43860 function OutlineTag(id, geometry, options) {
43861 var _this = _super.call(this, id, geometry) || this;
43862 options = !!options ? options : {};
43863 var domain = options.domain != null && geometry instanceof Component_1.PolygonGeometry ?
43864 options.domain : Component_1.TagDomain.TwoDimensional;
43865 var twoDimensionalPolygon = _this._twoDimensionalPolygon(domain, geometry);
43866 _this._domain = domain;
43867 _this._editable = options.editable == null || twoDimensionalPolygon ? false : options.editable;
43868 _this._fillColor = options.fillColor == null ? 0xFFFFFF : options.fillColor;
43869 _this._fillOpacity = options.fillOpacity == null ? 0.0 : options.fillOpacity;
43870 _this._icon = options.icon === undefined ? null : options.icon;
43871 _this._iconFloat = options.iconFloat == null ? Viewer_1.Alignment.Center : options.iconFloat;
43872 _this._iconIndex = options.iconIndex == null ? 3 : options.iconIndex;
43873 _this._indicateVertices = options.indicateVertices == null ? true : options.indicateVertices;
43874 _this._lineColor = options.lineColor == null ? 0xFFFFFF : options.lineColor;
43875 _this._lineOpacity = options.lineOpacity == null ? 1 : options.lineOpacity;
43876 _this._lineWidth = options.lineWidth == null ? 1 : options.lineWidth;
43877 _this._text = options.text === undefined ? null : options.text;
43878 _this._textColor = options.textColor == null ? 0xFFFFFF : options.textColor;
43879 _this._click$ = new rxjs_1.Subject();
43881 .subscribe(function (t) {
43882 _this.fire(OutlineTag.click, _this);
43886 Object.defineProperty(OutlineTag.prototype, "click$", {
43888 * Click observable.
43890 * @description An observable emitting the tag when the icon of the
43891 * tag has been clicked.
43893 * @returns {Observable<Tag>}
43896 return this._click$;
43901 Object.defineProperty(OutlineTag.prototype, "domain", {
43903 * Get domain property.
43905 * @description Readonly property that can only be set in constructor.
43907 * @returns Value indicating the domain of the tag.
43910 return this._domain;
43915 Object.defineProperty(OutlineTag.prototype, "editable", {
43917 * Get editable property.
43918 * @returns {boolean} Value indicating if tag is editable.
43921 return this._editable;
43924 * Set editable property.
43927 * @fires Tag#changed
43929 set: function (value) {
43930 if (this._twoDimensionalPolygon(this._domain, this._geometry)) {
43933 this._editable = value;
43934 this._notifyChanged$.next(this);
43939 Object.defineProperty(OutlineTag.prototype, "fillColor", {
43941 * Get fill color property.
43942 * @returns {number}
43945 return this._fillColor;
43948 * Set fill color property.
43951 * @fires Tag#changed
43953 set: function (value) {
43954 this._fillColor = value;
43955 this._notifyChanged$.next(this);
43960 Object.defineProperty(OutlineTag.prototype, "fillOpacity", {
43962 * Get fill opacity property.
43963 * @returns {number}
43966 return this._fillOpacity;
43969 * Set fill opacity property.
43972 * @fires Tag#changed
43974 set: function (value) {
43975 this._fillOpacity = value;
43976 this._notifyChanged$.next(this);
43981 Object.defineProperty(OutlineTag.prototype, "geometry", {
43984 return this._geometry;
43989 Object.defineProperty(OutlineTag.prototype, "icon", {
43991 * Get icon property.
43992 * @returns {string}
43998 * Set icon property.
44001 * @fires Tag#changed
44003 set: function (value) {
44004 this._icon = value;
44005 this._notifyChanged$.next(this);
44010 Object.defineProperty(OutlineTag.prototype, "iconFloat", {
44012 * Get icon float property.
44013 * @returns {Alignment}
44016 return this._iconFloat;
44019 * Set icon float property.
44020 * @param {Alignment}
44022 * @fires Tag#changed
44024 set: function (value) {
44025 this._iconFloat = value;
44026 this._notifyChanged$.next(this);
44031 Object.defineProperty(OutlineTag.prototype, "iconIndex", {
44033 * Get icon index property.
44034 * @returns {number}
44037 return this._iconIndex;
44040 * Set icon index property.
44043 * @fires Tag#changed
44045 set: function (value) {
44046 this._iconIndex = value;
44047 this._notifyChanged$.next(this);
44052 Object.defineProperty(OutlineTag.prototype, "indicateVertices", {
44054 * Get indicate vertices property.
44055 * @returns {boolean} Value indicating if vertices should be indicated
44056 * when tag is editable.
44059 return this._indicateVertices;
44062 * Set indicate vertices property.
44065 * @fires Tag#changed
44067 set: function (value) {
44068 this._indicateVertices = value;
44069 this._notifyChanged$.next(this);
44074 Object.defineProperty(OutlineTag.prototype, "lineColor", {
44076 * Get line color property.
44077 * @returns {number}
44080 return this._lineColor;
44083 * Set line color property.
44086 * @fires Tag#changed
44088 set: function (value) {
44089 this._lineColor = value;
44090 this._notifyChanged$.next(this);
44095 Object.defineProperty(OutlineTag.prototype, "lineOpacity", {
44097 * Get line opacity property.
44098 * @returns {number}
44101 return this._lineOpacity;
44104 * Set line opacity property.
44107 * @fires Tag#changed
44109 set: function (value) {
44110 this._lineOpacity = value;
44111 this._notifyChanged$.next(this);
44116 Object.defineProperty(OutlineTag.prototype, "lineWidth", {
44118 * Get line width property.
44119 * @returns {number}
44122 return this._lineWidth;
44125 * Set line width property.
44128 * @fires Tag#changed
44130 set: function (value) {
44131 this._lineWidth = value;
44132 this._notifyChanged$.next(this);
44137 Object.defineProperty(OutlineTag.prototype, "text", {
44139 * Get text property.
44140 * @returns {string}
44146 * Set text property.
44149 * @fires Tag#changed
44151 set: function (value) {
44152 this._text = value;
44153 this._notifyChanged$.next(this);
44158 Object.defineProperty(OutlineTag.prototype, "textColor", {
44160 * Get text color property.
44161 * @returns {number}
44164 return this._textColor;
44167 * Set text color property.
44170 * @fires Tag#changed
44172 set: function (value) {
44173 this._textColor = value;
44174 this._notifyChanged$.next(this);
44180 * Set options for tag.
44182 * @description Sets all the option properties provided and keeps
44183 * the rest of the values as is.
44185 * @param {IOutlineTagOptions} options - Outline tag options
44187 * @fires {Tag#changed}
44189 OutlineTag.prototype.setOptions = function (options) {
44190 var twoDimensionalPolygon = this._twoDimensionalPolygon(this._domain, this._geometry);
44191 this._editable = twoDimensionalPolygon || options.editable == null ? this._editable : options.editable;
44192 this._icon = options.icon === undefined ? this._icon : options.icon;
44193 this._iconFloat = options.iconFloat == null ? this._iconFloat : options.iconFloat;
44194 this._iconIndex = options.iconIndex == null ? this._iconIndex : options.iconIndex;
44195 this._indicateVertices = options.indicateVertices == null ? this._indicateVertices : options.indicateVertices;
44196 this._lineColor = options.lineColor == null ? this._lineColor : options.lineColor;
44197 this._lineWidth = options.lineWidth == null ? this._lineWidth : options.lineWidth;
44198 this._fillColor = options.fillColor == null ? this._fillColor : options.fillColor;
44199 this._fillOpacity = options.fillOpacity == null ? this._fillOpacity : options.fillOpacity;
44200 this._text = options.text === undefined ? this._text : options.text;
44201 this._textColor = options.textColor == null ? this._textColor : options.textColor;
44202 this._notifyChanged$.next(this);
44204 OutlineTag.prototype._twoDimensionalPolygon = function (domain, geometry) {
44205 return domain !== Component_1.TagDomain.ThreeDimensional && geometry instanceof Component_1.PolygonGeometry;
44208 * Event fired when the icon of the outline tag is clicked.
44210 * @event OutlineTag#click
44211 * @type {OutlineTag} The tag instance that was clicked.
44213 OutlineTag.click = "click";
44215 }(Component_1.Tag));
44216 exports.OutlineTag = OutlineTag;
44217 exports.default = OutlineTag;
44219 },{"../../../Component":291,"../../../Viewer":302,"rxjs":43}],399:[function(require,module,exports){
44221 Object.defineProperty(exports, "__esModule", { value: true });
44222 exports.RenderTag = void 0;
44223 var rxjs_1 = require("rxjs");
44224 var Geo_1 = require("../../../Geo");
44225 var RenderTag = /** @class */ (function () {
44226 function RenderTag(tag, transform, viewportCoords) {
44228 this._transform = transform;
44229 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
44230 this._glObjectsChanged$ = new rxjs_1.Subject();
44231 this._interact$ = new rxjs_1.Subject();
44233 Object.defineProperty(RenderTag.prototype, "glObjectsChanged$", {
44235 return this._glObjectsChanged$;
44240 Object.defineProperty(RenderTag.prototype, "interact$", {
44242 return this._interact$;
44247 Object.defineProperty(RenderTag.prototype, "tag", {
44256 exports.RenderTag = RenderTag;
44257 exports.default = RenderTag;
44259 },{"../../../Geo":294,"rxjs":43}],400:[function(require,module,exports){
44261 var __extends = (this && this.__extends) || (function () {
44262 var extendStatics = function (d, b) {
44263 extendStatics = Object.setPrototypeOf ||
44264 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
44265 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
44266 return extendStatics(d, b);
44268 return function (d, b) {
44269 extendStatics(d, b);
44270 function __() { this.constructor = d; }
44271 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44274 Object.defineProperty(exports, "__esModule", { value: true });
44275 exports.SpotRenderTag = void 0;
44276 var vd = require("virtual-dom");
44277 var Component_1 = require("../../../Component");
44278 var Viewer_1 = require("../../../Viewer");
44280 * @class SpotRenderTag
44281 * @classdesc Tag visualizing the properties of a SpotTag.
44283 var SpotRenderTag = /** @class */ (function (_super) {
44284 __extends(SpotRenderTag, _super);
44285 function SpotRenderTag() {
44286 return _super !== null && _super.apply(this, arguments) || this;
44288 SpotRenderTag.prototype.dispose = function () { };
44289 SpotRenderTag.prototype.getDOMObjects = function (atlas, camera, size) {
44291 var tag = this._tag;
44293 offsetHeight: size.height, offsetWidth: size.width,
44296 var _a = tag.geometry.getCentroid2d(), centroidBasicX = _a[0], centroidBasicY = _a[1];
44297 var centroidCanvas = this._viewportCoords.basicToCanvasSafe(centroidBasicX, centroidBasicY, container, this._transform, camera);
44298 if (centroidCanvas != null) {
44299 var interactNone = function (e) {
44300 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: tag });
44302 var canvasX = Math.round(centroidCanvas[0]);
44303 var canvasY = Math.round(centroidCanvas[1]);
44304 if (tag.icon != null) {
44305 if (atlas.loaded) {
44306 var sprite = atlas.getDOMSprite(tag.icon, Viewer_1.Alignment.Bottom);
44307 var iconTransform = "translate(" + canvasX + "px," + (canvasY + 8) + "px)";
44309 onmousedown: interactNone,
44311 pointerEvents: "all",
44312 transform: iconTransform,
44315 vNodes.push(vd.h("div", properties, [sprite]));
44318 else if (tag.text != null) {
44319 var textTransform = "translate(-50%,0%) translate(" + canvasX + "px," + (canvasY + 8) + "px)";
44321 onmousedown: interactNone,
44323 color: this._colorToCss(tag.textColor),
44324 transform: textTransform,
44326 textContent: tag.text,
44328 vNodes.push(vd.h("span.TagSymbol", properties, []));
44330 var interact = this._interact(Component_1.TagOperation.Centroid, tag, "move");
44331 var background = this._colorToCss(tag.color);
44332 var transform = "translate(-50%,-50%) translate(" + canvasX + "px," + canvasY + "px)";
44333 if (tag.editable) {
44334 var interactorProperties = {
44335 onmousedown: interact,
44337 background: background,
44338 transform: transform,
44341 vNodes.push(vd.h("div.TagSpotInteractor", interactorProperties, []));
44343 var pointProperties = {
44345 background: background,
44346 transform: transform,
44349 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
44353 SpotRenderTag.prototype.getGLObjects = function () { return []; };
44354 SpotRenderTag.prototype.getRetrievableObjects = function () { return []; };
44355 SpotRenderTag.prototype._colorToCss = function (color) {
44356 return "#" + ("000000" + color.toString(16)).substr(-6);
44358 SpotRenderTag.prototype._interact = function (operation, tag, cursor, vertexIndex) {
44360 return function (e) {
44361 var offsetX = e.offsetX - e.target.offsetWidth / 2;
44362 var offsetY = e.offsetY - e.target.offsetHeight / 2;
44363 _this._interact$.next({
44367 operation: operation,
44369 vertexIndex: vertexIndex,
44373 return SpotRenderTag;
44374 }(Component_1.RenderTag));
44375 exports.SpotRenderTag = SpotRenderTag;
44378 },{"../../../Component":291,"../../../Viewer":302,"virtual-dom":247}],401:[function(require,module,exports){
44380 var __extends = (this && this.__extends) || (function () {
44381 var extendStatics = function (d, b) {
44382 extendStatics = Object.setPrototypeOf ||
44383 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
44384 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
44385 return extendStatics(d, b);
44387 return function (d, b) {
44388 extendStatics(d, b);
44389 function __() { this.constructor = d; }
44390 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44393 Object.defineProperty(exports, "__esModule", { value: true });
44394 exports.SpotTag = void 0;
44395 var Component_1 = require("../../../Component");
44399 * @classdesc Tag holding properties for visualizing the centroid of a geometry.
44403 * var geometry = new Mapillary.TagComponent.PointGeometry([0.3, 0.3]);
44404 * var tag = new Mapillary.TagComponent.SpotTag(
44407 * { editable: true, color: 0xff0000 });
44409 * tagComponent.add([tag]);
44412 var SpotTag = /** @class */ (function (_super) {
44413 __extends(SpotTag, _super);
44415 * Create a spot tag.
44419 * @param {string} id
44420 * @param {Geometry} geometry
44421 * @param {IOutlineTagOptions} options - Options defining the visual appearance and
44422 * behavior of the spot tag.
44424 function SpotTag(id, geometry, options) {
44425 var _this = _super.call(this, id, geometry) || this;
44426 options = !!options ? options : {};
44427 _this._color = options.color == null ? 0xFFFFFF : options.color;
44428 _this._editable = options.editable == null ? false : options.editable;
44429 _this._icon = options.icon === undefined ? null : options.icon;
44430 _this._text = options.text === undefined ? null : options.text;
44431 _this._textColor = options.textColor == null ? 0xFFFFFF : options.textColor;
44434 Object.defineProperty(SpotTag.prototype, "color", {
44436 * Get color property.
44437 * @returns {number} The color of the spot as a hexagonal number;
44440 return this._color;
44443 * Set color property.
44446 * @fires Tag#changed
44448 set: function (value) {
44449 this._color = value;
44450 this._notifyChanged$.next(this);
44455 Object.defineProperty(SpotTag.prototype, "editable", {
44457 * Get editable property.
44458 * @returns {boolean} Value indicating if tag is editable.
44461 return this._editable;
44464 * Set editable property.
44467 * @fires Tag#changed
44469 set: function (value) {
44470 this._editable = value;
44471 this._notifyChanged$.next(this);
44476 Object.defineProperty(SpotTag.prototype, "icon", {
44478 * Get icon property.
44479 * @returns {string}
44485 * Set icon property.
44488 * @fires Tag#changed
44490 set: function (value) {
44491 this._icon = value;
44492 this._notifyChanged$.next(this);
44497 Object.defineProperty(SpotTag.prototype, "text", {
44499 * Get text property.
44500 * @returns {string}
44506 * Set text property.
44509 * @fires Tag#changed
44511 set: function (value) {
44512 this._text = value;
44513 this._notifyChanged$.next(this);
44518 Object.defineProperty(SpotTag.prototype, "textColor", {
44520 * Get text color property.
44521 * @returns {number}
44524 return this._textColor;
44527 * Set text color property.
44530 * @fires Tag#changed
44532 set: function (value) {
44533 this._textColor = value;
44534 this._notifyChanged$.next(this);
44540 * Set options for tag.
44542 * @description Sets all the option properties provided and keps
44543 * the rest of the values as is.
44545 * @param {ISpotTagOptions} options - Spot tag options
44547 * @fires {Tag#changed}
44549 SpotTag.prototype.setOptions = function (options) {
44550 this._color = options.color == null ? this._color : options.color;
44551 this._editable = options.editable == null ? this._editable : options.editable;
44552 this._icon = options.icon === undefined ? this._icon : options.icon;
44553 this._text = options.text === undefined ? this._text : options.text;
44554 this._textColor = options.textColor == null ? this._textColor : options.textColor;
44555 this._notifyChanged$.next(this);
44558 }(Component_1.Tag));
44559 exports.SpotTag = SpotTag;
44560 exports.default = SpotTag;
44562 },{"../../../Component":291}],402:[function(require,module,exports){
44564 var __extends = (this && this.__extends) || (function () {
44565 var extendStatics = function (d, b) {
44566 extendStatics = Object.setPrototypeOf ||
44567 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
44568 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
44569 return extendStatics(d, b);
44571 return function (d, b) {
44572 extendStatics(d, b);
44573 function __() { this.constructor = d; }
44574 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44577 Object.defineProperty(exports, "__esModule", { value: true });
44578 exports.Tag = void 0;
44579 var operators_1 = require("rxjs/operators");
44580 var rxjs_1 = require("rxjs");
44581 var Utils_1 = require("../../../Utils");
44585 * @classdesc Abstract class representing the basic functionality of for a tag.
44587 var Tag = /** @class */ (function (_super) {
44588 __extends(Tag, _super);
44593 * @param {string} id
44594 * @param {Geometry} geometry
44596 function Tag(id, geometry) {
44597 var _this = _super.call(this) || this;
44599 _this._geometry = geometry;
44600 _this._notifyChanged$ = new rxjs_1.Subject();
44601 _this._notifyChanged$
44602 .subscribe(function (t) {
44603 _this.fire(Tag.changed, _this);
44605 _this._geometry.changed$
44606 .subscribe(function (g) {
44607 _this.fire(Tag.geometrychanged, _this);
44611 Object.defineProperty(Tag.prototype, "id", {
44614 * @returns {string}
44622 Object.defineProperty(Tag.prototype, "geometry", {
44624 * Get geometry property.
44625 * @returns {Geometry} The geometry of the tag.
44628 return this._geometry;
44633 Object.defineProperty(Tag.prototype, "changed$", {
44635 * Get changed observable.
44636 * @returns {Observable<Tag>}
44640 return this._notifyChanged$;
44645 Object.defineProperty(Tag.prototype, "geometryChanged$", {
44647 * Get geometry changed observable.
44648 * @returns {Observable<Tag>}
44653 return this._geometry.changed$.pipe(operators_1.map(function (geometry) {
44655 }), operators_1.share());
44661 * Event fired when a property related to the visual appearance of the
44664 * @event Tag#changed
44665 * @type {Tag} The tag instance that has changed.
44667 Tag.changed = "changed";
44669 * Event fired when the geometry of the tag has changed.
44671 * @event Tag#geometrychanged
44672 * @type {Tag} The tag instance whose geometry has changed.
44674 Tag.geometrychanged = "geometrychanged";
44676 }(Utils_1.EventEmitter));
44678 exports.default = Tag;
44680 },{"../../../Utils":301,"rxjs":43,"rxjs/operators":241}],403:[function(require,module,exports){
44682 Object.defineProperty(exports, "__esModule", { value: true });
44683 exports.TagDomain = void 0;
44685 * Enumeration for tag domains.
44688 * @description Defines where lines between two vertices are treated
44691 * Only applicable for polygons. For rectangles lines between
44692 * vertices are always treated as straight in the distorted 2D
44693 * projection and bended in the undistorted 3D space.
44696 (function (TagDomain) {
44698 * Treats lines between two vertices as straight in the
44699 * distorted 2D projection, i.e. on the image. If the image
44700 * is distorted this will result in bended lines when rendered
44701 * in the undistorted 3D space.
44703 TagDomain[TagDomain["TwoDimensional"] = 0] = "TwoDimensional";
44705 * Treats lines as straight in the undistorted 3D space. If the
44706 * image is distorted this will result in bended lines when rendered
44707 * on the distorted 2D projection of the image.
44709 TagDomain[TagDomain["ThreeDimensional"] = 1] = "ThreeDimensional";
44710 })(TagDomain = exports.TagDomain || (exports.TagDomain = {}));
44711 exports.default = TagDomain;
44713 },{}],404:[function(require,module,exports){
44715 Object.defineProperty(exports, "__esModule", { value: true });
44716 exports.ComponentSize = void 0;
44718 * Enumeration for component size.
44721 * @description May be used by a component to allow for resizing
44722 * of the UI elements rendered by the component.
44725 (function (ComponentSize) {
44727 * Automatic size. The size of the elements will automatically
44728 * change at a predefined threshold.
44730 ComponentSize[ComponentSize["Automatic"] = 0] = "Automatic";
44732 * Large size. The size of the elements will be fixed until another
44733 * component size is configured.
44735 ComponentSize[ComponentSize["Large"] = 1] = "Large";
44737 * Small size. The size of the elements will be fixed until another
44738 * component size is configured.
44740 ComponentSize[ComponentSize["Small"] = 2] = "Small";
44741 })(ComponentSize = exports.ComponentSize || (exports.ComponentSize = {}));
44742 exports.default = ComponentSize;
44744 },{}],405:[function(require,module,exports){
44746 Object.defineProperty(exports, "__esModule", { value: true });
44747 exports.HandlerBase = void 0;
44748 var HandlerBase = /** @class */ (function () {
44750 function HandlerBase(component, container, navigator) {
44751 this._component = component;
44752 this._container = container;
44753 this._navigator = navigator;
44754 this._enabled = false;
44756 Object.defineProperty(HandlerBase.prototype, "isEnabled", {
44758 * Returns a Boolean indicating whether the interaction is enabled.
44760 * @returns {boolean} `true` if the interaction is enabled.
44763 return this._enabled;
44769 * Enables the interaction.
44771 * @example ```<component-name>.<handler-name>.enable();```
44773 HandlerBase.prototype.enable = function () {
44774 if (this._enabled || !this._component.activated) {
44778 this._enabled = true;
44779 this._component.configure(this._getConfiguration(true));
44782 * Disables the interaction.
44784 * @example ```<component-name>.<handler-name>.disable();```
44786 HandlerBase.prototype.disable = function () {
44787 if (!this._enabled) {
44791 this._enabled = false;
44792 if (this._component.activated) {
44793 this._component.configure(this._getConfiguration(false));
44796 return HandlerBase;
44798 exports.HandlerBase = HandlerBase;
44799 exports.default = HandlerBase;
44801 },{}],406:[function(require,module,exports){
44803 Object.defineProperty(exports, "__esModule", { value: true });
44804 exports.MeshFactory = void 0;
44805 var THREE = require("three");
44806 var Component_1 = require("../../Component");
44807 var MeshFactory = /** @class */ (function () {
44808 function MeshFactory(imagePlaneDepth, imageSphereRadius) {
44809 this._imagePlaneDepth = imagePlaneDepth != null ? imagePlaneDepth : 200;
44810 this._imageSphereRadius = imageSphereRadius != null ? imageSphereRadius : 200;
44812 MeshFactory.prototype.createMesh = function (node, transform) {
44814 return this._createImageSphere(node, transform);
44816 else if (transform.cameraProjection === "fisheye") {
44817 return this._createImagePlaneFisheye(node, transform);
44820 return this._createImagePlane(node, transform);
44823 MeshFactory.prototype.createFlatMesh = function (node, transform, basicX0, basicX1, basicY0, basicY1) {
44824 var texture = this._createTexture(node.image);
44825 var materialParameters = this._createDistortedPlaneMaterialParameters(transform, texture);
44826 var material = new THREE.ShaderMaterial(materialParameters);
44827 var geometry = this._getFlatImagePlaneGeoFromBasic(transform, basicX0, basicX1, basicY0, basicY1);
44828 return new THREE.Mesh(geometry, material);
44830 MeshFactory.prototype.createCurtainMesh = function (node, transform) {
44831 if (node.pano && !node.fullPano) {
44832 throw new Error("Cropped panoramas cannot have curtain.");
44835 return this._createSphereCurtainMesh(node, transform);
44837 else if (transform.cameraProjection === "fisheye") {
44838 return this._createCurtainMeshFisheye(node, transform);
44841 return this._createCurtainMesh(node, transform);
44844 MeshFactory.prototype.createDistortedCurtainMesh = function (node, transform) {
44846 throw new Error("Cropped panoramas cannot have curtain.");
44848 return this._createDistortedCurtainMesh(node, transform);
44850 MeshFactory.prototype._createCurtainMesh = function (node, transform) {
44851 var texture = this._createTexture(node.image);
44852 var materialParameters = this._createCurtainPlaneMaterialParameters(transform, texture);
44853 var material = new THREE.ShaderMaterial(materialParameters);
44854 var geometry = this._useMesh(transform, node) ?
44855 this._getImagePlaneGeo(transform, node) :
44856 this._getRegularFlatImagePlaneGeo(transform);
44857 return new THREE.Mesh(geometry, material);
44859 MeshFactory.prototype._createCurtainMeshFisheye = function (node, transform) {
44860 var texture = this._createTexture(node.image);
44861 var materialParameters = this._createCurtainPlaneMaterialParametersFisheye(transform, texture);
44862 var material = new THREE.ShaderMaterial(materialParameters);
44863 var geometry = this._useMesh(transform, node) ?
44864 this._getImagePlaneGeoFisheye(transform, node) :
44865 this._getRegularFlatImagePlaneGeo(transform);
44866 return new THREE.Mesh(geometry, material);
44868 MeshFactory.prototype._createDistortedCurtainMesh = function (node, transform) {
44869 var texture = this._createTexture(node.image);
44870 var materialParameters = this._createDistortedCurtainPlaneMaterialParameters(transform, texture);
44871 var material = new THREE.ShaderMaterial(materialParameters);
44872 var geometry = this._getRegularFlatImagePlaneGeo(transform);
44873 return new THREE.Mesh(geometry, material);
44875 MeshFactory.prototype._createSphereCurtainMesh = function (node, transform) {
44876 var texture = this._createTexture(node.image);
44877 var materialParameters = this._createCurtainSphereMaterialParameters(transform, texture);
44878 var material = new THREE.ShaderMaterial(materialParameters);
44879 return this._useMesh(transform, node) ?
44880 new THREE.Mesh(this._getImageSphereGeo(transform, node), material) :
44881 new THREE.Mesh(this._getFlatImageSphereGeo(transform), material);
44883 MeshFactory.prototype._createImageSphere = function (node, transform) {
44884 var texture = this._createTexture(node.image);
44885 var materialParameters = this._createSphereMaterialParameters(transform, texture);
44886 var material = new THREE.ShaderMaterial(materialParameters);
44887 var mesh = this._useMesh(transform, node) ?
44888 new THREE.Mesh(this._getImageSphereGeo(transform, node), material) :
44889 new THREE.Mesh(this._getFlatImageSphereGeo(transform), material);
44892 MeshFactory.prototype._createImagePlane = function (node, transform) {
44893 var texture = this._createTexture(node.image);
44894 var materialParameters = this._createPlaneMaterialParameters(transform, texture);
44895 var material = new THREE.ShaderMaterial(materialParameters);
44896 var geometry = this._useMesh(transform, node) ?
44897 this._getImagePlaneGeo(transform, node) :
44898 this._getRegularFlatImagePlaneGeo(transform);
44899 return new THREE.Mesh(geometry, material);
44901 MeshFactory.prototype._createImagePlaneFisheye = function (node, transform) {
44902 var texture = this._createTexture(node.image);
44903 var materialParameters = this._createPlaneMaterialParametersFisheye(transform, texture);
44904 var material = new THREE.ShaderMaterial(materialParameters);
44905 var geometry = this._useMesh(transform, node) ?
44906 this._getImagePlaneGeoFisheye(transform, node) :
44907 this._getRegularFlatImagePlaneGeoFisheye(transform);
44908 return new THREE.Mesh(geometry, material);
44910 MeshFactory.prototype._createSphereMaterialParameters = function (transform, texture) {
44911 var gpano = transform.gpano;
44912 var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2;
44913 var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels;
44914 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
44915 var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2;
44916 var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels;
44917 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
44918 var materialParameters = {
44920 fragmentShader: Component_1.Shaders.equirectangular.fragment,
44921 side: THREE.DoubleSide,
44924 opacity: { value: 1.0 },
44925 phiLength: { value: phiLength },
44926 phiShift: { value: phiShift },
44927 projectorMat: { value: transform.rt },
44928 projectorTex: { value: texture },
44929 thetaLength: { value: thetaLength },
44930 thetaShift: { value: thetaShift },
44932 vertexShader: Component_1.Shaders.equirectangular.vertex,
44934 return materialParameters;
44936 MeshFactory.prototype._createCurtainSphereMaterialParameters = function (transform, texture) {
44937 var gpano = transform.gpano;
44938 var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2;
44939 var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels;
44940 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
44941 var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2;
44942 var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels;
44943 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
44944 var materialParameters = {
44946 fragmentShader: Component_1.Shaders.equirectangularCurtain.fragment,
44947 side: THREE.DoubleSide,
44950 curtain: { value: 1.0 },
44951 opacity: { value: 1.0 },
44952 phiLength: { value: phiLength },
44953 phiShift: { value: phiShift },
44954 projectorMat: { value: transform.rt },
44955 projectorTex: { value: texture },
44956 thetaLength: { value: thetaLength },
44957 thetaShift: { value: thetaShift },
44959 vertexShader: Component_1.Shaders.equirectangularCurtain.vertex,
44961 return materialParameters;
44963 MeshFactory.prototype._createPlaneMaterialParameters = function (transform, texture) {
44964 var materialParameters = {
44966 fragmentShader: Component_1.Shaders.perspective.fragment,
44967 side: THREE.DoubleSide,
44970 focal: { value: transform.focal },
44971 k1: { value: transform.ck1 },
44972 k2: { value: transform.ck2 },
44973 opacity: { value: 1.0 },
44974 projectorMat: { value: transform.basicRt },
44975 projectorTex: { value: texture },
44976 radial_peak: { value: !!transform.radialPeak ? transform.radialPeak : 0.0 },
44977 scale_x: { value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth },
44978 scale_y: { value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight },
44980 vertexShader: Component_1.Shaders.perspective.vertex,
44982 return materialParameters;
44984 MeshFactory.prototype._createPlaneMaterialParametersFisheye = function (transform, texture) {
44985 var materialParameters = {
44987 fragmentShader: Component_1.Shaders.fisheye.fragment,
44988 side: THREE.DoubleSide,
44991 focal: { value: transform.focal },
44992 k1: { value: transform.ck1 },
44993 k2: { value: transform.ck2 },
44994 opacity: { value: 1.0 },
44995 projectorMat: { value: transform.basicRt },
44996 projectorTex: { value: texture },
44997 radial_peak: { value: !!transform.radialPeak ? transform.radialPeak : 0.0 },
44998 scale_x: { value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth },
44999 scale_y: { value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight },
45001 vertexShader: Component_1.Shaders.fisheye.vertex,
45003 return materialParameters;
45005 MeshFactory.prototype._createCurtainPlaneMaterialParametersFisheye = function (transform, texture) {
45006 var materialParameters = {
45008 fragmentShader: Component_1.Shaders.fisheyeCurtain.fragment,
45009 side: THREE.DoubleSide,
45012 curtain: { value: 1.0 },
45013 focal: { value: transform.focal },
45014 k1: { value: transform.ck1 },
45015 k2: { value: transform.ck2 },
45016 opacity: { value: 1.0 },
45017 projectorMat: { value: transform.basicRt },
45018 projectorTex: { value: texture },
45019 radial_peak: { value: !!transform.radialPeak ? transform.radialPeak : 0.0 },
45020 scale_x: { value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth },
45021 scale_y: { value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight },
45023 vertexShader: Component_1.Shaders.fisheyeCurtain.vertex,
45025 return materialParameters;
45027 MeshFactory.prototype._createCurtainPlaneMaterialParameters = function (transform, texture) {
45028 var materialParameters = {
45030 fragmentShader: Component_1.Shaders.perspectiveCurtain.fragment,
45031 side: THREE.DoubleSide,
45034 curtain: { value: 1.0 },
45035 focal: { value: transform.focal },
45036 k1: { value: transform.ck1 },
45037 k2: { value: transform.ck2 },
45038 opacity: { value: 1.0 },
45039 projectorMat: { value: transform.basicRt },
45040 projectorTex: { value: texture },
45041 radial_peak: { value: !!transform.radialPeak ? transform.radialPeak : 0.0 },
45042 scale_x: { value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth },
45043 scale_y: { value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight },
45045 vertexShader: Component_1.Shaders.perspectiveCurtain.vertex,
45047 return materialParameters;
45049 MeshFactory.prototype._createDistortedCurtainPlaneMaterialParameters = function (transform, texture) {
45050 var materialParameters = {
45052 fragmentShader: Component_1.Shaders.perspectiveDistortedCurtain.fragment,
45053 side: THREE.DoubleSide,
45056 curtain: { value: 1.0 },
45057 opacity: { value: 1.0 },
45058 projectorMat: { value: transform.projectorMatrix() },
45059 projectorTex: { value: texture },
45061 vertexShader: Component_1.Shaders.perspectiveDistortedCurtain.vertex,
45063 return materialParameters;
45065 MeshFactory.prototype._createDistortedPlaneMaterialParameters = function (transform, texture) {
45066 var materialParameters = {
45068 fragmentShader: Component_1.Shaders.perspectiveDistorted.fragment,
45069 side: THREE.DoubleSide,
45072 opacity: { value: 1.0 },
45073 projectorMat: { value: transform.projectorMatrix() },
45074 projectorTex: { value: texture },
45076 vertexShader: Component_1.Shaders.perspectiveDistorted.vertex,
45078 return materialParameters;
45080 MeshFactory.prototype._createTexture = function (image) {
45081 var texture = new THREE.Texture(image);
45082 texture.minFilter = THREE.LinearFilter;
45083 texture.needsUpdate = true;
45086 MeshFactory.prototype._useMesh = function (transform, node) {
45087 return node.mesh.vertices.length && transform.hasValidScale;
45089 MeshFactory.prototype._getImageSphereGeo = function (transform, node) {
45090 var t = new THREE.Matrix4().getInverse(transform.srt);
45091 // push everything at least 5 meters in front of the camera
45092 var minZ = 5.0 * transform.scale;
45093 var maxZ = this._imageSphereRadius * transform.scale;
45094 var vertices = node.mesh.vertices;
45095 var numVertices = vertices.length / 3;
45096 var positions = new Float32Array(vertices.length);
45097 for (var i = 0; i < numVertices; ++i) {
45099 var x = vertices[index + 0];
45100 var y = vertices[index + 1];
45101 var z = vertices[index + 2];
45102 var l = Math.sqrt(x * x + y * y + z * z);
45103 var boundedL = Math.max(minZ, Math.min(l, maxZ));
45104 var factor = boundedL / l;
45105 var p = new THREE.Vector3(x * factor, y * factor, z * factor);
45107 positions[index + 0] = p.x;
45108 positions[index + 1] = p.y;
45109 positions[index + 2] = p.z;
45111 var faces = node.mesh.faces;
45112 var indices = new Uint16Array(faces.length);
45113 for (var i = 0; i < faces.length; ++i) {
45114 indices[i] = faces[i];
45116 var geometry = new THREE.BufferGeometry();
45117 geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
45118 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
45121 MeshFactory.prototype._getImagePlaneGeo = function (transform, node) {
45122 var undistortionMarginFactor = 3;
45123 var t = new THREE.Matrix4().getInverse(transform.srt);
45124 // push everything at least 5 meters in front of the camera
45125 var minZ = 5.0 * transform.scale;
45126 var maxZ = this._imagePlaneDepth * transform.scale;
45127 var vertices = node.mesh.vertices;
45128 var numVertices = vertices.length / 3;
45129 var positions = new Float32Array(vertices.length);
45130 for (var i = 0; i < numVertices; ++i) {
45132 var x = vertices[index + 0];
45133 var y = vertices[index + 1];
45134 var z = vertices[index + 2];
45136 x *= undistortionMarginFactor;
45137 y *= undistortionMarginFactor;
45139 var boundedZ = Math.max(minZ, Math.min(z, maxZ));
45140 var factor = boundedZ / z;
45141 var p = new THREE.Vector3(x * factor, y * factor, boundedZ);
45143 positions[index + 0] = p.x;
45144 positions[index + 1] = p.y;
45145 positions[index + 2] = p.z;
45147 var faces = node.mesh.faces;
45148 var indices = new Uint16Array(faces.length);
45149 for (var i = 0; i < faces.length; ++i) {
45150 indices[i] = faces[i];
45152 var geometry = new THREE.BufferGeometry();
45153 geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
45154 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
45157 MeshFactory.prototype._getImagePlaneGeoFisheye = function (transform, node) {
45158 var t = new THREE.Matrix4().getInverse(transform.srt);
45159 // push everything at least 5 meters in front of the camera
45160 var minZ = 5.0 * transform.scale;
45161 var maxZ = this._imagePlaneDepth * transform.scale;
45162 var vertices = node.mesh.vertices;
45163 var numVertices = vertices.length / 3;
45164 var positions = new Float32Array(vertices.length);
45165 for (var i = 0; i < numVertices; ++i) {
45167 var x = vertices[index + 0];
45168 var y = vertices[index + 1];
45169 var z = vertices[index + 2];
45170 var l = Math.sqrt(x * x + y * y + z * z);
45171 var boundedL = Math.max(minZ, Math.min(l, maxZ));
45172 var factor = boundedL / l;
45173 var p = new THREE.Vector3(x * factor, y * factor, z * factor);
45175 positions[index + 0] = p.x;
45176 positions[index + 1] = p.y;
45177 positions[index + 2] = p.z;
45179 var faces = node.mesh.faces;
45180 var indices = new Uint16Array(faces.length);
45181 for (var i = 0; i < faces.length; ++i) {
45182 indices[i] = faces[i];
45184 var geometry = new THREE.BufferGeometry();
45185 geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
45186 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
45189 MeshFactory.prototype._getFlatImageSphereGeo = function (transform) {
45190 var gpano = transform.gpano;
45191 var phiStart = 2 * Math.PI * gpano.CroppedAreaLeftPixels / gpano.FullPanoWidthPixels;
45192 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
45193 var thetaStart = Math.PI *
45194 (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels - gpano.CroppedAreaTopPixels) /
45195 gpano.FullPanoHeightPixels;
45196 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
45197 var geometry = new THREE.SphereGeometry(this._imageSphereRadius, 20, 40, phiStart - Math.PI / 2, phiLength, thetaStart, thetaLength);
45198 geometry.applyMatrix4(new THREE.Matrix4().getInverse(transform.rt));
45201 MeshFactory.prototype._getRegularFlatImagePlaneGeo = function (transform) {
45202 var width = transform.width;
45203 var height = transform.height;
45204 var size = Math.max(width, height);
45205 var dx = width / 2.0 / size;
45206 var dy = height / 2.0 / size;
45207 return this._getFlatImagePlaneGeo(transform, dx, dy);
45209 MeshFactory.prototype._getFlatImagePlaneGeo = function (transform, dx, dy) {
45211 vertices.push(transform.unprojectSfM([-dx, -dy], this._imagePlaneDepth));
45212 vertices.push(transform.unprojectSfM([dx, -dy], this._imagePlaneDepth));
45213 vertices.push(transform.unprojectSfM([dx, dy], this._imagePlaneDepth));
45214 vertices.push(transform.unprojectSfM([-dx, dy], this._imagePlaneDepth));
45215 return this._createFlatGeometry(vertices);
45217 MeshFactory.prototype._getRegularFlatImagePlaneGeoFisheye = function (transform) {
45218 var width = transform.width;
45219 var height = transform.height;
45220 var size = Math.max(width, height);
45221 var dx = width / 2.0 / size;
45222 var dy = height / 2.0 / size;
45223 return this._getFlatImagePlaneGeoFisheye(transform, dx, dy);
45225 MeshFactory.prototype._getFlatImagePlaneGeoFisheye = function (transform, dx, dy) {
45227 vertices.push(transform.unprojectSfM([-dx, -dy], this._imagePlaneDepth));
45228 vertices.push(transform.unprojectSfM([dx, -dy], this._imagePlaneDepth));
45229 vertices.push(transform.unprojectSfM([dx, dy], this._imagePlaneDepth));
45230 vertices.push(transform.unprojectSfM([-dx, dy], this._imagePlaneDepth));
45231 return this._createFlatGeometry(vertices);
45233 MeshFactory.prototype._getFlatImagePlaneGeoFromBasic = function (transform, basicX0, basicX1, basicY0, basicY1) {
45235 vertices.push(transform.unprojectBasic([basicX0, basicY0], this._imagePlaneDepth));
45236 vertices.push(transform.unprojectBasic([basicX1, basicY0], this._imagePlaneDepth));
45237 vertices.push(transform.unprojectBasic([basicX1, basicY1], this._imagePlaneDepth));
45238 vertices.push(transform.unprojectBasic([basicX0, basicY1], this._imagePlaneDepth));
45239 return this._createFlatGeometry(vertices);
45241 MeshFactory.prototype._createFlatGeometry = function (vertices) {
45242 var positions = new Float32Array(12);
45243 for (var i = 0; i < vertices.length; i++) {
45245 positions[index + 0] = vertices[i][0];
45246 positions[index + 1] = vertices[i][1];
45247 positions[index + 2] = vertices[i][2];
45249 var indices = new Uint16Array(6);
45256 var geometry = new THREE.BufferGeometry();
45257 geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
45258 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
45261 return MeshFactory;
45263 exports.MeshFactory = MeshFactory;
45264 exports.default = MeshFactory;
45266 },{"../../Component":291,"three":242}],407:[function(require,module,exports){
45268 Object.defineProperty(exports, "__esModule", { value: true });
45269 exports.MeshScene = void 0;
45270 var THREE = require("three");
45271 var MeshScene = /** @class */ (function () {
45272 function MeshScene() {
45274 this._planesOld = {};
45275 this._planesPeriphery = {};
45276 this._scene = new THREE.Scene();
45277 this._sceneOld = new THREE.Scene();
45278 this._scenePeriphery = new THREE.Scene();
45280 Object.defineProperty(MeshScene.prototype, "planes", {
45282 return this._planes;
45287 Object.defineProperty(MeshScene.prototype, "planesOld", {
45289 return this._planesOld;
45294 Object.defineProperty(MeshScene.prototype, "planesPeriphery", {
45296 return this._planesPeriphery;
45301 Object.defineProperty(MeshScene.prototype, "scene", {
45303 return this._scene;
45308 Object.defineProperty(MeshScene.prototype, "sceneOld", {
45310 return this._sceneOld;
45315 Object.defineProperty(MeshScene.prototype, "scenePeriphery", {
45317 return this._scenePeriphery;
45322 MeshScene.prototype.updateImagePlanes = function (planes) {
45323 this._dispose(this._planesOld, this.sceneOld);
45324 for (var key in this._planes) {
45325 if (!this._planes.hasOwnProperty(key)) {
45328 var plane = this._planes[key];
45329 this._scene.remove(plane);
45330 this._sceneOld.add(plane);
45332 for (var key in planes) {
45333 if (!planes.hasOwnProperty(key)) {
45336 this._scene.add(planes[key]);
45338 this._planesOld = this._planes;
45339 this._planes = planes;
45341 MeshScene.prototype.addImagePlanes = function (planes) {
45342 for (var key in planes) {
45343 if (!planes.hasOwnProperty(key)) {
45346 var plane = planes[key];
45347 this._scene.add(plane);
45348 this._planes[key] = plane;
45351 MeshScene.prototype.addImagePlanesOld = function (planes) {
45352 for (var key in planes) {
45353 if (!planes.hasOwnProperty(key)) {
45356 var plane = planes[key];
45357 this._sceneOld.add(plane);
45358 this._planesOld[key] = plane;
45361 MeshScene.prototype.setImagePlanes = function (planes) {
45363 this.addImagePlanes(planes);
45365 MeshScene.prototype.addPeripheryPlanes = function (planes) {
45366 for (var key in planes) {
45367 if (!planes.hasOwnProperty(key)) {
45370 var plane = planes[key];
45371 this._scenePeriphery.add(plane);
45372 this._planesPeriphery[key] = plane;
45375 MeshScene.prototype.setPeripheryPlanes = function (planes) {
45376 this._clearPeriphery();
45377 this.addPeripheryPlanes(planes);
45379 MeshScene.prototype.setImagePlanesOld = function (planes) {
45381 this.addImagePlanesOld(planes);
45383 MeshScene.prototype.clear = function () {
45387 MeshScene.prototype._clear = function () {
45388 this._dispose(this._planes, this._scene);
45391 MeshScene.prototype._clearOld = function () {
45392 this._dispose(this._planesOld, this._sceneOld);
45393 this._planesOld = {};
45395 MeshScene.prototype._clearPeriphery = function () {
45396 this._dispose(this._planesPeriphery, this._scenePeriphery);
45397 this._planesPeriphery = {};
45399 MeshScene.prototype._dispose = function (planes, scene) {
45400 for (var key in planes) {
45401 if (!planes.hasOwnProperty(key)) {
45404 var plane = planes[key];
45405 scene.remove(plane);
45406 plane.geometry.dispose();
45407 plane.material.dispose();
45408 var texture = plane.material.uniforms.projectorTex.value;
45409 if (texture != null) {
45416 exports.MeshScene = MeshScene;
45417 exports.default = MeshScene;
45419 },{"three":242}],408:[function(require,module,exports){
45421 Object.defineProperty(exports, "__esModule", { value: true });
45422 exports.MouseOperator = void 0;
45423 var rxjs_1 = require("rxjs");
45424 var operators_1 = require("rxjs/operators");
45425 var MouseOperator = /** @class */ (function () {
45426 function MouseOperator() {
45428 MouseOperator.filteredPairwiseMouseDrag$ = function (name, mouseService) {
45429 return mouseService
45430 .filtered$(name, mouseService.mouseDragStart$).pipe(operators_1.switchMap(function (mouseDragStart) {
45431 var mouseDragging$ = rxjs_1.concat(rxjs_1.of(mouseDragStart), mouseService
45432 .filtered$(name, mouseService.mouseDrag$));
45433 var mouseDragEnd$ = mouseService
45434 .filtered$(name, mouseService.mouseDragEnd$).pipe(operators_1.map(function () {
45437 return rxjs_1.merge(mouseDragging$, mouseDragEnd$).pipe(operators_1.takeWhile(function (e) {
45439 }), operators_1.startWith(null));
45440 }), operators_1.pairwise(), operators_1.filter(function (pair) {
45441 return pair[0] != null && pair[1] != null;
45444 return MouseOperator;
45446 exports.MouseOperator = MouseOperator;
45447 exports.default = MouseOperator;
45449 },{"rxjs":43,"rxjs/operators":241}],409:[function(require,module,exports){
45451 var __extends = (this && this.__extends) || (function () {
45452 var extendStatics = function (d, b) {
45453 extendStatics = Object.setPrototypeOf ||
45454 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45455 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45456 return extendStatics(d, b);
45458 return function (d, b) {
45459 extendStatics(d, b);
45460 function __() { this.constructor = d; }
45461 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45464 Object.defineProperty(exports, "__esModule", { value: true });
45465 exports.ZoomComponent = void 0;
45466 var rxjs_1 = require("rxjs");
45467 var operators_1 = require("rxjs/operators");
45468 var vd = require("virtual-dom");
45469 var Component_1 = require("../../Component");
45470 var Geo_1 = require("../../Geo");
45471 var State_1 = require("../../State");
45472 var ComponentSize_1 = require("../utils/ComponentSize");
45474 * @class ZoomComponent
45476 * @classdesc Component rendering UI elements used for zooming.
45480 * var viewer = new Mapillary.Viewer(
45485 * var zoomComponent = viewer.getComponent("zoom");
45486 * zoomComponent.configure({ size: Mapillary.ComponentSize.Small });
45489 var ZoomComponent = /** @class */ (function (_super) {
45490 __extends(ZoomComponent, _super);
45491 function ZoomComponent(name, container, navigator) {
45492 var _this = _super.call(this, name, container, navigator) || this;
45493 _this._viewportCoords = new Geo_1.ViewportCoords();
45494 _this._zoomDelta$ = new rxjs_1.Subject();
45497 ZoomComponent.prototype._activate = function () {
45499 this._renderSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentState$, this._navigator.stateService.state$, this._configuration$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
45500 var frame = _a[0], state = _a[1], configuration = _a[2], size = _a[3];
45501 var zoom = frame.state.zoom;
45502 var zoomInIcon = vd.h("div.ZoomInIcon", []);
45503 var zoomInButton = zoom >= 3 || state === State_1.State.Waiting ?
45504 vd.h("div.ZoomInButtonDisabled", [zoomInIcon]) :
45505 vd.h("div.ZoomInButton", { onclick: function () { _this._zoomDelta$.next(1); } }, [zoomInIcon]);
45506 var zoomOutIcon = vd.h("div.ZoomOutIcon", []);
45507 var zoomOutButton = zoom <= 0 || state === State_1.State.Waiting ?
45508 vd.h("div.ZoomOutButtonDisabled", [zoomOutIcon]) :
45509 vd.h("div.ZoomOutButton", { onclick: function () { _this._zoomDelta$.next(-1); } }, [zoomOutIcon]);
45510 var compact = configuration.size === ComponentSize_1.default.Small ||
45511 configuration.size === ComponentSize_1.default.Automatic && size.width < 640 ?
45512 ".ZoomCompact" : "";
45515 vnode: vd.h("div.ZoomContainer" + compact, { oncontextmenu: function (event) { event.preventDefault(); } }, [zoomInButton, zoomOutButton]),
45518 .subscribe(this._container.domRenderer.render$);
45519 this._zoomSubscription = this._zoomDelta$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
45520 .subscribe(function (_a) {
45521 var zoomDelta = _a[0], render = _a[1], transform = _a[2];
45522 var unprojected = _this._viewportCoords.unprojectFromViewport(0, 0, render.perspective);
45523 var reference = transform.projectBasic(unprojected.toArray());
45524 _this._navigator.stateService.zoomIn(zoomDelta, reference);
45527 ZoomComponent.prototype._deactivate = function () {
45528 this._renderSubscription.unsubscribe();
45529 this._zoomSubscription.unsubscribe();
45531 ZoomComponent.prototype._getDefaultConfiguration = function () {
45532 return { size: ComponentSize_1.default.Automatic };
45534 ZoomComponent.componentName = "zoom";
45535 return ZoomComponent;
45536 }(Component_1.Component));
45537 exports.ZoomComponent = ZoomComponent;
45538 Component_1.ComponentService.register(ZoomComponent);
45539 exports.default = ZoomComponent;
45541 },{"../../Component":291,"../../Geo":294,"../../State":298,"../utils/ComponentSize":404,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],410:[function(require,module,exports){
45543 var __extends = (this && this.__extends) || (function () {
45544 var extendStatics = function (d, b) {
45545 extendStatics = Object.setPrototypeOf ||
45546 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45547 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45548 return extendStatics(d, b);
45550 return function (d, b) {
45551 extendStatics(d, b);
45552 function __() { this.constructor = d; }
45553 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45556 Object.defineProperty(exports, "__esModule", { value: true });
45557 exports.AbortMapillaryError = void 0;
45558 var MapillaryError_1 = require("./MapillaryError");
45560 * @class AbortMapillaryError
45562 * @classdesc Error thrown when a move to request has been
45563 * aborted before completing because of a subsequent request.
45565 var AbortMapillaryError = /** @class */ (function (_super) {
45566 __extends(AbortMapillaryError, _super);
45567 function AbortMapillaryError(message) {
45568 var _this = _super.call(this, message != null ? message : "The request was aborted.") || this;
45569 Object.setPrototypeOf(_this, AbortMapillaryError.prototype);
45570 _this.name = "AbortMapillaryError";
45573 return AbortMapillaryError;
45574 }(MapillaryError_1.MapillaryError));
45575 exports.AbortMapillaryError = AbortMapillaryError;
45576 exports.default = AbortMapillaryError;
45578 },{"./MapillaryError":413}],411:[function(require,module,exports){
45580 var __extends = (this && this.__extends) || (function () {
45581 var extendStatics = function (d, b) {
45582 extendStatics = Object.setPrototypeOf ||
45583 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45584 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45585 return extendStatics(d, b);
45587 return function (d, b) {
45588 extendStatics(d, b);
45589 function __() { this.constructor = d; }
45590 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45593 Object.defineProperty(exports, "__esModule", { value: true });
45594 exports.ArgumentMapillaryError = void 0;
45595 var MapillaryError_1 = require("./MapillaryError");
45596 var ArgumentMapillaryError = /** @class */ (function (_super) {
45597 __extends(ArgumentMapillaryError, _super);
45598 function ArgumentMapillaryError(message) {
45599 var _this = _super.call(this, message != null ? message : "The argument is not valid.") || this;
45600 Object.setPrototypeOf(_this, ArgumentMapillaryError.prototype);
45601 _this.name = "ArgumentMapillaryError";
45604 return ArgumentMapillaryError;
45605 }(MapillaryError_1.MapillaryError));
45606 exports.ArgumentMapillaryError = ArgumentMapillaryError;
45607 exports.default = ArgumentMapillaryError;
45609 },{"./MapillaryError":413}],412:[function(require,module,exports){
45611 var __extends = (this && this.__extends) || (function () {
45612 var extendStatics = function (d, b) {
45613 extendStatics = Object.setPrototypeOf ||
45614 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45615 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45616 return extendStatics(d, b);
45618 return function (d, b) {
45619 extendStatics(d, b);
45620 function __() { this.constructor = d; }
45621 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45624 Object.defineProperty(exports, "__esModule", { value: true });
45625 exports.GraphMapillaryError = void 0;
45626 var MapillaryError_1 = require("./MapillaryError");
45627 var GraphMapillaryError = /** @class */ (function (_super) {
45628 __extends(GraphMapillaryError, _super);
45629 function GraphMapillaryError(message) {
45630 var _this = _super.call(this, message) || this;
45631 Object.setPrototypeOf(_this, GraphMapillaryError.prototype);
45632 _this.name = "GraphMapillaryError";
45635 return GraphMapillaryError;
45636 }(MapillaryError_1.MapillaryError));
45637 exports.GraphMapillaryError = GraphMapillaryError;
45638 exports.default = GraphMapillaryError;
45640 },{"./MapillaryError":413}],413:[function(require,module,exports){
45642 var __extends = (this && this.__extends) || (function () {
45643 var extendStatics = function (d, b) {
45644 extendStatics = Object.setPrototypeOf ||
45645 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45646 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45647 return extendStatics(d, b);
45649 return function (d, b) {
45650 extendStatics(d, b);
45651 function __() { this.constructor = d; }
45652 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45655 Object.defineProperty(exports, "__esModule", { value: true });
45656 exports.MapillaryError = void 0;
45657 var MapillaryError = /** @class */ (function (_super) {
45658 __extends(MapillaryError, _super);
45659 function MapillaryError(message) {
45660 var _this = _super.call(this, message) || this;
45661 Object.setPrototypeOf(_this, MapillaryError.prototype);
45662 _this.name = "MapillaryError";
45665 return MapillaryError;
45667 exports.MapillaryError = MapillaryError;
45668 exports.default = MapillaryError;
45670 },{}],414:[function(require,module,exports){
45672 Object.defineProperty(exports, "__esModule", { value: true });
45673 exports.Camera = void 0;
45674 var THREE = require("three");
45678 * @classdesc Holds information about a camera.
45680 var Camera = /** @class */ (function () {
45682 * Create a new camera instance.
45683 * @param {Transform} [transform] - Optional transform instance.
45685 function Camera(transform) {
45686 if (transform != null) {
45687 this._position = new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0));
45688 this._lookat = new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10));
45689 this._up = transform.upVector();
45690 this._focal = this._getFocal(transform);
45693 this._position = new THREE.Vector3(0, 0, 0);
45694 this._lookat = new THREE.Vector3(0, 0, 1);
45695 this._up = new THREE.Vector3(0, -1, 0);
45699 Object.defineProperty(Camera.prototype, "position", {
45702 * @returns {THREE.Vector3} The position vector.
45705 return this._position;
45710 Object.defineProperty(Camera.prototype, "lookat", {
45713 * @returns {THREE.Vector3} The lookat vector.
45716 return this._lookat;
45721 Object.defineProperty(Camera.prototype, "up", {
45724 * @returns {THREE.Vector3} The up vector.
45732 Object.defineProperty(Camera.prototype, "focal", {
45735 * @returns {number} The focal length.
45738 return this._focal;
45743 set: function (value) {
45744 this._focal = value;
45750 * Update this camera to the linearly interpolated value of two other cameras.
45752 * @param {Camera} a - First camera.
45753 * @param {Camera} b - Second camera.
45754 * @param {number} alpha - Interpolation value on the interval [0, 1].
45756 Camera.prototype.lerpCameras = function (a, b, alpha) {
45757 this._position.subVectors(b.position, a.position).multiplyScalar(alpha).add(a.position);
45758 this._lookat.subVectors(b.lookat, a.lookat).multiplyScalar(alpha).add(a.lookat);
45759 this._up.subVectors(b.up, a.up).multiplyScalar(alpha).add(a.up);
45760 this._focal = (1 - alpha) * a.focal + alpha * b.focal;
45763 * Copy the properties of another camera to this camera.
45765 * @param {Camera} other - Another camera.
45767 Camera.prototype.copy = function (other) {
45768 this._position.copy(other.position);
45769 this._lookat.copy(other.lookat);
45770 this._up.copy(other.up);
45771 this._focal = other.focal;
45774 * Clone this camera.
45776 * @returns {Camera} A camera with cloned properties equal to this camera.
45778 Camera.prototype.clone = function () {
45779 var camera = new Camera();
45780 camera.position.copy(this._position);
45781 camera.lookat.copy(this._lookat);
45782 camera.up.copy(this._up);
45783 camera.focal = this._focal;
45787 * Determine the distance between this camera and another camera.
45789 * @param {Camera} other - Another camera.
45790 * @returns {number} The distance between the cameras.
45792 Camera.prototype.diff = function (other) {
45793 var pd = this._position.distanceToSquared(other.position);
45794 var ld = this._lookat.distanceToSquared(other.lookat);
45795 var ud = this._up.distanceToSquared(other.up);
45796 var fd = 100 * Math.abs(this._focal - other.focal);
45797 return Math.max(pd, ld, ud, fd);
45800 * Get the focal length based on the transform.
45802 * @description Returns the focal length of the transform if gpano info is not available.
45803 * Returns a focal length corresponding to a vertical fov clamped to [45, 90] degrees based on
45804 * the gpano information if available.
45806 * @returns {number} Focal length.
45808 Camera.prototype._getFocal = function (transform) {
45809 if (transform.gpano == null) {
45810 return transform.focal;
45812 var vFov = Math.PI * transform.gpano.CroppedAreaImageHeightPixels / transform.gpano.FullPanoHeightPixels;
45813 var focal = 0.5 / Math.tan(vFov / 2);
45814 return Math.min(1 / (2 * (Math.sqrt(2) - 1)), Math.max(0.5, focal));
45818 exports.Camera = Camera;
45820 },{"three":242}],415:[function(require,module,exports){
45822 Object.defineProperty(exports, "__esModule", { value: true });
45823 exports.computeProjectedPoints = exports.computeTranslation = void 0;
45824 var THREE = require("three");
45825 var Geo_1 = require("../Geo");
45826 var geoCoords = new Geo_1.GeoCoords();
45827 var spatial = new Geo_1.Spatial();
45828 function computeTranslation(position, rotation, reference) {
45829 var C = geoCoords.geodeticToEnu(position.lat, position.lon, position.alt, reference.lat, reference.lon, reference.alt);
45830 var RC = spatial.rotate(C, rotation);
45831 var translation = [-RC.x, -RC.y, -RC.z];
45832 return translation;
45834 exports.computeTranslation = computeTranslation;
45835 function computeProjectedPoints(transform, basicVertices, basicDirections, pointsPerLine, viewportCoords) {
45836 var basicPoints = [];
45837 for (var side = 0; side < basicVertices.length; ++side) {
45838 var v = basicVertices[side];
45839 var d = basicDirections[side];
45840 for (var i = 0; i <= pointsPerLine; ++i) {
45841 basicPoints.push([v[0] + d[0] * i / pointsPerLine,
45842 v[1] + d[1] * i / pointsPerLine]);
45845 var camera = new THREE.Camera();
45846 camera.up.copy(transform.upVector());
45847 camera.position.copy(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0)));
45848 camera.lookAt(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10)));
45849 camera.updateMatrix();
45850 camera.updateMatrixWorld(true);
45851 var projectedPoints = basicPoints
45852 .map(function (basicPoint) {
45853 var worldPoint = transform.unprojectBasic(basicPoint, 10000);
45854 var cameraPoint = viewportCoords.worldToCamera(worldPoint, camera);
45856 Math.abs(cameraPoint[0] / cameraPoint[2]),
45857 Math.abs(cameraPoint[1] / cameraPoint[2]),
45860 return projectedPoints;
45862 exports.computeProjectedPoints = computeProjectedPoints;
45864 },{"../Geo":294,"three":242}],416:[function(require,module,exports){
45866 Object.defineProperty(exports, "__esModule", { value: true });
45867 exports.GeoCoords = void 0;
45871 * @classdesc Converts coordinates between the geodetic (WGS84),
45872 * Earth-Centered, Earth-Fixed (ECEF) and local topocentric
45873 * East, North, Up (ENU) reference frames.
45875 * The WGS84 has latitude (degrees), longitude (degrees) and
45876 * altitude (meters) values.
45878 * The ECEF Z-axis pierces the north pole and the
45879 * XY-axis defines the equatorial plane. The X-axis extends
45880 * from the geocenter to the intersection of the Equator and
45881 * the Greenwich Meridian. All values in meters.
45883 * The WGS84 parameters are:
45887 * f = 1 / 298.257223563
45888 * e = Math.sqrt((a^2 - b^2) / a^2)
45889 * e' = Math.sqrt((a^2 - b^2) / b^2)
45891 * The WGS84 to ECEF conversion is performed using the following:
45893 * X = (N - h) * cos(phi) * cos(lambda)
45894 * Y = (N + h) * cos(phi) * sin(lambda)
45895 * Z = (b^2 * N / a^2 + h) * sin(phi)
45900 * lambda = longitude
45901 * h = height above ellipsoid (altitude)
45902 * N = Radius of curvature (meters)
45903 * = a / Math.sqrt(1 - e^2 * sin(phi)^2)
45905 * The ECEF to WGS84 conversion is performed using the following:
45907 * phi = arctan((Z + e'^2 * b * sin(theta)^3) / (p - e^2 * a * cos(theta)^3))
45908 * lambda = arctan(Y / X)
45909 * h = p / cos(phi) - N
45913 * p = Math.sqrt(X^2 + Y^2)
45914 * theta = arctan(Z * a / p * b)
45916 * In the ENU reference frame the x-axis points to the
45917 * East, the y-axis to the North and the z-axis Up. All values
45920 * The ECEF to ENU conversion is performed using the following:
45922 * | x | | -sin(lambda_r) cos(lambda_r) 0 | | X - X_r |
45923 * | y | = | -sin(phi_r) * cos(lambda_r) -sin(phi_r) * sin(lambda_r) cos(phi_r) | | Y - Y_r |
45924 * | z | | cos(phi_r) * cos(lambda_r) cos(phi_r) * sin(lambda_r) sin(phi_r) | | Z - Z_r |
45928 * phi_r = latitude of reference
45929 * lambda_r = longitude of reference
45930 * X_r, Y_r, Z_r = ECEF coordinates of reference
45932 * The ENU to ECEF conversion is performed by solving the above equation for X, Y, Z.
45934 * WGS84 to ENU and ENU to WGS84 are two step conversions with ECEF calculated in
45935 * the first step for both conversions.
45937 var GeoCoords = /** @class */ (function () {
45938 function GeoCoords() {
45939 this._wgs84a = 6378137.0;
45940 this._wgs84b = 6356752.31424518;
45943 * Convert coordinates from geodetic (WGS84) reference to local topocentric
45946 * @param {number} lat Latitude in degrees.
45947 * @param {number} lon Longitude in degrees.
45948 * @param {number} alt Altitude in meters.
45949 * @param {number} refLat Reference latitude in degrees.
45950 * @param {number} refLon Reference longitude in degrees.
45951 * @param {number} refAlt Reference altitude in meters.
45952 * @returns {Array<number>} The x, y, z local topocentric ENU coordinates.
45954 GeoCoords.prototype.geodeticToEnu = function (lat, lon, alt, refLat, refLon, refAlt) {
45955 var ecef = this.geodeticToEcef(lat, lon, alt);
45956 return this.ecefToEnu(ecef[0], ecef[1], ecef[2], refLat, refLon, refAlt);
45959 * Convert coordinates from local topocentric (ENU) reference to
45960 * geodetic (WGS84) reference.
45962 * @param {number} x Topocentric ENU coordinate in East direction.
45963 * @param {number} y Topocentric ENU coordinate in North direction.
45964 * @param {number} z Topocentric ENU coordinate in Up direction.
45965 * @param {number} refLat Reference latitude in degrees.
45966 * @param {number} refLon Reference longitude in degrees.
45967 * @param {number} refAlt Reference altitude in meters.
45968 * @returns {Array<number>} The latitude and longitude in degrees
45969 * as well as altitude in meters.
45971 GeoCoords.prototype.enuToGeodetic = function (x, y, z, refLat, refLon, refAlt) {
45972 var ecef = this.enuToEcef(x, y, z, refLat, refLon, refAlt);
45973 return this.ecefToGeodetic(ecef[0], ecef[1], ecef[2]);
45976 * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference
45977 * to local topocentric (ENU) reference.
45979 * @param {number} X ECEF X-value.
45980 * @param {number} Y ECEF Y-value.
45981 * @param {number} Z ECEF Z-value.
45982 * @param {number} refLat Reference latitude in degrees.
45983 * @param {number} refLon Reference longitude in degrees.
45984 * @param {number} refAlt Reference altitude in meters.
45985 * @returns {Array<number>} The x, y, z topocentric ENU coordinates in East, North
45986 * and Up directions respectively.
45988 GeoCoords.prototype.ecefToEnu = function (X, Y, Z, refLat, refLon, refAlt) {
45989 var refEcef = this.geodeticToEcef(refLat, refLon, refAlt);
45990 var V = [X - refEcef[0], Y - refEcef[1], Z - refEcef[2]];
45991 refLat = refLat * Math.PI / 180.0;
45992 refLon = refLon * Math.PI / 180.0;
45993 var cosLat = Math.cos(refLat);
45994 var sinLat = Math.sin(refLat);
45995 var cosLon = Math.cos(refLon);
45996 var sinLon = Math.sin(refLon);
45997 var x = -sinLon * V[0] + cosLon * V[1];
45998 var y = -sinLat * cosLon * V[0] - sinLat * sinLon * V[1] + cosLat * V[2];
45999 var z = cosLat * cosLon * V[0] + cosLat * sinLon * V[1] + sinLat * V[2];
46003 * Convert coordinates from local topocentric (ENU) reference
46004 * to Earth-Centered, Earth-Fixed (ECEF) reference.
46006 * @param {number} x Topocentric ENU coordinate in East direction.
46007 * @param {number} y Topocentric ENU coordinate in North direction.
46008 * @param {number} z Topocentric ENU coordinate in Up direction.
46009 * @param {number} refLat Reference latitude in degrees.
46010 * @param {number} refLon Reference longitude in degrees.
46011 * @param {number} refAlt Reference altitude in meters.
46012 * @returns {Array<number>} The X, Y, Z ECEF coordinates.
46014 GeoCoords.prototype.enuToEcef = function (x, y, z, refLat, refLon, refAlt) {
46015 var refEcef = this.geodeticToEcef(refLat, refLon, refAlt);
46016 refLat = refLat * Math.PI / 180.0;
46017 refLon = refLon * Math.PI / 180.0;
46018 var cosLat = Math.cos(refLat);
46019 var sinLat = Math.sin(refLat);
46020 var cosLon = Math.cos(refLon);
46021 var sinLon = Math.sin(refLon);
46022 var X = -sinLon * x - sinLat * cosLon * y + cosLat * cosLon * z + refEcef[0];
46023 var Y = cosLon * x - sinLat * sinLon * y + cosLat * sinLon * z + refEcef[1];
46024 var Z = cosLat * y + sinLat * z + refEcef[2];
46028 * Convert coordinates from geodetic reference (WGS84) to Earth-Centered,
46029 * Earth-Fixed (ECEF) reference.
46031 * @param {number} lat Latitude in degrees.
46032 * @param {number} lon Longitude in degrees.
46033 * @param {number} alt Altitude in meters.
46034 * @returns {Array<number>} The X, Y, Z ECEF coordinates.
46036 GeoCoords.prototype.geodeticToEcef = function (lat, lon, alt) {
46037 var a = this._wgs84a;
46038 var b = this._wgs84b;
46039 lat = lat * Math.PI / 180.0;
46040 lon = lon * Math.PI / 180.0;
46041 var cosLat = Math.cos(lat);
46042 var sinLat = Math.sin(lat);
46043 var cosLon = Math.cos(lon);
46044 var sinLon = Math.sin(lon);
46047 var L = 1.0 / Math.sqrt(a2 * cosLat * cosLat + b2 * sinLat * sinLat);
46048 var nhcl = (a2 * L + alt) * cosLat;
46049 var X = nhcl * cosLon;
46050 var Y = nhcl * sinLon;
46051 var Z = (b2 * L + alt) * sinLat;
46055 * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference
46056 * to geodetic reference (WGS84).
46058 * @param {number} X ECEF X-value.
46059 * @param {number} Y ECEF Y-value.
46060 * @param {number} Z ECEF Z-value.
46061 * @returns {Array<number>} The latitude and longitude in degrees
46062 * as well as altitude in meters.
46064 GeoCoords.prototype.ecefToGeodetic = function (X, Y, Z) {
46065 var a = this._wgs84a;
46066 var b = this._wgs84b;
46069 var a2mb2 = a2 - b2;
46070 var ea = Math.sqrt(a2mb2 / a2);
46071 var eb = Math.sqrt(a2mb2 / b2);
46072 var p = Math.sqrt(X * X + Y * Y);
46073 var theta = Math.atan2(Z * a, p * b);
46074 var sinTheta = Math.sin(theta);
46075 var cosTheta = Math.cos(theta);
46076 var lon = Math.atan2(Y, X);
46077 var lat = Math.atan2(Z + eb * eb * b * sinTheta * sinTheta * sinTheta, p - ea * ea * a * cosTheta * cosTheta * cosTheta);
46078 var sinLat = Math.sin(lat);
46079 var cosLat = Math.cos(lat);
46080 var N = a / Math.sqrt(1 - ea * ea * sinLat * sinLat);
46081 var alt = p / cosLat - N;
46082 return [lat * 180.0 / Math.PI, lon * 180.0 / Math.PI, alt];
46086 exports.GeoCoords = GeoCoords;
46087 exports.default = GeoCoords;
46089 },{}],417:[function(require,module,exports){
46091 var __extends = (this && this.__extends) || (function () {
46092 var extendStatics = function (d, b) {
46093 extendStatics = Object.setPrototypeOf ||
46094 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
46095 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
46096 return extendStatics(d, b);
46098 return function (d, b) {
46099 extendStatics(d, b);
46100 function __() { this.constructor = d; }
46101 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
46104 Object.defineProperty(exports, "__esModule", { value: true });
46105 exports.GeoRBush = void 0;
46106 var RBush = require("rbush");
46107 var GeoRBush = /** @class */ (function (_super) {
46108 __extends(GeoRBush, _super);
46109 function GeoRBush() {
46110 return _super !== null && _super.apply(this, arguments) || this;
46112 GeoRBush.prototype.compareMinX = function (a, b) { return a.lat - b.lat; };
46113 GeoRBush.prototype.compareMinY = function (a, b) { return a.lon - b.lon; };
46114 GeoRBush.prototype.toBBox = function (item) {
46115 return { minX: item.lat, minY: item.lon, maxX: item.lat, maxY: item.lon };
46119 exports.GeoRBush = GeoRBush;
46120 exports.default = GeoRBush;
46122 },{"rbush":42}],418:[function(require,module,exports){
46124 Object.defineProperty(exports, "__esModule", { value: true });
46125 exports.segmentIntersection = exports.segmentsIntersect = void 0;
46127 return n > 0 ? 1 : n < 0 ? -1 : 0;
46129 function colinearPointOnSegment(p, s) {
46130 return p.x <= Math.max(s.p1.x, s.p2.x) &&
46131 p.x >= Math.min(s.p1.x, s.p2.x) &&
46132 p.y >= Math.max(s.p1.y, s.p2.y) &&
46133 p.y >= Math.min(s.p1.y, s.p2.y);
46135 function parallel(s1, s2) {
46136 var ux = s1.p2.x - s1.p1.x;
46137 var uy = s1.p2.y - s1.p1.y;
46138 var vx = s2.p2.x - s2.p1.x;
46139 var vy = s2.p2.y - s2.p1.y;
46140 var cross = ux * vy - uy * vx;
46141 var u2 = ux * ux + uy * uy;
46142 var v2 = vx * vx + vy * vy;
46143 var epsilon2 = 1e-10;
46144 return cross * cross < epsilon2 * u2 * v2;
46146 function tripletOrientation(p1, p2, p3) {
46147 var orientation = (p2.y - p1.y) * (p3.x - p2.x) -
46148 (p3.y - p2.y) * (p2.x - p1.x);
46149 return sign(orientation);
46151 function segmentsIntersect(s1, s2) {
46152 if (parallel(s1, s2)) {
46155 var o1 = tripletOrientation(s1.p1, s1.p2, s2.p1);
46156 var o2 = tripletOrientation(s1.p1, s1.p2, s2.p2);
46157 var o3 = tripletOrientation(s2.p1, s2.p2, s1.p1);
46158 var o4 = tripletOrientation(s2.p1, s2.p2, s1.p2);
46159 if (o1 !== o2 && o3 !== o4) {
46162 if (o1 === 0 && colinearPointOnSegment(s2.p1, s1)) {
46165 if (o2 === 0 && colinearPointOnSegment(s2.p2, s1)) {
46168 if (o3 === 0 && colinearPointOnSegment(s1.p1, s2)) {
46171 if (o4 === 0 && colinearPointOnSegment(s1.p2, s2)) {
46176 exports.segmentsIntersect = segmentsIntersect;
46177 function segmentIntersection(s1, s2) {
46178 if (parallel(s1, s2)) {
46189 var den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
46190 var xNum = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
46191 var yNum = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
46192 return { x: xNum / den, y: yNum / den };
46194 exports.segmentIntersection = segmentIntersection;
46196 },{}],419:[function(require,module,exports){
46198 Object.defineProperty(exports, "__esModule", { value: true });
46199 exports.Spatial = void 0;
46200 var THREE = require("three");
46204 * @classdesc Provides methods for scalar, vector and matrix calculations.
46206 var Spatial = /** @class */ (function () {
46207 function Spatial() {
46208 this._epsilon = 1e-9;
46211 * Converts azimuthal phi rotation (counter-clockwise with origin on X-axis) to
46212 * bearing (clockwise with origin at north or Y-axis).
46214 * @param {number} phi - Azimuthal phi angle in radians.
46215 * @returns {number} Bearing in radians.
46217 Spatial.prototype.azimuthalToBearing = function (phi) {
46218 return -phi + Math.PI / 2;
46221 * Converts degrees to radians.
46223 * @param {number} deg - Degrees.
46224 * @returns {number} Radians.
46226 Spatial.prototype.degToRad = function (deg) {
46227 return Math.PI * deg / 180;
46230 * Converts radians to degrees.
46232 * @param {number} rad - Radians.
46233 * @returns {number} Degrees.
46235 Spatial.prototype.radToDeg = function (rad) {
46236 return 180 * rad / Math.PI;
46239 * Creates a rotation matrix from an angle-axis vector.
46241 * @param {Array<number>} angleAxis - Angle-axis representation of a rotation.
46242 * @returns {THREE.Matrix4} Rotation matrix.
46244 Spatial.prototype.rotationMatrix = function (angleAxis) {
46245 var axis = new THREE.Vector3(angleAxis[0], angleAxis[1], angleAxis[2]);
46246 var angle = axis.length();
46250 return new THREE.Matrix4().makeRotationAxis(axis, angle);
46253 * Rotates a vector according to a angle-axis rotation vector.
46255 * @param {Array<number>} vector - Vector to rotate.
46256 * @param {Array<number>} angleAxis - Angle-axis representation of a rotation.
46257 * @returns {THREE.Vector3} Rotated vector.
46259 Spatial.prototype.rotate = function (vector, angleAxis) {
46260 var v = new THREE.Vector3(vector[0], vector[1], vector[2]);
46261 var rotationMatrix = this.rotationMatrix(angleAxis);
46262 v.applyMatrix4(rotationMatrix);
46266 * Calculates the optical center from a rotation vector
46267 * on the angle-axis representation and a translation vector
46268 * according to C = -R^T t.
46270 * @param {Array<number>} rotation - Angle-axis representation of a rotation.
46271 * @param {Array<number>} translation - Translation vector.
46272 * @returns {THREE.Vector3} Optical center.
46274 Spatial.prototype.opticalCenter = function (rotation, translation) {
46275 var angleAxis = [-rotation[0], -rotation[1], -rotation[2]];
46276 var vector = [-translation[0], -translation[1], -translation[2]];
46277 return this.rotate(vector, angleAxis);
46280 * Calculates the viewing direction from a rotation vector
46281 * on the angle-axis representation.
46283 * @param {number[]} rotation - Angle-axis representation of a rotation.
46284 * @returns {THREE.Vector3} Viewing direction.
46286 Spatial.prototype.viewingDirection = function (rotation) {
46287 var angleAxis = [-rotation[0], -rotation[1], -rotation[2]];
46288 return this.rotate([0, 0, 1], angleAxis);
46291 * Wrap a number on the interval [min, max].
46293 * @param {number} value - Value to wrap.
46294 * @param {number} min - Lower endpoint of interval.
46295 * @param {number} max - Upper endpoint of interval.
46296 * @returns {number} The wrapped number.
46298 Spatial.prototype.wrap = function (value, min, max) {
46300 throw new Error("Invalid arguments: max must be larger than min.");
46302 var interval = (max - min);
46303 while (value > max || value < min) {
46305 value = value - interval;
46307 else if (value < min) {
46308 value = value + interval;
46314 * Wrap an angle on the interval [-Pi, Pi].
46316 * @param {number} angle - Value to wrap.
46317 * @returns {number} Wrapped angle.
46319 Spatial.prototype.wrapAngle = function (angle) {
46320 return this.wrap(angle, -Math.PI, Math.PI);
46323 * Limit the value to the interval [min, max] by changing the value to
46324 * the nearest available one when it is outside the interval.
46326 * @param {number} value - Value to clamp.
46327 * @param {number} min - Minimum of the interval.
46328 * @param {number} max - Maximum of the interval.
46329 * @returns {number} Clamped value.
46331 Spatial.prototype.clamp = function (value, min, max) {
46341 * Calculates the counter-clockwise angle from the first
46342 * vector (x1, y1)^T to the second (x2, y2)^T.
46344 * @param {number} x1 - X coordinate of first vector.
46345 * @param {number} y1 - Y coordinate of first vector.
46346 * @param {number} x2 - X coordinate of second vector.
46347 * @param {number} y2 - Y coordinate of second vector.
46348 * @returns {number} Counter clockwise angle between the vectors.
46350 Spatial.prototype.angleBetweenVector2 = function (x1, y1, x2, y2) {
46351 var angle = Math.atan2(y2, x2) - Math.atan2(y1, x1);
46352 return this.wrapAngle(angle);
46355 * Calculates the minimum (absolute) angle change for rotation
46356 * from one angle to another on the [-Pi, Pi] interval.
46358 * @param {number} angle1 - Start angle.
46359 * @param {number} angle2 - Destination angle.
46360 * @returns {number} Absolute angle change between angles.
46362 Spatial.prototype.angleDifference = function (angle1, angle2) {
46363 var angle = angle2 - angle1;
46364 return this.wrapAngle(angle);
46367 * Calculates the relative rotation angle between two
46368 * angle-axis vectors.
46370 * @param {number} rotation1 - First angle-axis vector.
46371 * @param {number} rotation2 - Second angle-axis vector.
46372 * @returns {number} Relative rotation angle.
46374 Spatial.prototype.relativeRotationAngle = function (rotation1, rotation2) {
46375 var R1T = this.rotationMatrix([-rotation1[0], -rotation1[1], -rotation1[2]]);
46376 var R2 = this.rotationMatrix(rotation2);
46377 var R = R1T.multiply(R2);
46378 var elements = R.elements;
46379 // from Tr(R) = 1 + 2 * cos(theta)
46380 var tr = elements[0] + elements[5] + elements[10];
46381 var theta = Math.acos(Math.max(Math.min((tr - 1) / 2, 1), -1));
46385 * Calculates the angle from a vector to a plane.
46387 * @param {Array<number>} vector - The vector.
46388 * @param {Array<number>} planeNormal - Normal of the plane.
46389 * @returns {number} Angle from between plane and vector.
46391 Spatial.prototype.angleToPlane = function (vector, planeNormal) {
46392 var v = new THREE.Vector3().fromArray(vector);
46393 var norm = v.length();
46394 if (norm < this._epsilon) {
46397 var projection = v.dot(new THREE.Vector3().fromArray(planeNormal));
46398 return Math.asin(projection / norm);
46400 Spatial.prototype.azimuthal = function (direction, up) {
46401 var directionVector = new THREE.Vector3().fromArray(direction);
46402 var upVector = new THREE.Vector3().fromArray(up);
46403 var upProjection = directionVector.clone().dot(upVector);
46404 var planeProjection = directionVector.clone().sub(upVector.clone().multiplyScalar(upProjection));
46405 return Math.atan2(planeProjection.y, planeProjection.x);
46408 * Calculates the distance between two coordinates
46409 * (latitude longitude pairs) in meters according to
46410 * the haversine formula.
46412 * @param {number} lat1 - Latitude of the first coordinate in degrees.
46413 * @param {number} lon1 - Longitude of the first coordinate in degrees.
46414 * @param {number} lat2 - Latitude of the second coordinate in degrees.
46415 * @param {number} lon2 - Longitude of the second coordinate in degrees.
46416 * @returns {number} Distance between lat lon positions in meters.
46418 Spatial.prototype.distanceFromLatLon = function (lat1, lon1, lat2, lon2) {
46420 var dLat = this.degToRad(lat2 - lat1);
46421 var dLon = this.degToRad(lon2 - lon1);
46422 var hav = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
46423 Math.cos(this.degToRad(lat1)) * Math.cos(this.degToRad(lat2)) *
46424 Math.sin(dLon / 2) * Math.sin(dLon / 2);
46425 var d = 2 * r * Math.atan2(Math.sqrt(hav), Math.sqrt(1 - hav));
46430 exports.Spatial = Spatial;
46431 exports.default = Spatial;
46433 },{"three":242}],420:[function(require,module,exports){
46435 Object.defineProperty(exports, "__esModule", { value: true });
46436 exports.Transform = void 0;
46437 var THREE = require("three");
46441 * @classdesc Class used for calculating coordinate transformations
46444 var Transform = /** @class */ (function () {
46446 * Create a new transform instance.
46447 * @param {number} orientation - Image orientation.
46448 * @param {number} width - Image height.
46449 * @param {number} height - Image width.
46450 * @param {number} focal - Focal length.
46451 * @param {number} scale - Atomic scale.
46452 * @param {IGPano} gpano - Panorama properties.
46453 * @param {Array<number>} rotation - Rotation vector in three dimensions.
46454 * @param {Array<number>} translation - Translation vector in three dimensions.
46455 * @param {HTMLImageElement} image - Image for fallback size calculations.
46457 function Transform(orientation, width, height, focal, scale, gpano, rotation, translation, image, textureScale, ck1, ck2, cameraProjection) {
46458 this._orientation = this._getValue(orientation, 1);
46459 var imageWidth = image != null ? image.width : 4;
46460 var imageHeight = image != null ? image.height : 3;
46461 var keepOrientation = this._orientation < 5;
46462 this._width = this._getValue(width, keepOrientation ? imageWidth : imageHeight);
46463 this._height = this._getValue(height, keepOrientation ? imageHeight : imageWidth);
46464 this._basicAspect = keepOrientation ?
46465 this._width / this._height :
46466 this._height / this._width;
46467 this._basicWidth = keepOrientation ? width : height;
46468 this._basicHeight = keepOrientation ? height : width;
46469 this._focal = this._getValue(focal, 1);
46470 this._scale = this._getValue(scale, 0);
46471 this._gpano = gpano != null ? gpano : null;
46472 this._rt = this._getRt(rotation, translation);
46473 this._srt = this._getSrt(this._rt, this._scale);
46474 this._basicRt = this._getBasicRt(this._rt, orientation);
46475 this._textureScale = !!textureScale ? textureScale : [1, 1];
46476 this._ck1 = !!ck1 ? ck1 : 0;
46477 this._ck2 = !!ck2 ? ck2 : 0;
46478 this._cameraProjection = !!cameraProjection ?
46481 "equirectangular" :
46483 this._radialPeak = this._getRadialPeak(this._ck1, this._ck2);
46485 Object.defineProperty(Transform.prototype, "ck1", {
46492 Object.defineProperty(Transform.prototype, "ck2", {
46499 Object.defineProperty(Transform.prototype, "cameraProjection", {
46501 return this._cameraProjection;
46506 Object.defineProperty(Transform.prototype, "basicAspect", {
46508 * Get basic aspect.
46509 * @returns {number} The orientation adjusted aspect ratio.
46512 return this._basicAspect;
46517 Object.defineProperty(Transform.prototype, "basicHeight", {
46519 * Get basic height.
46521 * @description Does not fall back to node image height but
46522 * uses original value from API so can be faulty.
46524 * @returns {number} The height of the basic version image
46525 * (adjusted for orientation).
46528 return this._basicHeight;
46533 Object.defineProperty(Transform.prototype, "basicRt", {
46535 return this._basicRt;
46540 Object.defineProperty(Transform.prototype, "basicWidth", {
46544 * @description Does not fall back to node image width but
46545 * uses original value from API so can be faulty.
46547 * @returns {number} The width of the basic version image
46548 * (adjusted for orientation).
46551 return this._basicWidth;
46556 Object.defineProperty(Transform.prototype, "focal", {
46559 * @returns {number} The node focal length.
46562 return this._focal;
46567 Object.defineProperty(Transform.prototype, "fullPano", {
46571 * @returns {boolean} Value indicating whether the node is a complete
46575 return this._gpano != null &&
46576 this._gpano.CroppedAreaLeftPixels === 0 &&
46577 this._gpano.CroppedAreaTopPixels === 0 &&
46578 this._gpano.CroppedAreaImageWidthPixels === this._gpano.FullPanoWidthPixels &&
46579 this._gpano.CroppedAreaImageHeightPixels === this._gpano.FullPanoHeightPixels;
46584 Object.defineProperty(Transform.prototype, "gpano", {
46587 * @returns {number} The node gpano information.
46590 return this._gpano;
46595 Object.defineProperty(Transform.prototype, "height", {
46599 * @description Falls back to the node image height if
46600 * the API data is faulty.
46602 * @returns {number} The orientation adjusted image height.
46605 return this._height;
46610 Object.defineProperty(Transform.prototype, "orientation", {
46613 * @returns {number} The image orientation.
46616 return this._orientation;
46621 Object.defineProperty(Transform.prototype, "rt", {
46624 * @returns {THREE.Matrix4} The extrinsic camera matrix.
46632 Object.defineProperty(Transform.prototype, "srt", {
46635 * @returns {THREE.Matrix4} The scaled extrinsic camera matrix.
46643 Object.defineProperty(Transform.prototype, "scale", {
46646 * @returns {number} The node atomic reconstruction scale.
46649 return this._scale;
46654 Object.defineProperty(Transform.prototype, "hasValidScale", {
46656 * Get has valid scale.
46657 * @returns {boolean} Value indicating if the scale of the transform is valid.
46660 return this._scale > 1e-2 && this._scale < 50;
46665 Object.defineProperty(Transform.prototype, "radialPeak", {
46668 * @returns {number} Value indicating the radius where the radial
46669 * undistortion function peaks.
46672 return this._radialPeak;
46677 Object.defineProperty(Transform.prototype, "width", {
46681 * @description Falls back to the node image width if
46682 * the API data is faulty.
46684 * @returns {number} The orientation adjusted image width.
46687 return this._width;
46693 * Calculate the up vector for the node transform.
46695 * @returns {THREE.Vector3} Normalized and orientation adjusted up vector.
46697 Transform.prototype.upVector = function () {
46698 var rte = this._rt.elements;
46699 switch (this._orientation) {
46701 return new THREE.Vector3(-rte[1], -rte[5], -rte[9]);
46703 return new THREE.Vector3(rte[1], rte[5], rte[9]);
46705 return new THREE.Vector3(-rte[0], -rte[4], -rte[8]);
46707 return new THREE.Vector3(rte[0], rte[4], rte[8]);
46709 return new THREE.Vector3(-rte[1], -rte[5], -rte[9]);
46713 * Calculate projector matrix for projecting 3D points to texture map
46714 * coordinates (u and v).
46716 * @returns {THREE.Matrix4} Projection matrix for 3D point to texture
46717 * map coordinate calculations.
46719 Transform.prototype.projectorMatrix = function () {
46720 var projector = this._normalizedToTextureMatrix();
46721 var f = this._focal;
46722 var projection = new THREE.Matrix4().set(f, 0, 0, 0, 0, f, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0);
46723 projector.multiply(projection);
46724 projector.multiply(this._rt);
46728 * Project 3D world coordinates to basic coordinates.
46730 * @param {Array<number>} point3d - 3D world coordinates.
46731 * @return {Array<number>} 2D basic coordinates.
46733 Transform.prototype.projectBasic = function (point3d) {
46734 var sfm = this.projectSfM(point3d);
46735 return this._sfmToBasic(sfm);
46738 * Unproject basic coordinates to 3D world coordinates.
46740 * @param {Array<number>} basic - 2D basic coordinates.
46741 * @param {Array<number>} distance - Distance to unproject from camera center.
46742 * @param {boolean} [depth] - Treat the distance value as depth from camera center.
46743 * Only applicable for perspective images. Will be
46744 * ignored for panoramas.
46745 * @returns {Array<number>} Unprojected 3D world coordinates.
46747 Transform.prototype.unprojectBasic = function (basic, distance, depth) {
46748 var sfm = this._basicToSfm(basic);
46749 return this.unprojectSfM(sfm, distance, depth);
46752 * Project 3D world coordinates to SfM coordinates.
46754 * @param {Array<number>} point3d - 3D world coordinates.
46755 * @return {Array<number>} 2D SfM coordinates.
46757 Transform.prototype.projectSfM = function (point3d) {
46758 var v = new THREE.Vector4(point3d[0], point3d[1], point3d[2], 1);
46759 v.applyMatrix4(this._rt);
46760 return this._bearingToSfm([v.x, v.y, v.z]);
46763 * Unproject SfM coordinates to a 3D world coordinates.
46765 * @param {Array<number>} sfm - 2D SfM coordinates.
46766 * @param {Array<number>} distance - Distance to unproject from camera center.
46767 * @param {boolean} [depth] - Treat the distance value as depth from camera center.
46768 * Only applicable for perspective images. Will be
46769 * ignored for panoramas.
46770 * @returns {Array<number>} Unprojected 3D world coordinates.
46772 Transform.prototype.unprojectSfM = function (sfm, distance, depth) {
46773 var bearing = this._sfmToBearing(sfm);
46774 var v = depth && !this.gpano ?
46775 new THREE.Vector4(distance * bearing[0] / bearing[2], distance * bearing[1] / bearing[2], distance, 1) :
46776 new THREE.Vector4(distance * bearing[0], distance * bearing[1], distance * bearing[2], 1);
46777 v.applyMatrix4(new THREE.Matrix4().getInverse(this._rt));
46778 return [v.x / v.w, v.y / v.w, v.z / v.w];
46781 * Transform SfM coordinates to bearing vector (3D cartesian
46782 * coordinates on the unit sphere).
46784 * @param {Array<number>} sfm - 2D SfM coordinates.
46785 * @returns {Array<number>} Bearing vector (3D cartesian coordinates
46786 * on the unit sphere).
46788 Transform.prototype._sfmToBearing = function (sfm) {
46789 if (this._fullPano()) {
46790 var lon = sfm[0] * 2 * Math.PI;
46791 var lat = -sfm[1] * 2 * Math.PI;
46792 var x = Math.cos(lat) * Math.sin(lon);
46793 var y = -Math.sin(lat);
46794 var z = Math.cos(lat) * Math.cos(lon);
46797 else if (this._gpano) {
46798 var size = Math.max(this.gpano.CroppedAreaImageWidthPixels, this.gpano.CroppedAreaImageHeightPixels);
46799 var fullPanoPixel = [
46800 sfm[0] * size + this.gpano.CroppedAreaImageWidthPixels / 2 + this.gpano.CroppedAreaLeftPixels,
46801 sfm[1] * size + this.gpano.CroppedAreaImageHeightPixels / 2 + this.gpano.CroppedAreaTopPixels,
46803 var lon = 2 * Math.PI * (fullPanoPixel[0] / this.gpano.FullPanoWidthPixels - 0.5);
46804 var lat = -Math.PI * (fullPanoPixel[1] / this.gpano.FullPanoHeightPixels - 0.5);
46805 var x = Math.cos(lat) * Math.sin(lon);
46806 var y = -Math.sin(lat);
46807 var z = Math.cos(lat) * Math.cos(lon);
46810 else if (this._cameraProjection === "fisheye") {
46811 var _a = [sfm[0] / this._focal, sfm[1] / this._focal], dxn = _a[0], dyn = _a[1];
46812 var dTheta = Math.sqrt(dxn * dxn + dyn * dyn);
46813 var d = this._distortionFromDistortedRadius(dTheta, this._ck1, this._ck2, this._radialPeak);
46814 var theta = dTheta / d;
46815 var z = Math.cos(theta);
46816 var r = Math.sin(theta);
46817 var x = r * dxn / dTheta;
46818 var y = r * dyn / dTheta;
46822 var _b = [sfm[0] / this._focal, sfm[1] / this._focal], dxn = _b[0], dyn = _b[1];
46823 var dr = Math.sqrt(dxn * dxn + dyn * dyn);
46824 var d = this._distortionFromDistortedRadius(dr, this._ck1, this._ck2, this._radialPeak);
46827 var v = new THREE.Vector3(xn, yn, 1);
46829 return [v.x, v.y, v.z];
46832 /** Compute distortion given the distorted radius.
46834 * Solves for d in the equation
46835 * y = d(x, k1, k2) * x
46836 * given the distorted radius, y.
46838 Transform.prototype._distortionFromDistortedRadius = function (distortedRadius, k1, k2, radialPeak) {
46840 for (var i = 0; i < 10; i++) {
46841 var radius = distortedRadius / d;
46842 if (radius > radialPeak) {
46843 radius = radialPeak;
46845 d = 1 + k1 * Math.pow(radius, 2) + k2 * Math.pow(radius, 4);
46850 * Transform bearing vector (3D cartesian coordiantes on the unit sphere) to
46853 * @param {Array<number>} bearing - Bearing vector (3D cartesian coordinates on the
46855 * @returns {Array<number>} 2D SfM coordinates.
46857 Transform.prototype._bearingToSfm = function (bearing) {
46858 if (this._fullPano()) {
46859 var x = bearing[0];
46860 var y = bearing[1];
46861 var z = bearing[2];
46862 var lon = Math.atan2(x, z);
46863 var lat = Math.atan2(-y, Math.sqrt(x * x + z * z));
46864 return [lon / (2 * Math.PI), -lat / (2 * Math.PI)];
46866 else if (this._gpano) {
46867 var x = bearing[0];
46868 var y = bearing[1];
46869 var z = bearing[2];
46870 var lon = Math.atan2(x, z);
46871 var lat = Math.atan2(-y, Math.sqrt(x * x + z * z));
46872 var fullPanoPixel = [
46873 (lon / (2 * Math.PI) + 0.5) * this.gpano.FullPanoWidthPixels,
46874 (-lat / Math.PI + 0.5) * this.gpano.FullPanoHeightPixels,
46876 var size = Math.max(this.gpano.CroppedAreaImageWidthPixels, this.gpano.CroppedAreaImageHeightPixels);
46878 (fullPanoPixel[0] - this.gpano.CroppedAreaLeftPixels - this.gpano.CroppedAreaImageWidthPixels / 2) / size,
46879 (fullPanoPixel[1] - this.gpano.CroppedAreaTopPixels - this.gpano.CroppedAreaImageHeightPixels / 2) / size,
46882 else if (this._cameraProjection === "fisheye") {
46883 if (bearing[2] > 0) {
46884 var x = bearing[0], y = bearing[1], z = bearing[2];
46885 var r = Math.sqrt(x * x + y * y);
46886 var theta = Math.atan2(r, z);
46887 if (theta > this._radialPeak) {
46888 theta = this._radialPeak;
46890 var distortion = 1.0 + Math.pow(theta, 2) * (this._ck1 + Math.pow(theta, 2) * this._ck2);
46891 var s = this._focal * distortion * theta / r;
46892 return [s * x, s * y];
46896 bearing[0] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
46897 bearing[1] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
46902 if (bearing[2] > 0) {
46903 var _a = [bearing[0] / bearing[2], bearing[1] / bearing[2]], xn = _a[0], yn = _a[1];
46904 var r2 = xn * xn + yn * yn;
46905 var rp2 = Math.pow(this._radialPeak, 2);
46909 var d = 1 + this._ck1 * r2 + this._ck2 * Math.pow(r2, 2);
46911 this._focal * d * xn,
46912 this._focal * d * yn,
46917 bearing[0] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
46918 bearing[1] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
46924 * Convert basic coordinates to SfM coordinates.
46926 * @param {Array<number>} basic - 2D basic coordinates.
46927 * @returns {Array<number>} 2D SfM coordinates.
46929 Transform.prototype._basicToSfm = function (basic) {
46932 switch (this._orientation) {
46934 rotatedX = basic[0];
46935 rotatedY = basic[1];
46938 rotatedX = 1 - basic[0];
46939 rotatedY = 1 - basic[1];
46942 rotatedX = basic[1];
46943 rotatedY = 1 - basic[0];
46946 rotatedX = 1 - basic[1];
46947 rotatedY = basic[0];
46950 rotatedX = basic[0];
46951 rotatedY = basic[1];
46954 var w = this._width;
46955 var h = this._height;
46956 var s = Math.max(w, h);
46957 var sfmX = rotatedX * w / s - w / s / 2;
46958 var sfmY = rotatedY * h / s - h / s / 2;
46959 return [sfmX, sfmY];
46962 * Convert SfM coordinates to basic coordinates.
46964 * @param {Array<number>} sfm - 2D SfM coordinates.
46965 * @returns {Array<number>} 2D basic coordinates.
46967 Transform.prototype._sfmToBasic = function (sfm) {
46968 var w = this._width;
46969 var h = this._height;
46970 var s = Math.max(w, h);
46971 var rotatedX = (sfm[0] + w / s / 2) / w * s;
46972 var rotatedY = (sfm[1] + h / s / 2) / h * s;
46975 switch (this._orientation) {
46981 basicX = 1 - rotatedX;
46982 basicY = 1 - rotatedY;
46985 basicX = 1 - rotatedY;
46990 basicY = 1 - rotatedX;
46997 return [basicX, basicY];
47000 * Determines if the gpano information indicates a full panorama.
47002 * @returns {boolean} Value determining if the gpano information indicates
47005 Transform.prototype._fullPano = function () {
47006 return this.gpano != null &&
47007 this.gpano.CroppedAreaLeftPixels === 0 &&
47008 this.gpano.CroppedAreaTopPixels === 0 &&
47009 this.gpano.CroppedAreaImageWidthPixels === this.gpano.FullPanoWidthPixels &&
47010 this.gpano.CroppedAreaImageHeightPixels === this.gpano.FullPanoHeightPixels;
47013 * Checks a value and returns it if it exists and is larger than 0.
47014 * Fallbacks if it is null.
47016 * @param {number} value - Value to check.
47017 * @param {number} fallback - Value to fall back to.
47018 * @returns {number} The value or its fallback value if it is not defined or negative.
47020 Transform.prototype._getValue = function (value, fallback) {
47021 return value != null && value > 0 ? value : fallback;
47024 * Creates the extrinsic camera matrix [ R | t ].
47026 * @param {Array<number>} rotation - Rotation vector in angle axis representation.
47027 * @param {Array<number>} translation - Translation vector.
47028 * @returns {THREE.Matrix4} Extrisic camera matrix.
47030 Transform.prototype._getRt = function (rotation, translation) {
47031 var axis = new THREE.Vector3(rotation[0], rotation[1], rotation[2]);
47032 var angle = axis.length();
47036 var rt = new THREE.Matrix4();
47037 rt.makeRotationAxis(axis, angle);
47038 rt.setPosition(new THREE.Vector3(translation[0], translation[1], translation[2]));
47042 * Calculates the scaled extrinsic camera matrix scale * [ R | t ].
47044 * @param {THREE.Matrix4} rt - Extrisic camera matrix.
47045 * @param {number} scale - Scale factor.
47046 * @returns {THREE.Matrix4} Scaled extrisic camera matrix.
47048 Transform.prototype._getSrt = function (rt, scale) {
47049 var srt = rt.clone();
47050 var elements = srt.elements;
47051 elements[12] = scale * elements[12];
47052 elements[13] = scale * elements[13];
47053 elements[14] = scale * elements[14];
47054 srt.scale(new THREE.Vector3(scale, scale, scale));
47057 Transform.prototype._getBasicRt = function (rt, orientation) {
47058 var axis = new THREE.Vector3(0, 0, 1);
47060 switch (orientation) {
47065 angle = Math.PI / 2;
47068 angle = 3 * Math.PI / 2;
47073 return new THREE.Matrix4()
47074 .makeRotationAxis(axis, angle)
47077 Transform.prototype._getRadialPeak = function (k1, k2) {
47081 var d = Math.pow(b, 2) - 4 * a * c;
47085 var root1 = (-b - Math.sqrt(d)) / 2 / a;
47086 var root2 = (-b + Math.sqrt(d)) / 2 / a;
47087 var minRoot = Math.min(root1, root2);
47088 var maxRoot = Math.max(root1, root2);
47089 return minRoot > 0 ?
47090 Math.sqrt(minRoot) :
47092 Math.sqrt(maxRoot) :
47096 * Calculate a transformation matrix from normalized coordinates for
47097 * texture map coordinates.
47099 * @returns {THREE.Matrix4} Normalized coordinates to texture map
47100 * coordinates transformation matrix.
47102 Transform.prototype._normalizedToTextureMatrix = function () {
47103 var size = Math.max(this._width, this._height);
47104 var scaleX = this._orientation < 5 ? this._textureScale[0] : this._textureScale[1];
47105 var scaleY = this._orientation < 5 ? this._textureScale[1] : this._textureScale[0];
47106 var w = size / this._width * scaleX;
47107 var h = size / this._height * scaleY;
47108 switch (this._orientation) {
47110 return new THREE.Matrix4().set(w, 0, 0, 0.5, 0, -h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
47112 return new THREE.Matrix4().set(-w, 0, 0, 0.5, 0, h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
47114 return new THREE.Matrix4().set(0, -h, 0, 0.5, -w, 0, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
47116 return new THREE.Matrix4().set(0, h, 0, 0.5, w, 0, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
47118 return new THREE.Matrix4().set(w, 0, 0, 0.5, 0, -h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
47123 exports.Transform = Transform;
47125 },{"three":242}],421:[function(require,module,exports){
47127 Object.defineProperty(exports, "__esModule", { value: true });
47128 exports.ViewportCoords = void 0;
47129 var THREE = require("three");
47131 * @class ViewportCoords
47133 * @classdesc Provides methods for calculating 2D coordinate conversions
47134 * as well as 3D projection and unprojection.
47136 * Basic coordinates are 2D coordinates on the [0, 1] interval and
47137 * have the origin point, (0, 0), at the top left corner and the
47138 * maximum value, (1, 1), at the bottom right corner of the original
47141 * Viewport coordinates are 2D coordinates on the [-1, 1] interval and
47142 * have the origin point in the center. The bottom left corner point is
47143 * (-1, -1) and the top right corner point is (1, 1).
47145 * Canvas coordiantes are 2D pixel coordinates on the [0, canvasWidth] and
47146 * [0, canvasHeight] intervals. The origin point (0, 0) is in the top left
47147 * corner and the maximum value is (canvasWidth, canvasHeight) is in the
47148 * bottom right corner.
47150 * 3D coordinates are in the topocentric world reference frame.
47152 var ViewportCoords = /** @class */ (function () {
47153 function ViewportCoords() {
47154 this._unprojectDepth = 200;
47157 * Convert basic coordinates to canvas coordinates.
47159 * @description Transform origin and camera position needs to be the
47160 * equal for reliable return value.
47162 * @param {number} basicX - Basic X coordinate.
47163 * @param {number} basicY - Basic Y coordinate.
47164 * @param {HTMLElement} container - The viewer container.
47165 * @param {Transform} transform - Transform of the node to unproject from.
47166 * @param {THREE.Camera} camera - Camera used in rendering.
47167 * @returns {Array<number>} 2D canvas coordinates.
47169 ViewportCoords.prototype.basicToCanvas = function (basicX, basicY, container, transform, camera) {
47170 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
47171 var canvas = this.projectToCanvas(point3d, container, camera);
47175 * Convert basic coordinates to canvas coordinates safely. If 3D point is
47176 * behind camera null will be returned.
47178 * @description Transform origin and camera position needs to be the
47179 * equal for reliable return value.
47181 * @param {number} basicX - Basic X coordinate.
47182 * @param {number} basicY - Basic Y coordinate.
47183 * @param {HTMLElement} container - The viewer container.
47184 * @param {Transform} transform - Transform of the node to unproject from.
47185 * @param {THREE.Camera} camera - Camera used in rendering.
47186 * @returns {Array<number>} 2D canvas coordinates if the basic point represents a 3D point
47187 * in front of the camera, otherwise null.
47189 ViewportCoords.prototype.basicToCanvasSafe = function (basicX, basicY, container, transform, camera) {
47190 var viewport = this.basicToViewportSafe(basicX, basicY, transform, camera);
47191 if (viewport === null) {
47194 var canvas = this.viewportToCanvas(viewport[0], viewport[1], container);
47198 * Convert basic coordinates to viewport coordinates.
47200 * @description Transform origin and camera position needs to be the
47201 * equal for reliable return value.
47203 * @param {number} basicX - Basic X coordinate.
47204 * @param {number} basicY - Basic Y coordinate.
47205 * @param {Transform} transform - Transform of the node to unproject from.
47206 * @param {THREE.Camera} camera - Camera used in rendering.
47207 * @returns {Array<number>} 2D viewport coordinates.
47209 ViewportCoords.prototype.basicToViewport = function (basicX, basicY, transform, camera) {
47210 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
47211 var viewport = this.projectToViewport(point3d, camera);
47215 * Convert basic coordinates to viewport coordinates safely. If 3D point is
47216 * behind camera null will be returned.
47218 * @description Transform origin and camera position needs to be the
47219 * equal for reliable return value.
47221 * @param {number} basicX - Basic X coordinate.
47222 * @param {number} basicY - Basic Y coordinate.
47223 * @param {Transform} transform - Transform of the node to unproject from.
47224 * @param {THREE.Camera} camera - Camera used in rendering.
47225 * @returns {Array<number>} 2D viewport coordinates.
47227 ViewportCoords.prototype.basicToViewportSafe = function (basicX, basicY, transform, camera) {
47228 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
47229 var pointCamera = this.worldToCamera(point3d, camera);
47230 if (pointCamera[2] > 0) {
47233 var viewport = this.projectToViewport(point3d, camera);
47237 * Convert camera 3D coordinates to viewport coordinates.
47239 * @param {number} pointCamera - 3D point in camera coordinate system.
47240 * @param {THREE.Camera} camera - Camera used in rendering.
47241 * @returns {Array<number>} 2D viewport coordinates.
47243 ViewportCoords.prototype.cameraToViewport = function (pointCamera, camera) {
47244 var viewport = new THREE.Vector3().fromArray(pointCamera)
47245 .applyMatrix4(camera.projectionMatrix);
47246 return [viewport.x, viewport.y];
47249 * Get canvas pixel position from event.
47251 * @param {Event} event - Event containing clientX and clientY properties.
47252 * @param {HTMLElement} element - HTML element.
47253 * @returns {Array<number>} 2D canvas coordinates.
47255 ViewportCoords.prototype.canvasPosition = function (event, element) {
47256 var clientRect = element.getBoundingClientRect();
47257 var canvasX = event.clientX - clientRect.left - element.clientLeft;
47258 var canvasY = event.clientY - clientRect.top - element.clientTop;
47259 return [canvasX, canvasY];
47262 * Convert canvas coordinates to basic coordinates.
47264 * @description Transform origin and camera position needs to be the
47265 * equal for reliable return value.
47267 * @param {number} canvasX - Canvas X coordinate.
47268 * @param {number} canvasY - Canvas Y coordinate.
47269 * @param {HTMLElement} container - The viewer container.
47270 * @param {Transform} transform - Transform of the node to unproject from.
47271 * @param {THREE.Camera} camera - Camera used in rendering.
47272 * @returns {Array<number>} 2D basic coordinates.
47274 ViewportCoords.prototype.canvasToBasic = function (canvasX, canvasY, container, transform, camera) {
47275 var point3d = this.unprojectFromCanvas(canvasX, canvasY, container, camera)
47277 var basic = transform.projectBasic(point3d);
47281 * Convert canvas coordinates to viewport coordinates.
47283 * @param {number} canvasX - Canvas X coordinate.
47284 * @param {number} canvasY - Canvas Y coordinate.
47285 * @param {HTMLElement} container - The viewer container.
47286 * @returns {Array<number>} 2D viewport coordinates.
47288 ViewportCoords.prototype.canvasToViewport = function (canvasX, canvasY, container) {
47289 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
47290 var viewportX = 2 * canvasX / canvasWidth - 1;
47291 var viewportY = 1 - 2 * canvasY / canvasHeight;
47292 return [viewportX, viewportY];
47295 * Determines the width and height of the container in canvas coordinates.
47297 * @param {HTMLElement} container - The viewer container.
47298 * @returns {Array<number>} 2D canvas coordinates.
47300 ViewportCoords.prototype.containerToCanvas = function (container) {
47301 return [container.offsetWidth, container.offsetHeight];
47304 * Determine basic distances from image to canvas corners.
47306 * @description Transform origin and camera position needs to be the
47307 * equal for reliable return value.
47309 * Determines the smallest basic distance for every side of the canvas.
47311 * @param {Transform} transform - Transform of the node to unproject from.
47312 * @param {THREE.Camera} camera - Camera used in rendering.
47313 * @returns {Array<number>} Array of basic distances as [top, right, bottom, left].
47315 ViewportCoords.prototype.getBasicDistances = function (transform, camera) {
47316 var topLeftBasic = this.viewportToBasic(-1, 1, transform, camera);
47317 var topRightBasic = this.viewportToBasic(1, 1, transform, camera);
47318 var bottomRightBasic = this.viewportToBasic(1, -1, transform, camera);
47319 var bottomLeftBasic = this.viewportToBasic(-1, -1, transform, camera);
47320 var topBasicDistance = 0;
47321 var rightBasicDistance = 0;
47322 var bottomBasicDistance = 0;
47323 var leftBasicDistance = 0;
47324 if (topLeftBasic[1] < 0 && topRightBasic[1] < 0) {
47325 topBasicDistance = topLeftBasic[1] > topRightBasic[1] ?
47329 if (topRightBasic[0] > 1 && bottomRightBasic[0] > 1) {
47330 rightBasicDistance = topRightBasic[0] < bottomRightBasic[0] ?
47331 topRightBasic[0] - 1 :
47332 bottomRightBasic[0] - 1;
47334 if (bottomRightBasic[1] > 1 && bottomLeftBasic[1] > 1) {
47335 bottomBasicDistance = bottomRightBasic[1] < bottomLeftBasic[1] ?
47336 bottomRightBasic[1] - 1 :
47337 bottomLeftBasic[1] - 1;
47339 if (bottomLeftBasic[0] < 0 && topLeftBasic[0] < 0) {
47340 leftBasicDistance = bottomLeftBasic[0] > topLeftBasic[0] ?
47341 -bottomLeftBasic[0] :
47344 return [topBasicDistance, rightBasicDistance, bottomBasicDistance, leftBasicDistance];
47347 * Determine pixel distances from image to canvas corners.
47349 * @description Transform origin and camera position needs to be the
47350 * equal for reliable return value.
47352 * Determines the smallest pixel distance for every side of the canvas.
47354 * @param {HTMLElement} container - The viewer container.
47355 * @param {Transform} transform - Transform of the node to unproject from.
47356 * @param {THREE.Camera} camera - Camera used in rendering.
47357 * @returns {Array<number>} Array of pixel distances as [top, right, bottom, left].
47359 ViewportCoords.prototype.getPixelDistances = function (container, transform, camera) {
47360 var topLeftBasic = this.viewportToBasic(-1, 1, transform, camera);
47361 var topRightBasic = this.viewportToBasic(1, 1, transform, camera);
47362 var bottomRightBasic = this.viewportToBasic(1, -1, transform, camera);
47363 var bottomLeftBasic = this.viewportToBasic(-1, -1, transform, camera);
47364 var topPixelDistance = 0;
47365 var rightPixelDistance = 0;
47366 var bottomPixelDistance = 0;
47367 var leftPixelDistance = 0;
47368 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
47369 if (topLeftBasic[1] < 0 && topRightBasic[1] < 0) {
47370 var basicX = topLeftBasic[1] > topRightBasic[1] ?
47373 var canvas = this.basicToCanvas(basicX, 0, container, transform, camera);
47374 topPixelDistance = canvas[1] > 0 ? canvas[1] : 0;
47376 if (topRightBasic[0] > 1 && bottomRightBasic[0] > 1) {
47377 var basicY = topRightBasic[0] < bottomRightBasic[0] ?
47379 bottomRightBasic[1];
47380 var canvas = this.basicToCanvas(1, basicY, container, transform, camera);
47381 rightPixelDistance = canvas[0] < canvasWidth ? canvasWidth - canvas[0] : 0;
47383 if (bottomRightBasic[1] > 1 && bottomLeftBasic[1] > 1) {
47384 var basicX = bottomRightBasic[1] < bottomLeftBasic[1] ?
47385 bottomRightBasic[0] :
47386 bottomLeftBasic[0];
47387 var canvas = this.basicToCanvas(basicX, 1, container, transform, camera);
47388 bottomPixelDistance = canvas[1] < canvasHeight ? canvasHeight - canvas[1] : 0;
47390 if (bottomLeftBasic[0] < 0 && topLeftBasic[0] < 0) {
47391 var basicY = bottomLeftBasic[0] > topLeftBasic[0] ?
47392 bottomLeftBasic[1] :
47394 var canvas = this.basicToCanvas(0, basicY, container, transform, camera);
47395 leftPixelDistance = canvas[0] > 0 ? canvas[0] : 0;
47397 return [topPixelDistance, rightPixelDistance, bottomPixelDistance, leftPixelDistance];
47400 * Determine if an event occured inside an element.
47402 * @param {Event} event - Event containing clientX and clientY properties.
47403 * @param {HTMLElement} element - HTML element.
47404 * @returns {boolean} Value indicating if the event occured inside the element or not.
47406 ViewportCoords.prototype.insideElement = function (event, element) {
47407 var clientRect = element.getBoundingClientRect();
47408 var minX = clientRect.left + element.clientLeft;
47409 var maxX = minX + element.clientWidth;
47410 var minY = clientRect.top + element.clientTop;
47411 var maxY = minY + element.clientHeight;
47412 return event.clientX > minX &&
47413 event.clientX < maxX &&
47414 event.clientY > minY &&
47415 event.clientY < maxY;
47418 * Project 3D world coordinates to canvas coordinates.
47420 * @param {Array<number>} point3D - 3D world coordinates.
47421 * @param {HTMLElement} container - The viewer container.
47422 * @param {THREE.Camera} camera - Camera used in rendering.
47423 * @returns {Array<number>} 2D canvas coordinates.
47425 ViewportCoords.prototype.projectToCanvas = function (point3d, container, camera) {
47426 var viewport = this.projectToViewport(point3d, camera);
47427 var canvas = this.viewportToCanvas(viewport[0], viewport[1], container);
47431 * Project 3D world coordinates to canvas coordinates safely. If 3D
47432 * point is behind camera null will be returned.
47434 * @param {Array<number>} point3D - 3D world coordinates.
47435 * @param {HTMLElement} container - The viewer container.
47436 * @param {THREE.Camera} camera - Camera used in rendering.
47437 * @returns {Array<number>} 2D canvas coordinates.
47439 ViewportCoords.prototype.projectToCanvasSafe = function (point3d, container, camera) {
47440 var pointCamera = this.worldToCamera(point3d, camera);
47441 if (pointCamera[2] > 0) {
47444 var viewport = this.projectToViewport(point3d, camera);
47445 var canvas = this.viewportToCanvas(viewport[0], viewport[1], container);
47449 * Project 3D world coordinates to viewport coordinates.
47451 * @param {Array<number>} point3D - 3D world coordinates.
47452 * @param {THREE.Camera} camera - Camera used in rendering.
47453 * @returns {Array<number>} 2D viewport coordinates.
47455 ViewportCoords.prototype.projectToViewport = function (point3d, camera) {
47456 var viewport = new THREE.Vector3(point3d[0], point3d[1], point3d[2])
47458 return [viewport.x, viewport.y];
47461 * Uproject canvas coordinates to 3D world coordinates.
47463 * @param {number} canvasX - Canvas X coordinate.
47464 * @param {number} canvasY - Canvas Y coordinate.
47465 * @param {HTMLElement} container - The viewer container.
47466 * @param {THREE.Camera} camera - Camera used in rendering.
47467 * @returns {Array<number>} 3D world coordinates.
47469 ViewportCoords.prototype.unprojectFromCanvas = function (canvasX, canvasY, container, camera) {
47470 var viewport = this.canvasToViewport(canvasX, canvasY, container);
47471 var point3d = this.unprojectFromViewport(viewport[0], viewport[1], camera);
47475 * Unproject viewport coordinates to 3D world coordinates.
47477 * @param {number} viewportX - Viewport X coordinate.
47478 * @param {number} viewportY - Viewport Y coordinate.
47479 * @param {THREE.Camera} camera - Camera used in rendering.
47480 * @returns {Array<number>} 3D world coordinates.
47482 ViewportCoords.prototype.unprojectFromViewport = function (viewportX, viewportY, camera) {
47483 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
47484 .unproject(camera);
47488 * Convert viewport coordinates to basic coordinates.
47490 * @description Transform origin and camera position needs to be the
47491 * equal for reliable return value.
47493 * @param {number} viewportX - Viewport X coordinate.
47494 * @param {number} viewportY - Viewport Y coordinate.
47495 * @param {Transform} transform - Transform of the node to unproject from.
47496 * @param {THREE.Camera} camera - Camera used in rendering.
47497 * @returns {Array<number>} 2D basic coordinates.
47499 ViewportCoords.prototype.viewportToBasic = function (viewportX, viewportY, transform, camera) {
47500 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
47503 var basic = transform.projectBasic(point3d);
47507 * Convert viewport coordinates to canvas coordinates.
47509 * @param {number} viewportX - Viewport X coordinate.
47510 * @param {number} viewportY - Viewport Y coordinate.
47511 * @param {HTMLElement} container - The viewer container.
47512 * @returns {Array<number>} 2D canvas coordinates.
47514 ViewportCoords.prototype.viewportToCanvas = function (viewportX, viewportY, container) {
47515 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
47516 var canvasX = canvasWidth * (viewportX + 1) / 2;
47517 var canvasY = -canvasHeight * (viewportY - 1) / 2;
47518 return [canvasX, canvasY];
47521 * Convert 3D world coordinates to 3D camera coordinates.
47523 * @param {number} point3D - 3D point in world coordinate system.
47524 * @param {THREE.Camera} camera - Camera used in rendering.
47525 * @returns {Array<number>} 3D camera coordinates.
47527 ViewportCoords.prototype.worldToCamera = function (point3d, camera) {
47528 var pointCamera = new THREE.Vector3(point3d[0], point3d[1], point3d[2])
47529 .applyMatrix4(camera.matrixWorldInverse);
47530 return pointCamera.toArray();
47532 return ViewportCoords;
47534 exports.ViewportCoords = ViewportCoords;
47535 exports.default = ViewportCoords;
47538 },{"three":242}],422:[function(require,module,exports){
47540 Object.defineProperty(exports, "__esModule", { value: true });
47542 },{}],423:[function(require,module,exports){
47544 Object.defineProperty(exports, "__esModule", { value: true });
47545 exports.FilterCreator = void 0;
47549 * @classdesc Represents a class for creating node filters. Implementation and
47550 * definitions based on https://github.com/mapbox/feature-filter.
47552 var FilterCreator = /** @class */ (function () {
47553 function FilterCreator() {
47556 * Create a filter from a filter expression.
47558 * @description The following filters are supported:
47575 * @param {FilterExpression} filter - Comparison, set membership or combinding filter
47577 * @returns {FilterFunction} Function taking a node and returning a boolean that
47578 * indicates whether the node passed the test or not.
47580 FilterCreator.prototype.createFilter = function (filter) {
47581 return new Function("node", "return " + this._compile(filter) + ";");
47583 FilterCreator.prototype._compile = function (filter) {
47584 if (filter == null || filter.length <= 1) {
47587 var operator = filter[0];
47588 var operation = operator === "==" ? this._compileComparisonOp("===", filter[1], filter[2], false) :
47589 operator === "!=" ? this._compileComparisonOp("!==", filter[1], filter[2], false) :
47590 operator === ">" ||
47591 operator === ">=" ||
47592 operator === "<" ||
47593 operator === "<=" ? this._compileComparisonOp(operator, filter[1], filter[2], true) :
47594 operator === "in" ?
47595 this._compileInOp(filter[1], filter.slice(2)) :
47596 operator === "!in" ?
47597 this._compileNegation(this._compileInOp(filter[1], filter.slice(2))) :
47598 operator === "all" ? this._compileLogicalOp(filter.slice(1), "&&") :
47600 return "(" + operation + ")";
47602 FilterCreator.prototype._compare = function (a, b) {
47603 return a < b ? -1 : a > b ? 1 : 0;
47605 FilterCreator.prototype._compileComparisonOp = function (operator, property, value, checkType) {
47606 var left = this._compilePropertyReference(property);
47607 var right = JSON.stringify(value);
47608 return (checkType ? "typeof " + left + "===typeof " + right + "&&" : "") + left + operator + right;
47610 FilterCreator.prototype._compileInOp = function (property, values) {
47611 var compare = this._compare;
47612 var left = JSON.stringify(values.sort(compare));
47613 var right = this._compilePropertyReference(property);
47614 return left + ".indexOf(" + right + ")!==-1";
47616 FilterCreator.prototype._compileLogicalOp = function (filters, operator) {
47617 var compile = this._compile.bind(this);
47618 return filters.map(compile).join(operator);
47620 FilterCreator.prototype._compileNegation = function (expression) {
47621 return "!(" + expression + ")";
47623 FilterCreator.prototype._compilePropertyReference = function (property) {
47624 return "node[" + JSON.stringify(property) + "]";
47626 return FilterCreator;
47628 exports.FilterCreator = FilterCreator;
47629 exports.default = FilterCreator;
47631 },{}],424:[function(require,module,exports){
47633 Object.defineProperty(exports, "__esModule", { value: true });
47634 exports.Graph = void 0;
47635 var rxjs_1 = require("rxjs");
47636 var operators_1 = require("rxjs/operators");
47637 var Edge_1 = require("../Edge");
47638 var Error_1 = require("../Error");
47639 var Graph_1 = require("../Graph");
47640 var Geo_1 = require("../Geo");
47644 * @classdesc Represents a graph of nodes with edges.
47646 var Graph = /** @class */ (function () {
47648 * Create a new graph instance.
47650 * @param {APIv3} [apiV3] - API instance for retrieving data.
47651 * @param {rbush.RBush<NodeIndexItem>} [nodeIndex] - Node index for fast spatial retreival.
47652 * @param {GraphCalculator} [graphCalculator] - Instance for graph calculations.
47653 * @param {EdgeCalculator} [edgeCalculator] - Instance for edge calculations.
47654 * @param {FilterCreator} [filterCreator] - Instance for filter creation.
47655 * @param {IGraphConfiguration} [configuration] - Configuration struct.
47657 function Graph(apiV3, nodeIndex, graphCalculator, edgeCalculator, filterCreator, configuration) {
47658 this._apiV3 = apiV3;
47659 this._cachedNodes = {};
47660 this._cachedNodeTiles = {};
47661 this._cachedSequenceNodes = {};
47662 this._cachedSpatialEdges = {};
47663 this._cachedTiles = {};
47664 this._cachingFill$ = {};
47665 this._cachingFull$ = {};
47666 this._cachingSequenceNodes$ = {};
47667 this._cachingSequences$ = {};
47668 this._cachingSpatialArea$ = {};
47669 this._cachingTiles$ = {};
47670 this._changed$ = new rxjs_1.Subject();
47671 this._defaultAlt = 2;
47672 this._edgeCalculator = edgeCalculator != null ? edgeCalculator : new Edge_1.EdgeCalculator();
47673 this._filterCreator = filterCreator != null ? filterCreator : new Graph_1.FilterCreator();
47674 this._filter = this._filterCreator.createFilter(undefined);
47675 this._graphCalculator = graphCalculator != null ? graphCalculator : new Graph_1.GraphCalculator();
47676 this._configuration = configuration != null ?
47680 maxUnusedNodes: 100,
47681 maxUnusedPreStoredNodes: 30,
47682 maxUnusedTiles: 20,
47685 this._nodeIndex = nodeIndex != null ? nodeIndex : new Geo_1.GeoRBush(16);
47686 this._nodeIndexTiles = {};
47687 this._nodeToTile = {};
47688 this._preStored = {};
47689 this._requiredNodeTiles = {};
47690 this._requiredSpatialArea = {};
47691 this._sequences = {};
47692 this._tilePrecision = 7;
47693 this._tileThreshold = 20;
47695 Object.defineProperty(Graph.prototype, "changed$", {
47699 * @returns {Observable<Graph>} Observable emitting
47700 * the graph every time it has changed.
47703 return this._changed$;
47709 * Caches the full node data for all images within a bounding
47712 * @description The node assets are not cached.
47714 * @param {ILatLon} sw - South west corner of bounding box.
47715 * @param {ILatLon} ne - North east corner of bounding box.
47716 * @returns {Observable<Graph>} Observable emitting the full
47717 * nodes in the bounding box.
47719 Graph.prototype.cacheBoundingBox$ = function (sw, ne) {
47721 var cacheTiles$ = this._graphCalculator.encodeHsFromBoundingBox(sw, ne)
47722 .filter(function (h) {
47723 return !(h in _this._cachedTiles);
47725 .map(function (h) {
47726 return h in _this._cachingTiles$ ?
47727 _this._cachingTiles$[h] :
47728 _this._cacheTile$(h);
47730 if (cacheTiles$.length === 0) {
47731 cacheTiles$.push(rxjs_1.of(this));
47733 return rxjs_1.from(cacheTiles$).pipe(operators_1.mergeAll(), operators_1.last(), operators_1.mergeMap(function (graph) {
47734 var nodes = _this._nodeIndex
47741 .map(function (item) {
47744 var fullNodes = [];
47745 var coreNodes = [];
47746 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
47747 var node = nodes_1[_i];
47749 fullNodes.push(node);
47752 coreNodes.push(node.key);
47755 var coreNodeBatches = [];
47756 var batchSize = 200;
47757 while (coreNodes.length > 0) {
47758 coreNodeBatches.push(coreNodes.splice(0, batchSize));
47760 var fullNodes$ = rxjs_1.of(fullNodes);
47761 var fillNodes$ = coreNodeBatches
47762 .map(function (batch) {
47763 return _this._apiV3.imageByKeyFill$(batch).pipe(operators_1.map(function (imageByKeyFill) {
47764 var filledNodes = [];
47765 for (var fillKey in imageByKeyFill) {
47766 if (!imageByKeyFill.hasOwnProperty(fillKey)) {
47769 if (_this.hasNode(fillKey)) {
47770 var node = _this.getNode(fillKey);
47772 _this._makeFull(node, imageByKeyFill[fillKey]);
47774 filledNodes.push(node);
47777 return filledNodes;
47780 return rxjs_1.merge(fullNodes$, rxjs_1.from(fillNodes$).pipe(operators_1.mergeAll()));
47781 }), operators_1.reduce(function (acc, value) {
47782 return acc.concat(value);
47786 * Retrieve and cache node fill properties.
47788 * @param {string} key - Key of node to fill.
47789 * @returns {Observable<Graph>} Observable emitting the graph
47790 * when the node has been updated.
47791 * @throws {GraphMapillaryError} When the operation is not valid on the
47794 Graph.prototype.cacheFill$ = function (key) {
47796 if (key in this._cachingFull$) {
47797 throw new Error_1.GraphMapillaryError("Cannot fill node while caching full (" + key + ").");
47799 if (!this.hasNode(key)) {
47800 throw new Error_1.GraphMapillaryError("Cannot fill node that does not exist in graph (" + key + ").");
47802 if (key in this._cachingFill$) {
47803 return this._cachingFill$[key];
47805 var node = this.getNode(key);
47807 throw new Error_1.GraphMapillaryError("Cannot fill node that is already full (" + key + ").");
47809 this._cachingFill$[key] = this._apiV3.imageByKeyFill$([key]).pipe(operators_1.tap(function (imageByKeyFill) {
47811 _this._makeFull(node, imageByKeyFill[key]);
47813 delete _this._cachingFill$[key];
47814 }), operators_1.map(function (imageByKeyFill) {
47816 }), operators_1.finalize(function () {
47817 if (key in _this._cachingFill$) {
47818 delete _this._cachingFill$[key];
47820 _this._changed$.next(_this);
47821 }), operators_1.publish(), operators_1.refCount());
47822 return this._cachingFill$[key];
47825 * Retrieve and cache full node properties.
47827 * @param {string} key - Key of node to fill.
47828 * @returns {Observable<Graph>} Observable emitting the graph
47829 * when the node has been updated.
47830 * @throws {GraphMapillaryError} When the operation is not valid on the
47833 Graph.prototype.cacheFull$ = function (key) {
47835 if (key in this._cachingFull$) {
47836 return this._cachingFull$[key];
47838 if (this.hasNode(key)) {
47839 throw new Error_1.GraphMapillaryError("Cannot cache full node that already exist in graph (" + key + ").");
47841 this._cachingFull$[key] = this._apiV3.imageByKeyFull$([key]).pipe(operators_1.tap(function (imageByKeyFull) {
47842 var fn = imageByKeyFull[key];
47843 if (_this.hasNode(key)) {
47844 var node = _this.getNode(key);
47846 _this._makeFull(node, fn);
47850 if (fn.sequence_key == null) {
47851 throw new Error_1.GraphMapillaryError("Node has no sequence key (" + key + ").");
47853 var node = new Graph_1.Node(fn);
47854 _this._makeFull(node, fn);
47855 var h = _this._graphCalculator.encodeH(node.originalLatLon, _this._tilePrecision);
47856 _this._preStore(h, node);
47857 _this._setNode(node);
47858 delete _this._cachingFull$[key];
47860 }), operators_1.map(function (imageByKeyFull) {
47862 }), operators_1.finalize(function () {
47863 if (key in _this._cachingFull$) {
47864 delete _this._cachingFull$[key];
47866 _this._changed$.next(_this);
47867 }), operators_1.publish(), operators_1.refCount());
47868 return this._cachingFull$[key];
47871 * Retrieve and cache a node sequence.
47873 * @param {string} key - Key of node for which to retrieve sequence.
47874 * @returns {Observable<Graph>} Observable emitting the graph
47875 * when the sequence has been retrieved.
47876 * @throws {GraphMapillaryError} When the operation is not valid on the
47879 Graph.prototype.cacheNodeSequence$ = function (key) {
47880 if (!this.hasNode(key)) {
47881 throw new Error_1.GraphMapillaryError("Cannot cache sequence edges of node that does not exist in graph (" + key + ").");
47883 var node = this.getNode(key);
47884 if (node.sequenceKey in this._sequences) {
47885 throw new Error_1.GraphMapillaryError("Sequence already cached (" + key + "), (" + node.sequenceKey + ").");
47887 return this._cacheSequence$(node.sequenceKey);
47890 * Retrieve and cache a sequence.
47892 * @param {string} sequenceKey - Key of sequence to cache.
47893 * @returns {Observable<Graph>} Observable emitting the graph
47894 * when the sequence has been retrieved.
47895 * @throws {GraphMapillaryError} When the operation is not valid on the
47898 Graph.prototype.cacheSequence$ = function (sequenceKey) {
47899 if (sequenceKey in this._sequences) {
47900 throw new Error_1.GraphMapillaryError("Sequence already cached (" + sequenceKey + ")");
47902 return this._cacheSequence$(sequenceKey);
47905 * Cache sequence edges for a node.
47907 * @param {string} key - Key of node.
47908 * @throws {GraphMapillaryError} When the operation is not valid on the
47911 Graph.prototype.cacheSequenceEdges = function (key) {
47912 var node = this.getNode(key);
47913 if (!(node.sequenceKey in this._sequences)) {
47914 throw new Error_1.GraphMapillaryError("Sequence is not cached (" + key + "), (" + node.sequenceKey + ")");
47916 var sequence = this._sequences[node.sequenceKey].sequence;
47917 var edges = this._edgeCalculator.computeSequenceEdges(node, sequence);
47918 node.cacheSequenceEdges(edges);
47921 * Retrieve and cache full nodes for all keys in a sequence.
47923 * @param {string} sequenceKey - Key of sequence.
47924 * @param {string} referenceNodeKey - Key of node to use as reference
47925 * for optimized caching.
47926 * @returns {Observable<Graph>} Observable emitting the graph
47927 * when the nodes of the sequence has been cached.
47929 Graph.prototype.cacheSequenceNodes$ = function (sequenceKey, referenceNodeKey) {
47931 if (!this.hasSequence(sequenceKey)) {
47932 throw new Error_1.GraphMapillaryError("Cannot cache sequence nodes of sequence that does not exist in graph (" + sequenceKey + ").");
47934 if (this.hasSequenceNodes(sequenceKey)) {
47935 throw new Error_1.GraphMapillaryError("Sequence nodes already cached (" + sequenceKey + ").");
47937 var sequence = this.getSequence(sequenceKey);
47938 if (sequence.key in this._cachingSequenceNodes$) {
47939 return this._cachingSequenceNodes$[sequence.key];
47942 var keys = sequence.keys.slice();
47943 var referenceBatchSize = 50;
47944 if (!!referenceNodeKey && keys.length > referenceBatchSize) {
47945 var referenceIndex = keys.indexOf(referenceNodeKey);
47946 var startIndex = Math.max(0, Math.min(referenceIndex - referenceBatchSize / 2, keys.length - referenceBatchSize));
47947 batches.push(keys.splice(startIndex, referenceBatchSize));
47949 var batchSize = 200;
47950 while (keys.length > 0) {
47951 batches.push(keys.splice(0, batchSize));
47953 var batchesToCache = batches.length;
47954 var sequenceNodes$ = rxjs_1.from(batches).pipe(operators_1.mergeMap(function (batch) {
47955 return _this._apiV3.imageByKeyFull$(batch).pipe(operators_1.tap(function (imageByKeyFull) {
47956 for (var fullKey in imageByKeyFull) {
47957 if (!imageByKeyFull.hasOwnProperty(fullKey)) {
47960 var fn = imageByKeyFull[fullKey];
47961 if (_this.hasNode(fullKey)) {
47962 var node = _this.getNode(fn.key);
47964 _this._makeFull(node, fn);
47968 if (fn.sequence_key == null) {
47969 console.warn("Sequence missing, discarding node (" + fn.key + ")");
47971 var node = new Graph_1.Node(fn);
47972 _this._makeFull(node, fn);
47973 var h = _this._graphCalculator.encodeH(node.originalLatLon, _this._tilePrecision);
47974 _this._preStore(h, node);
47975 _this._setNode(node);
47979 }), operators_1.map(function (imageByKeyFull) {
47982 }, 6), operators_1.last(), operators_1.finalize(function () {
47983 delete _this._cachingSequenceNodes$[sequence.key];
47984 if (batchesToCache === 0) {
47985 _this._cachedSequenceNodes[sequence.key] = true;
47987 }), operators_1.publish(), operators_1.refCount());
47988 this._cachingSequenceNodes$[sequence.key] = sequenceNodes$;
47989 return sequenceNodes$;
47992 * Retrieve and cache full nodes for a node spatial area.
47994 * @param {string} key - Key of node for which to retrieve sequence.
47995 * @returns {Observable<Graph>} Observable emitting the graph
47996 * when the nodes in the spatial area has been made full.
47997 * @throws {GraphMapillaryError} When the operation is not valid on the
48000 Graph.prototype.cacheSpatialArea$ = function (key) {
48002 if (!this.hasNode(key)) {
48003 throw new Error_1.GraphMapillaryError("Cannot cache spatial area of node that does not exist in graph (" + key + ").");
48005 if (key in this._cachedSpatialEdges) {
48006 throw new Error_1.GraphMapillaryError("Node already spatially cached (" + key + ").");
48008 if (!(key in this._requiredSpatialArea)) {
48009 throw new Error_1.GraphMapillaryError("Spatial area not determined (" + key + ").");
48011 var spatialArea = this._requiredSpatialArea[key];
48012 if (Object.keys(spatialArea.cacheNodes).length === 0) {
48013 throw new Error_1.GraphMapillaryError("Spatial nodes already cached (" + key + ").");
48015 if (key in this._cachingSpatialArea$) {
48016 return this._cachingSpatialArea$[key];
48019 while (spatialArea.cacheKeys.length > 0) {
48020 batches.push(spatialArea.cacheKeys.splice(0, 200));
48022 var batchesToCache = batches.length;
48023 var spatialNodes$ = [];
48024 var _loop_1 = function (batch) {
48025 var spatialNodeBatch$ = this_1._apiV3.imageByKeyFill$(batch).pipe(operators_1.tap(function (imageByKeyFill) {
48026 for (var fillKey in imageByKeyFill) {
48027 if (!imageByKeyFill.hasOwnProperty(fillKey)) {
48030 var spatialNode = spatialArea.cacheNodes[fillKey];
48031 if (spatialNode.full) {
48032 delete spatialArea.cacheNodes[fillKey];
48035 var fillNode = imageByKeyFill[fillKey];
48036 _this._makeFull(spatialNode, fillNode);
48037 delete spatialArea.cacheNodes[fillKey];
48039 if (--batchesToCache === 0) {
48040 delete _this._cachingSpatialArea$[key];
48042 }), operators_1.map(function (imageByKeyFill) {
48044 }), operators_1.catchError(function (error) {
48045 for (var _i = 0, batch_1 = batch; _i < batch_1.length; _i++) {
48046 var batchKey = batch_1[_i];
48047 if (batchKey in spatialArea.all) {
48048 delete spatialArea.all[batchKey];
48050 if (batchKey in spatialArea.cacheNodes) {
48051 delete spatialArea.cacheNodes[batchKey];
48054 if (--batchesToCache === 0) {
48055 delete _this._cachingSpatialArea$[key];
48058 }), operators_1.finalize(function () {
48059 if (Object.keys(spatialArea.cacheNodes).length === 0) {
48060 _this._changed$.next(_this);
48062 }), operators_1.publish(), operators_1.refCount());
48063 spatialNodes$.push(spatialNodeBatch$);
48066 for (var _i = 0, batches_1 = batches; _i < batches_1.length; _i++) {
48067 var batch = batches_1[_i];
48070 this._cachingSpatialArea$[key] = spatialNodes$;
48071 return spatialNodes$;
48074 * Cache spatial edges for a node.
48076 * @param {string} key - Key of node.
48077 * @throws {GraphMapillaryError} When the operation is not valid on the
48080 Graph.prototype.cacheSpatialEdges = function (key) {
48081 if (key in this._cachedSpatialEdges) {
48082 throw new Error_1.GraphMapillaryError("Spatial edges already cached (" + key + ").");
48084 var node = this.getNode(key);
48085 var sequence = this._sequences[node.sequenceKey].sequence;
48086 var fallbackKeys = [];
48087 var prevKey = sequence.findPrevKey(node.key);
48088 if (prevKey != null) {
48089 fallbackKeys.push(prevKey);
48091 var nextKey = sequence.findNextKey(node.key);
48092 if (nextKey != null) {
48093 fallbackKeys.push(nextKey);
48095 var allSpatialNodes = this._requiredSpatialArea[key].all;
48096 var potentialNodes = [];
48097 var filter = this._filter;
48098 for (var spatialNodeKey in allSpatialNodes) {
48099 if (!allSpatialNodes.hasOwnProperty(spatialNodeKey)) {
48102 var spatialNode = allSpatialNodes[spatialNodeKey];
48103 if (filter(spatialNode)) {
48104 potentialNodes.push(spatialNode);
48107 var potentialEdges = this._edgeCalculator.getPotentialEdges(node, potentialNodes, fallbackKeys);
48108 var edges = this._edgeCalculator.computeStepEdges(node, potentialEdges, prevKey, nextKey);
48109 edges = edges.concat(this._edgeCalculator.computeTurnEdges(node, potentialEdges));
48110 edges = edges.concat(this._edgeCalculator.computePanoEdges(node, potentialEdges));
48111 edges = edges.concat(this._edgeCalculator.computePerspectiveToPanoEdges(node, potentialEdges));
48112 edges = edges.concat(this._edgeCalculator.computeSimilarEdges(node, potentialEdges));
48113 node.cacheSpatialEdges(edges);
48114 this._cachedSpatialEdges[key] = node;
48115 delete this._requiredSpatialArea[key];
48116 delete this._cachedNodeTiles[key];
48119 * Retrieve and cache geohash tiles for a node.
48121 * @param {string} key - Key of node for which to retrieve tiles.
48122 * @returns {Array<Observable<Graph>>} Array of observables emitting
48123 * the graph for each tile required for the node has been cached.
48124 * @throws {GraphMapillaryError} When the operation is not valid on the
48127 Graph.prototype.cacheTiles$ = function (key) {
48129 if (key in this._cachedNodeTiles) {
48130 throw new Error_1.GraphMapillaryError("Tiles already cached (" + key + ").");
48132 if (key in this._cachedSpatialEdges) {
48133 throw new Error_1.GraphMapillaryError("Spatial edges already cached so tiles considered cached (" + key + ").");
48135 if (!(key in this._requiredNodeTiles)) {
48136 throw new Error_1.GraphMapillaryError("Tiles have not been determined (" + key + ").");
48138 var nodeTiles = this._requiredNodeTiles[key];
48139 if (nodeTiles.cache.length === 0 &&
48140 nodeTiles.caching.length === 0) {
48141 throw new Error_1.GraphMapillaryError("Tiles already cached (" + key + ").");
48143 if (!this.hasNode(key)) {
48144 throw new Error_1.GraphMapillaryError("Cannot cache tiles of node that does not exist in graph (" + key + ").");
48146 var hs = nodeTiles.cache.slice();
48147 nodeTiles.caching = this._requiredNodeTiles[key].caching.concat(hs);
48148 nodeTiles.cache = [];
48149 var cacheTiles$ = [];
48150 var _loop_2 = function (h) {
48151 var cacheTile$ = h in this_2._cachingTiles$ ?
48152 this_2._cachingTiles$[h] :
48153 this_2._cacheTile$(h);
48154 cacheTiles$.push(cacheTile$.pipe(operators_1.tap(function (graph) {
48155 var index = nodeTiles.caching.indexOf(h);
48157 nodeTiles.caching.splice(index, 1);
48159 if (nodeTiles.caching.length === 0 &&
48160 nodeTiles.cache.length === 0) {
48161 delete _this._requiredNodeTiles[key];
48162 _this._cachedNodeTiles[key] = true;
48164 }), operators_1.catchError(function (error) {
48165 var index = nodeTiles.caching.indexOf(h);
48167 nodeTiles.caching.splice(index, 1);
48169 if (nodeTiles.caching.length === 0 &&
48170 nodeTiles.cache.length === 0) {
48171 delete _this._requiredNodeTiles[key];
48172 _this._cachedNodeTiles[key] = true;
48175 }), operators_1.finalize(function () {
48176 _this._changed$.next(_this);
48177 }), operators_1.publish(), operators_1.refCount()));
48180 for (var _i = 0, _a = nodeTiles.caching; _i < _a.length; _i++) {
48184 return cacheTiles$;
48187 * Initialize the cache for a node.
48189 * @param {string} key - Key of node.
48190 * @throws {GraphMapillaryError} When the operation is not valid on the
48193 Graph.prototype.initializeCache = function (key) {
48194 if (key in this._cachedNodes) {
48195 throw new Error_1.GraphMapillaryError("Node already in cache (" + key + ").");
48197 var node = this.getNode(key);
48198 node.initializeCache(new Graph_1.NodeCache());
48199 var accessed = new Date().getTime();
48200 this._cachedNodes[key] = { accessed: accessed, node: node };
48201 this._updateCachedTileAccess(key, accessed);
48204 * Get a value indicating if the graph is fill caching a node.
48206 * @param {string} key - Key of node.
48207 * @returns {boolean} Value indicating if the node is being fill cached.
48209 Graph.prototype.isCachingFill = function (key) {
48210 return key in this._cachingFill$;
48213 * Get a value indicating if the graph is fully caching a node.
48215 * @param {string} key - Key of node.
48216 * @returns {boolean} Value indicating if the node is being fully cached.
48218 Graph.prototype.isCachingFull = function (key) {
48219 return key in this._cachingFull$;
48222 * Get a value indicating if the graph is caching a sequence of a node.
48224 * @param {string} key - Key of node.
48225 * @returns {boolean} Value indicating if the sequence of a node is
48228 Graph.prototype.isCachingNodeSequence = function (key) {
48229 var node = this.getNode(key);
48230 return node.sequenceKey in this._cachingSequences$;
48233 * Get a value indicating if the graph is caching a sequence.
48235 * @param {string} sequenceKey - Key of sequence.
48236 * @returns {boolean} Value indicating if the sequence is
48239 Graph.prototype.isCachingSequence = function (sequenceKey) {
48240 return sequenceKey in this._cachingSequences$;
48243 * Get a value indicating if the graph is caching sequence nodes.
48245 * @param {string} sequenceKey - Key of sequence.
48246 * @returns {boolean} Value indicating if the sequence nodes are
48249 Graph.prototype.isCachingSequenceNodes = function (sequenceKey) {
48250 return sequenceKey in this._cachingSequenceNodes$;
48253 * Get a value indicating if the graph is caching the tiles
48254 * required for calculating spatial edges of a node.
48256 * @param {string} key - Key of node.
48257 * @returns {boolean} Value indicating if the tiles of
48258 * a node are being cached.
48260 Graph.prototype.isCachingTiles = function (key) {
48261 return key in this._requiredNodeTiles &&
48262 this._requiredNodeTiles[key].cache.length === 0 &&
48263 this._requiredNodeTiles[key].caching.length > 0;
48266 * Get a value indicating if the cache has been initialized
48269 * @param {string} key - Key of node.
48270 * @returns {boolean} Value indicating if the cache has been
48271 * initialized for a node.
48273 Graph.prototype.hasInitializedCache = function (key) {
48274 return key in this._cachedNodes;
48277 * Get a value indicating if a node exist in the graph.
48279 * @param {string} key - Key of node.
48280 * @returns {boolean} Value indicating if a node exist in the graph.
48282 Graph.prototype.hasNode = function (key) {
48283 var accessed = new Date().getTime();
48284 this._updateCachedNodeAccess(key, accessed);
48285 this._updateCachedTileAccess(key, accessed);
48286 return key in this._nodes;
48289 * Get a value indicating if a node sequence exist in the graph.
48291 * @param {string} key - Key of node.
48292 * @returns {boolean} Value indicating if a node sequence exist
48295 Graph.prototype.hasNodeSequence = function (key) {
48296 var node = this.getNode(key);
48297 var sequenceKey = node.sequenceKey;
48298 var hasNodeSequence = sequenceKey in this._sequences;
48299 if (hasNodeSequence) {
48300 this._sequences[sequenceKey].accessed = new Date().getTime();
48302 return hasNodeSequence;
48305 * Get a value indicating if a sequence exist in the graph.
48307 * @param {string} sequenceKey - Key of sequence.
48308 * @returns {boolean} Value indicating if a sequence exist
48311 Graph.prototype.hasSequence = function (sequenceKey) {
48312 var hasSequence = sequenceKey in this._sequences;
48314 this._sequences[sequenceKey].accessed = new Date().getTime();
48316 return hasSequence;
48319 * Get a value indicating if sequence nodes has been cached in the graph.
48321 * @param {string} sequenceKey - Key of sequence.
48322 * @returns {boolean} Value indicating if a sequence nodes has been
48323 * cached in the graph.
48325 Graph.prototype.hasSequenceNodes = function (sequenceKey) {
48326 return sequenceKey in this._cachedSequenceNodes;
48329 * Get a value indicating if the graph has fully cached
48330 * all nodes in the spatial area of a node.
48332 * @param {string} key - Key of node.
48333 * @returns {boolean} Value indicating if the spatial area
48334 * of a node has been cached.
48336 Graph.prototype.hasSpatialArea = function (key) {
48337 if (!this.hasNode(key)) {
48338 throw new Error_1.GraphMapillaryError("Spatial area nodes cannot be determined if node not in graph (" + key + ").");
48340 if (key in this._cachedSpatialEdges) {
48343 if (key in this._requiredSpatialArea) {
48344 return Object.keys(this._requiredSpatialArea[key].cacheNodes).length === 0;
48346 var node = this.getNode(key);
48347 var bbox = this._graphCalculator.boundingBoxCorners(node.latLon, this._tileThreshold);
48348 var spatialItems = this._nodeIndex.search({
48354 var spatialNodes = {
48359 for (var _i = 0, spatialItems_1 = spatialItems; _i < spatialItems_1.length; _i++) {
48360 var spatialItem = spatialItems_1[_i];
48361 spatialNodes.all[spatialItem.node.key] = spatialItem.node;
48362 if (!spatialItem.node.full) {
48363 spatialNodes.cacheKeys.push(spatialItem.node.key);
48364 spatialNodes.cacheNodes[spatialItem.node.key] = spatialItem.node;
48367 this._requiredSpatialArea[key] = spatialNodes;
48368 return spatialNodes.cacheKeys.length === 0;
48371 * Get a value indicating if the graph has a tiles required
48374 * @param {string} key - Key of node.
48375 * @returns {boolean} Value indicating if the the tiles required
48376 * by a node has been cached.
48378 Graph.prototype.hasTiles = function (key) {
48380 if (key in this._cachedNodeTiles) {
48383 if (key in this._cachedSpatialEdges) {
48386 if (!this.hasNode(key)) {
48387 throw new Error_1.GraphMapillaryError("Node does not exist in graph (" + key + ").");
48389 var nodeTiles = { cache: [], caching: [] };
48390 if (!(key in this._requiredNodeTiles)) {
48391 var node = this.getNode(key);
48392 nodeTiles.cache = this._graphCalculator
48393 .encodeHs(node.latLon, this._tilePrecision, this._tileThreshold)
48394 .filter(function (h) {
48395 return !(h in _this._cachedTiles);
48397 if (nodeTiles.cache.length > 0) {
48398 this._requiredNodeTiles[key] = nodeTiles;
48402 nodeTiles = this._requiredNodeTiles[key];
48404 return nodeTiles.cache.length === 0 && nodeTiles.caching.length === 0;
48409 * @param {string} key - Key of node.
48410 * @returns {Node} Retrieved node.
48412 Graph.prototype.getNode = function (key) {
48413 var accessed = new Date().getTime();
48414 this._updateCachedNodeAccess(key, accessed);
48415 this._updateCachedTileAccess(key, accessed);
48416 return this._nodes[key];
48421 * @param {string} sequenceKey - Key of sequence.
48422 * @returns {Node} Retrieved sequence.
48424 Graph.prototype.getSequence = function (sequenceKey) {
48425 var sequenceAccess = this._sequences[sequenceKey];
48426 sequenceAccess.accessed = new Date().getTime();
48427 return sequenceAccess.sequence;
48430 * Reset all spatial edges of the graph nodes.
48432 Graph.prototype.resetSpatialEdges = function () {
48433 var cachedKeys = Object.keys(this._cachedSpatialEdges);
48434 for (var _i = 0, cachedKeys_1 = cachedKeys; _i < cachedKeys_1.length; _i++) {
48435 var cachedKey = cachedKeys_1[_i];
48436 var node = this._cachedSpatialEdges[cachedKey];
48437 node.resetSpatialEdges();
48438 delete this._cachedSpatialEdges[cachedKey];
48442 * Reset the complete graph but keep the nodes corresponding
48443 * to the supplied keys. All other nodes will be disposed.
48445 * @param {Array<string>} keepKeys - Keys for nodes to keep
48446 * in graph after reset.
48448 Graph.prototype.reset = function (keepKeys) {
48450 for (var _i = 0, keepKeys_1 = keepKeys; _i < keepKeys_1.length; _i++) {
48451 var key = keepKeys_1[_i];
48452 if (!this.hasNode(key)) {
48453 throw new Error("Node does not exist " + key);
48455 var node = this.getNode(key);
48456 node.resetSequenceEdges();
48457 node.resetSpatialEdges();
48460 for (var _a = 0, _b = Object.keys(this._cachedNodes); _a < _b.length; _a++) {
48461 var cachedKey = _b[_a];
48462 if (keepKeys.indexOf(cachedKey) !== -1) {
48465 this._cachedNodes[cachedKey].node.dispose();
48466 delete this._cachedNodes[cachedKey];
48468 this._cachedNodeTiles = {};
48469 this._cachedSpatialEdges = {};
48470 this._cachedTiles = {};
48471 this._cachingFill$ = {};
48472 this._cachingFull$ = {};
48473 this._cachingSequences$ = {};
48474 this._cachingSpatialArea$ = {};
48475 this._cachingTiles$ = {};
48477 this._nodeToTile = {};
48478 this._preStored = {};
48479 for (var _c = 0, nodes_2 = nodes; _c < nodes_2.length; _c++) {
48480 var node = nodes_2[_c];
48481 this._nodes[node.key] = node;
48482 var h = this._graphCalculator.encodeH(node.originalLatLon, this._tilePrecision);
48483 this._preStore(h, node);
48485 this._requiredNodeTiles = {};
48486 this._requiredSpatialArea = {};
48487 this._sequences = {};
48488 this._nodeIndexTiles = {};
48489 this._nodeIndex.clear();
48492 * Set the spatial node filter.
48494 * @param {FilterExpression} filter - Filter expression to be applied
48495 * when calculating spatial edges.
48497 Graph.prototype.setFilter = function (filter) {
48498 this._filter = this._filterCreator.createFilter(filter);
48501 * Uncache the graph according to the graph configuration.
48503 * @description Uncaches unused tiles, unused nodes and
48504 * sequences according to the numbers specified in the
48505 * graph configuration. Sequences does not have a direct
48506 * reference to either tiles or nodes and may be uncached
48507 * even if they are related to the nodes that should be kept.
48509 * @param {Array<string>} keepKeys - Keys of nodes to keep in
48510 * graph unrelated to last access. Tiles related to those keys
48511 * will also be kept in graph.
48512 * @param {string} keepSequenceKey - Optional key of sequence
48513 * for which the belonging nodes should not be disposed or
48514 * removed from the graph. These nodes may still be uncached if
48515 * not specified in keep keys param.
48517 Graph.prototype.uncache = function (keepKeys, keepSequenceKey) {
48518 var keysInUse = {};
48519 this._addNewKeys(keysInUse, this._cachingFull$);
48520 this._addNewKeys(keysInUse, this._cachingFill$);
48521 this._addNewKeys(keysInUse, this._cachingSpatialArea$);
48522 this._addNewKeys(keysInUse, this._requiredNodeTiles);
48523 this._addNewKeys(keysInUse, this._requiredSpatialArea);
48524 for (var _i = 0, keepKeys_2 = keepKeys; _i < keepKeys_2.length; _i++) {
48525 var key = keepKeys_2[_i];
48526 if (key in keysInUse) {
48529 keysInUse[key] = true;
48532 for (var key in keysInUse) {
48533 if (!keysInUse.hasOwnProperty(key)) {
48536 var node = this._nodes[key];
48537 var nodeHs = this._graphCalculator.encodeHs(node.latLon);
48538 for (var _a = 0, nodeHs_1 = nodeHs; _a < nodeHs_1.length; _a++) {
48539 var nodeH = nodeHs_1[_a];
48540 if (!(nodeH in keepHs)) {
48541 keepHs[nodeH] = true;
48545 var potentialHs = [];
48546 for (var h in this._cachedTiles) {
48547 if (!this._cachedTiles.hasOwnProperty(h) || h in keepHs) {
48550 potentialHs.push([h, this._cachedTiles[h]]);
48552 var uncacheHs = potentialHs
48553 .sort(function (h1, h2) {
48554 return h2[1].accessed - h1[1].accessed;
48556 .slice(this._configuration.maxUnusedTiles)
48557 .map(function (h) {
48560 for (var _b = 0, uncacheHs_1 = uncacheHs; _b < uncacheHs_1.length; _b++) {
48561 var uncacheH = uncacheHs_1[_b];
48562 this._uncacheTile(uncacheH, keepSequenceKey);
48564 var potentialPreStored = [];
48565 var nonCachedPreStored = [];
48566 for (var h in this._preStored) {
48567 if (!this._preStored.hasOwnProperty(h) || h in this._cachingTiles$) {
48570 var prestoredNodes = this._preStored[h];
48571 for (var key in prestoredNodes) {
48572 if (!prestoredNodes.hasOwnProperty(key) || key in keysInUse) {
48575 if (prestoredNodes[key].sequenceKey === keepSequenceKey) {
48578 if (key in this._cachedNodes) {
48579 potentialPreStored.push([this._cachedNodes[key], h]);
48582 nonCachedPreStored.push([key, h]);
48586 var uncachePreStored = potentialPreStored
48587 .sort(function (_a, _b) {
48588 var na1 = _a[0], h1 = _a[1];
48589 var na2 = _b[0], h2 = _b[1];
48590 return na2.accessed - na1.accessed;
48592 .slice(this._configuration.maxUnusedPreStoredNodes)
48593 .map(function (_a) {
48594 var na = _a[0], h = _a[1];
48595 return [na.node.key, h];
48597 this._uncachePreStored(nonCachedPreStored);
48598 this._uncachePreStored(uncachePreStored);
48599 var potentialNodes = [];
48600 for (var key in this._cachedNodes) {
48601 if (!this._cachedNodes.hasOwnProperty(key) || key in keysInUse) {
48604 potentialNodes.push(this._cachedNodes[key]);
48606 var uncacheNodes = potentialNodes
48607 .sort(function (n1, n2) {
48608 return n2.accessed - n1.accessed;
48610 .slice(this._configuration.maxUnusedNodes);
48611 for (var _c = 0, uncacheNodes_1 = uncacheNodes; _c < uncacheNodes_1.length; _c++) {
48612 var nodeAccess = uncacheNodes_1[_c];
48613 nodeAccess.node.uncache();
48614 var key = nodeAccess.node.key;
48615 delete this._cachedNodes[key];
48616 if (key in this._cachedNodeTiles) {
48617 delete this._cachedNodeTiles[key];
48619 if (key in this._cachedSpatialEdges) {
48620 delete this._cachedSpatialEdges[key];
48623 var potentialSequences = [];
48624 for (var sequenceKey in this._sequences) {
48625 if (!this._sequences.hasOwnProperty(sequenceKey) ||
48626 sequenceKey in this._cachingSequences$ ||
48627 sequenceKey === keepSequenceKey) {
48630 potentialSequences.push(this._sequences[sequenceKey]);
48632 var uncacheSequences = potentialSequences
48633 .sort(function (s1, s2) {
48634 return s2.accessed - s1.accessed;
48636 .slice(this._configuration.maxSequences);
48637 for (var _d = 0, uncacheSequences_1 = uncacheSequences; _d < uncacheSequences_1.length; _d++) {
48638 var sequenceAccess = uncacheSequences_1[_d];
48639 var sequenceKey = sequenceAccess.sequence.key;
48640 delete this._sequences[sequenceKey];
48641 if (sequenceKey in this._cachedSequenceNodes) {
48642 delete this._cachedSequenceNodes[sequenceKey];
48644 sequenceAccess.sequence.dispose();
48647 Graph.prototype._addNewKeys = function (keys, dict) {
48648 for (var key in dict) {
48649 if (!dict.hasOwnProperty(key) || !this.hasNode(key)) {
48652 if (!(key in keys)) {
48657 Graph.prototype._cacheSequence$ = function (sequenceKey) {
48659 if (sequenceKey in this._cachingSequences$) {
48660 return this._cachingSequences$[sequenceKey];
48662 this._cachingSequences$[sequenceKey] = this._apiV3.sequenceByKey$([sequenceKey]).pipe(operators_1.tap(function (sequenceByKey) {
48663 if (!(sequenceKey in _this._sequences)) {
48664 _this._sequences[sequenceKey] = {
48665 accessed: new Date().getTime(),
48666 sequence: new Graph_1.Sequence(sequenceByKey[sequenceKey]),
48669 delete _this._cachingSequences$[sequenceKey];
48670 }), operators_1.map(function (sequenceByKey) {
48672 }), operators_1.finalize(function () {
48673 if (sequenceKey in _this._cachingSequences$) {
48674 delete _this._cachingSequences$[sequenceKey];
48676 _this._changed$.next(_this);
48677 }), operators_1.publish(), operators_1.refCount());
48678 return this._cachingSequences$[sequenceKey];
48680 Graph.prototype._cacheTile$ = function (h) {
48682 this._cachingTiles$[h] = this._apiV3.imagesByH$([h]).pipe(operators_1.tap(function (imagesByH) {
48683 var coreNodes = imagesByH[h];
48684 if (h in _this._cachedTiles) {
48687 _this._nodeIndexTiles[h] = [];
48688 _this._cachedTiles[h] = { accessed: new Date().getTime(), nodes: [] };
48689 var hCache = _this._cachedTiles[h].nodes;
48690 var preStored = _this._removeFromPreStore(h);
48691 for (var index in coreNodes) {
48692 if (!coreNodes.hasOwnProperty(index)) {
48695 var coreNode = coreNodes[index];
48696 if (coreNode == null) {
48699 if (coreNode.sequence_key == null) {
48700 console.warn("Sequence missing, discarding node (" + coreNode.key + ")");
48703 if (preStored != null && coreNode.key in preStored) {
48704 var preStoredNode = preStored[coreNode.key];
48705 delete preStored[coreNode.key];
48706 hCache.push(preStoredNode);
48707 var preStoredNodeIndexItem = {
48708 lat: preStoredNode.latLon.lat,
48709 lon: preStoredNode.latLon.lon,
48710 node: preStoredNode,
48712 _this._nodeIndex.insert(preStoredNodeIndexItem);
48713 _this._nodeIndexTiles[h].push(preStoredNodeIndexItem);
48714 _this._nodeToTile[preStoredNode.key] = h;
48717 var node = new Graph_1.Node(coreNode);
48719 var nodeIndexItem = {
48720 lat: node.latLon.lat,
48721 lon: node.latLon.lon,
48724 _this._nodeIndex.insert(nodeIndexItem);
48725 _this._nodeIndexTiles[h].push(nodeIndexItem);
48726 _this._nodeToTile[node.key] = h;
48727 _this._setNode(node);
48729 delete _this._cachingTiles$[h];
48730 }), operators_1.map(function (imagesByH) {
48732 }), operators_1.catchError(function (error) {
48733 delete _this._cachingTiles$[h];
48735 }), operators_1.publish(), operators_1.refCount());
48736 return this._cachingTiles$[h];
48738 Graph.prototype._makeFull = function (node, fillNode) {
48739 if (fillNode.calt == null) {
48740 fillNode.calt = this._defaultAlt;
48742 if (fillNode.c_rotation == null) {
48743 fillNode.c_rotation = this._graphCalculator.rotationFromCompass(fillNode.ca, fillNode.orientation);
48745 node.makeFull(fillNode);
48747 Graph.prototype._preStore = function (h, node) {
48748 if (!(h in this._preStored)) {
48749 this._preStored[h] = {};
48751 this._preStored[h][node.key] = node;
48753 Graph.prototype._removeFromPreStore = function (h) {
48754 var preStored = null;
48755 if (h in this._preStored) {
48756 preStored = this._preStored[h];
48757 delete this._preStored[h];
48761 Graph.prototype._setNode = function (node) {
48762 var key = node.key;
48763 if (this.hasNode(key)) {
48764 throw new Error_1.GraphMapillaryError("Node already exist (" + key + ").");
48766 this._nodes[key] = node;
48768 Graph.prototype._uncacheTile = function (h, keepSequenceKey) {
48769 for (var _i = 0, _a = this._cachedTiles[h].nodes; _i < _a.length; _i++) {
48771 var key = node.key;
48772 delete this._nodeToTile[key];
48773 if (key in this._cachedNodes) {
48774 delete this._cachedNodes[key];
48776 if (key in this._cachedNodeTiles) {
48777 delete this._cachedNodeTiles[key];
48779 if (key in this._cachedSpatialEdges) {
48780 delete this._cachedSpatialEdges[key];
48782 if (node.sequenceKey === keepSequenceKey) {
48783 this._preStore(h, node);
48787 delete this._nodes[key];
48788 if (node.sequenceKey in this._cachedSequenceNodes) {
48789 delete this._cachedSequenceNodes[node.sequenceKey];
48794 for (var _b = 0, _c = this._nodeIndexTiles[h]; _b < _c.length; _b++) {
48795 var nodeIndexItem = _c[_b];
48796 this._nodeIndex.remove(nodeIndexItem);
48798 delete this._nodeIndexTiles[h];
48799 delete this._cachedTiles[h];
48801 Graph.prototype._uncachePreStored = function (preStored) {
48803 for (var _i = 0, preStored_1 = preStored; _i < preStored_1.length; _i++) {
48804 var _a = preStored_1[_i], key = _a[0], h = _a[1];
48805 if (key in this._nodes) {
48806 delete this._nodes[key];
48808 if (key in this._cachedNodes) {
48809 delete this._cachedNodes[key];
48811 var node = this._preStored[h][key];
48812 if (node.sequenceKey in this._cachedSequenceNodes) {
48813 delete this._cachedSequenceNodes[node.sequenceKey];
48815 delete this._preStored[h][key];
48819 for (var h in hs) {
48820 if (!hs.hasOwnProperty(h)) {
48823 if (Object.keys(this._preStored[h]).length === 0) {
48824 delete this._preStored[h];
48828 Graph.prototype._updateCachedTileAccess = function (key, accessed) {
48829 if (key in this._nodeToTile) {
48830 this._cachedTiles[this._nodeToTile[key]].accessed = accessed;
48833 Graph.prototype._updateCachedNodeAccess = function (key, accessed) {
48834 if (key in this._cachedNodes) {
48835 this._cachedNodes[key].accessed = accessed;
48840 exports.Graph = Graph;
48841 exports.default = Graph;
48843 },{"../Edge":292,"../Error":293,"../Geo":294,"../Graph":295,"rxjs":43,"rxjs/operators":241}],425:[function(require,module,exports){
48845 Object.defineProperty(exports, "__esModule", { value: true });
48846 exports.GraphCalculator = void 0;
48847 var geohash = require("latlon-geohash");
48848 var THREE = require("three");
48849 var Error_1 = require("../Error");
48850 var Geo_1 = require("../Geo");
48852 * @class GraphCalculator
48854 * @classdesc Represents a calculator for graph entities.
48856 var GraphCalculator = /** @class */ (function () {
48858 * Create a new graph calculator instance.
48860 * @param {GeoCoords} geoCoords - Geo coords instance.
48862 function GraphCalculator(geoCoords) {
48863 this._geoCoords = geoCoords != null ? geoCoords : new Geo_1.GeoCoords();
48866 * Encode the geohash tile for geodetic coordinates.
48868 * @param {ILatLon} latlon - Latitude and longitude to encode.
48869 * @param {number} precision - Precision of the encoding.
48871 * @returns {string} The geohash tile for the lat, lon and precision.
48873 GraphCalculator.prototype.encodeH = function (latLon, precision) {
48874 if (precision === void 0) { precision = 7; }
48875 return geohash.encode(latLon.lat, latLon.lon, precision);
48878 * Encode the geohash tiles within a threshold from a position
48879 * using Manhattan distance.
48881 * @param {ILatLon} latlon - Latitude and longitude to encode.
48882 * @param {number} precision - Precision of the encoding.
48883 * @param {number} threshold - Threshold of the encoding in meters.
48885 * @returns {string} The geohash tiles reachable within the threshold.
48887 GraphCalculator.prototype.encodeHs = function (latLon, precision, threshold) {
48888 if (precision === void 0) { precision = 7; }
48889 if (threshold === void 0) { threshold = 20; }
48890 var h = geohash.encode(latLon.lat, latLon.lon, precision);
48891 var bounds = geohash.bounds(h);
48892 var ne = bounds.ne;
48893 var sw = bounds.sw;
48894 var neighbours = geohash.neighbours(h);
48895 var bl = [0, 0, 0];
48896 var tr = this._geoCoords.geodeticToEnu(ne.lat, ne.lon, 0, sw.lat, sw.lon, 0);
48897 var position = this._geoCoords.geodeticToEnu(latLon.lat, latLon.lon, 0, sw.lat, sw.lon, 0);
48898 var left = position[0] - bl[0];
48899 var right = tr[0] - position[0];
48900 var bottom = position[1] - bl[1];
48901 var top = tr[1] - position[1];
48902 var l = left < threshold;
48903 var r = right < threshold;
48904 var b = bottom < threshold;
48905 var t = top < threshold;
48908 hs.push(neighbours.n);
48911 hs.push(neighbours.nw);
48914 hs.push(neighbours.w);
48917 hs.push(neighbours.sw);
48920 hs.push(neighbours.s);
48923 hs.push(neighbours.se);
48926 hs.push(neighbours.e);
48929 hs.push(neighbours.ne);
48934 * Encode the minimum set of geohash tiles containing a bounding box.
48936 * @description The current algorithm does expect the bounding box
48937 * to be sufficiently small to be contained in an area with the size
48938 * of maximally four tiles. Up to nine adjacent tiles may be returned.
48939 * The method currently uses the largest side as the threshold leading to
48940 * more tiles being returned than needed in edge cases.
48942 * @param {ILatLon} sw - South west corner of bounding box.
48943 * @param {ILatLon} ne - North east corner of bounding box.
48944 * @param {number} precision - Precision of the encoding.
48946 * @returns {string} The geohash tiles containing the bounding box.
48948 GraphCalculator.prototype.encodeHsFromBoundingBox = function (sw, ne, precision) {
48949 if (precision === void 0) { precision = 7; }
48950 if (ne.lat <= sw.lat || ne.lon <= sw.lon) {
48951 throw new Error_1.GraphMapillaryError("North east needs to be top right of south west");
48953 var centerLat = (sw.lat + ne.lat) / 2;
48954 var centerLon = (sw.lon + ne.lon) / 2;
48955 var enu = this._geoCoords.geodeticToEnu(ne.lat, ne.lon, 0, centerLat, centerLon, 0);
48956 var threshold = Math.max(enu[0], enu[1]);
48957 return this.encodeHs({ lat: centerLat, lon: centerLon }, precision, threshold);
48960 * Get the bounding box corners for a circle with radius of a threshold
48961 * with center in a geodetic position.
48963 * @param {ILatLon} latlon - Latitude and longitude to encode.
48964 * @param {number} threshold - Threshold distance from the position in meters.
48966 * @returns {Array<ILatLon>} The south west and north east corners of the
48969 GraphCalculator.prototype.boundingBoxCorners = function (latLon, threshold) {
48970 var bl = this._geoCoords.enuToGeodetic(-threshold, -threshold, 0, latLon.lat, latLon.lon, 0);
48971 var tr = this._geoCoords.enuToGeodetic(threshold, threshold, 0, latLon.lat, latLon.lon, 0);
48973 { lat: bl[0], lon: bl[1] },
48974 { lat: tr[0], lon: tr[1] },
48978 * Convert a compass angle to an angle axis rotation vector.
48980 * @param {number} compassAngle - The compass angle in degrees.
48981 * @param {number} orientation - The orientation of the original image.
48983 * @returns {Array<number>} Angle axis rotation vector.
48985 GraphCalculator.prototype.rotationFromCompass = function (compassAngle, orientation) {
48989 switch (orientation) {
49008 var rz = new THREE.Matrix4().makeRotationZ(z);
49009 var euler = new THREE.Euler(x, y, compassAngle * Math.PI / 180, "XYZ");
49010 var re = new THREE.Matrix4().makeRotationFromEuler(euler);
49011 var rotation = new THREE.Vector4().setAxisAngleFromRotationMatrix(re.multiply(rz));
49012 return rotation.multiplyScalar(rotation.w).toArray().slice(0, 3);
49014 return GraphCalculator;
49016 exports.GraphCalculator = GraphCalculator;
49017 exports.default = GraphCalculator;
49019 },{"../Error":293,"../Geo":294,"latlon-geohash":21,"three":242}],426:[function(require,module,exports){
49021 Object.defineProperty(exports, "__esModule", { value: true });
49022 exports.GraphMode = void 0;
49024 * Enumeration for graph modes.
49027 * @description Modes for the retrieval and caching performed
49028 * by the graph service on the graph.
49031 (function (GraphMode) {
49033 * Caching is performed on sequences only and sequence edges are
49034 * calculated. Spatial tiles
49035 * are not retrieved and spatial edges are not calculated when
49036 * caching nodes. Complete sequences are being cached for requested
49037 * nodes within the graph.
49039 GraphMode[GraphMode["Sequence"] = 0] = "Sequence";
49041 * Caching is performed with emphasis on spatial data. Sequence edges
49042 * as well as spatial edges are cached. Sequence data
49043 * is still requested but complete sequences are not being cached
49044 * for requested nodes.
49046 * This is the initial mode of the graph service.
49048 GraphMode[GraphMode["Spatial"] = 1] = "Spatial";
49049 })(GraphMode = exports.GraphMode || (exports.GraphMode = {}));
49050 exports.default = GraphMode;
49052 },{}],427:[function(require,module,exports){
49054 Object.defineProperty(exports, "__esModule", { value: true });
49055 exports.GraphService = void 0;
49056 var rxjs_1 = require("rxjs");
49057 var operators_1 = require("rxjs/operators");
49058 var Graph_1 = require("../Graph");
49060 * @class GraphService
49062 * @classdesc Represents a service for graph operations.
49064 var GraphService = /** @class */ (function () {
49066 * Create a new graph service instance.
49068 * @param {Graph} graph - Graph instance to be operated on.
49070 function GraphService(graph, imageLoadingService) {
49071 this._graph$ = rxjs_1.concat(rxjs_1.of(graph), graph.changed$).pipe(operators_1.publishReplay(1), operators_1.refCount());
49072 this._graph$.subscribe(function () { });
49073 this._graphMode = Graph_1.GraphMode.Spatial;
49074 this._graphModeSubject$ = new rxjs_1.Subject();
49075 this._graphMode$ = this._graphModeSubject$.pipe(operators_1.startWith(this._graphMode), operators_1.publishReplay(1), operators_1.refCount());
49076 this._graphMode$.subscribe(function () { });
49077 this._imageLoadingService = imageLoadingService;
49078 this._firstGraphSubjects$ = [];
49079 this._initializeCacheSubscriptions = [];
49080 this._sequenceSubscriptions = [];
49081 this._spatialSubscriptions = [];
49083 Object.defineProperty(GraphService.prototype, "graphMode$", {
49085 * Get graph mode observable.
49087 * @description Emits the current graph mode.
49089 * @returns {Observable<GraphMode>} Observable
49090 * emitting the current graph mode when it changes.
49093 return this._graphMode$;
49099 * Cache full nodes in a bounding box.
49101 * @description When called, the full properties of
49102 * the node are retrieved. The node cache is not initialized
49103 * for any new nodes retrieved and the node assets are not
49104 * retrieved, {@link cacheNode$} needs to be called for caching
49107 * @param {ILatLon} sw - South west corner of bounding box.
49108 * @param {ILatLon} ne - North east corner of bounding box.
49109 * @return {Observable<Array<Node>>} Observable emitting a single item,
49110 * the nodes of the bounding box, when they have all been retrieved.
49111 * @throws {Error} Propagates any IO node caching errors to the caller.
49113 GraphService.prototype.cacheBoundingBox$ = function (sw, ne) {
49114 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
49115 return graph.cacheBoundingBox$(sw, ne);
49119 * Cache a node in the graph and retrieve it.
49121 * @description When called, the full properties of
49122 * the node are retrieved and the node cache is initialized.
49123 * After that the node assets are cached and the node
49124 * is emitted to the observable when.
49125 * In parallel to caching the node assets, the sequence and
49126 * spatial edges of the node are cached. For this, the sequence
49127 * of the node and the required tiles and spatial nodes are
49128 * retrieved. The sequence and spatial edges may be set before
49129 * or after the node is returned.
49131 * @param {string} key - Key of the node to cache.
49132 * @return {Observable<Node>} Observable emitting a single item,
49133 * the node, when it has been retrieved and its assets are cached.
49134 * @throws {Error} Propagates any IO node caching errors to the caller.
49136 GraphService.prototype.cacheNode$ = function (key) {
49138 var firstGraphSubject$ = new rxjs_1.Subject();
49139 this._firstGraphSubjects$.push(firstGraphSubject$);
49140 var firstGraph$ = firstGraphSubject$.pipe(operators_1.publishReplay(1), operators_1.refCount());
49141 var node$ = firstGraph$.pipe(operators_1.map(function (graph) {
49142 return graph.getNode(key);
49143 }), operators_1.mergeMap(function (node) {
49144 return node.assetsCached ?
49146 node.cacheAssets$();
49147 }), operators_1.publishReplay(1), operators_1.refCount());
49148 node$.subscribe(function (node) {
49149 _this._imageLoadingService.loadnode$.next(node);
49150 }, function (error) {
49151 console.error("Failed to cache node (" + key + ")", error);
49153 var initializeCacheSubscription = this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
49154 if (graph.isCachingFull(key) || !graph.hasNode(key)) {
49155 return graph.cacheFull$(key);
49157 if (graph.isCachingFill(key) || !graph.getNode(key).full) {
49158 return graph.cacheFill$(key);
49160 return rxjs_1.of(graph);
49161 }), operators_1.tap(function (graph) {
49162 if (!graph.hasInitializedCache(key)) {
49163 graph.initializeCache(key);
49165 }), operators_1.finalize(function () {
49166 if (initializeCacheSubscription == null) {
49169 _this._removeFromArray(initializeCacheSubscription, _this._initializeCacheSubscriptions);
49170 _this._removeFromArray(firstGraphSubject$, _this._firstGraphSubjects$);
49172 .subscribe(function (graph) {
49173 firstGraphSubject$.next(graph);
49174 firstGraphSubject$.complete();
49175 }, function (error) {
49176 firstGraphSubject$.error(error);
49178 if (!initializeCacheSubscription.closed) {
49179 this._initializeCacheSubscriptions.push(initializeCacheSubscription);
49181 var graphSequence$ = firstGraph$.pipe(operators_1.mergeMap(function (graph) {
49182 if (graph.isCachingNodeSequence(key) || !graph.hasNodeSequence(key)) {
49183 return graph.cacheNodeSequence$(key);
49185 return rxjs_1.of(graph);
49186 }), operators_1.publishReplay(1), operators_1.refCount());
49187 var sequenceSubscription = graphSequence$.pipe(operators_1.tap(function (graph) {
49188 if (!graph.getNode(key).sequenceEdges.cached) {
49189 graph.cacheSequenceEdges(key);
49191 }), operators_1.finalize(function () {
49192 if (sequenceSubscription == null) {
49195 _this._removeFromArray(sequenceSubscription, _this._sequenceSubscriptions);
49197 .subscribe(function (graph) { return; }, function (error) {
49198 console.error("Failed to cache sequence edges (" + key + ").", error);
49200 if (!sequenceSubscription.closed) {
49201 this._sequenceSubscriptions.push(sequenceSubscription);
49203 if (this._graphMode === Graph_1.GraphMode.Spatial) {
49204 var spatialSubscription_1 = firstGraph$.pipe(operators_1.expand(function (graph) {
49205 if (graph.hasTiles(key)) {
49206 return rxjs_1.empty();
49208 return rxjs_1.from(graph.cacheTiles$(key)).pipe(operators_1.mergeMap(function (graph$) {
49209 return graph$.pipe(operators_1.mergeMap(function (g) {
49210 if (g.isCachingTiles(key)) {
49211 return rxjs_1.empty();
49213 return rxjs_1.of(g);
49214 }), operators_1.catchError(function (error, caught$) {
49215 console.error("Failed to cache tile data (" + key + ").", error);
49216 return rxjs_1.empty();
49219 }), operators_1.last(), operators_1.mergeMap(function (graph) {
49220 if (graph.hasSpatialArea(key)) {
49221 return rxjs_1.of(graph);
49223 return rxjs_1.from(graph.cacheSpatialArea$(key)).pipe(operators_1.mergeMap(function (graph$) {
49224 return graph$.pipe(operators_1.catchError(function (error, caught$) {
49225 console.error("Failed to cache spatial nodes (" + key + ").", error);
49226 return rxjs_1.empty();
49229 }), operators_1.last(), operators_1.mergeMap(function (graph) {
49230 return graph.hasNodeSequence(key) ?
49232 graph.cacheNodeSequence$(key);
49233 }), operators_1.tap(function (graph) {
49234 if (!graph.getNode(key).spatialEdges.cached) {
49235 graph.cacheSpatialEdges(key);
49237 }), operators_1.finalize(function () {
49238 if (spatialSubscription_1 == null) {
49241 _this._removeFromArray(spatialSubscription_1, _this._spatialSubscriptions);
49243 .subscribe(function (graph) { return; }, function (error) {
49244 console.error("Failed to cache spatial edges (" + key + ").", error);
49246 if (!spatialSubscription_1.closed) {
49247 this._spatialSubscriptions.push(spatialSubscription_1);
49250 return node$.pipe(operators_1.first(function (node) {
49251 return node.assetsCached;
49255 * Cache a sequence in the graph and retrieve it.
49257 * @param {string} sequenceKey - Sequence key.
49258 * @returns {Observable<Sequence>} Observable emitting a single item,
49259 * the sequence, when it has been retrieved and its assets are cached.
49260 * @throws {Error} Propagates any IO node caching errors to the caller.
49262 GraphService.prototype.cacheSequence$ = function (sequenceKey) {
49263 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
49264 if (graph.isCachingSequence(sequenceKey) || !graph.hasSequence(sequenceKey)) {
49265 return graph.cacheSequence$(sequenceKey);
49267 return rxjs_1.of(graph);
49268 }), operators_1.map(function (graph) {
49269 return graph.getSequence(sequenceKey);
49273 * Cache a sequence and its nodes in the graph and retrieve the sequence.
49275 * @description Caches a sequence and its assets are cached and
49276 * retrieves all nodes belonging to the sequence. The node assets
49277 * or edges will not be cached.
49279 * @param {string} sequenceKey - Sequence key.
49280 * @param {string} referenceNodeKey - Key of node to use as reference
49281 * for optimized caching.
49282 * @returns {Observable<Sequence>} Observable emitting a single item,
49283 * the sequence, when it has been retrieved, its assets are cached and
49284 * all nodes belonging to the sequence has been retrieved.
49285 * @throws {Error} Propagates any IO node caching errors to the caller.
49287 GraphService.prototype.cacheSequenceNodes$ = function (sequenceKey, referenceNodeKey) {
49288 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
49289 if (graph.isCachingSequence(sequenceKey) || !graph.hasSequence(sequenceKey)) {
49290 return graph.cacheSequence$(sequenceKey);
49292 return rxjs_1.of(graph);
49293 }), operators_1.mergeMap(function (graph) {
49294 if (graph.isCachingSequenceNodes(sequenceKey) || !graph.hasSequenceNodes(sequenceKey)) {
49295 return graph.cacheSequenceNodes$(sequenceKey, referenceNodeKey);
49297 return rxjs_1.of(graph);
49298 }), operators_1.map(function (graph) {
49299 return graph.getSequence(sequenceKey);
49303 * Set a spatial edge filter on the graph.
49305 * @description Resets the spatial edges of all cached nodes.
49307 * @param {FilterExpression} filter - Filter expression to be applied.
49308 * @return {Observable<Graph>} Observable emitting a single item,
49309 * the graph, when the spatial edges have been reset.
49311 GraphService.prototype.setFilter$ = function (filter) {
49312 this._resetSubscriptions(this._spatialSubscriptions);
49313 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
49314 graph.resetSpatialEdges();
49315 graph.setFilter(filter);
49316 }), operators_1.map(function (graph) {
49321 * Set the graph mode.
49323 * @description If graph mode is set to spatial, caching
49324 * is performed with emphasis on spatial edges. If graph
49325 * mode is set to sequence no tile data is requested and
49326 * no spatial edges are computed.
49328 * When setting graph mode to sequence all spatial
49329 * subscriptions are aborted.
49331 * @param {GraphMode} mode - Graph mode to set.
49333 GraphService.prototype.setGraphMode = function (mode) {
49334 if (this._graphMode === mode) {
49337 if (mode === Graph_1.GraphMode.Sequence) {
49338 this._resetSubscriptions(this._spatialSubscriptions);
49340 this._graphMode = mode;
49341 this._graphModeSubject$.next(this._graphMode);
49346 * @description Resets the graph but keeps the nodes of the
49349 * @param {Array<string>} keepKeys - Keys of nodes to keep in graph.
49350 * @return {Observable<Node>} Observable emitting a single item,
49351 * the graph, when it has been reset.
49353 GraphService.prototype.reset$ = function (keepKeys) {
49354 this._abortSubjects(this._firstGraphSubjects$);
49355 this._resetSubscriptions(this._initializeCacheSubscriptions);
49356 this._resetSubscriptions(this._sequenceSubscriptions);
49357 this._resetSubscriptions(this._spatialSubscriptions);
49358 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
49359 graph.reset(keepKeys);
49360 }), operators_1.map(function (graph) {
49365 * Uncache the graph.
49367 * @description Uncaches the graph by removing tiles, nodes and
49368 * sequences. Keeps the nodes of the supplied keys and the tiles
49369 * related to those nodes.
49371 * @param {Array<string>} keepKeys - Keys of nodes to keep in graph.
49372 * @param {string} keepSequenceKey - Optional key of sequence
49373 * for which the belonging nodes should not be disposed or
49374 * removed from the graph. These nodes may still be uncached if
49375 * not specified in keep keys param.
49376 * @return {Observable<Graph>} Observable emitting a single item,
49377 * the graph, when the graph has been uncached.
49379 GraphService.prototype.uncache$ = function (keepKeys, keepSequenceKey) {
49380 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
49381 graph.uncache(keepKeys, keepSequenceKey);
49382 }), operators_1.map(function (graph) {
49386 GraphService.prototype._abortSubjects = function (subjects) {
49387 for (var _i = 0, _a = subjects.slice(); _i < _a.length; _i++) {
49388 var subject = _a[_i];
49389 this._removeFromArray(subject, subjects);
49390 subject.error(new Error("Cache node request was aborted."));
49393 GraphService.prototype._removeFromArray = function (object, objects) {
49394 var index = objects.indexOf(object);
49395 if (index !== -1) {
49396 objects.splice(index, 1);
49399 GraphService.prototype._resetSubscriptions = function (subscriptions) {
49400 for (var _i = 0, _a = subscriptions.slice(); _i < _a.length; _i++) {
49401 var subscription = _a[_i];
49402 this._removeFromArray(subscription, subscriptions);
49403 if (!subscription.closed) {
49404 subscription.unsubscribe();
49408 return GraphService;
49410 exports.GraphService = GraphService;
49411 exports.default = GraphService;
49413 },{"../Graph":295,"rxjs":43,"rxjs/operators":241}],428:[function(require,module,exports){
49415 Object.defineProperty(exports, "__esModule", { value: true });
49416 exports.ImageLoadingService = void 0;
49417 var operators_1 = require("rxjs/operators");
49418 var rxjs_1 = require("rxjs");
49419 var ImageLoadingService = /** @class */ (function () {
49420 function ImageLoadingService() {
49421 this._loadnode$ = new rxjs_1.Subject();
49422 this._loadstatus$ = this._loadnode$.pipe(operators_1.scan(function (_a, node) {
49424 var changed = false;
49425 if (node.loadStatus.total === 0 || node.loadStatus.loaded === node.loadStatus.total) {
49426 if (node.key in nodes) {
49427 delete nodes[node.key];
49432 nodes[node.key] = node.loadStatus;
49435 return [nodes, changed];
49436 }, [{}, false]), operators_1.filter(function (_a) {
49437 var nodes = _a[0], changed = _a[1];
49439 }), operators_1.map(function (_a) {
49442 }), operators_1.publishReplay(1), operators_1.refCount());
49443 this._loadstatus$.subscribe(function () { });
49445 Object.defineProperty(ImageLoadingService.prototype, "loadnode$", {
49447 return this._loadnode$;
49452 Object.defineProperty(ImageLoadingService.prototype, "loadstatus$", {
49454 return this._loadstatus$;
49459 return ImageLoadingService;
49461 exports.ImageLoadingService = ImageLoadingService;
49463 },{"rxjs":43,"rxjs/operators":241}],429:[function(require,module,exports){
49465 Object.defineProperty(exports, "__esModule", { value: true });
49466 exports.MeshReader = void 0;
49467 var Pbf = require("pbf");
49468 var MeshReader = /** @class */ (function () {
49469 function MeshReader() {
49471 MeshReader.read = function (buffer) {
49472 var pbf = new Pbf(buffer);
49473 return pbf.readFields(MeshReader._readMeshField, { faces: [], vertices: [] });
49475 MeshReader._readMeshField = function (tag, mesh, pbf) {
49477 mesh.vertices.push(pbf.readFloat());
49479 else if (tag === 2) {
49480 mesh.faces.push(pbf.readVarint());
49485 exports.MeshReader = MeshReader;
49487 },{"pbf":40}],430:[function(require,module,exports){
49489 Object.defineProperty(exports, "__esModule", { value: true });
49490 exports.Node = void 0;
49491 var operators_1 = require("rxjs/operators");
49495 * @classdesc Represents a node in the navigation graph.
49497 * Explanation of position and bearing properties:
49499 * When images are uploaded they will have GPS information in the EXIF, this is what
49500 * is called `originalLatLon` {@link Node.originalLatLon}.
49502 * When Structure from Motions has been run for a node a `computedLatLon` that
49503 * differs from the `originalLatLon` will be created. It is different because
49504 * GPS positions are not very exact and SfM aligns the camera positions according
49505 * to the 3D reconstruction {@link Node.computedLatLon}.
49507 * At last there exist a `latLon` property which evaluates to
49508 * the `computedLatLon` from SfM if it exists but falls back
49509 * to the `originalLatLon` from the EXIF GPS otherwise {@link Node.latLon}.
49511 * Everything that is done in in the Viewer is based on the SfM positions,
49512 * i.e. `computedLatLon`. That is why the smooth transitions go in the right
49513 * direction (nd not in strange directions because of bad GPS).
49515 * E.g. when placing a marker in the Viewer it is relative to the SfM
49516 * position i.e. the `computedLatLon`.
49518 * The same concept as above also applies to the compass angle (or bearing) properties
49519 * `originalCa`, `computedCa` and `ca`.
49521 var Node = /** @class */ (function () {
49523 * Create a new node instance.
49525 * @description Nodes are always created internally by the library.
49526 * Nodes can not be added to the library through any API method.
49528 * @param {ICoreNode} coreNode - Raw core node data.
49531 function Node(core) {
49532 this._cache = null;
49536 Object.defineProperty(Node.prototype, "assetsCached", {
49538 * Get assets cached.
49540 * @description The assets that need to be cached for this property
49541 * to report true are the following: fill properties, image and mesh.
49542 * The library ensures that the current node will always have the
49545 * @returns {boolean} Value indicating whether all assets have been
49551 return this._core != null &&
49552 this._fill != null &&
49553 this._cache != null &&
49554 this._cache.image != null &&
49555 this._cache.mesh != null;
49560 Object.defineProperty(Node.prototype, "alt", {
49564 * @description If SfM has not been run the computed altitude is
49565 * set to a default value of two meters.
49567 * @returns {number} Altitude, in meters.
49570 return this._fill.calt;
49575 Object.defineProperty(Node.prototype, "ca", {
49579 * @description If the SfM computed compass angle exists it will
49580 * be returned, otherwise the original EXIF compass angle.
49582 * @returns {number} Compass angle, measured in degrees
49583 * clockwise with respect to north.
49586 return this._fill.cca != null ? this._fill.cca : this._fill.ca;
49591 Object.defineProperty(Node.prototype, "cameraProjection", {
49593 * Get cameraProjection.
49595 * @description Will be undefined if SfM has not been run.
49597 * @returns {number} The camera projection of the image.
49600 return this._fill.camera_projection_type;
49605 Object.defineProperty(Node.prototype, "capturedAt", {
49609 * @returns {number} Timestamp when the image was captured.
49612 return this._fill.captured_at;
49617 Object.defineProperty(Node.prototype, "cameraUuid", {
49621 * @description Will be undefined if the camera uuid was not
49622 * recorded in the image exif information.
49624 * @returns {string} Universally unique id for camera used
49625 * when capturing image.
49628 return this._fill.captured_with_camera_uuid;
49633 Object.defineProperty(Node.prototype, "clusterKey", {
49637 * @returns {string} Unique key of the SfM cluster to which
49638 * the node belongs.
49641 return this._fill.cluster_key;
49646 Object.defineProperty(Node.prototype, "ck1", {
49650 * @description Will not be set if SfM has not been run.
49652 * @returns {number} SfM computed radial distortion parameter
49656 return this._fill.ck1;
49661 Object.defineProperty(Node.prototype, "ck2", {
49665 * @description Will not be set if SfM has not been run.
49667 * @returns {number} SfM computed radial distortion parameter
49671 return this._fill.ck2;
49676 Object.defineProperty(Node.prototype, "computedCA", {
49680 * @description Will not be set if SfM has not been run.
49682 * @returns {number} SfM computed compass angle, measured
49683 * in degrees clockwise with respect to north.
49686 return this._fill.cca;
49691 Object.defineProperty(Node.prototype, "computedLatLon", {
49693 * Get computedLatLon.
49695 * @description Will not be set if SfM has not been run.
49697 * @returns {ILatLon} SfM computed latitude longitude in WGS84 datum,
49698 * measured in degrees.
49701 return this._core.cl;
49706 Object.defineProperty(Node.prototype, "focal", {
49710 * @description Will not be set if SfM has not been run.
49712 * @returns {number} SfM computed focal length.
49715 return this._fill.cfocal;
49720 Object.defineProperty(Node.prototype, "full", {
49724 * @description The library ensures that the current node will
49727 * @returns {boolean} Value indicating whether the node has all
49728 * properties filled.
49733 return this._fill != null;
49738 Object.defineProperty(Node.prototype, "fullPano", {
49742 * @returns {boolean} Value indicating whether the node is a complete
49746 return this._fill.gpano != null &&
49747 this._fill.gpano.CroppedAreaLeftPixels === 0 &&
49748 this._fill.gpano.CroppedAreaTopPixels === 0 &&
49749 this._fill.gpano.CroppedAreaImageWidthPixels === this._fill.gpano.FullPanoWidthPixels &&
49750 this._fill.gpano.CroppedAreaImageHeightPixels === this._fill.gpano.FullPanoHeightPixels;
49755 Object.defineProperty(Node.prototype, "gpano", {
49759 * @description Will not be set for non panoramic images.
49761 * @returns {IGPano} Panorama information for panorama images.
49764 return this._fill.gpano;
49769 Object.defineProperty(Node.prototype, "height", {
49773 * @returns {number} Height of original image, not adjusted
49777 return this._fill.height;
49782 Object.defineProperty(Node.prototype, "image", {
49786 * @description The image will always be set on the current node.
49788 * @returns {HTMLImageElement} Cached image element of the node.
49791 return this._cache.image;
49796 Object.defineProperty(Node.prototype, "image$", {
49800 * @returns {Observable<HTMLImageElement>} Observable emitting
49801 * the cached image when it is updated.
49806 return this._cache.image$;
49811 Object.defineProperty(Node.prototype, "key", {
49815 * @returns {string} Unique key of the node.
49818 return this._core.key;
49823 Object.defineProperty(Node.prototype, "latLon", {
49827 * @description If the SfM computed latitude longitude exist
49828 * it will be returned, otherwise the original EXIF latitude
49831 * @returns {ILatLon} Latitude longitude in WGS84 datum,
49832 * measured in degrees.
49835 return this._core.cl != null ? this._core.cl : this._core.l;
49840 Object.defineProperty(Node.prototype, "loadStatus", {
49844 * @returns {ILoadStatus} Value indicating the load status
49845 * of the mesh and image.
49850 return this._cache.loadStatus;
49855 Object.defineProperty(Node.prototype, "merged", {
49859 * @returns {boolean} Value indicating whether SfM has been
49860 * run on the node and the node has been merged into a
49861 * connected component.
49864 return this._fill != null &&
49865 this._fill.merge_version != null &&
49866 this._fill.merge_version > 0;
49871 Object.defineProperty(Node.prototype, "mergeCC", {
49875 * @description Will not be set if SfM has not yet been run on
49878 * @returns {number} SfM connected component key to which
49882 return this._fill.merge_cc;
49887 Object.defineProperty(Node.prototype, "mergeVersion", {
49889 * Get mergeVersion.
49891 * @returns {number} Version for which SfM was run and image was merged.
49894 return this._fill.merge_version;
49899 Object.defineProperty(Node.prototype, "mesh", {
49903 * @description The mesh will always be set on the current node.
49905 * @returns {IMesh} SfM triangulated mesh of reconstructed
49906 * atomic 3D points.
49909 return this._cache.mesh;
49914 Object.defineProperty(Node.prototype, "organizationKey", {
49916 * Get organizationKey.
49918 * @returns {string} Unique key of the organization to which
49919 * the node belongs. If the node does not belong to an
49920 * organization the organization key will be undefined.
49923 return this._fill.organization_key;
49928 Object.defineProperty(Node.prototype, "orientation", {
49932 * @returns {number} EXIF orientation of original image.
49935 return this._fill.orientation;
49940 Object.defineProperty(Node.prototype, "originalCA", {
49944 * @returns {number} Original EXIF compass angle, measured in
49948 return this._fill.ca;
49953 Object.defineProperty(Node.prototype, "originalLatLon", {
49955 * Get originalLatLon.
49957 * @returns {ILatLon} Original EXIF latitude longitude in
49958 * WGS84 datum, measured in degrees.
49961 return this._core.l;
49966 Object.defineProperty(Node.prototype, "pano", {
49970 * @returns {boolean} Value indicating whether the node is a panorama.
49971 * It could be a cropped or full panorama.
49974 return this._fill.gpano != null &&
49975 this._fill.gpano.FullPanoWidthPixels != null;
49980 Object.defineProperty(Node.prototype, "private", {
49984 * @returns {boolean} Value specifying if image is accessible to
49985 * organization members only or to everyone.
49988 return this._fill.private;
49993 Object.defineProperty(Node.prototype, "projectKey", {
49997 * @returns {string} Unique key of the project to which
49998 * the node belongs. If the node does not belong to a
49999 * project the project key will be undefined.
50001 * @deprecated This property will be deprecated in favor
50002 * of the organization key and private properties.
50005 return this._fill.project != null ?
50006 this._fill.project.key :
50012 Object.defineProperty(Node.prototype, "rotation", {
50016 * @description Will not be set if SfM has not been run.
50018 * @returns {Array<number>} Rotation vector in angle axis representation.
50021 return this._fill.c_rotation;
50026 Object.defineProperty(Node.prototype, "scale", {
50030 * @description Will not be set if SfM has not been run.
50032 * @returns {number} Scale of atomic reconstruction.
50035 return this._fill.atomic_scale;
50040 Object.defineProperty(Node.prototype, "sequenceKey", {
50044 * @returns {string} Unique key of the sequence to which
50045 * the node belongs.
50048 return this._core.sequence_key;
50053 Object.defineProperty(Node.prototype, "sequenceEdges", {
50055 * Get sequenceEdges.
50057 * @returns {IEdgeStatus} Value describing the status of the
50063 return this._cache.sequenceEdges;
50068 Object.defineProperty(Node.prototype, "sequenceEdges$", {
50070 * Get sequenceEdges$.
50072 * @description Internal observable, should not be used as an API.
50074 * @returns {Observable<IEdgeStatus>} Observable emitting
50075 * values describing the status of the sequence edges.
50080 return this._cache.sequenceEdges$;
50085 Object.defineProperty(Node.prototype, "spatialEdges", {
50087 * Get spatialEdges.
50089 * @returns {IEdgeStatus} Value describing the status of the
50095 return this._cache.spatialEdges;
50100 Object.defineProperty(Node.prototype, "spatialEdges$", {
50102 * Get spatialEdges$.
50104 * @description Internal observable, should not be used as an API.
50106 * @returns {Observable<IEdgeStatus>} Observable emitting
50107 * values describing the status of the spatial edges.
50112 return this._cache.spatialEdges$;
50117 Object.defineProperty(Node.prototype, "userKey", {
50121 * @returns {string} Unique key of the user who uploaded
50125 return this._fill.user.key;
50130 Object.defineProperty(Node.prototype, "username", {
50134 * @returns {string} Username of the user who uploaded
50138 return this._fill.user.username;
50143 Object.defineProperty(Node.prototype, "width", {
50147 * @returns {number} Width of original image, not
50148 * adjusted for orientation.
50151 return this._fill.width;
50157 * Cache the image and mesh assets.
50159 * @description The assets are always cached internally by the
50160 * library prior to setting a node as the current node.
50162 * @returns {Observable<Node>} Observable emitting this node whenever the
50163 * load status has changed and when the mesh or image has been fully loaded.
50167 Node.prototype.cacheAssets$ = function () {
50169 return this._cache.cacheAssets$(this.key, this.pano, this.merged).pipe(operators_1.map(function () {
50174 * Cache the image asset.
50176 * @description Use for caching a differently sized image than
50177 * the one currently held by the node.
50179 * @returns {Observable<Node>} Observable emitting this node whenever the
50180 * load status has changed and when the mesh or image has been fully loaded.
50184 Node.prototype.cacheImage$ = function (imageSize) {
50186 return this._cache.cacheImage$(this.key, imageSize).pipe(operators_1.map(function () {
50191 * Cache the sequence edges.
50193 * @description The sequence edges are cached asynchronously
50194 * internally by the library.
50196 * @param {Array<IEdge>} edges - Sequence edges to cache.
50199 Node.prototype.cacheSequenceEdges = function (edges) {
50200 this._cache.cacheSequenceEdges(edges);
50203 * Cache the spatial edges.
50205 * @description The spatial edges are cached asynchronously
50206 * internally by the library.
50208 * @param {Array<IEdge>} edges - Spatial edges to cache.
50211 Node.prototype.cacheSpatialEdges = function (edges) {
50212 this._cache.cacheSpatialEdges(edges);
50215 * Dispose the node.
50217 * @description Disposes all cached assets.
50220 Node.prototype.dispose = function () {
50221 if (this._cache != null) {
50222 this._cache.dispose();
50223 this._cache = null;
50229 * Initialize the node cache.
50231 * @description The node cache is initialized internally by
50234 * @param {NodeCache} cache - The node cache to set as cache.
50237 Node.prototype.initializeCache = function (cache) {
50238 if (this._cache != null) {
50239 throw new Error("Node cache already initialized (" + this.key + ").");
50241 this._cache = cache;
50244 * Fill the node with all properties.
50246 * @description The node is filled internally by
50249 * @param {IFillNode} fill - The fill node struct.
50252 Node.prototype.makeFull = function (fill) {
50253 if (fill == null) {
50254 throw new Error("Fill can not be null.");
50259 * Reset the sequence edges.
50263 Node.prototype.resetSequenceEdges = function () {
50264 this._cache.resetSequenceEdges();
50267 * Reset the spatial edges.
50271 Node.prototype.resetSpatialEdges = function () {
50272 this._cache.resetSpatialEdges();
50275 * Clears the image and mesh assets, aborts
50276 * any outstanding requests and resets edges.
50280 Node.prototype.uncache = function () {
50281 if (this._cache == null) {
50284 this._cache.dispose();
50285 this._cache = null;
50289 exports.Node = Node;
50290 exports.default = Node;
50292 },{"rxjs/operators":241}],431:[function(require,module,exports){
50293 (function (Buffer){
50295 Object.defineProperty(exports, "__esModule", { value: true });
50296 exports.NodeCache = void 0;
50297 var rxjs_1 = require("rxjs");
50298 var operators_1 = require("rxjs/operators");
50299 var Graph_1 = require("../Graph");
50300 var Utils_1 = require("../Utils");
50304 * @classdesc Represents the cached properties of a node.
50306 var NodeCache = /** @class */ (function () {
50308 * Create a new node cache instance.
50310 function NodeCache() {
50311 this._disposed = false;
50312 this._image = null;
50313 this._loadStatus = { loaded: 0, total: 0 };
50315 this._sequenceEdges = { cached: false, edges: [] };
50316 this._spatialEdges = { cached: false, edges: [] };
50317 this._imageChanged$ = new rxjs_1.Subject();
50318 this._image$ = this._imageChanged$.pipe(operators_1.startWith(null), operators_1.publishReplay(1), operators_1.refCount());
50319 this._iamgeSubscription = this._image$.subscribe();
50320 this._sequenceEdgesChanged$ = new rxjs_1.Subject();
50321 this._sequenceEdges$ = this._sequenceEdgesChanged$.pipe(operators_1.startWith(this._sequenceEdges), operators_1.publishReplay(1), operators_1.refCount());
50322 this._sequenceEdgesSubscription = this._sequenceEdges$.subscribe(function () { });
50323 this._spatialEdgesChanged$ = new rxjs_1.Subject();
50324 this._spatialEdges$ = this._spatialEdgesChanged$.pipe(operators_1.startWith(this._spatialEdges), operators_1.publishReplay(1), operators_1.refCount());
50325 this._spatialEdgesSubscription = this._spatialEdges$.subscribe(function () { });
50326 this._cachingAssets$ = null;
50328 Object.defineProperty(NodeCache.prototype, "image", {
50332 * @description Will not be set when assets have not been cached
50333 * or when the object has been disposed.
50335 * @returns {HTMLImageElement} Cached image element of the node.
50338 return this._image;
50343 Object.defineProperty(NodeCache.prototype, "image$", {
50347 * @returns {Observable<HTMLImageElement>} Observable emitting
50348 * the cached image when it is updated.
50351 return this._image$;
50356 Object.defineProperty(NodeCache.prototype, "loadStatus", {
50360 * @returns {ILoadStatus} Value indicating the load status
50361 * of the mesh and image.
50364 return this._loadStatus;
50369 Object.defineProperty(NodeCache.prototype, "mesh", {
50373 * @description Will not be set when assets have not been cached
50374 * or when the object has been disposed.
50376 * @returns {IMesh} SfM triangulated mesh of reconstructed
50377 * atomic 3D points.
50385 Object.defineProperty(NodeCache.prototype, "sequenceEdges", {
50387 * Get sequenceEdges.
50389 * @returns {IEdgeStatus} Value describing the status of the
50393 return this._sequenceEdges;
50398 Object.defineProperty(NodeCache.prototype, "sequenceEdges$", {
50400 * Get sequenceEdges$.
50402 * @returns {Observable<IEdgeStatus>} Observable emitting
50403 * values describing the status of the sequence edges.
50406 return this._sequenceEdges$;
50411 Object.defineProperty(NodeCache.prototype, "spatialEdges", {
50413 * Get spatialEdges.
50415 * @returns {IEdgeStatus} Value describing the status of the
50419 return this._spatialEdges;
50424 Object.defineProperty(NodeCache.prototype, "spatialEdges$", {
50426 * Get spatialEdges$.
50428 * @returns {Observable<IEdgeStatus>} Observable emitting
50429 * values describing the status of the spatial edges.
50432 return this._spatialEdges$;
50438 * Cache the image and mesh assets.
50440 * @param {string} key - Key of the node to cache.
50441 * @param {boolean} pano - Value indicating whether node is a panorama.
50442 * @param {boolean} merged - Value indicating whether node is merged.
50443 * @returns {Observable<NodeCache>} Observable emitting this node
50444 * cache whenever the load status has changed and when the mesh or image
50445 * has been fully loaded.
50447 NodeCache.prototype.cacheAssets$ = function (key, pano, merged) {
50449 if (this._cachingAssets$ != null) {
50450 return this._cachingAssets$;
50452 var imageSize = pano ?
50453 Utils_1.Settings.basePanoramaSize :
50454 Utils_1.Settings.baseImageSize;
50455 this._cachingAssets$ = rxjs_1.combineLatest(this._cacheImage$(key, imageSize), this._cacheMesh$(key, merged)).pipe(operators_1.map(function (_a) {
50456 var imageStatus = _a[0], meshStatus = _a[1];
50457 _this._loadStatus.loaded = 0;
50458 _this._loadStatus.total = 0;
50460 _this._mesh = meshStatus.object;
50461 _this._loadStatus.loaded += meshStatus.loaded.loaded;
50462 _this._loadStatus.total += meshStatus.loaded.total;
50465 _this._image = imageStatus.object;
50466 _this._loadStatus.loaded += imageStatus.loaded.loaded;
50467 _this._loadStatus.total += imageStatus.loaded.total;
50470 }), operators_1.finalize(function () {
50471 _this._cachingAssets$ = null;
50472 }), operators_1.publishReplay(1), operators_1.refCount());
50473 this._cachingAssets$.pipe(operators_1.first(function (nodeCache) {
50474 return !!nodeCache._image;
50476 .subscribe(function (nodeCache) {
50477 _this._imageChanged$.next(_this._image);
50478 }, function (error) { });
50479 return this._cachingAssets$;
50482 * Cache an image with a higher resolution than the current one.
50484 * @param {string} key - Key of the node to cache.
50485 * @param {ImageSize} imageSize - The size to cache.
50486 * @returns {Observable<NodeCache>} Observable emitting a single item,
50487 * the node cache, when the image has been cached. If supplied image
50488 * size is not larger than the current image size the node cache is
50489 * returned immediately.
50491 NodeCache.prototype.cacheImage$ = function (key, imageSize) {
50493 if (this._image != null && imageSize <= Math.max(this._image.width, this._image.height)) {
50494 return rxjs_1.of(this);
50496 var cacheImage$ = this._cacheImage$(key, imageSize).pipe(operators_1.first(function (status) {
50497 return status.object != null;
50498 }), operators_1.tap(function (status) {
50499 _this._disposeImage();
50500 _this._image = status.object;
50501 }), operators_1.map(function (imageStatus) {
50503 }), operators_1.publishReplay(1), operators_1.refCount());
50505 .subscribe(function (nodeCache) {
50506 _this._imageChanged$.next(_this._image);
50507 }, function (error) { });
50508 return cacheImage$;
50511 * Cache the sequence edges.
50513 * @param {Array<IEdge>} edges - Sequence edges to cache.
50515 NodeCache.prototype.cacheSequenceEdges = function (edges) {
50516 this._sequenceEdges = { cached: true, edges: edges };
50517 this._sequenceEdgesChanged$.next(this._sequenceEdges);
50520 * Cache the spatial edges.
50522 * @param {Array<IEdge>} edges - Spatial edges to cache.
50524 NodeCache.prototype.cacheSpatialEdges = function (edges) {
50525 this._spatialEdges = { cached: true, edges: edges };
50526 this._spatialEdgesChanged$.next(this._spatialEdges);
50529 * Dispose the node cache.
50531 * @description Disposes all cached assets and unsubscribes to
50534 NodeCache.prototype.dispose = function () {
50535 this._iamgeSubscription.unsubscribe();
50536 this._sequenceEdgesSubscription.unsubscribe();
50537 this._spatialEdgesSubscription.unsubscribe();
50538 this._disposeImage();
50540 this._loadStatus.loaded = 0;
50541 this._loadStatus.total = 0;
50542 this._sequenceEdges = { cached: false, edges: [] };
50543 this._spatialEdges = { cached: false, edges: [] };
50544 this._imageChanged$.next(null);
50545 this._sequenceEdgesChanged$.next(this._sequenceEdges);
50546 this._spatialEdgesChanged$.next(this._spatialEdges);
50547 this._disposed = true;
50548 if (this._imageRequest != null) {
50549 this._imageRequest.abort();
50551 if (this._meshRequest != null) {
50552 this._meshRequest.abort();
50556 * Reset the sequence edges.
50558 NodeCache.prototype.resetSequenceEdges = function () {
50559 this._sequenceEdges = { cached: false, edges: [] };
50560 this._sequenceEdgesChanged$.next(this._sequenceEdges);
50563 * Reset the spatial edges.
50565 NodeCache.prototype.resetSpatialEdges = function () {
50566 this._spatialEdges = { cached: false, edges: [] };
50567 this._spatialEdgesChanged$.next(this._spatialEdges);
50572 * @param {string} key - Key of the node to cache.
50573 * @param {boolean} pano - Value indicating whether node is a panorama.
50574 * @returns {Observable<ILoadStatusObject<HTMLImageElement>>} Observable
50575 * emitting a load status object every time the load status changes
50576 * and completes when the image is fully loaded.
50578 NodeCache.prototype._cacheImage$ = function (key, imageSize) {
50580 return rxjs_1.Observable.create(function (subscriber) {
50581 var xmlHTTP = new XMLHttpRequest();
50582 xmlHTTP.open("GET", Utils_1.Urls.thumbnail(key, imageSize, Utils_1.Urls.origin), true);
50583 xmlHTTP.responseType = "arraybuffer";
50584 xmlHTTP.timeout = 15000;
50585 xmlHTTP.onload = function (pe) {
50586 if (xmlHTTP.status !== 200) {
50587 _this._imageRequest = null;
50588 subscriber.error(new Error("Failed to fetch image (" + key + "). Status: " + xmlHTTP.status + ", " + xmlHTTP.statusText));
50591 var image = new Image();
50592 image.crossOrigin = "Anonymous";
50593 image.onload = function (e) {
50594 _this._imageRequest = null;
50595 if (_this._disposed) {
50596 window.URL.revokeObjectURL(image.src);
50597 subscriber.error(new Error("Image load was aborted (" + key + ")"));
50600 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: image });
50601 subscriber.complete();
50603 image.onerror = function (error) {
50604 _this._imageRequest = null;
50605 subscriber.error(new Error("Failed to load image (" + key + ")"));
50607 var blob = new Blob([xmlHTTP.response]);
50608 image.src = window.URL.createObjectURL(blob);
50610 xmlHTTP.onprogress = function (pe) {
50611 if (_this._disposed) {
50614 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: null });
50616 xmlHTTP.onerror = function (error) {
50617 _this._imageRequest = null;
50618 subscriber.error(new Error("Failed to fetch image (" + key + ")"));
50620 xmlHTTP.ontimeout = function (e) {
50621 _this._imageRequest = null;
50622 subscriber.error(new Error("Image request timed out (" + key + ")"));
50624 xmlHTTP.onabort = function (event) {
50625 _this._imageRequest = null;
50626 subscriber.error(new Error("Image request was aborted (" + key + ")"));
50628 _this._imageRequest = xmlHTTP;
50629 xmlHTTP.send(null);
50635 * @param {string} key - Key of the node to cache.
50636 * @param {boolean} merged - Value indicating whether node is merged.
50637 * @returns {Observable<ILoadStatusObject<IMesh>>} Observable emitting
50638 * a load status object every time the load status changes and completes
50639 * when the mesh is fully loaded.
50641 NodeCache.prototype._cacheMesh$ = function (key, merged) {
50643 return rxjs_1.Observable.create(function (subscriber) {
50645 subscriber.next(_this._createEmptyMeshLoadStatus());
50646 subscriber.complete();
50649 var xmlHTTP = new XMLHttpRequest();
50650 xmlHTTP.open("GET", Utils_1.Urls.protoMesh(key), true);
50651 xmlHTTP.responseType = "arraybuffer";
50652 xmlHTTP.timeout = 15000;
50653 xmlHTTP.onload = function (pe) {
50654 _this._meshRequest = null;
50655 if (_this._disposed) {
50658 var mesh = xmlHTTP.status === 200 ?
50659 Graph_1.MeshReader.read(new Buffer(xmlHTTP.response)) :
50660 { faces: [], vertices: [] };
50661 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: mesh });
50662 subscriber.complete();
50664 xmlHTTP.onprogress = function (pe) {
50665 if (_this._disposed) {
50668 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: null });
50670 xmlHTTP.onerror = function (e) {
50671 _this._meshRequest = null;
50672 console.error("Failed to cache mesh (" + key + ")");
50673 subscriber.next(_this._createEmptyMeshLoadStatus());
50674 subscriber.complete();
50676 xmlHTTP.ontimeout = function (e) {
50677 _this._meshRequest = null;
50678 console.error("Mesh request timed out (" + key + ")");
50679 subscriber.next(_this._createEmptyMeshLoadStatus());
50680 subscriber.complete();
50682 xmlHTTP.onabort = function (e) {
50683 _this._meshRequest = null;
50684 subscriber.error(new Error("Mesh request was aborted (" + key + ")"));
50686 _this._meshRequest = xmlHTTP;
50687 xmlHTTP.send(null);
50691 * Create a load status object with an empty mesh.
50693 * @returns {ILoadStatusObject<IMesh>} Load status object
50696 NodeCache.prototype._createEmptyMeshLoadStatus = function () {
50698 loaded: { loaded: 0, total: 0 },
50699 object: { faces: [], vertices: [] },
50702 NodeCache.prototype._disposeImage = function () {
50703 if (this._image != null) {
50704 window.URL.revokeObjectURL(this._image.src);
50706 this._image = null;
50710 exports.NodeCache = NodeCache;
50711 exports.default = NodeCache;
50713 }).call(this,require("buffer").Buffer)
50715 },{"../Graph":295,"../Utils":301,"buffer":6,"rxjs":43,"rxjs/operators":241}],432:[function(require,module,exports){
50717 Object.defineProperty(exports, "__esModule", { value: true });
50718 exports.Sequence = void 0;
50722 * @classdesc Represents a sequence of ordered nodes.
50724 var Sequence = /** @class */ (function () {
50726 * Create a new sequene instance.
50728 * @param {ISequence} sequence - Raw sequence data.
50730 function Sequence(sequence) {
50731 this._key = sequence.key;
50732 this._keys = sequence.keys;
50734 Object.defineProperty(Sequence.prototype, "key", {
50738 * @returns {string} Unique sequence key.
50746 Object.defineProperty(Sequence.prototype, "keys", {
50750 * @returns {Array<string>} Array of ordered node keys in the sequence.
50759 * Dispose the sequence.
50761 * @description Disposes all cached assets.
50763 Sequence.prototype.dispose = function () {
50768 * Find the next node key in the sequence with respect to
50769 * the provided node key.
50771 * @param {string} key - Reference node key.
50772 * @returns {string} Next key in sequence if it exists, null otherwise.
50774 Sequence.prototype.findNextKey = function (key) {
50775 var i = this._keys.indexOf(key);
50776 if ((i + 1) >= this._keys.length || i === -1) {
50780 return this._keys[i + 1];
50784 * Find the previous node key in the sequence with respect to
50785 * the provided node key.
50787 * @param {string} key - Reference node key.
50788 * @returns {string} Previous key in sequence if it exists, null otherwise.
50790 Sequence.prototype.findPrevKey = function (key) {
50791 var i = this._keys.indexOf(key);
50792 if (i === 0 || i === -1) {
50796 return this._keys[i - 1];
50801 exports.Sequence = Sequence;
50802 exports.default = Sequence;
50804 },{}],433:[function(require,module,exports){
50806 Object.defineProperty(exports, "__esModule", { value: true });
50807 exports.EdgeCalculator = void 0;
50808 var THREE = require("three");
50809 var Edge_1 = require("../../Edge");
50810 var Error_1 = require("../../Error");
50811 var Geo_1 = require("../../Geo");
50813 * @class EdgeCalculator
50815 * @classdesc Represents a class for calculating node edges.
50817 var EdgeCalculator = /** @class */ (function () {
50819 * Create a new edge calculator instance.
50821 * @param {EdgeCalculatorSettings} settings - Settings struct.
50822 * @param {EdgeCalculatorDirections} directions - Directions struct.
50823 * @param {EdgeCalculatorCoefficients} coefficients - Coefficients struct.
50825 function EdgeCalculator(settings, directions, coefficients) {
50826 this._spatial = new Geo_1.Spatial();
50827 this._geoCoords = new Geo_1.GeoCoords();
50828 this._settings = settings != null ? settings : new Edge_1.EdgeCalculatorSettings();
50829 this._directions = directions != null ? directions : new Edge_1.EdgeCalculatorDirections();
50830 this._coefficients = coefficients != null ? coefficients : new Edge_1.EdgeCalculatorCoefficients();
50833 * Returns the potential edges to destination nodes for a set
50834 * of nodes with respect to a source node.
50836 * @param {Node} node - Source node.
50837 * @param {Array<Node>} nodes - Potential destination nodes.
50838 * @param {Array<string>} fallbackKeys - Keys for destination nodes that should
50839 * be returned even if they do not meet the criteria for a potential edge.
50840 * @throws {ArgumentMapillaryError} If node is not full.
50842 EdgeCalculator.prototype.getPotentialEdges = function (node, potentialNodes, fallbackKeys) {
50844 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
50846 if (!node.merged) {
50849 var currentDirection = this._spatial.viewingDirection(node.rotation);
50850 var currentVerticalDirection = this._spatial.angleToPlane(currentDirection.toArray(), [0, 0, 1]);
50851 var potentialEdges = [];
50852 for (var _i = 0, potentialNodes_1 = potentialNodes; _i < potentialNodes_1.length; _i++) {
50853 var potential = potentialNodes_1[_i];
50854 if (!potential.merged ||
50855 potential.key === node.key) {
50858 var enu = this._geoCoords.geodeticToEnu(potential.latLon.lat, potential.latLon.lon, potential.alt, node.latLon.lat, node.latLon.lon, node.alt);
50859 var motion = new THREE.Vector3(enu[0], enu[1], enu[2]);
50860 var distance = motion.length();
50861 if (distance > this._settings.maxDistance &&
50862 fallbackKeys.indexOf(potential.key) < 0) {
50865 var motionChange = this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, motion.x, motion.y);
50866 var verticalMotion = this._spatial.angleToPlane(motion.toArray(), [0, 0, 1]);
50867 var direction = this._spatial.viewingDirection(potential.rotation);
50868 var directionChange = this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, direction.x, direction.y);
50869 var verticalDirection = this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
50870 var verticalDirectionChange = verticalDirection - currentVerticalDirection;
50871 var rotation = this._spatial.relativeRotationAngle(node.rotation, potential.rotation);
50872 var worldMotionAzimuth = this._spatial.angleBetweenVector2(1, 0, motion.x, motion.y);
50873 var sameSequence = potential.sequenceKey != null &&
50874 node.sequenceKey != null &&
50875 potential.sequenceKey === node.sequenceKey;
50876 var sameMergeCC = (potential.mergeCC == null && node.mergeCC == null) ||
50877 potential.mergeCC === node.mergeCC;
50878 var sameUser = potential.userKey === node.userKey;
50879 var potentialEdge = {
50880 capturedAt: potential.capturedAt,
50881 croppedPano: potential.pano && !potential.fullPano,
50882 directionChange: directionChange,
50883 distance: distance,
50884 fullPano: potential.fullPano,
50885 key: potential.key,
50886 motionChange: motionChange,
50887 rotation: rotation,
50888 sameMergeCC: sameMergeCC,
50889 sameSequence: sameSequence,
50890 sameUser: sameUser,
50891 sequenceKey: potential.sequenceKey,
50892 verticalDirectionChange: verticalDirectionChange,
50893 verticalMotion: verticalMotion,
50894 worldMotionAzimuth: worldMotionAzimuth,
50896 potentialEdges.push(potentialEdge);
50898 return potentialEdges;
50901 * Computes the sequence edges for a node.
50903 * @param {Node} node - Source node.
50904 * @throws {ArgumentMapillaryError} If node is not full.
50906 EdgeCalculator.prototype.computeSequenceEdges = function (node, sequence) {
50908 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
50910 if (node.sequenceKey !== sequence.key) {
50911 throw new Error_1.ArgumentMapillaryError("Node and sequence does not correspond.");
50914 var nextKey = sequence.findNextKey(node.key);
50915 if (nextKey != null) {
50918 direction: Edge_1.EdgeDirection.Next,
50919 worldMotionAzimuth: Number.NaN,
50925 var prevKey = sequence.findPrevKey(node.key);
50926 if (prevKey != null) {
50929 direction: Edge_1.EdgeDirection.Prev,
50930 worldMotionAzimuth: Number.NaN,
50939 * Computes the similar edges for a node.
50941 * @description Similar edges for perspective images and cropped panoramas
50942 * look roughly in the same direction and are positioned closed to the node.
50943 * Similar edges for full panoramas only target other full panoramas.
50945 * @param {Node} node - Source node.
50946 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
50947 * @throws {ArgumentMapillaryError} If node is not full.
50949 EdgeCalculator.prototype.computeSimilarEdges = function (node, potentialEdges) {
50952 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
50954 var nodeFullPano = node.fullPano;
50955 var sequenceGroups = {};
50956 for (var _i = 0, potentialEdges_1 = potentialEdges; _i < potentialEdges_1.length; _i++) {
50957 var potentialEdge = potentialEdges_1[_i];
50958 if (potentialEdge.sequenceKey == null) {
50961 if (potentialEdge.sameSequence) {
50964 if (nodeFullPano) {
50965 if (!potentialEdge.fullPano) {
50970 if (!potentialEdge.fullPano &&
50971 Math.abs(potentialEdge.directionChange) > this._settings.similarMaxDirectionChange) {
50975 if (potentialEdge.distance > this._settings.similarMaxDistance) {
50978 if (potentialEdge.sameUser &&
50979 Math.abs(potentialEdge.capturedAt - node.capturedAt) <
50980 this._settings.similarMinTimeDifference) {
50983 if (sequenceGroups[potentialEdge.sequenceKey] == null) {
50984 sequenceGroups[potentialEdge.sequenceKey] = [];
50986 sequenceGroups[potentialEdge.sequenceKey].push(potentialEdge);
50988 var similarEdges = [];
50989 var calculateScore = node.fullPano ?
50990 function (potentialEdge) {
50991 return potentialEdge.distance;
50993 function (potentialEdge) {
50994 return _this._coefficients.similarDistance * potentialEdge.distance +
50995 _this._coefficients.similarRotation * potentialEdge.rotation;
50997 for (var sequenceKey in sequenceGroups) {
50998 if (!sequenceGroups.hasOwnProperty(sequenceKey)) {
51001 var lowestScore = Number.MAX_VALUE;
51002 var similarEdge = null;
51003 for (var _a = 0, _b = sequenceGroups[sequenceKey]; _a < _b.length; _a++) {
51004 var potentialEdge = _b[_a];
51005 var score = calculateScore(potentialEdge);
51006 if (score < lowestScore) {
51007 lowestScore = score;
51008 similarEdge = potentialEdge;
51011 if (similarEdge == null) {
51014 similarEdges.push(similarEdge);
51016 return similarEdges
51017 .map(function (potentialEdge) {
51020 direction: Edge_1.EdgeDirection.Similar,
51021 worldMotionAzimuth: potentialEdge.worldMotionAzimuth,
51024 to: potentialEdge.key,
51029 * Computes the step edges for a perspective node.
51031 * @description Step edge targets can only be other perspective nodes.
51032 * Returns an empty array for cropped and full panoramas.
51034 * @param {Node} node - Source node.
51035 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
51036 * @param {string} prevKey - Key of previous node in sequence.
51037 * @param {string} prevKey - Key of next node in sequence.
51038 * @throws {ArgumentMapillaryError} If node is not full.
51040 EdgeCalculator.prototype.computeStepEdges = function (node, potentialEdges, prevKey, nextKey) {
51042 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
51048 for (var k in this._directions.steps) {
51049 if (!this._directions.steps.hasOwnProperty(k)) {
51052 var step = this._directions.steps[k];
51053 var lowestScore = Number.MAX_VALUE;
51055 var fallback = null;
51056 for (var _i = 0, potentialEdges_2 = potentialEdges; _i < potentialEdges_2.length; _i++) {
51057 var potential = potentialEdges_2[_i];
51058 if (potential.croppedPano || potential.fullPano) {
51061 if (Math.abs(potential.directionChange) > this._settings.stepMaxDirectionChange) {
51064 var motionDifference = this._spatial.angleDifference(step.motionChange, potential.motionChange);
51065 var directionMotionDifference = this._spatial.angleDifference(potential.directionChange, motionDifference);
51066 var drift = Math.max(Math.abs(motionDifference), Math.abs(directionMotionDifference));
51067 if (Math.abs(drift) > this._settings.stepMaxDrift) {
51070 var potentialKey = potential.key;
51071 if (step.useFallback && (potentialKey === prevKey || potentialKey === nextKey)) {
51072 fallback = potential;
51074 if (potential.distance > this._settings.stepMaxDistance) {
51077 motionDifference = Math.sqrt(motionDifference * motionDifference +
51078 potential.verticalMotion * potential.verticalMotion);
51079 var score = this._coefficients.stepPreferredDistance *
51080 Math.abs(potential.distance - this._settings.stepPreferredDistance) /
51081 this._settings.stepMaxDistance +
51082 this._coefficients.stepMotion * motionDifference / this._settings.stepMaxDrift +
51083 this._coefficients.stepRotation * potential.rotation / this._settings.stepMaxDirectionChange +
51084 this._coefficients.stepSequencePenalty * (potential.sameSequence ? 0 : 1) +
51085 this._coefficients.stepMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
51086 if (score < lowestScore) {
51087 lowestScore = score;
51091 edge = edge == null ? fallback : edge;
51092 if (edge != null) {
51095 direction: step.direction,
51096 worldMotionAzimuth: edge.worldMotionAzimuth,
51106 * Computes the turn edges for a perspective node.
51108 * @description Turn edge targets can only be other perspective images.
51109 * Returns an empty array for cropped and full panoramas.
51111 * @param {Node} node - Source node.
51112 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
51113 * @throws {ArgumentMapillaryError} If node is not full.
51115 EdgeCalculator.prototype.computeTurnEdges = function (node, potentialEdges) {
51117 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
51123 for (var k in this._directions.turns) {
51124 if (!this._directions.turns.hasOwnProperty(k)) {
51127 var turn = this._directions.turns[k];
51128 var lowestScore = Number.MAX_VALUE;
51130 for (var _i = 0, potentialEdges_3 = potentialEdges; _i < potentialEdges_3.length; _i++) {
51131 var potential = potentialEdges_3[_i];
51132 if (potential.croppedPano || potential.fullPano) {
51135 if (potential.distance > this._settings.turnMaxDistance) {
51138 var rig = turn.direction !== Edge_1.EdgeDirection.TurnU &&
51139 potential.distance < this._settings.turnMaxRigDistance &&
51140 Math.abs(potential.directionChange) > this._settings.turnMinRigDirectionChange;
51141 var directionDifference = this._spatial.angleDifference(turn.directionChange, potential.directionChange);
51142 var score = void 0;
51144 potential.directionChange * turn.directionChange > 0 &&
51145 Math.abs(potential.directionChange) < Math.abs(turn.directionChange)) {
51146 score = -Math.PI / 2 + Math.abs(potential.directionChange);
51149 if (Math.abs(directionDifference) > this._settings.turnMaxDirectionChange) {
51152 var motionDifference = turn.motionChange ?
51153 this._spatial.angleDifference(turn.motionChange, potential.motionChange) : 0;
51154 motionDifference = Math.sqrt(motionDifference * motionDifference +
51155 potential.verticalMotion * potential.verticalMotion);
51157 this._coefficients.turnDistance * potential.distance /
51158 this._settings.turnMaxDistance +
51159 this._coefficients.turnMotion * motionDifference / Math.PI +
51160 this._coefficients.turnSequencePenalty * (potential.sameSequence ? 0 : 1) +
51161 this._coefficients.turnMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
51163 if (score < lowestScore) {
51164 lowestScore = score;
51168 if (edge != null) {
51171 direction: turn.direction,
51172 worldMotionAzimuth: edge.worldMotionAzimuth,
51182 * Computes the pano edges for a perspective node.
51184 * @description Perspective to pano edge targets can only be
51185 * full pano nodes. Returns an empty array for cropped and full panoramas.
51187 * @param {Node} node - Source node.
51188 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
51189 * @throws {ArgumentMapillaryError} If node is not full.
51191 EdgeCalculator.prototype.computePerspectiveToPanoEdges = function (node, potentialEdges) {
51193 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
51198 var lowestScore = Number.MAX_VALUE;
51200 for (var _i = 0, potentialEdges_4 = potentialEdges; _i < potentialEdges_4.length; _i++) {
51201 var potential = potentialEdges_4[_i];
51202 if (!potential.fullPano) {
51205 var score = this._coefficients.panoPreferredDistance *
51206 Math.abs(potential.distance - this._settings.panoPreferredDistance) /
51207 this._settings.panoMaxDistance +
51208 this._coefficients.panoMotion * Math.abs(potential.motionChange) / Math.PI +
51209 this._coefficients.panoMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
51210 if (score < lowestScore) {
51211 lowestScore = score;
51215 if (edge == null) {
51221 direction: Edge_1.EdgeDirection.Pano,
51222 worldMotionAzimuth: edge.worldMotionAzimuth,
51230 * Computes the full pano and step edges for a full pano node.
51232 * @description Pano to pano edge targets can only be
51233 * full pano nodes. Pano to step edge targets can only be perspective
51235 * Returns an empty array for cropped panoramas and perspective nodes.
51237 * @param {Node} node - Source node.
51238 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
51239 * @throws {ArgumentMapillaryError} If node is not full.
51241 EdgeCalculator.prototype.computePanoEdges = function (node, potentialEdges) {
51243 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
51245 if (!node.fullPano) {
51248 var panoEdges = [];
51249 var potentialPanos = [];
51250 var potentialSteps = [];
51251 for (var _i = 0, potentialEdges_5 = potentialEdges; _i < potentialEdges_5.length; _i++) {
51252 var potential = potentialEdges_5[_i];
51253 if (potential.distance > this._settings.panoMaxDistance) {
51256 if (potential.fullPano) {
51257 if (potential.distance < this._settings.panoMinDistance) {
51260 potentialPanos.push(potential);
51263 if (potential.croppedPano) {
51266 for (var k in this._directions.panos) {
51267 if (!this._directions.panos.hasOwnProperty(k)) {
51270 var pano = this._directions.panos[k];
51271 var turn = this._spatial.angleDifference(potential.directionChange, potential.motionChange);
51272 var turnChange = this._spatial.angleDifference(pano.directionChange, turn);
51273 if (Math.abs(turnChange) > this._settings.panoMaxStepTurnChange) {
51276 potentialSteps.push([pano.direction, potential]);
51277 // break if step direction found
51282 var maxRotationDifference = Math.PI / this._settings.panoMaxItems;
51283 var occupiedAngles = [];
51284 var stepAngles = [];
51285 for (var index = 0; index < this._settings.panoMaxItems; index++) {
51286 var rotation = index / this._settings.panoMaxItems * 2 * Math.PI;
51287 var lowestScore = Number.MAX_VALUE;
51289 for (var _a = 0, potentialPanos_1 = potentialPanos; _a < potentialPanos_1.length; _a++) {
51290 var potential = potentialPanos_1[_a];
51291 var motionDifference = this._spatial.angleDifference(rotation, potential.motionChange);
51292 if (Math.abs(motionDifference) > maxRotationDifference) {
51295 var occupiedDifference = Number.MAX_VALUE;
51296 for (var _b = 0, occupiedAngles_1 = occupiedAngles; _b < occupiedAngles_1.length; _b++) {
51297 var occupiedAngle = occupiedAngles_1[_b];
51298 var difference = Math.abs(this._spatial.angleDifference(occupiedAngle, potential.motionChange));
51299 if (difference < occupiedDifference) {
51300 occupiedDifference = difference;
51303 if (occupiedDifference <= maxRotationDifference) {
51306 var score = this._coefficients.panoPreferredDistance *
51307 Math.abs(potential.distance - this._settings.panoPreferredDistance) /
51308 this._settings.panoMaxDistance +
51309 this._coefficients.panoMotion * Math.abs(motionDifference) / maxRotationDifference +
51310 this._coefficients.panoSequencePenalty * (potential.sameSequence ? 0 : 1) +
51311 this._coefficients.panoMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
51312 if (score < lowestScore) {
51313 lowestScore = score;
51317 if (edge != null) {
51318 occupiedAngles.push(edge.motionChange);
51321 direction: Edge_1.EdgeDirection.Pano,
51322 worldMotionAzimuth: edge.worldMotionAzimuth,
51329 stepAngles.push(rotation);
51332 var occupiedStepAngles = {};
51333 occupiedStepAngles[Edge_1.EdgeDirection.Pano] = occupiedAngles;
51334 occupiedStepAngles[Edge_1.EdgeDirection.StepForward] = [];
51335 occupiedStepAngles[Edge_1.EdgeDirection.StepLeft] = [];
51336 occupiedStepAngles[Edge_1.EdgeDirection.StepBackward] = [];
51337 occupiedStepAngles[Edge_1.EdgeDirection.StepRight] = [];
51338 for (var _c = 0, stepAngles_1 = stepAngles; _c < stepAngles_1.length; _c++) {
51339 var stepAngle = stepAngles_1[_c];
51340 var occupations = [];
51341 for (var k in this._directions.panos) {
51342 if (!this._directions.panos.hasOwnProperty(k)) {
51345 var pano = this._directions.panos[k];
51346 var allOccupiedAngles = occupiedStepAngles[Edge_1.EdgeDirection.Pano]
51347 .concat(occupiedStepAngles[pano.direction])
51348 .concat(occupiedStepAngles[pano.prev])
51349 .concat(occupiedStepAngles[pano.next]);
51350 var lowestScore = Number.MAX_VALUE;
51352 for (var _d = 0, potentialSteps_1 = potentialSteps; _d < potentialSteps_1.length; _d++) {
51353 var potential = potentialSteps_1[_d];
51354 if (potential[0] !== pano.direction) {
51357 var motionChange = this._spatial.angleDifference(stepAngle, potential[1].motionChange);
51358 if (Math.abs(motionChange) > maxRotationDifference) {
51361 var minOccupiedDifference = Number.MAX_VALUE;
51362 for (var _e = 0, allOccupiedAngles_1 = allOccupiedAngles; _e < allOccupiedAngles_1.length; _e++) {
51363 var occupiedAngle = allOccupiedAngles_1[_e];
51364 var occupiedDifference = Math.abs(this._spatial.angleDifference(occupiedAngle, potential[1].motionChange));
51365 if (occupiedDifference < minOccupiedDifference) {
51366 minOccupiedDifference = occupiedDifference;
51369 if (minOccupiedDifference <= maxRotationDifference) {
51372 var score = this._coefficients.panoPreferredDistance *
51373 Math.abs(potential[1].distance - this._settings.panoPreferredDistance) /
51374 this._settings.panoMaxDistance +
51375 this._coefficients.panoMotion * Math.abs(motionChange) / maxRotationDifference +
51376 this._coefficients.panoMergeCCPenalty * (potential[1].sameMergeCC ? 0 : 1);
51377 if (score < lowestScore) {
51378 lowestScore = score;
51382 if (edge != null) {
51383 occupations.push(edge);
51386 direction: edge[0],
51387 worldMotionAzimuth: edge[1].worldMotionAzimuth,
51394 for (var _f = 0, occupations_1 = occupations; _f < occupations_1.length; _f++) {
51395 var occupation = occupations_1[_f];
51396 occupiedStepAngles[occupation[0]].push(occupation[1].motionChange);
51401 return EdgeCalculator;
51403 exports.EdgeCalculator = EdgeCalculator;
51404 exports.default = EdgeCalculator;
51406 },{"../../Edge":292,"../../Error":293,"../../Geo":294,"three":242}],434:[function(require,module,exports){
51408 Object.defineProperty(exports, "__esModule", { value: true });
51409 exports.EdgeCalculatorCoefficients = void 0;
51410 var EdgeCalculatorCoefficients = /** @class */ (function () {
51411 function EdgeCalculatorCoefficients() {
51412 this.panoPreferredDistance = 2;
51413 this.panoMotion = 2;
51414 this.panoSequencePenalty = 1;
51415 this.panoMergeCCPenalty = 4;
51416 this.stepPreferredDistance = 4;
51417 this.stepMotion = 3;
51418 this.stepRotation = 4;
51419 this.stepSequencePenalty = 2;
51420 this.stepMergeCCPenalty = 6;
51421 this.similarDistance = 2;
51422 this.similarRotation = 3;
51423 this.turnDistance = 4;
51424 this.turnMotion = 2;
51425 this.turnSequencePenalty = 1;
51426 this.turnMergeCCPenalty = 4;
51428 return EdgeCalculatorCoefficients;
51430 exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients;
51431 exports.default = EdgeCalculatorCoefficients;
51433 },{}],435:[function(require,module,exports){
51435 Object.defineProperty(exports, "__esModule", { value: true });
51436 exports.EdgeCalculatorDirections = void 0;
51437 var Edge_1 = require("../../Edge");
51438 var EdgeCalculatorDirections = /** @class */ (function () {
51439 function EdgeCalculatorDirections() {
51443 this.steps[Edge_1.EdgeDirection.StepForward] = {
51444 direction: Edge_1.EdgeDirection.StepForward,
51448 this.steps[Edge_1.EdgeDirection.StepBackward] = {
51449 direction: Edge_1.EdgeDirection.StepBackward,
51450 motionChange: Math.PI,
51453 this.steps[Edge_1.EdgeDirection.StepLeft] = {
51454 direction: Edge_1.EdgeDirection.StepLeft,
51455 motionChange: Math.PI / 2,
51456 useFallback: false,
51458 this.steps[Edge_1.EdgeDirection.StepRight] = {
51459 direction: Edge_1.EdgeDirection.StepRight,
51460 motionChange: -Math.PI / 2,
51461 useFallback: false,
51463 this.turns[Edge_1.EdgeDirection.TurnLeft] = {
51464 direction: Edge_1.EdgeDirection.TurnLeft,
51465 directionChange: Math.PI / 2,
51466 motionChange: Math.PI / 4,
51468 this.turns[Edge_1.EdgeDirection.TurnRight] = {
51469 direction: Edge_1.EdgeDirection.TurnRight,
51470 directionChange: -Math.PI / 2,
51471 motionChange: -Math.PI / 4,
51473 this.turns[Edge_1.EdgeDirection.TurnU] = {
51474 direction: Edge_1.EdgeDirection.TurnU,
51475 directionChange: Math.PI,
51476 motionChange: null,
51478 this.panos[Edge_1.EdgeDirection.StepForward] = {
51479 direction: Edge_1.EdgeDirection.StepForward,
51480 directionChange: 0,
51481 next: Edge_1.EdgeDirection.StepLeft,
51482 prev: Edge_1.EdgeDirection.StepRight,
51484 this.panos[Edge_1.EdgeDirection.StepBackward] = {
51485 direction: Edge_1.EdgeDirection.StepBackward,
51486 directionChange: Math.PI,
51487 next: Edge_1.EdgeDirection.StepRight,
51488 prev: Edge_1.EdgeDirection.StepLeft,
51490 this.panos[Edge_1.EdgeDirection.StepLeft] = {
51491 direction: Edge_1.EdgeDirection.StepLeft,
51492 directionChange: Math.PI / 2,
51493 next: Edge_1.EdgeDirection.StepBackward,
51494 prev: Edge_1.EdgeDirection.StepForward,
51496 this.panos[Edge_1.EdgeDirection.StepRight] = {
51497 direction: Edge_1.EdgeDirection.StepRight,
51498 directionChange: -Math.PI / 2,
51499 next: Edge_1.EdgeDirection.StepForward,
51500 prev: Edge_1.EdgeDirection.StepBackward,
51503 return EdgeCalculatorDirections;
51505 exports.EdgeCalculatorDirections = EdgeCalculatorDirections;
51507 },{"../../Edge":292}],436:[function(require,module,exports){
51509 Object.defineProperty(exports, "__esModule", { value: true });
51510 exports.EdgeCalculatorSettings = void 0;
51511 var EdgeCalculatorSettings = /** @class */ (function () {
51512 function EdgeCalculatorSettings() {
51513 this.panoMinDistance = 0.1;
51514 this.panoMaxDistance = 20;
51515 this.panoPreferredDistance = 5;
51516 this.panoMaxItems = 4;
51517 this.panoMaxStepTurnChange = Math.PI / 8;
51518 this.rotationMaxDistance = this.turnMaxRigDistance;
51519 this.rotationMaxDirectionChange = Math.PI / 6;
51520 this.rotationMaxVerticalDirectionChange = Math.PI / 8;
51521 this.similarMaxDirectionChange = Math.PI / 8;
51522 this.similarMaxDistance = 12;
51523 this.similarMinTimeDifference = 12 * 3600 * 1000;
51524 this.stepMaxDistance = 20;
51525 this.stepMaxDirectionChange = Math.PI / 6;
51526 this.stepMaxDrift = Math.PI / 6;
51527 this.stepPreferredDistance = 4;
51528 this.turnMaxDistance = 15;
51529 this.turnMaxDirectionChange = 2 * Math.PI / 9;
51530 this.turnMaxRigDistance = 0.65;
51531 this.turnMinRigDirectionChange = Math.PI / 6;
51533 Object.defineProperty(EdgeCalculatorSettings.prototype, "maxDistance", {
51535 return Math.max(this.panoMaxDistance, this.similarMaxDistance, this.stepMaxDistance, this.turnMaxDistance);
51540 return EdgeCalculatorSettings;
51542 exports.EdgeCalculatorSettings = EdgeCalculatorSettings;
51543 exports.default = EdgeCalculatorSettings;
51545 },{}],437:[function(require,module,exports){
51547 Object.defineProperty(exports, "__esModule", { value: true });
51548 exports.EdgeDirection = void 0;
51550 * Enumeration for edge directions
51553 * @description Directions for edges in node graph describing
51554 * sequence, spatial and node type relations between nodes.
51557 (function (EdgeDirection) {
51559 * Next node in the sequence.
51561 EdgeDirection[EdgeDirection["Next"] = 0] = "Next";
51563 * Previous node in the sequence.
51565 EdgeDirection[EdgeDirection["Prev"] = 1] = "Prev";
51567 * Step to the left keeping viewing direction.
51569 EdgeDirection[EdgeDirection["StepLeft"] = 2] = "StepLeft";
51571 * Step to the right keeping viewing direction.
51573 EdgeDirection[EdgeDirection["StepRight"] = 3] = "StepRight";
51575 * Step forward keeping viewing direction.
51577 EdgeDirection[EdgeDirection["StepForward"] = 4] = "StepForward";
51579 * Step backward keeping viewing direction.
51581 EdgeDirection[EdgeDirection["StepBackward"] = 5] = "StepBackward";
51583 * Turn 90 degrees counter clockwise.
51585 EdgeDirection[EdgeDirection["TurnLeft"] = 6] = "TurnLeft";
51587 * Turn 90 degrees clockwise.
51589 EdgeDirection[EdgeDirection["TurnRight"] = 7] = "TurnRight";
51591 * Turn 180 degrees.
51593 EdgeDirection[EdgeDirection["TurnU"] = 8] = "TurnU";
51595 * Panorama in general direction.
51597 EdgeDirection[EdgeDirection["Pano"] = 9] = "Pano";
51599 * Looking in roughly the same direction at rougly the same position.
51601 EdgeDirection[EdgeDirection["Similar"] = 10] = "Similar";
51602 })(EdgeDirection = exports.EdgeDirection || (exports.EdgeDirection = {}));
51604 },{}],438:[function(require,module,exports){
51606 Object.defineProperty(exports, "__esModule", { value: true });
51608 },{}],439:[function(require,module,exports){
51610 Object.defineProperty(exports, "__esModule", { value: true });
51612 },{}],440:[function(require,module,exports){
51614 Object.defineProperty(exports, "__esModule", { value: true });
51615 exports.DOMRenderer = void 0;
51616 var rxjs_1 = require("rxjs");
51617 var operators_1 = require("rxjs/operators");
51618 var vd = require("virtual-dom");
51619 var rxjs_2 = require("rxjs");
51620 var Render_1 = require("../Render");
51621 var DOMRenderer = /** @class */ (function () {
51622 function DOMRenderer(element, renderService, currentFrame$) {
51623 this._adaptiveOperation$ = new rxjs_2.Subject();
51624 this._render$ = new rxjs_2.Subject();
51625 this._renderAdaptive$ = new rxjs_2.Subject();
51626 this._renderService = renderService;
51627 this._currentFrame$ = currentFrame$;
51628 var rootNode = vd.create(vd.h("div.domRenderer", []));
51629 element.appendChild(rootNode);
51630 this._offset$ = this._adaptiveOperation$.pipe(operators_1.scan(function (adaptive, operation) {
51631 return operation(adaptive);
51633 elementHeight: element.offsetHeight,
51634 elementWidth: element.offsetWidth,
51636 renderMode: Render_1.RenderMode.Fill,
51637 }), operators_1.filter(function (adaptive) {
51638 return adaptive.imageAspect > 0 && adaptive.elementWidth > 0 && adaptive.elementHeight > 0;
51639 }), operators_1.map(function (adaptive) {
51640 var elementAspect = adaptive.elementWidth / adaptive.elementHeight;
51641 var ratio = adaptive.imageAspect / elementAspect;
51642 var verticalOffset = 0;
51643 var horizontalOffset = 0;
51644 if (adaptive.renderMode === Render_1.RenderMode.Letterbox) {
51645 if (adaptive.imageAspect > elementAspect) {
51646 verticalOffset = adaptive.elementHeight * (1 - 1 / ratio) / 2;
51649 horizontalOffset = adaptive.elementWidth * (1 - ratio) / 2;
51653 if (adaptive.imageAspect > elementAspect) {
51654 horizontalOffset = -adaptive.elementWidth * (ratio - 1) / 2;
51657 verticalOffset = -adaptive.elementHeight * (1 / ratio - 1) / 2;
51661 bottom: verticalOffset,
51662 left: horizontalOffset,
51663 right: horizontalOffset,
51664 top: verticalOffset,
51667 this._currentFrame$.pipe(operators_1.filter(function (frame) {
51668 return frame.state.currentNode != null;
51669 }), operators_1.distinctUntilChanged(function (k1, k2) {
51671 }, function (frame) {
51672 return frame.state.currentNode.key;
51673 }), operators_1.map(function (frame) {
51674 return frame.state.currentTransform.basicAspect;
51675 }), operators_1.map(function (aspect) {
51676 return function (adaptive) {
51677 adaptive.imageAspect = aspect;
51681 .subscribe(this._adaptiveOperation$);
51682 rxjs_1.combineLatest(this._renderAdaptive$.pipe(operators_1.scan(function (vNodeHashes, vNodeHash) {
51683 if (vNodeHash.vnode == null) {
51684 delete vNodeHashes[vNodeHash.name];
51687 vNodeHashes[vNodeHash.name] = vNodeHash.vnode;
51689 return vNodeHashes;
51690 }, {})), this._offset$).pipe(operators_1.map(function (vo) {
51692 var hashes = vo[0];
51693 for (var name_1 in hashes) {
51694 if (!hashes.hasOwnProperty(name_1)) {
51697 vNodes.push(hashes[name_1]);
51699 var offset = vo[1];
51702 bottom: offset.bottom + "px",
51703 left: offset.left + "px",
51704 "pointer-events": "none",
51705 position: "absolute",
51706 right: offset.right + "px",
51707 top: offset.top + "px",
51711 name: "adaptiveDomRenderer",
51712 vnode: vd.h("div.adaptiveDomRenderer", properties, vNodes),
51715 .subscribe(this._render$);
51716 this._vNode$ = this._render$.pipe(operators_1.scan(function (vNodeHashes, vNodeHash) {
51717 if (vNodeHash.vnode == null) {
51718 delete vNodeHashes[vNodeHash.name];
51721 vNodeHashes[vNodeHash.name] = vNodeHash.vnode;
51723 return vNodeHashes;
51724 }, {}), operators_1.map(function (hashes) {
51726 for (var name_2 in hashes) {
51727 if (!hashes.hasOwnProperty(name_2)) {
51730 vNodes.push(hashes[name_2]);
51732 return vd.h("div.domRenderer", vNodes);
51734 this._vPatch$ = this._vNode$.pipe(operators_1.scan(function (nodePatch, vNode) {
51735 nodePatch.vpatch = vd.diff(nodePatch.vnode, vNode);
51736 nodePatch.vnode = vNode;
51738 }, { vnode: vd.h("div.domRenderer", []), vpatch: null }), operators_1.pluck("vpatch"));
51739 this._element$ = this._vPatch$.pipe(operators_1.scan(function (oldElement, vPatch) {
51740 return vd.patch(oldElement, vPatch);
51741 }, rootNode), operators_1.publishReplay(1), operators_1.refCount());
51742 this._element$.subscribe(function () { });
51743 this._renderService.size$.pipe(operators_1.map(function (size) {
51744 return function (adaptive) {
51745 adaptive.elementWidth = size.width;
51746 adaptive.elementHeight = size.height;
51750 .subscribe(this._adaptiveOperation$);
51751 this._renderService.renderMode$.pipe(operators_1.map(function (renderMode) {
51752 return function (adaptive) {
51753 adaptive.renderMode = renderMode;
51757 .subscribe(this._adaptiveOperation$);
51759 Object.defineProperty(DOMRenderer.prototype, "element$", {
51761 return this._element$;
51766 Object.defineProperty(DOMRenderer.prototype, "render$", {
51768 return this._render$;
51773 Object.defineProperty(DOMRenderer.prototype, "renderAdaptive$", {
51775 return this._renderAdaptive$;
51780 DOMRenderer.prototype.clear = function (name) {
51781 this._renderAdaptive$.next({ name: name, vnode: null });
51782 this._render$.next({ name: name, vnode: null });
51784 return DOMRenderer;
51786 exports.DOMRenderer = DOMRenderer;
51787 exports.default = DOMRenderer;
51790 },{"../Render":297,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],441:[function(require,module,exports){
51792 Object.defineProperty(exports, "__esModule", { value: true });
51793 exports.GLRenderStage = void 0;
51795 (function (GLRenderStage) {
51796 GLRenderStage[GLRenderStage["Background"] = 0] = "Background";
51797 GLRenderStage[GLRenderStage["Foreground"] = 1] = "Foreground";
51798 })(GLRenderStage = exports.GLRenderStage || (exports.GLRenderStage = {}));
51799 exports.default = GLRenderStage;
51801 },{}],442:[function(require,module,exports){
51803 Object.defineProperty(exports, "__esModule", { value: true });
51804 exports.GLRenderer = void 0;
51805 var rxjs_1 = require("rxjs");
51806 var operators_1 = require("rxjs/operators");
51807 var THREE = require("three");
51808 var Render_1 = require("../Render");
51809 var Utils_1 = require("../Utils");
51810 var GLRenderer = /** @class */ (function () {
51811 function GLRenderer(canvasContainer, renderService, dom) {
51813 this._renderFrame$ = new rxjs_1.Subject();
51814 this._renderCameraOperation$ = new rxjs_1.Subject();
51815 this._render$ = new rxjs_1.Subject();
51816 this._clear$ = new rxjs_1.Subject();
51817 this._renderOperation$ = new rxjs_1.Subject();
51818 this._rendererOperation$ = new rxjs_1.Subject();
51819 this._eraserOperation$ = new rxjs_1.Subject();
51820 this._renderService = renderService;
51821 this._dom = !!dom ? dom : new Utils_1.DOM();
51822 this._renderer$ = this._rendererOperation$.pipe(operators_1.scan(function (renderer, operation) {
51823 return operation(renderer);
51824 }, { needsRender: false, renderer: null }), operators_1.filter(function (renderer) {
51825 return !!renderer.renderer;
51827 this._renderCollection$ = this._renderOperation$.pipe(operators_1.scan(function (hashes, operation) {
51828 return operation(hashes);
51829 }, {}), operators_1.share());
51830 this._renderCamera$ = this._renderCameraOperation$.pipe(operators_1.scan(function (rc, operation) {
51831 return operation(rc);
51832 }, { frameId: -1, needsRender: false, perspective: null }));
51833 this._eraser$ = this._eraserOperation$.pipe(operators_1.startWith(function (eraser) {
51835 }), operators_1.scan(function (eraser, operation) {
51836 return operation(eraser);
51837 }, { needsRender: false }));
51838 rxjs_1.combineLatest(this._renderer$, this._renderCollection$, this._renderCamera$, this._eraser$).pipe(operators_1.map(function (_a) {
51839 var renderer = _a[0], hashes = _a[1], rc = _a[2], eraser = _a[3];
51840 var renders = Object.keys(hashes)
51841 .map(function (key) {
51842 return hashes[key];
51844 return { camera: rc, eraser: eraser, renderer: renderer, renders: renders };
51845 }), operators_1.filter(function (co) {
51846 var needsRender = co.renderer.needsRender ||
51847 co.camera.needsRender ||
51848 co.eraser.needsRender;
51849 var frameId = co.camera.frameId;
51850 for (var _i = 0, _a = co.renders; _i < _a.length; _i++) {
51851 var render = _a[_i];
51852 if (render.frameId !== frameId) {
51855 needsRender = needsRender || render.needsRender;
51857 return needsRender;
51858 }), operators_1.distinctUntilChanged(function (n1, n2) {
51861 return co.eraser.needsRender ? -1 : co.camera.frameId;
51863 .subscribe(function (co) {
51864 co.renderer.needsRender = false;
51865 co.camera.needsRender = false;
51866 co.eraser.needsRender = false;
51867 var perspectiveCamera = co.camera.perspective;
51868 var backgroundRenders = [];
51869 var foregroundRenders = [];
51870 for (var _i = 0, _a = co.renders; _i < _a.length; _i++) {
51871 var render = _a[_i];
51872 if (render.stage === Render_1.GLRenderStage.Background) {
51873 backgroundRenders.push(render.render);
51875 else if (render.stage === Render_1.GLRenderStage.Foreground) {
51876 foregroundRenders.push(render.render);
51879 var renderer = co.renderer.renderer;
51881 for (var _b = 0, backgroundRenders_1 = backgroundRenders; _b < backgroundRenders_1.length; _b++) {
51882 var render = backgroundRenders_1[_b];
51883 render(perspectiveCamera, renderer);
51885 renderer.clearDepth();
51886 for (var _c = 0, foregroundRenders_1 = foregroundRenders; _c < foregroundRenders_1.length; _c++) {
51887 var render = foregroundRenders_1[_c];
51888 render(perspectiveCamera, renderer);
51891 this._renderFrame$.pipe(operators_1.map(function (rc) {
51892 return function (irc) {
51893 irc.frameId = rc.frameId;
51894 irc.perspective = rc.perspective;
51895 if (rc.changed === true) {
51896 irc.needsRender = true;
51901 .subscribe(this._renderCameraOperation$);
51902 this._renderFrameSubscribe();
51903 var renderHash$ = this._render$.pipe(operators_1.map(function (hash) {
51904 return function (hashes) {
51905 hashes[hash.name] = hash.render;
51909 var clearHash$ = this._clear$.pipe(operators_1.map(function (name) {
51910 return function (hashes) {
51911 delete hashes[name];
51915 rxjs_1.merge(renderHash$, clearHash$)
51916 .subscribe(this._renderOperation$);
51917 this._webGLRenderer$ = this._render$.pipe(operators_1.first(), operators_1.map(function (hash) {
51918 var canvas = _this._dom.createElement("canvas", "mapillary-js-canvas");
51919 canvas.style.position = "absolute";
51920 canvas.setAttribute("tabindex", "0");
51921 canvasContainer.appendChild(canvas);
51922 var element = renderService.element;
51923 var webGLRenderer = new THREE.WebGLRenderer({ canvas: canvas });
51924 webGLRenderer.setPixelRatio(window.devicePixelRatio);
51925 webGLRenderer.setSize(element.offsetWidth, element.offsetHeight);
51926 webGLRenderer.setClearColor(new THREE.Color(0x202020), 1.0);
51927 webGLRenderer.autoClear = false;
51928 return webGLRenderer;
51929 }), operators_1.publishReplay(1), operators_1.refCount());
51930 this._webGLRenderer$.subscribe(function () { });
51931 var createRenderer$ = this._webGLRenderer$.pipe(operators_1.first(), operators_1.map(function (webGLRenderer) {
51932 return function (renderer) {
51933 renderer.needsRender = true;
51934 renderer.renderer = webGLRenderer;
51938 var resizeRenderer$ = this._renderService.size$.pipe(operators_1.map(function (size) {
51939 return function (renderer) {
51940 if (renderer.renderer == null) {
51943 renderer.renderer.setSize(size.width, size.height);
51944 renderer.needsRender = true;
51948 var clearRenderer$ = this._clear$.pipe(operators_1.map(function (name) {
51949 return function (renderer) {
51950 if (renderer.renderer == null) {
51953 renderer.needsRender = true;
51957 rxjs_1.merge(createRenderer$, resizeRenderer$, clearRenderer$)
51958 .subscribe(this._rendererOperation$);
51959 var renderCollectionEmpty$ = this._renderCollection$.pipe(operators_1.filter(function (hashes) {
51960 return Object.keys(hashes).length === 0;
51961 }), operators_1.share());
51962 renderCollectionEmpty$
51963 .subscribe(function (hashes) {
51964 if (_this._renderFrameSubscription == null) {
51967 _this._renderFrameSubscription.unsubscribe();
51968 _this._renderFrameSubscription = null;
51969 _this._renderFrameSubscribe();
51971 renderCollectionEmpty$.pipe(operators_1.map(function (hashes) {
51972 return function (eraser) {
51973 eraser.needsRender = true;
51977 .subscribe(this._eraserOperation$);
51979 Object.defineProperty(GLRenderer.prototype, "render$", {
51981 return this._render$;
51986 Object.defineProperty(GLRenderer.prototype, "webGLRenderer$", {
51988 return this._webGLRenderer$;
51993 GLRenderer.prototype.clear = function (name) {
51994 this._clear$.next(name);
51996 GLRenderer.prototype._renderFrameSubscribe = function () {
51998 this._render$.pipe(operators_1.first(), operators_1.map(function (renderHash) {
51999 return function (irc) {
52000 irc.needsRender = true;
52004 .subscribe(function (operation) {
52005 _this._renderCameraOperation$.next(operation);
52007 this._renderFrameSubscription = this._render$.pipe(operators_1.first(), operators_1.mergeMap(function (hash) {
52008 return _this._renderService.renderCameraFrame$;
52010 .subscribe(this._renderFrame$);
52014 exports.GLRenderer = GLRenderer;
52015 exports.default = GLRenderer;
52018 },{"../Render":297,"../Utils":301,"rxjs":43,"rxjs/operators":241,"three":242}],443:[function(require,module,exports){
52020 Object.defineProperty(exports, "__esModule", { value: true });
52021 exports.RenderCamera = void 0;
52022 var THREE = require("three");
52023 var Geo_1 = require("../Geo");
52024 var Render_1 = require("../Render");
52025 var State_1 = require("../State");
52026 var RenderCamera = /** @class */ (function () {
52027 function RenderCamera(elementWidth, elementHeight, renderMode) {
52028 this._spatial = new Geo_1.Spatial();
52029 this._viewportCoords = new Geo_1.ViewportCoords();
52030 this._initialFov = 50;
52032 this._renderMode = renderMode;
52034 this._frameId = -1;
52035 this._changed = false;
52036 this._changedForFrame = -1;
52037 this._currentNodeId = null;
52038 this._previousNodeId = null;
52039 this._currentPano = false;
52040 this._previousPano = false;
52041 this._state = null;
52042 this._currentProjectedPoints = [];
52043 this._previousProjectedPoints = [];
52044 this._currentFov = this._initialFov;
52045 this._previousFov = this._initialFov;
52046 this._camera = new Geo_1.Camera();
52047 this._perspective = new THREE.PerspectiveCamera(this._initialFov, this._computeAspect(elementWidth, elementHeight), 0.16, 10000);
52048 this._perspective.matrixAutoUpdate = false;
52049 this._rotation = { phi: 0, theta: 0 };
52051 Object.defineProperty(RenderCamera.prototype, "alpha", {
52053 return this._alpha;
52058 Object.defineProperty(RenderCamera.prototype, "camera", {
52060 return this._camera;
52065 Object.defineProperty(RenderCamera.prototype, "changed", {
52067 return this._frameId === this._changedForFrame;
52072 Object.defineProperty(RenderCamera.prototype, "frameId", {
52074 return this._frameId;
52079 Object.defineProperty(RenderCamera.prototype, "perspective", {
52081 return this._perspective;
52086 Object.defineProperty(RenderCamera.prototype, "renderMode", {
52088 return this._renderMode;
52093 Object.defineProperty(RenderCamera.prototype, "rotation", {
52095 return this._rotation;
52100 Object.defineProperty(RenderCamera.prototype, "zoom", {
52107 RenderCamera.prototype.getTilt = function () {
52108 return 90 - this._spatial.radToDeg(this._rotation.theta);
52110 RenderCamera.prototype.fovToZoom = function (fov) {
52111 fov = Math.min(90, Math.max(0, fov));
52112 var currentFov = this._computeCurrentFov(0);
52113 var actualFov = this._alpha === 1 ?
52115 this._interpolateFov(currentFov, this._computePreviousFov(0), this._alpha);
52116 var y0 = Math.tan(actualFov / 2 * Math.PI / 180);
52117 var y1 = Math.tan(fov / 2 * Math.PI / 180);
52118 var zoom = Math.log(y0 / y1) / Math.log(2);
52121 RenderCamera.prototype.setFrame = function (frame) {
52122 var state = frame.state;
52123 if (state.state !== this._state) {
52124 this._state = state.state;
52125 this._changed = true;
52127 var currentNodeId = state.currentNode.key;
52128 var previousNodeId = !!state.previousNode ? state.previousNode.key : null;
52129 if (currentNodeId !== this._currentNodeId) {
52130 this._currentNodeId = currentNodeId;
52131 this._currentPano = !!state.currentTransform.gpano;
52132 this._currentProjectedPoints = this._computeProjectedPoints(state.currentTransform);
52133 this._changed = true;
52135 if (previousNodeId !== this._previousNodeId) {
52136 this._previousNodeId = previousNodeId;
52137 this._previousPano = !!state.previousTransform.gpano;
52138 this._previousProjectedPoints = this._computeProjectedPoints(state.previousTransform);
52139 this._changed = true;
52141 var zoom = state.zoom;
52142 if (zoom !== this._zoom) {
52144 this._changed = true;
52146 if (this._changed) {
52147 this._currentFov = this._computeCurrentFov(this.zoom);
52148 this._previousFov = this._computePreviousFov(this._zoom);
52150 var alpha = state.alpha;
52151 if (this._changed || alpha !== this._alpha) {
52152 this._alpha = alpha;
52153 this._perspective.fov = this._state === State_1.State.Earth ?
52155 this._interpolateFov(this._currentFov, this._previousFov, this._alpha);
52156 this._changed = true;
52158 var camera = state.camera;
52159 if (this._camera.diff(camera) > 1e-9) {
52160 this._camera.copy(camera);
52161 this._rotation = this._computeRotation(camera);
52162 this._perspective.up.copy(camera.up);
52163 this._perspective.position.copy(camera.position);
52164 // Workaround for shaking camera
52165 this._perspective.matrixAutoUpdate = true;
52166 this._perspective.lookAt(camera.lookat);
52167 this._perspective.matrixAutoUpdate = false;
52168 this._perspective.updateMatrix();
52169 this._perspective.updateMatrixWorld(false);
52170 this._changed = true;
52172 if (this._changed) {
52173 this._perspective.updateProjectionMatrix();
52175 this._setFrameId(frame.id);
52177 RenderCamera.prototype.setRenderMode = function (renderMode) {
52178 this._renderMode = renderMode;
52179 this._perspective.fov = this._computeFov();
52180 this._perspective.updateProjectionMatrix();
52181 this._changed = true;
52183 RenderCamera.prototype.setSize = function (size) {
52184 this._perspective.aspect = this._computeAspect(size.width, size.height);
52185 this._perspective.fov = this._computeFov();
52186 this._perspective.updateProjectionMatrix();
52187 this._changed = true;
52189 RenderCamera.prototype._computeAspect = function (elementWidth, elementHeight) {
52190 return elementWidth === 0 ? 0 : elementWidth / elementHeight;
52192 RenderCamera.prototype._computeCurrentFov = function (zoom) {
52193 if (this._perspective.aspect === 0) {
52196 if (!this._currentNodeId) {
52197 return this._initialFov;
52199 return this._currentPano ?
52200 this._yToFov(1, zoom) :
52201 this._computeVerticalFov(this._currentProjectedPoints, this._renderMode, zoom, this.perspective.aspect);
52203 RenderCamera.prototype._computeFov = function () {
52204 this._currentFov = this._computeCurrentFov(this._zoom);
52205 this._previousFov = this._computePreviousFov(this._zoom);
52206 return this._interpolateFov(this._currentFov, this._previousFov, this._alpha);
52208 RenderCamera.prototype._computePreviousFov = function (zoom) {
52209 if (this._perspective.aspect === 0) {
52212 if (!this._currentNodeId) {
52213 return this._initialFov;
52215 return !this._previousNodeId ?
52217 this._previousPano ?
52218 this._yToFov(1, zoom) :
52219 this._computeVerticalFov(this._previousProjectedPoints, this._renderMode, zoom, this.perspective.aspect);
52221 RenderCamera.prototype._computeProjectedPoints = function (transform) {
52222 var vertices = [[0.5, 0], [1, 0]];
52223 var directions = [[0.5, 0], [0, 0.5]];
52224 var pointsPerLine = 100;
52225 return Geo_1.Geo.computeProjectedPoints(transform, vertices, directions, pointsPerLine, this._viewportCoords);
52227 RenderCamera.prototype._computeRequiredVerticalFov = function (projectedPoint, zoom, aspect) {
52228 var maxY = Math.max(projectedPoint[0] / aspect, projectedPoint[1]);
52229 return this._yToFov(maxY, zoom);
52231 RenderCamera.prototype._computeRotation = function (camera) {
52232 var direction = camera.lookat.clone().sub(camera.position);
52233 var up = camera.up.clone();
52234 var phi = this._spatial.azimuthal(direction.toArray(), up.toArray());
52235 var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
52236 return { phi: phi, theta: theta };
52238 RenderCamera.prototype._computeVerticalFov = function (projectedPoints, renderMode, zoom, aspect) {
52240 var fovs = projectedPoints
52241 .map(function (projectedPoint) {
52242 return _this._computeRequiredVerticalFov(projectedPoint, zoom, aspect);
52244 var fov = renderMode === Render_1.RenderMode.Fill ?
52245 Math.min.apply(Math, fovs) * 0.995 : Math.max.apply(Math, fovs);
52248 RenderCamera.prototype._yToFov = function (y, zoom) {
52249 return 2 * Math.atan(y / Math.pow(2, zoom)) * 180 / Math.PI;
52251 RenderCamera.prototype._interpolateFov = function (v1, v2, alpha) {
52252 return alpha * v1 + (1 - alpha) * v2;
52254 RenderCamera.prototype._setFrameId = function (frameId) {
52255 this._frameId = frameId;
52256 if (this._changed) {
52257 this._changed = false;
52258 this._changedForFrame = frameId;
52261 return RenderCamera;
52263 exports.RenderCamera = RenderCamera;
52264 exports.default = RenderCamera;
52266 },{"../Geo":294,"../Render":297,"../State":298,"three":242}],444:[function(require,module,exports){
52268 Object.defineProperty(exports, "__esModule", { value: true });
52269 exports.RenderMode = void 0;
52271 * Enumeration for render mode
52274 * @description Modes for specifying how rendering is done
52275 * in the viewer. All modes preserves the original aspect
52276 * ratio of the images.
52279 (function (RenderMode) {
52281 * Displays all content within the viewer.
52283 * @description Black bars shown on both
52284 * sides of the content. Bars are shown
52285 * either below and above or to the left
52286 * and right of the content depending on
52287 * the aspect ratio relation between the
52288 * image and the viewer.
52290 RenderMode[RenderMode["Letterbox"] = 0] = "Letterbox";
52292 * Fills the viewer by cropping content.
52294 * @description Cropping is done either
52295 * in horizontal or vertical direction
52296 * depending on the aspect ratio relation
52297 * between the image and the viewer.
52299 RenderMode[RenderMode["Fill"] = 1] = "Fill";
52300 })(RenderMode = exports.RenderMode || (exports.RenderMode = {}));
52301 exports.default = RenderMode;
52303 },{}],445:[function(require,module,exports){
52305 Object.defineProperty(exports, "__esModule", { value: true });
52306 exports.RenderService = void 0;
52307 var operators_1 = require("rxjs/operators");
52308 var rxjs_1 = require("rxjs");
52309 var Geo_1 = require("../Geo");
52310 var Render_1 = require("../Render");
52311 var RenderService = /** @class */ (function () {
52312 function RenderService(element, currentFrame$, renderMode, renderCamera) {
52314 this._element = element;
52315 this._currentFrame$ = currentFrame$;
52316 this._spatial = new Geo_1.Spatial();
52317 renderMode = renderMode != null ? renderMode : Render_1.RenderMode.Fill;
52318 this._resize$ = new rxjs_1.Subject();
52319 this._renderCameraOperation$ = new rxjs_1.Subject();
52321 new rxjs_1.BehaviorSubject({
52322 height: this._element.offsetHeight,
52323 width: this._element.offsetWidth,
52325 this._resize$.pipe(operators_1.map(function () {
52326 return { height: _this._element.offsetHeight, width: _this._element.offsetWidth };
52328 .subscribe(this._size$);
52329 this._renderMode$ = new rxjs_1.BehaviorSubject(renderMode);
52330 this._renderCameraHolder$ = this._renderCameraOperation$.pipe(operators_1.startWith(function (rc) {
52332 }), operators_1.scan(function (rc, operation) {
52333 return operation(rc);
52334 }, !!renderCamera ? renderCamera : new Render_1.RenderCamera(this._element.offsetWidth, this._element.offsetHeight, renderMode)), operators_1.publishReplay(1), operators_1.refCount());
52335 this._renderCameraFrame$ = this._currentFrame$.pipe(operators_1.withLatestFrom(this._renderCameraHolder$), operators_1.tap(function (_a) {
52336 var frame = _a[0], rc = _a[1];
52337 rc.setFrame(frame);
52338 }), operators_1.map(function (args) {
52340 }), operators_1.publishReplay(1), operators_1.refCount());
52341 this._renderCamera$ = this._renderCameraFrame$.pipe(operators_1.filter(function (rc) {
52343 }), operators_1.publishReplay(1), operators_1.refCount());
52344 this._bearing$ = this._renderCamera$.pipe(operators_1.map(function (rc) {
52345 var bearing = _this._spatial.radToDeg(_this._spatial.azimuthalToBearing(rc.rotation.phi));
52346 return _this._spatial.wrap(bearing, 0, 360);
52347 }), operators_1.publishReplay(1), operators_1.refCount());
52348 this._size$.pipe(operators_1.skip(1), operators_1.map(function (size) {
52349 return function (rc) {
52354 .subscribe(this._renderCameraOperation$);
52355 this._renderMode$.pipe(operators_1.skip(1), operators_1.map(function (rm) {
52356 return function (rc) {
52357 rc.setRenderMode(rm);
52361 .subscribe(this._renderCameraOperation$);
52362 this._bearing$.subscribe(function () { });
52363 this._renderCameraHolder$.subscribe(function () { });
52364 this._size$.subscribe(function () { });
52365 this._renderMode$.subscribe(function () { });
52366 this._renderCamera$.subscribe(function () { });
52367 this._renderCameraFrame$.subscribe(function () { });
52369 Object.defineProperty(RenderService.prototype, "bearing$", {
52371 return this._bearing$;
52376 Object.defineProperty(RenderService.prototype, "element", {
52378 return this._element;
52383 Object.defineProperty(RenderService.prototype, "resize$", {
52385 return this._resize$;
52390 Object.defineProperty(RenderService.prototype, "size$", {
52392 return this._size$;
52397 Object.defineProperty(RenderService.prototype, "renderMode$", {
52399 return this._renderMode$;
52404 Object.defineProperty(RenderService.prototype, "renderCameraFrame$", {
52406 return this._renderCameraFrame$;
52411 Object.defineProperty(RenderService.prototype, "renderCamera$", {
52413 return this._renderCamera$;
52418 return RenderService;
52420 exports.RenderService = RenderService;
52421 exports.default = RenderService;
52424 },{"../Geo":294,"../Render":297,"rxjs":43,"rxjs/operators":241}],446:[function(require,module,exports){
52426 Object.defineProperty(exports, "__esModule", { value: true });
52428 },{}],447:[function(require,module,exports){
52430 Object.defineProperty(exports, "__esModule", { value: true });
52431 exports.FrameGenerator = void 0;
52432 var FrameGenerator = /** @class */ (function () {
52433 function FrameGenerator(root) {
52434 if (root.requestAnimationFrame) {
52435 this._cancelAnimationFrame = root.cancelAnimationFrame.bind(root);
52436 this._requestAnimationFrame = root.requestAnimationFrame.bind(root);
52438 else if (root.mozRequestAnimationFrame) {
52439 this._cancelAnimationFrame = root.mozCancelAnimationFrame.bind(root);
52440 this._requestAnimationFrame = root.mozRequestAnimationFrame.bind(root);
52442 else if (root.webkitRequestAnimationFrame) {
52443 this._cancelAnimationFrame = root.webkitCancelAnimationFrame.bind(root);
52444 this._requestAnimationFrame = root.webkitRequestAnimationFrame.bind(root);
52446 else if (root.msRequestAnimationFrame) {
52447 this._cancelAnimationFrame = root.msCancelAnimationFrame.bind(root);
52448 this._requestAnimationFrame = root.msRequestAnimationFrame.bind(root);
52450 else if (root.oRequestAnimationFrame) {
52451 this._cancelAnimationFrame = root.oCancelAnimationFrame.bind(root);
52452 this._requestAnimationFrame = root.oRequestAnimationFrame.bind(root);
52455 this._cancelAnimationFrame = root.clearTimeout.bind(root);
52456 this._requestAnimationFrame = function (cb) { return root.setTimeout(cb, 1000 / 60); };
52459 Object.defineProperty(FrameGenerator.prototype, "cancelAnimationFrame", {
52461 return this._cancelAnimationFrame;
52466 Object.defineProperty(FrameGenerator.prototype, "requestAnimationFrame", {
52468 return this._requestAnimationFrame;
52473 return FrameGenerator;
52475 exports.FrameGenerator = FrameGenerator;
52476 exports.default = FrameGenerator;
52478 },{}],448:[function(require,module,exports){
52480 Object.defineProperty(exports, "__esModule", { value: true });
52481 exports.RotationDelta = void 0;
52482 var RotationDelta = /** @class */ (function () {
52483 function RotationDelta(phi, theta) {
52485 this._theta = theta;
52487 Object.defineProperty(RotationDelta.prototype, "phi", {
52491 set: function (value) {
52497 Object.defineProperty(RotationDelta.prototype, "theta", {
52499 return this._theta;
52501 set: function (value) {
52502 this._theta = value;
52507 Object.defineProperty(RotationDelta.prototype, "isZero", {
52509 return this._phi === 0 && this._theta === 0;
52514 RotationDelta.prototype.copy = function (delta) {
52515 this._phi = delta.phi;
52516 this._theta = delta.theta;
52518 RotationDelta.prototype.lerp = function (other, alpha) {
52519 this._phi = (1 - alpha) * this._phi + alpha * other.phi;
52520 this._theta = (1 - alpha) * this._theta + alpha * other.theta;
52522 RotationDelta.prototype.multiply = function (value) {
52523 this._phi *= value;
52524 this._theta *= value;
52526 RotationDelta.prototype.threshold = function (value) {
52527 this._phi = Math.abs(this._phi) > value ? this._phi : 0;
52528 this._theta = Math.abs(this._theta) > value ? this._theta : 0;
52530 RotationDelta.prototype.lengthSquared = function () {
52531 return this._phi * this._phi + this._theta * this._theta;
52533 RotationDelta.prototype.reset = function () {
52537 return RotationDelta;
52539 exports.RotationDelta = RotationDelta;
52540 exports.default = RotationDelta;
52542 },{}],449:[function(require,module,exports){
52544 Object.defineProperty(exports, "__esModule", { value: true });
52545 exports.State = void 0;
52547 (function (State) {
52548 State[State["Earth"] = 0] = "Earth";
52549 State[State["Traversing"] = 1] = "Traversing";
52550 State[State["Waiting"] = 2] = "Waiting";
52551 State[State["WaitingInteractively"] = 3] = "WaitingInteractively";
52552 })(State = exports.State || (exports.State = {}));
52553 exports.default = State;
52555 },{}],450:[function(require,module,exports){
52557 Object.defineProperty(exports, "__esModule", { value: true });
52558 exports.StateContext = void 0;
52559 var State_1 = require("../State");
52560 var Geo_1 = require("../Geo");
52561 var StateContext = /** @class */ (function () {
52562 function StateContext(transitionMode) {
52563 this._state = new State_1.TraversingState({
52565 camera: new Geo_1.Camera(),
52567 reference: { alt: 0, lat: 0, lon: 0 },
52569 transitionMode: transitionMode == null ? State_1.TransitionMode.Default : transitionMode,
52573 Object.defineProperty(StateContext.prototype, "state", {
52575 if (this._state instanceof State_1.EarthState) {
52576 return State_1.State.Earth;
52578 else if (this._state instanceof State_1.TraversingState) {
52579 return State_1.State.Traversing;
52581 else if (this._state instanceof State_1.WaitingState) {
52582 return State_1.State.Waiting;
52584 else if (this._state instanceof State_1.InteractiveWaitingState) {
52585 return State_1.State.WaitingInteractively;
52587 throw new Error("Invalid state");
52592 Object.defineProperty(StateContext.prototype, "reference", {
52594 return this._state.reference;
52599 Object.defineProperty(StateContext.prototype, "alpha", {
52601 return this._state.alpha;
52606 Object.defineProperty(StateContext.prototype, "camera", {
52608 return this._state.camera;
52613 Object.defineProperty(StateContext.prototype, "zoom", {
52615 return this._state.zoom;
52620 Object.defineProperty(StateContext.prototype, "currentNode", {
52622 return this._state.currentNode;
52627 Object.defineProperty(StateContext.prototype, "previousNode", {
52629 return this._state.previousNode;
52634 Object.defineProperty(StateContext.prototype, "currentCamera", {
52636 return this._state.currentCamera;
52641 Object.defineProperty(StateContext.prototype, "currentTransform", {
52643 return this._state.currentTransform;
52648 Object.defineProperty(StateContext.prototype, "previousTransform", {
52650 return this._state.previousTransform;
52655 Object.defineProperty(StateContext.prototype, "trajectory", {
52657 return this._state.trajectory;
52662 Object.defineProperty(StateContext.prototype, "currentIndex", {
52664 return this._state.currentIndex;
52669 Object.defineProperty(StateContext.prototype, "lastNode", {
52671 return this._state.trajectory[this._state.trajectory.length - 1];
52676 Object.defineProperty(StateContext.prototype, "nodesAhead", {
52678 return this._state.trajectory.length - 1 - this._state.currentIndex;
52683 Object.defineProperty(StateContext.prototype, "motionless", {
52685 return this._state.motionless;
52690 StateContext.prototype.earth = function () {
52691 this._state = this._state.earth();
52693 StateContext.prototype.traverse = function () {
52694 this._state = this._state.traverse();
52696 StateContext.prototype.wait = function () {
52697 this._state = this._state.wait();
52699 StateContext.prototype.waitInteractively = function () {
52700 this._state = this._state.waitInteractively();
52702 StateContext.prototype.getCenter = function () {
52703 return this._state.getCenter();
52705 StateContext.prototype.setCenter = function (center) {
52706 this._state.setCenter(center);
52708 StateContext.prototype.setZoom = function (zoom) {
52709 this._state.setZoom(zoom);
52711 StateContext.prototype.update = function (fps) {
52712 this._state.update(fps);
52714 StateContext.prototype.append = function (nodes) {
52715 this._state.append(nodes);
52717 StateContext.prototype.prepend = function (nodes) {
52718 this._state.prepend(nodes);
52720 StateContext.prototype.remove = function (n) {
52721 this._state.remove(n);
52723 StateContext.prototype.clear = function () {
52724 this._state.clear();
52726 StateContext.prototype.clearPrior = function () {
52727 this._state.clearPrior();
52729 StateContext.prototype.cut = function () {
52732 StateContext.prototype.set = function (nodes) {
52733 this._state.set(nodes);
52735 StateContext.prototype.rotate = function (delta) {
52736 this._state.rotate(delta);
52738 StateContext.prototype.rotateUnbounded = function (delta) {
52739 this._state.rotateUnbounded(delta);
52741 StateContext.prototype.rotateWithoutInertia = function (delta) {
52742 this._state.rotateWithoutInertia(delta);
52744 StateContext.prototype.rotateBasic = function (basicRotation) {
52745 this._state.rotateBasic(basicRotation);
52747 StateContext.prototype.rotateBasicUnbounded = function (basicRotation) {
52748 this._state.rotateBasicUnbounded(basicRotation);
52750 StateContext.prototype.rotateBasicWithoutInertia = function (basicRotation) {
52751 this._state.rotateBasicWithoutInertia(basicRotation);
52753 StateContext.prototype.rotateToBasic = function (basic) {
52754 this._state.rotateToBasic(basic);
52756 StateContext.prototype.move = function (delta) {
52757 this._state.move(delta);
52759 StateContext.prototype.moveTo = function (delta) {
52760 this._state.moveTo(delta);
52762 StateContext.prototype.zoomIn = function (delta, reference) {
52763 this._state.zoomIn(delta, reference);
52765 StateContext.prototype.setSpeed = function (speed) {
52766 this._state.setSpeed(speed);
52768 StateContext.prototype.setTransitionMode = function (mode) {
52769 this._state.setTransitionMode(mode);
52771 StateContext.prototype.dolly = function (delta) {
52772 this._state.dolly(delta);
52774 StateContext.prototype.orbit = function (rotation) {
52775 this._state.orbit(rotation);
52777 StateContext.prototype.truck = function (direction) {
52778 this._state.truck(direction);
52780 return StateContext;
52782 exports.StateContext = StateContext;
52784 },{"../Geo":294,"../State":298}],451:[function(require,module,exports){
52786 Object.defineProperty(exports, "__esModule", { value: true });
52787 exports.StateService = void 0;
52788 var rxjs_1 = require("rxjs");
52789 var operators_1 = require("rxjs/operators");
52790 var State_1 = require("../State");
52791 var StateService = /** @class */ (function () {
52792 function StateService(transitionMode) {
52794 this._appendNode$ = new rxjs_1.Subject();
52795 this._start$ = new rxjs_1.Subject();
52796 this._frame$ = new rxjs_1.Subject();
52797 this._fpsSampleRate = 30;
52798 this._contextOperation$ = new rxjs_1.BehaviorSubject(function (context) {
52801 this._context$ = this._contextOperation$.pipe(operators_1.scan(function (context, operation) {
52802 return operation(context);
52803 }, new State_1.StateContext(transitionMode)), operators_1.publishReplay(1), operators_1.refCount());
52804 this._state$ = this._context$.pipe(operators_1.map(function (context) {
52805 return context.state;
52806 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
52807 this._fps$ = this._start$.pipe(operators_1.switchMap(function () {
52808 return _this._frame$.pipe(operators_1.bufferCount(1, _this._fpsSampleRate), operators_1.map(function (frameIds) {
52809 return new Date().getTime();
52810 }), operators_1.pairwise(), operators_1.map(function (times) {
52811 return Math.max(20, 1000 * _this._fpsSampleRate / (times[1] - times[0]));
52812 }), operators_1.startWith(60));
52813 }), operators_1.share());
52814 this._currentState$ = this._frame$.pipe(operators_1.withLatestFrom(this._fps$, this._context$, function (frameId, fps, context) {
52815 return [frameId, fps, context];
52816 }), operators_1.filter(function (fc) {
52817 return fc[2].currentNode != null;
52818 }), operators_1.tap(function (fc) {
52819 fc[2].update(fc[1]);
52820 }), operators_1.map(function (fc) {
52821 return { fps: fc[1], id: fc[0], state: fc[2] };
52822 }), operators_1.share());
52823 this._lastState$ = this._currentState$.pipe(operators_1.publishReplay(1), operators_1.refCount());
52824 var nodeChanged$ = this._currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (f) {
52825 return f.state.currentNode.key;
52826 }), operators_1.publishReplay(1), operators_1.refCount());
52827 var nodeChangedSubject$ = new rxjs_1.Subject();
52829 .subscribe(nodeChangedSubject$);
52830 this._currentKey$ = new rxjs_1.BehaviorSubject(null);
52831 nodeChangedSubject$.pipe(operators_1.map(function (f) {
52832 return f.state.currentNode.key;
52834 .subscribe(this._currentKey$);
52835 this._currentNode$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
52836 return f.state.currentNode;
52837 }), operators_1.publishReplay(1), operators_1.refCount());
52838 this._currentCamera$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
52839 return f.state.currentCamera;
52840 }), operators_1.publishReplay(1), operators_1.refCount());
52841 this._currentTransform$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
52842 return f.state.currentTransform;
52843 }), operators_1.publishReplay(1), operators_1.refCount());
52844 this._reference$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
52845 return f.state.reference;
52846 }), operators_1.distinctUntilChanged(function (r1, r2) {
52847 return r1.lat === r2.lat && r1.lon === r2.lon;
52848 }, function (reference) {
52849 return { lat: reference.lat, lon: reference.lon };
52850 }), operators_1.publishReplay(1), operators_1.refCount());
52851 this._currentNodeExternal$ = nodeChanged$.pipe(operators_1.map(function (f) {
52852 return f.state.currentNode;
52853 }), operators_1.publishReplay(1), operators_1.refCount());
52854 this._appendNode$.pipe(operators_1.map(function (node) {
52855 return function (context) {
52856 context.append([node]);
52860 .subscribe(this._contextOperation$);
52861 this._inMotionOperation$ = new rxjs_1.Subject();
52862 nodeChanged$.pipe(operators_1.map(function (frame) {
52865 .subscribe(this._inMotionOperation$);
52866 this._inMotionOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.filter(function (moving) {
52868 }), operators_1.switchMap(function (moving) {
52869 return _this._currentState$.pipe(operators_1.filter(function (frame) {
52870 return frame.state.nodesAhead === 0;
52871 }), operators_1.map(function (frame) {
52872 return [frame.state.camera.clone(), frame.state.zoom];
52873 }), operators_1.pairwise(), operators_1.map(function (pair) {
52874 var c1 = pair[0][0];
52875 var c2 = pair[1][0];
52876 var z1 = pair[0][1];
52877 var z2 = pair[1][1];
52878 return c1.diff(c2) > 1e-5 || Math.abs(z1 - z2) > 1e-5;
52879 }), operators_1.first(function (changed) {
52883 .subscribe(this._inMotionOperation$);
52884 this._inMotion$ = this._inMotionOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
52885 this._inTranslationOperation$ = new rxjs_1.Subject();
52886 nodeChanged$.pipe(operators_1.map(function (frame) {
52889 .subscribe(this._inTranslationOperation$);
52890 this._inTranslationOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.filter(function (inTranslation) {
52891 return inTranslation;
52892 }), operators_1.switchMap(function (inTranslation) {
52893 return _this._currentState$.pipe(operators_1.filter(function (frame) {
52894 return frame.state.nodesAhead === 0;
52895 }), operators_1.map(function (frame) {
52896 return frame.state.camera.position.clone();
52897 }), operators_1.pairwise(), operators_1.map(function (pair) {
52898 return pair[0].distanceToSquared(pair[1]) !== 0;
52899 }), operators_1.first(function (changed) {
52903 .subscribe(this._inTranslationOperation$);
52904 this._inTranslation$ = this._inTranslationOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
52905 this._state$.subscribe(function () { });
52906 this._currentNode$.subscribe(function () { });
52907 this._currentCamera$.subscribe(function () { });
52908 this._currentTransform$.subscribe(function () { });
52909 this._reference$.subscribe(function () { });
52910 this._currentNodeExternal$.subscribe(function () { });
52911 this._lastState$.subscribe(function () { });
52912 this._inMotion$.subscribe(function () { });
52913 this._inTranslation$.subscribe(function () { });
52914 this._frameId = null;
52915 this._frameGenerator = new State_1.FrameGenerator(window);
52917 Object.defineProperty(StateService.prototype, "currentState$", {
52919 return this._currentState$;
52924 Object.defineProperty(StateService.prototype, "currentNode$", {
52926 return this._currentNode$;
52931 Object.defineProperty(StateService.prototype, "currentKey$", {
52933 return this._currentKey$;
52938 Object.defineProperty(StateService.prototype, "currentNodeExternal$", {
52940 return this._currentNodeExternal$;
52945 Object.defineProperty(StateService.prototype, "currentCamera$", {
52947 return this._currentCamera$;
52952 Object.defineProperty(StateService.prototype, "currentTransform$", {
52954 return this._currentTransform$;
52959 Object.defineProperty(StateService.prototype, "state$", {
52961 return this._state$;
52966 Object.defineProperty(StateService.prototype, "reference$", {
52968 return this._reference$;
52973 Object.defineProperty(StateService.prototype, "inMotion$", {
52975 return this._inMotion$;
52980 Object.defineProperty(StateService.prototype, "inTranslation$", {
52982 return this._inTranslation$;
52987 Object.defineProperty(StateService.prototype, "appendNode$", {
52989 return this._appendNode$;
52994 StateService.prototype.earth = function () {
52995 this._inMotionOperation$.next(true);
52996 this._invokeContextOperation(function (context) { context.earth(); });
52998 StateService.prototype.traverse = function () {
52999 this._inMotionOperation$.next(true);
53000 this._invokeContextOperation(function (context) { context.traverse(); });
53002 StateService.prototype.wait = function () {
53003 this._invokeContextOperation(function (context) { context.wait(); });
53005 StateService.prototype.waitInteractively = function () {
53006 this._invokeContextOperation(function (context) { context.waitInteractively(); });
53008 StateService.prototype.appendNodes = function (nodes) {
53009 this._invokeContextOperation(function (context) { context.append(nodes); });
53011 StateService.prototype.prependNodes = function (nodes) {
53012 this._invokeContextOperation(function (context) { context.prepend(nodes); });
53014 StateService.prototype.removeNodes = function (n) {
53015 this._invokeContextOperation(function (context) { context.remove(n); });
53017 StateService.prototype.clearNodes = function () {
53018 this._invokeContextOperation(function (context) { context.clear(); });
53020 StateService.prototype.clearPriorNodes = function () {
53021 this._invokeContextOperation(function (context) { context.clearPrior(); });
53023 StateService.prototype.cutNodes = function () {
53024 this._invokeContextOperation(function (context) { context.cut(); });
53026 StateService.prototype.setNodes = function (nodes) {
53027 this._invokeContextOperation(function (context) { context.set(nodes); });
53029 StateService.prototype.rotate = function (delta) {
53030 this._inMotionOperation$.next(true);
53031 this._invokeContextOperation(function (context) { context.rotate(delta); });
53033 StateService.prototype.rotateUnbounded = function (delta) {
53034 this._inMotionOperation$.next(true);
53035 this._invokeContextOperation(function (context) { context.rotateUnbounded(delta); });
53037 StateService.prototype.rotateWithoutInertia = function (delta) {
53038 this._inMotionOperation$.next(true);
53039 this._invokeContextOperation(function (context) { context.rotateWithoutInertia(delta); });
53041 StateService.prototype.rotateBasic = function (basicRotation) {
53042 this._inMotionOperation$.next(true);
53043 this._invokeContextOperation(function (context) { context.rotateBasic(basicRotation); });
53045 StateService.prototype.rotateBasicUnbounded = function (basicRotation) {
53046 this._inMotionOperation$.next(true);
53047 this._invokeContextOperation(function (context) { context.rotateBasicUnbounded(basicRotation); });
53049 StateService.prototype.rotateBasicWithoutInertia = function (basicRotation) {
53050 this._inMotionOperation$.next(true);
53051 this._invokeContextOperation(function (context) { context.rotateBasicWithoutInertia(basicRotation); });
53053 StateService.prototype.rotateToBasic = function (basic) {
53054 this._inMotionOperation$.next(true);
53055 this._invokeContextOperation(function (context) { context.rotateToBasic(basic); });
53057 StateService.prototype.move = function (delta) {
53058 this._inMotionOperation$.next(true);
53059 this._invokeContextOperation(function (context) { context.move(delta); });
53061 StateService.prototype.moveTo = function (position) {
53062 this._inMotionOperation$.next(true);
53063 this._invokeContextOperation(function (context) { context.moveTo(position); });
53065 StateService.prototype.dolly = function (delta) {
53066 this._inMotionOperation$.next(true);
53067 this._invokeContextOperation(function (context) { context.dolly(delta); });
53069 StateService.prototype.orbit = function (rotation) {
53070 this._inMotionOperation$.next(true);
53071 this._invokeContextOperation(function (context) { context.orbit(rotation); });
53073 StateService.prototype.truck = function (direction) {
53074 this._inMotionOperation$.next(true);
53075 this._invokeContextOperation(function (context) { context.truck(direction); });
53078 * Change zoom level while keeping the reference point position approximately static.
53080 * @parameter {number} delta - Change in zoom level.
53081 * @parameter {Array<number>} reference - Reference point in basic coordinates.
53083 StateService.prototype.zoomIn = function (delta, reference) {
53084 this._inMotionOperation$.next(true);
53085 this._invokeContextOperation(function (context) { context.zoomIn(delta, reference); });
53087 StateService.prototype.getCenter = function () {
53088 return this._lastState$.pipe(operators_1.first(), operators_1.map(function (frame) {
53089 return frame.state.getCenter();
53092 StateService.prototype.getZoom = function () {
53093 return this._lastState$.pipe(operators_1.first(), operators_1.map(function (frame) {
53094 return frame.state.zoom;
53097 StateService.prototype.setCenter = function (center) {
53098 this._inMotionOperation$.next(true);
53099 this._invokeContextOperation(function (context) { context.setCenter(center); });
53101 StateService.prototype.setSpeed = function (speed) {
53102 this._invokeContextOperation(function (context) { context.setSpeed(speed); });
53104 StateService.prototype.setTransitionMode = function (mode) {
53105 this._invokeContextOperation(function (context) { context.setTransitionMode(mode); });
53107 StateService.prototype.setZoom = function (zoom) {
53108 this._inMotionOperation$.next(true);
53109 this._invokeContextOperation(function (context) { context.setZoom(zoom); });
53111 StateService.prototype.start = function () {
53112 if (this._frameId == null) {
53113 this._start$.next(null);
53114 this._frameId = this._frameGenerator.requestAnimationFrame(this._frame.bind(this));
53115 this._frame$.next(this._frameId);
53118 StateService.prototype.stop = function () {
53119 if (this._frameId != null) {
53120 this._frameGenerator.cancelAnimationFrame(this._frameId);
53121 this._frameId = null;
53124 StateService.prototype._invokeContextOperation = function (action) {
53125 this._contextOperation$
53126 .next(function (context) {
53131 StateService.prototype._frame = function (time) {
53132 this._frameId = this._frameGenerator.requestAnimationFrame(this._frame.bind(this));
53133 this._frame$.next(this._frameId);
53135 return StateService;
53137 exports.StateService = StateService;
53139 },{"../State":298,"rxjs":43,"rxjs/operators":241}],452:[function(require,module,exports){
53141 Object.defineProperty(exports, "__esModule", { value: true });
53142 exports.TransitionMode = void 0;
53144 * Enumeration for transition mode
53147 * @description Modes for specifying how transitions
53148 * between nodes are performed.
53150 var TransitionMode;
53151 (function (TransitionMode) {
53153 * Default transitions.
53155 * @description The viewer dynamically determines
53156 * whether transitions should be performed with or
53157 * without motion and blending for each transition
53158 * based on the underlying data.
53160 TransitionMode[TransitionMode["Default"] = 0] = "Default";
53162 * Instantaneous transitions.
53164 * @description All transitions are performed
53165 * without motion or blending.
53167 TransitionMode[TransitionMode["Instantaneous"] = 1] = "Instantaneous";
53168 })(TransitionMode = exports.TransitionMode || (exports.TransitionMode = {}));
53169 exports.default = TransitionMode;
53171 },{}],453:[function(require,module,exports){
53173 Object.defineProperty(exports, "__esModule", { value: true });
53175 },{}],454:[function(require,module,exports){
53177 var __extends = (this && this.__extends) || (function () {
53178 var extendStatics = function (d, b) {
53179 extendStatics = Object.setPrototypeOf ||
53180 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
53181 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
53182 return extendStatics(d, b);
53184 return function (d, b) {
53185 extendStatics(d, b);
53186 function __() { this.constructor = d; }
53187 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
53190 Object.defineProperty(exports, "__esModule", { value: true });
53191 exports.EarthState = void 0;
53192 var THREE = require("three");
53193 var State_1 = require("../../State");
53194 var EarthState = /** @class */ (function (_super) {
53195 __extends(EarthState, _super);
53196 function EarthState(state) {
53197 var _this = _super.call(this, state) || this;
53198 var viewingDirection = _this._camera.lookat
53200 .sub(_this._camera.position)
53202 _this._camera.lookat.copy(_this._camera.position);
53203 _this._camera.position.z = state.camera.position.z + 20;
53204 _this._camera.position.x = state.camera.position.x - 16 * viewingDirection.x;
53205 _this._camera.position.y = state.camera.position.y - 16 * viewingDirection.y;
53206 _this._camera.up.set(0, 0, 1);
53209 EarthState.prototype.traverse = function () {
53210 return new State_1.TraversingState(this);
53212 EarthState.prototype.wait = function () {
53213 return new State_1.WaitingState(this);
53215 EarthState.prototype.waitInteractively = function () {
53216 return new State_1.InteractiveWaitingState(this);
53218 EarthState.prototype.dolly = function (delta) {
53219 var camera = this._camera;
53220 var offset = new THREE.Vector3()
53221 .copy(camera.position)
53222 .sub(camera.lookat);
53223 var length = offset.length();
53224 var scaled = length * Math.pow(2, -delta);
53225 var clipped = Math.max(1, Math.min(scaled, 1000));
53226 offset.normalize();
53227 offset.multiplyScalar(clipped);
53228 camera.position.copy(camera.lookat).add(offset);
53230 EarthState.prototype.orbit = function (rotation) {
53231 var camera = this._camera;
53232 var q = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
53233 var qInverse = q.clone().inverse();
53234 var offset = new THREE.Vector3();
53235 offset.copy(camera.position).sub(camera.lookat);
53236 offset.applyQuaternion(q);
53237 var length = offset.length();
53238 var phi = Math.atan2(offset.y, offset.x);
53239 phi += rotation.phi;
53240 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
53241 theta += rotation.theta;
53242 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
53243 offset.x = Math.sin(theta) * Math.cos(phi);
53244 offset.y = Math.sin(theta) * Math.sin(phi);
53245 offset.z = Math.cos(theta);
53246 offset.applyQuaternion(qInverse);
53247 camera.position.copy(camera.lookat).add(offset.multiplyScalar(length));
53249 EarthState.prototype.truck = function (direction) {
53250 this._camera.position.add(new THREE.Vector3().fromArray(direction));
53251 this._camera.lookat.add(new THREE.Vector3().fromArray(direction));
53253 EarthState.prototype.update = function () { };
53255 }(State_1.StateBase));
53256 exports.EarthState = EarthState;
53257 exports.default = EarthState;
53260 },{"../../State":298,"three":242}],455:[function(require,module,exports){
53262 var __extends = (this && this.__extends) || (function () {
53263 var extendStatics = function (d, b) {
53264 extendStatics = Object.setPrototypeOf ||
53265 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
53266 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
53267 return extendStatics(d, b);
53269 return function (d, b) {
53270 extendStatics(d, b);
53271 function __() { this.constructor = d; }
53272 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
53275 Object.defineProperty(exports, "__esModule", { value: true });
53276 exports.InteractiveStateBase = void 0;
53277 var THREE = require("three");
53278 var State_1 = require("../../State");
53279 var InteractiveStateBase = /** @class */ (function (_super) {
53280 __extends(InteractiveStateBase, _super);
53281 function InteractiveStateBase(state) {
53282 var _this = _super.call(this, state) || this;
53283 _this._animationSpeed = 1 / 40;
53284 _this._rotationDelta = new State_1.RotationDelta(0, 0);
53285 _this._requestedRotationDelta = null;
53286 _this._basicRotation = [0, 0];
53287 _this._requestedBasicRotation = null;
53288 _this._requestedBasicRotationUnbounded = null;
53289 _this._rotationAcceleration = 0.86;
53290 _this._rotationIncreaseAlpha = 0.97;
53291 _this._rotationDecreaseAlpha = 0.9;
53292 _this._rotationThreshold = 1e-3;
53293 _this._unboundedRotationAlpha = 0.8;
53294 _this._desiredZoom = state.zoom;
53295 _this._minZoom = 0;
53296 _this._maxZoom = 3;
53297 _this._lookatDepth = 10;
53298 _this._desiredLookat = null;
53299 _this._desiredCenter = null;
53302 InteractiveStateBase.prototype.rotate = function (rotationDelta) {
53303 if (this._currentNode == null) {
53306 if (rotationDelta.phi === 0 && rotationDelta.theta === 0) {
53309 this._desiredZoom = this._zoom;
53310 this._desiredLookat = null;
53311 this._requestedBasicRotation = null;
53312 if (this._requestedRotationDelta != null) {
53313 this._requestedRotationDelta.phi = this._requestedRotationDelta.phi + rotationDelta.phi;
53314 this._requestedRotationDelta.theta = this._requestedRotationDelta.theta + rotationDelta.theta;
53317 this._requestedRotationDelta = new State_1.RotationDelta(rotationDelta.phi, rotationDelta.theta);
53320 InteractiveStateBase.prototype.rotateUnbounded = function (delta) {
53321 if (this._currentNode == null) {
53324 this._requestedBasicRotation = null;
53325 this._requestedRotationDelta = null;
53326 this._applyRotation(delta, this._currentCamera);
53327 this._applyRotation(delta, this._previousCamera);
53328 if (!this._desiredLookat) {
53331 var q = new THREE.Quaternion().setFromUnitVectors(this._currentCamera.up, new THREE.Vector3(0, 0, 1));
53332 var qInverse = q.clone().inverse();
53333 var offset = new THREE.Vector3()
53334 .copy(this._desiredLookat)
53335 .sub(this._camera.position)
53336 .applyQuaternion(q);
53337 var length = offset.length();
53338 var phi = Math.atan2(offset.y, offset.x);
53340 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
53341 theta += delta.theta;
53342 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
53343 offset.x = Math.sin(theta) * Math.cos(phi);
53344 offset.y = Math.sin(theta) * Math.sin(phi);
53345 offset.z = Math.cos(theta);
53346 offset.applyQuaternion(qInverse);
53347 this._desiredLookat
53348 .copy(this._camera.position)
53349 .add(offset.multiplyScalar(length));
53351 InteractiveStateBase.prototype.rotateWithoutInertia = function (rotationDelta) {
53352 if (this._currentNode == null) {
53355 this._desiredZoom = this._zoom;
53356 this._desiredLookat = null;
53357 this._requestedBasicRotation = null;
53358 this._requestedRotationDelta = null;
53359 var threshold = Math.PI / (10 * Math.pow(2, this._zoom));
53361 phi: this._spatial.clamp(rotationDelta.phi, -threshold, threshold),
53362 theta: this._spatial.clamp(rotationDelta.theta, -threshold, threshold),
53364 this._applyRotation(delta, this._currentCamera);
53365 this._applyRotation(delta, this._previousCamera);
53367 InteractiveStateBase.prototype.rotateBasic = function (basicRotation) {
53368 if (this._currentNode == null) {
53371 this._desiredZoom = this._zoom;
53372 this._desiredLookat = null;
53373 this._requestedRotationDelta = null;
53374 if (this._requestedBasicRotation != null) {
53375 this._requestedBasicRotation[0] += basicRotation[0];
53376 this._requestedBasicRotation[1] += basicRotation[1];
53377 var threshold = 0.05 / Math.pow(2, this._zoom);
53378 this._requestedBasicRotation[0] =
53379 this._spatial.clamp(this._requestedBasicRotation[0], -threshold, threshold);
53380 this._requestedBasicRotation[1] =
53381 this._spatial.clamp(this._requestedBasicRotation[1], -threshold, threshold);
53384 this._requestedBasicRotation = basicRotation.slice();
53387 InteractiveStateBase.prototype.rotateBasicUnbounded = function (basicRotation) {
53388 if (this._currentNode == null) {
53391 if (this._requestedBasicRotationUnbounded != null) {
53392 this._requestedBasicRotationUnbounded[0] += basicRotation[0];
53393 this._requestedBasicRotationUnbounded[1] += basicRotation[1];
53396 this._requestedBasicRotationUnbounded = basicRotation.slice();
53399 InteractiveStateBase.prototype.rotateBasicWithoutInertia = function (basic) {
53400 if (this._currentNode == null) {
53403 this._desiredZoom = this._zoom;
53404 this._desiredLookat = null;
53405 this._requestedRotationDelta = null;
53406 this._requestedBasicRotation = null;
53407 var threshold = 0.05 / Math.pow(2, this._zoom);
53408 var basicRotation = basic.slice();
53409 basicRotation[0] = this._spatial.clamp(basicRotation[0], -threshold, threshold);
53410 basicRotation[1] = this._spatial.clamp(basicRotation[1], -threshold, threshold);
53411 this._applyRotationBasic(basicRotation);
53413 InteractiveStateBase.prototype.rotateToBasic = function (basic) {
53414 if (this._currentNode == null) {
53417 this._desiredZoom = this._zoom;
53418 this._desiredLookat = null;
53419 basic[0] = this._spatial.clamp(basic[0], 0, 1);
53420 basic[1] = this._spatial.clamp(basic[1], 0, 1);
53421 var lookat = this.currentTransform.unprojectBasic(basic, this._lookatDepth);
53422 this._currentCamera.lookat.fromArray(lookat);
53424 InteractiveStateBase.prototype.zoomIn = function (delta, reference) {
53425 if (this._currentNode == null) {
53428 this._desiredZoom = Math.max(this._minZoom, Math.min(this._maxZoom, this._desiredZoom + delta));
53429 var currentCenter = this.currentTransform.projectBasic(this._currentCamera.lookat.toArray());
53430 var currentCenterX = currentCenter[0];
53431 var currentCenterY = currentCenter[1];
53432 var zoom0 = Math.pow(2, this._zoom);
53433 var zoom1 = Math.pow(2, this._desiredZoom);
53434 var refX = reference[0];
53435 var refY = reference[1];
53436 if (this.currentTransform.gpano != null &&
53437 this.currentTransform.gpano.CroppedAreaImageWidthPixels === this.currentTransform.gpano.FullPanoWidthPixels) {
53438 if (refX - currentCenterX > 0.5) {
53441 else if (currentCenterX - refX > 0.5) {
53445 var newCenterX = refX - zoom0 / zoom1 * (refX - currentCenterX);
53446 var newCenterY = refY - zoom0 / zoom1 * (refY - currentCenterY);
53447 var gpano = this.currentTransform.gpano;
53448 if (this._currentNode.fullPano) {
53449 newCenterX = this._spatial.wrap(newCenterX + this._basicRotation[0], 0, 1);
53450 newCenterY = this._spatial.clamp(newCenterY + this._basicRotation[1], 0.05, 0.95);
53452 else if (gpano != null &&
53453 this.currentTransform.gpano.CroppedAreaImageWidthPixels === this.currentTransform.gpano.FullPanoWidthPixels) {
53454 newCenterX = this._spatial.wrap(newCenterX + this._basicRotation[0], 0, 1);
53455 newCenterY = this._spatial.clamp(newCenterY + this._basicRotation[1], 0, 1);
53458 newCenterX = this._spatial.clamp(newCenterX, 0, 1);
53459 newCenterY = this._spatial.clamp(newCenterY, 0, 1);
53461 this._desiredLookat = new THREE.Vector3()
53462 .fromArray(this.currentTransform.unprojectBasic([newCenterX, newCenterY], this._lookatDepth));
53464 InteractiveStateBase.prototype.setCenter = function (center) {
53465 this._desiredLookat = null;
53466 this._requestedRotationDelta = null;
53467 this._requestedBasicRotation = null;
53468 this._desiredZoom = this._zoom;
53470 this._spatial.clamp(center[0], 0, 1),
53471 this._spatial.clamp(center[1], 0, 1),
53473 if (this._currentNode == null) {
53474 this._desiredCenter = clamped;
53477 this._desiredCenter = null;
53478 var currentLookat = new THREE.Vector3()
53479 .fromArray(this.currentTransform.unprojectBasic(clamped, this._lookatDepth));
53480 var previousTransform = this.previousTransform != null ?
53481 this.previousTransform :
53482 this.currentTransform;
53483 var previousLookat = new THREE.Vector3()
53484 .fromArray(previousTransform.unprojectBasic(clamped, this._lookatDepth));
53485 this._currentCamera.lookat.copy(currentLookat);
53486 this._previousCamera.lookat.copy(previousLookat);
53488 InteractiveStateBase.prototype.setZoom = function (zoom) {
53489 this._desiredLookat = null;
53490 this._requestedRotationDelta = null;
53491 this._requestedBasicRotation = null;
53492 this._zoom = this._spatial.clamp(zoom, this._minZoom, this._maxZoom);
53493 this._desiredZoom = this._zoom;
53495 InteractiveStateBase.prototype._applyRotation = function (delta, camera) {
53496 if (camera == null) {
53499 var q = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
53500 var qInverse = q.clone().inverse();
53501 var offset = new THREE.Vector3();
53502 offset.copy(camera.lookat).sub(camera.position);
53503 offset.applyQuaternion(q);
53504 var length = offset.length();
53505 var phi = Math.atan2(offset.y, offset.x);
53507 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
53508 theta += delta.theta;
53509 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
53510 offset.x = Math.sin(theta) * Math.cos(phi);
53511 offset.y = Math.sin(theta) * Math.sin(phi);
53512 offset.z = Math.cos(theta);
53513 offset.applyQuaternion(qInverse);
53514 camera.lookat.copy(camera.position).add(offset.multiplyScalar(length));
53516 InteractiveStateBase.prototype._applyRotationBasic = function (basicRotation) {
53517 var currentNode = this._currentNode;
53518 var previousNode = this._previousNode != null ?
53519 this.previousNode :
53521 var currentCamera = this._currentCamera;
53522 var previousCamera = this._previousCamera;
53523 var currentTransform = this.currentTransform;
53524 var previousTransform = this.previousTransform != null ?
53525 this.previousTransform :
53526 this.currentTransform;
53527 var currentBasic = currentTransform.projectBasic(currentCamera.lookat.toArray());
53528 var previousBasic = previousTransform.projectBasic(previousCamera.lookat.toArray());
53529 var currentGPano = currentTransform.gpano;
53530 var previousGPano = previousTransform.gpano;
53531 if (currentNode.fullPano) {
53532 currentBasic[0] = this._spatial.wrap(currentBasic[0] + basicRotation[0], 0, 1);
53533 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0.05, 0.95);
53535 else if (currentGPano != null &&
53536 currentTransform.gpano.CroppedAreaImageWidthPixels === currentTransform.gpano.FullPanoWidthPixels) {
53537 currentBasic[0] = this._spatial.wrap(currentBasic[0] + basicRotation[0], 0, 1);
53538 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
53541 currentBasic[0] = this._spatial.clamp(currentBasic[0] + basicRotation[0], 0, 1);
53542 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
53544 if (previousNode.fullPano) {
53545 previousBasic[0] = this._spatial.wrap(previousBasic[0] + basicRotation[0], 0, 1);
53546 previousBasic[1] = this._spatial.clamp(previousBasic[1] + basicRotation[1], 0.05, 0.95);
53548 else if (previousGPano != null &&
53549 previousTransform.gpano.CroppedAreaImageWidthPixels === previousTransform.gpano.FullPanoWidthPixels) {
53550 previousBasic[0] = this._spatial.wrap(previousBasic[0] + basicRotation[0], 0, 1);
53551 previousBasic[1] = this._spatial.clamp(previousBasic[1] + basicRotation[1], 0, 1);
53554 previousBasic[0] = this._spatial.clamp(previousBasic[0] + basicRotation[0], 0, 1);
53555 previousBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
53557 var currentLookat = currentTransform.unprojectBasic(currentBasic, this._lookatDepth);
53558 currentCamera.lookat.fromArray(currentLookat);
53559 var previousLookat = previousTransform.unprojectBasic(previousBasic, this._lookatDepth);
53560 previousCamera.lookat.fromArray(previousLookat);
53562 InteractiveStateBase.prototype._updateZoom = function (animationSpeed) {
53563 var diff = this._desiredZoom - this._zoom;
53564 var sign = diff > 0 ? 1 : diff < 0 ? -1 : 0;
53568 else if (Math.abs(diff) < 2e-3) {
53569 this._zoom = this._desiredZoom;
53570 if (this._desiredLookat != null) {
53571 this._desiredLookat = null;
53575 this._zoom += sign * Math.max(Math.abs(5 * animationSpeed * diff), 2e-3);
53578 InteractiveStateBase.prototype._updateLookat = function (animationSpeed) {
53579 if (this._desiredLookat === null) {
53582 var diff = this._desiredLookat.distanceToSquared(this._currentCamera.lookat);
53583 if (Math.abs(diff) < 1e-6) {
53584 this._currentCamera.lookat.copy(this._desiredLookat);
53585 this._desiredLookat = null;
53588 this._currentCamera.lookat.lerp(this._desiredLookat, 5 * animationSpeed);
53591 InteractiveStateBase.prototype._updateRotation = function () {
53592 if (this._requestedRotationDelta != null) {
53593 var length_1 = this._rotationDelta.lengthSquared();
53594 var requestedLength = this._requestedRotationDelta.lengthSquared();
53595 if (requestedLength > length_1) {
53596 this._rotationDelta.lerp(this._requestedRotationDelta, this._rotationIncreaseAlpha);
53599 this._rotationDelta.lerp(this._requestedRotationDelta, this._rotationDecreaseAlpha);
53601 this._requestedRotationDelta = null;
53604 if (this._rotationDelta.isZero) {
53607 var alpha = this.currentNode.fullPano ? 1 : this._alpha;
53608 this._rotationDelta.multiply(this._rotationAcceleration * alpha);
53609 this._rotationDelta.threshold(this._rotationThreshold);
53611 InteractiveStateBase.prototype._updateRotationBasic = function () {
53612 if (this._requestedBasicRotation != null) {
53613 var x = this._basicRotation[0];
53614 var y = this._basicRotation[1];
53615 var reqX = this._requestedBasicRotation[0];
53616 var reqY = this._requestedBasicRotation[1];
53617 if (Math.abs(reqX) > Math.abs(x)) {
53618 this._basicRotation[0] = (1 - this._rotationIncreaseAlpha) * x + this._rotationIncreaseAlpha * reqX;
53621 this._basicRotation[0] = (1 - this._rotationDecreaseAlpha) * x + this._rotationDecreaseAlpha * reqX;
53623 if (Math.abs(reqY) > Math.abs(y)) {
53624 this._basicRotation[1] = (1 - this._rotationIncreaseAlpha) * y + this._rotationIncreaseAlpha * reqY;
53627 this._basicRotation[1] = (1 - this._rotationDecreaseAlpha) * y + this._rotationDecreaseAlpha * reqY;
53629 this._requestedBasicRotation = null;
53632 if (this._requestedBasicRotationUnbounded != null) {
53633 var reqX = this._requestedBasicRotationUnbounded[0];
53634 var reqY = this._requestedBasicRotationUnbounded[1];
53635 if (Math.abs(reqX) > 0) {
53636 this._basicRotation[0] = (1 - this._unboundedRotationAlpha) * this._basicRotation[0] + this._unboundedRotationAlpha * reqX;
53638 if (Math.abs(reqY) > 0) {
53639 this._basicRotation[1] = (1 - this._unboundedRotationAlpha) * this._basicRotation[1] + this._unboundedRotationAlpha * reqY;
53641 if (this._desiredLookat != null) {
53642 var desiredBasicLookat = this.currentTransform.projectBasic(this._desiredLookat.toArray());
53643 desiredBasicLookat[0] += reqX;
53644 desiredBasicLookat[1] += reqY;
53645 this._desiredLookat = new THREE.Vector3()
53646 .fromArray(this.currentTransform.unprojectBasic(desiredBasicLookat, this._lookatDepth));
53648 this._requestedBasicRotationUnbounded = null;
53650 if (this._basicRotation[0] === 0 && this._basicRotation[1] === 0) {
53653 this._basicRotation[0] = this._rotationAcceleration * this._basicRotation[0];
53654 this._basicRotation[1] = this._rotationAcceleration * this._basicRotation[1];
53655 if (Math.abs(this._basicRotation[0]) < this._rotationThreshold / Math.pow(2, this._zoom) &&
53656 Math.abs(this._basicRotation[1]) < this._rotationThreshold / Math.pow(2, this._zoom)) {
53657 this._basicRotation = [0, 0];
53660 InteractiveStateBase.prototype._clearRotation = function () {
53661 if (this._currentNode.fullPano) {
53664 if (this._requestedRotationDelta != null) {
53665 this._requestedRotationDelta = null;
53667 if (!this._rotationDelta.isZero) {
53668 this._rotationDelta.reset();
53670 if (this._requestedBasicRotation != null) {
53671 this._requestedBasicRotation = null;
53673 if (this._basicRotation[0] > 0 || this._basicRotation[1] > 0) {
53674 this._basicRotation = [0, 0];
53677 InteractiveStateBase.prototype._setDesiredCenter = function () {
53678 if (this._desiredCenter == null) {
53681 var lookatDirection = new THREE.Vector3()
53682 .fromArray(this.currentTransform.unprojectBasic(this._desiredCenter, this._lookatDepth))
53683 .sub(this._currentCamera.position);
53684 this._currentCamera.lookat.copy(this._currentCamera.position.clone().add(lookatDirection));
53685 this._previousCamera.lookat.copy(this._previousCamera.position.clone().add(lookatDirection));
53686 this._desiredCenter = null;
53688 InteractiveStateBase.prototype._setDesiredZoom = function () {
53689 this._desiredZoom =
53690 this._currentNode.fullPano || this._previousNode == null ?
53693 return InteractiveStateBase;
53694 }(State_1.StateBase));
53695 exports.InteractiveStateBase = InteractiveStateBase;
53696 exports.default = InteractiveStateBase;
53699 },{"../../State":298,"three":242}],456:[function(require,module,exports){
53701 var __extends = (this && this.__extends) || (function () {
53702 var extendStatics = function (d, b) {
53703 extendStatics = Object.setPrototypeOf ||
53704 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
53705 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
53706 return extendStatics(d, b);
53708 return function (d, b) {
53709 extendStatics(d, b);
53710 function __() { this.constructor = d; }
53711 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
53714 Object.defineProperty(exports, "__esModule", { value: true });
53715 exports.InteractiveWaitingState = void 0;
53716 var State_1 = require("../../State");
53717 var InteractiveWaitingState = /** @class */ (function (_super) {
53718 __extends(InteractiveWaitingState, _super);
53719 function InteractiveWaitingState(state) {
53720 var _this = _super.call(this, state) || this;
53721 _this._adjustCameras();
53722 _this._motionless = _this._motionlessTransition();
53725 InteractiveWaitingState.prototype.traverse = function () {
53726 return new State_1.TraversingState(this);
53728 InteractiveWaitingState.prototype.wait = function () {
53729 return new State_1.WaitingState(this);
53731 InteractiveWaitingState.prototype.prepend = function (nodes) {
53732 _super.prototype.prepend.call(this, nodes);
53733 this._motionless = this._motionlessTransition();
53735 InteractiveWaitingState.prototype.set = function (nodes) {
53736 _super.prototype.set.call(this, nodes);
53737 this._motionless = this._motionlessTransition();
53739 InteractiveWaitingState.prototype.move = function (delta) {
53740 this._alpha = Math.max(0, Math.min(1, this._alpha + delta));
53742 InteractiveWaitingState.prototype.moveTo = function (position) {
53743 this._alpha = Math.max(0, Math.min(1, position));
53745 InteractiveWaitingState.prototype.update = function (fps) {
53746 this._updateRotation();
53747 if (!this._rotationDelta.isZero) {
53748 this._applyRotation(this._rotationDelta, this._previousCamera);
53749 this._applyRotation(this._rotationDelta, this._currentCamera);
53751 this._updateRotationBasic();
53752 if (this._basicRotation[0] !== 0 || this._basicRotation[1] !== 0) {
53753 this._applyRotationBasic(this._basicRotation);
53755 var animationSpeed = this._animationSpeed * (60 / fps);
53756 this._updateZoom(animationSpeed);
53757 this._updateLookat(animationSpeed);
53758 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
53760 InteractiveWaitingState.prototype._getAlpha = function () {
53761 return this._motionless ? Math.round(this._alpha) : this._alpha;
53763 InteractiveWaitingState.prototype._setCurrentCamera = function () {
53764 _super.prototype._setCurrentCamera.call(this);
53765 this._adjustCameras();
53767 InteractiveWaitingState.prototype._adjustCameras = function () {
53768 if (this._previousNode == null) {
53771 if (this._currentNode.fullPano) {
53772 var lookat = this._camera.lookat.clone().sub(this._camera.position);
53773 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
53775 if (this._previousNode.fullPano) {
53776 var lookat = this._currentCamera.lookat.clone().sub(this._currentCamera.position);
53777 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
53780 return InteractiveWaitingState;
53781 }(State_1.InteractiveStateBase));
53782 exports.InteractiveWaitingState = InteractiveWaitingState;
53783 exports.default = InteractiveWaitingState;
53785 },{"../../State":298}],457:[function(require,module,exports){
53787 Object.defineProperty(exports, "__esModule", { value: true });
53788 exports.StateBase = void 0;
53789 var Error_1 = require("../../Error");
53790 var Geo_1 = require("../../Geo");
53791 var State_1 = require("../../State");
53792 var StateBase = /** @class */ (function () {
53793 function StateBase(state) {
53794 this._spatial = new Geo_1.Spatial();
53795 this._geoCoords = new Geo_1.GeoCoords();
53796 this._referenceThreshold = 0.01;
53797 this._transitionMode = state.transitionMode;
53798 this._reference = state.reference;
53799 this._alpha = state.alpha;
53800 this._camera = state.camera.clone();
53801 this._zoom = state.zoom;
53802 this._currentIndex = state.currentIndex;
53803 this._trajectory = state.trajectory.slice();
53804 this._trajectoryTransforms = [];
53805 this._trajectoryCameras = [];
53806 for (var _i = 0, _a = this._trajectory; _i < _a.length; _i++) {
53808 var translation = this._nodeToTranslation(node, this._reference);
53809 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, node.cameraProjection);
53810 this._trajectoryTransforms.push(transform);
53811 this._trajectoryCameras.push(new Geo_1.Camera(transform));
53813 this._currentNode = this._trajectory.length > 0 ?
53814 this._trajectory[this._currentIndex] :
53816 this._previousNode = this._trajectory.length > 1 && this.currentIndex > 0 ?
53817 this._trajectory[this._currentIndex - 1] :
53819 this._currentCamera = this._trajectoryCameras.length > 0 ?
53820 this._trajectoryCameras[this._currentIndex].clone() :
53821 new Geo_1.Camera();
53822 this._previousCamera = this._trajectoryCameras.length > 1 && this.currentIndex > 0 ?
53823 this._trajectoryCameras[this._currentIndex - 1].clone() :
53824 this._currentCamera.clone();
53826 Object.defineProperty(StateBase.prototype, "reference", {
53828 return this._reference;
53833 Object.defineProperty(StateBase.prototype, "alpha", {
53835 return this._getAlpha();
53840 Object.defineProperty(StateBase.prototype, "camera", {
53842 return this._camera;
53847 Object.defineProperty(StateBase.prototype, "zoom", {
53854 Object.defineProperty(StateBase.prototype, "trajectory", {
53856 return this._trajectory;
53861 Object.defineProperty(StateBase.prototype, "currentIndex", {
53863 return this._currentIndex;
53868 Object.defineProperty(StateBase.prototype, "currentNode", {
53870 return this._currentNode;
53875 Object.defineProperty(StateBase.prototype, "previousNode", {
53877 return this._previousNode;
53882 Object.defineProperty(StateBase.prototype, "currentCamera", {
53884 return this._currentCamera;
53889 Object.defineProperty(StateBase.prototype, "currentTransform", {
53891 return this._trajectoryTransforms.length > 0 ?
53892 this._trajectoryTransforms[this.currentIndex] : null;
53897 Object.defineProperty(StateBase.prototype, "previousTransform", {
53899 return this._trajectoryTransforms.length > 1 && this.currentIndex > 0 ?
53900 this._trajectoryTransforms[this.currentIndex - 1] : null;
53905 Object.defineProperty(StateBase.prototype, "motionless", {
53907 return this._motionless;
53912 Object.defineProperty(StateBase.prototype, "transitionMode", {
53914 return this._transitionMode;
53919 StateBase.prototype.earth = function () { throw new Error("Not implemented"); };
53920 StateBase.prototype.traverse = function () { throw new Error("Not implemented"); };
53921 StateBase.prototype.wait = function () { throw new Error("Not implemented"); };
53922 StateBase.prototype.waitInteractively = function () { throw new Error("Not implemented"); };
53923 StateBase.prototype.move = function (delta) { };
53924 StateBase.prototype.moveTo = function (position) { };
53925 StateBase.prototype.rotate = function (delta) { };
53926 StateBase.prototype.rotateUnbounded = function (delta) { };
53927 StateBase.prototype.rotateWithoutInertia = function (delta) { };
53928 StateBase.prototype.rotateBasic = function (basicRotation) { };
53929 StateBase.prototype.rotateBasicUnbounded = function (basicRotation) { };
53930 StateBase.prototype.rotateBasicWithoutInertia = function (basicRotation) { };
53931 StateBase.prototype.rotateToBasic = function (basic) { };
53932 StateBase.prototype.setSpeed = function (speed) { };
53933 StateBase.prototype.zoomIn = function (delta, reference) { };
53934 StateBase.prototype.update = function (fps) { };
53935 StateBase.prototype.setCenter = function (center) { };
53936 StateBase.prototype.setZoom = function (zoom) { };
53937 StateBase.prototype.dolly = function (delta) { };
53938 StateBase.prototype.orbit = function (rotation) { };
53939 StateBase.prototype.truck = function (direction) { };
53940 StateBase.prototype.append = function (nodes) {
53941 if (nodes.length < 1) {
53942 throw Error("Trajectory can not be empty");
53944 if (this._currentIndex < 0) {
53948 this._trajectory = this._trajectory.concat(nodes);
53949 this._appendToTrajectories(nodes);
53952 StateBase.prototype.prepend = function (nodes) {
53953 if (nodes.length < 1) {
53954 throw Error("Trajectory can not be empty");
53956 this._trajectory = nodes.slice().concat(this._trajectory);
53957 this._currentIndex += nodes.length;
53958 this._setCurrentNode();
53959 var referenceReset = this._setReference(this._currentNode);
53960 if (referenceReset) {
53961 this._setTrajectories();
53964 this._prependToTrajectories(nodes);
53966 this._setCurrentCamera();
53968 StateBase.prototype.remove = function (n) {
53970 throw Error("n must be a positive integer");
53972 if (this._currentIndex - 1 < n) {
53973 throw Error("Current and previous nodes can not be removed");
53975 for (var i = 0; i < n; i++) {
53976 this._trajectory.shift();
53977 this._trajectoryTransforms.shift();
53978 this._trajectoryCameras.shift();
53979 this._currentIndex--;
53981 this._setCurrentNode();
53983 StateBase.prototype.clearPrior = function () {
53984 if (this._currentIndex > 0) {
53985 this.remove(this._currentIndex - 1);
53988 StateBase.prototype.clear = function () {
53990 if (this._currentIndex > 0) {
53991 this.remove(this._currentIndex - 1);
53994 StateBase.prototype.cut = function () {
53995 while (this._trajectory.length - 1 > this._currentIndex) {
53996 this._trajectory.pop();
53997 this._trajectoryTransforms.pop();
53998 this._trajectoryCameras.pop();
54001 StateBase.prototype.set = function (nodes) {
54002 this._setTrajectory(nodes);
54003 this._setCurrentNode();
54004 this._setReference(this._currentNode);
54005 this._setTrajectories();
54006 this._setCurrentCamera();
54008 StateBase.prototype.getCenter = function () {
54009 return this._currentNode != null ?
54010 this.currentTransform.projectBasic(this._camera.lookat.toArray()) :
54013 StateBase.prototype.setTransitionMode = function (mode) {
54014 this._transitionMode = mode;
54016 StateBase.prototype._getAlpha = function () { return 1; };
54017 StateBase.prototype._setCurrent = function () {
54018 this._setCurrentNode();
54019 var referenceReset = this._setReference(this._currentNode);
54020 if (referenceReset) {
54021 this._setTrajectories();
54023 this._setCurrentCamera();
54025 StateBase.prototype._setCurrentCamera = function () {
54026 this._currentCamera = this._trajectoryCameras[this._currentIndex].clone();
54027 this._previousCamera = this._currentIndex > 0 ?
54028 this._trajectoryCameras[this._currentIndex - 1].clone() :
54029 this._currentCamera.clone();
54031 StateBase.prototype._motionlessTransition = function () {
54032 var nodesSet = this._currentNode != null && this._previousNode != null;
54033 return nodesSet && (this._transitionMode === State_1.TransitionMode.Instantaneous || !(this._currentNode.merged &&
54034 this._previousNode.merged &&
54035 this._withinOriginalDistance() &&
54036 this._sameConnectedComponent()));
54038 StateBase.prototype._setReference = function (node) {
54039 // do not reset reference if node is within threshold distance
54040 if (Math.abs(node.latLon.lat - this.reference.lat) < this._referenceThreshold &&
54041 Math.abs(node.latLon.lon - this.reference.lon) < this._referenceThreshold) {
54044 // do not reset reference if previous node exist and transition is with motion
54045 if (this._previousNode != null && !this._motionlessTransition()) {
54048 this._reference.lat = node.latLon.lat;
54049 this._reference.lon = node.latLon.lon;
54050 this._reference.alt = node.alt;
54053 StateBase.prototype._setCurrentNode = function () {
54054 this._currentNode = this._trajectory.length > 0 ?
54055 this._trajectory[this._currentIndex] :
54057 this._previousNode = this._currentIndex > 0 ?
54058 this._trajectory[this._currentIndex - 1] :
54061 StateBase.prototype._setTrajectory = function (nodes) {
54062 if (nodes.length < 1) {
54063 throw new Error_1.ArgumentMapillaryError("Trajectory can not be empty");
54065 if (this._currentNode != null) {
54066 this._trajectory = [this._currentNode].concat(nodes);
54067 this._currentIndex = 1;
54070 this._trajectory = nodes.slice();
54071 this._currentIndex = 0;
54074 StateBase.prototype._setTrajectories = function () {
54075 this._trajectoryTransforms.length = 0;
54076 this._trajectoryCameras.length = 0;
54077 this._appendToTrajectories(this._trajectory);
54079 StateBase.prototype._appendToTrajectories = function (nodes) {
54080 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
54081 var node = nodes_1[_i];
54082 if (!node.assetsCached) {
54083 throw new Error_1.ArgumentMapillaryError("Assets must be cached when node is added to trajectory");
54085 var translation = this._nodeToTranslation(node, this.reference);
54086 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, node.cameraProjection);
54087 this._trajectoryTransforms.push(transform);
54088 this._trajectoryCameras.push(new Geo_1.Camera(transform));
54091 StateBase.prototype._prependToTrajectories = function (nodes) {
54092 for (var _i = 0, _a = nodes.reverse(); _i < _a.length; _i++) {
54094 if (!node.assetsCached) {
54095 throw new Error_1.ArgumentMapillaryError("Assets must be cached when added to trajectory");
54097 var translation = this._nodeToTranslation(node, this.reference);
54098 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, node.cameraProjection);
54099 this._trajectoryTransforms.unshift(transform);
54100 this._trajectoryCameras.unshift(new Geo_1.Camera(transform));
54103 StateBase.prototype._nodeToTranslation = function (node, reference) {
54104 return Geo_1.Geo.computeTranslation({ alt: node.alt, lat: node.latLon.lat, lon: node.latLon.lon }, node.rotation, reference);
54106 StateBase.prototype._sameConnectedComponent = function () {
54107 var current = this._currentNode;
54108 var previous = this._previousNode;
54109 return !!current && !!previous &&
54110 current.mergeCC === previous.mergeCC;
54112 StateBase.prototype._withinOriginalDistance = function () {
54113 var current = this._currentNode;
54114 var previous = this._previousNode;
54115 if (!current || !previous) {
54118 // 50 km/h moves 28m in 2s
54119 var distance = this._spatial.distanceFromLatLon(current.originalLatLon.lat, current.originalLatLon.lon, previous.originalLatLon.lat, previous.originalLatLon.lon);
54120 return distance < 25;
54124 exports.StateBase = StateBase;
54126 },{"../../Error":293,"../../Geo":294,"../../State":298}],458:[function(require,module,exports){
54128 var __extends = (this && this.__extends) || (function () {
54129 var extendStatics = function (d, b) {
54130 extendStatics = Object.setPrototypeOf ||
54131 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
54132 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
54133 return extendStatics(d, b);
54135 return function (d, b) {
54136 extendStatics(d, b);
54137 function __() { this.constructor = d; }
54138 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
54141 Object.defineProperty(exports, "__esModule", { value: true });
54142 exports.TraversingState = void 0;
54143 var UnitBezier = require("@mapbox/unitbezier");
54144 var State_1 = require("../../State");
54145 var TraversingState = /** @class */ (function (_super) {
54146 __extends(TraversingState, _super);
54147 function TraversingState(state) {
54148 var _this = _super.call(this, state) || this;
54149 _this._adjustCameras();
54150 _this._motionless = _this._motionlessTransition();
54151 _this._baseAlpha = _this._alpha;
54152 _this._speedCoefficient = 1;
54153 _this._unitBezier = new UnitBezier(0.74, 0.67, 0.38, 0.96);
54154 _this._useBezier = false;
54157 TraversingState.prototype.earth = function () {
54158 return new State_1.EarthState(this);
54160 TraversingState.prototype.wait = function () {
54161 return new State_1.WaitingState(this);
54163 TraversingState.prototype.waitInteractively = function () {
54164 return new State_1.InteractiveWaitingState(this);
54166 TraversingState.prototype.append = function (nodes) {
54167 var emptyTrajectory = this._trajectory.length === 0;
54168 if (emptyTrajectory) {
54169 this._resetTransition();
54171 _super.prototype.append.call(this, nodes);
54172 if (emptyTrajectory) {
54173 this._setDesiredCenter();
54174 this._setDesiredZoom();
54177 TraversingState.prototype.prepend = function (nodes) {
54178 var emptyTrajectory = this._trajectory.length === 0;
54179 if (emptyTrajectory) {
54180 this._resetTransition();
54182 _super.prototype.prepend.call(this, nodes);
54183 if (emptyTrajectory) {
54184 this._setDesiredCenter();
54185 this._setDesiredZoom();
54188 TraversingState.prototype.set = function (nodes) {
54189 _super.prototype.set.call(this, nodes);
54190 this._desiredLookat = null;
54191 this._resetTransition();
54192 this._clearRotation();
54193 this._setDesiredCenter();
54194 this._setDesiredZoom();
54195 if (this._trajectory.length < 3) {
54196 this._useBezier = true;
54199 TraversingState.prototype.setSpeed = function (speed) {
54200 this._speedCoefficient = this._spatial.clamp(speed, 0, 10);
54202 TraversingState.prototype.update = function (fps) {
54203 if (this._alpha === 1 && this._currentIndex + this._alpha < this._trajectory.length) {
54204 this._currentIndex += 1;
54205 this._useBezier = this._trajectory.length < 3 &&
54206 this._currentIndex + 1 === this._trajectory.length;
54207 this._setCurrent();
54208 this._resetTransition();
54209 this._clearRotation();
54210 this._desiredZoom = this._currentNode.fullPano ? this._zoom : 0;
54211 this._desiredLookat = null;
54213 var animationSpeed = this._animationSpeed * (60 / fps);
54214 this._baseAlpha = Math.min(1, this._baseAlpha + this._speedCoefficient * animationSpeed);
54215 if (this._useBezier) {
54216 this._alpha = this._unitBezier.solve(this._baseAlpha);
54219 this._alpha = this._baseAlpha;
54221 this._updateRotation();
54222 if (!this._rotationDelta.isZero) {
54223 this._applyRotation(this._rotationDelta, this._previousCamera);
54224 this._applyRotation(this._rotationDelta, this._currentCamera);
54226 this._updateRotationBasic();
54227 if (this._basicRotation[0] !== 0 || this._basicRotation[1] !== 0) {
54228 this._applyRotationBasic(this._basicRotation);
54230 this._updateZoom(animationSpeed);
54231 this._updateLookat(animationSpeed);
54232 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
54234 TraversingState.prototype._getAlpha = function () {
54235 return this._motionless ? Math.ceil(this._alpha) : this._alpha;
54237 TraversingState.prototype._setCurrentCamera = function () {
54238 _super.prototype._setCurrentCamera.call(this);
54239 this._adjustCameras();
54241 TraversingState.prototype._adjustCameras = function () {
54242 if (this._previousNode == null) {
54245 var lookat = this._camera.lookat.clone().sub(this._camera.position);
54246 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
54247 if (this._currentNode.fullPano) {
54248 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
54251 TraversingState.prototype._resetTransition = function () {
54253 this._baseAlpha = 0;
54254 this._motionless = this._motionlessTransition();
54256 return TraversingState;
54257 }(State_1.InteractiveStateBase));
54258 exports.TraversingState = TraversingState;
54259 exports.default = TraversingState;
54261 },{"../../State":298,"@mapbox/unitbezier":2}],459:[function(require,module,exports){
54263 var __extends = (this && this.__extends) || (function () {
54264 var extendStatics = function (d, b) {
54265 extendStatics = Object.setPrototypeOf ||
54266 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
54267 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
54268 return extendStatics(d, b);
54270 return function (d, b) {
54271 extendStatics(d, b);
54272 function __() { this.constructor = d; }
54273 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
54276 Object.defineProperty(exports, "__esModule", { value: true });
54277 exports.WaitingState = void 0;
54278 var State_1 = require("../../State");
54279 var WaitingState = /** @class */ (function (_super) {
54280 __extends(WaitingState, _super);
54281 function WaitingState(state) {
54282 var _this = _super.call(this, state) || this;
54284 _this._adjustCameras();
54285 _this._motionless = _this._motionlessTransition();
54288 WaitingState.prototype.traverse = function () {
54289 return new State_1.TraversingState(this);
54291 WaitingState.prototype.waitInteractively = function () {
54292 return new State_1.InteractiveWaitingState(this);
54294 WaitingState.prototype.prepend = function (nodes) {
54295 _super.prototype.prepend.call(this, nodes);
54296 this._motionless = this._motionlessTransition();
54298 WaitingState.prototype.set = function (nodes) {
54299 _super.prototype.set.call(this, nodes);
54300 this._motionless = this._motionlessTransition();
54302 WaitingState.prototype.move = function (delta) {
54303 this._alpha = Math.max(0, Math.min(1, this._alpha + delta));
54305 WaitingState.prototype.moveTo = function (position) {
54306 this._alpha = Math.max(0, Math.min(1, position));
54308 WaitingState.prototype.update = function (fps) {
54309 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
54311 WaitingState.prototype._getAlpha = function () {
54312 return this._motionless ? Math.round(this._alpha) : this._alpha;
54314 WaitingState.prototype._setCurrentCamera = function () {
54315 _super.prototype._setCurrentCamera.call(this);
54316 this._adjustCameras();
54318 WaitingState.prototype._adjustCameras = function () {
54319 if (this._previousNode == null) {
54322 if (this._currentNode.fullPano) {
54323 var lookat = this._camera.lookat.clone().sub(this._camera.position);
54324 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
54326 if (this._previousNode.fullPano) {
54327 var lookat = this._currentCamera.lookat.clone().sub(this._currentCamera.position);
54328 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
54331 return WaitingState;
54332 }(State_1.StateBase));
54333 exports.WaitingState = WaitingState;
54334 exports.default = WaitingState;
54336 },{"../../State":298}],460:[function(require,module,exports){
54338 Object.defineProperty(exports, "__esModule", { value: true });
54339 exports.ImageTileLoader = void 0;
54340 var rxjs_1 = require("rxjs");
54342 * @class ImageTileLoader
54344 * @classdesc Represents a loader of image tiles.
54346 var ImageTileLoader = /** @class */ (function () {
54348 * Create a new node image tile loader instance.
54350 * @param {string} scheme - The URI scheme.
54351 * @param {string} host - The URI host.
54352 * @param {string} [origin] - The origin query param.
54354 function ImageTileLoader(scheme, host, origin) {
54355 this._scheme = scheme;
54357 this._origin = origin != null ? "?origin=" + origin : "";
54360 * Retrieve an image tile.
54362 * @description Retrieve an image tile by specifying the area
54363 * as well as the scaled size.
54365 * @param {string} identifier - The identifier of the image.
54366 * @param {number} x - The top left x pixel coordinate for the tile
54367 * in the original image.
54368 * @param {number} y - The top left y pixel coordinate for the tile
54369 * in the original image.
54370 * @param {number} w - The pixel width of the tile in the original image.
54371 * @param {number} h - The pixel height of the tile in the original image.
54372 * @param {number} scaledW - The scaled width of the returned tile.
54373 * @param {number} scaledH - The scaled height of the returned tile.
54375 ImageTileLoader.prototype.getTile = function (identifier, x, y, w, h, scaledW, scaledH) {
54376 var characteristics = "/" + identifier + "/" + x + "," + y + "," + w + "," + h + "/" + scaledW + "," + scaledH + "/0/default.jpg";
54377 var url = this._scheme +
54382 var xmlHTTP = null;
54383 return [rxjs_1.Observable.create(function (subscriber) {
54384 xmlHTTP = new XMLHttpRequest();
54385 xmlHTTP.open("GET", url, true);
54386 xmlHTTP.responseType = "arraybuffer";
54387 xmlHTTP.timeout = 15000;
54388 xmlHTTP.onload = function (event) {
54389 if (xmlHTTP.status !== 200) {
54390 subscriber.error(new Error("Failed to fetch tile (" + identifier + ": " + x + "," + y + "," + w + "," + h + "). " +
54391 ("Status: " + xmlHTTP.status + ", " + xmlHTTP.statusText)));
54394 var image = new Image();
54395 image.crossOrigin = "Anonymous";
54396 image.onload = function (e) {
54397 subscriber.next(image);
54398 subscriber.complete();
54400 image.onerror = function (error) {
54401 subscriber.error(new Error("Failed to load tile image (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
54403 var blob = new Blob([xmlHTTP.response]);
54404 image.src = window.URL.createObjectURL(blob);
54406 xmlHTTP.onerror = function (error) {
54407 subscriber.error(new Error("Failed to fetch tile (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
54409 xmlHTTP.ontimeout = function (error) {
54410 subscriber.error(new Error("Tile request timed out (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
54412 xmlHTTP.onabort = function (event) {
54413 subscriber.error(new Error("Tile request was aborted (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
54415 xmlHTTP.send(null);
54418 if (xmlHTTP != null) {
54424 return ImageTileLoader;
54426 exports.ImageTileLoader = ImageTileLoader;
54427 exports.default = ImageTileLoader;
54429 },{"rxjs":43}],461:[function(require,module,exports){
54431 Object.defineProperty(exports, "__esModule", { value: true });
54432 exports.ImageTileStore = void 0;
54434 * @class ImageTileStore
54436 * @classdesc Represents a store for image tiles.
54438 var ImageTileStore = /** @class */ (function () {
54440 * Create a new node image tile store instance.
54442 function ImageTileStore() {
54446 * Add an image tile to the store.
54448 * @param {HTMLImageElement} image - The image tile.
54449 * @param {string} key - The identifier for the tile.
54450 * @param {number} level - The level of the tile.
54452 ImageTileStore.prototype.addImage = function (image, key, level) {
54453 if (!(level in this._images)) {
54454 this._images[level] = {};
54456 this._images[level][key] = image;
54459 * Dispose the store.
54461 * @description Disposes all cached assets.
54463 ImageTileStore.prototype.dispose = function () {
54464 for (var _i = 0, _a = Object.keys(this._images); _i < _a.length; _i++) {
54465 var level = _a[_i];
54466 var levelImages = this._images[level];
54467 for (var _b = 0, _c = Object.keys(levelImages); _b < _c.length; _b++) {
54469 window.URL.revokeObjectURL(levelImages[key].src);
54470 delete levelImages[key];
54472 delete this._images[level];
54476 * Get an image tile from the store.
54478 * @param {string} key - The identifier for the tile.
54479 * @param {number} level - The level of the tile.
54481 ImageTileStore.prototype.getImage = function (key, level) {
54482 return this._images[level][key];
54485 * Check if an image tile exist in the store.
54487 * @param {string} key - The identifier for the tile.
54488 * @param {number} level - The level of the tile.
54490 ImageTileStore.prototype.hasImage = function (key, level) {
54491 return level in this._images && key in this._images[level];
54493 return ImageTileStore;
54495 exports.ImageTileStore = ImageTileStore;
54496 exports.default = ImageTileStore;
54498 },{}],462:[function(require,module,exports){
54500 Object.defineProperty(exports, "__esModule", { value: true });
54501 exports.RegionOfInterestCalculator = void 0;
54502 var Geo_1 = require("../Geo");
54504 * @class RegionOfInterestCalculator
54506 * @classdesc Represents a calculator for regions of interest.
54508 var RegionOfInterestCalculator = /** @class */ (function () {
54509 function RegionOfInterestCalculator() {
54510 this._viewportCoords = new Geo_1.ViewportCoords();
54513 * Compute a region of interest based on the current render camera
54514 * and the viewport size.
54516 * @param {RenderCamera} renderCamera - Render camera used for unprojections.
54517 * @param {ISize} size - Viewport size in pixels.
54518 * @param {Transform} transform - Transform used for projections.
54520 * @returns {IRegionOfInterest} A region of interest.
54522 RegionOfInterestCalculator.prototype.computeRegionOfInterest = function (renderCamera, size, transform) {
54523 var viewportBoundaryPoints = this._viewportBoundaryPoints(4);
54524 var bbox = this._viewportPointsBoundingBox(viewportBoundaryPoints, renderCamera, transform);
54525 this._clipBoundingBox(bbox);
54526 var viewportPixelWidth = 2 / size.width;
54527 var viewportPixelHeight = 2 / size.height;
54528 var centralViewportPixel = [
54529 [-0.5 * viewportPixelWidth, 0.5 * viewportPixelHeight],
54530 [0.5 * viewportPixelWidth, 0.5 * viewportPixelHeight],
54531 [0.5 * viewportPixelWidth, -0.5 * viewportPixelHeight],
54532 [-0.5 * viewportPixelWidth, -0.5 * viewportPixelHeight],
54534 var cpbox = this._viewportPointsBoundingBox(centralViewportPixel, renderCamera, transform);
54537 pixelHeight: cpbox.maxY - cpbox.minY,
54538 pixelWidth: cpbox.maxX - cpbox.minX + (cpbox.minX < cpbox.maxX ? 0 : 1),
54541 RegionOfInterestCalculator.prototype._viewportBoundaryPoints = function (pointsPerSide) {
54543 var os = [[-1, 1], [1, 1], [1, -1], [-1, -1]];
54544 var ds = [[2, 0], [0, -2], [-2, 0], [0, 2]];
54545 for (var side = 0; side < 4; ++side) {
54548 for (var i = 0; i < pointsPerSide; ++i) {
54549 points.push([o[0] + d[0] * i / pointsPerSide,
54550 o[1] + d[1] * i / pointsPerSide]);
54555 RegionOfInterestCalculator.prototype._viewportPointsBoundingBox = function (viewportPoints, renderCamera, transform) {
54557 var basicPoints = viewportPoints
54558 .map(function (point) {
54559 return _this._viewportCoords
54560 .viewportToBasic(point[0], point[1], transform, renderCamera.perspective);
54562 if (transform.gpano != null) {
54563 return this._boundingBoxPano(basicPoints);
54566 return this._boundingBox(basicPoints);
54569 RegionOfInterestCalculator.prototype._boundingBox = function (points) {
54571 maxX: Number.NEGATIVE_INFINITY,
54572 maxY: Number.NEGATIVE_INFINITY,
54573 minX: Number.POSITIVE_INFINITY,
54574 minY: Number.POSITIVE_INFINITY,
54576 for (var i = 0; i < points.length; ++i) {
54577 bbox.minX = Math.min(bbox.minX, points[i][0]);
54578 bbox.maxX = Math.max(bbox.maxX, points[i][0]);
54579 bbox.minY = Math.min(bbox.minY, points[i][1]);
54580 bbox.maxY = Math.max(bbox.maxY, points[i][1]);
54584 RegionOfInterestCalculator.prototype._boundingBoxPano = function (points) {
54588 for (var i = 0; i < points.length; ++i) {
54589 xs.push(points[i][0]);
54590 ys.push(points[i][1]);
54592 xs.sort(function (a, b) { return _this._sign(a - b); });
54593 ys.sort(function (a, b) { return _this._sign(a - b); });
54594 var intervalX = this._intervalPano(xs);
54596 maxX: intervalX[1],
54597 maxY: ys[ys.length - 1],
54598 minX: intervalX[0],
54603 * Find the max interval between consecutive numbers.
54604 * Assumes numbers are between 0 and 1, sorted and that
54605 * x is equivalent to x + 1.
54607 RegionOfInterestCalculator.prototype._intervalPano = function (xs) {
54610 for (var i = 0; i < xs.length - 1; ++i) {
54611 var dx = xs[i + 1] - xs[i];
54617 var loopdx = xs[0] + 1 - xs[xs.length - 1];
54618 if (loopdx > maxdx) {
54619 return [xs[0], xs[xs.length - 1]];
54622 return [xs[maxi + 1], xs[maxi]];
54625 RegionOfInterestCalculator.prototype._clipBoundingBox = function (bbox) {
54626 bbox.minX = Math.max(0, Math.min(1, bbox.minX));
54627 bbox.maxX = Math.max(0, Math.min(1, bbox.maxX));
54628 bbox.minY = Math.max(0, Math.min(1, bbox.minY));
54629 bbox.maxY = Math.max(0, Math.min(1, bbox.maxY));
54631 RegionOfInterestCalculator.prototype._sign = function (n) {
54632 return n > 0 ? 1 : n < 0 ? -1 : 0;
54634 return RegionOfInterestCalculator;
54636 exports.RegionOfInterestCalculator = RegionOfInterestCalculator;
54637 exports.default = RegionOfInterestCalculator;
54639 },{"../Geo":294}],463:[function(require,module,exports){
54641 Object.defineProperty(exports, "__esModule", { value: true });
54642 exports.TextureProvider = void 0;
54643 var operators_1 = require("rxjs/operators");
54644 var THREE = require("three");
54645 var rxjs_1 = require("rxjs");
54647 * @class TextureProvider
54649 * @classdesc Represents a provider of textures.
54651 var TextureProvider = /** @class */ (function () {
54653 * Create a new node texture provider instance.
54655 * @param {string} key - The identifier of the image for which to request tiles.
54656 * @param {number} width - The full width of the original image.
54657 * @param {number} height - The full height of the original image.
54658 * @param {number} tileSize - The size used when requesting tiles.
54659 * @param {HTMLImageElement} background - Image to use as background.
54660 * @param {ImageTileLoader} imageTileLoader - Loader for retrieving tiles.
54661 * @param {ImageTileStore} imageTileStore - Store for saving tiles.
54662 * @param {THREE.WebGLRenderer} renderer - Renderer used for rendering tiles to texture.
54664 function TextureProvider(key, width, height, tileSize, background, imageTileLoader, imageTileStore, renderer) {
54665 this._disposed = false;
54667 if (width <= 0 || height <= 0) {
54668 console.warn("Original image size (" + width + ", " + height + ") is invalid (" + key + "). Tiles will not be loaded.");
54670 this._width = width;
54671 this._height = height;
54672 this._maxLevel = Math.ceil(Math.log(Math.max(height, width)) / Math.log(2));
54673 this._currentLevel = -1;
54674 this._tileSize = tileSize;
54675 this._updated$ = new rxjs_1.Subject();
54676 this._createdSubject$ = new rxjs_1.Subject();
54677 this._created$ = this._createdSubject$.pipe(operators_1.publishReplay(1), operators_1.refCount());
54678 this._createdSubscription = this._created$.subscribe(function () { });
54679 this._hasSubject$ = new rxjs_1.Subject();
54680 this._has$ = this._hasSubject$.pipe(operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
54681 this._hasSubscription = this._has$.subscribe(function () { });
54682 this._abortFunctions = [];
54683 this._tileSubscriptions = {};
54684 this._renderedCurrentLevelTiles = {};
54685 this._renderedTiles = {};
54686 this._background = background;
54687 this._camera = null;
54688 this._imageTileLoader = imageTileLoader;
54689 this._imageTileStore = imageTileStore;
54690 this._renderer = renderer;
54691 this._renderTarget = null;
54694 Object.defineProperty(TextureProvider.prototype, "disposed", {
54698 * @returns {boolean} Value indicating whether provider has
54702 return this._disposed;
54707 Object.defineProperty(TextureProvider.prototype, "hasTexture$", {
54711 * @returns {Observable<boolean>} Observable emitting
54712 * values indicating when the existance of a texture
54721 Object.defineProperty(TextureProvider.prototype, "key", {
54725 * @returns {boolean} The identifier of the image for
54726 * which to render textures.
54734 Object.defineProperty(TextureProvider.prototype, "textureUpdated$", {
54736 * Get textureUpdated$.
54738 * @returns {Observable<boolean>} Observable emitting
54739 * values when an existing texture has been updated.
54742 return this._updated$;
54747 Object.defineProperty(TextureProvider.prototype, "textureCreated$", {
54749 * Get textureCreated$.
54751 * @returns {Observable<boolean>} Observable emitting
54752 * values when a new texture has been created.
54755 return this._created$;
54761 * Abort all outstanding image tile requests.
54763 TextureProvider.prototype.abort = function () {
54764 for (var key in this._tileSubscriptions) {
54765 if (!this._tileSubscriptions.hasOwnProperty(key)) {
54768 this._tileSubscriptions[key].unsubscribe();
54770 this._tileSubscriptions = {};
54771 for (var _i = 0, _a = this._abortFunctions; _i < _a.length; _i++) {
54772 var abort = _a[_i];
54775 this._abortFunctions = [];
54778 * Dispose the provider.
54780 * @description Disposes all cached assets and
54781 * aborts all outstanding image tile requests.
54783 TextureProvider.prototype.dispose = function () {
54784 if (this._disposed) {
54785 console.warn("Texture already disposed (" + this._key + ")");
54789 if (this._renderTarget != null) {
54790 this._renderTarget.dispose();
54791 this._renderTarget = null;
54793 this._imageTileStore.dispose();
54794 this._imageTileStore = null;
54795 this._background = null;
54796 this._camera = null;
54797 this._imageTileLoader = null;
54798 this._renderer = null;
54800 this._createdSubscription.unsubscribe();
54801 this._hasSubscription.unsubscribe();
54802 this._disposed = true;
54805 * Set the region of interest.
54807 * @description When the region of interest is set the
54808 * the tile level is determined and tiles for the region
54809 * are fetched from the store or the loader and renderedLevel
54812 * @param {IRegionOfInterest} roi - Spatial edges to cache.
54814 TextureProvider.prototype.setRegionOfInterest = function (roi) {
54815 if (this._width <= 0 || this._height <= 0) {
54819 var width = 1 / this._roi.pixelWidth;
54820 var height = 1 / this._roi.pixelHeight;
54821 var size = Math.max(height, width);
54822 var currentLevel = Math.max(0, Math.min(this._maxLevel, Math.ceil(Math.log(size) / Math.log(2))));
54823 if (currentLevel !== this._currentLevel) {
54825 this._currentLevel = currentLevel;
54826 if (!(this._currentLevel in this._renderedTiles)) {
54827 this._renderedTiles[this._currentLevel] = [];
54829 this._renderedCurrentLevelTiles = {};
54830 for (var _i = 0, _a = this._renderedTiles[this._currentLevel]; _i < _a.length; _i++) {
54832 this._renderedCurrentLevelTiles[this._tileKey(this._tileSize, tile)] = true;
54835 var topLeft = this._getTileCoords([this._roi.bbox.minX, this._roi.bbox.minY]);
54836 var bottomRight = this._getTileCoords([this._roi.bbox.maxX, this._roi.bbox.maxY]);
54837 var tiles = this._getTiles(topLeft, bottomRight);
54838 if (this._camera == null) {
54839 this._camera = new THREE.OrthographicCamera(-this._width / 2, this._width / 2, this._height / 2, -this._height / 2, -1, 1);
54840 this._camera.position.z = 1;
54841 var gl = this._renderer.getContext();
54842 var maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
54843 var backgroundSize = Math.max(this._width, this._height);
54844 var scale = maxTextureSize > backgroundSize ? 1 : maxTextureSize / backgroundSize;
54845 var targetWidth = Math.floor(scale * this._width);
54846 var targetHeight = Math.floor(scale * this._height);
54847 this._renderTarget = new THREE.WebGLRenderTarget(targetWidth, targetHeight, {
54848 depthBuffer: false,
54849 format: THREE.RGBFormat,
54850 magFilter: THREE.LinearFilter,
54851 minFilter: THREE.LinearFilter,
54852 stencilBuffer: false,
54854 this._renderToTarget(0, 0, this._width, this._height, this._background);
54855 this._createdSubject$.next(this._renderTarget.texture);
54856 this._hasSubject$.next(true);
54858 this._fetchTiles(tiles);
54860 TextureProvider.prototype.setTileSize = function (tileSize) {
54861 this._tileSize = tileSize;
54864 * Update the image used as background for the texture.
54866 * @param {HTMLImageElement} background - The background image.
54868 TextureProvider.prototype.updateBackground = function (background) {
54869 this._background = background;
54872 * Retrieve an image tile.
54874 * @description Retrieve an image tile and render it to the
54875 * texture. Add the tile to the store and emit to the updated
54878 * @param {Array<number>} tile - The tile coordinates.
54879 * @param {number} level - The tile level.
54880 * @param {number} x - The top left x pixel coordinate of the tile.
54881 * @param {number} y - The top left y pixel coordinate of the tile.
54882 * @param {number} w - The pixel width of the tile.
54883 * @param {number} h - The pixel height of the tile.
54884 * @param {number} scaledW - The scaled width of the returned tile.
54885 * @param {number} scaledH - The scaled height of the returned tile.
54887 TextureProvider.prototype._fetchTile = function (tile, level, x, y, w, h, scaledX, scaledY) {
54889 var getTile = this._imageTileLoader.getTile(this._key, x, y, w, h, scaledX, scaledY);
54890 var tile$ = getTile[0];
54891 var abort = getTile[1];
54892 this._abortFunctions.push(abort);
54893 var tileKey = this._tileKey(this._tileSize, tile);
54894 var subscription = tile$
54895 .subscribe(function (image) {
54896 _this._renderToTarget(x, y, w, h, image);
54897 _this._removeFromDictionary(tileKey, _this._tileSubscriptions);
54898 _this._removeFromArray(abort, _this._abortFunctions);
54899 _this._setTileRendered(tile, _this._currentLevel);
54900 _this._imageTileStore.addImage(image, tileKey, level);
54901 _this._updated$.next(true);
54902 }, function (error) {
54903 _this._removeFromDictionary(tileKey, _this._tileSubscriptions);
54904 _this._removeFromArray(abort, _this._abortFunctions);
54905 console.error(error);
54907 if (!subscription.closed) {
54908 this._tileSubscriptions[tileKey] = subscription;
54912 * Retrieve image tiles.
54914 * @description Retrieve a image tiles and render them to the
54915 * texture. Retrieve from store if it exists, otherwise Retrieve
54918 * @param {Array<Array<number>>} tiles - Array of tile coordinates to
54921 TextureProvider.prototype._fetchTiles = function (tiles) {
54922 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
54923 for (var _i = 0, tiles_1 = tiles; _i < tiles_1.length; _i++) {
54924 var tile = tiles_1[_i];
54925 var tileKey = this._tileKey(this._tileSize, tile);
54926 if (tileKey in this._renderedCurrentLevelTiles ||
54927 tileKey in this._tileSubscriptions) {
54930 var tileX = tileSize * tile[0];
54931 var tileY = tileSize * tile[1];
54932 var tileWidth = tileX + tileSize > this._width ? this._width - tileX : tileSize;
54933 var tileHeight = tileY + tileSize > this._height ? this._height - tileY : tileSize;
54934 if (this._imageTileStore.hasImage(tileKey, this._currentLevel)) {
54935 this._renderToTarget(tileX, tileY, tileWidth, tileHeight, this._imageTileStore.getImage(tileKey, this._currentLevel));
54936 this._setTileRendered(tile, this._currentLevel);
54937 this._updated$.next(true);
54940 var scaledX = Math.floor(tileWidth / tileSize * this._tileSize);
54941 var scaledY = Math.floor(tileHeight / tileSize * this._tileSize);
54942 this._fetchTile(tile, this._currentLevel, tileX, tileY, tileWidth, tileHeight, scaledX, scaledY);
54946 * Get tile coordinates for a point using the current level.
54948 * @param {Array<number>} point - Point in basic coordinates.
54950 * @returns {Array<number>} x and y tile coodinates.
54952 TextureProvider.prototype._getTileCoords = function (point) {
54953 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
54954 var maxX = Math.ceil(this._width / tileSize) - 1;
54955 var maxY = Math.ceil(this._height / tileSize) - 1;
54957 Math.min(Math.floor(this._width * point[0] / tileSize), maxX),
54958 Math.min(Math.floor(this._height * point[1] / tileSize), maxY),
54962 * Get tile coordinates for all tiles contained in a bounding
54965 * @param {Array<number>} topLeft - Top left tile coordinate of bounding box.
54966 * @param {Array<number>} bottomRight - Bottom right tile coordinate of bounding box.
54968 * @returns {Array<Array<number>>} Array of x, y tile coodinates.
54970 TextureProvider.prototype._getTiles = function (topLeft, bottomRight) {
54972 if (topLeft[0] > bottomRight[0]) {
54973 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
54974 var maxX = Math.ceil(this._width / tileSize) - 1;
54975 for (var x = topLeft[0]; x <= maxX; x++) {
54978 for (var x = 0; x <= bottomRight[0]; x++) {
54983 for (var x = topLeft[0]; x <= bottomRight[0]; x++) {
54988 for (var _i = 0, xs_1 = xs; _i < xs_1.length; _i++) {
54990 for (var y = topLeft[1]; y <= bottomRight[1]; y++) {
54991 tiles.push([x, y]);
54997 * Remove an item from an array if it exists in array.
54999 * @param {T} item - Item to remove.
55000 * @param {Array<T>} array - Array from which item should be removed.
55002 TextureProvider.prototype._removeFromArray = function (item, array) {
55003 var index = array.indexOf(item);
55004 if (index !== -1) {
55005 array.splice(index, 1);
55009 * Remove an item from a dictionary.
55011 * @param {string} key - Key of the item to remove.
55012 * @param {Object} dict - Dictionary from which item should be removed.
55014 TextureProvider.prototype._removeFromDictionary = function (key, dict) {
55020 * Render an image tile to the target texture.
55022 * @param {number} x - The top left x pixel coordinate of the tile.
55023 * @param {number} y - The top left y pixel coordinate of the tile.
55024 * @param {number} w - The pixel width of the tile.
55025 * @param {number} h - The pixel height of the tile.
55026 * @param {HTMLImageElement} background - The image tile to render.
55028 TextureProvider.prototype._renderToTarget = function (x, y, w, h, image) {
55029 var texture = new THREE.Texture(image);
55030 texture.minFilter = THREE.LinearFilter;
55031 texture.needsUpdate = true;
55032 var geometry = new THREE.PlaneGeometry(w, h);
55033 var material = new THREE.MeshBasicMaterial({ map: texture, side: THREE.FrontSide });
55034 var mesh = new THREE.Mesh(geometry, material);
55035 mesh.position.x = -this._width / 2 + x + w / 2;
55036 mesh.position.y = this._height / 2 - y - h / 2;
55037 var scene = new THREE.Scene();
55039 var target = this._renderer.getRenderTarget();
55040 this._renderer.setRenderTarget(this._renderTarget);
55041 this._renderer.render(scene, this._camera);
55042 this._renderer.setRenderTarget(target);
55043 scene.remove(mesh);
55044 geometry.dispose();
55045 material.dispose();
55049 * Mark a tile as rendered.
55051 * @description Clears tiles marked as rendered in other
55052 * levels of the tile pyramid if they were rendered on
55053 * top of or below the tile.
55055 * @param {Arrary<number>} tile - The tile coordinates.
55056 * @param {number} level - Tile level of the tile coordinates.
55058 TextureProvider.prototype._setTileRendered = function (tile, level) {
55059 var otherLevels = Object.keys(this._renderedTiles)
55060 .map(function (key) {
55061 return parseInt(key, 10);
55063 .filter(function (renderedLevel) {
55064 return renderedLevel !== level;
55066 for (var _i = 0, otherLevels_1 = otherLevels; _i < otherLevels_1.length; _i++) {
55067 var otherLevel = otherLevels_1[_i];
55068 var scale = Math.pow(2, otherLevel - level);
55069 if (otherLevel < level) {
55070 var x = Math.floor(scale * tile[0]);
55071 var y = Math.floor(scale * tile[1]);
55072 for (var _a = 0, _b = this._renderedTiles[otherLevel].slice(); _a < _b.length; _a++) {
55073 var otherTile = _b[_a];
55074 if (otherTile[0] === x && otherTile[1] === y) {
55075 var index = this._renderedTiles[otherLevel].indexOf(otherTile);
55076 this._renderedTiles[otherLevel].splice(index, 1);
55081 var startX = scale * tile[0];
55082 var endX = startX + scale - 1;
55083 var startY = scale * tile[1];
55084 var endY = startY + scale - 1;
55085 for (var _c = 0, _d = this._renderedTiles[otherLevel].slice(); _c < _d.length; _c++) {
55086 var otherTile = _d[_c];
55087 if (otherTile[0] >= startX && otherTile[0] <= endX &&
55088 otherTile[1] >= startY && otherTile[1] <= endY) {
55089 var index = this._renderedTiles[otherLevel].indexOf(otherTile);
55090 this._renderedTiles[otherLevel].splice(index, 1);
55094 if (this._renderedTiles[otherLevel].length === 0) {
55095 delete this._renderedTiles[otherLevel];
55098 this._renderedTiles[level].push(tile);
55099 this._renderedCurrentLevelTiles[this._tileKey(this._tileSize, tile)] = true;
55102 * Create a tile key from a tile coordinates.
55104 * @description Tile keys are used as a hash for
55105 * storing the tile in a dictionary.
55107 * @param {number} tileSize - The tile size.
55108 * @param {Arrary<number>} tile - The tile coordinates.
55110 TextureProvider.prototype._tileKey = function (tileSize, tile) {
55111 return tileSize + "-" + tile[0] + "-" + tile[1];
55113 return TextureProvider;
55115 exports.TextureProvider = TextureProvider;
55116 exports.default = TextureProvider;
55118 },{"rxjs":43,"rxjs/operators":241,"three":242}],464:[function(require,module,exports){
55120 Object.defineProperty(exports, "__esModule", { value: true });
55122 },{}],465:[function(require,module,exports){
55124 Object.defineProperty(exports, "__esModule", { value: true });
55125 exports.DOM = void 0;
55126 var DOM = /** @class */ (function () {
55127 function DOM(doc) {
55128 this._document = !!doc ? doc : document;
55130 Object.defineProperty(DOM.prototype, "document", {
55132 return this._document;
55137 DOM.prototype.createElement = function (tagName, className, container) {
55138 var element = this._document.createElement(tagName);
55140 element.className = className;
55143 container.appendChild(element);
55150 exports.default = DOM;
55152 },{}],466:[function(require,module,exports){
55154 Object.defineProperty(exports, "__esModule", { value: true });
55155 exports.EventEmitter = void 0;
55156 var EventEmitter = /** @class */ (function () {
55157 function EventEmitter() {
55161 * Subscribe to an event by its name.
55162 * @param {string }eventType - The name of the event to subscribe to.
55163 * @param {any} fn - The handler called when the event occurs.
55165 EventEmitter.prototype.on = function (eventType, fn) {
55166 this._events[eventType] = this._events[eventType] || [];
55167 this._events[eventType].push(fn);
55171 * Unsubscribe from an event by its name.
55172 * @param {string} eventType - The name of the event to subscribe to.
55173 * @param {any} fn - The handler to remove.
55175 EventEmitter.prototype.off = function (eventType, fn) {
55180 if (!this._listens(eventType)) {
55181 var idx = this._events[eventType].indexOf(fn);
55183 this._events[eventType].splice(idx, 1);
55185 if (this._events[eventType].length) {
55186 delete this._events[eventType];
55190 delete this._events[eventType];
55194 EventEmitter.prototype.fire = function (eventType, data) {
55195 if (!this._listens(eventType)) {
55198 for (var _i = 0, _a = this._events[eventType]; _i < _a.length; _i++) {
55200 fn.call(this, data);
55204 EventEmitter.prototype._listens = function (eventType) {
55205 return !!(this._events && this._events[eventType]);
55207 return EventEmitter;
55209 exports.EventEmitter = EventEmitter;
55210 exports.default = EventEmitter;
55212 },{}],467:[function(require,module,exports){
55214 Object.defineProperty(exports, "__esModule", { value: true });
55215 exports.Settings = void 0;
55216 var Viewer_1 = require("../Viewer");
55217 var Settings = /** @class */ (function () {
55218 function Settings() {
55220 Object.defineProperty(Settings, "baseImageSize", {
55222 return Settings._baseImageSize;
55227 Object.defineProperty(Settings, "basePanoramaSize", {
55229 return Settings._basePanoramaSize;
55234 Object.defineProperty(Settings, "maxImageSize", {
55236 return Settings._maxImageSize;
55241 Settings.setOptions = function (options) {
55242 Settings._baseImageSize = options.baseImageSize != null ?
55243 options.baseImageSize :
55244 Viewer_1.ImageSize.Size640;
55245 Settings._basePanoramaSize = options.basePanoramaSize != null ?
55246 options.basePanoramaSize :
55247 Viewer_1.ImageSize.Size2048;
55248 Settings._maxImageSize = options.maxImageSize != null ?
55249 options.maxImageSize :
55250 Viewer_1.ImageSize.Size2048;
55254 exports.Settings = Settings;
55255 exports.default = Settings;
55257 },{"../Viewer":302}],468:[function(require,module,exports){
55259 Object.defineProperty(exports, "__esModule", { value: true });
55260 exports.isWebGLSupported = exports.isWebGLSupportedCached = exports.isBlobSupported = exports.isObjectSupported = exports.isJSONSupported = exports.isFunctionSupported = exports.isArraySupported = exports.isBrowser = void 0;
55261 function isBrowser() {
55262 return typeof window !== "undefined" && typeof document !== "undefined";
55264 exports.isBrowser = isBrowser;
55265 function isArraySupported() {
55266 return !!(Array.prototype &&
55267 Array.prototype.filter &&
55268 Array.prototype.indexOf &&
55269 Array.prototype.map &&
55270 Array.prototype.reverse);
55272 exports.isArraySupported = isArraySupported;
55273 function isFunctionSupported() {
55274 return !!(Function.prototype && Function.prototype.bind);
55276 exports.isFunctionSupported = isFunctionSupported;
55277 function isJSONSupported() {
55278 return "JSON" in window && "parse" in JSON && "stringify" in JSON;
55280 exports.isJSONSupported = isJSONSupported;
55281 function isObjectSupported() {
55282 return !!(Object.keys &&
55285 exports.isObjectSupported = isObjectSupported;
55286 function isBlobSupported() {
55287 return "Blob" in window && "URL" in window;
55289 exports.isBlobSupported = isBlobSupported;
55290 var isWebGLSupportedCache = undefined;
55291 function isWebGLSupportedCached() {
55292 if (isWebGLSupportedCache === undefined) {
55293 isWebGLSupportedCache = isWebGLSupported();
55295 return isWebGLSupportedCache;
55297 exports.isWebGLSupportedCached = isWebGLSupportedCached;
55298 function isWebGLSupported() {
55299 var webGLContextAttributes = {
55303 failIfMajorPerformanceCaveat: false,
55304 premultipliedAlpha: true,
55305 preserveDrawingBuffer: false,
55308 var canvas = document.createElement("canvas");
55309 var context = canvas.getContext("webgl", webGLContextAttributes) ||
55310 canvas.getContext("experimental-webgl", webGLContextAttributes);
55314 var requiredExtensions = [
55315 "OES_standard_derivatives",
55317 var supportedExtensions = context.getSupportedExtensions();
55318 for (var _i = 0, requiredExtensions_1 = requiredExtensions; _i < requiredExtensions_1.length; _i++) {
55319 var requiredExtension = requiredExtensions_1[_i];
55320 if (supportedExtensions.indexOf(requiredExtension) === -1) {
55326 exports.isWebGLSupported = isWebGLSupported;
55328 },{}],469:[function(require,module,exports){
55330 Object.defineProperty(exports, "__esModule", { value: true });
55331 exports.Urls = void 0;
55332 var Urls = /** @class */ (function () {
55335 Object.defineProperty(Urls, "explore", {
55337 return Urls._scheme + "://" + Urls._exploreHost;
55342 Object.defineProperty(Urls, "origin", {
55344 return Urls._origin;
55349 Object.defineProperty(Urls, "tileScheme", {
55351 return Urls._scheme;
55356 Object.defineProperty(Urls, "tileDomain", {
55358 return Urls._imageTileHost;
55363 Urls.clusterReconstruction = function (key) {
55364 return Urls._scheme + "://" + Urls._clusterReconstructionHost + "/" + key + "/v1.0/aligned.jsonz";
55366 Urls.exporeImage = function (key) {
55367 return Urls._scheme + "://" + Urls._exploreHost + "/app/?pKey=" + key + "&focus=photo";
55369 Urls.exporeUser = function (username) {
55370 return Urls._scheme + "://" + Urls._exploreHost + "/app/user/" + username;
55372 Urls.falcorModel = function (clientId) {
55373 return Urls._scheme + "://" + Urls._apiHost + "/v3/model.json?client_id=" + clientId;
55375 Urls.protoMesh = function (key) {
55376 return Urls._scheme + "://" + Urls._meshHost + "/v2/mesh/" + key;
55378 Urls.thumbnail = function (key, size, origin) {
55379 var query = !!origin ? "?origin=" + origin : "";
55380 return Urls._scheme + "://" + Urls._imageHost + "/" + key + "/thumb-" + size + ".jpg" + query;
55382 Urls.setOptions = function (options) {
55386 if (!!options.apiHost) {
55387 Urls._apiHost = options.apiHost;
55389 if (!!options.clusterReconstructionHost) {
55390 Urls._clusterReconstructionHost = options.clusterReconstructionHost;
55392 if (!!options.exploreHost) {
55393 Urls._exploreHost = options.exploreHost;
55395 if (!!options.imageHost) {
55396 Urls._imageHost = options.imageHost;
55398 if (!!options.imageTileHost) {
55399 Urls._imageTileHost = options.imageTileHost;
55401 if (!!options.meshHost) {
55402 Urls._meshHost = options.meshHost;
55404 if (!!options.scheme) {
55405 Urls._scheme = options.scheme;
55408 Urls._apiHost = "a.mapillary.com";
55409 Urls._clusterReconstructionHost = "cluster-reconstructions.mapillary.com";
55410 Urls._exploreHost = "www.mapillary.com";
55411 Urls._imageHost = "images.mapillary.com";
55412 Urls._imageTileHost = "loris.mapillary.com";
55413 Urls._meshHost = "meshes.mapillary.com";
55414 Urls._origin = "mapillary.webgl";
55415 Urls._scheme = "https";
55418 exports.Urls = Urls;
55419 exports.default = Urls;
55421 },{}],470:[function(require,module,exports){
55423 Object.defineProperty(exports, "__esModule", { value: true });
55424 exports.Alignment = void 0;
55426 * Enumeration for alignments
55431 (function (Alignment) {
55435 Alignment[Alignment["Bottom"] = 0] = "Bottom";
55437 * Align to bottom left
55439 Alignment[Alignment["BottomLeft"] = 1] = "BottomLeft";
55441 * Align to bottom right
55443 Alignment[Alignment["BottomRight"] = 2] = "BottomRight";
55447 Alignment[Alignment["Center"] = 3] = "Center";
55451 Alignment[Alignment["Left"] = 4] = "Left";
55455 Alignment[Alignment["Right"] = 5] = "Right";
55459 Alignment[Alignment["Top"] = 6] = "Top";
55461 * Align to top left
55463 Alignment[Alignment["TopLeft"] = 7] = "TopLeft";
55465 * Align to top right
55467 Alignment[Alignment["TopRight"] = 8] = "TopRight";
55468 })(Alignment = exports.Alignment || (exports.Alignment = {}));
55469 exports.default = Alignment;
55471 },{}],471:[function(require,module,exports){
55473 Object.defineProperty(exports, "__esModule", { value: true });
55474 exports.CacheService = void 0;
55475 var rxjs_1 = require("rxjs");
55476 var operators_1 = require("rxjs/operators");
55477 var Graph_1 = require("../Graph");
55478 var CacheService = /** @class */ (function () {
55479 function CacheService(graphService, stateService) {
55480 this._graphService = graphService;
55481 this._stateService = stateService;
55482 this._started = false;
55484 Object.defineProperty(CacheService.prototype, "started", {
55486 return this._started;
55491 CacheService.prototype.start = function () {
55493 if (this._started) {
55496 this._uncacheSubscription = this._stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
55497 return frame.state.currentNode.key;
55498 }), operators_1.map(function (frame) {
55499 var trajectory = frame.state.trajectory;
55500 var trajectoryKeys = trajectory
55501 .map(function (n) {
55504 var sequenceKey = trajectory[trajectory.length - 1].sequenceKey;
55505 return [trajectoryKeys, sequenceKey];
55506 }), operators_1.bufferCount(1, 5), operators_1.withLatestFrom(this._graphService.graphMode$), operators_1.switchMap(function (_a) {
55507 var keepBuffer = _a[0], graphMode = _a[1];
55508 var keepKeys = keepBuffer[0][0];
55509 var keepSequenceKey = graphMode === Graph_1.GraphMode.Sequence ?
55510 keepBuffer[0][1] : undefined;
55511 return _this._graphService.uncache$(keepKeys, keepSequenceKey);
55513 .subscribe(function () { });
55514 this._cacheNodeSubscription = this._graphService.graphMode$.pipe(operators_1.skip(1), operators_1.withLatestFrom(this._stateService.currentState$), operators_1.switchMap(function (_a) {
55515 var mode = _a[0], frame = _a[1];
55516 return mode === Graph_1.GraphMode.Sequence ?
55517 _this._keyToEdges(frame.state.currentNode.key, function (node) {
55518 return node.sequenceEdges$;
55520 rxjs_1.from(frame.state.trajectory
55521 .map(function (node) {
55524 .slice(frame.state.currentIndex)).pipe(operators_1.mergeMap(function (key) {
55525 return _this._keyToEdges(key, function (node) {
55526 return node.spatialEdges$;
55530 .subscribe(function () { });
55531 this._started = true;
55533 CacheService.prototype.stop = function () {
55534 if (!this._started) {
55537 this._uncacheSubscription.unsubscribe();
55538 this._uncacheSubscription = null;
55539 this._cacheNodeSubscription.unsubscribe();
55540 this._cacheNodeSubscription = null;
55541 this._started = false;
55543 CacheService.prototype._keyToEdges = function (key, nodeToEdgeMap) {
55544 return this._graphService.cacheNode$(key).pipe(operators_1.switchMap(nodeToEdgeMap), operators_1.first(function (status) {
55545 return status.cached;
55546 }), operators_1.timeout(15000), operators_1.catchError(function (error) {
55547 console.error("Failed to cache edges (" + key + ").", error);
55548 return rxjs_1.empty();
55551 return CacheService;
55553 exports.CacheService = CacheService;
55554 exports.default = CacheService;
55556 },{"../Graph":295,"rxjs":43,"rxjs/operators":241}],472:[function(require,module,exports){
55558 Object.defineProperty(exports, "__esModule", { value: true });
55559 exports.ComponentController = void 0;
55560 var operators_1 = require("rxjs/operators");
55561 var Component_1 = require("../Component");
55562 var ComponentController = /** @class */ (function () {
55563 function ComponentController(container, navigator, observer, key, options, componentService) {
55565 this._container = container;
55566 this._observer = observer;
55567 this._navigator = navigator;
55568 this._options = options != null ? options : {};
55570 this._navigable = key == null;
55571 this._componentService = !!componentService ?
55573 new Component_1.ComponentService(this._container, this._navigator);
55574 this._coverComponent = this._componentService.getCover();
55575 this._initializeComponents();
55577 this._initilizeCoverComponent();
55578 this._subscribeCoverComponent();
55581 this._navigator.movedToKey$.pipe(operators_1.first(function (k) {
55584 .subscribe(function (k) {
55586 _this._componentService.deactivateCover();
55587 _this._coverComponent.configure({ key: _this._key, state: Component_1.CoverState.Hidden });
55588 _this._subscribeCoverComponent();
55589 _this._navigator.stateService.start();
55590 _this._navigator.cacheService.start();
55591 _this._navigator.panService.start();
55592 _this._observer.startEmit();
55596 Object.defineProperty(ComponentController.prototype, "navigable", {
55598 return this._navigable;
55603 ComponentController.prototype.get = function (name) {
55604 return this._componentService.get(name);
55606 ComponentController.prototype.activate = function (name) {
55607 this._componentService.activate(name);
55609 ComponentController.prototype.activateCover = function () {
55610 this._coverComponent.configure({ state: Component_1.CoverState.Visible });
55612 ComponentController.prototype.deactivate = function (name) {
55613 this._componentService.deactivate(name);
55615 ComponentController.prototype.deactivateCover = function () {
55616 this._coverComponent.configure({ state: Component_1.CoverState.Loading });
55618 ComponentController.prototype._initializeComponents = function () {
55619 var options = this._options;
55620 this._uFalse(options.background, "background");
55621 this._uFalse(options.debug, "debug");
55622 this._uFalse(options.image, "image");
55623 this._uFalse(options.marker, "marker");
55624 this._uFalse(options.navigation, "navigation");
55625 this._uFalse(options.popup, "popup");
55626 this._uFalse(options.route, "route");
55627 this._uFalse(options.slider, "slider");
55628 this._uFalse(options.spatialData, "spatialData");
55629 this._uFalse(options.tag, "tag");
55630 this._uTrue(options.attribution, "attribution");
55631 this._uTrue(options.bearing, "bearing");
55632 this._uTrue(options.cache, "cache");
55633 this._uTrue(options.direction, "direction");
55634 this._uTrue(options.imagePlane, "imagePlane");
55635 this._uTrue(options.keyboard, "keyboard");
55636 this._uTrue(options.loading, "loading");
55637 this._uTrue(options.mouse, "mouse");
55638 this._uTrue(options.sequence, "sequence");
55639 this._uTrue(options.stats, "stats");
55640 this._uTrue(options.zoom, "zoom");
55642 ComponentController.prototype._initilizeCoverComponent = function () {
55643 var options = this._options;
55644 this._coverComponent.configure({ key: this._key });
55645 if (options.cover === undefined || options.cover) {
55646 this.activateCover();
55649 this.deactivateCover();
55652 ComponentController.prototype._setNavigable = function (navigable) {
55653 if (this._navigable === navigable) {
55656 this._navigable = navigable;
55657 this._observer.navigable$.next(navigable);
55659 ComponentController.prototype._subscribeCoverComponent = function () {
55661 this._coverComponent.configuration$.pipe(operators_1.distinctUntilChanged(undefined, function (c) {
55664 .subscribe(function (conf) {
55665 if (conf.state === Component_1.CoverState.Loading) {
55666 _this._navigator.stateService.currentKey$.pipe(operators_1.first(), operators_1.switchMap(function (key) {
55667 var keyChanged = key == null || key !== conf.key;
55669 _this._setNavigable(false);
55671 return keyChanged ?
55672 _this._navigator.moveToKey$(conf.key) :
55673 _this._navigator.stateService.currentNode$.pipe(operators_1.first());
55675 .subscribe(function () {
55676 _this._navigator.stateService.start();
55677 _this._navigator.cacheService.start();
55678 _this._navigator.panService.start();
55679 _this._observer.startEmit();
55680 _this._coverComponent.configure({ state: Component_1.CoverState.Hidden });
55681 _this._componentService.deactivateCover();
55682 _this._setNavigable(true);
55683 }, function (error) {
55684 console.error("Failed to deactivate cover.", error);
55685 _this._coverComponent.configure({ state: Component_1.CoverState.Visible });
55688 else if (conf.state === Component_1.CoverState.Visible) {
55689 _this._observer.stopEmit();
55690 _this._navigator.stateService.stop();
55691 _this._navigator.cacheService.stop();
55692 _this._navigator.playService.stop();
55693 _this._navigator.panService.stop();
55694 _this._componentService.activateCover();
55695 _this._setNavigable(conf.key == null);
55699 ComponentController.prototype._uFalse = function (option, name) {
55700 if (option === undefined) {
55701 this._componentService.deactivate(name);
55704 if (typeof option === "boolean") {
55706 this._componentService.activate(name);
55709 this._componentService.deactivate(name);
55713 this._componentService.configure(name, option);
55714 this._componentService.activate(name);
55716 ComponentController.prototype._uTrue = function (option, name) {
55717 if (option === undefined) {
55718 this._componentService.activate(name);
55721 if (typeof option === "boolean") {
55723 this._componentService.activate(name);
55726 this._componentService.deactivate(name);
55730 this._componentService.configure(name, option);
55731 this._componentService.activate(name);
55733 return ComponentController;
55735 exports.ComponentController = ComponentController;
55737 },{"../Component":291,"rxjs/operators":241}],473:[function(require,module,exports){
55739 Object.defineProperty(exports, "__esModule", { value: true });
55740 exports.Container = void 0;
55741 var Render_1 = require("../Render");
55742 var Utils_1 = require("../Utils");
55743 var Viewer_1 = require("../Viewer");
55744 var Container = /** @class */ (function () {
55745 function Container(container, stateService, options, dom) {
55746 this._dom = !!dom ? dom : new Utils_1.DOM();
55747 if (typeof container === 'string') {
55748 this._container = this._dom.document.getElementById(container);
55749 if (!this._container) {
55750 throw new Error("Container '" + container + "' not found.");
55753 else if (container instanceof HTMLElement) {
55754 this._container = container;
55757 throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
55759 this.id = !!this._container.id ? this._container.id : "mapillary-js-fallback-container-id";
55760 this._container.classList.add("mapillary-js");
55761 this._canvasContainer = this._dom.createElement("div", "mapillary-js-interactive", this._container);
55762 this._domContainer = this._dom.createElement("div", "mapillary-js-dom", this._container);
55763 this.renderService = new Render_1.RenderService(this._container, stateService.currentState$, options.renderMode);
55764 this.glRenderer = new Render_1.GLRenderer(this._canvasContainer, this.renderService, this._dom);
55765 this.domRenderer = new Render_1.DOMRenderer(this._domContainer, this.renderService, stateService.currentState$);
55766 this.keyboardService = new Viewer_1.KeyboardService(this._canvasContainer);
55767 this.mouseService = new Viewer_1.MouseService(this._container, this._canvasContainer, this._domContainer, document);
55768 this.touchService = new Viewer_1.TouchService(this._canvasContainer, this._domContainer);
55769 this.spriteService = new Viewer_1.SpriteService(options.sprite);
55771 Object.defineProperty(Container.prototype, "element", {
55773 return this._container;
55778 Object.defineProperty(Container.prototype, "canvasContainer", {
55780 return this._canvasContainer;
55785 Object.defineProperty(Container.prototype, "domContainer", {
55787 return this._domContainer;
55794 exports.Container = Container;
55795 exports.default = Container;
55797 },{"../Render":297,"../Utils":301,"../Viewer":302}],474:[function(require,module,exports){
55799 Object.defineProperty(exports, "__esModule", { value: true });
55800 exports.ImageSize = void 0;
55802 * Enumeration for image sizes
55805 * @description Image sizes in pixels for the long side of the image.
55808 (function (ImageSize) {
55810 * 320 pixels image size
55812 ImageSize[ImageSize["Size320"] = 320] = "Size320";
55814 * 640 pixels image size
55816 ImageSize[ImageSize["Size640"] = 640] = "Size640";
55818 * 1024 pixels image size
55820 ImageSize[ImageSize["Size1024"] = 1024] = "Size1024";
55822 * 2048 pixels image size
55824 ImageSize[ImageSize["Size2048"] = 2048] = "Size2048";
55825 })(ImageSize = exports.ImageSize || (exports.ImageSize = {}));
55827 },{}],475:[function(require,module,exports){
55829 Object.defineProperty(exports, "__esModule", { value: true });
55830 exports.KeyboardService = void 0;
55831 var rxjs_1 = require("rxjs");
55832 var KeyboardService = /** @class */ (function () {
55833 function KeyboardService(canvasContainer) {
55834 this._keyDown$ = rxjs_1.fromEvent(canvasContainer, "keydown");
55835 this._keyUp$ = rxjs_1.fromEvent(canvasContainer, "keyup");
55837 Object.defineProperty(KeyboardService.prototype, "keyDown$", {
55839 return this._keyDown$;
55844 Object.defineProperty(KeyboardService.prototype, "keyUp$", {
55846 return this._keyUp$;
55851 return KeyboardService;
55853 exports.KeyboardService = KeyboardService;
55854 exports.default = KeyboardService;
55856 },{"rxjs":43}],476:[function(require,module,exports){
55858 Object.defineProperty(exports, "__esModule", { value: true });
55859 exports.LoadingService = void 0;
55860 var operators_1 = require("rxjs/operators");
55861 var rxjs_1 = require("rxjs");
55862 var LoadingService = /** @class */ (function () {
55863 function LoadingService() {
55864 this._loadersSubject$ = new rxjs_1.Subject();
55865 this._loaders$ = this._loadersSubject$.pipe(operators_1.scan(function (loaders, loader) {
55866 if (loader.task !== undefined) {
55867 loaders[loader.task] = loader.loading;
55870 }, {}), operators_1.startWith({}), operators_1.publishReplay(1), operators_1.refCount());
55872 Object.defineProperty(LoadingService.prototype, "loading$", {
55874 return this._loaders$.pipe(operators_1.map(function (loaders) {
55875 for (var key in loaders) {
55876 if (!loaders.hasOwnProperty(key)) {
55879 if (loaders[key]) {
55884 }), operators_1.debounceTime(100), operators_1.distinctUntilChanged());
55889 LoadingService.prototype.taskLoading$ = function (task) {
55890 return this._loaders$.pipe(operators_1.map(function (loaders) {
55891 return !!loaders[task];
55892 }), operators_1.debounceTime(100), operators_1.distinctUntilChanged());
55894 LoadingService.prototype.startLoading = function (task) {
55895 this._loadersSubject$.next({ loading: true, task: task });
55897 LoadingService.prototype.stopLoading = function (task) {
55898 this._loadersSubject$.next({ loading: false, task: task });
55900 return LoadingService;
55902 exports.LoadingService = LoadingService;
55903 exports.default = LoadingService;
55905 },{"rxjs":43,"rxjs/operators":241}],477:[function(require,module,exports){
55907 Object.defineProperty(exports, "__esModule", { value: true });
55908 exports.MouseService = void 0;
55909 var rxjs_1 = require("rxjs");
55910 var operators_1 = require("rxjs/operators");
55911 var MouseService = /** @class */ (function () {
55912 function MouseService(container, canvasContainer, domContainer, doc) {
55914 this._activeSubject$ = new rxjs_1.BehaviorSubject(false);
55915 this._active$ = this._activeSubject$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
55916 this._claimMouse$ = new rxjs_1.Subject();
55917 this._claimWheel$ = new rxjs_1.Subject();
55918 this._deferPixelClaims$ = new rxjs_1.Subject();
55919 this._deferPixels$ = this._deferPixelClaims$.pipe(operators_1.scan(function (claims, claim) {
55920 if (claim.deferPixels == null) {
55921 delete claims[claim.name];
55924 claims[claim.name] = claim.deferPixels;
55927 }, {}), operators_1.map(function (claims) {
55928 var deferPixelMax = -1;
55929 for (var key in claims) {
55930 if (!claims.hasOwnProperty(key)) {
55933 var deferPixels = claims[key];
55934 if (deferPixels > deferPixelMax) {
55935 deferPixelMax = deferPixels;
55938 return deferPixelMax;
55939 }), operators_1.startWith(-1), operators_1.publishReplay(1), operators_1.refCount());
55940 this._deferPixels$.subscribe(function () { });
55941 this._documentMouseMove$ = rxjs_1.fromEvent(doc, "mousemove");
55942 this._documentMouseUp$ = rxjs_1.fromEvent(doc, "mouseup");
55943 this._mouseDown$ = rxjs_1.fromEvent(canvasContainer, "mousedown");
55944 this._mouseLeave$ = rxjs_1.fromEvent(canvasContainer, "mouseleave");
55945 this._mouseMove$ = rxjs_1.fromEvent(canvasContainer, "mousemove");
55946 this._mouseUp$ = rxjs_1.fromEvent(canvasContainer, "mouseup");
55947 this._mouseOut$ = rxjs_1.fromEvent(canvasContainer, "mouseout");
55948 this._mouseOver$ = rxjs_1.fromEvent(canvasContainer, "mouseover");
55949 this._domMouseDown$ = rxjs_1.fromEvent(domContainer, "mousedown");
55950 this._domMouseMove$ = rxjs_1.fromEvent(domContainer, "mousemove");
55951 this._click$ = rxjs_1.fromEvent(canvasContainer, "click");
55952 this._contextMenu$ = rxjs_1.fromEvent(canvasContainer, "contextmenu");
55953 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) {
55954 var event1 = events[0];
55955 var event2 = events[1];
55956 var event3 = events[2];
55957 return event1.type === "click" &&
55958 event2.type === "click" &&
55959 event3.type === "dblclick" &&
55960 event1.target.parentNode === canvasContainer &&
55961 event2.target.parentNode === canvasContainer;
55962 }), operators_1.map(function (events) {
55964 }), operators_1.share());
55965 rxjs_1.merge(this._domMouseDown$, this._domMouseMove$, this._dblClick$, this._contextMenu$)
55966 .subscribe(function (event) {
55967 event.preventDefault();
55969 this._mouseWheel$ = rxjs_1.merge(rxjs_1.fromEvent(canvasContainer, "wheel"), rxjs_1.fromEvent(domContainer, "wheel")).pipe(operators_1.share());
55970 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) {
55971 // fire context menu on mouse up both on mac and windows
55972 return events[0].type === "mousedown" &&
55973 events[1].type === "contextmenu" &&
55974 events[2].type === "mouseup";
55975 }), operators_1.map(function (events) {
55977 }), operators_1.share());
55978 var dragStop$ = rxjs_1.merge(rxjs_1.fromEvent(window, "blur"), this._documentMouseUp$.pipe(operators_1.filter(function (e) {
55979 return e.button === 0;
55980 }))).pipe(operators_1.share());
55981 var mouseDragInitiate$ = this._createMouseDragInitiate$(this._mouseDown$, dragStop$, true).pipe(operators_1.share());
55982 this._mouseDragStart$ = this._createMouseDragStart$(mouseDragInitiate$).pipe(operators_1.share());
55983 this._mouseDrag$ = this._createMouseDrag$(mouseDragInitiate$, dragStop$).pipe(operators_1.share());
55984 this._mouseDragEnd$ = this._createMouseDragEnd$(this._mouseDragStart$, dragStop$).pipe(operators_1.share());
55985 var domMouseDragInitiate$ = this._createMouseDragInitiate$(this._domMouseDown$, dragStop$, false).pipe(operators_1.share());
55986 this._domMouseDragStart$ = this._createMouseDragStart$(domMouseDragInitiate$).pipe(operators_1.share());
55987 this._domMouseDrag$ = this._createMouseDrag$(domMouseDragInitiate$, dragStop$).pipe(operators_1.share());
55988 this._domMouseDragEnd$ = this._createMouseDragEnd$(this._domMouseDragStart$, dragStop$).pipe(operators_1.share());
55989 this._proximateClick$ = this._mouseDown$.pipe(operators_1.switchMap(function (mouseDown) {
55990 return _this._click$.pipe(operators_1.takeUntil(_this._createDeferredMouseMove$(mouseDown, _this._documentMouseMove$)), operators_1.take(1));
55991 }), operators_1.share());
55992 this._staticClick$ = this._mouseDown$.pipe(operators_1.switchMap(function (e) {
55993 return _this._click$.pipe(operators_1.takeUntil(_this._documentMouseMove$), operators_1.take(1));
55994 }), operators_1.share());
55995 this._mouseDragStart$.subscribe();
55996 this._mouseDrag$.subscribe();
55997 this._mouseDragEnd$.subscribe();
55998 this._domMouseDragStart$.subscribe();
55999 this._domMouseDrag$.subscribe();
56000 this._domMouseDragEnd$.subscribe();
56001 this._staticClick$.subscribe();
56002 this._mouseOwner$ = this._createOwner$(this._claimMouse$).pipe(operators_1.publishReplay(1), operators_1.refCount());
56003 this._wheelOwner$ = this._createOwner$(this._claimWheel$).pipe(operators_1.publishReplay(1), operators_1.refCount());
56004 this._mouseOwner$.subscribe(function () { });
56005 this._wheelOwner$.subscribe(function () { });
56007 Object.defineProperty(MouseService.prototype, "active$", {
56009 return this._active$;
56014 Object.defineProperty(MouseService.prototype, "activate$", {
56016 return this._activeSubject$;
56021 Object.defineProperty(MouseService.prototype, "documentMouseMove$", {
56023 return this._documentMouseMove$;
56028 Object.defineProperty(MouseService.prototype, "documentMouseUp$", {
56030 return this._documentMouseUp$;
56035 Object.defineProperty(MouseService.prototype, "domMouseDragStart$", {
56037 return this._domMouseDragStart$;
56042 Object.defineProperty(MouseService.prototype, "domMouseDrag$", {
56044 return this._domMouseDrag$;
56049 Object.defineProperty(MouseService.prototype, "domMouseDragEnd$", {
56051 return this._domMouseDragEnd$;
56056 Object.defineProperty(MouseService.prototype, "domMouseDown$", {
56058 return this._domMouseDown$;
56063 Object.defineProperty(MouseService.prototype, "domMouseMove$", {
56065 return this._domMouseMove$;
56070 Object.defineProperty(MouseService.prototype, "mouseOwner$", {
56072 return this._mouseOwner$;
56077 Object.defineProperty(MouseService.prototype, "mouseDown$", {
56079 return this._mouseDown$;
56084 Object.defineProperty(MouseService.prototype, "mouseMove$", {
56086 return this._mouseMove$;
56091 Object.defineProperty(MouseService.prototype, "mouseLeave$", {
56093 return this._mouseLeave$;
56098 Object.defineProperty(MouseService.prototype, "mouseOut$", {
56100 return this._mouseOut$;
56105 Object.defineProperty(MouseService.prototype, "mouseOver$", {
56107 return this._mouseOver$;
56112 Object.defineProperty(MouseService.prototype, "mouseUp$", {
56114 return this._mouseUp$;
56119 Object.defineProperty(MouseService.prototype, "click$", {
56121 return this._click$;
56126 Object.defineProperty(MouseService.prototype, "dblClick$", {
56128 return this._dblClick$;
56133 Object.defineProperty(MouseService.prototype, "contextMenu$", {
56135 return this._consistentContextMenu$;
56140 Object.defineProperty(MouseService.prototype, "mouseWheel$", {
56142 return this._mouseWheel$;
56147 Object.defineProperty(MouseService.prototype, "mouseDragStart$", {
56149 return this._mouseDragStart$;
56154 Object.defineProperty(MouseService.prototype, "mouseDrag$", {
56156 return this._mouseDrag$;
56161 Object.defineProperty(MouseService.prototype, "mouseDragEnd$", {
56163 return this._mouseDragEnd$;
56168 Object.defineProperty(MouseService.prototype, "proximateClick$", {
56170 return this._proximateClick$;
56175 Object.defineProperty(MouseService.prototype, "staticClick$", {
56177 return this._staticClick$;
56182 MouseService.prototype.claimMouse = function (name, zindex) {
56183 this._claimMouse$.next({ name: name, zindex: zindex });
56185 MouseService.prototype.unclaimMouse = function (name) {
56186 this._claimMouse$.next({ name: name, zindex: null });
56188 MouseService.prototype.deferPixels = function (name, deferPixels) {
56189 this._deferPixelClaims$.next({ name: name, deferPixels: deferPixels });
56191 MouseService.prototype.undeferPixels = function (name) {
56192 this._deferPixelClaims$.next({ name: name, deferPixels: null });
56194 MouseService.prototype.claimWheel = function (name, zindex) {
56195 this._claimWheel$.next({ name: name, zindex: zindex });
56197 MouseService.prototype.unclaimWheel = function (name) {
56198 this._claimWheel$.next({ name: name, zindex: null });
56200 MouseService.prototype.filtered$ = function (name, observable$) {
56201 return this._filtered(name, observable$, this._mouseOwner$);
56203 MouseService.prototype.filteredWheel$ = function (name, observable$) {
56204 return this._filtered(name, observable$, this._wheelOwner$);
56206 MouseService.prototype._createDeferredMouseMove$ = function (origin, mouseMove$) {
56207 return mouseMove$.pipe(operators_1.map(function (mouseMove) {
56208 var deltaX = mouseMove.clientX - origin.clientX;
56209 var deltaY = mouseMove.clientY - origin.clientY;
56210 return [mouseMove, Math.sqrt(deltaX * deltaX + deltaY * deltaY)];
56211 }), operators_1.withLatestFrom(this._deferPixels$), operators_1.filter(function (_a) {
56212 var _b = _a[0], mouseMove = _b[0], delta = _b[1], deferPixels = _a[1];
56213 return delta > deferPixels;
56214 }), operators_1.map(function (_a) {
56215 var _b = _a[0], mouseMove = _b[0], delta = _b[1], deferPixels = _a[1];
56219 MouseService.prototype._createMouseDrag$ = function (mouseDragStartInitiate$, stop$) {
56221 return mouseDragStartInitiate$.pipe(operators_1.map(function (_a) {
56222 var mouseDown = _a[0], mouseMove = _a[1];
56224 }), operators_1.switchMap(function (mouseMove) {
56225 return rxjs_1.concat(rxjs_1.of(mouseMove), _this._documentMouseMove$).pipe(operators_1.takeUntil(stop$));
56228 MouseService.prototype._createMouseDragEnd$ = function (mouseDragStart$, stop$) {
56229 return mouseDragStart$.pipe(operators_1.switchMap(function (event) {
56230 return stop$.pipe(operators_1.first());
56233 MouseService.prototype._createMouseDragStart$ = function (mouseDragStartInitiate$) {
56234 return mouseDragStartInitiate$.pipe(operators_1.map(function (_a) {
56235 var mouseDown = _a[0], mouseMove = _a[1];
56239 MouseService.prototype._createMouseDragInitiate$ = function (mouseDown$, stop$, defer) {
56241 return mouseDown$.pipe(operators_1.filter(function (mouseDown) {
56242 return mouseDown.button === 0;
56243 }), operators_1.switchMap(function (mouseDown) {
56244 return rxjs_1.combineLatest(rxjs_1.of(mouseDown), defer ?
56245 _this._createDeferredMouseMove$(mouseDown, _this._documentMouseMove$) :
56246 _this._documentMouseMove$).pipe(operators_1.takeUntil(stop$), operators_1.take(1));
56249 MouseService.prototype._createOwner$ = function (claim$) {
56250 return claim$.pipe(operators_1.scan(function (claims, claim) {
56251 if (claim.zindex == null) {
56252 delete claims[claim.name];
56255 claims[claim.name] = claim.zindex;
56258 }, {}), operators_1.map(function (claims) {
56260 var zIndexMax = -1;
56261 for (var name_1 in claims) {
56262 if (!claims.hasOwnProperty(name_1)) {
56265 if (claims[name_1] > zIndexMax) {
56266 zIndexMax = claims[name_1];
56271 }), operators_1.startWith(null));
56273 MouseService.prototype._filtered = function (name, observable$, owner$) {
56274 return observable$.pipe(operators_1.withLatestFrom(owner$), operators_1.filter(function (_a) {
56275 var item = _a[0], owner = _a[1];
56276 return owner === name;
56277 }), operators_1.map(function (_a) {
56278 var item = _a[0], owner = _a[1];
56282 return MouseService;
56284 exports.MouseService = MouseService;
56285 exports.default = MouseService;
56287 },{"rxjs":43,"rxjs/operators":241}],478:[function(require,module,exports){
56289 Object.defineProperty(exports, "__esModule", { value: true });
56290 exports.Navigator = void 0;
56291 var rxjs_1 = require("rxjs");
56292 var operators_1 = require("rxjs/operators");
56293 var API_1 = require("../API");
56294 var Graph_1 = require("../Graph");
56295 var Edge_1 = require("../Edge");
56296 var Error_1 = require("../Error");
56297 var State_1 = require("../State");
56298 var Viewer_1 = require("../Viewer");
56299 var PanService_1 = require("./PanService");
56300 var Navigator = /** @class */ (function () {
56301 function Navigator(clientId, options, token, apiV3, graphService, imageLoadingService, loadingService, stateService, cacheService, playService, panService) {
56302 this._apiV3 = apiV3 != null ? apiV3 : new API_1.APIv3(clientId, token);
56303 this._imageLoadingService = imageLoadingService != null ? imageLoadingService : new Graph_1.ImageLoadingService();
56304 this._graphService = graphService != null ?
56306 new Graph_1.GraphService(new Graph_1.Graph(this.apiV3), this._imageLoadingService);
56307 this._loadingService = loadingService != null ? loadingService : new Viewer_1.LoadingService();
56308 this._loadingName = "navigator";
56309 this._stateService = stateService != null ? stateService : new State_1.StateService(options.transitionMode);
56310 this._cacheService = cacheService != null ?
56312 new Viewer_1.CacheService(this._graphService, this._stateService);
56313 this._playService = playService != null ?
56315 new Viewer_1.PlayService(this._graphService, this._stateService);
56316 this._panService = panService != null ?
56318 new PanService_1.PanService(this._graphService, this._stateService, options.combinedPanning);
56319 this._keyRequested$ = new rxjs_1.BehaviorSubject(null);
56320 this._movedToKey$ = new rxjs_1.BehaviorSubject(null);
56321 this._request$ = null;
56322 this._requestSubscription = null;
56323 this._nodeRequestSubscription = null;
56325 Object.defineProperty(Navigator.prototype, "apiV3", {
56327 return this._apiV3;
56332 Object.defineProperty(Navigator.prototype, "cacheService", {
56334 return this._cacheService;
56339 Object.defineProperty(Navigator.prototype, "graphService", {
56341 return this._graphService;
56346 Object.defineProperty(Navigator.prototype, "imageLoadingService", {
56348 return this._imageLoadingService;
56353 Object.defineProperty(Navigator.prototype, "loadingService", {
56355 return this._loadingService;
56360 Object.defineProperty(Navigator.prototype, "movedToKey$", {
56362 return this._movedToKey$;
56367 Object.defineProperty(Navigator.prototype, "panService", {
56369 return this._panService;
56374 Object.defineProperty(Navigator.prototype, "playService", {
56376 return this._playService;
56381 Object.defineProperty(Navigator.prototype, "stateService", {
56383 return this._stateService;
56388 Navigator.prototype.moveToKey$ = function (key) {
56389 this._abortRequest("to key " + key);
56390 this._loadingService.startLoading(this._loadingName);
56391 var node$ = this._moveToKey$(key);
56392 return this._makeRequest$(node$);
56394 Navigator.prototype.moveDir$ = function (direction) {
56396 this._abortRequest("in dir " + Edge_1.EdgeDirection[direction]);
56397 this._loadingService.startLoading(this._loadingName);
56398 var node$ = this.stateService.currentNode$.pipe(operators_1.first(), operators_1.mergeMap(function (node) {
56399 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
56400 node.sequenceEdges$ :
56401 node.spatialEdges$).pipe(operators_1.first(), operators_1.map(function (status) {
56402 for (var _i = 0, _a = status.edges; _i < _a.length; _i++) {
56404 if (edge.data.direction === direction) {
56410 }), operators_1.mergeMap(function (directionKey) {
56411 if (directionKey == null) {
56412 _this._loadingService.stopLoading(_this._loadingName);
56413 return rxjs_1.throwError(new Error("Direction (" + direction + ") does not exist for current node."));
56415 return _this._moveToKey$(directionKey);
56417 return this._makeRequest$(node$);
56419 Navigator.prototype.moveCloseTo$ = function (lat, lon) {
56421 this._abortRequest("to lat " + lat + ", lon " + lon);
56422 this._loadingService.startLoading(this._loadingName);
56423 var node$ = this.apiV3.imageCloseTo$(lat, lon).pipe(operators_1.mergeMap(function (fullNode) {
56424 if (fullNode == null) {
56425 _this._loadingService.stopLoading(_this._loadingName);
56426 return rxjs_1.throwError(new Error("No image found close to lat " + lat + ", lon " + lon + "."));
56428 return _this._moveToKey$(fullNode.key);
56430 return this._makeRequest$(node$);
56432 Navigator.prototype.setFilter$ = function (filter) {
56434 this._stateService.clearNodes();
56435 return this._movedToKey$.pipe(operators_1.first(), operators_1.mergeMap(function (key) {
56437 return _this._trajectoryKeys$().pipe(operators_1.mergeMap(function (keys) {
56438 return _this._graphService.setFilter$(filter).pipe(operators_1.mergeMap(function () {
56439 return _this._cacheKeys$(keys);
56441 }), operators_1.last());
56443 return _this._keyRequested$.pipe(operators_1.first(), operators_1.mergeMap(function (requestedKey) {
56444 if (requestedKey != null) {
56445 return _this._graphService.setFilter$(filter).pipe(operators_1.mergeMap(function () {
56446 return _this._graphService.cacheNode$(requestedKey);
56449 return _this._graphService.setFilter$(filter).pipe(operators_1.map(function () {
56453 }), operators_1.map(function (node) {
56457 Navigator.prototype.setToken$ = function (token) {
56459 this._abortRequest("to set token");
56460 this._stateService.clearNodes();
56461 return this._movedToKey$.pipe(operators_1.first(), operators_1.tap(function (key) {
56462 _this._apiV3.setToken(token);
56463 }), operators_1.mergeMap(function (key) {
56464 return key == null ?
56465 _this._graphService.reset$([]) :
56466 _this._trajectoryKeys$().pipe(operators_1.mergeMap(function (keys) {
56467 return _this._graphService.reset$(keys).pipe(operators_1.mergeMap(function () {
56468 return _this._cacheKeys$(keys);
56470 }), operators_1.last(), operators_1.map(function (node) {
56475 Navigator.prototype._cacheKeys$ = function (keys) {
56477 var cacheNodes$ = keys
56478 .map(function (key) {
56479 return _this._graphService.cacheNode$(key);
56481 return rxjs_1.from(cacheNodes$).pipe(operators_1.mergeAll());
56483 Navigator.prototype._abortRequest = function (reason) {
56484 if (this._requestSubscription != null) {
56485 this._requestSubscription.unsubscribe();
56486 this._requestSubscription = null;
56488 if (this._nodeRequestSubscription != null) {
56489 this._nodeRequestSubscription.unsubscribe();
56490 this._nodeRequestSubscription = null;
56492 if (this._request$ != null) {
56493 if (!(this._request$.isStopped || this._request$.hasError)) {
56494 this._request$.error(new Error_1.AbortMapillaryError("Request aborted by a subsequent request " + reason + "."));
56496 this._request$ = null;
56499 Navigator.prototype._makeRequest$ = function (node$) {
56501 var request$ = new rxjs_1.ReplaySubject(1);
56502 this._requestSubscription = request$
56503 .subscribe(undefined, function () { });
56504 this._request$ = request$;
56505 this._nodeRequestSubscription = node$
56506 .subscribe(function (node) {
56507 _this._request$ = null;
56508 request$.next(node);
56509 request$.complete();
56510 }, function (error) {
56511 _this._request$ = null;
56512 request$.error(error);
56516 Navigator.prototype._moveToKey$ = function (key) {
56518 this._keyRequested$.next(key);
56519 return this._graphService.cacheNode$(key).pipe(operators_1.tap(function (node) {
56520 _this._stateService.setNodes([node]);
56521 _this._movedToKey$.next(node.key);
56522 }), operators_1.finalize(function () {
56523 _this._loadingService.stopLoading(_this._loadingName);
56526 Navigator.prototype._trajectoryKeys$ = function () {
56527 return this._stateService.currentState$.pipe(operators_1.first(), operators_1.map(function (frame) {
56528 return frame.state.trajectory
56529 .map(function (node) {
56536 exports.Navigator = Navigator;
56537 exports.default = Navigator;
56539 },{"../API":290,"../Edge":292,"../Error":293,"../Graph":295,"../State":298,"../Viewer":302,"./PanService":480,"rxjs":43,"rxjs/operators":241}],479:[function(require,module,exports){
56541 Object.defineProperty(exports, "__esModule", { value: true });
56542 exports.Observer = void 0;
56543 var rxjs_1 = require("rxjs");
56544 var operators_1 = require("rxjs/operators");
56545 var Viewer_1 = require("../Viewer");
56546 var Observer = /** @class */ (function () {
56547 function Observer(eventEmitter, navigator, container) {
56549 this._container = container;
56550 this._eventEmitter = eventEmitter;
56551 this._navigator = navigator;
56552 this._projection = new Viewer_1.Projection();
56553 this._started = false;
56554 this._navigable$ = new rxjs_1.Subject();
56555 // navigable and loading should always emit, also when cover is activated.
56557 .subscribe(function (navigable) {
56558 _this._eventEmitter.fire(Viewer_1.Viewer.navigablechanged, navigable);
56560 this._navigator.loadingService.loading$
56561 .subscribe(function (loading) {
56562 _this._eventEmitter.fire(Viewer_1.Viewer.loadingchanged, loading);
56565 Object.defineProperty(Observer.prototype, "started", {
56567 return this._started;
56572 Object.defineProperty(Observer.prototype, "navigable$", {
56574 return this._navigable$;
56579 Object.defineProperty(Observer.prototype, "projection", {
56581 return this._projection;
56586 Observer.prototype.project$ = function (latLon) {
56588 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentNode$, this._navigator.stateService.reference$).pipe(operators_1.first(), operators_1.map(function (_a) {
56589 var render = _a[0], node = _a[1], reference = _a[2];
56590 if (_this._projection.distanceBetweenLatLons(latLon, node.latLon) > 1000) {
56593 var canvasPoint = _this._projection.latLonToCanvas(latLon, _this._container.element, render, reference);
56594 return !!canvasPoint ?
56595 [Math.round(canvasPoint[0]), Math.round(canvasPoint[1])] :
56599 Observer.prototype.projectBasic$ = function (basicPoint) {
56601 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) {
56602 var render = _a[0], transform = _a[1];
56603 var canvasPoint = _this._projection.basicToCanvas(basicPoint, _this._container.element, render, transform);
56604 return !!canvasPoint ?
56605 [Math.round(canvasPoint[0]), Math.round(canvasPoint[1])] :
56609 Observer.prototype.startEmit = function () {
56611 if (this._started) {
56614 this._started = true;
56615 this._currentNodeSubscription = this._navigator.stateService.currentNodeExternal$
56616 .subscribe(function (node) {
56617 _this._eventEmitter.fire(Viewer_1.Viewer.nodechanged, node);
56619 this._sequenceEdgesSubscription = this._navigator.stateService.currentNodeExternal$.pipe(operators_1.switchMap(function (node) {
56620 return node.sequenceEdges$;
56622 .subscribe(function (status) {
56623 _this._eventEmitter.fire(Viewer_1.Viewer.sequenceedgeschanged, status);
56625 this._spatialEdgesSubscription = this._navigator.stateService.currentNodeExternal$.pipe(operators_1.switchMap(function (node) {
56626 return node.spatialEdges$;
56628 .subscribe(function (status) {
56629 _this._eventEmitter.fire(Viewer_1.Viewer.spatialedgeschanged, status);
56631 this._moveSubscription = rxjs_1.combineLatest(this._navigator.stateService.inMotion$, this._container.mouseService.active$, this._container.touchService.active$).pipe(operators_1.map(function (values) {
56632 return values[0] || values[1] || values[2];
56633 }), operators_1.distinctUntilChanged())
56634 .subscribe(function (started) {
56636 _this._eventEmitter.fire(Viewer_1.Viewer.movestart, null);
56639 _this._eventEmitter.fire(Viewer_1.Viewer.moveend, null);
56642 this._bearingSubscription = this._container.renderService.bearing$.pipe(operators_1.auditTime(100), operators_1.distinctUntilChanged(function (b1, b2) {
56643 return Math.abs(b2 - b1) < 1;
56645 .subscribe(function (bearing) {
56646 _this._eventEmitter.fire(Viewer_1.Viewer.bearingchanged, bearing);
56648 var mouseMove$ = this._container.mouseService.active$.pipe(operators_1.switchMap(function (active) {
56651 _this._container.mouseService.mouseMove$;
56653 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) {
56654 var _b = _a[0], type = _b[0], event = _b[1], render = _a[1], reference = _a[2], transform = _a[3];
56655 var unprojection = _this._projection.eventToUnprojection(event, _this._container.element, render, reference, transform);
56657 basicPoint: unprojection.basicPoint,
56658 latLon: unprojection.latLon,
56659 originalEvent: event,
56660 pixelPoint: unprojection.pixelPoint,
56661 target: _this._eventEmitter,
56665 .subscribe(function (event) {
56666 _this._eventEmitter.fire(event.type, event);
56668 this._positionSubscription = this._container.renderService.renderCamera$.pipe(operators_1.distinctUntilChanged(function (_a, _b) {
56669 var x1 = _a[0], y1 = _a[1];
56670 var x2 = _b[0], y2 = _b[1];
56671 return _this._closeTo(x1, x2, 1e-2) &&
56672 _this._closeTo(y1, y2, 1e-2);
56674 return rc.camera.position.toArray();
56676 .subscribe(function () {
56677 _this._eventEmitter.fire(Viewer_1.Viewer.positionchanged, {
56678 target: _this._eventEmitter,
56679 type: Viewer_1.Viewer.positionchanged,
56682 this._povSubscription = this._container.renderService.renderCamera$.pipe(operators_1.distinctUntilChanged(function (_a, _b) {
56683 var phi1 = _a[0], theta1 = _a[1];
56684 var phi2 = _b[0], theta2 = _b[1];
56685 return _this._closeTo(phi1, phi2, 1e-3) &&
56686 _this._closeTo(theta1, theta2, 1e-3);
56688 return [rc.rotation.phi, rc.rotation.theta];
56690 .subscribe(function () {
56691 _this._eventEmitter.fire(Viewer_1.Viewer.povchanged, {
56692 target: _this._eventEmitter,
56693 type: Viewer_1.Viewer.povchanged,
56696 this._fovSubscription = this._container.renderService.renderCamera$.pipe(operators_1.distinctUntilChanged(function (fov1, fov2) {
56697 return _this._closeTo(fov1, fov2, 1e-2);
56699 return rc.perspective.fov;
56701 .subscribe(function () {
56702 _this._eventEmitter.fire(Viewer_1.Viewer.fovchanged, {
56703 target: _this._eventEmitter,
56704 type: Viewer_1.Viewer.fovchanged,
56708 Observer.prototype.stopEmit = function () {
56709 if (!this.started) {
56712 this._started = false;
56713 this._bearingSubscription.unsubscribe();
56714 this._currentNodeSubscription.unsubscribe();
56715 this._fovSubscription.unsubscribe();
56716 this._moveSubscription.unsubscribe();
56717 this._positionSubscription.unsubscribe();
56718 this._povSubscription.unsubscribe();
56719 this._sequenceEdgesSubscription.unsubscribe();
56720 this._spatialEdgesSubscription.unsubscribe();
56721 this._viewerMouseEventSubscription.unsubscribe();
56722 this._bearingSubscription = null;
56723 this._currentNodeSubscription = null;
56724 this._fovSubscription = null;
56725 this._moveSubscription = null;
56726 this._positionSubscription = null;
56727 this._povSubscription = null;
56728 this._sequenceEdgesSubscription = null;
56729 this._spatialEdgesSubscription = null;
56730 this._viewerMouseEventSubscription = null;
56732 Observer.prototype.unproject$ = function (canvasPoint) {
56734 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) {
56735 var render = _a[0], reference = _a[1], transform = _a[2];
56736 var unprojection = _this._projection.canvasToUnprojection(canvasPoint, _this._container.element, render, reference, transform);
56737 return unprojection.latLon;
56740 Observer.prototype.unprojectBasic$ = function (canvasPoint) {
56742 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) {
56743 var render = _a[0], transform = _a[1];
56744 return _this._projection.canvasToBasic(canvasPoint, _this._container.element, render, transform);
56747 Observer.prototype._closeTo = function (v1, v2, absoluteTolerance) {
56748 return Math.abs(v1 - v2) <= absoluteTolerance;
56750 Observer.prototype._mapMouseEvent$ = function (type, mouseEvent$) {
56751 return mouseEvent$.pipe(operators_1.map(function (event) {
56752 return [type, event];
56757 exports.Observer = Observer;
56758 exports.default = Observer;
56760 },{"../Viewer":302,"rxjs":43,"rxjs/operators":241}],480:[function(require,module,exports){
56762 Object.defineProperty(exports, "__esModule", { value: true });
56763 exports.PanService = void 0;
56764 var rxjs_1 = require("rxjs");
56765 var operators_1 = require("rxjs/operators");
56766 var Geo = require("../geo/Geo");
56767 var GeoCoords_1 = require("../geo/GeoCoords");
56768 var GraphCalculator_1 = require("../graph/GraphCalculator");
56769 var Spatial_1 = require("../geo/Spatial");
56770 var Transform_1 = require("../geo/Transform");
56771 var ViewportCoords_1 = require("../geo/ViewportCoords");
56773 (function (PanMode) {
56774 PanMode[PanMode["Disabled"] = 0] = "Disabled";
56775 PanMode[PanMode["Enabled"] = 1] = "Enabled";
56776 PanMode[PanMode["Started"] = 2] = "Started";
56777 })(PanMode || (PanMode = {}));
56778 var PanService = /** @class */ (function () {
56779 function PanService(graphService, stateService, enabled, geoCoords, graphCalculator, spatial, viewportCoords) {
56780 this._graphService = graphService;
56781 this._stateService = stateService;
56782 this._geoCoords = !!geoCoords ? geoCoords : new GeoCoords_1.default();
56783 this._graphCalculator = !!graphCalculator ? graphCalculator : new GraphCalculator_1.default(this._geoCoords);
56784 this._spatial = !!spatial ? spatial : new Spatial_1.default();
56785 this._viewportCoords = !!viewportCoords ? viewportCoords : new ViewportCoords_1.default();
56786 this._mode = enabled !== false ? PanMode.Enabled : PanMode.Disabled;
56787 this._panNodesSubject$ = new rxjs_1.Subject();
56788 this._panNodes$ = this._panNodesSubject$.pipe(operators_1.startWith([]), operators_1.publishReplay(1), operators_1.refCount());
56789 this._panNodes$.subscribe();
56791 Object.defineProperty(PanService.prototype, "panNodes$", {
56793 return this._panNodes$;
56798 PanService.prototype.enable = function () {
56799 if (this._mode !== PanMode.Disabled) {
56802 this._mode = PanMode.Enabled;
56805 PanService.prototype.disable = function () {
56806 if (this._mode === PanMode.Disabled) {
56810 this._mode = PanMode.Disabled;
56812 PanService.prototype.start = function () {
56814 if (this._mode !== PanMode.Enabled) {
56817 var panNodes$ = this._stateService.currentNode$.pipe(operators_1.switchMap(function (current) {
56818 if (!current.merged) {
56819 return rxjs_1.of([]);
56821 var current$ = rxjs_1.of(current);
56822 var bounds = _this._graphCalculator.boundingBoxCorners(current.latLon, 20);
56823 var adjacent$ = _this._graphService
56824 .cacheBoundingBox$(bounds[0], bounds[1]).pipe(operators_1.catchError(function (error) {
56825 console.error("Failed to cache periphery bounding box (" + current.key + ")", error);
56826 return rxjs_1.empty();
56827 }), operators_1.map(function (nodes) {
56828 if (current.pano) {
56831 var potential = [];
56832 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
56833 var node = nodes_1[_i];
56834 if (node.key === current.key) {
56837 if (node.mergeCC !== current.mergeCC) {
56843 if (_this._distance(node, current) > 4) {
56846 potential.push(node);
56850 return rxjs_1.combineLatest(current$, adjacent$).pipe(operators_1.withLatestFrom(_this._stateService.reference$), operators_1.map(function (_a) {
56851 var _b = _a[0], cn = _b[0], adjacent = _b[1], reference = _a[1];
56852 var currentDirection = _this._spatial.viewingDirection(cn.rotation);
56853 var currentTranslation = Geo.computeTranslation({ lat: cn.latLon.lat, lon: cn.latLon.lon, alt: cn.alt }, cn.rotation, reference);
56854 var currentTransform = _this._createTransform(cn, currentTranslation);
56855 var currentAzimuthal = _this._spatial.wrap(_this._spatial.azimuthal(currentDirection.toArray(), currentTransform.upVector().toArray()), 0, 2 * Math.PI);
56856 var currentProjectedPoints = _this._computeProjectedPoints(currentTransform);
56857 var currentHFov = _this._computeHorizontalFov(currentProjectedPoints) / 180 * Math.PI;
56858 var preferredOverlap = Math.PI / 8;
56859 var left = undefined;
56860 var right = undefined;
56861 for (var _i = 0, adjacent_1 = adjacent; _i < adjacent_1.length; _i++) {
56862 var a = adjacent_1[_i];
56863 var translation = Geo.computeTranslation({ lat: a.latLon.lat, lon: a.latLon.lon, alt: a.alt }, a.rotation, reference);
56864 var transform = _this._createTransform(a, translation);
56865 var projectedPoints = _this._computeProjectedPoints(transform);
56866 var hFov = _this._computeHorizontalFov(projectedPoints) / 180 * Math.PI;
56867 var direction = _this._spatial.viewingDirection(a.rotation);
56868 var azimuthal = _this._spatial.wrap(_this._spatial.azimuthal(direction.toArray(), transform.upVector().toArray()), 0, 2 * Math.PI);
56869 var directionChange = _this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, direction.x, direction.y);
56870 var overlap = Number.NEGATIVE_INFINITY;
56871 if (directionChange > 0) {
56872 if (currentAzimuthal > azimuthal) {
56873 overlap = currentAzimuthal - 2 * Math.PI + currentHFov / 2 - (azimuthal - hFov / 2);
56876 overlap = currentAzimuthal + currentHFov / 2 - (azimuthal - hFov / 2);
56880 if (currentAzimuthal < azimuthal) {
56881 overlap = azimuthal + hFov / 2 - (currentAzimuthal + 2 * Math.PI - currentHFov / 2);
56884 overlap = azimuthal + hFov / 2 - (currentAzimuthal - currentHFov / 2);
56887 var nonOverlap = Math.abs(hFov - overlap);
56888 var distanceCost = _this._distance(a, cn);
56889 var timeCost = Math.min(_this._timeDifference(a, cn), 4);
56890 var overlapCost = 20 * Math.abs(overlap - preferredOverlap);
56891 var fovCost = Math.min(5, 1 / Math.min(hFov / currentHFov, 1));
56892 var nonOverlapCost = overlap > 0 ? -2 * nonOverlap : 0;
56893 var cost = distanceCost + timeCost + overlapCost + fovCost + nonOverlapCost;
56895 overlap < 0.5 * currentHFov &&
56896 overlap < 0.5 * hFov &&
56897 nonOverlap > 0.5 * currentHFov) {
56898 if (directionChange > 0) {
56900 left = [cost, a, transform, hFov];
56903 if (cost < left[0]) {
56904 left = [cost, a, transform, hFov];
56910 right = [cost, a, transform, hFov];
56913 if (cost < right[0]) {
56914 right = [cost, a, transform, hFov];
56922 panNodes.push([left[1], left[2], left[3]]);
56925 panNodes.push([right[1], right[2], right[3]]);
56928 }), operators_1.startWith([]));
56930 this._panNodesSubscription = this._stateService.currentState$.pipe(operators_1.map(function (frame) {
56931 return frame.state.nodesAhead > 0;
56932 }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (traversing) {
56933 return traversing ? rxjs_1.of([]) : panNodes$;
56935 .subscribe(function (panNodes) {
56936 _this._panNodesSubject$.next(panNodes);
56938 this._mode = PanMode.Started;
56940 PanService.prototype.stop = function () {
56941 if (this._mode !== PanMode.Started) {
56944 this._panNodesSubscription.unsubscribe();
56945 this._panNodesSubject$.next([]);
56946 this._mode = PanMode.Enabled;
56948 PanService.prototype._distance = function (node, reference) {
56949 var _a = this._geoCoords.geodeticToEnu(node.latLon.lat, node.latLon.lon, node.alt, reference.latLon.lat, reference.latLon.lon, reference.alt), x = _a[0], y = _a[1], z = _a[2];
56950 return Math.sqrt(x * x + y * y + z * z);
56952 PanService.prototype._timeDifference = function (node, reference) {
56953 return Math.abs(node.capturedAt - reference.capturedAt) / (1000 * 60 * 60 * 24 * 30);
56955 PanService.prototype._createTransform = function (node, translation) {
56956 return new Transform_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.assetsCached ? node.image : undefined, undefined, node.ck1, node.ck2, node.cameraProjection);
56958 PanService.prototype._computeProjectedPoints = function (transform) {
56959 var vertices = [[1, 0]];
56960 var directions = [[0, 0.5]];
56961 var pointsPerLine = 20;
56962 return Geo.computeProjectedPoints(transform, vertices, directions, pointsPerLine, this._viewportCoords);
56964 PanService.prototype._computeHorizontalFov = function (projectedPoints) {
56966 var fovs = projectedPoints
56967 .map(function (projectedPoint) {
56968 return _this._coordToFov(projectedPoint[0]);
56970 var fov = Math.min.apply(Math, fovs);
56973 PanService.prototype._coordToFov = function (x) {
56974 return 2 * Math.atan(x) * 180 / Math.PI;
56978 exports.PanService = PanService;
56980 },{"../geo/Geo":415,"../geo/GeoCoords":416,"../geo/Spatial":419,"../geo/Transform":420,"../geo/ViewportCoords":421,"../graph/GraphCalculator":425,"rxjs":43,"rxjs/operators":241}],481:[function(require,module,exports){
56982 Object.defineProperty(exports, "__esModule", { value: true });
56983 exports.PlayService = void 0;
56984 var rxjs_1 = require("rxjs");
56985 var operators_1 = require("rxjs/operators");
56986 var Edge_1 = require("../Edge");
56987 var Graph_1 = require("../Graph");
56988 var PlayService = /** @class */ (function () {
56989 function PlayService(graphService, stateService, graphCalculator) {
56990 this._graphService = graphService;
56991 this._stateService = stateService;
56992 this._graphCalculator = !!graphCalculator ? graphCalculator : new Graph_1.GraphCalculator();
56993 this._directionSubject$ = new rxjs_1.Subject();
56994 this._direction$ = this._directionSubject$.pipe(operators_1.startWith(Edge_1.EdgeDirection.Next), operators_1.publishReplay(1), operators_1.refCount());
56995 this._direction$.subscribe();
56996 this._playing = false;
56997 this._playingSubject$ = new rxjs_1.Subject();
56998 this._playing$ = this._playingSubject$.pipe(operators_1.startWith(this._playing), operators_1.publishReplay(1), operators_1.refCount());
56999 this._playing$.subscribe();
57001 this._speedSubject$ = new rxjs_1.Subject();
57002 this._speed$ = this._speedSubject$.pipe(operators_1.startWith(this._speed), operators_1.publishReplay(1), operators_1.refCount());
57003 this._speed$.subscribe();
57004 this._nodesAhead = this._mapNodesAhead(this._mapSpeed(this._speed));
57005 this._bridging$ = null;
57007 Object.defineProperty(PlayService.prototype, "playing", {
57009 return this._playing;
57014 Object.defineProperty(PlayService.prototype, "direction$", {
57016 return this._direction$;
57021 Object.defineProperty(PlayService.prototype, "playing$", {
57023 return this._playing$;
57028 Object.defineProperty(PlayService.prototype, "speed$", {
57030 return this._speed$;
57035 PlayService.prototype.play = function () {
57037 if (this._playing) {
57040 this._stateService.cutNodes();
57041 var stateSpeed = this._setSpeed(this._speed);
57042 this._stateService.setSpeed(stateSpeed);
57043 this._graphModeSubscription = this._speed$.pipe(operators_1.map(function (speed) {
57044 return speed > PlayService.sequenceSpeed ? Graph_1.GraphMode.Sequence : Graph_1.GraphMode.Spatial;
57045 }), operators_1.distinctUntilChanged())
57046 .subscribe(function (mode) {
57047 _this._graphService.setGraphMode(mode);
57049 this._cacheSubscription = rxjs_1.combineLatest(this._stateService.currentNode$.pipe(operators_1.map(function (node) {
57050 return [node.sequenceKey, node.key];
57051 }), operators_1.distinctUntilChanged(undefined, function (_a) {
57052 var sequenceKey = _a[0], nodeKey = _a[1];
57053 return sequenceKey;
57054 })), this._graphService.graphMode$, this._direction$).pipe(operators_1.switchMap(function (_a) {
57055 var _b = _a[0], sequenceKey = _b[0], nodeKey = _b[1], mode = _a[1], direction = _a[2];
57056 if (direction !== Edge_1.EdgeDirection.Next && direction !== Edge_1.EdgeDirection.Prev) {
57057 return rxjs_1.of([undefined, direction]);
57059 var sequence$ = (mode === Graph_1.GraphMode.Sequence ?
57060 _this._graphService.cacheSequenceNodes$(sequenceKey, nodeKey) :
57061 _this._graphService.cacheSequence$(sequenceKey)).pipe(operators_1.retry(3), operators_1.catchError(function (error) {
57062 console.error(error);
57063 return rxjs_1.of(undefined);
57065 return rxjs_1.combineLatest(sequence$, rxjs_1.of(direction));
57066 }), operators_1.switchMap(function (_a) {
57067 var sequence = _a[0], direction = _a[1];
57068 if (sequence === undefined) {
57069 return rxjs_1.empty();
57071 var sequenceKeys = sequence.keys.slice();
57072 if (direction === Edge_1.EdgeDirection.Prev) {
57073 sequenceKeys.reverse();
57075 return _this._stateService.currentState$.pipe(operators_1.map(function (frame) {
57076 return [frame.state.trajectory[frame.state.trajectory.length - 1].key, frame.state.nodesAhead];
57077 }), operators_1.scan(function (_a, _b) {
57078 var lastRequestKey = _a[0], previousRequestKeys = _a[1];
57079 var lastTrajectoryKey = _b[0], nodesAhead = _b[1];
57080 if (lastRequestKey === undefined) {
57081 lastRequestKey = lastTrajectoryKey;
57083 var lastIndex = sequenceKeys.length - 1;
57084 if (nodesAhead >= _this._nodesAhead || sequenceKeys[lastIndex] === lastRequestKey) {
57085 return [lastRequestKey, []];
57087 var current = sequenceKeys.indexOf(lastTrajectoryKey);
57088 var start = sequenceKeys.indexOf(lastRequestKey) + 1;
57089 var end = Math.min(lastIndex, current + _this._nodesAhead - nodesAhead) + 1;
57090 if (end <= start) {
57091 return [lastRequestKey, []];
57093 return [sequenceKeys[end - 1], sequenceKeys.slice(start, end)];
57094 }, [undefined, []]), operators_1.mergeMap(function (_a) {
57095 var lastRequestKey = _a[0], newRequestKeys = _a[1];
57096 return rxjs_1.from(newRequestKeys);
57098 }), operators_1.mergeMap(function (key) {
57099 return _this._graphService.cacheNode$(key).pipe(operators_1.catchError(function () {
57100 return rxjs_1.empty();
57104 this._playingSubscription = this._stateService.currentState$.pipe(operators_1.filter(function (frame) {
57105 return frame.state.nodesAhead < _this._nodesAhead;
57106 }), operators_1.distinctUntilChanged(undefined, function (frame) {
57107 return frame.state.lastNode.key;
57108 }), operators_1.map(function (frame) {
57109 var lastNode = frame.state.lastNode;
57110 var trajectory = frame.state.trajectory;
57111 var increasingTime = undefined;
57112 for (var i = trajectory.length - 2; i >= 0; i--) {
57113 var node = trajectory[i];
57114 if (node.sequenceKey !== lastNode.sequenceKey) {
57117 if (node.capturedAt !== lastNode.capturedAt) {
57118 increasingTime = node.capturedAt < lastNode.capturedAt;
57122 return [frame.state.lastNode, increasingTime];
57123 }), operators_1.withLatestFrom(this._direction$), operators_1.switchMap(function (_a) {
57124 var _b = _a[0], node = _b[0], increasingTime = _b[1], direction = _a[1];
57125 return rxjs_1.zip(([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
57126 node.sequenceEdges$ :
57127 node.spatialEdges$).pipe(operators_1.first(function (status) {
57128 return status.cached;
57129 }), operators_1.timeout(15000)), rxjs_1.of(direction)).pipe(operators_1.map(function (_a) {
57130 var s = _a[0], d = _a[1];
57131 for (var _i = 0, _b = s.edges; _i < _b.length; _i++) {
57133 if (edge.data.direction === d) {
57138 }), operators_1.switchMap(function (key) {
57139 return key != null ?
57140 _this._graphService.cacheNode$(key) :
57141 _this._bridge$(node, increasingTime).pipe(operators_1.filter(function (n) {
57146 .subscribe(function (node) {
57147 _this._stateService.appendNodes([node]);
57148 }, function (error) {
57149 console.error(error);
57152 this._clearSubscription = this._stateService.currentNode$.pipe(operators_1.bufferCount(1, 10))
57153 .subscribe(function (nodes) {
57154 _this._stateService.clearPriorNodes();
57156 this._setPlaying(true);
57157 var currentLastNodes$ = this._stateService.currentState$.pipe(operators_1.map(function (frame) {
57158 return frame.state;
57159 }), operators_1.distinctUntilChanged(function (_a, _b) {
57160 var kc1 = _a[0], kl1 = _a[1];
57161 var kc2 = _b[0], kl2 = _b[1];
57162 return kc1 === kc2 && kl1 === kl2;
57163 }, function (state) {
57164 return [state.currentNode.key, state.lastNode.key];
57165 }), operators_1.filter(function (state) {
57166 return state.currentNode.key === state.lastNode.key &&
57167 state.currentIndex === state.trajectory.length - 1;
57168 }), operators_1.map(function (state) {
57169 return state.currentNode;
57171 this._stopSubscription = rxjs_1.combineLatest(currentLastNodes$, this._direction$).pipe(operators_1.switchMap(function (_a) {
57172 var node = _a[0], direction = _a[1];
57173 var edgeStatus$ = ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
57174 node.sequenceEdges$ :
57175 node.spatialEdges$).pipe(operators_1.first(function (status) {
57176 return status.cached;
57177 }), operators_1.timeout(15000), operators_1.catchError(function (error) {
57178 console.error(error);
57179 return rxjs_1.of({ cached: false, edges: [] });
57181 return rxjs_1.combineLatest(rxjs_1.of(direction), edgeStatus$).pipe(operators_1.map(function (_a) {
57182 var d = _a[0], es = _a[1];
57183 for (var _i = 0, _b = es.edges; _i < _b.length; _i++) {
57185 if (edge.data.direction === d) {
57191 }), operators_1.mergeMap(function (hasEdge) {
57192 if (hasEdge || !_this._bridging$) {
57193 return rxjs_1.of(hasEdge);
57195 return _this._bridging$.pipe(operators_1.map(function (node) {
57196 return node != null;
57197 }), operators_1.catchError(function (error) {
57198 console.error(error);
57199 return rxjs_1.of(false);
57201 }), operators_1.first(function (hasEdge) {
57204 .subscribe(undefined, undefined, function () { _this.stop(); });
57205 if (this._stopSubscription.closed) {
57206 this._stopSubscription = null;
57209 PlayService.prototype.setDirection = function (direction) {
57210 this._directionSubject$.next(direction);
57212 PlayService.prototype.setSpeed = function (speed) {
57213 speed = Math.max(0, Math.min(1, speed));
57214 if (speed === this._speed) {
57217 var stateSpeed = this._setSpeed(speed);
57218 if (this._playing) {
57219 this._stateService.setSpeed(stateSpeed);
57221 this._speedSubject$.next(this._speed);
57223 PlayService.prototype.stop = function () {
57224 if (!this._playing) {
57227 if (!!this._stopSubscription) {
57228 if (!this._stopSubscription.closed) {
57229 this._stopSubscription.unsubscribe();
57231 this._stopSubscription = null;
57233 this._graphModeSubscription.unsubscribe();
57234 this._graphModeSubscription = null;
57235 this._cacheSubscription.unsubscribe();
57236 this._cacheSubscription = null;
57237 this._playingSubscription.unsubscribe();
57238 this._playingSubscription = null;
57239 this._clearSubscription.unsubscribe();
57240 this._clearSubscription = null;
57241 this._stateService.setSpeed(1);
57242 this._stateService.cutNodes();
57243 this._graphService.setGraphMode(Graph_1.GraphMode.Spatial);
57244 this._setPlaying(false);
57246 PlayService.prototype._bridge$ = function (node, increasingTime) {
57248 if (increasingTime === undefined) {
57249 return rxjs_1.of(null);
57251 var boundingBox = this._graphCalculator.boundingBoxCorners(node.latLon, 25);
57252 this._bridging$ = this._graphService.cacheBoundingBox$(boundingBox[0], boundingBox[1]).pipe(operators_1.mergeMap(function (nodes) {
57253 var nextNode = null;
57254 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
57255 var n = nodes_1[_i];
57256 if (n.sequenceKey === node.sequenceKey ||
57258 n.cameraUuid !== node.cameraUuid ||
57259 n.capturedAt === node.capturedAt ||
57260 n.capturedAt > node.capturedAt !== increasingTime) {
57263 var delta = Math.abs(n.capturedAt - node.capturedAt);
57264 if (delta > 15000) {
57267 if (!nextNode || delta < Math.abs(nextNode.capturedAt - node.capturedAt)) {
57271 return !!nextNode ?
57272 _this._graphService.cacheNode$(nextNode.key) :
57274 }), operators_1.finalize(function () {
57275 _this._bridging$ = null;
57276 }), operators_1.publish(), operators_1.refCount());
57277 return this._bridging$;
57279 PlayService.prototype._mapSpeed = function (speed) {
57280 var x = 2 * speed - 1;
57281 return Math.pow(10, x) - 0.2 * x;
57283 PlayService.prototype._mapNodesAhead = function (stateSpeed) {
57284 return Math.round(Math.max(10, Math.min(50, 8 + 6 * stateSpeed)));
57286 PlayService.prototype._setPlaying = function (playing) {
57287 this._playing = playing;
57288 this._playingSubject$.next(playing);
57290 PlayService.prototype._setSpeed = function (speed) {
57291 this._speed = speed;
57292 var stateSpeed = this._mapSpeed(this._speed);
57293 this._nodesAhead = this._mapNodesAhead(stateSpeed);
57296 PlayService.sequenceSpeed = 0.54;
57297 return PlayService;
57299 exports.PlayService = PlayService;
57300 exports.default = PlayService;
57302 },{"../Edge":292,"../Graph":295,"rxjs":43,"rxjs/operators":241}],482:[function(require,module,exports){
57304 Object.defineProperty(exports, "__esModule", { value: true });
57305 exports.Projection = void 0;
57306 var THREE = require("three");
57307 var Geo_1 = require("../Geo");
57308 var Spatial_1 = require("../geo/Spatial");
57309 var Projection = /** @class */ (function () {
57310 function Projection(geoCoords, viewportCoords, spatial) {
57311 this._geoCoords = !!geoCoords ? geoCoords : new Geo_1.GeoCoords();
57312 this._spatial = !!spatial ? spatial : new Spatial_1.default();
57313 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
57315 Projection.prototype.basicToCanvas = function (basicPoint, container, render, transform) {
57316 return this._viewportCoords
57317 .basicToCanvasSafe(basicPoint[0], basicPoint[1], container, transform, render.perspective);
57319 Projection.prototype.canvasToBasic = function (canvasPoint, container, render, transform) {
57320 var basicPoint = this._viewportCoords
57321 .canvasToBasic(canvasPoint[0], canvasPoint[1], container, transform, render.perspective);
57322 if (basicPoint[0] < 0 || basicPoint[0] > 1 || basicPoint[1] < 0 || basicPoint[1] > 1) {
57327 Projection.prototype.eventToUnprojection = function (event, container, render, reference, transform) {
57328 var pixelPoint = this._viewportCoords.canvasPosition(event, container);
57329 return this.canvasToUnprojection(pixelPoint, container, render, reference, transform);
57331 Projection.prototype.canvasToUnprojection = function (canvasPoint, container, render, reference, transform) {
57332 var canvasX = canvasPoint[0];
57333 var canvasY = canvasPoint[1];
57334 var _a = this._viewportCoords.canvasToViewport(canvasX, canvasY, container), viewportX = _a[0], viewportY = _a[1];
57335 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
57336 .unproject(render.perspective);
57337 var basicPoint = transform.projectBasic(point3d.toArray());
57338 if (basicPoint[0] < 0 || basicPoint[0] > 1 || basicPoint[1] < 0 || basicPoint[1] > 1) {
57341 var direction3d = point3d.clone().sub(render.camera.position).normalize();
57342 var dist = -2 / direction3d.z;
57344 if (dist > 0 && dist < 100 && !!basicPoint) {
57345 var point = direction3d.clone().multiplyScalar(dist).add(render.camera.position);
57346 var latLonArray = this._geoCoords
57347 .enuToGeodetic(point.x, point.y, point.z, reference.lat, reference.lon, reference.alt)
57349 latLon = { lat: latLonArray[0], lon: latLonArray[1] };
57351 var unprojection = {
57352 basicPoint: basicPoint,
57354 pixelPoint: [canvasX, canvasY],
57356 return unprojection;
57358 Projection.prototype.cameraToLatLon = function (render, reference) {
57359 var position = render.camera.position;
57360 var _a = this._geoCoords.enuToGeodetic(position.x, position.y, position.z, reference.lat, reference.lon, reference.alt), lat = _a[0], lon = _a[1];
57361 return { lat: lat, lon: lon };
57363 Projection.prototype.latLonToCanvas = function (latLon, container, render, reference) {
57364 var point3d = this._geoCoords.geodeticToEnu(latLon.lat, latLon.lon, 0, reference.lat, reference.lon, reference.alt);
57365 var canvas = this._viewportCoords.projectToCanvasSafe(point3d, container, render.perspective);
57368 Projection.prototype.distanceBetweenLatLons = function (latLon1, latLon2) {
57369 return this._spatial.distanceFromLatLon(latLon1.lat, latLon1.lon, latLon2.lat, latLon2.lon);
57373 exports.Projection = Projection;
57374 exports.default = Projection;
57376 },{"../Geo":294,"../geo/Spatial":419,"three":242}],483:[function(require,module,exports){
57378 Object.defineProperty(exports, "__esModule", { value: true });
57379 exports.SpriteService = void 0;
57380 var operators_1 = require("rxjs/operators");
57381 var THREE = require("three");
57382 var vd = require("virtual-dom");
57383 var rxjs_1 = require("rxjs");
57384 var Viewer_1 = require("../Viewer");
57385 var SpriteAtlas = /** @class */ (function () {
57386 function SpriteAtlas() {
57388 Object.defineProperty(SpriteAtlas.prototype, "json", {
57389 set: function (value) {
57390 this._json = value;
57395 Object.defineProperty(SpriteAtlas.prototype, "image", {
57396 set: function (value) {
57397 this._image = value;
57398 this._texture = new THREE.Texture(this._image);
57399 this._texture.minFilter = THREE.NearestFilter;
57404 Object.defineProperty(SpriteAtlas.prototype, "loaded", {
57406 return !!(this._image && this._json);
57411 SpriteAtlas.prototype.getGLSprite = function (name) {
57412 if (!this.loaded) {
57413 throw new Error("Sprites cannot be retrieved before the atlas is loaded.");
57415 var definition = this._json[name];
57417 console.warn("Sprite with key" + name + "does not exist in sprite definition.");
57418 return new THREE.Object3D();
57420 var texture = this._texture.clone();
57421 texture.needsUpdate = true;
57422 var width = this._image.width;
57423 var height = this._image.height;
57424 texture.offset.x = definition.x / width;
57425 texture.offset.y = (height - definition.y - definition.height) / height;
57426 texture.repeat.x = definition.width / width;
57427 texture.repeat.y = definition.height / height;
57428 var material = new THREE.SpriteMaterial({ map: texture });
57429 return new THREE.Sprite(material);
57431 SpriteAtlas.prototype.getDOMSprite = function (name, float) {
57432 if (!this.loaded) {
57433 throw new Error("Sprites cannot be retrieved before the atlas is loaded.");
57435 if (float == null) {
57436 float = Viewer_1.Alignment.Center;
57438 var definition = this._json[name];
57440 console.warn("Sprite with key" + name + "does not exist in sprite definition.");
57441 return vd.h("div", {}, []);
57443 var clipTop = definition.y;
57444 var clipRigth = definition.x + definition.width;
57445 var clipBottom = definition.y + definition.height;
57446 var clipLeft = definition.x;
57447 var left = -definition.x;
57448 var top = -definition.y;
57449 var height = this._image.height;
57450 var width = this._image.width;
57452 case Viewer_1.Alignment.Bottom:
57453 case Viewer_1.Alignment.Center:
57454 case Viewer_1.Alignment.Top:
57455 left -= definition.width / 2;
57457 case Viewer_1.Alignment.BottomLeft:
57458 case Viewer_1.Alignment.Left:
57459 case Viewer_1.Alignment.TopLeft:
57460 left -= definition.width;
57462 case Viewer_1.Alignment.BottomRight:
57463 case Viewer_1.Alignment.Right:
57464 case Viewer_1.Alignment.TopRight:
57469 case Viewer_1.Alignment.Center:
57470 case Viewer_1.Alignment.Left:
57471 case Viewer_1.Alignment.Right:
57472 top -= definition.height / 2;
57474 case Viewer_1.Alignment.Top:
57475 case Viewer_1.Alignment.TopLeft:
57476 case Viewer_1.Alignment.TopRight:
57477 top -= definition.height;
57479 case Viewer_1.Alignment.Bottom:
57480 case Viewer_1.Alignment.BottomLeft:
57481 case Viewer_1.Alignment.BottomRight:
57485 var pixelRatioInverse = 1 / definition.pixelRatio;
57486 clipTop *= pixelRatioInverse;
57487 clipRigth *= pixelRatioInverse;
57488 clipBottom *= pixelRatioInverse;
57489 clipLeft *= pixelRatioInverse;
57490 left *= pixelRatioInverse;
57491 top *= pixelRatioInverse;
57492 height *= pixelRatioInverse;
57493 width *= pixelRatioInverse;
57495 src: this._image.src,
57497 clip: "rect(" + clipTop + "px, " + clipRigth + "px, " + clipBottom + "px, " + clipLeft + "px)",
57498 height: height + "px",
57500 position: "absolute",
57502 width: width + "px",
57505 return vd.h("img", properties, []);
57507 return SpriteAtlas;
57509 var SpriteService = /** @class */ (function () {
57510 function SpriteService(sprite) {
57512 this._retina = window.devicePixelRatio > 1;
57513 this._spriteAtlasOperation$ = new rxjs_1.Subject();
57514 this._spriteAtlas$ = this._spriteAtlasOperation$.pipe(operators_1.startWith(function (atlas) {
57516 }), operators_1.scan(function (atlas, operation) {
57517 return operation(atlas);
57518 }, new SpriteAtlas()), operators_1.publishReplay(1), operators_1.refCount());
57519 this._spriteAtlas$.subscribe(function () { });
57520 if (sprite == null) {
57523 var format = this._retina ? "@2x" : "";
57524 var imageXmlHTTP = new XMLHttpRequest();
57525 imageXmlHTTP.open("GET", sprite + format + ".png", true);
57526 imageXmlHTTP.responseType = "arraybuffer";
57527 imageXmlHTTP.onload = function () {
57528 var image = new Image();
57529 image.onload = function () {
57530 _this._spriteAtlasOperation$.next(function (atlas) {
57531 atlas.image = image;
57535 var blob = new Blob([imageXmlHTTP.response]);
57536 image.src = window.URL.createObjectURL(blob);
57538 imageXmlHTTP.onerror = function (error) {
57539 console.error(new Error("Failed to fetch sprite sheet (" + sprite + format + ".png)"));
57541 imageXmlHTTP.send();
57542 var jsonXmlHTTP = new XMLHttpRequest();
57543 jsonXmlHTTP.open("GET", sprite + format + ".json", true);
57544 jsonXmlHTTP.responseType = "text";
57545 jsonXmlHTTP.onload = function () {
57546 var json = JSON.parse(jsonXmlHTTP.response);
57547 _this._spriteAtlasOperation$.next(function (atlas) {
57552 jsonXmlHTTP.onerror = function (error) {
57553 console.error(new Error("Failed to fetch sheet (" + sprite + format + ".json)"));
57555 jsonXmlHTTP.send();
57557 Object.defineProperty(SpriteService.prototype, "spriteAtlas$", {
57559 return this._spriteAtlas$;
57564 return SpriteService;
57566 exports.SpriteService = SpriteService;
57567 exports.default = SpriteService;
57570 },{"../Viewer":302,"rxjs":43,"rxjs/operators":241,"three":242,"virtual-dom":247}],484:[function(require,module,exports){
57572 Object.defineProperty(exports, "__esModule", { value: true });
57573 exports.TouchService = void 0;
57574 var rxjs_1 = require("rxjs");
57575 var operators_1 = require("rxjs/operators");
57576 var TouchService = /** @class */ (function () {
57577 function TouchService(canvasContainer, domContainer) {
57579 this._activeSubject$ = new rxjs_1.BehaviorSubject(false);
57580 this._active$ = this._activeSubject$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
57581 rxjs_1.fromEvent(domContainer, "touchmove")
57582 .subscribe(function (event) {
57583 event.preventDefault();
57585 this._touchStart$ = rxjs_1.fromEvent(canvasContainer, "touchstart");
57586 this._touchMove$ = rxjs_1.fromEvent(canvasContainer, "touchmove");
57587 this._touchEnd$ = rxjs_1.fromEvent(canvasContainer, "touchend");
57588 this._touchCancel$ = rxjs_1.fromEvent(canvasContainer, "touchcancel");
57589 var tapStart$ = this._touchStart$.pipe(operators_1.filter(function (te) {
57590 return te.touches.length === 1 && te.targetTouches.length === 1;
57591 }), operators_1.share());
57592 this._doubleTap$ = tapStart$.pipe(operators_1.bufferWhen(function () {
57593 return tapStart$.pipe(operators_1.first(), operators_1.switchMap(function (event) {
57594 return rxjs_1.merge(rxjs_1.timer(300), tapStart$).pipe(operators_1.take(1));
57596 }), operators_1.filter(function (events) {
57597 return events.length === 2;
57598 }), operators_1.map(function (events) {
57599 return events[events.length - 1];
57600 }), operators_1.share());
57602 .subscribe(function (event) {
57603 event.preventDefault();
57605 this._singleTouchMove$ = this._touchMove$.pipe(operators_1.filter(function (te) {
57606 return te.touches.length === 1 && te.targetTouches.length === 1;
57607 }), operators_1.share());
57608 var singleTouchStart$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
57609 return te.touches.length === 1 && te.targetTouches.length === 1;
57611 var multipleTouchStart$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
57612 return te.touches.length >= 1;
57614 var touchStop$ = rxjs_1.merge(this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
57615 return te.touches.length === 0;
57617 this._singleTouchDragStart$ = singleTouchStart$.pipe(operators_1.mergeMap(function (e) {
57618 return _this._singleTouchMove$.pipe(operators_1.takeUntil(rxjs_1.merge(touchStop$, multipleTouchStart$)), operators_1.take(1));
57620 this._singleTouchDragEnd$ = singleTouchStart$.pipe(operators_1.mergeMap(function (e) {
57621 return rxjs_1.merge(touchStop$, multipleTouchStart$).pipe(operators_1.first());
57623 this._singleTouchDrag$ = singleTouchStart$.pipe(operators_1.switchMap(function (te) {
57624 return _this._singleTouchMove$.pipe(operators_1.skip(1), operators_1.takeUntil(rxjs_1.merge(multipleTouchStart$, touchStop$)));
57626 var touchesChanged$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$);
57627 this._pinchStart$ = touchesChanged$.pipe(operators_1.filter(function (te) {
57628 return te.touches.length === 2 && te.targetTouches.length === 2;
57630 this._pinchEnd$ = touchesChanged$.pipe(operators_1.filter(function (te) {
57631 return te.touches.length !== 2 || te.targetTouches.length !== 2;
57633 this._pinchOperation$ = new rxjs_1.Subject();
57634 this._pinch$ = this._pinchOperation$.pipe(operators_1.scan(function (pinch, operation) {
57635 return operation(pinch);
57645 originalEvent: null,
57653 this._touchMove$.pipe(operators_1.filter(function (te) {
57654 return te.touches.length === 2 && te.targetTouches.length === 2;
57655 }), operators_1.map(function (te) {
57656 return function (previous) {
57657 var touch1 = te.touches[0];
57658 var touch2 = te.touches[1];
57659 var minX = Math.min(touch1.clientX, touch2.clientX);
57660 var maxX = Math.max(touch1.clientX, touch2.clientX);
57661 var minY = Math.min(touch1.clientY, touch2.clientY);
57662 var maxY = Math.max(touch1.clientY, touch2.clientY);
57663 var centerClientX = minX + (maxX - minX) / 2;
57664 var centerClientY = minY + (maxY - minY) / 2;
57665 var centerPageX = centerClientX + touch1.pageX - touch1.clientX;
57666 var centerPageY = centerClientY + touch1.pageY - touch1.clientY;
57667 var centerScreenX = centerClientX + touch1.screenX - touch1.clientX;
57668 var centerScreenY = centerClientY + touch1.screenY - touch1.clientY;
57669 var distanceX = Math.abs(touch1.clientX - touch2.clientX);
57670 var distanceY = Math.abs(touch1.clientY - touch2.clientY);
57671 var distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
57672 var distanceChange = distance - previous.distance;
57673 var changeX = distanceX - previous.distanceX;
57674 var changeY = distanceY - previous.distanceY;
57678 clientX: centerClientX,
57679 clientY: centerClientY,
57680 distance: distance,
57681 distanceChange: distanceChange,
57682 distanceX: distanceX,
57683 distanceY: distanceY,
57685 pageX: centerPageX,
57686 pageY: centerPageY,
57687 screenX: centerScreenX,
57688 screenY: centerScreenY,
57695 .subscribe(this._pinchOperation$);
57696 this._pinchChange$ = this._pinchStart$.pipe(operators_1.switchMap(function (te) {
57697 return _this._pinch$.pipe(operators_1.skip(1), operators_1.takeUntil(_this._pinchEnd$));
57700 Object.defineProperty(TouchService.prototype, "active$", {
57702 return this._active$;
57707 Object.defineProperty(TouchService.prototype, "activate$", {
57709 return this._activeSubject$;
57714 Object.defineProperty(TouchService.prototype, "doubleTap$", {
57716 return this._doubleTap$;
57721 Object.defineProperty(TouchService.prototype, "touchStart$", {
57723 return this._touchStart$;
57728 Object.defineProperty(TouchService.prototype, "touchMove$", {
57730 return this._touchMove$;
57735 Object.defineProperty(TouchService.prototype, "touchEnd$", {
57737 return this._touchEnd$;
57742 Object.defineProperty(TouchService.prototype, "touchCancel$", {
57744 return this._touchCancel$;
57749 Object.defineProperty(TouchService.prototype, "singleTouchDragStart$", {
57751 return this._singleTouchDragStart$;
57756 Object.defineProperty(TouchService.prototype, "singleTouchDrag$", {
57758 return this._singleTouchDrag$;
57763 Object.defineProperty(TouchService.prototype, "singleTouchDragEnd$", {
57765 return this._singleTouchDragEnd$;
57770 Object.defineProperty(TouchService.prototype, "pinch$", {
57772 return this._pinchChange$;
57777 Object.defineProperty(TouchService.prototype, "pinchStart$", {
57779 return this._pinchStart$;
57784 Object.defineProperty(TouchService.prototype, "pinchEnd$", {
57786 return this._pinchEnd$;
57791 return TouchService;
57793 exports.TouchService = TouchService;
57795 },{"rxjs":43,"rxjs/operators":241}],485:[function(require,module,exports){
57797 var __extends = (this && this.__extends) || (function () {
57798 var extendStatics = function (d, b) {
57799 extendStatics = Object.setPrototypeOf ||
57800 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
57801 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
57802 return extendStatics(d, b);
57804 return function (d, b) {
57805 extendStatics(d, b);
57806 function __() { this.constructor = d; }
57807 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
57810 Object.defineProperty(exports, "__esModule", { value: true });
57811 exports.Viewer = void 0;
57812 var rxjs_1 = require("rxjs");
57813 var operators_1 = require("rxjs/operators");
57814 var when = require("when");
57815 var Viewer_1 = require("../Viewer");
57816 var Utils_1 = require("../Utils");
57820 * @classdesc The Viewer object represents the navigable image viewer.
57821 * Create a Viewer by specifying a container, client ID, image key and
57822 * other options. The viewer exposes methods and events for programmatic
57825 * In the case of asynchronous methods, MapillaryJS returns promises to
57826 * the results. Notifications are always emitted through JavaScript events.
57828 * The viewer works with a few different coordinate systems.
57830 * Container pixel coordinates
57832 * Pixel coordinates are coordinates on the viewer container. The origin is
57833 * in the top left corner of the container. The axes are
57834 * directed according to the following for a viewer container with a width
57835 * of 640 pixels and height of 480 pixels.
57839 * +------------------------>
57844 * (0, 480) (640, 480)
57847 * Basic image coordinates
57849 * Basic image coordinates represents points in the original image adjusted for
57850 * orientation. They range from 0 to 1 on both axes. The origin is in the top left
57851 * corner of the image and the axes are directed
57852 * according to the following for all image types.
57856 * +------------------------>
57864 * For every camera viewing direction it is possible to convert between these
57865 * two coordinate systems for the current node. The image can be panned and
57866 * zoomed independently of the size of the viewer container resulting in
57867 * different conversion results for different viewing directions.
57869 var Viewer = /** @class */ (function (_super) {
57870 __extends(Viewer, _super);
57872 * Create a new viewer instance.
57874 * @description It is possible to initialize the viewer with or
57877 * When you want to show a specific image in the viewer from
57878 * the start you should initialize it with a key.
57880 * When you do not know the first image key at implementation
57881 * time, e.g. in a map-viewer application you should initialize
57882 * the viewer without a key and call `moveToKey` instead.
57884 * When initializing with a key the viewer is bound to that key
57885 * until the node for that key has been successfully loaded.
57886 * Also, a cover with the image of the key will be shown.
57887 * If the data for that key can not be loaded because the key is
57888 * faulty or other errors occur it is not possible to navigate
57889 * to another key because the viewer is not navigable. The viewer
57890 * becomes navigable when the data for the key has been loaded and
57891 * the image is shown in the viewer. This way of initializing
57892 * the viewer is mostly for embedding in blog posts and similar
57893 * where one wants to show a specific image initially.
57895 * If the viewer is initialized without a key (with null or
57896 * undefined) it is not bound to any particular key and it is
57897 * possible to move to any key with `viewer.moveToKey("<my-image-key>")`.
57898 * If the first move to a key fails it is possible to move to another
57899 * key. The viewer will show a black background until a move
57900 * succeeds. This way of intitializing is suited for a map-viewer
57901 * application when the initial key is not known at implementation
57904 * @param {string | HTMLElement} container - The HTML element in which
57905 * MapillaryJS will render the viewer, or the element's string `id`. The
57906 * specified element must have no children.
57907 * @param {string} clientId - Required `Mapillary API ClientID`. Can
57908 * be obtained from https://www.mapillary.com/app/settings/developers.
57909 * @param {string} key - Optional `image-key` to start from. The key
57910 * can be any Mapillary image. If a key is provided the viewer is
57911 * bound to that key until it has been fully loaded. If null is provided
57912 * no image is loaded at viewer initialization and the viewer is not
57913 * bound to any particular key. Any image can then be navigated to
57914 * with e.g. `viewer.moveToKey("<my-image-key>")`.
57915 * @param {IViewerOptions} options - Optional configuration object
57916 * specifing Viewer's and the components' initial setup.
57917 * @param {string} token - Optional bearer token for API requests of
57918 * protected resources.
57922 * var viewer = new Mapillary.Viewer("<element-id>", "<client-id>", "<image-key>");
57925 function Viewer(container, clientId, key, options, token) {
57926 var _this = _super.call(this) || this;
57927 options = options != null ? options : {};
57928 Utils_1.Settings.setOptions(options);
57929 Utils_1.Urls.setOptions(options.url);
57930 _this._navigator = new Viewer_1.Navigator(clientId, options, token);
57931 _this._container = new Viewer_1.Container(container, _this._navigator.stateService, options);
57932 _this._observer = new Viewer_1.Observer(_this, _this._navigator, _this._container);
57933 _this._componentController = new Viewer_1.ComponentController(_this._container, _this._navigator, _this._observer, key, options.component);
57936 Object.defineProperty(Viewer.prototype, "isNavigable", {
57938 * Return a boolean indicating if the viewer is in a navigable state.
57940 * @description The navigable state indicates if the viewer supports
57941 * moving, i.e. calling the {@link moveToKey}, {@link moveDir}
57942 * and {@link moveCloseTo} methods or changing the authentication state,
57943 * i.e. calling {@link setAuthToken}. The viewer will not be in a navigable
57944 * state if the cover is activated and the viewer has been supplied a key.
57945 * When the cover is deactivated or the viewer is activated without being
57946 * supplied a key it will be navigable.
57948 * @returns {boolean} Boolean indicating whether the viewer is navigable.
57951 return this._componentController.navigable;
57957 * Activate the combined panning functionality.
57959 * @description The combined panning functionality is active by default.
57961 Viewer.prototype.activateCombinedPanning = function () {
57962 this._navigator.panService.enable();
57965 * Activate a component.
57967 * @param {string} name - Name of the component which will become active.
57971 * viewer.activateComponent("marker");
57974 Viewer.prototype.activateComponent = function (name) {
57975 this._componentController.activate(name);
57978 * Activate the cover (deactivates all other components).
57980 Viewer.prototype.activateCover = function () {
57981 this._componentController.activateCover();
57984 * Deactivate the combined panning functionality.
57986 * @description Deactivating the combined panning functionality
57987 * could be needed in scenarios involving sequence only navigation.
57989 Viewer.prototype.deactivateCombinedPanning = function () {
57990 this._navigator.panService.disable();
57993 * Deactivate a component.
57995 * @param {string} name - Name of component which become inactive.
57999 * viewer.deactivateComponent("mouse");
58002 Viewer.prototype.deactivateComponent = function (name) {
58003 this._componentController.deactivate(name);
58006 * Deactivate the cover (activates all components marked as active).
58008 Viewer.prototype.deactivateCover = function () {
58009 this._componentController.deactivateCover();
58012 * Get the bearing of the current viewer camera.
58014 * @description The bearing depends on how the camera
58015 * is currently rotated and does not correspond
58016 * to the compass angle of the current node if the view
58019 * Bearing is measured in degrees clockwise with respect to
58022 * @returns {Promise<number>} Promise to the bearing
58023 * of the current viewer camera.
58027 * viewer.getBearing().then((b) => { console.log(b); });
58030 Viewer.prototype.getBearing = function () {
58032 return when.promise(function (resolve, reject) {
58033 _this._container.renderService.bearing$.pipe(operators_1.first())
58034 .subscribe(function (bearing) {
58036 }, function (error) {
58042 * Returns the HTML element containing the viewer's <canvas> element.
58044 * @description This is the element to which event bindings for viewer
58045 * interactivity (such as panning and zooming) are attached.
58047 * @returns {HTMLElement} The container viewer's <canvas> element.
58049 Viewer.prototype.getCanvasContainer = function () {
58050 return this._container.canvasContainer;
58053 * Get the basic coordinates of the current image that is
58054 * at the center of the viewport.
58056 * @description Basic coordinates are 2D coordinates on the [0, 1] interval
58057 * and have the origin point, (0, 0), at the top left corner and the
58058 * maximum value, (1, 1), at the bottom right corner of the original
58061 * @returns {Promise<number[]>} Promise to the basic coordinates
58062 * of the current image at the center for the viewport.
58066 * viewer.getCenter().then((c) => { console.log(c); });
58069 Viewer.prototype.getCenter = function () {
58071 return when.promise(function (resolve, reject) {
58072 _this._navigator.stateService.getCenter()
58073 .subscribe(function (center) {
58075 }, function (error) {
58083 * @param {string} name - Name of component.
58084 * @returns {Component} The requested component.
58088 * var mouseComponent = viewer.getComponent("mouse");
58091 Viewer.prototype.getComponent = function (name) {
58092 return this._componentController.get(name);
58095 * Returns the viewer's containing HTML element.
58097 * @returns {HTMLElement} The viewer's container.
58099 Viewer.prototype.getContainer = function () {
58100 return this._container.element;
58103 * Get the viewer's current vertical field of view.
58105 * @description The vertical field of view rendered on the viewer canvas
58106 * measured in degrees.
58108 * @returns {Promise<number>} Promise to the current field of view
58109 * of the viewer camera.
58113 * viewer.getFieldOfView().then((fov) => { console.log(fov); });
58116 Viewer.prototype.getFieldOfView = function () {
58118 return when.promise(function (resolve, reject) {
58119 _this._container.renderService.renderCamera$.pipe(operators_1.first())
58120 .subscribe(function (rc) {
58121 resolve(rc.perspective.fov);
58122 }, function (error) {
58128 * Get the viewer's current point of view.
58130 * @returns {Promise<IPointOfView>} Promise to the current point of view
58131 * of the viewer camera.
58135 * viewer.getPointOfView().then((pov) => { console.log(pov); });
58138 Viewer.prototype.getPointOfView = function () {
58140 return when.promise(function (resolve, reject) {
58141 rxjs_1.combineLatest(_this._container.renderService.renderCamera$, _this._container.renderService.bearing$).pipe(operators_1.first())
58142 .subscribe(function (_a) {
58143 var rc = _a[0], bearing = _a[1];
58146 tilt: rc.getTilt(),
58148 }, function (error) {
58154 * Get the viewer's current position
58156 * @returns {Promise<ILatLon>} Promise to the viewers's current
58161 * viewer.getPosition().then((pos) => { console.log(pos); });
58164 Viewer.prototype.getPosition = function () {
58166 return when.promise(function (resolve, reject) {
58167 rxjs_1.combineLatest(_this._container.renderService.renderCamera$, _this._navigator.stateService.reference$).pipe(operators_1.first())
58168 .subscribe(function (_a) {
58169 var render = _a[0], reference = _a[1];
58170 resolve(_this._observer.projection.cameraToLatLon(render, reference));
58171 }, function (error) {
58177 * Get the image's current zoom level.
58179 * @returns {Promise<number>} Promise to the viewers's current
58184 * viewer.getZoom().then((z) => { console.log(z); });
58187 Viewer.prototype.getZoom = function () {
58189 return when.promise(function (resolve, reject) {
58190 _this._navigator.stateService.getZoom()
58191 .subscribe(function (zoom) {
58193 }, function (error) {
58199 * Move close to given latitude and longitude.
58201 * @description Because the method propagates IO errors, these potential errors
58202 * need to be handled by the method caller (see example).
58204 * @param {Number} lat - Latitude, in degrees.
58205 * @param {Number} lon - Longitude, in degrees.
58206 * @returns {Promise<Node>} Promise to the node that was navigated to.
58207 * @throws {Error} If no nodes exist close to provided latitude
58209 * @throws {Error} Propagates any IO errors to the caller.
58210 * @throws {Error} When viewer is not navigable.
58211 * @throws {@link AbortMapillaryError} When a subsequent move request is made
58212 * before the move close to call has completed.
58216 * viewer.moveCloseTo(0, 0).then(
58217 * (n) => { console.log(n); },
58218 * (e) => { console.error(e); });
58221 Viewer.prototype.moveCloseTo = function (lat, lon) {
58222 var moveCloseTo$ = this.isNavigable ?
58223 this._navigator.moveCloseTo$(lat, lon) :
58224 rxjs_1.throwError(new Error("Calling moveCloseTo is not supported when viewer is not navigable."));
58225 return when.promise(function (resolve, reject) {
58226 moveCloseTo$.subscribe(function (node) {
58228 }, function (error) {
58234 * Navigate in a given direction.
58236 * @description This method has to be called through EdgeDirection enumeration as in the example.
58238 * @param {EdgeDirection} dir - Direction in which which to move.
58239 * @returns {Promise<Node>} Promise to the node that was navigated to.
58240 * @throws {Error} If the current node does not have the edge direction
58241 * or the edges has not yet been cached.
58242 * @throws {Error} Propagates any IO errors to the caller.
58243 * @throws {Error} When viewer is not navigable.
58244 * @throws {@link AbortMapillaryError} When a subsequent move request is made
58245 * before the move dir call has completed.
58249 * viewer.moveDir(Mapillary.EdgeDirection.Next).then(
58250 * (n) => { console.log(n); },
58251 * (e) => { console.error(e); });
58254 Viewer.prototype.moveDir = function (dir) {
58255 var moveDir$ = this.isNavigable ?
58256 this._navigator.moveDir$(dir) :
58257 rxjs_1.throwError(new Error("Calling moveDir is not supported when viewer is not navigable."));
58258 return when.promise(function (resolve, reject) {
58259 moveDir$.subscribe(function (node) {
58261 }, function (error) {
58267 * Navigate to a given image key.
58269 * @param {string} key - A valid Mapillary image key.
58270 * @returns {Promise<Node>} Promise to the node that was navigated to.
58271 * @throws {Error} Propagates any IO errors to the caller.
58272 * @throws {Error} When viewer is not navigable.
58273 * @throws {@link AbortMapillaryError} When a subsequent move request is made
58274 * before the move to key call has completed.
58278 * viewer.moveToKey("<my key>").then(
58279 * (n) => { console.log(n); },
58280 * (e) => { console.error(e); });
58283 Viewer.prototype.moveToKey = function (key) {
58284 var moveToKey$ = this.isNavigable ?
58285 this._navigator.moveToKey$(key) :
58286 rxjs_1.throwError(new Error("Calling moveToKey is not supported when viewer is not navigable."));
58287 return when.promise(function (resolve, reject) {
58288 moveToKey$.subscribe(function (node) {
58290 }, function (error) {
58296 * Project an ILatLon representing geographicalcoordinates to
58297 * canvas pixel coordinates.
58299 * @description The geographical coordinates may not always correspond to pixel
58300 * coordinates, e.g. if the geographical coordinates have a position behind the
58301 * viewer camera. In the case of no correspondence the returned value will
58304 * If the distance from the viewer camera position to the provided lat-lon
58305 * is more than 1000 meters `null` will be returned.
58307 * The projection is performed from the ground plane, i.e.
58308 * the altitude with respect to the ground plane for the geographical
58311 * Note that whenever the camera moves, the result of the method will be
58314 * @param {ILatLon} latLon - Geographical coordinates to project.
58315 * @returns {Promise<Array<number>>} Promise to the pixel coordinates corresponding
58320 * viewer.project({ lat: 0, lon: 0 })
58321 * .then((pixelPoint) => {
58322 * if (!pixelPoint) {
58323 * console.log("no correspondence");
58326 * console.log(pixelPoint);
58330 Viewer.prototype.project = function (latLon) {
58332 return when.promise(function (resolve, reject) {
58333 _this._observer.project$(latLon)
58334 .subscribe(function (pixelPoint) {
58335 resolve(pixelPoint);
58336 }, function (error) {
58342 * Project basic image coordinates for the current node to canvas pixel
58345 * @description The basic image coordinates may not always correspond to a
58346 * pixel point that lies in the visible area of the viewer container. In the
58347 * case of no correspondence the returned value can be `null`.
58350 * @param {Array<number>} basicPoint - Basic images coordinates to project.
58351 * @returns {Promise<Array<number>>} Promise to the pixel coordinates corresponding
58352 * to the basic image point.
58356 * viewer.projectFromBasic([0.3, 0.7])
58357 * .then((pixelPoint) => { console.log(pixelPoint); });
58360 Viewer.prototype.projectFromBasic = function (basicPoint) {
58362 return when.promise(function (resolve, reject) {
58363 _this._observer.projectBasic$(basicPoint)
58364 .subscribe(function (pixelPoint) {
58365 resolve(pixelPoint);
58366 }, function (error) {
58372 * Detect the viewer's new width and height and resize it.
58374 * @description The components will also detect the viewer's
58375 * new size and resize their rendered elements if needed.
58382 Viewer.prototype.resize = function () {
58383 this._container.renderService.resize$.next(null);
58386 * Set a bearer token for authenticated API requests of
58387 * protected resources.
58389 * @description When the supplied token is null or undefined,
58390 * any previously set bearer token will be cleared and the
58391 * viewer will make unauthenticated requests.
58393 * Calling setAuthToken aborts all outstanding move requests.
58394 * The promises of those move requests will be rejected with a
58395 * {@link AbortMapillaryError} the rejections need to be caught.
58397 * Calling setAuthToken also resets the complete viewer cache
58398 * so it should not be called repeatedly.
58400 * @param {string} [token] token - Bearer token.
58401 * @returns {Promise<void>} Promise that resolves after token
58404 * @throws {Error} When viewer is not navigable.
58408 * viewer.setAuthToken("<my token>")
58409 * .then(() => { console.log("token set"); });
58412 Viewer.prototype.setAuthToken = function (token) {
58413 var setToken$ = this.isNavigable ?
58414 this._navigator.setToken$(token) :
58415 rxjs_1.throwError(new Error("Calling setAuthToken is not supported when viewer is not navigable."));
58416 return when.promise(function (resolve, reject) {
58418 .subscribe(function () {
58419 resolve(undefined);
58420 }, function (error) {
58426 * Set the basic coordinates of the current image to be in the
58427 * center of the viewport.
58429 * @description Basic coordinates are 2D coordinates on the [0, 1] interval
58430 * and has the origin point, (0, 0), at the top left corner and the
58431 * maximum value, (1, 1), at the bottom right corner of the original
58434 * @param {number[]} The basic coordinates of the current
58435 * image to be at the center for the viewport.
58439 * viewer.setCenter([0.5, 0.5]);
58442 Viewer.prototype.setCenter = function (center) {
58443 this._navigator.stateService.setCenter(center);
58446 * Set the filter selecting nodes to use when calculating
58447 * the spatial edges.
58449 * @description The following filter types are supported:
58453 * `["==", key, value]` equality: `node[key] = value`
58455 * `["!=", key, value]` inequality: `node[key] ≠value`
58457 * `["<", key, value]` less than: `node[key] < value`
58459 * `["<=", key, value]` less than or equal: `node[key] ≤ value`
58461 * `[">", key, value]` greater than: `node[key] > value`
58463 * `[">=", key, value]` greater than or equal: `node[key] ≥ value`
58467 * `["in", key, v0, ..., vn]` set inclusion: `node[key] ∈ {v0, ..., vn}`
58469 * `["!in", key, v0, ..., vn]` set exclusion: `node[key] ∉ {v0, ..., vn}`
58473 * `["all", f0, ..., fn]` logical `AND`: `f0 ∧ ... ∧ fn`
58475 * A key must be a string that identifies a property name of a
58476 * simple {@link Node} property. A value must be a string, number, or
58477 * boolean. Strictly-typed comparisons are used. The values
58478 * `f0, ..., fn` of the combining filter must be filter expressions.
58480 * Clear the filter by setting it to null or empty array.
58482 * Commonly used filter properties (see the {@link Node} class
58483 * documentation for a full list of properties that can be used
58484 * in a filter) and common use cases:
58487 * fullPano // Show only full 360 panoramas or not
58488 * organizationKey // Show images from one or several organizations
58489 * sequenceKey // Show images from one or several sequences
58490 * userKey // Show images from one or several users
58491 * capturedAt // Show images from a certain time interval
58494 * @param {FilterExpression} filter - The filter expression.
58495 * @returns {Promise<void>} Promise that resolves after filter is applied.
58499 * viewer.setFilter(["==", "sequenceKey", "<my sequence key>"]);
58501 * // Other examples
58502 * // viewer.setFilter(["==", "organizationKey", "<my organization key>"]);
58503 * // viewer.setFilter(["in", "userKey", "<my user key #1>", "<my user key #2>"]);
58504 * // viewer.setFilter(["==", "fullPano", true]);
58505 * // viewer.setFilter([">=", "capturedAt", <my time stamp>]);
58508 Viewer.prototype.setFilter = function (filter) {
58510 return when.promise(function (resolve, reject) {
58511 _this._navigator.setFilter$(filter)
58512 .subscribe(function () {
58513 resolve(undefined);
58514 }, function (error) {
58520 * Set the viewer's current vertical field of view.
58522 * @description Sets the vertical field of view rendered
58523 * on the viewer canvas measured in degrees. The value
58524 * will be clamped to be able to set a valid zoom level
58525 * based on the projection model of the current image and
58526 * the viewer's current render mode.
58528 * @param {number} fov - Vertical field of view in degrees.
58532 * viewer.setFieldOfView(45);
58535 Viewer.prototype.setFieldOfView = function (fov) {
58537 this._container.renderService.renderCamera$.pipe(operators_1.first())
58538 .subscribe(function (rc) {
58539 var zoom = rc.fovToZoom(fov);
58540 _this._navigator.stateService.setZoom(zoom);
58544 * Set the viewer's render mode.
58546 * @param {RenderMode} renderMode - Render mode.
58550 * viewer.setRenderMode(Mapillary.RenderMode.Letterbox);
58553 Viewer.prototype.setRenderMode = function (renderMode) {
58554 this._container.renderService.renderMode$.next(renderMode);
58557 * Set the viewer's transition mode.
58559 * @param {TransitionMode} transitionMode - Transition mode.
58563 * viewer.setTransitionMode(Mapillary.TransitionMode.Instantaneous);
58566 Viewer.prototype.setTransitionMode = function (transitionMode) {
58567 this._navigator.stateService.setTransitionMode(transitionMode);
58570 * Set the image's current zoom level.
58572 * @description Possible zoom level values are on the [0, 3] interval.
58573 * Zero means zooming out to fit the image to the view whereas three
58574 * shows the highest level of detail.
58576 * @param {number} The image's current zoom level.
58580 * viewer.setZoom(2);
58583 Viewer.prototype.setZoom = function (zoom) {
58584 this._navigator.stateService.setZoom(zoom);
58587 * Unproject canvas pixel coordinates to an ILatLon representing geographical
58590 * @description The pixel point may not always correspond to geographical
58591 * coordinates. In the case of no correspondence the returned value will
58594 * The unprojection to a latLon will be performed towards the ground plane, i.e.
58595 * the altitude with respect to the ground plane for the returned latLon is zero.
58597 * @param {Array<number>} pixelPoint - Pixel coordinates to unproject.
58598 * @returns {Promise<ILatLon>} Promise to the latLon corresponding to the pixel point.
58602 * viewer.unproject([100, 100])
58603 * .then((latLon) => { console.log(latLon); });
58606 Viewer.prototype.unproject = function (pixelPoint) {
58608 return when.promise(function (resolve, reject) {
58609 _this._observer.unproject$(pixelPoint)
58610 .subscribe(function (latLon) {
58612 }, function (error) {
58618 * Unproject canvas pixel coordinates to basic image coordinates for the
58621 * @description The pixel point may not always correspond to basic image
58622 * coordinates. In the case of no correspondence the returned value will
58625 * @param {Array<number>} pixelPoint - Pixel coordinates to unproject.
58626 * @returns {Promise<ILatLon>} Promise to the basic coordinates corresponding
58627 * to the pixel point.
58631 * viewer.unprojectToBasic([100, 100])
58632 * .then((basicPoint) => { console.log(basicPoint); });
58635 Viewer.prototype.unprojectToBasic = function (pixelPoint) {
58637 return when.promise(function (resolve, reject) {
58638 _this._observer.unprojectBasic$(pixelPoint)
58639 .subscribe(function (basicPoint) {
58640 resolve(basicPoint);
58641 }, function (error) {
58647 * Fired when the viewing direction of the camera changes.
58649 * @description Related to the computed compass angle
58650 * ({@link Node.computedCA}) from SfM, not the original EXIF compass
58654 * @type {number} bearing - Value indicating the current bearing
58655 * measured in degrees clockwise with respect to north.
58657 Viewer.bearingchanged = "bearingchanged";
58659 * Fired when a pointing device (usually a mouse) is pressed and released at
58660 * the same point in the viewer.
58662 * @type {@link IViewerMouseEvent} event - Viewer mouse event data.
58664 Viewer.click = "click";
58666 * Fired when the right button of the mouse is clicked within the viewer.
58668 * @type {@link IViewerMouseEvent} event - Viewer mouse event data.
58670 Viewer.contextmenu = "contextmenu";
58672 * Fired when a pointing device (usually a mouse) is clicked twice at
58673 * the same point in the viewer.
58675 * @type {@link IViewerMouseEvent} event - Viewer mouse event data.
58677 Viewer.dblclick = "dblclick";
58679 * Fired when the viewer's vertical field of view changes.
58682 * @type {@link IViewerEvent} event - The event object.
58684 Viewer.fovchanged = "fovchanged";
58686 * Fired when the viewer is loading more data.
58688 * @type {boolean} loading - Boolean indicating whether the viewer is loading.
58690 Viewer.loadingchanged = "loadingchanged";
58692 * Fired when a pointing device (usually a mouse) is pressed within the viewer.
58694 * @type {@link IViewerMouseEvent} event - Viewer mouse event data.
58696 Viewer.mousedown = "mousedown";
58698 * Fired when a pointing device (usually a mouse) is moved within the viewer.
58699 * @description Will not fire when the mouse is actively used, e.g. for drag pan.
58701 * @type {@link IViewerMouseEvent} event - Viewer mouse event data.
58703 Viewer.mousemove = "mousemove";
58705 * Fired when a pointing device (usually a mouse) leaves the viewer's canvas.
58707 * @type {@link IViewerMouseEvent} event - Viewer mouse event data.
58709 Viewer.mouseout = "mouseout";
58711 * Fired when a pointing device (usually a mouse) is moved onto the viewer's canvas.
58713 * @type {@link IViewerMouseEvent} event - Viewer mouse event data.
58715 Viewer.mouseover = "mouseover";
58717 * Fired when a pointing device (usually a mouse) is released within the viewer.
58719 * @type {@link IViewerMouseEvent} event - Viewer mouse event data.
58721 Viewer.mouseup = "mouseup";
58723 * Fired when the viewer motion stops and it is in a fixed
58724 * position with a fixed point of view.
58727 Viewer.moveend = "moveend";
58729 * Fired when the motion from one view to another start,
58730 * either by changing the position (e.g. when changing node) or
58731 * when changing point of view (e.g. by interaction such as pan and zoom).
58734 Viewer.movestart = "movestart";
58736 * Fired when the navigable state of the viewer changes.
58738 * @description The navigable state indicates if the viewer supports
58739 * moving, i.e. calling the `moveToKey`, `moveDir` and `moveCloseTo`
58740 * methods. The viewer will not be in a navigable state if the cover
58741 * is activated and the viewer has been supplied a key. When the cover
58742 * is deactivated or activated without being supplied a key it will
58746 * @type {boolean} navigable - Boolean indicating whether the viewer is navigable.
58748 Viewer.navigablechanged = "navigablechanged";
58750 * Fired every time the viewer navigates to a new node.
58753 * @type {@link Node} node - Current node.
58755 Viewer.nodechanged = "nodechanged";
58757 * Fired when the viewer's position changes.
58759 * @description The viewer's position changes when transitioning
58763 * @type {@link IViewerEvent} event - The event object.
58765 Viewer.positionchanged = "positionchanged";
58767 * Fired when the viewer's point of view changes. The point of view changes
58768 * when the bearing, or tilt changes.
58771 * @type {@link IViewerEvent} event - The event object.
58773 Viewer.povchanged = "povchanged";
58775 * Fired every time the sequence edges of the current node changes.
58777 * @type {@link IEdgeStatus} status - The edge status object.
58779 Viewer.sequenceedgeschanged = "sequenceedgeschanged";
58781 * Fired every time the spatial edges of the current node changes.
58783 * @type {@link IEdgeStatus} status - The edge status object.
58785 Viewer.spatialedgeschanged = "spatialedgeschanged";
58787 }(Utils_1.EventEmitter));
58788 exports.Viewer = Viewer;
58790 },{"../Utils":301,"../Viewer":302,"rxjs":43,"rxjs/operators":241,"when":288}],486:[function(require,module,exports){
58792 Object.defineProperty(exports, "__esModule", { value: true });
58794 },{}]},{},[296])(296)
58796 //# sourceMappingURL=mapillary.js.map